@hubspot/cli 7.2.4-experimental.0 → 7.3.0-beta.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 (67) hide show
  1. package/bin/cli.js +7 -8
  2. package/commands/account/clean.js +9 -10
  3. package/commands/account/info.js +9 -10
  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/customObject.d.ts +1 -1
  24. package/commands/filemanager/fetch.js +5 -6
  25. package/commands/filemanager/upload.js +12 -13
  26. package/commands/function/deploy.js +9 -10
  27. package/commands/function/list.js +4 -5
  28. package/commands/function/server.js +7 -8
  29. package/commands/mv.d.ts +1 -1
  30. package/commands/project/add.d.ts +10 -0
  31. package/commands/project/add.js +64 -52
  32. package/commands/project/create.js +1 -0
  33. package/commands/project/deploy.d.ts +11 -1
  34. package/commands/project/deploy.js +79 -71
  35. package/commands/project/dev/index.d.ts +1 -1
  36. package/commands/project/download.d.ts +11 -0
  37. package/commands/project/download.js +56 -54
  38. package/commands/project/listBuilds.d.ts +10 -0
  39. package/commands/project/listBuilds.js +101 -91
  40. package/commands/project/open.d.ts +9 -0
  41. package/commands/project/open.js +43 -35
  42. package/commands/sandbox/create.d.ts +1 -1
  43. package/commands/sandbox/delete.d.ts +1 -1
  44. package/commands/sandbox.d.ts +1 -1
  45. package/lang/en.js +3453 -0
  46. package/lang/en.lyaml +9 -3
  47. package/lib/DevServerManagerV2.d.ts +1 -2
  48. package/lib/DevServerManagerV2.js +1 -2
  49. package/lib/LocalDevManagerV2.js +10 -15
  50. package/lib/dependencyManagement.js +8 -9
  51. package/lib/errorHandlers/index.js +17 -0
  52. package/lib/projects/buildAndDeploy.d.ts +1 -1
  53. package/lib/projects/buildAndDeploy.js +14 -12
  54. package/lib/projects/index.d.ts +1 -1
  55. package/lib/projects/index.js +1 -1
  56. package/lib/projects/structure.d.ts +1 -2
  57. package/lib/projects/structure.js +0 -4
  58. package/lib/prompts/downloadProjectPrompt.js +5 -1
  59. package/lib/prompts/projectNamePrompt.d.ts +6 -1
  60. package/lib/prompts/projectNamePrompt.js +17 -16
  61. package/lib/testUtils.d.ts +4 -2
  62. package/lib/testUtils.js +17 -3
  63. package/lib/ui/index.d.ts +2 -1
  64. package/lib/yargsUtils.d.ts +2 -2
  65. package/lib/yargsUtils.js +2 -2
  66. package/package.json +5 -5
  67. package/types/ProjectComponents.d.ts +0 -15
package/lang/en.lyaml CHANGED
@@ -631,7 +631,7 @@ en:
631
631
  debug:
632
632
  deploying: "Deploying project at path: {{ path }}"
633
633
  errors:
634
- deploy: "Deploy error: {{ details }}"
634
+ deploy: "Deploy error: an unknown error occurred."
635
635
  noBuilds: "Deploy error: no builds for this project were found."
636
636
  noBuildId: "You must specify a build to deploy"
637
637
  projectNotFound: "The project {{ projectName }} does not exist in account {{ accountIdentifier }}. Run {{ command }} to upload your project files to HubSpot."
@@ -750,7 +750,7 @@ en:
750
750
  downloadSucceeded: "Downloaded build \"{{ buildId }}\" from project \"{{ projectName }}\""
751
751
  errors:
752
752
  downloadFailed: "Something went wrong downloading the project"
753
- projectNotFound: "Your project {{ projectName }} could not be found in {{ accountId }}"
753
+ noBuildIdToDownload: "This project is empty. There is no build content to download"
754
754
  warnings:
755
755
  cannotDownloadWithinProject: "Cancelling project download. Please run the command again outside the context of an existing project."
