Skip to content

Commit

Permalink
Merge pull request #1079 from chromaui/cody/cap-2202-chromatic-cli-do…
Browse files Browse the repository at this point in the history
…esnt-show-correct-version

Fix CLI version output
  • Loading branch information
codykaup authored Oct 7, 2024
2 parents 59c5f54 + b079245 commit 3f3be64
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions node-src/lib/parseArguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function parseArguments(argv: string[]) {
argv,
booleanDefault: undefined,
description: false,
version: pkg.version,
flags: {
// Required options
projectToken: { type: 'string', alias: 't', isMultiple: true },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"lint": "yarn lint:js bin-src node-src test-stories ./isChromatic.js ./isChromatic.mjs",
"lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location=.cache/eslint --report-unused-disable-directives",
"lint:package": "sort-package-json",
"release": "yarn run build && auto shipit",
"release": "./scripts/versionAndBuild.mjs && auto shipit",
"prepack": "clean-package",
"postpack": "clean-package restore",
"publish-action": "./scripts/publish-action.mjs",
Expand Down
26 changes: 26 additions & 0 deletions scripts/versionAndBuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

import { $ } from 'execa';

async function main() {
const { stdout: status } = await $`git status --porcelain`;
if (status) {
console.error(`❗️ Working directory is not clean:\n${status}`);
return;
}

const { stdout: nextVersion } = await $`auto shipit --dry-run --quiet`;

console.info(`📌 Temporarily bumping version to '${nextVersion}' for build step`);
await $`npm --no-git-tag-version version ${nextVersion}`;

console.info('📦 Building with new version');
await $({ stdio: 'inherit' })`yarn build`;

console.info('🧹 Resetting changes to let `auto` do its thing');
await $`git reset --hard`;

console.info('✅ Build with new version completed');
}

main();

0 comments on commit 3f3be64

Please sign in to comment.