@hubspot/cli 7.3.0-experimental.2 → 7.3.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 (42) hide show
  1. package/bin/cli.js +25 -83
  2. package/commands/account/clean.js +9 -10
  3. package/commands/account/info.js +9 -11
  4. package/commands/account/list.js +7 -8
  5. package/commands/account/remove.js +8 -9
  6. package/commands/account/rename.js +4 -5
  7. package/commands/account/use.js +7 -8
  8. package/commands/cms/convertFields.js +5 -6
  9. package/commands/cms/getReactModule.js +7 -8
  10. package/commands/cms/lighthouseScore.js +15 -16
  11. package/commands/config/set.js +6 -7
  12. package/commands/create/api-sample.js +6 -7
  13. package/commands/create/module.js +1 -2
  14. package/commands/create/template.js +1 -2
  15. package/commands/customObject/create.js +8 -9
  16. package/commands/customObject/schema/create.js +5 -6
  17. package/commands/customObject/schema/delete.js +9 -10
  18. package/commands/customObject/schema/fetch-all.js +7 -8
  19. package/commands/customObject/schema/fetch.js +9 -10
  20. package/commands/customObject/schema/list.js +2 -3
  21. package/commands/customObject/schema/update.js +7 -8
  22. package/commands/customObject/schema.js +1 -2
  23. package/commands/filemanager/fetch.js +5 -6
  24. package/commands/filemanager/upload.js +12 -13
  25. package/commands/function/deploy.js +9 -10
  26. package/commands/function/list.js +4 -5
  27. package/commands/function/server.js +7 -8
  28. package/commands/project/create.js +1 -0
  29. package/lang/en.js +6 -1
  30. package/lang/en.lyaml +4 -0
  31. package/lib/DevServerManagerV2.d.ts +1 -2
  32. package/lib/DevServerManagerV2.js +1 -2
  33. package/lib/LocalDevManagerV2.js +10 -15
  34. package/lib/dependencyManagement.d.ts +5 -0
  35. package/lib/dependencyManagement.js +47 -22
  36. package/lib/doctor/Doctor.js +1 -2
  37. package/lib/projects/structure.d.ts +1 -2
  38. package/lib/projects/structure.js +0 -4
  39. package/package.json +3 -3
  40. package/types/ProjectComponents.d.ts +0 -15
  41. package/lib/npm.d.ts +0 -9
  42. package/lib/npm.js +0 -36
@@ -19,9 +19,8 @@ const commonOpts_1 = require("../../lib/commonOpts");
19
19
  const usageTracking_1 = require("../../lib/usageTracking");
20
20
  const lang_1 = require("../../lib/lang");
21
21
  const exitCodes_1 = require("../../lib/enums/exitCodes");
22
- const i18nKey = 'commands.filemanager.subcommands.upload';
23
22
  exports.command = 'upload <src> <dest>';
24
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
23
+ exports.describe = (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.describe`);
25
24
  async function handler(args) {
26
25
  const { src, dest, derivedAccountId } = args;
27
26
  const absoluteSrcPath = path_1.default.resolve((0, path_2.getCwd)(), src);
@@ -29,20 +28,20 @@ async function handler(args) {
29
28
  try {
30
29
  stats = fs_1.default.statSync(absoluteSrcPath);
31
30
  if (!stats.isFile() && !stats.isDirectory()) {
32
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
31
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.invalidPath`, {
33
32
  path: src,
34
33
  }));
35
34
  return;
36
35
  }
37
36
  }
