diff --git a/lib/deploy/defaultStrategy.js b/lib/deploy/defaultStrategy.js index 1354b9a5..8b9c525c 100644 --- a/lib/deploy/defaultStrategy.js +++ b/lib/deploy/defaultStrategy.js @@ -10,8 +10,8 @@ const createArchive = async (env) => { if (numberOfFiles == 0) throw 'Archive failed to create.'; }; -const uploadArchive = async (env) => { - const res = await push(env); +const uploadArchive = async (env, { spinner } = {}) => { + const res = await push(env, { spinner }); if (!res) throw 'Server did not accept release file.'; return res; @@ -27,7 +27,7 @@ const strategy = async ({ env, _authData, _params }) => { const spinner = ora({ text: `Deploying to: ${url}`, stream: process.stdout }); spinner.start(); - const duration = await uploadArchive(env); + const duration = await uploadArchive(env, { spinner }); spinner.succeed(`Deploy succeeded after ${duration}`); report('[OK] Deploy: Default Strategy'); diff --git a/lib/deploy/directAssetsUploadStrategy.js b/lib/deploy/directAssetsUploadStrategy.js index 6ee81d61..55bc5fe2 100644 --- a/lib/deploy/directAssetsUploadStrategy.js +++ b/lib/deploy/directAssetsUploadStrategy.js @@ -11,7 +11,7 @@ import report from '../logger/report.js'; import ServerError from '../ServerError.js'; const createArchive = (env) => makeArchive(env, { withoutAssets: true }); -const uploadArchive = (env) => push(env); +const uploadArchive = (env, { spinner } = {}) => push(env, { spinner }); const deployAndUploadAssets = async (authData) => { const assetsToDeploy = await files.getAssets(); @@ -34,7 +34,7 @@ const strategy = async ({ env, authData, _params }) => { const t0 = performance.now(); if (numberOfFiles > 0) { - await uploadArchive(env); + await uploadArchive(env, { spinner }); } else { logger.Warn('There are no files in release file, skipping.'); } diff --git a/lib/deploy/dryRunStrategy.js b/lib/deploy/dryRunStrategy.js index f81aa99b..45170b11 100644 --- a/lib/deploy/dryRunStrategy.js +++ b/lib/deploy/dryRunStrategy.js @@ -8,7 +8,7 @@ import report from '../logger/report.js'; import ServerError from '../ServerError.js'; const createArchive = (env) => makeArchive(env, { withoutAssets: true }); -const uploadArchive = (env) => push(env); +const uploadArchive = (env, { spinner } = {}) => push(env, { spinner }); const strategy = async ({ env, _authData, _params }) => { env.DRY_RUN = 'true'; @@ -24,7 +24,7 @@ const strategy = async ({ env, _authData, _params }) => { spinner.start(); if (numberOfFiles > 0) { - await uploadArchive(env); + await uploadArchive(env, { spinner }); } else { logger.Warn('There are no files in release file, skipping.'); } diff --git a/lib/push.js b/lib/push.js index 202701a1..f3231500 100644 --- a/lib/push.js +++ b/lib/push.js @@ -45,7 +45,7 @@ const printDeployReport = (deployReport, { verbose = false } = {}) => { const MAX_STATUS_RETRIES = 3; const isTransientError = (e) => e.name === 'RequestError' || (e.name === 'StatusCodeError' && e.statusCode >= 500); -const getDeploymentStatus = ({ id }) => { +const getDeploymentStatus = ({ id }, { spinner } = {}) => { return new Promise((resolve, reject) => { let retries = 0; let getStatus = () => { @@ -53,6 +53,10 @@ const getDeploymentStatus = ({ id }) => { .getStatus(id) .then(response => { if (response && response.status === 'ready_for_import') { + if (spinner) spinner.text = 'Deploy scheduled, waiting…'; + setTimeout(getStatus, 1000); + } else if (response && response.status === 'in_progress') { + if (spinner) spinner.text = 'Deploy in progress…'; setTimeout(getStatus, 1000); } else if (response && response.status === 'error') { const body = response.error; @@ -80,7 +84,7 @@ const getDeploymentStatus = ({ id }) => { }); }; -const push = async env => { +const push = async (env, { spinner } = {}) => { const program = { email: env.MARKETPLACE_EMAIL, token: env.MARKETPLACE_TOKEN, @@ -99,7 +103,7 @@ const push = async env => { gateway = new Gateway(program); return gateway .push(formData) - .then(getDeploymentStatus) + .then(res => getDeploymentStatus(res, { spinner })) .then((response) => { logger.Debug('Release deployed'); printDeployReport(response.report, { verbose: env.VERBOSE === true || env.VERBOSE === 'true' }); diff --git a/package-lock.json b/package-lock.json index 5ae764e9..a647fc3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6173,9 +6173,9 @@ } }, "node_modules/minimatch": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.2.tgz", - "integrity": "sha512-+G4CpNBxa5MprY+04MbgOw1v7So6n5JY166pFi9KfYwT78fxScCeSNQSNzp6dpPSW2rONOps6Ocam1wFhCgoVw==", + "version": "10.2.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz", + "integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==", "license": "BlueOak-1.0.0", "dependencies": { "brace-expansion": "^5.0.2" @@ -6318,18 +6318,6 @@ "node": ">= 18" } }, - "node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "license": "MIT", - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6337,21 +6325,22 @@ "license": "MIT" }, "node_modules/multer": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/multer/-/multer-2.0.2.tgz", - "integrity": "sha512-u7f2xaZ/UG8oLXHvtF/oWTRvT44p9ecwBBqTwgJVq0+4BW1g8OW01TyMEGWBHbyMOYVHXslaut7qEQ1meATXgw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/multer/-/multer-2.1.0.tgz", + "integrity": "sha512-TBm6j41rxNohqawsxlsWsNNh/VdV4QFXcBvRcPhXaA05EZ79z0qJ2bQFpync6JBoHTeNY5Q1JpG7AlTjdlfAEA==", "license": "MIT", "dependencies": { "append-field": "^1.0.0", "busboy": "^1.6.0", "concat-stream": "^2.0.0", - "mkdirp": "^0.5.6", - "object-assign": "^4.1.1", - "type-is": "^1.6.18", - "xtend": "^4.0.2" + "type-is": "^1.6.18" }, "engines": { "node": ">= 10.16.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/multer/node_modules/media-typer": { @@ -6705,15 +6694,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", @@ -9254,15 +9234,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "license": "MIT", - "engines": { - "node": ">=0.4" - } - }, "node_modules/yallist": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", diff --git a/test/unit/deploy.test.js b/test/unit/deploy.test.js index 16274791..e2ba42d6 100644 --- a/test/unit/deploy.test.js +++ b/test/unit/deploy.test.js @@ -24,7 +24,8 @@ vi.mock('ora', () => ({ start: vi.fn().mockReturnThis(), succeed: vi.fn().mockReturnThis(), fail: vi.fn().mockReturnThis(), - stop: vi.fn().mockReturnThis() + stop: vi.fn().mockReturnThis(), + text: '' }) }));