@hubspot/cli 7.7.0-experimental.3 → 7.7.2-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/bin/cli.js +96 -94
- package/commands/account/auth.js +51 -82
- package/commands/account.js +0 -2
- package/commands/app.js +0 -2
- package/commands/auth.js +2 -17
- package/commands/cms.js +0 -2
- package/commands/completion.js +0 -2
- package/commands/config/migrate.js +17 -36
- package/commands/config.js +0 -2
- package/commands/create.js +0 -2
- package/commands/customObject.js +0 -2
- package/commands/doctor.js +0 -2
- package/commands/feedback.js +0 -2
- package/commands/filemanager.js +0 -2
- package/commands/function.js +0 -2
- package/commands/hubdb.js +0 -2
- package/commands/init.js +1 -4
- package/commands/lint.js +0 -2
- package/commands/list.js +0 -2
- package/commands/module/marketplace-validate.js +6 -8
- package/commands/module.js +2 -1
- package/commands/mv.js +0 -2
- package/commands/open.js +0 -2
- package/commands/project/add.d.ts +5 -2
- package/commands/project/add.js +43 -80
- package/commands/project/create.d.ts +2 -8
- package/commands/project/create.js +84 -55
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +9 -1
- package/commands/project/dev/index.js +59 -34
- package/commands/project/dev/unifiedFlow.d.ts +10 -2
- package/commands/project/dev/unifiedFlow.js +28 -41
- package/commands/project.js +0 -2
- package/commands/remove.js +6 -14
- package/commands/sandbox.js +0 -2
- package/commands/secret.js +0 -2
- package/commands/theme/generate-selectors.js +7 -10
- package/commands/theme/marketplace-validate.js +6 -8
- package/commands/theme/preview.js +17 -18
- package/commands/theme.js +2 -4
- package/commands/upload.js +26 -65
- package/commands/watch.js +20 -32
- package/lang/en.d.ts +154 -95
- package/lang/en.js +156 -100
- package/lang/en.lyaml +3 -186
- package/lib/accountTypes.js +1 -3
- package/lib/commonOpts.d.ts +1 -3
- package/lib/commonOpts.js +1 -1
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +34 -69
- package/lib/constants.d.ts +23 -5
- package/lib/constants.js +24 -6
- package/lib/generateSelectors.js +3 -5
- package/lib/marketplaceValidate.d.ts +12 -2
- package/lib/marketplaceValidate.js +22 -29
- package/lib/middleware/configMiddleware.js +1 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +5 -3
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +20 -11
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +3 -2
- package/lib/projects/localDev/AppDevModeInterface.js +38 -8
- package/lib/projects/localDev/LocalDevProcess.d.ts +12 -5
- package/lib/projects/localDev/LocalDevProcess.js +47 -17
- package/lib/projects/localDev/LocalDevState.d.ts +16 -3
- package/lib/projects/localDev/LocalDevState.js +43 -2
- package/lib/projects/localDev/LocalDevWatcher.js +3 -6
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +3 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +48 -9
- package/lib/projects/upload.js +6 -0
- package/lib/prompts/createProjectPrompt.d.ts +14 -5
- package/lib/prompts/createProjectPrompt.js +36 -13
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -7
- package/lib/prompts/promptUtils.d.ts +0 -1
- package/lib/prompts/promptUtils.js +0 -2
- package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
- package/package.json +7 -6
- package/types/LocalDev.d.ts +11 -1
- package/types/Projects.d.ts +19 -2
- package/types/Yargs.d.ts +2 -0
- package/commands/testAccount/create.d.ts +0 -7
- package/commands/testAccount/create.js +0 -118
- package/commands/testAccount/delete.d.ts +0 -6
- package/commands/testAccount/delete.js +0 -42
- package/commands/testAccount.d.ts +0 -3
- package/commands/testAccount.js +0 -27
- package/lib/projects/create.d.ts +0 -5
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.builder = void 0;
|
|
4
4
|
const usageTracking_1 = require("../../../lib/usageTracking");
|
|
5
|
-
const lang_1 = require("../../../lib/lang");
|
|
6
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
5
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
6
|
const config_2 = require("../../../lib/projects/config");
|
|
9
7
|
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
@@ -13,22 +11,35 @@ const unifiedFlow_1 = require("./unifiedFlow");
|
|
|
13
11
|
const buildAndDeploy_1 = require("../../../lib/projects/buildAndDeploy");
|
|
14
12
|
const yargsUtils_1 = require("../../../lib/yargsUtils");
|
|
15
13
|
const projectProfiles_1 = require("../../../lib/projectProfiles");
|
|
14
|
+
const en_1 = require("../../../lang/en");
|
|
15
|
+
const logger_1 = require("../../../lib/ui/logger");
|
|
16
16
|
const command = 'dev';
|
|
17
|
-
const describe = (0, ui_1.uiBetaTag)(
|
|
17
|
+
const describe = (0, ui_1.uiBetaTag)(en_1.commands.project.dev.describe, false);
|
|
18
|
+
function validateAccountFlags(testingAccount, projectAccount, providedAccountId, useV3) {
|
|
19
|
+
// Legacy projects do not support targetTestingAccount and targetProjectAccount
|
|
20
|
+
if (testingAccount && projectAccount && !useV3) {
|
|
21
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.unsupportedAccountFlagLegacy);
|
|
22
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
23
|
+
}
|
|
24
|
+
if (providedAccountId && useV3) {
|
|
25
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.unsupportedAccountFlagV3);
|
|
26
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
18
29
|
async function handler(args) {
|
|
19
|
-
const { derivedAccountId, providedAccountId } = args;
|
|
30
|
+
const { derivedAccountId, providedAccountId, testingAccount, projectAccount, } = args;
|
|
20
31
|
const { projectConfig, projectDir } = await (0, config_2.getProjectConfig)();
|
|
21
32
|
(0, config_2.validateProjectConfig)(projectConfig, projectDir);
|
|
33
|
+
const useV3 = (0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion);
|
|
22
34
|
if (!projectDir) {
|
|
23
|
-
logger_1.
|
|
24
|
-
accountId: derivedAccountId,
|
|
25
|
-
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
26
|
-
}));
|
|
35
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.noProjectConfig);
|
|
27
36
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
28
37
|
}
|
|
29
|
-
|
|
38
|
+
validateAccountFlags(testingAccount, projectAccount, providedAccountId, useV3);
|
|
39
|
+
let targetProjectAccountId = (projectAccount && (0, config_1.getAccountId)(projectAccount)) ||
|
|
40
|
+
(providedAccountId && derivedAccountId);
|
|
30
41
|
let profile;
|
|
31
|
-
if (!
|
|
42
|
+
if (!targetProjectAccountId && (0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion)) {
|
|
32
43
|
if (args.profile) {
|
|
33
44
|
(0, projectProfiles_1.logProfileHeader)(args.profile);
|
|
34
45
|
profile = (0, projectProfiles_1.loadProfile)(projectConfig, projectDir, args.profile);
|
|
@@ -36,7 +47,7 @@ async function handler(args) {
|
|
|
36
47
|
(0, ui_1.uiLine)();
|
|
37
48
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
38
49
|
}
|
|
39
|
-
|
|
50
|
+
targetProjectAccountId = profile.accountId;
|
|
40
51
|
(0, projectProfiles_1.logProfileFooter)(profile);
|
|
41
52
|
}
|
|
42
53
|
else {
|
|
@@ -44,42 +55,56 @@ async function handler(args) {
|
|
|
44
55
|
await (0, projectProfiles_1.exitIfUsingProfiles)(projectConfig, projectDir);
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
|
-
if (!
|
|
48
|
-
// The user is not using
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
(0, usageTracking_1.trackCommandUsage)('project-dev', {}, targetAccountId);
|
|
52
|
-
const accountConfig = (0, config_1.getAccountConfig)(targetAccountId);
|
|
53
|
-
(0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.dev.logs.betaMessage`));
|
|
54
|
-
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.dev.logs.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
55
|
-
if (!accountConfig) {
|
|
56
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noAccount`, {
|
|
57
|
-
accountId: (0, ui_1.uiAccountDescription)(targetAccountId),
|
|
58
|
-
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
59
|
-
}));
|
|
60
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
58
|
+
if (!targetProjectAccountId) {
|
|
59
|
+
// The user is not using profile or account flags, so we can use the derived accountId
|
|
60
|
+
targetProjectAccountId = derivedAccountId;
|
|
61
61
|
}
|
|
62
|
+
(0, usageTracking_1.trackCommandUsage)('project-dev', {}, targetProjectAccountId);
|
|
63
|
+
(0, ui_1.uiBetaTag)(en_1.commands.project.dev.logs.betaMessage);
|
|
64
|
+
logger_1.uiLogger.log(en_1.commands.project.dev.logs.learnMoreLocalDevServer);
|
|
62
65
|
if ((0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion)) {
|
|
63
|
-
|
|
66
|
+
const targetTestingAccountId = (testingAccount && (0, config_1.getAccountId)(testingAccount)) || undefined;
|
|
67
|
+
await (0, unifiedFlow_1.unifiedProjectDevFlow)({
|
|
68
|
+
args,
|
|
69
|
+
targetProjectAccountId,
|
|
70
|
+
providedTargetTestingAccountId: targetTestingAccountId,
|
|
71
|
+
projectConfig,
|
|
72
|
+
projectDir,
|
|
73
|
+
profileConfig: profile,
|
|
74
|
+
});
|
|
64
75
|
}
|
|
65
76
|
else {
|
|
66
|
-
await (0, deprecatedFlow_1.deprecatedProjectDevFlow)(
|
|
77
|
+
await (0, deprecatedFlow_1.deprecatedProjectDevFlow)({
|
|
78
|
+
args,
|
|
79
|
+
accountId: targetProjectAccountId,
|
|
80
|
+
projectConfig,
|
|
81
|
+
projectDir,
|
|
82
|
+
});
|
|
67
83
|
}
|
|
68
84
|
}
|
|
69
85
|
function projectDevBuilder(yargs) {
|
|
70
86
|
yargs.option('profile', {
|
|
71
87
|
type: 'string',
|
|
72
88
|
alias: 'p',
|
|
73
|
-
description:
|
|
89
|
+
description: en_1.commands.project.dev.options.profile,
|
|
90
|
+
hidden: true,
|
|
91
|
+
});
|
|
92
|
+
yargs.options('testingAccount', {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: en_1.commands.project.dev.options.testingAccount,
|
|
95
|
+
hidden: true,
|
|
96
|
+
implies: ['projectAccount'],
|
|
97
|
+
});
|
|
98
|
+
yargs.options('projectAccount', {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: en_1.commands.project.dev.options.projectAccount,
|
|
74
101
|
hidden: true,
|
|
102
|
+
implies: ['testingAccount'],
|
|
75
103
|
});
|
|
76
|
-
yargs.example([
|
|
77
|
-
[
|
|
78
|
-
'$0 project dev',
|
|
79
|
-
(0, lang_1.i18n)(`commands.project.subcommands.dev.examples.default`),
|
|
80
|
-
],
|
|
81
|
-
]);
|
|
104
|
+
yargs.example([['$0 project dev', en_1.commands.project.dev.examples.default]]);
|
|
82
105
|
yargs.conflicts('profile', 'account');
|
|
106
|
+
yargs.conflicts('profile', 'testingAccount');
|
|
107
|
+
yargs.conflicts('profile', 'projectAccount');
|
|
83
108
|
return yargs;
|
|
84
109
|
}
|
|
85
110
|
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(projectDevBuilder, command, describe, {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { ArgumentsCamelCase } from 'yargs';
|
|
2
2
|
import { HsProfileFile } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
|
-
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
4
3
|
import { ProjectDevArgs } from '../../../types/Yargs';
|
|
5
4
|
import { ProjectConfig } from '../../../types/Projects';
|
|
6
|
-
|
|
5
|
+
type UnifiedProjectDevFlowArgs = {
|
|
6
|
+
args: ArgumentsCamelCase<ProjectDevArgs>;
|
|
7
|
+
targetProjectAccountId: number;
|
|
8
|
+
providedTargetTestingAccountId?: number;
|
|
9
|
+
projectConfig: ProjectConfig;
|
|
10
|
+
projectDir: string;
|
|
11
|
+
profileConfig?: HsProfileFile;
|
|
12
|
+
};
|
|
13
|
+
export declare function unifiedProjectDevFlow({ args, targetProjectAccountId, providedTargetTestingAccountId, projectConfig, projectDir, profileConfig, }: UnifiedProjectDevFlowArgs): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.unifiedProjectDevFlow = unifiedProjectDevFlow;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const util_1 = __importDefault(require("util"));
|
|
9
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
-
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
11
9
|
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
12
10
|
const errors_1 = require("@hubspot/project-parsing-lib/src/lib/errors");
|
|
13
11
|
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
@@ -24,14 +22,10 @@ const LocalDevWatcher_1 = __importDefault(require("../../../lib/projects/localDe
|
|
|
24
22
|
const process_1 = require("../../../lib/process");
|
|
25
23
|
const accountTypes_1 = require("../../../lib/accountTypes");
|
|
26
24
|
const ui_1 = require("../../../lib/ui");
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
async function unifiedProjectDevFlow(args,
|
|
30
|
-
const targetProjectAccountId = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
25
|
+
const logger_1 = require("../../../lib/ui/logger");
|
|
26
|
+
const en_1 = require("../../../lang/en");
|
|
27
|
+
async function unifiedProjectDevFlow({ args, targetProjectAccountId, providedTargetTestingAccountId, projectConfig, projectDir, profileConfig, }) {
|
|
31
28
|
const env = (0, environment_1.getValidEnv)((0, config_2.getEnv)(targetProjectAccountId));
|
|
32
|
-
if (!targetProjectAccountId) {
|
|
33
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
34
|
-
}
|
|
35
29
|
let projectNodes;
|
|
36
30
|
// Get IR
|
|
37
31
|
try {
|
|
@@ -41,58 +35,49 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
41
35
|
accountId: targetProjectAccountId,
|
|
42
36
|
}, { profile: args.profile });
|
|
43
37
|
projectNodes = intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
44
|
-
logger_1.
|
|
38
|
+
logger_1.uiLogger.debug(util_1.default.inspect(projectNodes, false, null, true));
|
|
45
39
|
}
|
|
46
40
|
catch (e) {
|
|
47
41
|
if ((0, errors_1.isTranslationError)(e)) {
|
|
48
|
-
logger_1.
|
|
42
|
+
logger_1.uiLogger.error(e.toString());
|
|
49
43
|
}
|
|
50
44
|
else {
|
|
51
45
|
(0, errorHandlers_1.logError)(e);
|
|
52
46
|
}
|
|
53
47
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
48
|
}
|
|
55
|
-
// @TODO Do we need to do more than this or leave it to the dev servers?
|
|
56
49
|
if (!Object.keys(projectNodes).length) {
|
|
57
|
-
logger_1.
|
|
58
|
-
projectDir,
|
|
59
|
-
command: (0, ui_1.uiCommandReference)('hs project add'),
|
|
60
|
-
}));
|
|
50
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.noRunnableComponents);
|
|
61
51
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
62
52
|
}
|
|
63
|
-
|
|
53
|
+
const targetProjectAccountConfig = (0, config_2.getAccountConfig)(targetProjectAccountId);
|
|
54
|
+
if (!targetProjectAccountConfig) {
|
|
55
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.noAccount(targetProjectAccountId));
|
|
56
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
57
|
+
}
|
|
64
58
|
const accounts = (0, config_2.getConfigAccounts)();
|
|
65
|
-
const accountIsCombined = await (0, accountTypes_1.isUnifiedAccount)(
|
|
59
|
+
const accountIsCombined = await (0, accountTypes_1.isUnifiedAccount)(targetProjectAccountConfig);
|
|
66
60
|
if (!accountIsCombined && !profileConfig) {
|
|
67
|
-
logger_1.
|
|
68
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.accountNotCombined`, {
|
|
69
|
-
accountUseCommand: (0, ui_1.uiCommandReference)('hs account use'),
|
|
70
|
-
}));
|
|
61
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.accountNotCombined);
|
|
71
62
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
72
63
|
}
|
|
73
|
-
let targetTestingAccountId =
|
|
64
|
+
let targetTestingAccountId = providedTargetTestingAccountId;
|
|
74
65
|
if (profileConfig) {
|
|
75
66
|
// Bypass the prompt for the testing account if the user has a profile configured
|
|
76
67
|
targetTestingAccountId = profileConfig.accountId;
|
|
77
68
|
}
|
|
78
|
-
else if (
|
|
79
|
-
|
|
80
|
-
targetTestingAccountId = targetProjectAccountId;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
logger_1.logger.log('');
|
|
69
|
+
else if (!targetTestingAccountId) {
|
|
70
|
+
logger_1.uiLogger.log('');
|
|
84
71
|
(0, ui_1.uiLine)();
|
|
85
|
-
logger_1.
|
|
86
|
-
logger_1.
|
|
87
|
-
logger_1.logger.log((0, lang_1.i18n)(`commands.project.subcommands.dev.logs.learnMoreMessage`, {
|
|
88
|
-
learnMoreLink: (0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.dev.logs.learnMoreLink`), 'https://developers.hubspot.com/docs/getting-started/account-types'),
|
|
89
|
-
}));
|
|
72
|
+
logger_1.uiLogger.log(en_1.commands.project.dev.logs.accountTypeInformation);
|
|
73
|
+
logger_1.uiLogger.log(en_1.commands.project.dev.logs.learnMoreMessage);
|
|
90
74
|
(0, ui_1.uiLine)();
|
|
91
|
-
logger_1.
|
|
92
|
-
const accountType = await (0, helpers_1.selectAccountTypePrompt)(
|
|
75
|
+
logger_1.uiLogger.log('');
|
|
76
|
+
const accountType = await (0, helpers_1.selectAccountTypePrompt)(targetProjectAccountConfig);
|
|
93
77
|
if (accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
94
|
-
const devAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectDeveloperTestTargetAccountPrompt)(accounts,
|
|
95
|
-
targetTestingAccountId =
|
|
78
|
+
const devAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectDeveloperTestTargetAccountPrompt)(accounts, targetProjectAccountConfig);
|
|
79
|
+
targetTestingAccountId =
|
|
80
|
+
devAccountPromptResponse.targetAccountId || undefined;
|
|
96
81
|
if (!!devAccountPromptResponse.notInConfigAccount) {
|
|
97
82
|
// When the developer test account isn't configured in the CLI config yet
|
|
98
83
|
// Walk the user through adding the account's PAK to the config
|
|
@@ -100,12 +85,13 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
100
85
|
}
|
|
101
86
|
else if (devAccountPromptResponse.createNestedAccount) {
|
|
102
87
|
// Create a new developer test account and automatically add it to the CLI config
|
|
103
|
-
targetTestingAccountId = await (0, helpers_1.createDeveloperTestAccountForLocalDev)(targetProjectAccountId,
|
|
88
|
+
targetTestingAccountId = await (0, helpers_1.createDeveloperTestAccountForLocalDev)(targetProjectAccountId, targetProjectAccountConfig, env);
|
|
104
89
|
}
|
|
105
90
|
}
|
|
106
91
|
else if (accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
107
|
-
const sandboxAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectSandboxTargetAccountPrompt)(accounts,
|
|
108
|
-
targetTestingAccountId =
|
|
92
|
+
const sandboxAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectSandboxTargetAccountPrompt)(accounts, targetProjectAccountConfig);
|
|
93
|
+
targetTestingAccountId =
|
|
94
|
+
sandboxAccountPromptResponse.targetAccountId || undefined;
|
|
109
95
|
}
|
|
110
96
|
else {
|
|
111
97
|
targetTestingAccountId = targetProjectAccountId;
|
|
@@ -138,6 +124,7 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
138
124
|
targetTestingAccountId: targetTestingAccountId,
|
|
139
125
|
projectConfig,
|
|
140
126
|
projectDir,
|
|
127
|
+
projectName: project.name,
|
|
141
128
|
projectId: project.id,
|
|
142
129
|
env,
|
|
143
130
|
});
|
package/commands/project.js
CHANGED
package/commands/remove.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
|
|
4
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
5
4
|
const index_1 = require("../lib/errorHandlers/index");
|
|
6
5
|
const usageTracking_1 = require("../lib/usageTracking");
|
|
7
|
-
const
|
|
6
|
+
const en_1 = require("../lang/en");
|
|
8
7
|
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
8
|
+
const logger_1 = require("../lib/ui/logger");
|
|
9
9
|
const command = 'remove <path>';
|
|
10
|
-
const describe =
|
|
10
|
+
const describe = en_1.commands.remove.describe;
|
|
11
11
|
async function handler(args) {
|
|
12
12
|
const { path: hsPath, derivedAccountId } = args;
|
|
13
13
|
(0, usageTracking_1.trackCommandUsage)('remove', undefined, derivedAccountId);
|
|
14
14
|
try {
|
|
15
15
|
await (0, fileMapper_1.deleteFile)(derivedAccountId, hsPath);
|
|
16
|
-
logger_1.
|
|
17
|
-
accountId: derivedAccountId,
|
|
18
|
-
path: hsPath,
|
|
19
|
-
}));
|
|
16
|
+
logger_1.uiLogger.log(en_1.commands.remove.deleted(hsPath, derivedAccountId));
|
|
20
17
|
}
|
|
21
18
|
catch (error) {
|
|
22
|
-
logger_1.
|
|
23
|
-
accountId: derivedAccountId,
|
|
24
|
-
path: hsPath,
|
|
25
|
-
}));
|
|
19
|
+
logger_1.uiLogger.error(en_1.commands.remove.errors.deleteFailed(hsPath, derivedAccountId));
|
|
26
20
|
(0, index_1.logError)(error, new index_1.ApiErrorContext({
|
|
27
21
|
accountId: derivedAccountId,
|
|
28
22
|
request: hsPath,
|
|
@@ -31,7 +25,7 @@ async function handler(args) {
|
|
|
31
25
|
}
|
|
32
26
|
function cmsRemoveBuilder(yargs) {
|
|
33
27
|
yargs.positional('path', {
|
|
34
|
-
describe:
|
|
28
|
+
describe: en_1.commands.remove.positionals.path,
|
|
35
29
|
type: 'string',
|
|
36
30
|
});
|
|
37
31
|
return yargs;
|
|
@@ -49,5 +43,3 @@ const cmsRemoveCommand = {
|
|
|
49
43
|
builder,
|
|
50
44
|
};
|
|
51
45
|
exports.default = cmsRemoveCommand;
|
|
52
|
-
// TODO Remove this legacy export once we've migrated all commands to TS
|
|
53
|
-
module.exports = cmsRemoveCommand;
|
package/commands/sandbox.js
CHANGED
package/commands/secret.js
CHANGED
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const
|
|
8
|
-
const lang_1 = require("../../lib/lang");
|
|
7
|
+
const en_1 = require("../../lang/en");
|
|
9
8
|
const generateSelectors_1 = require("../../lib/generateSelectors");
|
|
10
9
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
11
10
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
11
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
12
12
|
const HUBL_EXPRESSION_REGEX = new RegExp(/{%\s*(.*)\s*%}/, 'g');
|
|
13
13
|
const HUBL_VARIABLE_NAME_REGEX = new RegExp(/{%\s*set\s*(\w*)/, 'i');
|
|
14
14
|
const HUBL_STATEMENT_REGEX = new RegExp(/{{\s*[\w.(,\d\-\s)|/~]*.*}}/, 'g');
|
|
@@ -19,12 +19,12 @@ const CSS_SELECTORS_REGEX = new RegExp(/([\s\w:.,\0-[\]]*){/, 'i');
|
|
|
19
19
|
const CSS_EXPRESSION_REGEX = new RegExp(/(?!\s)([^}])*(?![.#\s,>])[^}]*}/, 'g');
|
|
20
20
|
const THEME_PATH_REGEX = new RegExp(/=\s*.*(theme\.(\w|\.)*)/, 'i');
|
|
21
21
|
const command = 'generate-selectors <path>';
|
|
22
|
-
const describe =
|
|
22
|
+
const describe = en_1.commands.theme.subcommands.generateSelectors.describe;
|
|
23
23
|
async function handler(args) {
|
|
24
24
|
const { path } = args;
|
|
25
25
|
const fieldsJsonPath = (0, generateSelectors_1.findFieldsJsonPath)(path);
|
|
26
26
|
if (!fieldsJsonPath) {
|
|
27
|
-
logger_1.
|
|
27
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.generateSelectors.errors.fieldsNotFound);
|
|
28
28
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
29
29
|
}
|
|
30
30
|
let fieldsJson = JSON.parse(fs_1.default.readFileSync(fieldsJsonPath, 'utf-8'));
|
|
@@ -134,7 +134,7 @@ async function handler(args) {
|
|
|
134
134
|
return themeFieldsSelectorMap;
|
|
135
135
|
}, {});
|
|
136
136
|
if (!Object.keys(finalMap).length) {
|
|
137
|
-
logger_1.
|
|
137
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.generateSelectors.errors.noSelectorsFound);
|
|
138
138
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
139
139
|
}
|
|
140
140
|
Object.keys(finalMap).forEach(themeFieldKey => {
|
|
@@ -151,14 +151,11 @@ async function handler(args) {
|
|
|
151
151
|
const selectorsMap = (0, generateSelectors_1.generateSelectorsMap)(fieldsJson);
|
|
152
152
|
const selectorsPath = `${path}/editor-preview.json`;
|
|
153
153
|
fs_1.default.writeFileSync(selectorsPath, `${JSON.stringify({ selectors: selectorsMap }, null, 2)}\n`);
|
|
154
|
-
logger_1.
|
|
155
|
-
themePath: path,
|
|
156
|
-
selectorsPath,
|
|
157
|
-
}));
|
|
154
|
+
logger_1.uiLogger.success(en_1.commands.theme.subcommands.generateSelectors.success(path, selectorsPath));
|
|
158
155
|
}
|
|
159
156
|
function themeSelectorBuilder(yargs) {
|
|
160
157
|
yargs.positional('path', {
|
|
161
|
-
describe:
|
|
158
|
+
describe: en_1.commands.theme.subcommands.generateSelectors.positionals.path,
|
|
162
159
|
type: 'string',
|
|
163
160
|
required: true,
|
|
164
161
|
});
|
|
@@ -6,31 +6,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
7
7
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
8
8
|
const marketplaceValidate_1 = require("../../lib/marketplaceValidate");
|
|
9
|
-
const
|
|
9
|
+
const en_1 = require("../../lang/en");
|
|
10
10
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
11
11
|
const command = 'marketplace-validate <path>';
|
|
12
|
-
const describe =
|
|
12
|
+
const describe = en_1.commands.theme.subcommands.marketplaceValidate.describe;
|
|
13
13
|
async function handler(args) {
|
|
14
14
|
const { path, derivedAccountId } = args;
|
|
15
15
|
(0, usageTracking_1.trackCommandUsage)('validate', {}, derivedAccountId);
|
|
16
16
|
SpinniesManager_1.default.init();
|
|
17
17
|
SpinniesManager_1.default.add('marketplaceValidation', {
|
|
18
|
-
text:
|
|
19
|
-
path,
|
|
20
|
-
}),
|
|
18
|
+
text: en_1.commands.theme.subcommands.marketplaceValidate.logs.validatingTheme(path),
|
|
21
19
|
});
|
|
22
20
|
const assetType = 'THEME';
|
|
23
21
|
const validationId = await (0, marketplaceValidate_1.kickOffValidation)(derivedAccountId, assetType, path);
|
|
24
22
|
await (0, marketplaceValidate_1.pollForValidationFinish)(derivedAccountId, validationId);
|
|
25
23
|
SpinniesManager_1.default.remove('marketplaceValidation');
|
|
26
24
|
const validationResults = await (0, marketplaceValidate_1.fetchValidationResults)(derivedAccountId, validationId);
|
|
27
|
-
(0, marketplaceValidate_1.processValidationErrors)(
|
|
28
|
-
(0, marketplaceValidate_1.displayValidationResults)(
|
|
25
|
+
(0, marketplaceValidate_1.processValidationErrors)(en_1.commands.theme.subcommands.marketplaceValidate.errors.invalidPath, validationResults);
|
|
26
|
+
(0, marketplaceValidate_1.displayValidationResults)(en_1.commands.theme.subcommands.marketplaceValidate.results, validationResults);
|
|
29
27
|
process.exit();
|
|
30
28
|
}
|
|
31
29
|
function themeValidateBuilder(yargs) {
|
|
32
30
|
yargs.positional('path', {
|
|
33
|
-
describe:
|
|
31
|
+
describe: en_1.commands.theme.subcommands.marketplaceValidate.positionals.path.describe,
|
|
34
32
|
type: 'string',
|
|
35
33
|
required: true,
|
|
36
34
|
});
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
9
|
-
const
|
|
10
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const en_1 = require("../../lang/en");
|
|
11
10
|
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
12
11
|
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
13
12
|
const themes_1 = require("@hubspot/local-dev-lib/cms/themes");
|
|
@@ -24,13 +23,12 @@ const Projects_1 = require("../../types/Projects");
|
|
|
24
23
|
const hasFeature_1 = require("../../lib/hasFeature");
|
|
25
24
|
const constants_1 = require("../../lib/constants");
|
|
26
25
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
26
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
27
27
|
const command = 'preview [--src] [--dest]';
|
|
28
|
-
const describe =
|
|
28
|
+
const describe = en_1.commands.theme.subcommands.preview.describe;
|
|
29
29
|
function validateSrcPath(src) {
|
|
30
30
|
const logInvalidPath = () => {
|
|
31
|
-
logger_1.
|
|
32
|
-
path: src,
|
|
33
|
-
}));
|
|
31
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.preview.errors.invalidPath(src));
|
|
34
32
|
};
|
|
35
33
|
try {
|
|
36
34
|
const stats = fs_1.default.statSync(src);
|
|
@@ -47,7 +45,7 @@ function validateSrcPath(src) {
|
|
|
47
45
|
}
|
|
48
46
|
function handleUserInput() {
|
|
49
47
|
const onTerminate = () => {
|
|
50
|
-
logger_1.
|
|
48
|
+
logger_1.uiLogger.log(en_1.commands.theme.subcommands.preview.logs.processExited);
|
|
51
49
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
52
50
|
};
|
|
53
51
|
(0, process_1.handleExit)(onTerminate);
|
|
@@ -78,7 +76,7 @@ async function determineSrcAndDest(args) {
|
|
|
78
76
|
const projectComponents = await (0, structure_1.findProjectComponents)(projectDir);
|
|
79
77
|
const themeComponents = projectComponents.filter(c => c.type === Projects_1.ComponentTypes.HublTheme);
|
|
80
78
|
if (themeComponents.length === 0) {
|
|
81
|
-
logger_1.
|
|
79
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.preview.errors.noThemeComponents);
|
|
82
80
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
83
81
|
}
|
|
84
82
|
const answer = await (0, previewPrompt_1.previewProjectPrompt)(themeComponents);
|
|
@@ -102,7 +100,7 @@ async function handler(args) {
|
|
|
102
100
|
hideCursor: true,
|
|
103
101
|
}, cli_progress_1.default.Presets.rect);
|
|
104
102
|
initialUploadProgressBar.start(numFiles, 0, {
|
|
105
|
-
label:
|
|
103
|
+
label: en_1.commands.theme.subcommands.preview.initialUploadProgressBar.start,
|
|
106
104
|
});
|
|
107
105
|
let uploadsHaveStarted = false;
|
|
108
106
|
const uploadOptions = {
|
|
@@ -114,7 +112,8 @@ async function handler(args) {
|
|
|
114
112
|
if (!uploadsHaveStarted) {
|
|
115
113
|
uploadsHaveStarted = true;
|
|
116
114
|
initialUploadProgressBar.update(0, {
|
|
117
|
-
label:
|
|
115
|
+
label: en_1.commands.theme.subcommands.preview.initialUploadProgressBar
|
|
116
|
+
.uploading,
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
119
|
},
|
|
@@ -127,12 +126,12 @@ async function handler(args) {
|
|
|
127
126
|
onFinalErrorCallback: () => initialUploadProgressBar.increment(),
|
|
128
127
|
onFinishCallback: (results) => {
|
|
129
128
|
initialUploadProgressBar.update(numFiles, {
|
|
130
|
-
label:
|
|
129
|
+
label: en_1.commands.theme.subcommands.preview.initialUploadProgressBar.finish,
|
|
131
130
|
});
|
|
132
131
|
initialUploadProgressBar.stop();
|
|
133
132
|
results.forEach(result => {
|
|
134
133
|
if (result.resultType == files_1.FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
135
|
-
logger_1.
|
|
134
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.preview.errors.uploadFailed(result.file, dest));
|
|
136
135
|
(0, index_1.logError)(result.error, new index_1.ApiErrorContext({
|
|
137
136
|
accountId: derivedAccountId,
|
|
138
137
|
request: dest,
|
|
@@ -154,7 +153,7 @@ async function handler(args) {
|
|
|
154
153
|
createUnifiedDevServer = createDevServer;
|
|
155
154
|
}
|
|
156
155
|
catch (e) {
|
|
157
|
-
logger_1.
|
|
156
|
+
logger_1.uiLogger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
|
|
158
157
|
}
|
|
159
158
|
const isUngatedForUnified = await (0, hasFeature_1.hasFeature)(derivedAccountId, constants_1.FEATURES.UNIFIED_THEME_PREVIEW);
|
|
160
159
|
if (isUngatedForUnified && createUnifiedDevServer) {
|
|
@@ -183,27 +182,27 @@ async function handler(args) {
|
|
|
183
182
|
function themePreviewBuilder(yargs) {
|
|
184
183
|
yargs
|
|
185
184
|
.option('src', {
|
|
186
|
-
describe:
|
|
185
|
+
describe: en_1.commands.theme.subcommands.preview.positionals.src,
|
|
187
186
|
type: 'string',
|
|
188
187
|
requiresArg: true,
|
|
189
188
|
})
|
|
190
189
|
.option('dest', {
|
|
191
|
-
describe:
|
|
190
|
+
describe: en_1.commands.theme.subcommands.preview.positionals.dest,
|
|
192
191
|
type: 'string',
|
|
193
192
|
requiresArg: true,
|
|
194
193
|
})
|
|
195
194
|
.option('notify', {
|
|
196
195
|
alias: 'n',
|
|
197
|
-
describe:
|
|
196
|
+
describe: en_1.commands.theme.subcommands.preview.options.notify,
|
|
198
197
|
type: 'string',
|
|
199
198
|
requiresArg: true,
|
|
200
199
|
})
|
|
201
200
|
.option('no-ssl', {
|
|
202
|
-
describe:
|
|
201
|
+
describe: en_1.commands.theme.subcommands.preview.options.noSsl,
|
|
203
202
|
type: 'boolean',
|
|
204
203
|
})
|
|
205
204
|
.option('port', {
|
|
206
|
-
describe:
|
|
205
|
+
describe: en_1.commands.theme.subcommands.preview.options.port,
|
|
207
206
|
type: 'number',
|
|
208
207
|
})
|
|
209
208
|
.option('resetSession', {
|
package/commands/theme.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const marketplace_validate_1 = __importDefault(require("./theme/marketplace-validate"));
|
|
7
7
|
const generate_selectors_1 = __importDefault(require("./theme/generate-selectors"));
|
|
8
8
|
const preview_1 = __importDefault(require("./theme/preview"));
|
|
9
|
-
const
|
|
9
|
+
const en_1 = require("../lang/en");
|
|
10
10
|
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
11
11
|
const command = ['theme', 'themes'];
|
|
12
|
-
const describe =
|
|
12
|
+
const describe = en_1.commands.theme.describe;
|
|
13
13
|
function themeBuilder(yargs) {
|
|
14
14
|
yargs
|
|
15
15
|
.command(preview_1.default)
|
|
@@ -26,5 +26,3 @@ const themeCommand = {
|
|
|
26
26
|
handler: () => { },
|
|
27
27
|
};
|
|
28
28
|
exports.default = themeCommand;
|
|
29
|
-
// TODO Remove this legacy export once we've migrated all commands to TS
|
|
30
|
-
module.exports = themeCommand;
|