Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inject next version into bundled "auto" #1775

Merged
merged 2 commits into from Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cli/package.json
Expand Up @@ -41,7 +41,8 @@
"start": "npm run build -- -w",
"lint": "eslint src --ext .ts",
"test": "jest --maxWorkers=2",
"bundle": "yarn package && yarn gzip",
"bundle": "yarn inject-version && yarn package && yarn gzip",
"inject-version": "node scripts/inject-version.js",
"package": "rimraf binary && pkg . --out-path binary",
"gzip": "ls binary/auto* | xargs gzip"
},
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/scripts/inject-version.js
@@ -0,0 +1,23 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */

const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
const dotenv = require("dotenv");

dotenv.config({ path: path.join(__dirname, "../../../.env") });

const autoPath = path.join(__dirname, "../dist/bin/auto.js");

execSync(`chmod +x ${autoPath}`);
const nextVersion = execSync(`${autoPath} shipit -dq`, {
encoding: "utf-8",
}).trim();
const parseArgsPath = path.join(__dirname, "../dist/parse-args.js");
const parseArgsContent = fs.readFileSync(parseArgsPath, { encoding: "utf-8" });

fs.writeFileSync(
parseArgsPath,
parseArgsContent.replace(/process\.env\.AUTO_CLI_VERSION/, `"${nextVersion}"`)
);
3 changes: 2 additions & 1 deletion packages/cli/src/parse-args.ts
Expand Up @@ -623,7 +623,8 @@ export default function parseArgs(testArgs?: string[]) {

if (!mainOptions._command) {
if (mainOptions.version) {
console.log(`v${getAutoVersion()}`);
const version = process.env.AUTO_CLI_VERSION || getAutoVersion();
console.log(`v${version}`);
}

return [];
Expand Down