Skip to content

Commit

Permalink
chore(gatsby): Drop (experimental) support for Loki
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdz committed May 7, 2020
1 parent 649b4dd commit 59c7287
Show file tree
Hide file tree
Showing 56 changed files with 430 additions and 2,100 deletions.
3 changes: 0 additions & 3 deletions integration-tests/cache-resilience/utils/load-state.js
Expand Up @@ -45,9 +45,6 @@ const sanitiseNode = value => {
// we don't care about order of node creation at this point
delete value.internal.counter

// loki adds $loki metadata into nodes
delete value.$loki

return value
}

Expand Down
Expand Up @@ -17,24 +17,6 @@ Object {
}
`;

exports[`npm package resource e2e npm package resource test: NPMPackage destroy 1`] = `
Object {
"_message": "Installed NPM package is-sorted@1.0.2",
"id": "is-sorted",
"name": "is-sorted",
"version": "1.0.2",
}
`;

exports[`npm package resource e2e npm package resource test: NPMPackage update 1`] = `
Object {
"_message": "Installed NPM package is-sorted@1.0.2",
"id": "is-sorted",
"name": "is-sorted",
"version": "1.0.2",
}
`;

exports[`npm package resource e2e npm package resource test: NPMPackage update plan 1`] = `
Object {
"currentState": "is-sorted@1.0.0",
Expand Down
4 changes: 0 additions & 4 deletions packages/gatsby-telemetry/src/telemetry.js
Expand Up @@ -196,11 +196,7 @@ module.exports = class AnalyticsTracker {
}

getDbEngine() {
// if (process.env.GATSBY_DB_NODES === `loki`) {
// return `loki`
// } else {
return `redux`
// }
}

getMachineId() {
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/package.json
Expand Up @@ -94,7 +94,6 @@
"json-stringify-safe": "^5.0.1",
"latest-version": "5.1.0",
"lodash": "^4.17.15",
"lokijs": "^1.5.8",
"md5": "^2.2.1",
"md5-file": "^3.2.3",
"micromatch": "^3.1.10",
Expand Down
22 changes: 0 additions & 22 deletions packages/gatsby/src/bootstrap/index.js
Expand Up @@ -282,28 +282,6 @@ module.exports = async (args: BootstrapArgs) => {

activity.end()

// if (process.env.GATSBY_DB_NODES === `loki`) {
// const loki = require(`../db/loki`)
// // Start the nodes database (in memory loki js with interval disk
// // saves). If data was saved from a previous build, it will be
// // loaded here
// activity = report.activityTimer(`start nodes db`, {
// parentSpan: bootstrapSpan,
// })
// activity.start()
// const dbSaveFile = `${cacheDirectory}/loki/loki.db`
// try {
// await loki.start({
// saveFile: dbSaveFile,
// })
// } catch (e) {
// report.error(
// `Error starting DB. Perhaps try deleting ${path.dirname(dbSaveFile)}`
// )
// }
// activity.end()
// }

activity = report.activityTimer(`copy gatsby files`, {
parentSpan: bootstrapSpan,
})
Expand Down
11 changes: 0 additions & 11 deletions packages/gatsby/src/db/__tests__/fixtures/ensure-loki.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/gatsby/src/db/__tests__/nodes.js
@@ -1,7 +1,6 @@
const { actions } = require(`../../redux/actions`)
const { getNode, getNodes } = require(`../nodes`)
const { store } = require(`../../redux`)
require(`./fixtures/ensure-loki`)()

const report = require(`gatsby-cli/lib/reporter`)
jest.mock(`gatsby-cli/lib/reporter`)
Expand Down
45 changes: 0 additions & 45 deletions packages/gatsby/src/db/common/query.ts
Expand Up @@ -122,8 +122,6 @@ export function dbQueryToSiftQuery(query: DbQuery): object {
return result
}

// Most of the below can be gone after we decide to remove loki

// Converts a nested mongo args object into a dotted notation. acc
// (accumulator) must be a reference to an empty object. The converted
// fields will be added to it. E.g
Expand Down Expand Up @@ -155,24 +153,6 @@ export function dbQueryToSiftQuery(query: DbQuery): object {
// $regex: // as above
// }
// }
export function toDottedFields(
filter: object,
acc: object = {},
path: Array<string> = []
): object {
Object.keys(filter).forEach(key => {
const value = filter[key]
const nextValue = _.isPlainObject(value) && value[Object.keys(value)[0]]
if (key === `$elemMatch`) {
acc[path.join(`.`)] = { [`$elemMatch`]: toDottedFields(value) }
} else if (_.isPlainObject(nextValue)) {
toDottedFields(value, acc, path.concat(key))
} else {
acc[path.concat(key).join(`.`)] = value
}
})
return acc
}

// Like above, but doesn't handle $elemMatch
export function objectToDottedField(
Expand All @@ -194,28 +174,3 @@ export function objectToDottedField(
})
return result
}

export function liftResolvedFields(
args: object,
resolvedFields: object
): object {
const dottedFields = objectToDottedField(resolvedFields)
const dottedFieldKeys = Object.keys(dottedFields)
const finalArgs = {}
Object.keys(args).forEach(key => {
const value = args[key]
if (dottedFields[key]) {
finalArgs[`__gatsby_resolved.${key}`] = value
} else if (
dottedFieldKeys.some(dottedKey => dottedKey.startsWith(key)) &&
value.$elemMatch
) {
finalArgs[`__gatsby_resolved.${key}`] = value
} else if (dottedFieldKeys.some(dottedKey => key.startsWith(dottedKey))) {
finalArgs[`__gatsby_resolved.${key}`] = value
} else {
finalArgs[key] = value
}
})
return finalArgs
}
10 changes: 1 addition & 9 deletions packages/gatsby/src/db/index.js
Expand Up @@ -3,21 +3,13 @@ const report = require(`gatsby-cli/lib/reporter`)
const redux = require(`../redux`)
const { emitter } = redux

// Even if we are using loki, we still include redux in the list of
// dbs since it still has pages, config, etc.
const dbs = [redux]
// if (process.env.GATSBY_DB_NODES === `loki`) {
// dbs.push(require(`./loki`))
// }

// calls `saveState()` on all DBs
let saveInProgress = false
async function saveState() {
if (saveInProgress) return
saveInProgress = true

try {
await Promise.all(dbs.map(db => db.saveState()))
await redux.saveState()
} catch (err) {
report.warn(`Error persisting state: ${(err && err.message) || err}`)
}
Expand Down
12 changes: 0 additions & 12 deletions packages/gatsby/src/db/loki/__tests__/index.js

This file was deleted.

56 changes: 0 additions & 56 deletions packages/gatsby/src/db/loki/__tests__/nodes-query-test.js

This file was deleted.

30 changes: 0 additions & 30 deletions packages/gatsby/src/db/loki/__tests__/nodes.js

This file was deleted.

0 comments on commit 59c7287

Please sign in to comment.