@hubspot/cli 4.1.6-beta.1 → 4.1.7-beta.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.
@@ -10,7 +10,10 @@ const { logger } = require('@hubspot/cli-lib/logger');
10
10
  const Spinnies = require('spinnies');
11
11
  const { createSandbox } = require('@hubspot/cli-lib/sandboxes');
12
12
  const { loadAndValidateOptions } = require('../../lib/validation');
13
- const { createSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
13
+ const {
14
+ createSandboxPrompt,
15
+ getSandboxType,
16
+ } = require('../../lib/prompts/sandboxesPrompt');
14
17
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
15
18
  const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
16
19
  const {
@@ -122,6 +125,21 @@ exports.handler = async options => {
122
125
 
123
126
  trackCommandUsage('sandbox-create', null, accountId);
124
127
 
128
+ if (
129
+ accountConfig.sandboxAccountType &&
130
+ accountConfig.sandboxAccountType !== null
131
+ ) {
132
+ trackCommandUsage('sandbox-create', { successful: false }, accountId);
133
+
134
+ logger.error(
135
+ i18n(`${i18nKey}.failure.creatingWithinSandbox`, {
136
+ sandboxType: getSandboxType(accountConfig.sandboxAccountType),
137
+ })
138
+ );
139
+
140
+ process.exit(EXIT_CODES.ERROR);
141
+ }
142
+
125
143
  let namePrompt;
126
144
 
127
145
  logger.log(i18n(`${i18nKey}.sandboxLimitation`));
package/lib/projects.js CHANGED
@@ -18,6 +18,8 @@ const {
18
18
  PROJECT_BUILD_TEXT,
19
19
  PROJECT_DEPLOY_TEXT,
20
20
  PROJECT_CONFIG_FILE,
21
+ PROJECT_TASK_TYPES,
22
+ SPINNER_STATUS,
21
23
  } = require('@hubspot/cli-lib/lib/constants');
22
24
  const {
23
25
  createProject,
@@ -361,7 +363,7 @@ const handleProjectUpload = async (
361
363
  archive.pipe(output);
362
364
 
363
365
  archive.directory(srcDir, false, file =>
364
- shouldIgnoreFile(file.name) ? false : file
366
+ shouldIgnoreFile(file.name, true) ? false : file
365
367
  );
366
368
 
367
369
  archive.finalize();
@@ -374,6 +376,8 @@ const makePollTaskStatusFunc = ({
374
376
  statusStrings,
375
377
  linkToHubSpot,
376
378
  }) => {
379
+ const i18nKey = 'cli.commands.project.lib.makePollTaskStatusFunc';
380
+
377
381
  const isTaskComplete = task => {
378
382
  if (
379
383
  !task[statusText.SUBTASK_KEY].length ||
@@ -410,29 +414,60 @@ const makePollTaskStatusFunc = ({
410
414
  structureFn(accountId, taskName, taskId),
411
415
  ]);
412
416
 
413
- const topLevelSubtasks = initialTaskStatus[statusText.SUBTASK_KEY].filter(
414
- ({ id }) => !!taskStructure[id]
417
+ const tasksById = initialTaskStatus[statusText.SUBTASK_KEY].reduce(
418
+ (acc, task) => {
419
+ const type = task[statusText.TYPE_KEY];
420
+ if (type !== 'APP_ID' && type !== 'SERVERLESS_PKG') {
421
+ acc[task.id] = task;
422
+ }
423
+ return acc;
424
+ },
425
+ {}
415
426
  );
416
427
 
417
- const numOfComponents = topLevelSubtasks.length;
418
- const componentCountText = `\nFound ${numOfComponents} component${
419
- numOfComponents !== 1 ? 's' : ''
420
- } in this project ...\n`;
428
+ const structuredTasks = Object.keys(taskStructure).map(key => {
429
+ return {
430
+ ...tasksById[key],
431
+ subtasks: taskStructure[key]
432
+ .filter(taskId => Boolean(tasksById[taskId]))
433
+ .map(taskId => tasksById[taskId]),
434
+ };
435
+ });
436
+
437
+ const numComponents = structuredTasks.length;
438
+ const componentCountText = i18n(
439
+ numComponents === 1
440
+ ? `${i18nKey}.componentCountSingular`
441
+ : `${i18nKey}.componentCount`,
442
+ { numComponents }
443
+ );
421
444
 
422
445
  spinnies.update('overallTaskStatus', {
423
- text: `${statusStrings.INITIALIZE(taskName)}${componentCountText}`,
446
+ text: `${statusStrings.INITIALIZE(taskName)}\n${componentCountText}\n`,
424
447
  });
425
448
 
426
- for (let subTask of topLevelSubtasks) {
427
- const subTaskName = subTask[statusText.SUBTASK_NAME_KEY];
428
-
429
- spinnies.add(subTaskName, {
430
- text: `${chalk.bold(subTaskName)} ${
431
- statusText.STATUS_TEXT[statusText.STATES.ENQUEUED]
432
- }\n`,
433
- indent: 2,
449
+ const addTaskSpinner = (task, indent, newline) => {
450
+ const taskName = task[statusText.SUBTASK_NAME_KEY];
451
+ const taskType = task[statusText.TYPE_KEY];
452
+ const formattedTaskType = PROJECT_TASK_TYPES[taskType]
453
+ ? `[${PROJECT_TASK_TYPES[taskType]}]`
454
+ : '';
455
+ const text = `${statusText.STATUS_TEXT} ${chalk.bold(
456
+ taskName
457
+ )} ${formattedTaskType} ...${newline ? '\n' : ''}`;
458
+
459
+ spinnies.add(task.id, {
460
+ text,
461
+ indent,
434
462
  });
435
- }
463
+ };
464
+
465
+ structuredTasks.forEach(task => {
466
+ addTaskSpinner(task, 2, !task.subtasks || task.subtasks.length === 0);
467
+ task.subtasks.forEach((subtask, i) =>
468
+ addTaskSpinner(subtask, 4, i === task.subtasks.length - 1)
469
+ );
470
+ });
436
471
 
437
472
  return new Promise((resolve, reject) => {
438
473
  const pollInterval = setInterval(async () => {
@@ -444,34 +479,43 @@ const makePollTaskStatusFunc = ({
444
479
 
445
480
  if (spinnies.hasActiveSpinners()) {
446
481
  subTaskStatus.forEach(subTask => {
447
- const subTaskName = subTask[statusText.SUBTASK_NAME_KEY];
482
+ const { id, status } = subTask;
483
+ const spinner = spinnies.pick(id);
448
484
 
449
- if (!spinnies.pick(subTaskName)) {
485
+ if (!spinner || spinner.status !== SPINNER_STATUS.SPINNING) {
450
486
  return;
451
487
  }
452
488
 
453
- const updatedText = `${chalk.bold(subTaskName)} ${
454
- statusText.STATUS_TEXT[subTask.status]
455
- }\n`;
456
-
457
- switch (subTask.status) {
458
- case statusText.STATES.SUCCESS:
459
- spinnies.succeed(subTaskName, { text: updatedText });
460
- break;
461
- case statusText.STATES.FAILURE:
462
- spinnies.fail(subTaskName, { text: updatedText });
463
- break;
464
- default:
465
- spinnies.update(subTaskName, { text: updatedText });
466
- break;
489
+ const topLevelTask = structuredTasks.find(t => t.id == id);
490
+
491
+ if (
492
+ status === statusText.STATES.SUCCESS ||
493
+ status === statusText.STATES.FAILURE
494
+ ) {
495
+ const taskStatusText =
496
+ subTask.status === statusText.STATES.SUCCESS
497
+ ? i18n(`${i18nKey}.successStatusText`)
498
+ : i18n(`${i18nKey}.failedStatusText`);
499
+ const hasNewline =
500
+ spinner.text.includes('\n') || Boolean(topLevelTask);
501
+ const updatedText = `${spinner.text.replace(
502
+ '\n',
503
+ ''
504
+ )} ${taskStatusText}${hasNewline ? '\n' : ''}`;
505
+
506
+ status === statusText.STATES.SUCCESS
507
+ ? spinnies.succeed(id, { text: updatedText })
508
+ : spinnies.fail(id, { text: updatedText });
509
+
510
+ if (topLevelTask) {
511
+ topLevelTask.subtasks.forEach(currentSubtask =>
512
+ spinnies.remove(currentSubtask.id)
513
+ );
514
+ }
467
515
  }
468
516
  });
469
517
 
470
518
  if (isTaskComplete(taskStatus)) {
471
- // subTaskStatus.forEach(subTask => {
472
- // spinnies.remove(subTask[statusText.SUBTASK_NAME_KEY]);
473
- // });
474
-
475
519
  if (status === statusText.STATES.SUCCESS) {
476
520
  spinnies.succeed('overallTaskStatus', {
477
521
  text: statusStrings.SUCCESS(taskName),
@@ -481,7 +525,7 @@ const makePollTaskStatusFunc = ({
481
525
  text: statusStrings.FAIL(taskName),
482
526
  });
483
527
 
484
- const failedSubtask = subTaskStatus.filter(
528
+ const failedSubtasks = subTaskStatus.filter(
485
529
  subtask => subtask.status === 'FAILURE'
486
530
  );
487
531
 
@@ -489,19 +533,19 @@ const makePollTaskStatusFunc = ({
489
533
  logger.log(
490
534
  `${statusStrings.SUBTASK_FAIL(
491
535
  displayId,
492
- failedSubtask.length === 1
493
- ? failedSubtask[0][statusText.SUBTASK_NAME_KEY]
494
- : failedSubtask.length + ' components'
536
+ failedSubtasks.length === 1
537
+ ? failedSubtasks[0][statusText.SUBTASK_NAME_KEY]
538
+ : failedSubtasks.length + ' components'
495
539
  )}\n`
496
540
  );
497
541
  logger.log('See below for a summary of errors.');
498
542
  uiLine();
499
543
 
500
- failedSubtask.forEach(subTask => {
544
+ failedSubtasks.forEach(subTask => {
501
545
  logger.log(
502
- `\n--- ${chalk.bold(subTask[statusText.SUBTASK_NAME_KEY])} ${
503
- statusText.STATUS_TEXT[subTask.status]
504
- } with the following error ---`
546
+ `\n--- ${chalk.bold(
547
+ subTask[statusText.SUBTASK_NAME_KEY]
548
+ )} failed with the following error ---`
505
549
  );
506
550
  logger.error(subTask.errorMessage);
507
551
 
@@ -1,7 +1,19 @@
1
1
  const { updateDefaultAccount } = require('@hubspot/cli-lib/lib/config');
2
2
  const { promptUser } = require('./promptUtils');
3
3
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
4
- const { mapAccountChoices } = require('./sandboxesPrompt');
4
+
5
+ const getSandboxType = type =>
6
+ type === 'DEVELOPER' ? 'development' : 'standard';
7
+
8
+ const mapAccountChoices = portals =>
9
+ portals.map(p => {
10
+ const isSandbox = p.sandboxAccountType && p.sandboxAccountType !== null;
11
+ const sandboxName = `[${getSandboxType(p.sandboxAccountType)} sandbox] `;
12
+ return {
13
+ name: `${p.name} ${isSandbox ? sandboxName : ''}(${p.portalId})`,
14
+ value: p.name || p.portalId,
15
+ };
16
+ });
5
17
 
6
18
  const i18nKey = 'cli.commands.accounts.subcommands.use';
7
19
 
@@ -6,15 +6,16 @@ const i18nKey = 'cli.lib.prompts.sandboxesPrompt';
6
6
  const getSandboxType = type =>
7
7
  type === 'DEVELOPER' ? 'development' : 'standard';
8
8
 
9
- const mapAccountChoices = portals =>
10
- portals.map(p => {
11
- const isSandbox = p.sandboxAccountType !== null;
12
- const sandboxName = `[${getSandboxType(p.sandboxAccountType)} sandbox] `;
13
- return {
14
- name: `${p.name} ${isSandbox ? sandboxName : ''}(${p.portalId})`,
15
- value: p.name || p.portalId,
16
- };
17
- });
9
+ const mapSandboxAccountChoices = portals =>
10
+ portals
11
+ .filter(p => p.sandboxAccountType && p.sandboxAccountType !== null)
12
+ .map(p => {
13
+ const sandboxName = `[${getSandboxType(p.sandboxAccountType)} sandbox] `;
14
+ return {
15
+ name: `${p.name} ${sandboxName}(${p.portalId})`,
16
+ value: p.name || p.portalId,
17
+ };
18
+ });
18
19
 
19
20
  const createSandboxPrompt = () => {
20
21
  return promptUser([
@@ -44,7 +45,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
44
45
  type: 'list',
45
46
  look: false,
46
47
  pageSize: 20,
47
- choices: mapAccountChoices(config.portals),
48
+ choices: mapSandboxAccountChoices(config.portals),
48
49
  default: config.defaultPortal,
49
50
  },
50
51
  ]);
@@ -54,5 +55,4 @@ module.exports = {
54
55
  createSandboxPrompt,
55
56
  deleteSandboxPrompt,
56
57
  getSandboxType,
57
- mapAccountChoices,
58
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.1.6-beta.1",
3
+ "version": "4.1.7-beta.0",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,8 +8,8 @@
8
8
  "url": "https://github.com/HubSpot/hubspot-cms-tools"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/cli-lib": "4.1.6-beta.1",
12
- "@hubspot/serverless-dev-runtime": "4.1.6-beta.1",
11
+ "@hubspot/cli-lib": "4.1.7-beta.0",
12
+ "@hubspot/serverless-dev-runtime": "4.1.7-beta.0",
13
13
  "archiver": "^5.3.0",
14
14
  "chalk": "^4.1.2",
15
15
  "express": "^4.17.1",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "886b32d3fd4385be85dfb118e58b61a24a7ac568"
40
+ "gitHead": "2f99be18415403ff6bbd48faba96cf5315f220ab"
41
41
  }