@hubspot/cli 7.4.2 → 7.4.3-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.
package/api/migrate.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.isMigrationStatus = isMigrationStatus;
7
4
  exports.listAppsForMigration = listAppsForMigration;
@@ -10,8 +7,6 @@ exports.continueMigration = continueMigration;
10
7
  exports.checkMigrationStatusV2 = checkMigrationStatusV2;
11
8
  const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
12
9
  const http_1 = require("@hubspot/local-dev-lib/http");
13
- const logger_1 = require("@hubspot/local-dev-lib/logger");
14
- const util_1 = __importDefault(require("util"));
15
10
  const MIGRATIONS_API_PATH_V2 = 'dfs/migrations/v2';
16
11
  function isMigrationStatus(error) {
17
12
  return (typeof error === 'object' &&
@@ -53,9 +48,7 @@ async function continueMigration(portalId, migrationId, componentUids, projectNa
53
48
  });
54
49
  }
55
50
  async function checkMigrationStatusV2(accountId, id) {
56
- const response = await http_1.http.get(accountId, {
51
+ return http_1.http.get(accountId, {
57
52
  url: `${MIGRATIONS_API_PATH_V2}/migrations/${id}/status`,
58
53
  });
59
- logger_1.logger.debug(util_1.default.inspect(response.data, { depth: null }));
60
- return response;
61
54
  }
package/lang/en.d.ts CHANGED
@@ -2795,6 +2795,8 @@ export declare const lib: {
2795
2795
  migrate: {
2796
2796
  componentsToBeMigrated: (components: any) => string;
2797
2797
  componentsThatWillNotBeMigrated: (components: any) => string;
2798
+ sourceContentsMoved: (newLocation: string) => string;
2799
+ projectMigrationWarning: string;
2798
2800
  errors: {
2799
2801
  project: {
2800
2802
  invalidConfig: string;
package/lang/en.js CHANGED
@@ -2754,6 +2754,8 @@ exports.lib = {
2754
2754
  migrate: {
2755
2755
  componentsToBeMigrated: components => `The following component types will be migrated: ${components}`,
2756
2756
  componentsThatWillNotBeMigrated: components => `[NOTE] These component types are not yet supported for migration but will be available later: ${components}`,
2757
+ sourceContentsMoved: (newLocation) => `The contents of your old source directory have been moved to ${newLocation}, move any required files to the new source directory.`,
2758
+ projectMigrationWarning: `Migrating a project is irreversible and cannot be undone.`,
2757
2759
  errors: {
2758
2760
  project: {
2759
2761
  invalidConfig: 'The project configuration file is invalid. Please check the config file and try again.',
@@ -23,7 +23,6 @@ const polling_1 = require("../polling");
23
23
  const migrate_1 = require("../../api/migrate");
24
24
  const fs_1 = __importDefault(require("fs"));
25
25
  const en_1 = require("../../lang/en");
26
- const util_1 = __importDefault(require("util"));
27
26
  const hasFeature_1 = require("../hasFeature");
28
27
  function getUnmigratableReason(reasonCode) {
29
28
  switch (reasonCode) {
@@ -69,7 +68,7 @@ async function fetchMigrationApps(appId, derivedAccountId, platformVersion, proj
69
68
  }
70
69
  return allApps;
71
70
  }
72
- async function selectAppToMigrate(allApps, appId) {
71
+ async function selectAppToMigrate(allApps, appId, projectConfig) {
73
72
  if (appId &&
74
73
  !allApps.some(app => {
75
74
  return app.appId === appId;
@@ -93,24 +92,27 @@ async function selectAppToMigrate(allApps, appId) {
93
92
  appIdToMigrate = selectedAppId;
94
93
  }
95
94
  const selectedApp = allApps.find(app => app.appId === appIdToMigrate);
96
- const migratableComponents = [];
97
- const unmigratableComponents = [];
95
+ const migratableComponents = new Set();
96
+ const unmigratableComponents = new Set();
98
97
  selectedApp?.migrationComponents.forEach(component => {
99
98
  if (component.isSupported) {
100
- migratableComponents.push((0, transform_1.mapToUserFacingType)(component.componentType));
99
+ migratableComponents.add((0, transform_1.mapToUserFacingType)(component.componentType));
101
100
  }
102
101
  else {
103
- unmigratableComponents.push((0, transform_1.mapToUserFacingType)(component.componentType));
102
+ unmigratableComponents.add((0, transform_1.mapToUserFacingType)(component.componentType));
104
103
  }
105
104
  });
106
- if (migratableComponents.length !== 0) {
107
- logger_1.logger.log(en_1.lib.migrate.componentsToBeMigrated(`\n - ${migratableComponents.join('\n - ')}`));
105
+ if (migratableComponents.size !== 0) {
106
+ logger_1.logger.log(en_1.lib.migrate.componentsToBeMigrated(`\n - ${[...migratableComponents].join('\n - ')}`));
108
107
  }
109
- if (unmigratableComponents.length !== 0) {
110
- logger_1.logger.log(en_1.lib.migrate.componentsThatWillNotBeMigrated(`\n - ${unmigratableComponents.join('\n - ')}`));
108
+ if (unmigratableComponents.size !== 0) {
109
+ logger_1.logger.log(en_1.lib.migrate.componentsThatWillNotBeMigrated(`\n - ${[...unmigratableComponents].join('\n - ')}`));
111
110
  }
112
111
  logger_1.logger.log();
113
- const proceed = await (0, promptUtils_1.confirmPrompt)(en_1.lib.migrate.prompt.proceed);
112
+ const promptMessage = projectConfig?.projectConfig
113
+ ? `${en_1.lib.migrate.projectMigrationWarning} ${en_1.lib.migrate.prompt.proceed}`
114
+ : en_1.lib.migrate.prompt.proceed;
115
+ const proceed = await (0, promptUtils_1.confirmPrompt)(promptMessage);
114
116
  return {
115
117
  proceed,
116
118
  appIdToMigrate,
@@ -119,7 +121,7 @@ async function selectAppToMigrate(allApps, appId) {
119
121
  async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
120
122
  const { name, dest, appId } = options;
121
123
  const allApps = await fetchMigrationApps(appId, derivedAccountId, options.platformVersion, projectConfig);
122
- const { proceed, appIdToMigrate } = await selectAppToMigrate(allApps, appId);
124
+ const { proceed, appIdToMigrate } = await selectAppToMigrate(allApps, appId, projectConfig);
123
125
  if (!proceed) {
124
126
  return {};
125
127
  }
@@ -133,9 +135,16 @@ async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
133
135
  projectDest: projectConfig.projectDir,
134
136
  };
135
137
  }
136
- const projectName = projectConfig?.projectConfig?.name ||
137
- name ||
138
- (await (0, promptUtils_1.inputPrompt)(en_1.lib.migrate.prompt.inputName));
138
+ const projectName = name ||
139
+ (await (0, promptUtils_1.inputPrompt)(en_1.lib.migrate.prompt.inputName, {
140
+ validate: async (input) => {
141
+ const { projectExists } = await (0, projects_3.ensureProjectExists)(derivedAccountId, input, { allowCreate: false, noLogs: true });
142
+ if (projectExists) {
143
+ return en_1.lib.migrate.errors.project.alreadyExists(input);
144
+ }
145
+ return true;
146
+ },
147
+ }));
139
148
  const { projectExists } = await (0, projects_3.ensureProjectExists)(derivedAccountId, projectName, { allowCreate: false, noLogs: true });
140
149
  if (projectExists) {
141
150
  throw new Error(en_1.lib.migrate.errors.project.alreadyExists(projectName));
@@ -211,7 +220,6 @@ async function finalizeMigration(derivedAccountId, migrationId, uidMap, projectN
211
220
  if (pollResponse.status !== Migration_1.MIGRATION_STATUS.SUCCESS) {
212
221
  throw new Error(en_1.lib.migrate.errors.migrationFailed);
213
222
  }
214
- logger_1.logger.debug(util_1.default.inspect(pollResponse, { depth: null }));
215
223
  if (pollResponse.status === Migration_1.MIGRATION_STATUS.SUCCESS) {
216
224
  SpinniesManager_1.default.succeed('finishingMigration', {
217
225
  text: en_1.lib.migrate.spinners.migrationComplete,
@@ -233,6 +241,7 @@ async function downloadProjectFiles(derivedAccountId, projectName, buildId, proj
233
241
  const archiveDest = path_1.default.join(projectDir, 'archive');
234
242
  // Move the existing source directory to archive
235
243
  fs_1.default.renameSync(path_1.default.join(projectDir, srcDir), archiveDest);
244
+ logger_1.logger.info(en_1.lib.migrate.sourceContentsMoved(archiveDest));
236
245
  }
237
246
  else {
238
247
  absoluteDestPath = projectDest
@@ -10,6 +10,6 @@ export declare function listPrompt<T = string>(message: string, { choices, when,
10
10
  }): Promise<T>;
11
11
  export declare function inputPrompt(message: string, { when, validate, defaultAnswer, }?: {
12
12
  when?: boolean | (() => boolean);
13
- validate?: (input: string) => boolean | string;
13
+ validate?: (input: string) => (boolean | string) | Promise<boolean | string>;
14
14
  defaultAnswer?: string;
15
15
  }): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.4.2",
3
+ "version": "7.4.3-beta.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",