@hubspot/cli 7.5.5-experimental.0 → 7.5.7-experimental.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.d.ts +1 -1
- package/api/migrate.js +13 -3
- package/commands/project/migrate.d.ts +1 -2
- package/lang/en.d.ts +1 -1
- package/lang/en.js +1 -1
- package/lang/en.lyaml +2 -25
- package/lib/app/migrate.js +26 -4
- package/package.json +1 -1
package/api/migrate.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface MigrationFailed extends MigrationBaseStatus {
|
|
|
55
55
|
}
|
|
56
56
|
export type MigrationStatus = MigrationInProgress | MigrationInputRequired | MigrationSuccess | MigrationFailed;
|
|
57
57
|
export declare function isMigrationStatus(error: unknown): error is MigrationStatus;
|
|
58
|
-
export declare function listAppsForMigration(accountId: number): HubSpotPromise<ListAppsResponse>;
|
|
58
|
+
export declare function listAppsForMigration(accountId: number, platformVersion: string): HubSpotPromise<ListAppsResponse>;
|
|
59
59
|
export declare function initializeMigration(accountId: number, applicationId: number, platformVersion: string): HubSpotPromise<InitializeMigrationResponse>;
|
|
60
60
|
export declare function continueMigration(portalId: number, migrationId: number, componentUids: Record<string, string>, projectName: string): HubSpotPromise<ContinueMigrationResponse>;
|
|
61
61
|
export declare function checkMigrationStatusV2(accountId: number, id: number): HubSpotPromise<MigrationStatus>;
|
package/api/migrate.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isMigrationStatus = isMigrationStatus;
|
|
4
7
|
exports.listAppsForMigration = listAppsForMigration;
|
|
@@ -7,6 +10,8 @@ exports.continueMigration = continueMigration;
|
|
|
7
10
|
exports.checkMigrationStatusV2 = checkMigrationStatusV2;
|
|
8
11
|
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
9
12
|
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"));
|
|
10
15
|
const MIGRATIONS_API_PATH_V2 = 'dfs/migrations/v2';
|
|
11
16
|
function isMigrationStatus(error) {
|
|
12
17
|
return (typeof error === 'object' &&
|
|
@@ -14,9 +19,12 @@ function isMigrationStatus(error) {
|
|
|
14
19
|
'id' in error &&
|
|
15
20
|
'status' in error);
|
|
16
21
|
}
|
|
17
|
-
async function listAppsForMigration(accountId) {
|
|
22
|
+
async function listAppsForMigration(accountId, platformVersion) {
|
|
18
23
|
return http_1.http.get(accountId, {
|
|
19
24
|
url: `${MIGRATIONS_API_PATH_V2}/list-apps`,
|
|
25
|
+
params: {
|
|
26
|
+
platformVersion: mapPlatformVersionToEnum(platformVersion),
|
|
27
|
+
},
|
|
20
28
|
});
|
|
21
29
|
}
|
|
22
30
|
function mapPlatformVersionToEnum(platformVersion) {
|
|
@@ -44,8 +52,10 @@ async function continueMigration(portalId, migrationId, componentUids, projectNa
|
|
|
44
52
|
},
|
|
45
53
|
});
|
|
46
54
|
}
|
|
47
|
-
function checkMigrationStatusV2(accountId, id) {
|
|
48
|
-
|
|
55
|
+
async function checkMigrationStatusV2(accountId, id) {
|
|
56
|
+
const response = await http_1.http.get(accountId, {
|
|
49
57
|
url: `${MIGRATIONS_API_PATH_V2}/migrations/${id}/status`,
|
|
50
58
|
});
|
|
59
|
+
logger_1.logger.debug(util_1.default.inspect(response.data, { depth: null }));
|
|
60
|
+
return response;
|
|
51
61
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
|
|
2
2
|
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs } from '../../types/Yargs';
|
|
3
3
|
export type ProjectMigrateArgs = CommonArgs & AccountArgs & EnvironmentArgs & ConfigArgs & {
|
|
4
|
-
dest?: string;
|
|
5
4
|
platformVersion: string;
|
|
6
5
|
};
|
|
7
6
|
export declare const command = "migrate";
|
|
8
7
|
export declare const describe: undefined;
|
|
9
|
-
export declare function handler(options: ArgumentsCamelCase<ProjectMigrateArgs>): Promise<
|
|
8
|
+
export declare function handler(options: ArgumentsCamelCase<ProjectMigrateArgs>): Promise<void>;
|
|
10
9
|
export declare function builder(yargs: Argv): Argv<ProjectMigrateArgs>;
|
|
11
10
|
declare const migrateAppCommand: CommandModule<unknown, ProjectMigrateArgs>;
|
|
12
11
|
export default migrateAppCommand;
|
package/lang/en.d.ts
CHANGED
|
@@ -2811,7 +2811,7 @@ export declare const lib: {
|
|
|
2811
2811
|
invalidAccountTypeTitle: () => string;
|
|
2812
2812
|
invalidAccountTypeDescription: (useCommand: any, authCommand: any) => string;
|
|
2813
2813
|
appWithAppIdNotFound: (appId: any) => string;
|
|
2814
|
-
noAppsForProject: string;
|
|
2814
|
+
noAppsForProject: (projectName: string) => string;
|
|
2815
2815
|
migrationFailed: string;
|
|
2816
2816
|
};
|
|
2817
2817
|
prompt: {
|
package/lang/en.js
CHANGED
|
@@ -2770,7 +2770,7 @@ exports.lib = {
|
|
|
2770
2770
|
invalidAccountTypeTitle: () => `${chalk_1.default.bold('Developer account not targeted')}`,
|
|
2771
2771
|
invalidAccountTypeDescription: (useCommand, authCommand) => `Only public apps created in a developer account can be converted to a project component. Select a connected developer account with ${useCommand} or ${authCommand} and try again.`,
|
|
2772
2772
|
appWithAppIdNotFound: appId => `Could not find an app with the id ${appId} `,
|
|
2773
|
-
noAppsForProject:
|
|
2773
|
+
noAppsForProject: (projectName) => `No apps associated with project ${projectName}`,
|
|
2774
2774
|
migrationFailed: 'Migration Failed',
|
|
2775
2775
|
},
|
|
2776
2776
|
prompt: {
|
package/lang/en.lyaml
CHANGED
|
@@ -651,33 +651,10 @@ en:
|
|
|
651
651
|
componentsThatWillNotBeMigrated: "[NOTE] These component types are not yet supported for migration but will be available later: {{ components }}"
|
|
652
652
|
errors:
|
|
653
653
|
noAppsForProject: "No apps associated with project {{ projectName }}"
|
|
654
|
-
noAppsEligible: "No apps in account {{ accountId }} are currently migratable"
|
|
655
654
|
noAccountConfig: "There is no account associated with {{ accountId }} in the config file. Please choose another account and try again, or authenticate {{ accountId }} using {{ authCommand }}."
|
|
656
|
-
invalidAccountTypeTitle: "{{#bold}}Developer account not targeted{{/bold}}"
|
|
657
|
-
invalidAccountTypeDescription: "Only public apps created in a developer account can be converted to a project component. Select a connected developer account with {{useCommand}} or {{authCommand}} and try again."
|
|
658
655
|
projectAlreadyExists: "A project with name {{ projectName }} already exists. Please choose another name."
|
|
659
656
|
invalidApp: "Could not migrate appId {{ appId }}. This app cannot be migrated at this time. Please choose another public app."
|
|
660
|
-
appWithAppIdNotFound: "Could not find an app with the id {{ appId }} "
|
|
661
657
|
migrationFailed: 'Migration Failed'
|
|
662
|
-
prompt:
|
|
663
|
-
chooseApp: 'Which app would you like to migrate?'
|
|
664
|
-
inputName: '[--name] What would you like to name the project?'
|
|
665
|
-
inputDest: '[--dest] Where would you like to save the project?'
|
|
666
|
-
uidForComponent: 'What UID would you like to use for {{ componentName }}?'
|
|
667
|
-
proceed: 'Would you like to proceed?'
|
|
668
|
-
spinners:
|
|
669
|
-
beginningMigration: "Beginning migration"
|
|
670
|
-
unableToStartMigration: "Unable to begin migration"
|
|
671
|
-
finishingMigration: "Wrapping up migration"
|
|
672
|
-
migrationComplete: "Migration completed"
|
|
673
|
-
migrationFailed: "Migration failed"
|
|
674
|
-
downloadingProjectContents: "Downloading migrated project files"
|
|
675
|
-
downloadingProjectContentsComplete: "Migrated project files downloaded"
|
|
676
|
-
downloadingProjectContentsFailed: "Unable to download migrated project files"
|
|
677
|
-
copyingProjectFiles: "Copying migrated project files"
|
|
678
|
-
copyingProjectFilesComplete: "Migrated project files copied"
|
|
679
|
-
copyingProjectFilesFailed: "Unable to copy migrated project files"
|
|
680
|
-
|
|
681
658
|
cloneApp:
|
|
682
659
|
describe: "Clone a public app using the projects framework."
|
|
683
660
|
examples:
|
|
@@ -715,11 +692,11 @@ en:
|
|
|
715
692
|
default: "Create a component within your project"
|
|
716
693
|
withFlags: "Use --name and --type flags to bypass the prompt."
|
|
717
694
|
migrate:
|
|
718
|
-
describe: "Migrate
|
|
695
|
+
describe: "Migrate an existing project to the new version of the projects framework."
|
|
719
696
|
errors:
|
|
720
697
|
noProjectConfig: "No project detected. Please run this command again from a project directory."
|
|
721
698
|
examples:
|
|
722
|
-
default: "Migrate
|
|
699
|
+
default: "Migrate an existing project to the new version of the projects framework."
|
|
723
700
|
deploy:
|
|
724
701
|
describe: "Deploy a project build."
|
|
725
702
|
deployBuildIdPrompt: "[--build] Deploy which build?"
|
package/lib/app/migrate.js
CHANGED
|
@@ -23,6 +23,7 @@ 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"));
|
|
26
27
|
function getUnmigratableReason(reasonCode) {
|
|
27
28
|
switch (reasonCode) {
|
|
28
29
|
case projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE:
|
|
@@ -43,20 +44,31 @@ function filterAppsByProjectName(projectConfig) {
|
|
|
43
44
|
return !app.projectName;
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
async function
|
|
47
|
-
const {
|
|
48
|
-
const { data: { migratableApps, unmigratableApps }, } = await (0, migrate_1.listAppsForMigration)(derivedAccountId);
|
|
47
|
+
async function fetchMigrationApps(appId, derivedAccountId, platformVersion, projectConfig) {
|
|
48
|
+
const { data: { migratableApps, unmigratableApps }, } = await (0, migrate_1.listAppsForMigration)(derivedAccountId, platformVersion);
|
|
49
49
|
const filteredMigratableApps = migratableApps.filter(filterAppsByProjectName(projectConfig));
|
|
50
50
|
const filteredUnmigratableApps = unmigratableApps.filter(filterAppsByProjectName(projectConfig));
|
|
51
51
|
const allApps = [...filteredMigratableApps, ...filteredUnmigratableApps];
|
|
52
52
|
if (allApps.length > 1 && projectConfig) {
|
|
53
53
|
throw new Error(en_1.lib.migrate.errors.project.multipleApps);
|
|
54
54
|
}
|
|
55
|
+
if (allApps.length === 0 && projectConfig) {
|
|
56
|
+
throw new Error(en_1.lib.migrate.errors.noAppsForProject(projectConfig?.projectConfig?.name || ''));
|
|
57
|
+
}
|
|
55
58
|
if (allApps.length === 0 ||
|
|
56
59
|
filteredUnmigratableApps.length === allApps.length) {
|
|
57
60
|
const reasons = filteredUnmigratableApps.map(app => `${chalk_1.default.bold(app.appName)}: ${getUnmigratableReason(app.unmigratableReason)}`);
|
|
58
61
|
throw new Error(en_1.lib.migrate.errors.noAppsEligible((0, ui_1.uiAccountDescription)(derivedAccountId), reasons));
|
|
59
62
|
}
|
|
63
|
+
if (appId &&
|
|
64
|
+
!allApps.some(app => {
|
|
65
|
+
return app.appId === appId;
|
|
66
|
+
})) {
|
|
67
|
+
throw new Error(en_1.lib.migrate.errors.appWithAppIdNotFound(appId));
|
|
68
|
+
}
|
|
69
|
+
return allApps;
|
|
70
|
+
}
|
|
71
|
+
async function selectAppToMigrate(allApps, appId) {
|
|
60
72
|
if (appId &&
|
|
61
73
|
!allApps.some(app => {
|
|
62
74
|
return app.appId === appId;
|
|
@@ -98,6 +110,15 @@ async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
|
|
|
98
110
|
}
|
|
99
111
|
logger_1.logger.log();
|
|
100
112
|
const proceed = await (0, promptUtils_1.confirmPrompt)(en_1.lib.migrate.prompt.proceed);
|
|
113
|
+
return {
|
|
114
|
+
proceed,
|
|
115
|
+
appIdToMigrate,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
|
|
119
|
+
const { name, dest, appId } = options;
|
|
120
|
+
const allApps = await fetchMigrationApps(appId, derivedAccountId, options.platformVersion, projectConfig);
|
|
121
|
+
const { proceed, appIdToMigrate } = await selectAppToMigrate(allApps, appId);
|
|
101
122
|
if (!proceed) {
|
|
102
123
|
return {};
|
|
103
124
|
}
|
|
@@ -189,6 +210,7 @@ async function finalizeMigration(derivedAccountId, migrationId, uidMap, projectN
|
|
|
189
210
|
if (pollResponse.status !== Migration_1.MIGRATION_STATUS.SUCCESS) {
|
|
190
211
|
throw new Error(en_1.lib.migrate.errors.migrationFailed);
|
|
191
212
|
}
|
|
213
|
+
logger_1.logger.debug(util_1.default.inspect(pollResponse, { depth: null }));
|
|
192
214
|
if (pollResponse.status === Migration_1.MIGRATION_STATUS.SUCCESS) {
|
|
193
215
|
SpinniesManager_1.default.succeed('finishingMigration', {
|
|
194
216
|
text: en_1.lib.migrate.spinners.migrationComplete,
|
|
@@ -258,6 +280,6 @@ async function migrateApp2025_2(derivedAccountId, options, projectConfig) {
|
|
|
258
280
|
function logInvalidAccountError() {
|
|
259
281
|
(0, ui_1.uiLine)();
|
|
260
282
|
logger_1.logger.error(en_1.lib.migrate.errors.invalidAccountTypeTitle);
|
|
261
|
-
logger_1.logger.log(en_1.lib.migrate.errors.invalidAccountTypeDescription((0, ui_1.uiCommandReference)('hs
|
|
283
|
+
logger_1.logger.log(en_1.lib.migrate.errors.invalidAccountTypeDescription((0, ui_1.uiCommandReference)('hs account use'), (0, ui_1.uiCommandReference)('hs auth')));
|
|
262
284
|
(0, ui_1.uiLine)();
|
|
263
285
|
}
|
package/package.json
CHANGED