756
756
  options:
@@ -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 }}"
@@ -1145,7 +1146,7 @@ en:
1145
1146
  componentCount: "Found {{ numComponents }} components in this project"
1146
1147
  successStatusText: "DONE"
1147
1148
  failedStatusText: "FAILED"
1148
- errorFetchingTaskStatus: "Error fetching {{ taskType }} status"
1149
+ errorFetchingTaskStatus: "An error occurred while fetching the status of the current {{ taskType }}. For more information, view this project in HubSpot by running {{ openCommand }}."
1149
1150
  pollBuildAutodeployStatusError: "Error fetching autodeploy status for build #{{ buildId }}"
1150
1151
  pollProjectBuildAndDeploy:
1151
1152
  buildSucceededAutomaticallyDeploying: "Build #{{ buildId }} succeeded. {{#bold}}Automatically deploying{{/bold}} to {{ accountIdentifier }}\n"
@@ -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:
@@ -1514,6 +1518,8 @@ en:
1514
1518
  errorContext: "Context: {{ context }}"
1515
1519
  errorCause: "Cause: {{ cause }}"
1516
1520
  unknownErrorOccurred: "An unknown error has occurred."
1521
+ configTimeoutErrorOccurred: "This error occurred because a request exceeded the default HTTP timeout of {{ timeout }}ms. To increase the default HTTP timeout, run {{ configSetCommand }}."
1522
+ genericTimeoutErrorOccurred: "This error occurred because an HTTP request timed out. Re-running the command may resolve this issue."
1517
1523
  suppressErrors:
1518
1524
  platformVersionErrors:
1519
1525
  header: "Platform version update required"
@@ -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
  });
@@ -20,10 +20,9 @@ const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
20
20
  const fs_2 = __importDefault(require("fs"));
21
21
  const package_json_1 = __importDefault(require("../package.json"));
22
22
  const DEFAULT_PACKAGE_MANAGER = 'npm';
