@hubspot/cli 7.7.1-experimental.0 → 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/commands/account/auth.js +51 -82
- package/commands/auth.js +2 -15
- package/commands/config/migrate.js +17 -36
- package/commands/init.js +1 -2
- package/commands/module/marketplace-validate.js +6 -8
- package/commands/module.js +2 -1
- 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/unifiedFlow.js +1 -0
- package/commands/remove.js +6 -12
- 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 -2
- package/commands/upload.js +26 -63
- package/commands/watch.js +20 -32
- package/lang/en.d.ts +140 -92
- package/lang/en.js +143 -98
- package/lang/en.lyaml +3 -186
- 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/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 -2
- 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/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/setAsDefaultAccountPrompt.js +10 -0
- package/package.json +6 -5
- package/types/LocalDev.d.ts +11 -1
- package/types/Projects.d.ts +19 -2
- package/lib/projects/create.d.ts +0 -5
package/commands/account/auth.js
CHANGED
|
@@ -3,46 +3,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
4
4
|
const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
|
|
5
5
|
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
6
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
6
|
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
8
7
|
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
9
8
|
const text_1 = require("@hubspot/local-dev-lib/text");
|
|
10
9
|
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
11
|
-
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
12
10
|
const configMigrate_1 = require("../../lib/configMigrate");
|
|
13
11
|
const process_1 = require("../../lib/process");
|
|
14
12
|
const index_1 = require("../../lib/errorHandlers/index");
|
|
15
|
-
const lang_1 = require("../../lib/lang");
|
|
16
13
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
17
14
|
const personalAccessKeyPrompt_1 = require("../../lib/prompts/personalAccessKeyPrompt");
|
|
18
15
|
const accountNamePrompt_1 = require("../../lib/prompts/accountNamePrompt");
|
|
19
16
|
const setAsDefaultAccountPrompt_1 = require("../../lib/prompts/setAsDefaultAccountPrompt");
|
|
20
17
|
const index_2 = require("../../lib/errorHandlers/index");
|
|
21
|
-
const usageTracking_2 = require("../../lib/usageTracking");
|
|
22
18
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
23
19
|
const ui_1 = require("../../lib/ui");
|
|
24
20
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
21
|
+
const en_1 = require("../../lang/en");
|
|
22
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
25
23
|
const TRACKING_STATUS = {
|
|
26
24
|
STARTED: 'started',
|
|
27
25
|
ERROR: 'error',
|
|
28
26
|
COMPLETE: 'complete',
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
29
|
+
async function updateConfigWithNewAccount(env, configAlreadyExists, accountId) {
|
|
31
30
|
try {
|
|
32
31
|
const { personalAccessKey } = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
|
|
33
32
|
env,
|
|
34
|
-
account,
|
|
33
|
+
account: accountId,
|
|
35
34
|
});
|
|
36
35
|
const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
const defaultAccountName = token.hubName
|
|
37
|
+
? (0, text_1.toKebabCase)(token.hubName)
|
|
38
|
+
: undefined;
|
|
39
|
+
const accountName = configAlreadyExists
|
|
39
40
|
? undefined
|
|
40
|
-
: (await (0, accountNamePrompt_1.cliAccountNamePrompt)(
|
|
41
|
-
const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env,
|
|
41
|
+
: (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultAccountName)).name;
|
|
42
|
+
const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env, accountName, !configAlreadyExists);
|
|
42
43
|
if (!updatedConfig)
|
|
43
44
|
return null;
|
|
44
|
-
if
|
|
45
|
-
|
|
45
|
+
// Can happen if the user is re-authenticating an account with no name
|
|
46
|
+
if (configAlreadyExists && !updatedConfig.name) {
|
|
47
|
+
updatedConfig.name = (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultAccountName)).name;
|
|
46
48
|
(0, config_1.updateAccountConfig)({
|
|
47
49
|
...updatedConfig,
|
|
48
50
|
});
|
|
@@ -51,97 +53,81 @@ async function updateConfig(env, doesConfigExist, disableTracking, authType, acc
|
|
|
51
53
|
return updatedConfig;
|
|
52
54
|
}
|
|
53
55
|
catch (e) {
|
|
54
|
-
if (!disableTracking) {
|
|
55
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
|
|
56
|
-
}
|
|
57
56
|
(0, index_1.debugError)(e);
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
async function handleConfigMigration(
|
|
60
|
+
async function handleConfigMigration() {
|
|
62
61
|
const deprecatedConfigExists = (0, migrate_1.configFileExists)(false);
|
|
63
62
|
const globalConfigExists = (0, migrate_1.configFileExists)(true);
|
|
63
|
+
// No deprecated config exists, so no migration is needed
|
|
64
64
|
if (!deprecatedConfigExists) {
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
|
+
// Global config exists, so we need to merge the deprecated config with the global config
|
|
67
68
|
if (globalConfigExists) {
|
|
68
69
|
try {
|
|
69
|
-
const mergeConfirmed = await (0, configMigrate_1.handleMerge)(
|
|
70
|
+
const mergeConfirmed = await (0, configMigrate_1.handleMerge)();
|
|
70
71
|
if (!mergeConfirmed) {
|
|
71
|
-
logger_1.
|
|
72
|
-
|
|
73
|
-
migrateCommand: (0, ui_1.uiCommandReference)('hs config migrate'),
|
|
74
|
-
}));
|
|
75
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
72
|
+
logger_1.uiLogger.log('');
|
|
73
|
+
logger_1.uiLogger.log(en_1.commands.account.subcommands.auth.errors.mergeNotConfirmed);
|
|
76
74
|
}
|
|
77
75
|
return mergeConfirmed;
|
|
78
76
|
}
|
|
79
77
|
catch (error) {
|
|
80
78
|
(0, index_2.logError)(error);
|
|
81
|
-
|
|
82
|
-
command: 'hs account auth',
|
|
83
|
-
type: 'Merge configs',
|
|
84
|
-
successful: false,
|
|
85
|
-
}, providedAccountId);
|
|
86
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
79
|
+
return false;
|
|
87
80
|
}
|
|
88
81
|
}
|
|
82
|
+
// Global config does not exist, so we only need to migrate the deprecated config
|
|
89
83
|
try {
|
|
90
|
-
const migrationConfirmed = await (0, configMigrate_1.handleMigration)(
|
|
84
|
+
const migrationConfirmed = await (0, configMigrate_1.handleMigration)();
|
|
91
85
|
if (!migrationConfirmed) {
|
|
92
|
-
logger_1.
|
|
93
|
-
|
|
94
|
-
deprecatedConfigPath: (0, migrate_1.getConfigPath)('', false),
|
|
95
|
-
}));
|
|
96
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
86
|
+
logger_1.uiLogger.log('');
|
|
87
|
+
logger_1.uiLogger.log(en_1.commands.account.subcommands.auth.errors.migrationNotConfirmed);
|
|
97
88
|
}
|
|
98
89
|
return migrationConfirmed;
|
|
99
90
|
}
|
|
100
91
|
catch (error) {
|
|
101
92
|
(0, index_2.logError)(error);
|
|
102
|
-
|
|
103
|
-
command: 'hs account auth',
|
|
104
|
-
type: 'Migrate a single config',
|
|
105
|
-
successful: false,
|
|
106
|
-
}, providedAccountId);
|
|
107
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
93
|
+
return false;
|
|
108
94
|
}
|
|
109
95
|
}
|
|
110
|
-
|
|
96
|
+
const describe = en_1.commands.account.subcommands.auth.describe;
|
|
97
|
+
const command = 'auth';
|
|
98
|
+
async function handler(args) {
|
|
99
|
+
const { providedAccountId, disableTracking } = args;
|
|
100
|
+
if (!disableTracking) {
|
|
101
|
+
(0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
|
|
102
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
|
|
103
|
+
}
|
|
104
|
+
const configMigrationSuccess = await handleConfigMigration();
|
|
105
|
+
if (!configMigrationSuccess) {
|
|
106
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
|
|
107
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
108
|
+
}
|
|
109
|
+
const configAlreadyExists = (0, migrate_1.configFileExists)(true);
|
|
111
110
|
if (!configAlreadyExists) {
|
|
112
111
|
(0, config_1.createEmptyConfigFile)({}, true);
|
|
113
112
|
}
|
|
114
113
|
(0, config_1.loadConfig)('');
|
|
115
114
|
(0, process_1.handleExit)(config_1.deleteEmptyConfigFile);
|
|
116
|
-
const updatedConfig = await
|
|
115
|
+
const updatedConfig = await updateConfigWithNewAccount(args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD, configAlreadyExists, providedAccountId);
|
|
117
116
|
if (!updatedConfig) {
|
|
118
|
-
|
|
117
|
+
if (!disableTracking) {
|
|
118
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
|
|
119
|
+
}
|
|
120
|
+
logger_1.uiLogger.error(en_1.commands.account.subcommands.auth.errors.failedToUpdateConfig);
|
|
119
121
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
120
122
|
}
|
|
121
|
-
const { name } = updatedConfig;
|
|
122
123
|
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(updatedConfig);
|
|
123
124
|
if (!configAlreadyExists) {
|
|
124
|
-
logger_1.
|
|
125
|
-
logger_1.
|
|
126
|
-
|
|
127
|
-
}));
|
|
128
|
-
logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.auth.success.configFileUpdated', {
|
|
129
|
-
account: name || accountId?.toString() || '',
|
|
130
|
-
}));
|
|
125
|
+
logger_1.uiLogger.log('');
|
|
126
|
+
logger_1.uiLogger.success(en_1.commands.account.subcommands.auth.success.configFileCreated((0, migrate_1.getConfigPath)('', true)));
|
|
127
|
+
logger_1.uiLogger.success(en_1.commands.account.subcommands.auth.success.configFileUpdated(accountId));
|
|
131
128
|
}
|
|
132
129
|
else {
|
|
133
|
-
|
|
134
|
-
logger_1.logger.log('');
|
|
135
|
-
if (setAsDefault) {
|
|
136
|
-
logger_1.logger.success((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount`, {
|
|
137
|
-
accountName: name,
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
logger_1.logger.info((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
|
|
142
|
-
accountName: (0, config_1.getConfigDefaultAccount)(),
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
130
|
+
await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(updatedConfig.name);
|
|
145
131
|
}
|
|
146
132
|
(0, ui_1.uiFeatureHighlight)([
|
|
147
133
|
'helpCommand',
|
|
@@ -153,24 +139,10 @@ async function handleConfigUpdate(env, configAlreadyExists, disableTracking, aut
|
|
|
153
139
|
}
|
|
154
140
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
155
141
|
}
|
|
156
|
-
const describe = (0, lang_1.i18n)('commands.account.subcommands.auth.describe');
|
|
157
|
-
const command = 'auth';
|
|
158
|
-
async function handler(args) {
|
|
159
|
-
const { providedAccountId, disableTracking } = args;
|
|
160
|
-
const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
161
|
-
await handleConfigMigration(providedAccountId);
|
|
162
|
-
if (!disableTracking) {
|
|
163
|
-
(0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
|
|
164
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
|
|
165
|
-
}
|
|
166
|
-
const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
|
|
167
|
-
const configAlreadyExists = (0, migrate_1.configFileExists)(true);
|
|
168
|
-
await handleConfigUpdate(env, configAlreadyExists, disableTracking, authType, providedAccountId);
|
|
169
|
-
}
|
|
170
142
|
function accountAuthBuilder(yargs) {
|
|
171
143
|
yargs.options({
|
|
172
144
|
account: {
|
|
173
|
-
describe:
|
|
145
|
+
describe: en_1.commands.account.subcommands.auth.options.account,
|
|
174
146
|
type: 'string',
|
|
175
147
|
alias: 'a',
|
|
176
148
|
},
|
|
@@ -182,10 +154,7 @@ function accountAuthBuilder(yargs) {
|
|
|
182
154
|
});
|
|
183
155
|
return yargs;
|
|
184
156
|
}
|
|
185
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(accountAuthBuilder, command,
|
|
186
|
-
authMethod: auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
187
|
-
globalConfigPath: config_2.GLOBAL_CONFIG_PATH,
|
|
188
|
-
}), {
|
|
157
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(accountAuthBuilder, command, en_1.commands.account.subcommands.auth.verboseDescribe, {
|
|
189
158
|
useGlobalOptions: true,
|
|
190
159
|
useTestingOptions: true,
|
|
191
160
|
});
|
package/commands/auth.js
CHANGED
|
@@ -45,10 +45,8 @@ async function handler(args) {
|
|
|
45
45
|
(0, git_1.checkAndWarnGitInclusion)(configPath);
|
|
46
46
|
}
|
|
47
47
|
if ((0, config_2.configFileExists)(true)) {
|
|
48
|
-
const globalConfigPath = (0, config_2.getConfigPath)('', true);
|
|
49
48
|
logger_1.logger.error((0, lang_1.i18n)(`commands.auth.errors.globalConfigFileExists`, {
|
|
50
|
-
|
|
51
|
-
authCommand: (0, ui_1.uiCommandReference)('hs account auth'),
|
|
49
|
+
accountAuthCommand: (0, ui_1.uiCommandReference)('hs account auth'),
|
|
52
50
|
}));
|
|
53
51
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
52
|
}
|
|
@@ -112,18 +110,7 @@ async function handler(args) {
|
|
|
112
110
|
}
|
|
113
111
|
const nameFromConfigData = 'name' in configData ? configData.name : undefined;
|
|
114
112
|
const accountName = (updatedConfig && updatedConfig.name) || validName || nameFromConfigData;
|
|
115
|
-
|
|
116
|
-
logger_1.logger.log('');
|
|
117
|
-
if (setAsDefault) {
|
|
118
|
-
logger_1.logger.success((0, lang_1.i18n)('lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount', {
|
|
119
|
-
accountName,
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
logger_1.logger.info((0, lang_1.i18n)('lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault', {
|
|
124
|
-
accountName: (0, config_2.getConfigDefaultAccount)(),
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
113
|
+
await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(accountName);
|
|
127
114
|
logger_1.logger.success((0, lang_1.i18n)('commands.auth.success.configFileUpdated', {
|
|
128
115
|
configFilename: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
129
116
|
authType: successAuthMethod,
|
|
@@ -4,54 +4,42 @@ 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 config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
8
7
|
const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
|
|
9
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
8
|
const configMigrate_1 = require("../../lib/configMigrate");
|
|
11
|
-
const lang_1 = require("../../lib/lang");
|
|
12
|
-
const usageTracking_1 = require("../../lib/usageTracking");
|
|
13
9
|
const index_1 = require("../../lib/errorHandlers/index");
|
|
14
10
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
15
11
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
13
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
14
|
+
const en_1 = require("../../lang/en");
|
|
15
|
+
const describe = en_1.commands.config.subcommands.migrate.describe;
|
|
20
16
|
const command = 'migrate';
|
|
21
17
|
async function handler(args) {
|
|
22
|
-
const { config: configPath, force
|
|
18
|
+
const { derivedAccountId, config: configPath, force } = args;
|
|
19
|
+
(0, usageTracking_1.trackCommandUsage)('config-migrate', {}, derivedAccountId);
|
|
23
20
|
if (configPath && !fs_1.default.existsSync(configPath)) {
|
|
24
|
-
logger_1.
|
|
25
|
-
configPath,
|
|
26
|
-
}));
|
|
21
|
+
logger_1.uiLogger.error(en_1.commands.config.subcommands.migrate.errors.configNotFound(configPath));
|
|
27
22
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
28
23
|
}
|
|
29
24
|
const deprecatedConfigExists = (0, migrate_1.configFileExists)(false, configPath);
|
|
30
25
|
const globalConfigExists = (0, migrate_1.configFileExists)(true);
|
|
31
26
|
if (!deprecatedConfigExists) {
|
|
32
|
-
logger_1.
|
|
33
|
-
|
|
34
|
-
}));
|
|
35
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
27
|
+
logger_1.uiLogger.error(en_1.commands.config.subcommands.migrate.errors.noConfigToMigrate);
|
|
28
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
36
29
|
}
|
|
30
|
+
let success = false;
|
|
37
31
|
try {
|
|
38
32
|
if (!globalConfigExists) {
|
|
39
|
-
await (0, configMigrate_1.handleMigration)(
|
|
33
|
+
success = await (0, configMigrate_1.handleMigration)(configPath, true);
|
|
40
34
|
}
|
|
41
35
|
else {
|
|
42
|
-
await (0, configMigrate_1.handleMerge)(
|
|
36
|
+
success = await (0, configMigrate_1.handleMerge)(configPath, force, true);
|
|
43
37
|
}
|
|
44
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
45
38
|
}
|
|
46
39
|
catch (error) {
|
|
47
|
-
(0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
|
|
48
|
-
command: 'hs config migrate',
|
|
49
|
-
type: 'Migration/merge',
|
|
50
|
-
successful: false,
|
|
51
|
-
}, derivedAccountId);
|
|
52
40
|
(0, index_1.logError)(error);
|
|
53
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
41
|
}
|
|
42
|
+
process.exit(success ? exitCodes_1.EXIT_CODES.SUCCESS : exitCodes_1.EXIT_CODES.ERROR);
|
|
55
43
|
}
|
|
56
44
|
function configMigrateBuilder(yargs) {
|
|
57
45
|
return yargs
|
|
@@ -60,28 +48,21 @@ function configMigrateBuilder(yargs) {
|
|
|
60
48
|
alias: 'f',
|
|
61
49
|
type: 'boolean',
|
|
62
50
|
default: false,
|
|
63
|
-
description:
|
|
51
|
+
description: en_1.commands.config.subcommands.migrate.options.force,
|
|
64
52
|
},
|
|
65
53
|
})
|
|
66
54
|
.example([
|
|
67
55
|
[
|
|
68
56
|
'$0 config migrate',
|
|
69
|
-
|
|
70
|
-
deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
71
|
-
globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
|
|
72
|
-
}),
|
|
57
|
+
en_1.commands.config.subcommands.migrate.examples.default,
|
|
73
58
|
],
|
|
74
59
|
[
|
|
75
60
|
'$0 config migrate --config=/path/to/config.yml',
|
|
76
|
-
|
|
77
|
-
globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
|
|
78
|
-
}),
|
|
61
|
+
en_1.commands.config.subcommands.migrate.examples.configFlag,
|
|
79
62
|
],
|
|
80
63
|
]);
|
|
81
64
|
}
|
|
82
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(configMigrateBuilder, command,
|
|
83
|
-
archivedConfigPath: config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
84
|
-
}), {
|
|
65
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(configMigrateBuilder, command, en_1.commands.config.subcommands.migrate.verboseDescribe, {
|
|
85
66
|
useGlobalOptions: true,
|
|
86
67
|
useConfigOptions: true,
|
|
87
68
|
});
|
package/commands/init.js
CHANGED
|
@@ -76,9 +76,8 @@ async function handler(args) {
|
|
|
76
76
|
}
|
|
77
77
|
const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
|
|
78
78
|
if ((0, config_1.configFileExists)(true)) {
|
|
79
|
-
const globalConfigPath = (0, config_1.getConfigPath)('', true);
|
|
80
79
|
logger_1.logger.error((0, lang_1.i18n)(`commands.init.errors.globalConfigFileExists`, {
|
|
81
|
-
|
|
80
|
+
accountAuthCommand: (0, ui_1.uiCommandReference)('hs account auth'),
|
|
82
81
|
}));
|
|
83
82
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
84
83
|
}
|
|
@@ -6,32 +6,30 @@ 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 exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
11
11
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
12
12
|
const command = 'marketplace-validate <src>';
|
|
13
|
-
const describe =
|
|
13
|
+
const describe = en_1.commands.module.subcommands.marketplaceValidate.describe;
|
|
14
14
|
async function handler(args) {
|
|
15
15
|
const { src, derivedAccountId } = args;
|
|
16
16
|
(0, usageTracking_1.trackCommandUsage)('validate', undefined, derivedAccountId);
|
|
17
17
|
SpinniesManager_1.default.init();
|
|
18
18
|
SpinniesManager_1.default.add('marketplaceValidation', {
|
|
19
|
-
text:
|
|
20
|
-
path: src,
|
|
21
|
-
}),
|
|
19
|
+
text: en_1.commands.module.subcommands.marketplaceValidate.logs.validatingModule(src),
|
|
22
20
|
});
|
|
23
21
|
const assetType = 'MODULE';
|
|
24
22
|
const validationId = await (0, marketplaceValidate_1.kickOffValidation)(derivedAccountId, assetType, src);
|
|
25
23
|
await (0, marketplaceValidate_1.pollForValidationFinish)(derivedAccountId, validationId);
|
|
26
24
|
SpinniesManager_1.default.remove('marketplaceValidation');
|
|
27
25
|
const validationResults = await (0, marketplaceValidate_1.fetchValidationResults)(derivedAccountId, validationId);
|
|
28
|
-
(0, marketplaceValidate_1.processValidationErrors)(
|
|
29
|
-
(0, marketplaceValidate_1.displayValidationResults)(
|
|
26
|
+
(0, marketplaceValidate_1.processValidationErrors)(en_1.commands.module.subcommands.marketplaceValidate.errors.invalidPath, validationResults);
|
|
27
|
+
(0, marketplaceValidate_1.displayValidationResults)(en_1.commands.module.subcommands.marketplaceValidate.results, validationResults);
|
|
30
28
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
31
29
|
}
|
|
32
30
|
function marketplaceValidateBuilder(yargs) {
|
|
33
31
|
yargs.positional('src', {
|
|
34
|
-
describe:
|
|
32
|
+
describe: en_1.commands.module.subcommands.marketplaceValidate.positionals.src,
|
|
35
33
|
type: 'string',
|
|
36
34
|
});
|
|
37
35
|
return yargs;
|
package/commands/module.js
CHANGED
|
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const marketplace_validate_1 = __importDefault(require("./module/marketplace-validate"));
|
|
7
|
+
const en_1 = require("../lang/en");
|
|
7
8
|
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
8
9
|
const command = 'module';
|
|
9
|
-
const describe =
|
|
10
|
+
const describe = en_1.commands.module.describe;
|
|
10
11
|
function moduleBuilder(yargs) {
|
|
11
12
|
yargs.command(marketplace_validate_1.default).demandCommand(1, '');
|
|
12
13
|
return yargs;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { YargsCommandModule, CommonArgs } from '../../types/Yargs';
|
|
2
2
|
type ProjectAddArgs = CommonArgs & {
|
|
3
|
-
type
|
|
4
|
-
name
|
|
3
|
+
type?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
features?: string[];
|
|
6
|
+
distribution?: string;
|
|
7
|
+
auth?: string;
|
|
5
8
|
};
|
|
6
9
|
declare const projectAddCommand: YargsCommandModule<unknown, ProjectAddArgs>;
|
|
7
10
|
export default projectAddCommand;
|
package/commands/project/add.js
CHANGED
|
@@ -1,87 +1,38 @@
|
|
|
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
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
-
const github_1 = require("@hubspot/local-dev-lib/github");
|
|
9
3
|
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
10
4
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
11
|
-
const lang_1 = require("../../lib/lang");
|
|
12
|
-
const projectAddPrompt_1 = require("../../lib/prompts/projectAddPrompt");
|
|
13
5
|
const config_1 = require("../../lib/projects/config");
|
|
14
|
-
const create_1 = require("../../lib/projects/create");
|
|
15
|
-
const structure_1 = require("../../lib/projects/structure");
|
|
16
|
-
const Projects_1 = require("../../types/Projects");
|
|
17
6
|
const ui_1 = require("../../lib/ui");
|
|
18
|
-
const constants_1 = require("../../lib/constants");
|
|
19
7
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
20
8
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
9
|
+
const en_1 = require("../../lang/en");
|
|
10
|
+
const buildAndDeploy_1 = require("../../lib/projects/buildAndDeploy");
|
|
11
|
+
const legacyAddComponent_1 = require("../../lib/projects/add/legacyAddComponent");
|
|
12
|
+
const v3AddComponent_1 = require("../../lib/projects/add/v3AddComponent");
|
|
13
|
+
const constants_1 = require("../../lib/constants");
|
|
14
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
21
15
|
const command = 'add';
|
|
22
|
-
const describe = (0, ui_1.uiBetaTag)(
|
|
16
|
+
const describe = (0, ui_1.uiBetaTag)(en_1.commands.project.add.describe, false);
|
|
23
17
|
async function handler(args) {
|
|
24
|
-
const { derivedAccountId } = args;
|
|
25
|
-
(0, usageTracking_1.trackCommandUsage)('project-add', undefined, derivedAccountId);
|
|
26
|
-
const { projectConfig, projectDir } = await (0, config_1.getProjectConfig)();
|
|
27
|
-
if (!projectDir || !projectConfig) {
|
|
28
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.add.error.locationInProject`));
|
|
29
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
|
-
}
|
|
31
|
-
// We currently only support adding private apps to projects
|
|
32
|
-
let projectContainsPublicApp = false;
|
|
33
|
-
try {
|
|
34
|
-
const components = await (0, structure_1.findProjectComponents)(projectDir);
|
|
35
|
-
projectContainsPublicApp = components.some(c => c.type === Projects_1.ComponentTypes.PublicApp);
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
(0, errorHandlers_1.debugError)(err);
|
|
39
|
-
}
|
|
40
|
-
if (projectContainsPublicApp) {
|
|
41
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.add.error.projectContainsPublicApp`));
|
|
42
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
43
|
-
}
|
|
44
|
-
logger_1.logger.log('');
|
|
45
|
-
logger_1.logger.log((0, lang_1.i18n)(`commands.project.subcommands.add.creatingComponent`, {
|
|
46
|
-
projectName: projectConfig.name,
|
|
47
|
-
}));
|
|
48
|
-
logger_1.logger.log('');
|
|
49
|
-
let latestRepoReleaseTag;
|
|
50
18
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
19
|
+
const { derivedAccountId } = args;
|
|
20
|
+
(0, usageTracking_1.trackCommandUsage)('project-add', undefined, derivedAccountId);
|
|
21
|
+
const { projectConfig, projectDir } = await (0, config_1.getProjectConfig)();
|
|
22
|
+
if (!projectDir || !projectConfig) {
|
|
23
|
+
logger_1.uiLogger.error(en_1.commands.project.add.error.locationInProject);
|
|
24
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
25
|
+
}
|
|
26
|
+
const isV3ProjectCreate = (0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion);
|
|
27
|
+
if (isV3ProjectCreate) {
|
|
28
|
+
await (0, v3AddComponent_1.v3AddComponent)(args, projectDir, projectConfig);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
await (0, legacyAddComponent_1.legacyAddComponent)(args, projectDir, projectConfig);
|
|
55
32
|
}
|
|
56
33
|
}
|
|
57
|
-
catch (
|
|
58
|
-
(0, errorHandlers_1.
|
|
59
|
-
}
|
|
60
|
-
if (!latestRepoReleaseTag) {
|
|
61
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.add.error.failedToFetchComponentList`));
|
|
62
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
|
-
}
|
|
64
|
-
const components = await (0, create_1.getProjectComponentListFromRepo)(latestRepoReleaseTag);
|
|
65
|
-
if (!components.length) {
|
|
66
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.add.error.failedToFetchComponentList`));
|
|
67
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
68
|
-
}
|
|
69
|
-
const projectAddPromptResponse = await (0, projectAddPrompt_1.projectAddPrompt)(components, args);
|
|
70
|
-
try {
|
|
71
|
-
const componentPath = path_1.default.join(projectDir, projectConfig.srcDir, projectAddPromptResponse.componentTemplate.insertPath, projectAddPromptResponse.name);
|
|
72
|
-
await (0, github_1.cloneGithubRepo)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, componentPath, {
|
|
73
|
-
sourceDir: projectAddPromptResponse.componentTemplate.path,
|
|
74
|
-
tag: latestRepoReleaseTag,
|
|
75
|
-
hideLogs: true,
|
|
76
|
-
});
|
|
77
|
-
logger_1.logger.log('');
|
|
78
|
-
logger_1.logger.success((0, lang_1.i18n)(`commands.project.subcommands.add.success`, {
|
|
79
|
-
componentName: projectAddPromptResponse.name,
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
(0, errorHandlers_1.debugError)(error);
|
|
84
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.add.error.failedToDownloadComponent`));
|
|
34
|
+
catch (e) {
|
|
35
|
+
(0, errorHandlers_1.logError)(e);
|
|
85
36
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
86
37
|
}
|
|
87
38
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
@@ -89,24 +40,36 @@ async function handler(args) {
|
|
|
89
40
|
function projectAddBuilder(yargs) {
|
|
90
41
|
yargs.options({
|
|
91
42
|
type: {
|
|
92
|
-
describe:
|
|
43
|
+
describe: en_1.commands.project.add.options.type.describe,
|
|
93
44
|
type: 'string',
|
|
94
45
|
},
|
|
95
46
|
name: {
|
|
96
|
-
describe:
|
|
47
|
+
describe: en_1.commands.project.add.options.name.describe,
|
|
48
|
+
type: 'string',
|
|
49
|
+
},
|
|
50
|
+
distribution: {
|
|
51
|
+
describe: en_1.commands.project.add.options.distribution.describe,
|
|
52
|
+
hidden: true,
|
|
97
53
|
type: 'string',
|
|
54
|
+
choices: [constants_1.privateDistribution, constants_1.marketplaceDistribution],
|
|
55
|
+
},
|
|
56
|
+
auth: {
|
|
57
|
+
describe: en_1.commands.project.add.options.auth.describe,
|
|
58
|
+
hidden: true,
|
|
59
|
+
type: 'string',
|
|
60
|
+
choices: [constants_1.oAuth, constants_1.staticAuth],
|
|
61
|
+
},
|
|
62
|
+
features: {
|
|
63
|
+
describe: en_1.commands.project.add.options.features.describe,
|
|
64
|
+
hidden: true,
|
|
65
|
+
type: 'array',
|
|
98
66
|
},
|
|
99
67
|
});
|
|
100
|
-
yargs.example([
|
|
101
|
-
[
|
|
102
|
-
'$0 project add',
|
|
103
|
-
(0, lang_1.i18n)(`commands.project.subcommands.add.examples.default`),
|
|
104
|
-
],
|
|
105
|
-
]);
|
|
68
|
+
yargs.example([['$0 project add', en_1.commands.project.add.examples.default]]);
|
|
106
69
|
yargs.example([
|
|
107
70
|
[
|
|
108
71
|
'$0 project add --name="my-component" --type="components/example-app"',
|
|
109
|
-
|
|
72
|
+
en_1.commands.project.add.examples.withFlags,
|
|
110
73
|
],
|
|
111
74
|
]);
|
|
112
75
|
return yargs;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
type ProjectCreateArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
4
|
-
name?: string;
|
|
5
|
-
dest?: string;
|
|
6
|
-
templateSource?: RepoPath;
|
|
7
|
-
template?: string;
|
|
8
|
-
};
|
|
1
|
+
import { YargsCommandModule } from '../../types/Yargs';
|
|
2
|
+
import { ProjectCreateArgs } from '../../lib/projects/create';
|
|
9
3
|
declare const projectCreateCommand: YargsCommandModule<unknown, ProjectCreateArgs>;
|
|
10
4
|
export default projectCreateCommand;
|