@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.
Files changed (49) hide show
  1. package/bin/cli.js +96 -94
  2. package/commands/account.js +0 -2
  3. package/commands/app.js +0 -2
  4. package/commands/auth.js +0 -2
  5. package/commands/cms.js +0 -2
  6. package/commands/completion.js +0 -2
  7. package/commands/config.js +0 -2
  8. package/commands/create.js +0 -2
  9. package/commands/customObject.js +0 -2
  10. package/commands/doctor.js +0 -2
  11. package/commands/feedback.js +0 -2
  12. package/commands/filemanager.js +0 -2
  13. package/commands/function.js +0 -2
  14. package/commands/hubdb.js +0 -2
  15. package/commands/init.js +0 -2
  16. package/commands/lint.js +0 -2
  17. package/commands/list.js +0 -2
  18. package/commands/mv.js +0 -2
  19. package/commands/open.js +0 -2
  20. package/commands/project/dev/deprecatedFlow.d.ts +8 -2
  21. package/commands/project/dev/deprecatedFlow.js +9 -1
  22. package/commands/project/dev/index.js +59 -34
  23. package/commands/project/dev/unifiedFlow.d.ts +10 -2
  24. package/commands/project/dev/unifiedFlow.js +27 -41
  25. package/commands/project.js +0 -2
  26. package/commands/remove.js +0 -2
  27. package/commands/sandbox.js +0 -2
  28. package/commands/secret.js +0 -2
  29. package/commands/theme.js +0 -2
  30. package/commands/upload.js +0 -2
  31. package/lang/en.d.ts +14 -3
  32. package/lang/en.js +14 -3
  33. package/lib/accountTypes.js +1 -3
  34. package/lib/commonOpts.d.ts +1 -3
  35. package/lib/commonOpts.js +1 -1
  36. package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
  37. package/lib/middleware/fireAlarmMiddleware.js +5 -3
  38. package/lib/projects/localDev/AppDevModeInterface.js +0 -6
  39. package/lib/projects/upload.js +6 -0
  40. package/lib/prompts/promptUtils.d.ts +0 -1
  41. package/lib/prompts/promptUtils.js +0 -2
  42. package/package.json +4 -4
  43. package/types/Yargs.d.ts +2 -0
  44. package/commands/testAccount/create.d.ts +0 -7
  45. package/commands/testAccount/create.js +0 -118
  46. package/commands/testAccount/delete.d.ts +0 -6
  47. package/commands/testAccount/delete.js +0 -42
  48. package/commands/testAccount.d.ts +0 -3
  49. 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
