Skip to content

Commit

Permalink
Merge pull request #1775 from intuit/bundle-version
Browse files Browse the repository at this point in the history
inject next version into bundled "auto"
  • Loading branch information
hipstersmoothie committed Feb 4, 2021
2 parents 942aaed + fed8a9b commit 4018098
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
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

0 comments on commit 4018098

Please sign in to comment.