@zuplo/cli
Advanced tools
Comparing version 1.22.0 to 1.23.0
@@ -15,3 +15,2 @@ import setBlocking from "../common/output.js"; | ||
}) | ||
.demandOption(["api-key"]) | ||
.option("dir", { | ||
@@ -24,2 +23,9 @@ type: "string", | ||
}) | ||
.option("verify-remote", { | ||
type: "boolean", | ||
describe: "Verify that this Git repository matches the one configured on Zuplo. Use --no-verify-remote to disable.", | ||
default: true, | ||
}) | ||
.demandOption(["api-key"]) | ||
.boolean("verify-remote") | ||
.check(async (argv) => { | ||
@@ -26,0 +32,0 @@ return await new YargsChecker(validDeployDirectoryValidator).check(argv.dir); |
@@ -11,7 +11,8 @@ import ignore from "ignore"; | ||
export const ARCHIVE_EXTENSION = ".tar.gz"; | ||
export async function archive(dir) { | ||
export async function archive(argv) { | ||
const tarball = temp.path({ suffix: ARCHIVE_EXTENSION }); | ||
const dir = argv.dir; | ||
const ignoreFn = createIgnoreFunction(dir); | ||
const normalizedDir = join(relative(process.cwd(), dir)); | ||
const metadata = await prepareDeployerMetadata(dir); | ||
const metadata = await prepareDeployerMetadata(argv); | ||
await tar.create({ | ||
@@ -63,8 +64,10 @@ gzip: true, | ||
} | ||
async function prepareDeployerMetadata(dir) { | ||
const metadata = await generateMetadata(dir); | ||
async function prepareDeployerMetadata(argv) { | ||
const dir = argv.dir; | ||
const metadata = await generateMetadata(argv); | ||
await writeGeneratedMetadata(dir, metadata); | ||
return metadata; | ||
} | ||
async function generateMetadata(dir) { | ||
async function generateMetadata(argv) { | ||
const dir = argv.dir; | ||
const git = simpleGit({ baseDir: dir }); | ||
@@ -78,2 +81,3 @@ const status = await git.status(); | ||
const repoUrl = (await git.listRemote(["--get-url"])).trim(); | ||
const verifyRemote = argv["verify-remote"]; | ||
return { | ||
@@ -83,2 +87,3 @@ branch, | ||
sha, | ||
verifyRemote, | ||
}; | ||
@@ -85,0 +90,0 @@ } |
@@ -9,3 +9,3 @@ import { parse } from "path"; | ||
export async function deploy(argv) { | ||
const archiveMetadata = await archive(argv.dir); | ||
const archiveMetadata = await archive(argv); | ||
logger.info(`Tarball created locally at ${archiveMetadata}`); | ||
@@ -32,3 +32,3 @@ const whoAmIResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`, { | ||
const fileId = parse(new URL(uploadUrl).pathname).base.replace(ARCHIVE_EXTENSION, ""); | ||
const { url, buildResult } = await pollDeployment(argv, fileId, account, project); | ||
const { url, steps, buildResult } = await pollDeployment(argv, fileId, account, project); | ||
if (url) { | ||
@@ -38,3 +38,4 @@ printResultToConsoleAndExitGracefully(`Deployed to ${url}`); | ||
else { | ||
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)}`); | ||
const diagnostics = buildResult ?? steps; | ||
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)}`); | ||
} | ||
@@ -41,0 +42,0 @@ } |
@@ -20,3 +20,3 @@ import { logger } from "../common/logger.js"; | ||
const rawJSON = await response.text(); | ||
const { status, url, buildResult } = JSON.parse(rawJSON); | ||
const { status, url, steps, buildResult } = JSON.parse(rawJSON); | ||
switch (status) { | ||
@@ -31,2 +31,3 @@ case "IN_PROGRESS": | ||
url, | ||
steps, | ||
buildResult, | ||
@@ -40,2 +41,3 @@ }; | ||
return { | ||
steps, | ||
buildResult, | ||
@@ -42,0 +44,0 @@ }; |
{ | ||
"name": "@zuplo/cli", | ||
"version": "1.22.0", | ||
"version": "1.23.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/zuplo/cli", |
36056
907