votive 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle.js +1 -0
- package/lib/createDatabase.js +45 -3
- package/lib/readSources.js +1 -1
- package/package.json +1 -1
- package/tests/.votive.db +0 -0
- package/tests/index.js +1 -1
package/lib/bundle.js
CHANGED
package/lib/createDatabase.js
CHANGED
|
@@ -138,7 +138,7 @@ function createDatabase(dbPath = ".votive.db") {
|
|
|
138
138
|
deleteMetadata.get(deletedDatum.destination, deletedDatum.label)
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
if(changedAbstract || changedMetadata) staleDepen.get(dest.path)
|
|
141
|
+
if (changedAbstract || changedMetadata) staleDepen.get(dest.path)
|
|
142
142
|
|
|
143
143
|
if (changedAbstract) {
|
|
144
144
|
updateDest.get(JSON.stringify(dest.abstract), dest.path)
|
|
@@ -185,7 +185,7 @@ function createDatabase(dbPath = ".votive.db") {
|
|
|
185
185
|
? database.getMetadataIndependently(params).all(path)
|
|
186
186
|
: [database.getDestinationWithoutMetadata().get(path)]
|
|
187
187
|
|
|
188
|
-
if(!metadatas) return
|
|
188
|
+
if (!metadatas) return
|
|
189
189
|
|
|
190
190
|
const [first] = metadatas
|
|
191
191
|
|
|
@@ -280,7 +280,49 @@ function createDatabase(dbPath = ".votive.db") {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
database.getStaleDestinations = () => {
|
|
283
|
-
|
|
283
|
+
const metadatas = store.all`
|
|
284
|
+
SELECT * FROM destinations d
|
|
285
|
+
LEFT JOIN metadata m on d.path = m.destination
|
|
286
|
+
WHERE stale = 1`
|
|
287
|
+
|
|
288
|
+
const grouped = metadatas.map((value, index, array) => {
|
|
289
|
+
if (array.slice(0, index)
|
|
290
|
+
.find(prior => prior.path === value.path)
|
|
291
|
+
) {
|
|
292
|
+
return null
|
|
293
|
+
} else {
|
|
294
|
+
return {
|
|
295
|
+
path: value.path,
|
|
296
|
+
dir: value.dir,
|
|
297
|
+
syntax: value.syntax,
|
|
298
|
+
stale: value.stale,
|
|
299
|
+
abstract: JSON.parse(value.abstract),
|
|
300
|
+
metadata: Object.fromEntries(
|
|
301
|
+
array.slice(index)
|
|
302
|
+
.filter(following => following.path === value.path)
|
|
303
|
+
.map(succeeding => {
|
|
304
|
+
return reconstituteMetadata(succeeding)
|
|
305
|
+
})
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}).filter(a => a)
|
|
311
|
+
|
|
312
|
+
function reconstituteMetadata({ label, value, type }) {
|
|
313
|
+
const originalValue = type === "undefined"
|
|
314
|
+
? undefined
|
|
315
|
+
: type === "string"
|
|
316
|
+
? String(value)
|
|
317
|
+
: type === "boolean"
|
|
318
|
+
? Boolean(value)
|
|
319
|
+
: typeof value !== "string"
|
|
320
|
+
? value
|
|
321
|
+
: JSON.parse(value)
|
|
322
|
+
return [label, originalValue]
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return grouped
|
|
284
326
|
}
|
|
285
327
|
|
|
286
328
|
const createSetting = databaseSync.prepare(`INSERT INTO settings (destination, label, value, source) VALUES (?, ?, ?, ?) RETURNING *`)
|
package/lib/readSources.js
CHANGED
|
@@ -109,7 +109,7 @@ function readSourceFile(processors, database, config) {
|
|
|
109
109
|
// Set URL if exists
|
|
110
110
|
const buffer = await fs.readFile(path.format(fileInfo))
|
|
111
111
|
const data = decodeBuffer(buffer)
|
|
112
|
-
const { jobs, abstract, metadata } = read.text(data, database, config)
|
|
112
|
+
const { jobs, abstract, metadata } = read.text(data, filePath, database, config)
|
|
113
113
|
jobs && jobs.forEach(job => job.plugin = plugin.name)
|
|
114
114
|
|
|
115
115
|
const timeStamp = stat.mtimeMs.toFixed()
|
package/package.json
CHANGED
package/tests/.votive.db
CHANGED
|
Binary file
|
package/tests/index.js
CHANGED
|
@@ -56,7 +56,7 @@ test("internals", async (t) => {
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
/** @type {ReadText} */
|
|
59
|
-
function exampleTextReader(text, database, config) {
|
|
59
|
+
function exampleTextReader(text, filePath, database, config) {
|
|
60
60
|
const matches = text.match(/\b\w+\b/)
|
|
61
61
|
const title = matches ? matches[0] : "Untitled"
|
|
62
62
|
|