- const yargs = require('yargs');
4
- const { logger } = require('@hubspot/local-dev-lib/logger');
5
- const { logError } = require('../lib/errorHandlers/index');
6
- const { setLogLevel, getCommandName } = require('../lib/commonOpts');
7
- const { trackHelpUsage, trackConvertFieldsUsage, } = require('../lib/usageTracking');
8
- const { EXIT_CODES } = require('../lib/enums/exitCodes');
9
- const { loadConfigMiddleware, injectAccountIdMiddleware, validateAccountOptions, handleDeprecatedEnvVariables, } = require('../lib/middleware/configMiddleware');
10
- const { autoUpdateCLI } = require('../lib/middleware/autoUpdateMiddleware');
11
- const { checkAndWarnGitInclusionMiddleware, } = require('../lib/middleware/gitMiddleware');
12
- const { performChecks } = require('../lib/middleware/yargsChecksMiddleware');
13
- const { setRequestHeaders } = require('../lib/middleware/requestMiddleware');
14
- const { checkFireAlarms } = require('../lib/middleware/fireAlarmMiddleware');
15
- const removeCommand = require('../commands/remove');
16
- const initCommand = require('../commands/init');
17
- const logsCommand = require('../commands/logs');
18
- const lintCommand = require('../commands/lint');
19
- const hubdbCommand = require('../commands/hubdb');
20
- const watchCommand = require('../commands/watch');
21
- const authCommand = require('../commands/auth');
22
- const uploadCommand = require('../commands/upload');
23
- const createCommand = require('../commands/create');
24
- const fetchCommand = require('../commands/fetch');
25
- const filemanagerCommand = require('../commands/filemanager');
26
- const secretCommands = require('../commands/secret');
27
- const customObjectCommand = require('../commands/customObject');
28
- const functionCommands = require('../commands/function');
29
- const listCommand = require('../commands/list');
30
- const openCommand = require('../commands/open');
31
- const mvCommand = require('../commands/mv');
32
- const projectCommands = require('../commands/project');
33
- const themeCommand = require('../commands/theme');
34
- const moduleCommand = require('../commands/module');
35
- const configCommand = require('../commands/config');
36
- const accountCommands = require('../commands/account');
37
- const sandboxesCommand = require('../commands/sandbox');
38
- const cmsCommand = require('../commands/cms');
39
- const feedbackCommand = require('../commands/feedback');
40
- const doctorCommand = require('../commands/doctor');
41
- const completionCommand = require('../commands/completion');
42
- const appCommand = require('../commands/app');
43
- const testAccountCommand = require('../commands/testAccount');
44
- const getTerminalWidth = () => {
45
- const width = yargs.terminalWidth();
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
- const handleFailure = (msg, err, yargs) => {
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 = yargs
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(authCommand)
95
- .command(initCommand)
96
- .command(logsCommand)
97
- .command(cmsCommand)
98
- .command(lintCommand)
99
- .command(hubdbCommand)
100
- .command(watchCommand)
101
- .command(removeCommand)
102
- .command(uploadCommand)
103
- .command(createCommand)
104
- .command(fetchCommand)
105
- .command(filemanagerCommand)
106
- .command(secretCommands)
107
- .command(customObjectCommand)
108
- .command(functionCommands)
109
- .command(listCommand)
110
- .command(openCommand)
111
- .command(mvCommand)
112
- .command(projectCommands)
113
- .command(themeCommand)
114
- .command(moduleCommand)
115
- .command(configCommand)
116
- .command(accountCommands)
117
- .command(sandboxesCommand)
118
- .command(feedbackCommand)
119
- .command(doctorCommand)
120
- .command(completionCommand)
121
- .command(appCommand)
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
  }
@@ -38,5 +38,3 @@ const accountCommand = {
38
38
  handler: () => { },
39
39
  };
40
40
  exports.default = accountCommand;
41
- // TODO Remove this legacy export once we've migrated all commands to TS
42
- module.exports = accountCommand;
package/commands/app.js CHANGED
@@ -21,5 +21,3 @@ const appCommand = {
21
21
  handler: () => { },
22
22
  };
23
23
  exports.default = appCommand;
24
- // TODO Remove this legacy export once we've migrated all commands to TS
25
- module.exports = appCommand;
package/commands/auth.js CHANGED
@@ -172,5 +172,3 @@ const authCommand = {
172
172
  builder,
173
173
  };
174
174
  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
@@ -26,5 +26,3 @@ const cmsCommand = {
26
26
  handler: () => { },
27
27
  };
28
28
  exports.default = cmsCommand;
29
- // TODO Remove this legacy export once we've migrated all commands to TS
30
- module.exports = cmsCommand;
@@ -30,5 +30,3 @@ const completionCommand = {
30
30
  builder,
31
31
  };
32
32
  exports.default = completionCommand;
33
- // TODO Remove this legacy export once we've migrated all commands to TS
34
- module.exports = completionCommand;
@@ -21,5 +21,3 @@ const configCommand = {
21
21
  handler: () => { },
22
22
  };
23
23
  exports.default = configCommand;
24
- // TODO Remove this legacy export once we've migrated all commands to TS
25
- module.exports = configCommand;
@@ -91,5 +91,3 @@ const createCommand = {
91
91
  handler,
92
92
  };
93
93
  exports.default = createCommand;
94
- // TODO Remove this legacy export once we've migrated all commands to TS
95
- module.exports = createCommand;
@@ -29,5 +29,3 @@ const customObjectCommand = {
29
29
  handler: () => { },
30
30
  };
31
31
  exports.default = customObjectCommand;
32
- // TODO Remove this legacy export once we've migrated all commands to TS
33
- module.exports = customObjectCommand;
@@ -68,5 +68,3 @@ const doctorCommand = {
68
68
  builder,
69
69
  };
70
70
  exports.default = doctorCommand;
71
- // TODO Remove this after cli.ts is ported to TS
72
- module.exports = doctorCommand;
@@ -40,5 +40,3 @@ const feedbackCommand = {
40
40
  builder,
41
41
  };
42
42
  exports.default = feedbackCommand;
43
- // TODO remove this after cli.ts is ported to TS
44
- module.exports = feedbackCommand;
@@ -21,5 +21,3 @@ const fileManagerCommand = {
21
21
  handler: () => { },
22
22
  };
23
23
  exports.default = fileManagerCommand;
24
- // TODO Remove this legacy export once we've migrated all commands to TS
25
- module.exports = fileManagerCommand;
@@ -25,5 +25,3 @@ const functionCommand = {
25
25
  handler: () => { },
26
26
  };
27
27
  exports.default = functionCommand;
28
- // TODO Remove this legacy export once we've migrated all commands to TS
29
- module.exports = functionCommand;
package/commands/hubdb.js CHANGED
@@ -29,5 +29,3 @@ const hubdbCommand = {
29
29
  handler: () => { },
30
30
  };
31
31
  exports.default = hubdbCommand;
32
- // TODO Remove this legacy export once we've migrated all commands to TS
33
- module.exports = hubdbCommand;
package/commands/init.js CHANGED
@@ -188,5 +188,3 @@ const initCommand = {
188
188
  builder,
189
189
  };
190
190
  exports.default = initCommand;
191
- // TODO Remove this legacy export once we've migrated all commands to TS
192
- module.exports = initCommand;
package/commands/lint.js CHANGED
@@ -83,5 +83,3 @@ const lintCommand = {
83
83
  builder,
84
84
  };
85
85
  exports.default = lintCommand;
86
- // TODO Remove this after cli.ts is ported to TS
87
- module.exports = lintCommand;
package/commands/list.js CHANGED
@@ -101,5 +101,3 @@ const cmsListCommand = {
101
101
  builder,
102
102
  };
103
103
  exports.default = cmsListCommand;
104
- // TODO Remove this legacy export once we've migrated all commands to TS
105
- module.exports = cmsListCommand;
package/commands/mv.js CHANGED
@@ -72,5 +72,3 @@ const cmsMvCommand = {
72
72
  builder,
73
73
  };
74
74
  exports.default = cmsMvCommand;
75
- // TODO Remove this legacy export once we've migrated all commands to TS
76
- module.exports = cmsMvCommand;
package/commands/open.js CHANGED
@@ -68,5 +68,3 @@ const openCommand = {
68
68
  builder,
69
69
  };
70
70
  exports.default = openCommand;
71
- // TODO Remove this legacy export once we've migrated all commands to TS
72
- module.exports = openCommand;
@@ -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
- export declare function deprecatedProjectDevFlow(args: ArgumentsCamelCase<ProjectDevArgs>, accountConfig: CLIAccount, projectConfig: ProjectConfig, projectDir: string): Promise<void>;
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, accountConfig, projectConfig, projectDir) {
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)((0, lang_1.i18n)(`commands.project.subcommands.dev.describe`), false);
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.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noProjectConfig`, {
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
- let targetAccountId = providedAccountId;
38
+ validateAccountFlags(testingAccount, projectAccount, providedAccountId, useV3);
39
+ let targetProjectAccountId = (projectAccount && (0, config_1.getAccountId)(projectAccount)) ||
40
+ (providedAccountId && derivedAccountId);
30
41
  let profile;
31
- if (!targetAccountId && (0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion)) {
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
- targetAccountId = profile.accountId;
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 (!targetAccountId) {
48
- // The user is not using profiles, so we can use the derived accountId
49
- targetAccountId = derivedAccountId;
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
- await (0, unifiedFlow_1.unifiedProjectDevFlow)(args, accountConfig, projectConfig, projectDir, profile);
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)(args, accountConfig, projectConfig, projectDir);
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: (0, lang_1.i18n)(`commands.project.subcommands.dev.options.profile`),
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
- export declare function unifiedProjectDevFlow(args: ArgumentsCamelCase<ProjectDevArgs>, accountConfig: CLIAccount, projectConfig: ProjectConfig, projectDir: string, profileConfig?: HsProfileFile): Promise<void>;
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 lang_1 = require("../../../lib/lang");
28
- // import LocalDevWebsocketServer from '../../../lib/projects/localDev/LocalDevWebsocketServer';
29
- async function unifiedProjectDevFlow(args, accountConfig, projectConfig, projectDir, profileConfig) {
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.logger.debug(util_1.default.inspect(projectNodes, false, null, true));
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.logger.error(e.toString());
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.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noRunnableComponents`, {
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
- // @TODO Validate component types (i.e. previously you could not have both private and public apps)
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)(accountConfig);
59
+ const accountIsCombined = await (0, accountTypes_1.isUnifiedAccount)(targetProjectAccountConfig);
66
60
  if (!accountIsCombined && !profileConfig) {
67
- logger_1.logger.log('');
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 = null;
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 (args.providedAccountId) {
79
- // By pass the prompt if the user explicitly provides an --account flag.
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.logger.log((0, lang_1.i18n)(`commands.project.subcommands.dev.logs.accountTypeInformation`));
86
- logger_1.logger.log('');
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.logger.log('');
92
- const accountType = await (0, helpers_1.selectAccountTypePrompt)(accountConfig);
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, accountConfig);
95
- targetTestingAccountId = devAccountPromptResponse.targetAccountId;
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, accountConfig, env);
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, accountConfig);
108
- targetTestingAccountId = sandboxAccountPromptResponse.targetAccountId;
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;
@@ -51,5 +51,3 @@ const projectCommand = {
51
51
  handler: () => { },
52
52
  };
