Skip to content

Commit

Permalink
Fix version number reading of interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed May 3, 2023
1 parent df0deb5 commit 2ebf09d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion apps/interpreter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jayvee",
"version": "0.0.14",
"version": "0.0.15",
"scripts": {
"nx": "nx",
"format": "nx format:write",
Expand Down
21 changes: 21 additions & 0 deletions tools/scripts/interpreter/rewrite-version-mainjs.mjs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 2ebf09d

Please sign in to comment.