@hubspot/cli 7.7.0-experimental.3 → 7.7.1-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.js +0 -2
- package/commands/app.js +0 -2
- package/commands/auth.js +0 -2
- package/commands/cms.js +0 -2
- package/commands/completion.js +0 -2
- 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 +0 -2
- package/commands/lint.js +0 -2
- package/commands/list.js +0 -2
- package/commands/mv.js +0 -2
- package/commands/open.js +0 -2
- 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 +27 -41
- package/commands/project.js +0 -2
- package/commands/remove.js +0 -2
- package/commands/sandbox.js +0 -2
- package/commands/secret.js +0 -2
- package/commands/theme.js +0 -2
- package/commands/upload.js +0 -2
- package/lang/en.d.ts +14 -3
- package/lang/en.js +14 -3
- package/lib/accountTypes.js +1 -3
- package/lib/commonOpts.d.ts +1 -3
- package/lib/commonOpts.js +1 -1
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +5 -3
- package/lib/projects/localDev/AppDevModeInterface.js +0 -6
- package/lib/projects/upload.js +6 -0
- package/lib/prompts/promptUtils.d.ts +0 -1
- package/lib/prompts/promptUtils.js +0 -2
- package/package.json +4 -4
- 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/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.js
CHANGED
package/commands/app.js
CHANGED
package/commands/auth.js
CHANGED
package/commands/cms.js
CHANGED
package/commands/completion.js
CHANGED
package/commands/config.js
CHANGED
package/commands/create.js
CHANGED
package/commands/customObject.js
CHANGED
package/commands/doctor.js
CHANGED
package/commands/feedback.js
CHANGED
package/commands/filemanager.js
CHANGED
package/commands/function.js
CHANGED
package/commands/hubdb.js
CHANGED
package/commands/init.js
CHANGED
package/commands/lint.js
CHANGED
package/commands/list.js
CHANGED
package/commands/mv.js
CHANGED
package/commands/open.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
3
2
|
import { ProjectConfig } from '../../../types/Projects';
|
|
4
3
|
import { ProjectDevArgs } from '../../../types/Yargs';
|
|
5
|
-
|
|
4
|
+
type DeprecatedProjectDevFlowArgs = {
|
|
5
|
+
args: ArgumentsCamelCase<ProjectDevArgs>;
|
|
6
|
+
accountId: number;
|
|
7
|
+
projectConfig: ProjectConfig;
|
|
8
|
+
projectDir: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function deprecatedProjectDevFlow({ args, accountId, projectConfig, projectDir, }: DeprecatedProjectDevFlowArgs): Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -18,7 +18,7 @@ const helpers_1 = require("../../../lib/projects/localDev/helpers");
|
|
|
18
18
|
const process_1 = require("../../../lib/process");
|
|
19
19
|
const accountTypes_1 = require("../../../lib/accountTypes");
|
|
20
20
|
const ensureProjectExists_1 = require("../../../lib/projects/ensureProjectExists");
|
|
21
|
-
async function deprecatedProjectDevFlow(args,
|
|
21
|
+
async function deprecatedProjectDevFlow({ args, accountId, projectConfig, projectDir, }) {
|
|
22
22
|
const { providedAccountId, derivedAccountId } = args;
|
|
23
23
|
const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
|
|
24
24
|
const components = await (0, structure_1.findProjectComponents)(projectDir);
|
|
@@ -26,6 +26,14 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
|
|
|
26
26
|
const componentTypes = (0, structure_1.getProjectComponentTypes)(runnableComponents);
|
|
27
27
|
const hasPrivateApps = !!componentTypes[Projects_1.ComponentTypes.PrivateApp];
|
|
28
28
|
const hasPublicApps = !!componentTypes[Projects_1.ComponentTypes.PublicApp];
|
|
29
|
+
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
30
|
+
if (!accountConfig) {
|
|
31
|
+
logger_1.logger.error((0, lang_1.i18n)('commands.project.subcommands.dev.errors.noAccount', {
|
|
32
|
+
accountId: accountId,
|
|
33
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
34
|
+
}));
|
|
35
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
36
|
+
}
|
|
29
37
|
if (runnableComponents.length === 0) {
|
|
30
38
|
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noRunnableComponents`, {
|
|
31
39
|
projectDir,
|
|
@@ -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;
|
package/commands/project.js
CHANGED
package/commands/remove.js
CHANGED
package/commands/sandbox.js
CHANGED
package/commands/secret.js
CHANGED
package/commands/theme.js
CHANGED
package/commands/upload.js
CHANGED
package/lang/en.d.ts
CHANGED
|
@@ -810,18 +810,28 @@ Profiles enable you to reference variables in your component configuration files
|
|
|
810
810
|
readonly placeholderAccountSelection: "Using default account as target account (for now)";
|
|
811
811
|
readonly learnMoreLocalDevServer: "Learn more about the projects local dev server";
|
|
812
812
|
readonly accountTypeInformation: "Testing in a developer test account is strongly recommended, but you can use a sandbox account if your plan allows you to create one.";
|
|
813
|
-
readonly learnMoreMessage: `
|
|
813
|
+
readonly learnMoreMessage: `
|
|
814
|
+
Visit our ${string} to learn more.`;
|
|
814
815
|
};
|
|
815
816
|
readonly errors: {
|
|
816
817
|
readonly noProjectConfig: "No project detected. Please run this command again from a project directory.";
|
|
817
|
-
readonly noAccount: (accountId:
|
|
818
|
+
readonly noAccount: (accountId: number) => string;
|
|
818
819
|
readonly noAccountsInConfig: (authCommand: string) => string;
|
|
819
820
|
readonly invalidProjectComponents: "Projects cannot contain both private and public apps. Move your apps to separate projects before attempting local development.";
|
|
820
|
-
readonly noRunnableComponents:
|
|
821
|
+
readonly noRunnableComponents: `No supported components were found in this project. Run ${string} to see a list of available components and add one to your project.`;
|
|
822
|
+
readonly accountNotCombined: `
|
|
823
|
+
Local development of unified apps is currently only compatible with accounts that are opted into the unified apps beta. Make sure that this account is opted in or switch accounts using ${string}.`;
|
|
824
|
+
readonly unsupportedAccountFlagLegacy: "The --projectAccount and --testingAccount flags are not supported for projects with platform versions earlier than 2025.2.";
|
|
825
|
+
readonly unsupportedAccountFlagV3: "The --account flag is is not supported supported for projects with platform versions 2025.2 and newer. Use --testingAccount and --projectAccount flags to specify accounts to use for local dev";
|
|
821
826
|
};
|
|
822
827
|
readonly examples: {
|
|
823
828
|
readonly default: "Start local dev for the current project";
|
|
824
829
|
};
|
|
830
|
+
readonly options: {
|
|
831
|
+
readonly profile: "The profile to target during local dev";
|
|
832
|
+
readonly projectAccount: "The id of the account to upload your project to. Only compatible with platform versions 2025.2 and above.";
|
|
833
|
+
readonly testingAccount: "The id of the account to install apps and test on. Only compatible with platform versions 2025.2 and above.";
|
|
834
|
+
};
|
|
825
835
|
};
|
|
826
836
|
readonly create: {
|
|
827
837
|
readonly describe: "Create a new project.";
|
|
@@ -2410,6 +2420,7 @@ Run ${string} to upgrade to version ${string}`;
|
|
|
2410
2420
|
};
|
|
2411
2421
|
};
|
|
2412
2422
|
readonly projectUpload: {
|
|
2423
|
+
readonly wrongPlatformVersionMetaFiles: `Detected components that require a minimum platform version of ${string}. You need to update your platform version in your hsproject.json and run ${string}`;
|
|
2413
2424
|
readonly uploadProjectFiles: {
|
|
2414
2425
|
readonly add: (projectName: string, accountIdentifier: string) => string;
|
|
2415
2426
|
readonly fail: (projectName: string, accountIdentifier: string) => string;
|
package/lang/en.js
CHANGED
|
@@ -8,6 +8,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const ui_1 = require("../lib/ui");
|
|
9
9
|
const urls_1 = require("../lib/projects/urls");
|
|
10
10
|
const ui_2 = require("../lib/ui");
|
|
11
|
+
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
12
|
+
const constants_1 = require("../lib/constants");
|
|
11
13
|
exports.commands = {
|
|
12
14
|
generalErrors: {
|
|
13
15
|
srcIsProject: (src, command) => `"${src}" is in a project folder. Did you mean "hs project ${command}"?`,
|
|
@@ -814,18 +816,26 @@ exports.commands = {
|
|
|
814
816
|
placeholderAccountSelection: 'Using default account as target account (for now)',
|
|
815
817
|
learnMoreLocalDevServer: 'Learn more about the projects local dev server',
|
|
816
818
|
accountTypeInformation: 'Testing in a developer test account is strongly recommended, but you can use a sandbox account if your plan allows you to create one.',
|
|
817
|
-
learnMoreMessage:
|
|
819
|
+
learnMoreMessage: `\nVisit our ${(0, ui_1.uiLink)('docs on Developer Test and Sandbox accounts', 'https://developers.hubspot.com/docs/getting-started/account-types')} to learn more.`,
|
|
818
820
|
},
|
|
819
821
|
errors: {
|
|
820
822
|
noProjectConfig: 'No project detected. Please run this command again from a project directory.',
|
|
821
|
-
noAccount: (accountId
|
|
823
|
+
noAccount: (accountId) => `An error occurred while reading account ${(0, ui_1.uiAccountDescription)(accountId)} from your config. Run ${(0, ui_1.uiCommandReference)('hs auth')} to re-auth this account.`,
|
|
822
824
|
noAccountsInConfig: (authCommand) => `No accounts found in your config. Run ${chalk_1.default.bold(authCommand)} to configure a HubSpot account with the CLI.`,
|
|
823
825
|
invalidProjectComponents: 'Projects cannot contain both private and public apps. Move your apps to separate projects before attempting local development.',
|
|
824
|
-
noRunnableComponents:
|
|
826
|
+
noRunnableComponents: `No supported components were found in this project. Run ${(0, ui_1.uiCommandReference)('hs project add')} to see a list of available components and add one to your project.`,
|
|
827
|
+
accountNotCombined: `\nLocal development of unified apps is currently only compatible with accounts that are opted into the unified apps beta. Make sure that this account is opted in or switch accounts using ${(0, ui_1.uiCommandReference)('hs account use')}.`,
|
|
828
|
+
unsupportedAccountFlagLegacy: 'The --projectAccount and --testingAccount flags are not supported for projects with platform versions earlier than 2025.2.',
|
|
829
|
+
unsupportedAccountFlagV3: 'The --account flag is is not supported supported for projects with platform versions 2025.2 and newer. Use --testingAccount and --projectAccount flags to specify accounts to use for local dev',
|
|
825
830
|
},
|
|
826
831
|
examples: {
|
|
827
832
|
default: 'Start local dev for the current project',
|
|
828
833
|
},
|
|
834
|
+
options: {
|
|
835
|
+
profile: 'The profile to target during local dev',
|
|
836
|
+
projectAccount: 'The id of the account to upload your project to. Only compatible with platform versions 2025.2 and above.',
|
|
837
|
+
testingAccount: 'The id of the account to install apps and test on. Only compatible with platform versions 2025.2 and above.',
|
|
838
|
+
},
|
|
829
839
|
},
|
|
830
840
|
create: {
|
|
831
841
|
describe: 'Create a new project.',
|
|
@@ -2409,6 +2419,7 @@ exports.lib = {
|
|
|
2409
2419
|
},
|
|
2410
2420
|
},
|
|
2411
2421
|
projectUpload: {
|
|
2422
|
+
wrongPlatformVersionMetaFiles: `Detected components that require a minimum platform version of ${projects_1.PLATFORM_VERSIONS.v2025_2}. You need to update your platform version in your ${constants_1.PROJECT_CONFIG_FILE} and run ${(0, ui_1.uiCommandReference)('hs project upload')}`,
|
|
2412
2423
|
uploadProjectFiles: {
|
|
2413
2424
|
add: (projectName, accountIdentifier) => `Uploading ${chalk_1.default.bold(projectName)} project files to ${accountIdentifier}`,
|
|
2414
2425
|
fail: (projectName, accountIdentifier) => `Failed to upload ${chalk_1.default.bold(projectName)} project files to ${accountIdentifier}`,
|
package/lib/accountTypes.js
CHANGED
|
@@ -39,7 +39,5 @@ async function isUnifiedAccount(account) {
|
|
|
39
39
|
if (!accountId) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
return ((isStandardAccount(account) || isAppDeveloperAccount(account)) &&
|
|
44
|
-
isUngatedForUnifiedApps);
|
|
42
|
+
return (0, hasFeature_1.hasFeature)(accountId, constants_1.FEATURES.UNIFIED_APPS);
|
|
45
43
|
}
|
package/lib/commonOpts.d.ts
CHANGED
|
@@ -16,9 +16,7 @@ export declare function setLogLevel(options: Arguments<{
|
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
networkDebug?: boolean;
|
|
18
18
|
}>): void;
|
|
19
|
-
export declare function getCommandName(argv: Arguments
|
|
20
|
-
_?: string[];
|
|
21
|
-
}>): string;
|
|
19
|
+
export declare function getCommandName(argv: Arguments): string;
|
|
22
20
|
export declare function getCmsPublishMode(options: Arguments<{
|
|
23
21
|
cmsPublishMode?: CmsPublishMode;
|
|
24
22
|
derivedAccountId?: number;
|
package/lib/commonOpts.js
CHANGED
|
@@ -138,7 +138,7 @@ function setLogLevel(options) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
function getCommandName(argv) {
|
|
141
|
-
return (argv && argv._ && argv._[0]) || '';
|
|
141
|
+
return String(argv && argv._ && argv._[0]) || '';
|
|
142
142
|
}
|
|
143
143
|
function getCmsPublishMode(options) {
|
|
144
144
|
// 1. --cmsPublishMode
|
|
@@ -112,10 +112,12 @@ async function logFireAlarms(accountId, command, version) {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
async function checkFireAlarms(
|
|
116
|
-
const { derivedAccountId } =
|
|
115
|
+
async function checkFireAlarms(argv) {
|
|
116
|
+
const { derivedAccountId } = argv;
|
|
117
117
|
try {
|
|
118
|
-
|
|
118
|
+
if (derivedAccountId) {
|
|
119
|
+
await logFireAlarms(derivedAccountId, argv._.join(' '), package_json_1.default.version);
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
122
|
catch (error) {
|
|
121
123
|
(0, errorHandlers_1.debugError)(error);
|
|
@@ -98,12 +98,6 @@ class AppDevModeInterface {
|
|
|
98
98
|
if (!this.appNode || !this.appData) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
// If the app is static auth, always prompt the user to install the app.
|
|
102
|
-
// We are currently going this because we have no method to determine if the static auth app
|
|
103
|
-
// is already installed in the portal
|
|
104
|
-
if (this.appNode.config.auth.type === constants_1.APP_AUTH_TYPES.STATIC) {
|
|
105
|
-
return (0, installAppPrompt_1.installAppPrompt)(await this.getAppInstallUrl(), false);
|
|
106
|
-
}
|
|
107
101
|
const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await (0, localDevAuth_1.fetchAppInstallationData)(this.localDevState.targetTestingAccountId, this.localDevState.projectId, this.appNode.uid, this.appNode.config.auth.requiredScopes, this.appNode.config.auth.optionalScopes);
|
|
108
102
|
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
109
103
|
if (!isInstalledWithScopeGroups) {
|
package/lib/projects/upload.js
CHANGED
|
@@ -19,6 +19,7 @@ const node_util_1 = __importDefault(require("node:util"));
|
|
|
19
19
|
const en_1 = require("../../lang/en");
|
|
20
20
|
const ensureProjectExists_1 = require("./ensureProjectExists");
|
|
21
21
|
const logger_1 = require("../ui/logger");
|
|
22
|
+
const buildAndDeploy_1 = require("./buildAndDeploy");
|
|
22
23
|
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation) {
|
|
23
24
|
SpinniesManager_1.default.init({});
|
|
24
25
|
const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
|
|
@@ -53,6 +54,11 @@ async function handleProjectUpload({ accountId, projectConfig, projectDir, callb
|
|
|
53
54
|
logger_1.uiLogger.log(en_1.lib.projectUpload.handleProjectUpload.emptySource(projectConfig.srcDir));
|
|
54
55
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
55
56
|
}
|
|
57
|
+
const hasHsMetaFiles = await (0, project_parsing_lib_1.projectContainsHsMetaFiles)(srcDir);
|
|
58
|
+
if (!(0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion) && hasHsMetaFiles) {
|
|
59
|
+
logger_1.uiLogger.error(en_1.lib.projectUpload.wrongPlatformVersionMetaFiles);
|
|
60
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
61
|
+
}
|
|
56
62
|
const tempFile = tmp_1.default.fileSync({ postfix: '.zip' });
|
|
57
63
|
logger_1.uiLogger.debug(en_1.lib.projectUpload.handleProjectUpload.compressing(tempFile.name));
|
|
58
64
|
const output = fs_extra_1.default.createWriteStream(tempFile.name);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PromptConfig, GenericPromptResponse, PromptWhen, PromptChoices } from '../../types/Prompts';
|
|
2
|
-
export declare const Separator: any;
|
|
3
2
|
export declare function promptUser<T extends GenericPromptResponse>(config: PromptConfig<T> | PromptConfig<T>[]): Promise<T>;
|
|
4
3
|
export declare function confirmPrompt(message: string, options?: {
|
|
5
4
|
defaultAnswer?: boolean;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Separator = void 0;
|
|
4
3
|
exports.promptUser = promptUser;
|
|
5
4
|
exports.confirmPrompt = confirmPrompt;
|
|
6
5
|
exports.listPrompt = listPrompt;
|
|
7
6
|
exports.inputPrompt = inputPrompt;
|
|
8
7
|
const inquirer = require('inquirer');
|
|
9
8
|
const promptModule = inquirer.createPromptModule();
|
|
10
|
-
exports.Separator = new inquirer.Separator();
|
|
11
9
|
function promptUser(config) {
|
|
12
10
|
return promptModule(config);
|
|
13
11
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.1-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.2.0",
|
|
8
|
+
"@hubspot/local-dev-lib": "3.7.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.2.2-beta.0",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.2",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.8.52",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/yargs": "^17.0.33",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
48
48
|
"@typescript-eslint/parser": "^8.11.0",
|
|
49
|
-
"axios": "^1.7.
|
|
49
|
+
"axios": "^1.7.4",
|
|
50
50
|
"eslint": "^8.56.0",
|
|
51
51
|
"eslint-plugin-import": "^2.31.0",
|
|
52
52
|
"husky": "^4.3.8",
|
package/types/Yargs.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export type StringArgType = Options & {
|
|
|
26
26
|
};
|
|
27
27
|
export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs & {
|
|
28
28
|
profile?: string;
|
|
29
|
+
testingAccount?: string | number;
|
|
30
|
+
projectAccount?: string | number;
|
|
29
31
|
};
|
|
30
32
|
export type TestingArgs = {
|
|
31
33
|
qa?: boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CommonArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
-
type CreateTestAccountArgs = CommonArgs & {
|
|
3
|
-
name: string;
|
|
4
|
-
tiers: string[];
|
|
5
|
-
};
|
|
6
|
-
declare const createTestAccountCommand: YargsCommandModule<unknown, CreateTestAccountArgs>;
|
|
7
|
-
export default createTestAccountCommand;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
4
|
-
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
5
|
-
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
6
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
7
|
-
const logger_1 = require("../../lib/ui/logger");
|
|
8
|
-
const command = 'create [name]';
|
|
9
|
-
const describe = 'Create a test account';
|
|
10
|
-
const hubs = {
|
|
11
|
-
MARKETING: 'marketingLevel',
|
|
12
|
-
OPS: 'opsLevel',
|
|
13
|
-
SERVICE: 'serviceLevel',
|
|
14
|
-
SALES: 'salesLevel',
|
|
15
|
-
CONTENT: 'contentLevel',
|
|
16
|
-
};
|
|
17
|
-
const TEST_ACCOUNT_TIERS = [
|
|
18
|
-
{ name: 'Marketing STARTER', value: 'MARKETING:STARTER' },
|
|
19
|
-
{ name: 'Marketing PRO', value: 'MARKETING:PRO' },
|
|
20
|
-
{ name: 'Marketing ENTERPRISE', value: 'MARKETING:ENTERPRISE' },
|
|
21
|
-
promptUtils_1.Separator,
|
|
22
|
-
{ name: 'Ops STARTER', value: 'OPS:STARTER' },
|
|
23
|
-
{ name: 'Ops PRO', value: 'OPS:PRO' },
|
|
24
|
-
{ name: 'Ops ENTERPRISE', value: 'OPS:ENTERPRISE' },
|
|
25
|
-
promptUtils_1.Separator,
|
|
26
|
-
{ name: 'Service STARTER', value: 'SERVICE:STARTER' },
|
|
27
|
-
{ name: 'Service PRO', value: 'SERVICE:PRO' },
|
|
28
|
-
{ name: 'Service ENTERPRISE', value: 'SERVICE:ENTERPRISE' },
|
|
29
|
-
promptUtils_1.Separator,
|
|
30
|
-
{ name: 'Sales STARTER', value: 'SALES:STARTER' },
|
|
31
|
-
{ name: 'Sales PRO', value: 'SALES:PRO' },
|
|
32
|
-
{ name: 'Sales ENTERPRISE', value: 'SALES:ENTERPRISE' },
|
|
33
|
-
promptUtils_1.Separator,
|
|
34
|
-
{ name: 'Content STARTER', value: 'CONTENT:STARTER' },
|
|
35
|
-
{ name: 'Content PRO', value: 'CONTENT:PRO' },
|
|
36
|
-
{ name: 'Content ENTERPRISE', value: 'CONTENT:ENTERPRISE' },
|
|
37
|
-
promptUtils_1.Separator,
|
|
38
|
-
];
|
|
39
|
-
async function handler(args) {
|
|
40
|
-
const { derivedAccountId, name, tiers } = args;
|
|
41
|
-
// trackCommandUsage('test-account-create', {}, derivedAccountId);
|
|
42
|
-
let accountName = name;
|
|
43
|
-
let accountLevelsArray = tiers;
|
|
44
|
-
if (!name) {
|
|
45
|
-
const namePromptResult = await (0, promptUtils_1.promptUser)({
|
|
46
|
-
name: 'accountName',
|
|
47
|
-
message: 'What is the name of the test account?',
|
|
48
|
-
type: 'input',
|
|
49
|
-
});
|
|
50
|
-
accountName = namePromptResult.accountName;
|
|
51
|
-
}
|
|
52
|
-
if (!accountLevelsArray) {
|
|
53
|
-
const accountLevelsPromptResult = await (0, promptUtils_1.promptUser)({
|
|
54
|
-
name: 'testAccountLevels',
|
|
55
|
-
message: '[--tiers] Which tiers should the test account have?',
|
|
56
|
-
type: 'checkbox',
|
|
57
|
-
choices: TEST_ACCOUNT_TIERS,
|
|
58
|
-
validate: choices => {
|
|
59
|
-
if (choices?.length > 1) {
|
|
60
|
-
const hubMap = {};
|
|
61
|
-
for (const choice of choices) {
|
|
62
|
-
const hub = choice.split(':')[0];
|
|
63
|
-
if (hubMap[hub]) {
|
|
64
|
-
return 'Cannot have more than one tier per hub';
|
|
65
|
-
}
|
|
66
|
-
hubMap[hub] = true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
accountLevelsArray = accountLevelsPromptResult.testAccountLevels;
|
|
73
|
-
}
|
|
74
|
-
const accountLevels = accountLevelsArray.reduce((acc, level) => {
|
|
75
|
-
const parts = level.split(':');
|
|
76
|
-
const hubName = hubs[parts[0]];
|
|
77
|
-
const hubTier = parts[1];
|
|
78
|
-
acc[hubName] = hubTier;
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
try {
|
|
82
|
-
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(derivedAccountId, accountName, true, accountLevels);
|
|
83
|
-
// @ts-expect-error - testPortalId is not typed
|
|
84
|
-
logger_1.uiLogger.log(`Test account created: ${data.testPortalId}`);
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
logger_1.uiLogger.error('Failed to create test account');
|
|
88
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
89
|
-
}
|
|
90
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
91
|
-
}
|
|
92
|
-
function createTestAccountBuilder(yargs) {
|
|
93
|
-
yargs.positional('name', {
|
|
94
|
-
type: 'string',
|
|
95
|
-
description: 'The name of the test account',
|
|
96
|
-
});
|
|
97
|
-
yargs.option('tiers', {
|
|
98
|
-
type: 'array',
|
|
99
|
-
description: 'The tiers of the test account',
|
|
100
|
-
});
|
|
101
|
-
yargs.example([
|
|
102
|
-
[
|
|
103
|
-
'$0 create my-account --tiers MARKETING:STARTER OPS:PRO',
|
|
104
|
-
'Create a test account with the name "my-account" and the tiers "Marketing - STARTER, OPS - PRO"',
|
|
105
|
-
],
|
|
106
|
-
]);
|
|
107
|
-
return yargs;
|
|
108
|
-
}
|
|
109
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(createTestAccountBuilder, command, describe, {
|
|
110
|
-
useGlobalOptions: true,
|
|
111
|
-
});
|
|
112
|
-
const createTestAccountCommand = {
|
|
113
|
-
command,
|
|
114
|
-
describe,
|
|
115
|
-
handler,
|
|
116
|
-
builder,
|
|
117
|
-
};
|
|
118
|
-
exports.default = createTestAccountCommand;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CommonArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
-
type DeleteTestAccountArgs = CommonArgs & {
|
|
3
|
-
testAccountId: number;
|
|
4
|
-
};
|
|
5
|
-
declare const deleteTestAccountCommand: YargsCommandModule<unknown, DeleteTestAccountArgs>;
|
|
6
|
-
export default deleteTestAccountCommand;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
4
|
-
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
5
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
6
|
-
const logger_1 = require("../../lib/ui/logger");
|
|
7
|
-
const command = 'delete <testAccountId>';
|
|
8
|
-
const describe = 'delete a test account';
|
|
9
|
-
async function handler(args) {
|
|
10
|
-
const { derivedAccountId, testAccountId } = args;
|
|
11
|
-
// trackCommandUsage('test-account-delete', {}, derivedAccountId);
|
|
12
|
-
try {
|
|
13
|
-
await (0, developerTestAccounts_1.deleteDeveloperTestAccount)(derivedAccountId, testAccountId, true);
|
|
14
|
-
logger_1.uiLogger.log(`Test account deleted: ${testAccountId}`);
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
logger_1.uiLogger.error('Failed to delete test account');
|
|
18
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
19
|
-
}
|
|
20
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
21
|
-
}
|
|
22
|
-
function deleteTestAccountBuilder(yargs) {
|
|
23
|
-
yargs.positional('testAccountId', {
|
|
24
|
-
type: 'number',
|
|
25
|
-
description: 'The id of the test account',
|
|
26
|
-
required: true,
|
|
27
|
-
});
|
|
28
|
-
yargs.example([
|
|
29
|
-
['$0 delete 1234567890', 'Delete a test account with the id "1234567890"'],
|
|
30
|
-
]);
|
|
31
|
-
return yargs;
|
|
32
|
-
}
|
|
33
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(deleteTestAccountBuilder, command, describe, {
|
|
34
|
-
useGlobalOptions: true,
|
|
35
|
-
});
|
|
36
|
-
const deleteTestAccountCommand = {
|
|
37
|
-
command,
|
|
38
|
-
describe,
|
|
39
|
-
handler,
|
|
40
|
-
builder,
|
|
41
|
-
};
|
|
42
|
-
exports.default = deleteTestAccountCommand;
|
package/commands/testAccount.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const create_1 = __importDefault(require("./testAccount/create"));
|
|
7
|
-
const delete_1 = __importDefault(require("./testAccount/delete"));
|
|
8
|
-
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
9
|
-
const command = ['test-account', 'test-accounts'];
|
|
10
|
-
const describe = 'Test account';
|
|
11
|
-
function secretBuilder(yargs) {
|
|
12
|
-
yargs
|
|
13
|
-
.command(create_1.default)
|
|
14
|
-
.command(delete_1.default)
|
|
15
|
-
.demandCommand(1, '');
|
|
16
|
-
return yargs;
|
|
17
|
-
}
|
|
18
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(secretBuilder, command, describe);
|
|
19
|
-
const testAccountCommand = {
|
|
20
|
-
command,
|
|
21
|
-
describe,
|
|
22
|
-
builder,
|
|
23
|
-
handler: () => { },
|
|
24
|
-
};
|
|
25
|
-
exports.default = testAccountCommand;
|
|
26
|
-
// TODO Remove this legacy export once we've migrated all commands to TS
|
|
27
|
-
module.exports = testAccountCommand;
|