53
53
  exports.default = projectCommand;
54
- // TODO Remove this legacy export once we've migrated all commands to TS
55
- module.exports = projectCommand;
@@ -49,5 +49,3 @@ const cmsRemoveCommand = {
49
49
  builder,
50
50
  };
51
51
  exports.default = cmsRemoveCommand;
52
- // TODO Remove this legacy export once we've migrated all commands to TS
53
- module.exports = cmsRemoveCommand;
@@ -22,5 +22,3 @@ const sandboxCommand = {
22
22
  handler: () => { },
23
23
  };
24
24
  exports.default = sandboxCommand;
25
- // TODO Remove this legacy export once we've migrated all commands to TS
26
- module.exports = sandboxCommand;
@@ -28,5 +28,3 @@ const secretCommand = {
28
28
  handler: () => { },
29
29
  };
30
30
  exports.default = secretCommand;
31
- // TODO Remove this legacy export once we've migrated all commands to TS
32
- module.exports = secretCommand;
package/commands/theme.js CHANGED
@@ -26,5 +26,3 @@ const themeCommand = {
26
26
  handler: () => { },
27
27
  };
28
28
  exports.default = themeCommand;
29
- // TODO Remove this legacy export once we've migrated all commands to TS
30
- module.exports = themeCommand;
@@ -252,5 +252,3 @@ const uploadCommand = {
252
252
  builder,
253
253
  };
