This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new e379eae Create script to update the version inside of package.json
and VERSION
e379eae is described below
commit e379eaeac2d2bd4b1fc07773044c58644fce29a0
Author: Shane Dell <[email protected]>
AuthorDate: Mon Apr 7 11:54:58 2025 -0400
Create script to update the version inside of package.json and VERSION
---
build/yarn-scripts.ts | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 3 ++-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/build/yarn-scripts.ts b/build/yarn-scripts.ts
index 75d156b..2c8709e 100644
--- a/build/yarn-scripts.ts
+++ b/build/yarn-scripts.ts
@@ -120,10 +120,67 @@ function package() {
)
}
+/* START SECTION: Update version */
+// helper function to get the version passed in
+function parseArgs() {
+ const args = process.argv.slice(1)
+
+ for (let i = 0; i < args.length; i++) {
+ if ((args[i] === '-v' || args[i] == '--version') && i + 1 < args.length) {
+ return args[i + 1]
+ }
+ }
+
+ return null
+}
+
+function updatePackageJsonVersion(version) {
+ const packageJsonPath = 'package.json'
+
+ if (!fs.existsSync(packageJsonPath)) {
+ console.error('Error: package.json not found')
+ process.exit(1)
+ }
+
+ const pkgRaw = fs.readFileSync(packageJsonPath, 'utf-8')
+ const pkg = JSON.parse(pkgRaw)
+ pkg.version = version
+
+ fs.writeFileSync(
+ packageJsonPath,
+ JSON.stringify(pkg, null, 2) + '\n',
+ 'utf-8'
+ )
+ console.log(`package.json version updated to ${version}`)
+}
+
+function updateVersionFile(version) {
+ fs.writeFileSync('VERSION', version + '\n', 'utf-8')
+ console.log(`VERSION updated to ${version}`)
+}
+
+function updateVersion() {
+ let newVersion = parseArgs()
+
+ if (!newVersion) {
+ console.error('Error: Please provide a version using -v or --version')
+ process.exit(1)
+ }
+
+ if (newVersion.startsWith('v')) {
+ newVersion = newVersion.slice(1)
+ }
+
+ updatePackageJsonVersion(newVersion)
+ updateVersionFile(newVersion)
+}
+/* END SECTION: Update version */
+
module.exports = {
genVersionTS: genVersionTS,
nodeclean: nodeclean,
scalaclean: scalaclean,
+ updateVersion: updateVersion,
watch: watch,
package: package,
}
diff --git a/package.json b/package.json
index 7ecadde..8c2f341 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,8 @@
"test": "sbt test && yarn test:svelte && node ./out/tests/runTest.js",
"test:svelte": "mocha -r ts-node/register ./src/svelte/tests/**/*.test.ts",
"sbt": "sbt debugger/Universal/packageBin",
- "svelte:check": "svelte-check --tsconfig ./tsconfig.json"
+ "svelte:check": "svelte-check --tsconfig ./tsconfig.json",
+ "update-version": "run-func build/yarn-scripts.ts updateVersion"
},
"dependencies": {
"@omega-edit/client": "0.9.87",