Skip to content

Commit

Permalink
Fix event order in CLI (#3502)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdev authored and kodiakhq[bot] committed Jan 6, 2020
1 parent 718a451 commit b5142d9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
4 changes: 1 addition & 3 deletions packages/now-cli/src/commands/dev/dev.ts
Expand Up @@ -17,9 +17,7 @@ export default async function dev(
args: string[],
output: Output
) {
output.dim(
`Now CLI ${pkg.version} dev (beta) — https://zeit.co/feedback`
);
output.dim(`Now CLI ${pkg.version} dev (beta) — https://zeit.co/feedback`);

const [dir = '.'] = args;
const cwd = path.resolve(dir);
Expand Down
40 changes: 22 additions & 18 deletions packages/now-cli/src/commands/scale.js
Expand Up @@ -18,7 +18,10 @@ import getMinFromArgs from '../util/scale/get-min-from-args';
import patchDeploymentScale from '../util/scale/patch-deployment-scale';
import waitVerifyDeploymentScale from '../util/scale/wait-verify-deployment-scale';
import { handleError } from '../util/error';
import { VerifyScaleTimeout, DeploymentTypeUnsupported } from '../util/errors-ts';
import {
VerifyScaleTimeout,
DeploymentTypeUnsupported,
} from '../util/errors-ts';
import {
DeploymentNotFound,
DeploymentPermissionDenied,
Expand All @@ -28,7 +31,7 @@ import {
InvalidMaxForScale,
InvalidMinForScale,
InvalidScaleMinMaxRelation,
NotSupportedMinScaleSlots
NotSupportedMinScaleSlots,
} from '../util/errors-ts';
import { InvalidAllForScale, InvalidRegionOrDCForScale } from '../util/errors';
import handleCertError from '../util/certs/handle-cert-error';
Expand Down Expand Up @@ -56,7 +59,9 @@ const help = () => {
${chalk.dim('Examples:')}
${chalk.gray('–')} Enable your deployment in all datacenters (min: 0, max: auto)
${chalk.gray(
'–'
)} Enable your deployment in all datacenters (min: 0, max: auto)
${chalk.cyan('$ now scale my-deployment-123.now.sh all')}
Expand Down Expand Up @@ -87,7 +92,7 @@ export default async function main(ctx) {
argv = getArgs(ctx.argv.slice(2), {
'--verify-timeout': Number,
'--no-verify': Boolean,
'-n': '--no-verify'
'-n': '--no-verify',
});
} catch (err) {
handleError(err);
Expand All @@ -100,7 +105,10 @@ export default async function main(ctx) {
}

// Prepare the context
const { authConfig: { token }, config } = ctx;
const {
authConfig: { token },
config,
} = ctx;
const { currentTeam } = config;
const { apiUrl } = ctx;
const debug = argv['--debug'];
Expand Down Expand Up @@ -155,8 +163,7 @@ export default async function main(ctx) {
}
if (dcs instanceof InvalidRegionOrDCForScale) {
output.error(
`The value "${dcs.meta
.regionOrDC}" is not a valid region or DC identifier`
`The value "${dcs.meta.regionOrDC}" is not a valid region or DC identifier`
);
now.close();
return 1;
Expand All @@ -165,8 +172,7 @@ export default async function main(ctx) {
const min = getMinFromArgs(argv._);
if (min instanceof InvalidMinForScale) {
output.error(
`Invalid <min> parameter "${min.meta
.value}". A number or "auto" were expected`
`Invalid <min> parameter "${min.meta.value}". A number or "auto" were expected`
);
now.close();
return 1;
Expand All @@ -175,24 +181,21 @@ export default async function main(ctx) {
const max = getMaxFromArgs(argv._);
if (max instanceof InvalidMinForScale) {
output.error(
`Invalid <min> parameter "${max.meta
.value}". A number or "auto" were expected`
`Invalid <min> parameter "${max.meta.value}". A number or "auto" were expected`
);
now.close();
return 1;
}
if (max instanceof InvalidArgsForMinMaxScale) {
output.error(
`Invalid number of arguments: expected <min> ("${max.meta
.min}") and [max]`
`Invalid number of arguments: expected <min> ("${max.meta.min}") and [max]`
);
now.close();
return 1;
}
if (max instanceof InvalidMaxForScale) {
output.error(
`Invalid <max> parameter "${max.meta
.value}". A number or "auto" were expected`
`Invalid <max> parameter "${max.meta.value}". A number or "auto" were expected`
);
now.close();
return 1;
Expand Down Expand Up @@ -262,14 +265,15 @@ export default async function main(ctx) {
deployment.url
);
if (result instanceof ForbiddenScaleMinInstances) {
output.error(`You can't scale to more than ${result.meta.max} min instances with your current plan.`);
output.error(
`You can't scale to more than ${result.meta.max} min instances with your current plan.`
);
now.close();
return 1;
}
if (result instanceof ForbiddenScaleMaxInstances) {
output.error(
`You can't scale to more than ${result.meta
.max} max instances with your current plan.`
`You can't scale to more than ${result.meta.max} max instances with your current plan.`
);
now.close();
return 1;
Expand Down
38 changes: 18 additions & 20 deletions packages/now-cli/src/util/deploy/process-deployment.ts
Expand Up @@ -82,16 +82,6 @@ export default async function processDeployment({
`Total files ${event.payload.total.size}, ${event.payload.missing.length} changed`
);

if (!quiet) {
log(
`Synced ${pluralize(
'file',
event.payload.missing.length,
true
)} ${uploadStamp()}`
);
}

const missingSize = event.payload.missing
.map((sha: string) => event.payload.total.get(sha).data.length)
.reduce((a: number, b: number) => a + b, 0);
Expand Down Expand Up @@ -121,14 +111,24 @@ export default async function processDeployment({
now._host = event.payload.url;

if (!quiet) {
log(
`Synced ${pluralize(
'file',
event.payload.missing.length,
true
)} ${uploadStamp()}`
);
const version = isLegacy ? `${chalk.grey('[v1]')} ` : '';
log(`https://${event.payload.url} ${version}${deployStamp()}`);
} else {
process.stdout.write(`https://${event.payload.url}`);
}

if (queuedSpinner === null) {
queuedSpinner = wait('Queued...');
queuedSpinner =
event.payload.readyState === 'QUEUED'
? wait('Queued...')
: wait('Building...');
}
}

Expand Down Expand Up @@ -200,15 +200,6 @@ export default async function processDeployment({
debug(
`Total files ${event.payload.total.size}, ${event.payload.missing.length} changed`
);
if (!quiet) {
log(
`Synced ${pluralize(
'file',
event.payload.missing.length,
true
)} ${uploadStamp()}`
);
}

const missingSize = event.payload.missing
.map((sha: string) => event.payload.total.get(sha).data.length)
Expand Down Expand Up @@ -239,6 +230,13 @@ export default async function processDeployment({
now._host = event.payload.url;

if (!quiet) {
log(
`Synced ${pluralize(
'file',
event.payload.missing.length,
true
)} ${uploadStamp()}`
);
const version = isLegacy ? `${chalk.grey('[v1]')} ` : '';
log(`${event.payload.url} ${version}${deployStamp()}`);
} else {
Expand Down
7 changes: 3 additions & 4 deletions packages/now-python/src/index.ts
Expand Up @@ -36,11 +36,10 @@ export async function downloadFilesInWorkPath({
files,
meta,
config,

}: BuildOptions) {
debug('Downloading user files...');
let downloadedFiles = await download(files, workPath, meta);
if (meta && meta.isDev) {
debug('Downloading user files...');
let downloadedFiles = await download(files, workPath, meta);
if (meta && meta.isDev) {
let base = null;

if (config && config.zeroConfig) {
Expand Down

0 comments on commit b5142d9

Please sign in to comment.