@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
package/bin/cli.js
CHANGED
|
@@ -1,80 +1,83 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const index_1 = require("../lib/errorHandlers/index");
|
|
10
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
11
|
+
const usageTracking_1 = require("../lib/usageTracking");
|
|
12
|
+
const exitCodes_1 = require("../lib/enums/exitCodes");
|
|
13
|
+
const configMiddleware_1 = require("../lib/middleware/configMiddleware");
|
|
14
|
+
const autoUpdateMiddleware_1 = require("../lib/middleware/autoUpdateMiddleware");
|
|
15
|
+
const gitMiddleware_1 = require("../lib/middleware/gitMiddleware");
|
|
16
|
+
const yargsChecksMiddleware_1 = require("../lib/middleware/yargsChecksMiddleware");
|
|
17
|
+
const requestMiddleware_1 = require("../lib/middleware/requestMiddleware");
|
|
18
|
+
const fireAlarmMiddleware_1 = require("../lib/middleware/fireAlarmMiddleware");
|
|
19
|
+
const remove_1 = __importDefault(require("../commands/remove"));
|
|
20
|
+
const init_1 = __importDefault(require("../commands/init"));
|
|
21
|
+
const logs_1 = __importDefault(require("../commands/logs"));
|
|
22
|
+
const lint_1 = __importDefault(require("../commands/lint"));
|
|
23
|
+
const hubdb_1 = __importDefault(require("../commands/hubdb"));
|
|
24
|
+
const watch_1 = __importDefault(require("../commands/watch"));
|
|
25
|
+
const auth_1 = __importDefault(require("../commands/auth"));
|
|
26
|
+
const upload_1 = __importDefault(require("../commands/upload"));
|
|
27
|
+
const create_1 = __importDefault(require("../commands/create"));
|
|
28
|
+
const fetch_1 = __importDefault(require("../commands/fetch"));
|
|
29
|
+
const filemanager_1 = __importDefault(require("../commands/filemanager"));
|
|
30
|
+
const secret_1 = __importDefault(require("../commands/secret"));
|
|
31
|
+
const customObject_1 = __importDefault(require("../commands/customObject"));
|
|
32
|
+
const function_1 = __importDefault(require("../commands/function"));
|
|
33
|
+
const list_1 = __importDefault(require("../commands/list"));
|
|
34
|
+
const open_1 = __importDefault(require("../commands/open"));
|
|
35
|
+
const mv_1 = __importDefault(require("../commands/mv"));
|
|
36
|
+
const project_1 = __importDefault(require("../commands/project"));
|
|
37
|
+
const theme_1 = __importDefault(require("../commands/theme"));
|
|
38
|
+
const module_1 = __importDefault(require("../commands/module"));
|
|
39
|
+
const config_1 = __importDefault(require("../commands/config"));
|
|
40
|
+
const account_1 = __importDefault(require("../commands/account"));
|
|
41
|
+
const sandbox_1 = __importDefault(require("../commands/sandbox"));
|
|
42
|
+
const cms_1 = __importDefault(require("../commands/cms"));
|
|
43
|
+
const feedback_1 = __importDefault(require("../commands/feedback"));
|
|
44
|
+
const doctor_1 = __importDefault(require("../commands/doctor"));
|
|
45
|
+
const completion_1 = __importDefault(require("../commands/completion"));
|
|
46
|
+
const app_1 = __importDefault(require("../commands/app"));
|
|
47
|
+
function getTerminalWidth() {
|
|
48
|
+
const width = yargs_1.default.terminalWidth();
|
|
46
49
|
if (width >= 100)
|
|
47
50
|
return width * 0.9;
|
|
48
51
|
return width;
|
|
49
|
-
}
|
|
50
|
-
|
|
52
|
+
}
|
|
53
|
+
function handleFailure(msg, err, yargs) {
|
|
51
54
|
if (msg) {
|
|
52
|
-
logger.error(msg);
|
|
55
|
+
logger_1.logger.error(msg);
|
|
53
56
|
}
|
|
54
57
|
else if (err) {
|
|
55
|
-
logError(err);
|
|
58
|
+
(0, index_1.logError)(err);
|
|
56
59
|
}
|
|
57
60
|
if (msg === null) {
|
|
58
61
|
yargs.showHelp('log');
|
|
59
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
62
|
-
process.exit(EXIT_CODES.ERROR);
|
|
65
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
66
|
}
|
|
64
|
-
}
|
|
65
|
-
const argv =
|
|
67
|
+
}
|
|
68
|
+
const argv = yargs_1.default
|
|
66
69
|
.usage('The command line interface to interact with HubSpot.')
|
|
67
70
|
// loadConfigMiddleware loads the new hidden config for all commands
|
|
68
71
|
.middleware([
|
|
69
|
-
setLogLevel,
|
|
70
|
-
setRequestHeaders,
|
|
71
|
-
handleDeprecatedEnvVariables,
|
|
72
|
-
loadConfigMiddleware,
|
|
73
|
-
injectAccountIdMiddleware,
|
|
74
|
-
autoUpdateCLI,
|
|
75
|
-
checkAndWarnGitInclusionMiddleware,
|
|
76
|
-
validateAccountOptions,
|
|
77
|
-
checkFireAlarms,
|
|
72
|
+
commonOpts_1.setLogLevel,
|
|
73
|
+
requestMiddleware_1.setRequestHeaders,
|
|
74
|
+
configMiddleware_1.handleDeprecatedEnvVariables,
|
|
75
|
+
configMiddleware_1.loadConfigMiddleware,
|
|
76
|
+
configMiddleware_1.injectAccountIdMiddleware,
|
|
77
|
+
autoUpdateMiddleware_1.autoUpdateCLI,
|
|
78
|
+
gitMiddleware_1.checkAndWarnGitInclusionMiddleware,
|
|
79
|
+
configMiddleware_1.validateAccountOptions,
|
|
80
|
+
fireAlarmMiddleware_1.checkFireAlarms,
|
|
78
81
|
])
|
|
79
82
|
.exitProcess(false)
|
|
80
83
|
.fail(handleFailure)
|
|
@@ -90,45 +93,44 @@ const argv = yargs
|
|
|
90
93
|
hidden: true,
|
|
91
94
|
type: 'boolean',
|
|
92
95
|
})
|
|
93
|
-
.check(performChecks)
|
|
94
|
-
.command(
|
|
95
|
-
.command(
|
|
96
|
-
.command(
|
|
97
|
-
.command(
|
|
98
|
-
.command(
|
|
99
|
-
.command(
|
|
100
|
-
.command(
|
|
101
|
-
.command(
|
|
102
|
-
.command(
|
|
103
|
-
.command(
|
|
104
|
-
.command(
|
|
105
|
-
.command(
|
|
106
|
-
.command(
|
|
107
|
-
.command(
|
|
108
|
-
.command(
|
|
109
|
-
.command(
|
|
110
|
-
.command(
|
|
111
|
-
.command(
|
|
112
|
-
.command(
|
|
113
|
-
.command(
|
|
114
|
-
.command(
|
|
115
|
-
.command(
|
|
116
|
-
.command(
|
|
117
|
-
.command(
|
|
118
|
-
.command(
|
|
119
|
-
.command(
|
|
120
|
-
.command(
|
|
121
|
-
.command(
|
|
122
|
-
.command(testAccountCommand)
|
|
96
|
+
.check(yargsChecksMiddleware_1.performChecks)
|
|
97
|
+
.command(auth_1.default)
|
|
98
|
+
.command(init_1.default)
|
|
99
|
+
.command(logs_1.default)
|
|
100
|
+
.command(cms_1.default)
|
|
101
|
+
.command(lint_1.default)
|
|
102
|
+
.command(hubdb_1.default)
|
|
103
|
+
.command(watch_1.default)
|
|
104
|
+
.command(remove_1.default)
|
|
105
|
+
.command(upload_1.default)
|
|
106
|
+
.command(create_1.default)
|
|
107
|
+
.command(fetch_1.default)
|
|
108
|
+
.command(filemanager_1.default)
|
|
109
|
+
.command(secret_1.default)
|
|
110
|
+
.command(customObject_1.default)
|
|
111
|
+
.command(function_1.default)
|
|
112
|
+
.command(list_1.default)
|
|
113
|
+
.command(open_1.default)
|
|
114
|
+
.command(mv_1.default)
|
|
115
|
+
.command(project_1.default)
|
|
116
|
+
.command(theme_1.default)
|
|
117
|
+
.command(module_1.default)
|
|
118
|
+
.command(config_1.default)
|
|
119
|
+
.command(account_1.default)
|
|
120
|
+
.command(sandbox_1.default)
|
|
121
|
+
.command(feedback_1.default)
|
|
122
|
+
.command(doctor_1.default)
|
|
123
|
+
.command(completion_1.default)
|
|
124
|
+
.command(app_1.default)
|
|
123
125
|
.help()
|
|
124
126
|
.alias('h', 'help')
|
|
125
127
|
.recommendCommands()
|
|
126
128
|
.demandCommand(1, '')
|
|
127
129
|
.wrap(getTerminalWidth())
|
|
128
130
|
.strict().argv;
|
|
129
|
-
if (argv.help) {
|
|
130
|
-
trackHelpUsage(getCommandName(argv));
|
|
131
|
+
if ('help' in argv && argv.help !== undefined) {
|
|
132
|
+
(0, usageTracking_1.trackHelpUsage)((0, commonOpts_1.getCommandName)(argv));
|
|
131
133
|
}
|
|
132
|
-
if (argv.convertFields) {
|
|
133
|
-
trackConvertFieldsUsage(getCommandName(argv));
|
|
134
|
+
if ('convertFields' in argv && argv.convertFields !== undefined) {
|
|
135
|
+
(0, usageTracking_1.trackConvertFieldsUsage)((0, commonOpts_1.getCommandName)(argv));
|
|
134
136
|
}
|
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/account.js
CHANGED
package/commands/app.js
CHANGED
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,
|
|
@@ -172,5 +159,3 @@ const authCommand = {
|
|
|
172
159
|
builder,
|
|
173
160
|
};
|
|
174
161
|
exports.default = authCommand;
|
|
175
|
-
// TODO Remove this legacy export once we've migrated all commands to TS
|
|
176
|
-
module.exports = authCommand;
|
package/commands/cms.js
CHANGED
package/commands/completion.js
CHANGED
|
@@ -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/config.js
CHANGED