diff --git a/package.json b/package.json index 81fc2dbf..ef8b9a08 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "test": "LOG_LEVEL=SILENT TZ=UTC jest --maxWorkers=4", "develop": "npm run __prepare-folder-develop && npm run __develop-core", "develop-watch": "npm run develop && chokidar \"src/**/*.(ts|tsx|json)\" \"public/**/*.(html|css)\" -c \"[[ {path} == src* ]] && npm run __develop-core;[[ {path} == public* ]] && copyup {path} dist\"", - "build": "npm run __prepare-folder && npm run __check-types && NODE_ENV=production node --import ./register.js ./build.ts" + "build": "npm run __prepare-folder && npm run __check-types && NODE_ENV=production node --import ./register.js ./build.ts", + "set-version": "node --import ./register.js scripts/set-version.ts" }, "devDependencies": { "@jest/types": "^29.6.3", diff --git a/scripts/set-version.ts b/scripts/set-version.ts new file mode 100644 index 00000000..d608831e --- /dev/null +++ b/scripts/set-version.ts @@ -0,0 +1,27 @@ +import fs from "fs"; +import { execSync } from "child_process"; + +const version = process.argv[2]; +if (!version || !/^\d+\.\d+\.\d+$/.test(version)) { + console.error("Usage: set-version.ts "); + process.exit(1); +} + +const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8")); +packageJson.version = version; +fs.writeFileSync("package.json", `${JSON.stringify(packageJson, null, 2)}\n`); + +const manifestJson = JSON.parse(fs.readFileSync("manifest.json", "utf8")); +manifestJson.version = version; +fs.writeFileSync("manifest.json", `${JSON.stringify(manifestJson, null, 2)}\n`); + +execSync("npm install", { stdio: "inherit" }); + +const lockfileVersion = JSON.parse(fs.readFileSync("package-lock.json", "utf8")).version; + +if (lockfileVersion !== version) { + console.error(`package-lock.json version is ${lockfileVersion}, expected ${version}`); + process.exit(1); +} + +console.log(`My Notes updated to ${version}`); diff --git a/tsconfig.json b/tsconfig.json index d8ac2008..2fd8f05b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "./jest.config.ts", "./jest.setup.ts", "./register.js", - "./build.ts" + "./build.ts", + "./scripts/**/*" ], "compilerOptions": {