@zuplo/cli 1.22.0 → 1.23.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.
@@ -12,7 +12,6 @@ export default {
12
12
  describe: "The API Key from Zuplo",
13
13
  envVar: "API_KEY",
14
14
  })
15
- .demandOption(["api-key"])
16
15
  .option("dir", {
17
16
  type: "string",
18
17
  describe: "The directory containing your zup",
@@ -20,6 +19,13 @@ export default {
20
19
  normalize: true,
21
20
  hidden: true,
22
21
  })
22
+ .option("verify-remote", {
23
+ type: "boolean",
24
+ describe: "Verify that this Git repository matches the one configured on Zuplo. Use --no-verify-remote to disable.",
25
+ default: true,
26
+ })
27
+ .demandOption(["api-key"])
28
+ .boolean("verify-remote")
23
29
  .check(async (argv) => {
24
30
  return await new YargsChecker(validDeployDirectoryValidator).check(argv.dir);
25
31
  })
@@ -8,11 +8,12 @@ import * as temp from "temp";
8
8
  import { DEPLOYER_METADATA_FILE } from "../common/constants.js";
9
9
  import { logger } from "../common/logger.js";
10
10
  export const ARCHIVE_EXTENSION = ".tar.gz";
11
- export async function archive(dir) {
11
+ export async function archive(argv) {
12
12
  const tarball = temp.path({ suffix: ARCHIVE_EXTENSION });
13
+ const dir = argv.dir;
13
14
  const ignoreFn = createIgnoreFunction(dir);
14
15
  const normalizedDir = join(relative(process.cwd(), dir));
15
- const metadata = await prepareDeployerMetadata(dir);
16
+ const metadata = await prepareDeployerMetadata(argv);
16
17
  await tar.create({
17
18
  gzip: true,
18
19
  file: tarball,
@@ -59,12 +60,14 @@ function createIgnoreFunction(normalizedDir) {
59
60
  return baseIgnore.add("node_modules/");
60
61
  }
61
62
  }
62
- async function prepareDeployerMetadata(dir) {
63
- const metadata = await generateMetadata(dir);
63
+ async function prepareDeployerMetadata(argv) {
64
+ const dir = argv.dir;
65
+ const metadata = await generateMetadata(argv);
64
66
  await writeGeneratedMetadata(dir, metadata);
65
67
  return metadata;
66
68
  }
67
- async function generateMetadata(dir) {
69
+ async function generateMetadata(argv) {
70
+ const dir = argv.dir;
68
71
  const git = simpleGit({ baseDir: dir });
69
72
  const status = await git.status();
70
73
  if (!status.current) {
@@ -73,10 +76,12 @@ async function generateMetadata(dir) {
73
76
  const branch = status.current.trim();
74
77
  const sha = (await git.revparse(["HEAD"])).trim();
75
78
  const repoUrl = (await git.listRemote(["--get-url"])).trim();
79
+ const verifyRemote = argv["verify-remote"];
76
80
  return {
77
81
  branch,
78
82
  repoUrl,
79
83
  sha,
84
+ verifyRemote,
80
85
  };
81
86
  }
82
87
  async function writeGeneratedMetadata(dir, metadata) {
@@ -6,7 +6,7 @@ import { archive, ARCHIVE_EXTENSION } from "./archive.js";
6
6
  import { upload } from "./file-upload.js";
7
7
  import { pollDeployment } from "./poll-deployment.js";
8
8
  export async function deploy(argv) {
9
- const archiveMetadata = await archive(argv.dir);
9
+ const archiveMetadata = await archive(argv);
10
10
  logger.info(`Tarball created locally at ${archiveMetadata}`);
11
11
  const whoAmIResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`, {
12
12
  method: "GET",
@@ -28,12 +28,13 @@ export async function deploy(argv) {
28
28
  if (uploadResponse.ok) {
29
29
  printDiagnosticsToConsole(`Deploying the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}...`);
30
30
  const fileId = parse(new URL(uploadUrl).pathname).base.replace(ARCHIVE_EXTENSION, "");
31
- const { url, buildResult } = await pollDeployment(argv, fileId, account, project);
31
+ const { url, steps, buildResult } = await pollDeployment(argv, fileId, account, project);
32
32
  if (url) {
33
33
  printResultToConsoleAndExitGracefully(`Deployed to ${url}`);
34
34
  }
35
35
  else {
36
- printCriticalFailureToConsoleAndExit(`Failed to deploy the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}. Here's the build result: ${JSON.stringify(buildResult, null, 2)}`);
36
+ const diagnostics = buildResult ?? steps;
37
+ printCriticalFailureToConsoleAndExit(`Failed to deploy the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}. Here's the diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
37
38
  }
38
39
  }
39
40
  else {
@@ -17,7 +17,7 @@ export async function pollDeployment(argv, fileId, account, project) {
17
17
  });
18
18
  if (response.ok) {
19
19
  const rawJSON = await response.text();
20
- const { status, url, buildResult } = JSON.parse(rawJSON);
20
+ const { status, url, steps, buildResult } = JSON.parse(rawJSON);
21
21
  switch (status) {
22
22
  case "IN_PROGRESS":
23
23
  await wait();
@@ -27,6 +27,7 @@ export async function pollDeployment(argv, fileId, account, project) {
27
27
  if (zupResponse.ok) {
28
28
  return {
29
29
  url,
30
+ steps,
30
31
  buildResult,
31
32
  };
32
33
  }
@@ -35,6 +36,7 @@ export async function pollDeployment(argv, fileId, account, project) {
35
36
  }
36
37
  case "ERROR":
37
38
  return {
39
+ steps,
38
40
  buildResult,
39
41
  };
40
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "author": "Zuplo, Inc.",