From 97572acb495e240b0ee3ae5d0f70ae88e87ea89b Mon Sep 17 00:00:00 2001 From: Ell Date: Tue, 2 Apr 2024 16:32:05 +0200 Subject: [PATCH] Use release-it to store package version in src (#748) * ci: reflect module splitting in dockerfile (untested) * refactor: bad copy-paste * dep: updated submodules * ci: ensure we check out submodules for docker deploy * feat-fix: fixed outdated paths after refactor * feat-fix: fixed up dockerfile * refactor: dockerfile cleanup * refactor: we don't need to copy to dist * dep: use release-it-regex-bumper to avoid packaging package.json * ci: fix run-suite path * dep: updated cli submodule * refactor: updated docker paths to reflect new directory structure * refactor: explicitly omit test sources in docker Co-authored-by: Florian Sihler --- modules/cli | 2 +- package-lock.json | 103 ++++++++++++++++++++++++++++++++++ package.json | 12 +++- scripts/Dockerfile | 18 +++--- src/util/version.ts | 4 +- test/performance/run-suite.sh | 4 +- 6 files changed, 131 insertions(+), 12 deletions(-) diff --git a/modules/cli b/modules/cli index 6a4c41e617..1f6ccd06d0 160000 --- a/modules/cli +++ b/modules/cli @@ -1 +1 @@ -Subproject commit 6a4c41e6171beee1dfdf9ffefa431713be495da7 +Subproject commit 1f6ccd06d09155dc6c846966a8d9a29201aea200 diff --git a/package-lock.json b/package-lock.json index e96ee2d9b4..b4cbf9f79c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@commitlint/cli": "^18.4.3", "@commitlint/config-angular": "^18.4.3", "@eagleoutice/eslint-config-flowr": "^1.0.2", + "@j-ulrich/release-it-regex-bumper": "^5.1.0", "@stylistic/eslint-plugin": "^1.6.2", "@stylistic/eslint-plugin-plus": "^1.6.2", "@stylistic/eslint-plugin-ts": "^1.6.2", @@ -445,6 +446,31 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.24.1", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.1.tgz", + "integrity": "sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/runtime-corejs3": { + "version": "7.24.1", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.24.1.tgz", + "integrity": "sha512-T9ko/35G+Bkl+win48GduaPlhSlOjjE5s1TeiEcD+QpxlLQnoEfb/nO/T+TQqkm+ipFwORn+rB8w14iJ/uD0bg==", + "dev": true, + "dependencies": { + "core-js-pure": "^3.30.2", + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.24.0", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.0.tgz", @@ -1074,6 +1100,41 @@ "node": ">=8" } }, + "node_modules/@j-ulrich/release-it-regex-bumper": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@j-ulrich/release-it-regex-bumper/-/release-it-regex-bumper-5.1.0.tgz", + "integrity": "sha512-nXvpAehdeStBxyUkBDNr/afAjF0BWPPRCfl5N5XYoZmcHCqVyoHklzZrVEH6LTnzm+Xwt9f58BynWsO+Sc/jyA==", + "dev": true, + "dependencies": { + "chalk": "^5.0.0", + "date-fns": "^2.8.0", + "fast-glob": "^3.2.0", + "lodash": "^4.17.20", + "semver": "^7.3.0", + "xregexp": "^5.0.0" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "diff": "3 - 5" + }, + "peerDependencies": { + "release-it": "16 || 17" + } + }, + "node_modules/@j-ulrich/release-it-regex-bumper/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -3315,6 +3376,17 @@ "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", "dev": true }, + "node_modules/core-js-pure": { + "version": "3.36.1", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.36.1.tgz", + "integrity": "sha512-NXCvHvSVYSrewP0L5OhltzXeWFJLo2AL2TYnj6iLV3Bw8mM62wAQMNgUCRI6EBu6hVVpbCxmOPlxh1Ikw2PfUA==", + "dev": true, + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -3485,6 +3557,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/dbly-linked-list": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/dbly-linked-list/-/dbly-linked-list-0.3.4.tgz", @@ -8987,6 +9075,12 @@ "node": ">=8" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "dev": true + }, "node_modules/regexp.prototype.flags": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", @@ -11170,6 +11264,15 @@ "resolved": "https://registry.npmjs.org/xpath-ts2/-/xpath-ts2-1.4.2.tgz", "integrity": "sha512-8o56hhPRZaSkR/BM8JXIeMc16FPnLEtlXhYhf85uYLopETOKp1nH0cJg+meBO7BgLeZDTLRj0pFi2UhBUAUh4A==" }, + "node_modules/xregexp": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-5.1.1.tgz", + "integrity": "sha512-fKXeVorD+CzWvFs7VBuKTYIW63YD1e1osxwQ8caZ6o1jg6pDAbABDG54LCIq0j5cy7PjRvGIq6sef9DYPXpncg==", + "dev": true, + "dependencies": { + "@babel/runtime-corejs3": "^7.16.5" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 8d04efe5ab..60713d4762 100644 --- a/package.json +++ b/package.json @@ -201,6 +201,15 @@ "after:bump": "npm run build", "after:git:release": "echo After git push, before github release", "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}." + }, + "plugins": { + "@j-ulrich/release-it-regex-bumper": { + "out": { + "file": "src/util/version.ts", + "search": "const version = '[\\d.]+'", + "replace": "const version = '{{version}}'" + } + } } }, "devDependencies": { @@ -239,7 +248,8 @@ "typedoc-plugin-missing-exports": "^2.1.0", "typedoc-theme-hierarchy": "^4.1.2", "typedoc-umlclass": "^0.8.0", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "@j-ulrich/release-it-regex-bumper": "^5.1.0" }, "dependencies": { "@types/semver": "^7.5.6", diff --git a/scripts/Dockerfile b/scripts/Dockerfile index dca66d8b58..7a1080f92b 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -4,12 +4,16 @@ FROM node:21.4-alpine3.19 AS builder WORKDIR /app -# copy all modules into the workdir -COPY ./src /app/src/ +# copy the source and build files of all modules into the workdir +# (by doing this, we explicitly omit test sources) +COPY ./src /app/src COPY ./package.json ./package-lock.json ./tsconfig.json /app/ -COPY ./modules/benchmark /app/modules/benchmark -COPY ./modules/cli /app/modules/cli -COPY ./modules/statistics /app/modules/statistics +COPY ./modules/benchmark/src /app/modules/benchmark/src +COPY ./modules/benchmark/package.json ./modules/benchmark/package-lock.json ./modules/benchmark/tsconfig.json /app/modules/benchmark/ +COPY ./modules/cli/src /app/modules/cli/src +COPY ./modules/cli/package.json ./modules/cli/package-lock.json ./modules/cli/tsconfig.json /app/modules/cli/ +COPY ./modules/statistics/src /app/modules/statistics/src +COPY ./modules/statistics/package.json ./modules/statistics/package-lock.json ./modules/statistics/tsconfig.json /app/modules/statistics/ # install and build all modules RUN npm install && npm run build @@ -41,9 +45,9 @@ RUN cd modules/benchmark && npm install --omit=dev RUN cd modules/cli && npm install --omit=dev RUN cd modules/statistics && npm install --omit=dev -COPY --from=builder /app/dist/src /app/dist +COPY --from=builder /app/dist /app/dist COPY --from=builder /app/modules/benchmark/dist /app/modules/benchmark/dist -COPY --from=builder /app/modules/cli/dist/src /app/modules/cli/dist +COPY --from=builder /app/modules/cli/dist /app/modules/cli/dist COPY --from=builder /app/modules/statistics/dist /app/modules/statistics/dist RUN rm -rf /app/**/tsconfig.tsbuildinfo diff --git a/src/util/version.ts b/src/util/version.ts index e16cde71fc..ebcd0fb96f 100644 --- a/src/util/version.ts +++ b/src/util/version.ts @@ -1,6 +1,8 @@ -import { version } from '../../package.json' import { SemVer } from 'semver' +// this is automatically replaced with the current version by release-it +const version = '1.0.0' + export function flowrVersion(): SemVer { return new SemVer(version) } diff --git a/test/performance/run-suite.sh b/test/performance/run-suite.sh index c23a461ce8..73f16a770f 100755 --- a/test/performance/run-suite.sh +++ b/test/performance/run-suite.sh @@ -37,14 +37,14 @@ echo "done." FILES_DIR="$(pwd)/files/" ## run the benchmark script for each file -CMD=(npm run benchmark --prefix ../../../cli -- --parallel "${PARALLEL}" --runs "${RUNS}" --output "${RAW_OUTPUT}" "${FILES_DIR}") +CMD=(npm run benchmark --prefix ../../../modules/cli -- --parallel "${PARALLEL}" --runs "${RUNS}" --output "${RAW_OUTPUT}" "${FILES_DIR}") echo -e " * Running: \"${CMD[*]}\"...\033[33m" "${CMD[@]}" echo -e "\033[0m * Done (written to ${RAW_OUTPUT})." echo " * Summarizing results to ${OUTPUT_FILE}${ULTIMATE_SUMMARY_SUFFIX}..." -CMD=(npm run summarizer --prefix ../../../cli -- --input "${RAW_OUTPUT}" --output "${OUTPUT_FILE}" --graph) +CMD=(npm run summarizer --prefix ../../../modules/cli -- --input "${RAW_OUTPUT}" --output "${OUTPUT_FILE}" --graph) echo -e " * Running: \"${CMD[*]}\"...\033[33m" "${CMD[@]}" echo -e "\033[0m * Done (written to ${OUTPUT_FILE}${ULTIMATE_SUMMARY_SUFFIX})."