@ecosyste-ms/critical 1.0.20260328 → 1.1.0

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/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { build, databasePath } from './lib/index.js'
3
- import Database from 'better-sqlite3'
3
+ import { DatabaseSync } from 'node:sqlite'
4
4
  import { existsSync } from 'fs'
5
5
 
6
6
  const args = process.argv.slice(2)
@@ -40,7 +40,7 @@ if (args.includes('--stats')) {
40
40
  console.error(`Database not found: ${path}`)
41
41
  process.exit(1)
42
42
  }
43
- const db = new Database(path, { readonly: true })
43
+ const db = new DatabaseSync(path, { readOnly: true })
44
44
  const info = db.prepare('SELECT * FROM build_info WHERE id = 1').get()
45
45
  const packageCount = db.prepare('SELECT COUNT(*) as count FROM packages').get().count
46
46
  const versionCount = db.prepare('SELECT COUNT(*) as count FROM versions').get().count
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import Database from 'better-sqlite3'
1
+ import { DatabaseSync } from 'node:sqlite'
2
2
  import { createReadStream, createWriteStream, existsSync } from 'fs'
3
3
  import { mkdir, unlink, readFile } from 'fs/promises'
4
4
  import { dirname, join } from 'path'
@@ -96,8 +96,8 @@ function ecosystemToRegistry(ecosystem) {
96
96
  }
97
97
 
98
98
  function createDatabase(dbPath) {
99
- const db = new Database(dbPath)
100
- db.pragma('journal_mode = WAL')
99
+ const db = new DatabaseSync(dbPath)
100
+ db.exec('PRAGMA journal_mode = WAL')
101
101
 
102
102
  db.exec(`
103
103
  CREATE TABLE packages (
@@ -342,16 +342,19 @@ async function build(options = {}) {
342
342
  const packages = await fetchAllCriticalPackages(onProgress)
343
343
  onProgress(`Found ${packages.length} critical packages`)
344
344
 
345
- const insertAll = db.transaction((pkgs) => {
346
- for (const pkg of pkgs) {
345
+ onProgress('Inserting packages...')
346
+ db.exec('BEGIN')
347
+ try {
348
+ for (const pkg of packages) {
347
349
  insertPackage(db, pkg)
348
350
  insertRepoMetadata(db, pkg.id, pkg.repo_metadata, pkg.host)
349
351
  insertAdvisories(db, pkg.id, pkg.advisories)
350
352
  }
351
- })
352
-
353
- onProgress('Inserting packages...')
354
- insertAll(packages)
353
+ db.exec('COMMIT')
354
+ } catch (err) {
355
+ db.exec('ROLLBACK')
356
+ throw err
357
+ }
355
358
 
356
359
  if (fetchVersionsData) {
357
360
  onProgress('Fetching versions...')
@@ -369,13 +372,18 @@ async function build(options = {}) {
369
372
  const batch = packages.slice(i, i + CONCURRENCY)
370
373
  const results = await Promise.all(batch.map(processPackage))
371
374
 
372
- db.transaction(() => {
375
+ db.exec('BEGIN')
376
+ try {
373
377
  for (const { pkg, versions } of results) {
374
378
  if (versions.length > 0) {
375
379
  insertVersions(db, pkg.id, versions)
376
380
  }
377
381
  }
378
- })()
382
+ db.exec('COMMIT')
383
+ } catch (err) {
384
+ db.exec('ROLLBACK')
385
+ throw err
386
+ }
379
387
 
380
388
  completed += batch.length
381
389
  onProgress(`Fetched versions for ${completed}/${total} packages`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecosyste-ms/critical",
3
- "version": "1.0.20260328",
3
+ "version": "1.1.0",
4
4
  "description": "SQLite database of critical packages from ecosyste.ms",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -35,9 +35,6 @@
35
35
  "access": "public"
36
36
  },
37
37
  "engines": {
38
- "node": ">=18.0.0"
39
- },
40
- "dependencies": {
41
- "better-sqlite3": "^12.5.0"
38
+ "node": ">=22.5.0"
42
39
  }
43
40
  }
Binary file