38
37
  catch (e) {
39
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
38
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.invalidPath`, {
40
39
  path: src,
41
40
  }));
42
41
  return;
43
42
  }
44
43
  if (!dest) {
45
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.destinationRequired`));
44
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.destinationRequired`));
46
45
  return;
47
46
  }
48
47
  const normalizedDest = (0, path_2.convertToUnixPath)(dest);
@@ -54,21 +53,21 @@ async function handler(args) {
54
53
  }
55
54
  if (stats.isFile()) {
56
55
  if ((0, ignoreRules_1.shouldIgnoreFile)(absoluteSrcPath)) {
57
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.fileIgnored`, {
56
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.fileIgnored`, {
58
57
  path: src,
59
58
  }));
60
59
  return;
61
60
  }
62
61
  (0, fileManager_2.uploadFile)(derivedAccountId, absoluteSrcPath, normalizedDest)
63
62
  .then(() => {
64
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.upload`, {
63
+ logger_1.logger.success((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.success.upload`, {
65
64
  accountId: derivedAccountId,
66
65
  dest: normalizedDest,
67
66
  src,
68
67
  }));
69
68
  })
70
69
  .catch(error => {
71
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.upload`, {
70
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.upload`, {
72
71
  dest: normalizedDest,
73
72
  src,
74
73
  }));
@@ -80,19 +79,19 @@ async function handler(args) {
80
79
  });
81
80
  }
82
81
  else {
83
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.uploading`, {
82
+ logger_1.logger.log((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.logs.uploading`, {
84
83
  accountId: derivedAccountId,
85
84
  dest,
86
85
  src,
87
86
  }));
88
87
  (0, fileManager_1.uploadFolder)(derivedAccountId, absoluteSrcPath, dest)
89
88
  .then(() => {
90
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.uploadComplete`, {
89
+ logger_1.logger.success((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.success.uploadComplete`, {
91
90
  dest,
92
91
  }));
93
92
  })
94
93
  .catch(error => {
95
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.uploadingFailed`));
94
+ logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.uploadingFailed`));
96
95
  (0, index_1.logError)(error, {
97
96
  accountId: derivedAccountId,
98
97
  });
@@ -105,11 +104,11 @@ function builder(yargs) {
105
104
  (0, commonOpts_1.addAccountOptions)(yargs);
106
105
  (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
107
106
  yargs.positional('src', {
108
- describe: (0, lang_1.i18n)(`${i18nKey}.positionals.src.describe`),
107
+ describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.positionals.src.describe`),
109
108
  type: 'string',
110
109
  });
111
110
  yargs.positional('dest', {
112
- describe: (0, lang_1.i18n)(`${i18nKey}.positionals.dest.describe`),
111
+ describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.positionals.dest.describe`),
113
112
  type: 'string',
114
113
  });
115
114
  return yargs;
@@ -12,7 +12,6 @@ const { buildPackage, getBuildStatus, } = require('@hubspot/local-dev-lib/api/fu
12
12
  const { outputBuildLog } = require('../../lib/serverlessLogs');
13
13
  const { i18n } = require('../../lib/lang');
14
14
  const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
15
- const i18nKey = 'commands.function.subcommands.deploy';
16
15
  exports.command = 'deploy <path>';
17
16
  exports.describe = false;
18
17
  exports.handler = async (options) => {
@@ -21,17 +20,17 @@ exports.handler = async (options) => {
21
20
  trackCommandUsage('functions-deploy', null, derivedAccountId);
22
21
  if (!splitFunctionPath.length ||
23
22
  splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
24
- logger.error(i18n(`${i18nKey}.errors.notFunctionsFolder`, {
23
+ logger.error(i18n('commands.function.subcommands.deploy.errors.notFunctionsFolder', {
25
24
  functionPath,
26
25
  }));
27
26
  return;
28
27
  }
29
- logger.debug(i18n(`${i18nKey}.debug.startingBuildAndDeploy`, {
28
+ logger.debug(i18n('commands.function.subcommands.deploy.debug.startingBuildAndDeploy', {
30
29
  functionPath,
31
30
  }));
32
31
  SpinniesManager.init();
33
32
  SpinniesManager.add('loading', {
34
- text: i18n(`${i18nKey}.loading`, {
33
+ text: i18n('commands.function.subcommands.deploy.loading', {
35
34
  account: uiAccountDescription(derivedAccountId),
36
35
  functionPath,
37
36
  }),
@@ -42,7 +41,7 @@ exports.handler = async (options) => {
42
41
  const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
43
42
  SpinniesManager.succeed('loading');
44
43
  await outputBuildLog(successResp.cdnUrl);
45
- logger.success(i18n(`${i18nKey}.success.deployed`, {
44
+ logger.success(i18n('commands.function.subcommands.deploy.success.deployed', {
46
45
  accountId: derivedAccountId,
47
46
  buildTimeSeconds,
48
47
  functionPath,
@@ -50,19 +49,19 @@ exports.handler = async (options) => {
50
49
  }
51
50
  catch (e) {
52
51
  SpinniesManager.fail('loading', {
53
- text: i18n(`${i18nKey}.loadingFailed`, {
52
+ text: i18n('commands.function.subcommands.deploy.loadingFailed', {
54
53
  account: uiAccountDescription(derivedAccountId),
55
54
  functionPath,
56
55
  }),
57
56
  });
58
57
  if (isHubSpotHttpError(e) && e.status === 404) {
59
- logger.error(i18n(`${i18nKey}.errors.noPackageJson`, {
58
+ logger.error(i18n('commands.function.subcommands.deploy.errors.noPackageJson', {
60
59
  functionPath,
61
60
  }));
62
61
  }
63
62
  else if (e.status === 'ERROR') {
64
63
  await outputBuildLog(e.cdnUrl);
65
- logger.error(i18n(`${i18nKey}.errors.buildError`, {
64
+ logger.error(i18n('commands.function.subcommands.deploy.errors.buildError', {
66
65
  details: e.errorReason,
67
66
  }));
68
67
  }
@@ -76,13 +75,13 @@ exports.handler = async (options) => {
76
75
  };
77
76
  exports.builder = yargs => {
78
77
  yargs.positional('path', {
79
- describe: i18n(`${i18nKey}.positionals.path.describe`),
78
+ describe: i18n('commands.function.subcommands.deploy.positionals.path.describe'),
80
79
  type: 'string',
81
80
  });
82
81
  yargs.example([
83
82
  [
84
83
  '$0 functions deploy myFunctionFolder.functions',
85
- i18n(`${i18nKey}.examples.default`),
84
+ i18n('commands.function.subcommands.deploy.examples.default'),
86
85
  ],
87
86
  ]);
88
87
  addConfigOptions(yargs);
@@ -9,20 +9,19 @@ const { getTableContents, getTableHeader } = require('../../lib/ui/table');
9
9
  const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
10
10
  const { trackCommandUsage } = require('../../lib/usageTracking');
11
11
  const { i18n } = require('../../lib/lang');
12
- const i18nKey = 'commands.function.subcommands.list';
13
12
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
14
13
  exports.command = ['list', 'ls'];
15
- exports.describe = i18n(`${i18nKey}.describe`);
14
+ exports.describe = i18n('commands.function.subcommands.list.describe');
16
15
  exports.handler = async (options) => {
17
16
  const { derivedAccountId } = options;
18
17
  trackCommandUsage('functions-list', null, derivedAccountId);
19
- logger.debug(i18n(`${i18nKey}.debug.gettingFunctions`));
18
+ logger.debug(i18n('commands.function.subcommands.list.debug.gettingFunctions'));
20
19
  const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
21
20
  logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
22
21
  process.exit(EXIT_CODES.SUCCESS);
23
22
  });
24
23
  if (!routesResp.objects.length) {
25
- return logger.info(i18n(`${i18nKey}.info.noFunctions`));
24
+ return logger.info(i18n('commands.function.subcommands.list.info.noFunctions'));
26
25
  }
27
26
  if (options.json) {
28
27
  return logger.log(routesResp.objects);
@@ -46,7 +45,7 @@ exports.builder = yargs => {
46
45
  addUseEnvironmentOptions(yargs);
47
46
  yargs.options({
48
47
  json: {
49
- describe: i18n(`${i18nKey}.options.json.describe`),
48
+ describe: i18n('commands.function.subcommands.list.options.json.describe'),
50
49
  type: 'boolean',
51
50
  },
52
51
  });
@@ -6,13 +6,12 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
6
6
  const { logger } = require('@hubspot/local-dev-lib/logger');
7
7
  const { start: startTestServer } = require('@hubspot/serverless-dev-runtime');
8
8
  const { i18n } = require('../../lib/lang');
9
- const i18nKey = 'commands.function.subcommands.server';
10
9
  exports.command = 'server <path>';
11
10
  exports.describe = false;
12
11
  exports.handler = async (options) => {
13
12
  const { path: functionPath, derivedAccountId } = options;
14
13
  trackCommandUsage('functions-server', null, derivedAccountId);
15
- logger.debug(i18n(`${i18nKey}.debug.startingServer`, {
14
+ logger.debug(i18n('commands.function.subcommands.server.debug.startingServer', {
16
15
  functionPath,
17
16
  }));
18
17
  startTestServer({
@@ -22,33 +21,33 @@ exports.handler = async (options) => {
22
21
  };
23
22
  exports.builder = yargs => {
24
23
  yargs.positional('path', {
25
- describe: i18n(`${i18nKey}.positionals.path.describe`),
24
+ describe: i18n('commands.function.subcommands.server.positionals.path.describe'),
26
25
  type: 'string',
27
26
  });
28
27
  yargs.option('port', {
29
- describe: i18n(`${i18nKey}.options.port.describe`),
28
+ describe: i18n('commands.function.subcommands.server.options.port.describe'),
30
29
  type: 'string',
31
30
  default: 5432,
32
31
  });
33
32
  yargs.option('contact', {
34
- describe: i18n(`${i18nKey}.options.contact.describe`),
33
+ describe: i18n('commands.function.subcommands.server.options.contact.describe'),
35
34
  type: 'boolean',
36
35
  default: true,
37
36
  });
38
37
  yargs.option('watch', {
39
- describe: i18n(`${i18nKey}.options.watch.describe`),
38
+ describe: i18n('commands.function.subcommands.server.options.watch.describe'),
40
39
  type: 'boolean',
41
40
  default: true,
42
41
  });
43
42
  yargs.option('log-output', {
44
- describe: i18n(`${i18nKey}.options.logOutput.describe`),
43
+ describe: i18n('commands.function.subcommands.server.options.logOutput.describe'),
45
44
  type: 'boolean',
46
45
  default: false,
47
46
  });
48
47
  yargs.example([
49
48
  [
50
49
  '$0 functions server ./tmp/myFunctionFolder.functions',
51
- i18n(`${i18nKey}.examples.default`),
50
+ i18n('commands.function.subcommands.server.examples.default'),
52
51
  ],
53
52
  ]);
54
53
  addConfigOptions(yargs);
@@ -87,6 +87,7 @@ exports.handler = async (options) => {
87
87
  'projectCommandTip',
88
88
  'projectUploadCommand',
89
89
  'projectDevCommand',
90
+ 'projectInstallDepsCommand',
90
91
  'projectHelpCommand',
91
92
  'feedbackCommand',
92
93
  'sampleProjects',
package/lang/en.js CHANGED
@@ -2841,7 +2841,7 @@ export const lib = {
2841
2841
  disabledUrlText: 'See all HubSpot CLI commands here.',
2842
2842
  featureHighlight: {
2843
2843
  defaultTitle: "What's next?",
2844
- commandKeys: {
2844
+ featureKeys: {
2845
2845
  accountOption: {
2846
2846
  command: '--account',
2847
2847
  message: command =>
@@ -2895,6 +2895,11 @@ export const lib = {
2895
2895
  message: command =>
2896
2896
  `Run ${command} to set up your test environment and start local development`,
2897
2897
  },
2898
+ projectInstallDepsCommand: {
2899
+ command: 'hs project install-deps',
2900
+ message: command =>
2901
+ `Run ${command} to install dependencies for your project components`,
2902
+ },
2898
2903
  sampleProjects: {
2899
2904
  linkText: "HubSpot's sample projects",
2900
2905
  url: 'https://developers.hubspot.com/docs/platform/sample-projects?utm_source=cli&utm_content=project_create_whats_next',
package/lang/en.lyaml CHANGED
@@ -1077,6 +1077,7 @@ en:
1077
1077
  missingComponents: "Couldn't find the following components in the deployed build for this project: {{#bold}}'{{ missingComponents }}'{{/bold}}. This may cause issues in local development."
1078
1078
  defaultWarning: "{{#bold}}Changing project configuration requires a new project build.{{/bold}}"
1079
1079
  defaultPublicAppWarning: "{{#bold}}Changing project configuration requires a new project build.{{/bold}}\n\nThis will affect your public app's {{#bold}}{{ installCount }} existing {{ installText }}{{/bold}}. If your app has users in production, we strongly recommend creating a copy of this app to test your changes before proceding."
1080
+ defaultMarketplaceAppWarning: "{{#bold}}Changing project configuration requires creating a new project build.{{/bold}}\n\nYour marketplace app is currently installed in {{#bold}}{{ installCount }} {{ accountText }}{{/bold}}. Any uploaded changes will impact your app's users. We strongly recommend creating a copy of this app to test your changes before proceding."
1080
1081
  header: "{{ warning }} To reflect these changes and continue testing:"
1081
1082
  stopDev: " * Stop {{ command }}"
1082
1083
  runUpload: " * Run {{ command }}"
@@ -1212,6 +1213,9 @@ en:
1212
1213
  projectDevCommand:
1213
1214
  command: "hs project dev"
1214
1215
  message: "Run {{ command }} to set up your test environment and start local development"
1216
+ projectInstallDepsCommand:
1217
+ command: "hs project install-deps"
1218
+ message: "Run {{ command }} to install dependencies for your project components"
1215
1219
  projectCommandTip:
1216
1220
  message: "Tip: All project commands must be run from within a project directory"
1217
1221
  sampleProjects:
@@ -12,11 +12,10 @@ declare class DevServerManagerV2 {
12
12
  private devServers;
13
13
  constructor();
14
14
  iterateDevServers(callback: (serverInterface: DevServerInterface) => Promise<void>): Promise<void>;
15
- setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }: {
15
+ setup({ projectNodes, accountId, setActiveApp, }: {
16
16
  projectNodes: {
17
17
  [key: string]: IntermediateRepresentationNodeLocalDev;
18
18
  };
19
- onUploadRequired: () => void;
20
19
  accountId: number;
21
20
  setActiveApp: (appUid: string | undefined) => Promise<void>;
22
21
  }): Promise<void>;
@@ -20,7 +20,7 @@ class DevServerManagerV2 {
20
20
  async iterateDevServers(callback) {
21
21
  await Promise.all(this.devServers.map(devServer => callback(devServer)));
22
22
  }
23
- async setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }) {
23
+ async setup({ projectNodes, accountId, setActiveApp, }) {
24
24
  let env;
25
25
  const accountConfig = (0, config_1.getAccountConfig)(accountId);
26
26
  if (accountConfig) {
@@ -31,7 +31,6 @@ class DevServerManagerV2 {
31
31
  if (serverInterface.setup) {
32
32
  await serverInterface.setup({
33
33
  components: projectNodes,
34
- onUploadRequired,
35
34
  promptUser: promptUtils_1.promptUser,
36
35
  logger: logger_1.logger,
37
36
  urls: {
@@ -10,6 +10,7 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
10
10
  const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
11
11
  const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
12
12
  const config_1 = require("@hubspot/local-dev-lib/config");
13
+ const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
13
14
  const constants_1 = require("./constants");
14
15
  const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
15
16
  const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
@@ -212,16 +213,13 @@ class LocalDevManagerV2 {
212
213
  : (0, ui_1.uiCommandReference)('hs project upload');
213
214
  }
214
215
  logUploadWarning(reason) {
215
- let warning;
216
- if (reason) {
217
- warning = reason;
218
- }
219
- else {
216
+ let warning = reason;
217
+ if (!warning) {
220
218
  warning =
221
219
  this.publicAppActiveInstalls && this.publicAppActiveInstalls > 0
222
- ? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultPublicAppWarning`, {
220
+ ? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultMarketplaceAppWarning`, {
223
221
  installCount: this.publicAppActiveInstalls,
224
- installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
222
+ accountText: this.publicAppActiveInstalls === 1 ? 'account' : 'accounts',
225
223
  })
226
224
  : (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultWarning`);
227
225
  }
@@ -268,10 +266,10 @@ class LocalDevManagerV2 {
268
266
  const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
269
267
  const missingProjectNodes = [];
270
268
  Object.values(this.projectNodes).forEach(node => {
271
- if ((0, structure_1.isAppIRNode)(node) || (0, structure_1.isCardIRNode)(node)) {
272
- if (!deployedComponentNames.includes(node.uid)) {
273
- missingProjectNodes.push(`${(0, lang_1.i18n)(`${i18nKey}.uploadWarning.appLabel`)} ${node.uid}`);
274
- }
269
+ if (!deployedComponentNames.includes(node.uid)) {
270
+ const userFriendlyName = (0, project_parsing_lib_1.mapToUserFriendlyName)(node.componentType);
271
+ const label = userFriendlyName ? `[${userFriendlyName}] ` : '';
272
+ missingProjectNodes.push(`${label}${node.uid}`);
275
273
  }
276
274
  });
277
275
  if (missingProjectNodes.length) {
@@ -284,9 +282,7 @@ class LocalDevManagerV2 {
284
282
  this.watcher = chokidar_1.default.watch(this.projectDir, {
285
283
  ignoreInitial: true,
286
284
  });
287
- const configPaths = Object.values(this.projectNodes)
288
- .filter(structure_1.isAppIRNode)
289
- .map(component => component.localDev.componentConfigPath);
285
+ const configPaths = Object.values(this.projectNodes).map(component => component.localDev.componentConfigPath);
290
286
  const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
291
287
  configPaths.push(projectConfigPath);
292
288
  this.watcher.on('add', filePath => {
@@ -317,7 +313,6 @@ class LocalDevManagerV2 {
317
313
  try {
318
314
  await DevServerManagerV2_1.default.setup({
319
315
  projectNodes: this.projectNodes,
320
- onUploadRequired: this.logUploadWarning.bind(this),
321
316
  accountId: this.targetTestingAccountId,
322
317
  setActiveApp: this.setActiveApp.bind(this),
323
318
  });
@@ -1,3 +1,8 @@
1
+ export declare function isGloballyInstalled(command: string): Promise<boolean>;
2
+ export declare function getLatestCliVersion(): Promise<{
3
+ latest: string;
4
+ next: string;
5
+ }>;
1
6
  export declare function installPackages({ packages, installLocations, }: {
2
7
  packages?: string[];
3
8
  installLocations?: string[];
@@ -3,28 +3,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isGloballyInstalled = isGloballyInstalled;
7
+ exports.getLatestCliVersion = getLatestCliVersion;
6
8
  exports.installPackages = installPackages;
7
9
  exports.getProjectPackageJsonLocations = getProjectPackageJsonLocations;
8
10
  exports.hasMissingPackages = hasMissingPackages;
9
- const fs_1 = __importDefault(require("fs"));
10
- const util_1 = __importDefault(require("util"));
11
- const path_1 = __importDefault(require("path"));
12
- const child_process_1 = require("child_process");
13
- const fs_2 = require("@hubspot/local-dev-lib/fs");
11
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
14
12
  const projects_1 = require("./projects");
13
+ const child_process_1 = require("child_process");
14
+ const fs_1 = require("@hubspot/local-dev-lib/fs");
15
+ const path_1 = __importDefault(require("path"));
15
16
  const ui_1 = require("./ui");
17
+ const util_1 = __importDefault(require("util"));
16
18
  const lang_1 = require("./lang");
17
19
  const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
18
- const npm_1 = require("./npm");
19
- const i18nKey = `commands.project.subcommands.installDeps`;
20
+ const fs_2 = __importDefault(require("fs"));
21
+ const package_json_1 = __importDefault(require("../package.json"));
22
+ const DEFAULT_PACKAGE_MANAGER = 'npm';
20
23
  class NoPackageJsonFilesError extends Error {
21
24
  constructor(projectName) {
22
- super((0, lang_1.i18n)(`${i18nKey}.noPackageJsonInProject`, {
25
+ super((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noPackageJsonInProject`, {
23
26
  projectName,
24
27
  link: (0, ui_1.uiLink)('Learn how to create a project from scratch.', 'https://developers.hubspot.com/beta-docs/guides/crm/intro/create-a-project'),
25
28
  }));
26
29
  }
27
30
  }
31
+ async function isGloballyInstalled(command) {
32
+ const exec = util_1.default.promisify(child_process_1.exec);
33
+ try {
34
+ await exec(`${command} --version`);
35
+ return true;
36
+ }
37
+ catch (e) {
38
+ return false;
39
+ }
40
+ }
41
+ async function getLatestCliVersion() {
42
+ const exec = util_1.default.promisify(child_process_1.exec);
43
+ const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
44
+ const { latest, next } = JSON.parse(stdout);
45
+ return { latest, next };
46
+ }
28
47
  async function installPackages({ packages, installLocations, }) {
29
48
  const installDirs = installLocations || (await getProjectPackageJsonLocations());
30
49
  await Promise.all(installDirs.map(async (dir) => {
@@ -37,29 +56,35 @@ async function installPackagesInDirectory(directory, packages) {
37
56
  SpinniesManager_1.default.init();
38
57
  SpinniesManager_1.default.add(spinner, {
39
58
  text: packages && packages.length
40
- ? (0, lang_1.i18n)(`${i18nKey}.addingDependenciesToLocation`, {
59
+ ? (0, lang_1.i18n)(`commands.project.subcommands.installDeps.addingDependenciesToLocation`, {
41
60
  dependencies: `[${packages.join(', ')}]`,
42
61
  directory: relativeDir,
43
62
  })
44
- : (0, lang_1.i18n)(`${i18nKey}.installingDependencies`, {
63
+ : (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependencies`, {
45
64
  directory: relativeDir,
46
65
  }),
47
66
  });
67
+ let installCommand = `${DEFAULT_PACKAGE_MANAGER} install`;
68
+ if (packages) {
69
+ installCommand = `${installCommand} ${packages.join(' ')}`;
70
+ }
71
+ logger_1.logger.debug(`Running ${installCommand}`);
48
72
  try {
49
- await (0, npm_1.executeInstall)(packages, null, { cwd: directory });
73
+ const exec = util_1.default.promisify(child_process_1.exec);
74
+ await exec(installCommand, { cwd: directory });
50
75
  SpinniesManager_1.default.succeed(spinner, {
51
- text: (0, lang_1.i18n)(`${i18nKey}.installationSuccessful`, {
76
+ text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installationSuccessful`, {
52
77
  directory: relativeDir,
53
78
  }),
54
79
  });
55
80
  }
56
81
  catch (e) {
57
82
  SpinniesManager_1.default.fail(spinner, {
58
- text: (0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
83
+ text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
59
84
  directory: relativeDir,
60
85
  }),
61
86
  });
62
- throw new Error((0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
87
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
63
88
  directory: relativeDir,
64
89
  }), {
65
90
  cause: e,
@@ -71,20 +96,20 @@ async function getProjectPackageJsonLocations() {
71
96
  if (!projectConfig ||
72
97
  !projectConfig.projectDir ||
73
98
  !projectConfig.projectConfig) {
74
- throw new Error((0, lang_1.i18n)(`${i18nKey}.noProjectConfig`));
99
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noProjectConfig`));
75
100
  }
76
101
  const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
77
- if (!(await (0, npm_1.isGloballyInstalled)())) {
78
- throw new Error((0, lang_1.i18n)(`${i18nKey}.packageManagerNotInstalled`, {
79
- packageManager: npm_1.DEFAULT_PACKAGE_MANAGER,
80
- link: (0, ui_1.uiLink)(npm_1.DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
102
+ if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
103
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.packageManagerNotInstalled`, {
104
+ packageManager: DEFAULT_PACKAGE_MANAGER,
105
+ link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
81
106
  }));
82
107
  }
83
- if (!fs_1.default.existsSync(projectConfig.projectDir) ||
84
- !fs_1.default.existsSync(path_1.default.join(projectDir, srcDir))) {
108
+ if (!fs_2.default.existsSync(projectConfig.projectDir) ||
109
+ !fs_2.default.existsSync(path_1.default.join(projectDir, srcDir))) {
85
110
  throw new NoPackageJsonFilesError(name);
86
111
  }
87
- const packageJsonFiles = (await (0, fs_2.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
112
+ const packageJsonFiles = (await (0, fs_1.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
88
113
  !file.includes('node_modules') &&
89
114
  !file.includes('.vite'));
90
115
  if (packageJsonFiles.length === 0) {
@@ -8,7 +8,6 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
8
8
  const config_1 = require("@hubspot/local-dev-lib/config");
9
9
  const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
10
10
  const dependencyManagement_1 = require("../dependencyManagement");
11
- const npm_1 = require("../npm");
12
11
  const util_1 = __importDefault(require("util"));
13
12
  const fs_1 = __importDefault(require("fs"));
14
13
  const path_1 = __importDefault(require("path"));
@@ -216,7 +215,7 @@ class Doctor {
216
215
  let latestCLIVersion;
217
216
  let nextCliVersion;
218
217
  try {
219
- const { latest, next } = await (0, npm_1.getLatestCliVersion)();
218
+ const { latest, next } = await (0, dependencyManagement_1.getLatestCliVersion)();
220
219
  latestCLIVersion = latest;
221
220
  nextCliVersion = next;
222
221
  }
@@ -1,6 +1,6 @@
1
1
  import { ComponentTypes, Component, GenericComponentConfig, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
2
2
  import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
3
- import { AppIRNode, CardIRNode } from '../../types/ProjectComponents';
3
+ import { AppIRNode } from '../../types/ProjectComponents';
4
4
  export declare const CONFIG_FILES: {
5
5
  [k in ComponentTypes]: string;
6
6
  };
@@ -16,4 +16,3 @@ export declare function getComponentUid(component?: Component | null): string |
16
16
  export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
17
17
  export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
18
18
  export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev): component is AppIRNode;
19
- export declare function isCardIRNode(component: IntermediateRepresentationNodeLocalDev): component is CardIRNode;
@@ -44,7 +44,6 @@ exports.getComponentUid = getComponentUid;
44
44
  exports.componentIsApp = componentIsApp;
45
45
  exports.componentIsPublicApp = componentIsPublicApp;
46
46
  exports.isAppIRNode = isAppIRNode;
47
- exports.isCardIRNode = isCardIRNode;
48
47
  const fs = __importStar(require("fs"));
49
48
  const path = __importStar(require("path"));
50
49
  const fs_1 = require("@hubspot/local-dev-lib/fs");
@@ -175,6 +174,3 @@ function componentIsPublicApp(component) {
175
174
  function isAppIRNode(component) {
176
175
  return component.componentType === constants_1.IR_COMPONENT_TYPES.APPLICATION;
177
176
  }
178
- function isCardIRNode(component) {
179
- return component.componentType === constants_1.IR_COMPONENT_TYPES.CARD;
180
- }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.3.0-experimental.2",
3
+ "version": "7.3.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
8
  "@hubspot/local-dev-lib": "3.4.1",
9
- "@hubspot/project-parsing-lib": "0.1.4",
9
+ "@hubspot/project-parsing-lib": "0.1.5",
10
10
  "@hubspot/serverless-dev-runtime": "7.0.2",
11
11
  "@hubspot/theme-preview-dev-server": "0.0.10",
12
- "@hubspot/ui-extensions-dev-server": "0.8.50",
12
+ "@hubspot/ui-extensions-dev-server": "0.8.52",
13
13
  "archiver": "7.0.1",
14
14
  "chalk": "4.1.2",
15
15
  "chokidar": "3.6.0",
@@ -16,23 +16,8 @@ type AppConfig = {
16
16
  conditionallyRequiredScopes: string[];
17
17
  };
18
18
  };
19
- type CardConfig = {
20
- name: string;
21
- description: string;
22
- previewImage: {
23
- file: string;
24
- altText: string;
25
- };
26
- entrypoint: string;
27
- location: string;
28
- objectTypes: string[];
29
- };
30
19
  export interface AppIRNode extends IntermediateRepresentationNodeLocalDev {
31
20
  componentType: typeof IR_COMPONENT_TYPES.APPLICATION;
32
21
  config: AppConfig;
33
22
  }
34
- export interface CardIRNode extends IntermediateRepresentationNodeLocalDev {
35
- componentType: typeof IR_COMPONENT_TYPES.CARD;
36
- config: CardConfig;
37
- }
38
23
  export {};
package/lib/npm.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export declare const DEFAULT_PACKAGE_MANAGER = "npm";
2
- export declare function isGloballyInstalled(): Promise<boolean>;
3
- export declare function getLatestCliVersion(): Promise<{
4
- latest: string;
5
- next: string;
6
- }>;
7
- export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
8
- cwd?: string;
9
- }): Promise<void>;