23
- const i18nKey = `commands.project.subcommands.installDeps`;
24
23
  class NoPackageJsonFilesError extends Error {
25
24
  constructor(projectName) {
26
- super((0, lang_1.i18n)(`${i18nKey}.noPackageJsonInProject`, {
25
+ super((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noPackageJsonInProject`, {
27
26
  projectName,
28
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'),
29
28
  }));
@@ -57,11 +56,11 @@ async function installPackagesInDirectory(directory, packages) {
57
56
  SpinniesManager_1.default.init();
58
57
  SpinniesManager_1.default.add(spinner, {
59
58
  text: packages && packages.length
60
- ? (0, lang_1.i18n)(`${i18nKey}.addingDependenciesToLocation`, {
59
+ ? (0, lang_1.i18n)(`commands.project.subcommands.installDeps.addingDependenciesToLocation`, {
61
60
  dependencies: `[${packages.join(', ')}]`,
62
61
  directory: relativeDir,
63
62
  })
64
- : (0, lang_1.i18n)(`${i18nKey}.installingDependencies`, {
63
+ : (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependencies`, {
65
64
  directory: relativeDir,
66
65
  }),
67
66
  });
@@ -74,18 +73,18 @@ async function installPackagesInDirectory(directory, packages) {
74
73
  const exec = util_1.default.promisify(child_process_1.exec);
75
74
  await exec(installCommand, { cwd: directory });
76
75
  SpinniesManager_1.default.succeed(spinner, {
77
- text: (0, lang_1.i18n)(`${i18nKey}.installationSuccessful`, {
76
+ text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installationSuccessful`, {
78
77
  directory: relativeDir,
79
78
  }),
80
79
  });
81
80
  }
82
81
  catch (e) {
83
82
  SpinniesManager_1.default.fail(spinner, {
84
- text: (0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
83
+ text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
85
84
  directory: relativeDir,
86
85
  }),
87
86
  });
88
- throw new Error((0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
87
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
89
88
  directory: relativeDir,
90
89
  }), {
91
90
  cause: e,
@@ -97,11 +96,11 @@ async function getProjectPackageJsonLocations() {
97
96
  if (!projectConfig ||
98
97
  !projectConfig.projectDir ||
99
98
  !projectConfig.projectConfig) {
100
- throw new Error((0, lang_1.i18n)(`${i18nKey}.noProjectConfig`));
99
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noProjectConfig`));
101
100
  }
102
101
  const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
103
102
  if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
104
- throw new Error((0, lang_1.i18n)(`${i18nKey}.packageManagerNotInstalled`, {
103
+ throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.packageManagerNotInstalled`, {
105
104
  packageManager: DEFAULT_PACKAGE_MANAGER,
106
105
  link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
107
106
  }));
@@ -8,9 +8,11 @@ exports.logError = logError;
8
8
  exports.debugError = debugError;
9
9
  const logger_1 = require("@hubspot/local-dev-lib/logger");
10
10
  const index_1 = require("@hubspot/local-dev-lib/errors/index");
11
+ const config_1 = require("@hubspot/local-dev-lib/config");
11
12
  const suppressError_1 = require("./suppressError");
12
13
  const lang_1 = require("../lang");
13
14
  const util_1 = __importDefault(require("util"));
15
+ const ui_1 = require("../ui");
14
16
  const i18nKey = 'lib.errorHandlers.index';
15
17
  function logError(error, context) {
16
18
  debugError(error, context);
@@ -41,6 +43,21 @@ function logError(error, context) {
41
43
  // Unknown errors
42
44
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.unknownErrorOccurred`));
43
45
  }
46
+ if ((0, index_1.isHubSpotHttpError)(error) && error.code === 'ETIMEDOUT') {
47
+ const config = (0, config_1.getConfig)();
48
+ const defaultTimeout = config?.httpTimeout;
49
+ // Timeout was caused by the default timeout
50
+ if (error.timeout && defaultTimeout === error.timeout) {
51
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.configTimeoutErrorOccurred`, {
52
+ timeout: error.timeout,
53
+ configSetCommand: (0, ui_1.uiCommandReference)('hs config set'),
54
+ }));
55
+ }
56
+ // Timeout was caused by a custom timeout set by the CLI or LDL
57
+ else {
58
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.genericTimeoutErrorOccurred`));
59
+ }
60
+ }
44
61
  }
45
62
  function debugError(error, context) {
46
63
  if ((0, index_1.isHubSpotHttpError)(error)) {
@@ -3,7 +3,7 @@ import { Build } from '@hubspot/local-dev-lib/types/Build';
3
3
  import { Deploy } from '@hubspot/local-dev-lib/types/Deploy';
4
4
  import { ProjectConfig, ProjectTask, ProjectPollResult } from '../../types/Projects';
5
5
  export declare function useV3Api(platformVersion?: string | null): boolean;
6
- type PollTaskStatusFunction<T extends ProjectTask> = (accountId: number, taskName: string, taskId: number, deployedBuildId: number | null, silenceLogs: boolean) => Promise<T>;
6
+ type PollTaskStatusFunction<T extends ProjectTask> = (accountId: number, taskName: string, taskId: number, deployedBuildId: number | null, silenceLogs?: boolean) => Promise<T>;
7
7
  export declare const pollBuildStatus: PollTaskStatusFunction<Build>;
8
8
  export declare const pollDeployStatus: PollTaskStatusFunction<Deploy>;
9
9
  export declare function displayWarnLogs(accountId: number, projectName: string, taskId: number, isDeploy?: boolean): Promise<void>;
@@ -16,6 +16,7 @@ const lang_1 = require("../lang");
16
16
  const errorHandlers_1 = require("../errorHandlers");
17
17
  const ui_1 = require("../ui");
18
18
  const urls_1 = require("./urls");
19
+ const exitCodes_1 = require("../enums/exitCodes");
19
20
  const i18nKey = 'lib.projectBuildAndDeploy';
20
21
  const SPINNER_STATUS = {
21
22
  SPINNING: 'spinning',
@@ -48,8 +49,17 @@ function getSubtaskType(task) {
48
49
  }
49
50
  return task.deployType;
50
51
  }
52
+ function handleTaskStatusError(statusText) {
53
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.makePollTaskStatusFunc.errorFetchingTaskStatus`, {
54
+ taskType: statusText.TYPE_KEY === constants_1.PROJECT_BUILD_TEXT.TYPE_KEY
55
+ ? 'build'
56
+ : 'deploy',
57
+ openCommand: (0, ui_1.uiCommandReference)('hs project open'),
58
+ }));
59
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
60
+ }
51
61
  function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrings, linkToHubSpot, }) {
52
- return async function (accountId, taskName, taskId, deployedBuildId = null, silenceLogs = false) {
62
+ return async function (accountId, taskName, taskId, deployedBuildId, silenceLogs = false) {
53
63
  const displayId = deployedBuildId || taskId;
54
64
  if (linkToHubSpot && !silenceLogs) {
55
65
  logger_1.logger.log(`\n${linkToHubSpot(accountId, taskName, taskId, deployedBuildId)}\n`);
@@ -111,7 +121,7 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
111
121
  task.subtasks.forEach((subtask, i) => addTaskSpinner(subtask, 4, i === task.subtasks.length - 1));
112
122
  });
113
123
  }
114
- return new Promise((resolve, reject) => {
124
+ return new Promise(resolve => {
115
125
  const pollInterval = setInterval(async () => {
116
126
  let taskStatus;
117
127
  try {
@@ -124,19 +134,11 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
124
134
  accountId,
125
135
  projectName: taskName,
126
136
  }));
127
- return reject(new Error((0, lang_1.i18n)(`${i18nKey}.makePollTaskStatusFunc.errorFetchingTaskStatus`, {
128
- taskType: statusText.TYPE_KEY === constants_1.PROJECT_BUILD_TEXT.TYPE_KEY
129
- ? 'build'
130
- : 'deploy',
131
- })));
137
+ handleTaskStatusError(statusText);
132
138
  }
133
139
  const subtasks = getSubtasks(taskStatus);
134
140
  if (!taskStatus || !taskStatus.status || !subtasks) {
135
- return reject(new Error((0, lang_1.i18n)(`${i18nKey}.makePollTaskStatusFunc.errorFetchingTaskStatus`, {
136
- taskType: statusText.TYPE_KEY === constants_1.PROJECT_BUILD_TEXT.TYPE_KEY
137
- ? 'build'
138
- : 'deploy',
139
- })));
141
+ handleTaskStatusError(statusText);
140
142
  }
141
143
  const { status } = taskStatus;
142
144
  if (SpinniesManager_1.default.hasActiveSpinners()) {
@@ -6,7 +6,7 @@ export declare function getProjectConfig(dir?: string): Promise<{
6
6
  projectDir: string | null;
7
7
  projectConfig: ProjectConfig | null;
8
8
  }>;
9
- export declare function validateProjectConfig(projectConfig: ProjectConfig, projectDir: string): void;
9
+ export declare function validateProjectConfig(projectConfig: ProjectConfig | null, projectDir: string | null): void;
10
10
  export declare function ensureProjectExists(accountId: number, projectName: string, { forceCreate, allowCreate, noLogs, withPolling, uploadCommand, }?: {
11
11
  forceCreate?: boolean | undefined;
12
12
  allowCreate?: boolean | undefined;
@@ -67,7 +67,7 @@ async function getProjectConfig(dir) {
67
67
  }
68
68
  }
69
69
  function validateProjectConfig(projectConfig, projectDir) {
70
- if (!projectConfig) {
70
+ if (!projectConfig || !projectDir) {
71
71
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.validateProjectConfig.configNotFound`, {
72
72
  createCommand: (0, ui_1.uiCommandReference)('hs project create'),
73
73
  }));
@@ -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
- }
@@ -26,7 +26,7 @@ async function createProjectsList(accountId) {
26
26
  async function downloadProjectPrompt(promptOptions) {
27
27
  const accountId = (0, config_1.getAccountId)(promptOptions.account);
28
28
  const projectsList = await createProjectsList(accountId);
29
- return (0, promptUtils_1.promptUser)([
29
+ const response = await (0, promptUtils_1.promptUser)([
30
30
  {
31
31
  name: 'project',
32
32
  message: () => {
@@ -49,4 +49,8 @@ async function downloadProjectPrompt(promptOptions) {
49
49
  }),
50
50
  },
51
51
  ]);
52
+ if (!response.project) {
53
+ response.project = promptOptions.project;
54
+ }
55
+ return response;
52
56
  }
@@ -1 +1,6 @@
1
- export {};
1
+ export type ProjectNamePromptResponse = {
2
+ projectName: string;
3
+ };
4
+ export declare function projectNamePrompt(accountId: number, options?: {
5
+ project?: string;
6
+ }): Promise<ProjectNamePromptResponse>;
@@ -1,34 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { promptUser } = require('./promptUtils');
5
- const { i18n } = require('../lang');
6
- const { ensureProjectExists } = require('../projects');
7
- const { uiAccountDescription } = require('../ui');
3
+ exports.projectNamePrompt = projectNamePrompt;
4
+ const promptUtils_1 = require("./promptUtils");
5
+ const lang_1 = require("../lang");
6
+ const projects_1 = require("../projects");
7
+ const ui_1 = require("../ui");
8
8
  const i18nKey = 'lib.prompts.projectNamePrompt';
9
- const projectNamePrompt = (accountId, options = {}) => {
10
- return promptUser({
9
+ async function projectNamePrompt(accountId, options = {}) {
10
+ const result = await (0, promptUtils_1.promptUser)({
11
11
  name: 'projectName',
12
- message: i18n(`${i18nKey}.enterName`),
12
+ message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
13
13
  when: !options.project,
14
14
  validate: async (val) => {
15
15
  if (typeof val !== 'string' || !val) {
16
- return i18n(`${i18nKey}.errors.invalidName`);
16
+ return (0, lang_1.i18n)(`${i18nKey}.errors.invalidName`);
17
17
  }
18
- const { projectExists } = await ensureProjectExists(accountId, val, {
18
+ const { projectExists } = await (0, projects_1.ensureProjectExists)(accountId, val, {
19
19
  allowCreate: false,
20
20
  noLogs: true,
21
21
  });
22
22
  if (!projectExists) {
23
- return i18n(`${i18nKey}.errors.projectDoesNotExist`, {
23
+ return (0, lang_1.i18n)(`${i18nKey}.errors.projectDoesNotExist`, {
24
24
  projectName: val,
25
- accountIdentifier: uiAccountDescription(accountId),
25
+ accountIdentifier: (0, ui_1.uiAccountDescription)(accountId),
26
26
  });
27
27
  }
28
28
  return true;
29
29
  },
30
30
  });
31
- };
32
- module.exports = {
33
- projectNamePrompt,
34
- };
31
+ if (!result.projectName && options.project) {
32
+ result.projectName = options.project;
33
+ }
34
+ return result;
35
+ }
@@ -1,5 +1,6 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError';
2
- type MockResponse = {
3
+ type MockErrorResponse = {
3
4
  status: number;
4
5
  data: {
5
6
  message?: string;
@@ -8,5 +9,6 @@ type MockResponse = {
8
9
  subCategory?: string;
9
10
  };
10
11
  };
11
- export declare const makeHubSpotHttpError: (message: string, response: MockResponse) => HubSpotHttpError;
12
+ export declare const mockHubSpotHttpResponse: (data: any) => AxiosResponse;
13
+ export declare const mockHubSpotHttpError: (message: string, response: MockErrorResponse) => HubSpotHttpError;
12
14
  export {};
package/lib/testUtils.js CHANGED
@@ -1,10 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeHubSpotHttpError = void 0;
3
+ exports.mockHubSpotHttpError = exports.mockHubSpotHttpResponse = void 0;
4
+ const axios_1 = require("axios");
4
5
  const HubSpotHttpError_1 = require("@hubspot/local-dev-lib/models/HubSpotHttpError");
5
- const makeHubSpotHttpError = (message, response) => {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ const mockHubSpotHttpResponse = (data) => {
8
+ return {
9
+ data,
10
+ status: 200,
11
+ statusText: 'OK',
12
+ headers: {},
13
+ config: {
14
+ headers: new axios_1.AxiosHeaders(),
15
+ },
16
+ };
17
+ };
18
+ exports.mockHubSpotHttpResponse = mockHubSpotHttpResponse;
19
+ const mockHubSpotHttpError = (message, response) => {
6
20
  return new HubSpotHttpError_1.HubSpotHttpError(message, {
7
21
  cause: { isAxiosError: true, response },
8
22
  });
9
23
  };
10
- exports.makeHubSpotHttpError = makeHubSpotHttpError;
24
+ exports.mockHubSpotHttpError = mockHubSpotHttpError;
package/lib/ui/index.d.ts CHANGED
@@ -9,7 +9,8 @@ export declare function uiAccountDescription(accountId?: number | null, bold?: b
9
9
  export declare function uiInfoSection(title: string, logContent: () => void): void;
10
10
  export declare function uiCommandReference(command: string, withQuotes?: boolean): string;
11
11
  export declare function uiFeatureHighlight(features: string[], title?: string): void;
12
- export declare function uiBetaTag(message: string, log?: boolean): string | undefined;
12
+ export declare function uiBetaTag(message: string, log?: true): undefined;
13
+ export declare function uiBetaTag(message: string, log: false): string;
13
14
  export declare function uiDeprecatedTag(message: string): void;
14
15
  export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
15
16
  export declare function uiDeprecatedDescription(message: string, command: string, url?: string): void;
@@ -1,9 +1,9 @@
1
1
  import { Argv } from 'yargs';
2
2
  export declare function hasFlag(flag: string, argv?: string[]): boolean;
3
- export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>, command: string, describe: string, options: {
3
+ export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>, command: string, describe: string, options?: {
4
4
  useGlobalOptions?: boolean;
5
5
  useAccountOptions?: boolean;
6
6
  useConfigOptions?: boolean;
7
- useUseEnvironmentOptions?: boolean;
7
+ useEnvironmentOptions?: boolean;
8
8
  useTestingOptions?: boolean;
9
9
  }): (yargs: Argv) => Promise<Argv<T>>;
package/lib/yargsUtils.js CHANGED
@@ -15,7 +15,7 @@ function hasFlag(flag, argv = process_1.default.argv) {
15
15
  return (position !== -1 &&
16
16
  (terminatorPosition === -1 || position < terminatorPosition));
17
17
  }
18
- function makeYargsBuilder(callback, command, describe, options) {
18
+ function makeYargsBuilder(callback, command, describe, options = {}) {
19
19
  return async function (yargs) {
20
20
  if (options.useGlobalOptions) {
21
21
  (0, commonOpts_1.addGlobalOptions)(yargs);
@@ -26,7 +26,7 @@ function makeYargsBuilder(callback, command, describe, options) {
26
26
  if (options.useConfigOptions) {
27
27
  (0, commonOpts_1.addConfigOptions)(yargs);
28
28
  }
29
- if (options.useUseEnvironmentOptions) {
29
+ if (options.useEnvironmentOptions) {
30
30
  (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
31
31
  }
32
32
  if (options.useTestingOptions) {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.2.4-experimental.0",
3
+ "version": "7.3.0-beta.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": "3.3.2",
9
- "@hubspot/project-parsing-lib": "0.1.3-beta.0",
8
+ "@hubspot/local-dev-lib": "3.4.1",
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.48",
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",
@@ -58,7 +58,7 @@
58
58
  "typescript": "^5.6.2"
59
59
  },
60
60
  "optionalDependencies": {
61
- "@hubspot/cms-dev-server": "^0.18.10"
61
+ "@hubspot/cms-dev-server": "^1.0.9"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "ts-node ./scripts/build.ts",
@@ -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 {};