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 CHANGED
@@ -10,6 +10,10 @@ import { styleText } from "node:util"
10
10
 
11
11
  /** @import {Database} from "./createDatabase.js" */
12
12
 
13
+ /**
14
+ * @typedef {Database} Database
15
+ */
16
+
13
17
  /**
14
18
  * @typedef {object} VotivePlugin
15
19
  * @property {string} name
@@ -264,43 +264,43 @@ function prepareStatements(database) {
264
264
  ORDER BY d.path ASC;
265
265
  `))),
266
266
 
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
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
- GROUP BY m.destination
284
- ),
285
- filter_count AS (
286
- SELECT COUNT(*) AS total FROM json_each('{ "breadcrumb": "Hello World" }')
287
- )
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
- */
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
- : value
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
 
@@ -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 { jobs, abstract, metadata } = read(data, sourceFilePath, targetFilePath, database, config)
176
-
177
-
178
- if (Array.isArray(jobs)) {
179
- allJobs.push(...jobs)
180
- }
181
-
182
- const target = database.target.create({
183
- abstract,
184
- path: targetFilePath,
185
- metadata,
186
- })
187
-
188
- // FIXME this won't work with the refactor
189
- allJobs && allJobs.forEach(job => job.syntax = processor.extensions[0])
190
- updateSource()
191
- return {
192
- abstract,
193
- metadata,
194
- syntax: targetFileExtension,
195
- targetFilePath: target.path,
196
- dir: target.dir,
197
- sourceFilePath,
198
- jobs: allJobs
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "votive",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A file processor.",
5
5
  "homepage": "https://github.com/samlfair/votive#readme",
6
6
  "bugs": {