diff --git a/apps/interpreter/package.json b/apps/interpreter/package.json index 6bfb831d9..d080675dd 100644 --- a/apps/interpreter/package.json +++ b/apps/interpreter/package.json @@ -18,5 +18,5 @@ "access": "public", "registry": "https://registry.npmjs.org" }, - "version": "will be overridden by the root version, the presence of this version field is required by the interpreter" + "version": "$REPLACE_WITH_PROGRAM_VERSION_IN_PREPUBLISH_STEP" } diff --git a/apps/interpreter/project.json b/apps/interpreter/project.json index 404aa1a43..bd1c2c6d8 100644 --- a/apps/interpreter/project.json +++ b/apps/interpreter/project.json @@ -44,7 +44,8 @@ "options": { "commands": [ "node tools/scripts/interpreter/prepend-shebang.mjs interpreter main.js", - "node tools/scripts/add-package-json-version.mjs interpreter" + "node tools/scripts/add-package-json-version.mjs interpreter", + "node tools/scripts/interpreter/rewrite-version-mainjs.mjs interpreter" ] } }, diff --git a/package.json b/package.json index c9c0f5dc2..4bb146ebf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jayvee", - "version": "0.0.14", + "version": "0.0.15", "scripts": { "nx": "nx", "format": "nx format:write", diff --git a/tools/scripts/interpreter/rewrite-version-mainjs.mjs b/tools/scripts/interpreter/rewrite-version-mainjs.mjs new file mode 100644 index 000000000..6462115f8 --- /dev/null +++ b/tools/scripts/interpreter/rewrite-version-mainjs.mjs @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg +// +// SPDX-License-Identifier: AGPL-3.0-only + +import {readFileSync, writeFileSync} from 'fs'; +import { + parsePackageJson, getOutputPath +} from '../shared-util.mjs'; +import { workspaceRoot } from "@nrwl/devkit"; + +// Executing this script: node path/to/rewrite-version-mainjs.mjs {projectName} +const [, , projectName] = process.argv; + +process.chdir(workspaceRoot); +const rootPackageJson = parsePackageJson(); + +process.chdir(getOutputPath(projectName)); + +const mainJs = readFileSync(`main.js`).toString(); +const modifiedMainJs = mainJs.replace('$REPLACE_WITH_PROGRAM_VERSION_IN_PREPUBLISH_STEP', rootPackageJson.version); +writeFileSync(`main.js`, modifiedMainJs);