From f2e0fcc5c0e2bdfd6ea6373d98c40fa5ba5bbe85 Mon Sep 17 00:00:00 2001 From: Henri Meltaus Date: Tue, 14 Mar 2023 18:41:35 +0200 Subject: [PATCH] fix: fix version info --- .github/workflows/release.yml | 6 +++--- package.json | 1 + src/cli/common.ts | 4 ++-- src/cli/index.ts | 5 +++++ src/parser/project-config-parser.ts | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e809c84..6ca98eed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,9 +79,9 @@ jobs: release: runs-on: ubuntu-20.04 - needs: - - unit-test - - integration-test + needs: build +# - unit-test +# - integration-test steps: - uses: actions/checkout@v3 with: diff --git a/package.json b/package.json index 5dfb64d5..f5a25c35 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "scripts": { "prepare": "husky install", "build": "tsc", + "postbuild": "cp package.json dist/", "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --selectProjects test --maxWorkers=2 --ci --verbose", "integration-test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --selectProjects integration-test --maxWorkers=5 --ci --verbose", "clean": "rm -f package-lock.json && rm -rf node_modules && rm -rf dist", diff --git a/src/cli/common.ts b/src/cli/common.ts index b7664796..c5d64bae 100644 --- a/src/cli/common.ts +++ b/src/cli/common.ts @@ -61,7 +61,7 @@ export const initCommandContext = async ( } const require = createRequire(import.meta.url) - const packageJson = require("../../package.json") + const packageJson = require("../package.json") const buildInfo = { version: packageJson.version, } @@ -142,7 +142,7 @@ export const onError = (e: any): void => { } const require = createRequire(import.meta.url) - const packageJson = require("../../package.json") + const packageJson = require("../package.json") console.log() console.log() diff --git a/src/cli/index.ts b/src/cli/index.ts index fd67083b..04b7f0de 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -1,3 +1,4 @@ +import { createRequire } from "module" import yargs from "yargs" import { hideBin } from "yargs/helpers" import { RunProps } from "./common.js" @@ -6,6 +7,9 @@ import { iamCmd } from "./iam/index.js" import { stacksCmd } from "./stacks/index.js" export { initCommandContext } from "./common.js" +const require = createRequire(import.meta.url) +const packageJson = require("../package.json") + /** * @hidden */ @@ -89,5 +93,6 @@ export const run = (props: RunProps = { showHelpOnFail: true }): void => { .recommendCommands() .strict(true) .showHelpOnFail(props?.showHelpOnFail === true) + .version(packageJson.version) .help().argv } diff --git a/src/parser/project-config-parser.ts b/src/parser/project-config-parser.ts index bc32deeb..3c521bc7 100644 --- a/src/parser/project-config-parser.ts +++ b/src/parser/project-config-parser.ts @@ -35,7 +35,7 @@ const validateRequiredVersion = async ( } const require = createRequire(import.meta.url) - const packageJson = require("../../package.json") + const packageJson = require("../package.json") if (!semver.satisfies(packageJson.version, requiredVersion)) { throw new TakomoError(