votive 0.4.0 → 0.4.1
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 +4 -0
- package/lib/createDatabase.js +38 -37
- package/lib/readSources.js +28 -24
- package/package.json +1 -1
package/lib/bundle.js
CHANGED
package/lib/createDatabase.js
CHANGED
|
@@ -264,43 +264,43 @@ function prepareStatements(database) {
|
|
|
264
264
|
ORDER BY d.path ASC;
|
|
265
265
|
`))),
|
|
266
266
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
267
|
+
/*
|
|
268
|
+
WITH matches AS (
|
|
269
|
+
SELECT m.destination, COUNT(*) AS match_count
|
|
270
|
+
FROM metadata m
|
|
271
|
+
INNER JOIN json_each('{ "breadcrumb": "Hello World" }') j ON j.key = m.label AND (
|
|
272
|
+
j.value = m.value
|
|
273
|
+
OR (
|
|
274
|
+
json_valid(m.value)
|
|
275
|
+
AND json_type(m.value) = 'array'
|
|
276
|
+
AND EXISTS (
|
|
277
|
+
SELECT 1
|
|
278
|
+
FROM json_each(m.value)
|
|
279
|
+
WHERE value = j.value
|
|
280
|
+
)
|
|
280
281
|
)
|
|
281
282
|
)
|
|
283
|
+
GROUP BY m.destination
|
|
284
|
+
),
|
|
285
|
+
filter_count AS (
|
|
286
|
+
SELECT COUNT(*) AS total FROM json_each('{ "breadcrumb": "Hello World" }')
|
|
282
287
|
)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
OR d.dir LIKE '%'
|
|
300
|
-
)
|
|
301
|
-
GROUP BY d.path
|
|
302
|
-
ORDER BY d.path ASC;
|
|
303
|
-
*/
|
|
288
|
+
SELECT d.*, json_group_object(i.label, i.value) AS metadata
|
|
289
|
+
FROM destinations d
|
|
290
|
+
INNER JOIN metadata i ON d.path = i.destination
|
|
291
|
+
LEFT JOIN matches ON matches.destination = d.path
|
|
292
|
+
CROSS JOIN filter_count f
|
|
293
|
+
WHERE (
|
|
294
|
+
f.total = 0
|
|
295
|
+
OR matches.match_count = f.total
|
|
296
|
+
)
|
|
297
|
+
AND (
|
|
298
|
+
d.dir = '/'
|
|
299
|
+
OR d.dir LIKE '%'
|
|
300
|
+
)
|
|
301
|
+
GROUP BY d.path
|
|
302
|
+
ORDER BY d.path ASC;
|
|
303
|
+
*/
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
306
|
* @callback SQLiteTargetGetAll
|
|
@@ -659,7 +659,9 @@ function createDatabase(databasePath = ".votive.db") {
|
|
|
659
659
|
const type = typeof value
|
|
660
660
|
const safeValue = type === "object"
|
|
661
661
|
? JSON.stringify(value)
|
|
662
|
-
:
|
|
662
|
+
: type === "boolean"
|
|
663
|
+
? Number(value)
|
|
664
|
+
: value
|
|
663
665
|
|
|
664
666
|
const descendents = folder === ""
|
|
665
667
|
? "%"
|
|
@@ -746,7 +748,6 @@ function createDatabase(databasePath = ".votive.db") {
|
|
|
746
748
|
* @param {string} filePath
|
|
747
749
|
*/
|
|
748
750
|
delete(filePath) {
|
|
749
|
-
console.log("deleting")
|
|
750
751
|
const deleted = prepared.target.delete.get(filePath)
|
|
751
752
|
prepared.metadata.deleteByTarget.all(filePath)
|
|
752
753
|
const deps = queries.dependency.getAllByTarget(filePath)
|
|
@@ -817,7 +818,7 @@ function createDatabase(databasePath = ".votive.db") {
|
|
|
817
818
|
getWithTrackers(filePath, dependent) {
|
|
818
819
|
const target = queries.target.get(filePath)
|
|
819
820
|
|
|
820
|
-
if(!target) return
|
|
821
|
+
if (!target) return
|
|
821
822
|
|
|
822
823
|
const trackedTarget = { metadata: {} }
|
|
823
824
|
|
package/lib/readSources.js
CHANGED
|
@@ -172,30 +172,34 @@ function readSourceFile(processors, database, config) {
|
|
|
172
172
|
const stats = await fs.stat(sourceFilePath)
|
|
173
173
|
const data = await fs.readFile(sourceFilePath, { encoding: "utf-8" })
|
|
174
174
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
175
|
+
const content = read(data, sourceFilePath, targetFilePath, database, config)
|
|
176
|
+
if (content) {
|
|
177
|
+
|
|
178
|
+
const { jobs, abstract, metadata } = read(data, sourceFilePath, targetFilePath, database, config)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if (Array.isArray(jobs)) {
|
|
182
|
+
allJobs.push(...jobs)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const target = database.target.create({
|
|
186
|
+
abstract,
|
|
187
|
+
path: targetFilePath,
|
|
188
|
+
metadata,
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
// FIXME this won't work with the refactor
|
|
192
|
+
allJobs && allJobs.forEach(job => job.syntax = processor.extensions[0])
|
|
193
|
+
updateSource()
|
|
194
|
+
return {
|
|
195
|
+
abstract,
|
|
196
|
+
metadata,
|
|
197
|
+
syntax: targetFileExtension,
|
|
198
|
+
targetFilePath: target.path,
|
|
199
|
+
dir: target.dir,
|
|
200
|
+
sourceFilePath,
|
|
201
|
+
jobs: allJobs
|
|
202
|
+
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
|