@argos-ci/cli 4.2.0 → 4.2.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +33 -2
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
-
import { Option, program } from "commander";
|
|
5
|
-
import { finalize, skip, upload } from "@argos-ci/core";
|
|
4
|
+
import { InvalidArgumentError, Option, program } from "commander";
|
|
5
|
+
import { deploy, finalize, skip, upload } from "@argos-ci/core";
|
|
6
6
|
import ora from "ora";
|
|
7
7
|
import { createClient, formatAPIError, throwAPIError } from "@argos-ci/api-client";
|
|
8
8
|
import { homedir } from "node:os";
|
|
@@ -572,6 +572,36 @@ function loginCommand(program) {
|
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
574
|
//#endregion
|
|
575
|
+
//#region src/commands/publish.ts
|
|
576
|
+
function parsePrNumber(value) {
|
|
577
|
+
if (!/^\d+$/.test(value)) throw new InvalidArgumentError("pull request number must be a positive integer");
|
|
578
|
+
const prNumber = Number(value);
|
|
579
|
+
if (!Number.isSafeInteger(prNumber) || prNumber <= 0) throw new InvalidArgumentError("pull request number must be a positive integer");
|
|
580
|
+
return prNumber;
|
|
581
|
+
}
|
|
582
|
+
function publishCommand(program) {
|
|
583
|
+
program.command("publish").alias("deploy").argument("<directory>", "Directory of the static build to publish").description("Publish a static build (Storybook or any static site) to Argos").addOption(tokenOption).addOption(new Option("--environment <string>", "Deployment environment").choices(["preview", "production"]).default("preview").env("ARGOS_ENVIRONMENT")).addOption(new Option("--commit <string>", "Git commit SHA").env("ARGOS_COMMIT")).addOption(new Option("--branch <string>", "Git branch name").env("ARGOS_BRANCH")).addOption(new Option("--pr-number <number>", "Pull request number").argParser(parsePrNumber).env("ARGOS_PR_NUMBER")).action(async (directory, options) => {
|
|
584
|
+
const spinner = ora("Publishing").start();
|
|
585
|
+
try {
|
|
586
|
+
const result = await deploy({
|
|
587
|
+
token: options.token,
|
|
588
|
+
root: resolve(directory),
|
|
589
|
+
environment: options.environment,
|
|
590
|
+
commit: options.commit ?? void 0,
|
|
591
|
+
branch: options.branch ?? void 0,
|
|
592
|
+
prNumber: options.prNumber
|
|
593
|
+
});
|
|
594
|
+
spinner.succeed(`Published: ${result.url}`);
|
|
595
|
+
} catch (error) {
|
|
596
|
+
if (error instanceof Error) {
|
|
597
|
+
spinner.fail(`Publish failed: ${error.message}`);
|
|
598
|
+
console.error(error.stack);
|
|
599
|
+
}
|
|
600
|
+
process.exit(1);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
575
605
|
//#region src/index.ts
|
|
576
606
|
const rawPkg = await readFile(resolve(fileURLToPath(new URL(".", import.meta.url)), "..", "package.json"), "utf8");
|
|
577
607
|
const pkg = JSON.parse(rawPkg);
|
|
@@ -581,6 +611,7 @@ skipCommand(program);
|
|
|
581
611
|
finalizeCommand(program);
|
|
582
612
|
buildCommand(program);
|
|
583
613
|
loginCommand(program);
|
|
614
|
+
publishCommand(program);
|
|
584
615
|
if (!process.argv.slice(2).length) program.outputHelp();
|
|
585
616
|
else program.parse(process.argv);
|
|
586
617
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/cli",
|
|
3
3
|
"description": "Command-line (CLI) for visual testing with Argos.",
|
|
4
|
-
"version": "4.2.0",
|
|
4
|
+
"version": "4.2.1-alpha.0+4f1cfa9",
|
|
5
5
|
"bin": {
|
|
6
6
|
"argos": "./bin/argos-cli.js"
|
|
7
7
|
},
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@argos-ci/api-client": "0.18.0",
|
|
38
|
-
"@argos-ci/core": "5.2.
|
|
37
|
+
"@argos-ci/api-client": "0.18.1-alpha.0+4f1cfa9",
|
|
38
|
+
"@argos-ci/core": "5.2.2-alpha.0+4f1cfa9",
|
|
39
39
|
"commander": "^14.0.3",
|
|
40
40
|
"open": "^11.0.0",
|
|
41
41
|
"ora": "^9.3.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
52
52
|
"lint": "eslint ."
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "4f1cfa9db40cef760779b553b622524abcf6b199"
|
|
55
55
|
}
|