254
254
  exports.default = uploadCommand;
255
- // TODO remove this after cli.ts is ported to TS
256
- module.exports = uploadCommand;
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: `Visit our ${string} to learn more.`;
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: string, authCommand: string) => string;
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: (command: string) => string;
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: `Visit our ${(0, ui_1.uiLink)('docs on Developer Test and Sandbox accounts', 'https://developers.hubspot.com/docs/getting-started/account-types')} to learn more.`,
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, authCommand) => `An error occurred while reading account ${accountId} from your config. Run ${chalk_1.default.bold(authCommand)} to re-auth this account.`,
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: (command) => `No supported components were found in this project. Run ${chalk_1.default.bold(command)} to see a list of available components and add one to your project.`,
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}`,
@@ -39,7 +39,5 @@ async function isUnifiedAccount(account) {
39
39
  if (!accountId) {
40
40
  return false;
41
41
  }
42
- const isUngatedForUnifiedApps = await (0, hasFeature_1.hasFeature)(accountId, constants_1.FEATURES.UNIFIED_APPS);
43
- return ((isStandardAccount(account) || isAppDeveloperAccount(account)) &&
44
- isUngatedForUnifiedApps);
42
+ return (0, hasFeature_1.hasFeature)(accountId, constants_1.FEATURES.UNIFIED_APPS);
45
43
  }
@@ -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
@@ -1,4 +1,4 @@
1
1
  import { Arguments } from 'yargs';
2
- export declare function checkFireAlarms(args: Arguments<{
3
- derivedAccountId: number;
2
+ export declare function checkFireAlarms(argv: Arguments<{
3
+ derivedAccountId?: number;
4
4
  }>): Promise<void>;
@@ -112,10 +112,12 @@ async function logFireAlarms(accountId, command, version) {
112
112
  });
113
113
  }
114
114
  }
115
- async function checkFireAlarms(args) {
116
- const { derivedAccountId } = args;
115
+ async function checkFireAlarms(argv) {
116
+ const { derivedAccountId } = argv;
117
117
  try {
118
- await logFireAlarms(derivedAccountId, args._.join(' '), package_json_1.default.version);
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) {
@@ -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.0-experimental.3",
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": "0.4.0-experimental.1",
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.2",
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;
@@ -1,3 +0,0 @@
1
- import { YargsCommandModuleBucket } from '../types/Yargs';
2
- declare const testAccountCommand: YargsCommandModuleBucket;
3
- export default testAccountCommand;
@@ -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;