Skip to content

Commit 9cbe0ee

Browse files
committed
ref: Show target names before publishing
1 parent 7a30a6f commit 9cbe0ee

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/commands/publish.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Github from '@octokit/rest';
2-
import { isDryRun, shouldPerform } from 'dryrun';
2+
import { shouldPerform } from 'dryrun';
33
import * as inquirer from 'inquirer';
44
import * as ora from 'ora';
55
import { Arguments, Argv } from 'yargs';
@@ -41,7 +41,7 @@ export const builder = (yargs: Argv) =>
4141
SpecialTarget.All,
4242
SpecialTarget.None,
4343
]),
44-
default: 'all',
44+
default: SpecialTarget.All,
4545
description: 'Publish to this target',
4646
type: 'string',
4747
})
@@ -311,10 +311,12 @@ async function waitForTheBuildToSucceed(
311311
*
312312
* @param zeus Zeus store object
313313
* @param revision Git revision SHA
314+
* @param targetNames A list of target names to publish
314315
*/
315316
async function printRevisionSummary(
316317
zeus: ZeusStore,
317-
revision: string
318+
revision: string,
319+
targetNames: string[]
318320
): Promise<void> {
319321
const artifacts = await zeus.listArtifactsForRevision(revision);
320322
const artifactData = artifacts.map(ar => [ar.name, ar.updated_at || '']);
@@ -326,13 +328,19 @@ async function printRevisionSummary(
326328
},
327329
artifactData
328330
);
329-
logger.info('Available files:', table.toString());
331+
332+
logger.info(`Available files: \n${table.toString()}\n`);
333+
334+
logger.info('Publishing to targets:');
335+
// TODO init all targets earlier
336+
targetNames.forEach(target => logger.info(` - ${target}`));
337+
logger.info(' ');
330338

331339
if (hasInput()) {
332340
const questions = [
333341
{
334342
default: false,
335-
message: 'Is it OK to proceed with publishing?',
343+
message: 'Is it OK to proceed?',
336344
name: 'readyToPublish',
337345
type: 'confirm',
338346
},
@@ -453,9 +461,6 @@ async function handleReleaseBranch(
453461
*/
454462
export async function publishMain(argv: PublishOptions): Promise<any> {
455463
logger.debug('Argv:', JSON.stringify(argv));
456-
if (isDryRun()) {
457-
logger.info('[dry-run] Dry-run mode is on!');
458-
}
459464
checkMinimalConfigVersion();
460465
checkPrerequisites();
461466

@@ -500,8 +505,6 @@ export async function publishMain(argv: PublishOptions): Promise<any> {
500505
// Check status of all CI builds linked to the revision
501506
await checkRevisionStatus(zeus, revision, argv.noStatusCheck);
502507

503-
await printRevisionSummary(zeus, revision);
504-
505508
// Find targets
506509
const targetList: string[] = (typeof argv.target === 'string'
507510
? [argv.target]
@@ -518,7 +521,8 @@ export async function publishMain(argv: PublishOptions): Promise<any> {
518521
}
519522

520523
let targetConfigList = config.targets || [];
521-
if (targetList[0] !== 'all') {
524+
525+
if (targetList[0] !== SpecialTarget.All) {
522526
targetConfigList = targetConfigList.filter(
523527
(targetConf: { [key: string]: any }) =>
524528
targetList.indexOf(targetConf.name) > -1
@@ -530,6 +534,13 @@ export async function publishMain(argv: PublishOptions): Promise<any> {
530534
logger.warn('No valid targets detected! Exiting.');
531535
return undefined;
532536
}
537+
538+
await printRevisionSummary(
539+
zeus,
540+
revision,
541+
targetConfigList.map(t => t.name || '__undefined__')
542+
);
543+
533544
await publishToTargets(
534545
githubConfig,
535546
newVersion,

0 commit comments

Comments
 (0)