Commit c7b087f

Anton Golub <antongolub@antongolub.com>
2025-08-19 18:27:43
ci: minor manifest gen improvements (#1324)
1 parent 976a74a
scripts/build-pkgjson-lite.mjs
@@ -20,8 +20,9 @@ import { depseekSync } from 'depseek'
 
 const __dirname = path.dirname(new URL(import.meta.url).pathname)
 const root = path.resolve(__dirname, '..')
-const pkgJsonFile = path.join(root, 'package.json')
-const _pkgJson = JSON.parse(fs.readFileSync(pkgJsonFile, 'utf-8'))
+const source = 'package.json'
+const dest = 'package-lite.json'
+const _pkgJson = JSON.parse(fs.readFileSync(path.join(root, source), 'utf-8'))
 
 const files = new Set()
 const entries = new Set(['./core.js', './3rd-party-licenses'])
@@ -86,6 +87,6 @@ const pkgJson = {
   files: [...files].map((f) => path.join('build', f)).sort(),
 }
 
-fs.writeFileSync('package-lite.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync(path.resolve(root, dest), JSON.stringify(pkgJson, null, 2))
 
-console.log('package-lite.json prepared for npm')
+console.log(`${dest} prepared for npm`)
scripts/build-pkgjson-main.mjs
@@ -19,8 +19,9 @@ import path from 'node:path'
 
 const __dirname = path.dirname(new URL(import.meta.url).pathname)
 const root = path.resolve(__dirname, '..')
-const pkgJsonFile = path.join(root, 'package.json')
-const _pkgJson = JSON.parse(fs.readFileSync(pkgJsonFile, 'utf-8'))
+const source = 'package.json'
+const dest = 'package-main.json'
+const _pkgJson = JSON.parse(fs.readFileSync(path.join(root, source), 'utf-8'))
 
 const whitelist = new Set([
   'name',
@@ -47,6 +48,7 @@ const whitelist = new Set([
 const pkgJson = Object.fromEntries(
   Object.entries(_pkgJson).filter(([k]) => whitelist.has(k))
 )
-fs.writeFileSync('package-main.json', JSON.stringify(pkgJson, null, 2))
 
-console.log('package-main.json prepared for npm')
+fs.writeFileSync(path.resolve(root, dest), JSON.stringify(pkgJson, null, 2))
+
+console.log(`${dest} prepared for npm`)