@hubspot/cli 4.2.1-beta.3 → 4.2.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -42,7 +42,11 @@ const cmsCommand = require('../commands/cms');
42
42
  const feedbackCommand = require('../commands/feedback');
43
43
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
44
44
 
45
- const notifier = updateNotifier({ pkg: { ...pkg, name: '@hubspot/cli' } });
45
+ const notifier = updateNotifier({
46
+ pkg: { ...pkg, name: '@hubspot/cli' },
47
+ distTag: 'latest',
48
+ shouldNotifyInNpmScript: true,
49
+ });
46
50
 
47
51
  const i18nKey = 'cli.commands.generalErrors';
48
52
 
@@ -51,7 +55,6 @@ const CLI_UPGRADE_MESSAGE =
51
55
  '\n\nTo upgrade, run:\n\nnpm uninstall -g @hubspot/cms-cli\nand npm install -g @hubspot/cli';
52
56
 
53
57
  notifier.notify({
54
- shouldNotifyInNpmScript: true,
55
58
  message: pkg.name === '@hubspot/cms-cli' ? CLI_UPGRADE_MESSAGE : null,
56
59
  });
57
60
 
@@ -38,7 +38,7 @@ exports.handler = async options => {
38
38
  await createProjectConfig(
39
39
  path.resolve(getCwd(), options.location || location),
40
40
  options.name || name,
41
- options.template || template,
41
+ template || { path: options.template },
42
42
  options.templateSource
43
43
  );
44
44
 
@@ -78,9 +78,6 @@ exports.handler = async options => {
78
78
 
79
79
  const { projectConfig, projectDir } = await getProjectConfig();
80
80
 
81
- if (!options.debug) {
82
- console.clear();
83
- }
84
81
  uiBetaMessage(i18n(`${i18nKey}.logs.betaMessage`));
85
82
 
86
83
  if (!projectConfig) {
@@ -211,11 +208,6 @@ exports.handler = async options => {
211
208
 
212
209
  SpinniesManager.init();
213
210
 
214
- if (!options.debug) {
215
- console.clear();
216
- }
217
- uiBetaMessage(i18n(`${i18nKey}.logs.betaMessage`));
218
-
219
211
  if (!projectExists) {
220
212
  // Create the project without prompting if this is a newly created sandbox
221
213
  let shouldCreateProject = createNewSandbox;
@@ -242,13 +234,14 @@ exports.handler = async options => {
242
234
  if (shouldCreateProject) {
243
235
  await showPlatformVersionWarning(accountId, projectConfig);
244
236
 
237
+ SpinniesManager.add('createProject', {
238
+ text: i18n(`${i18nKey}.status.creatingProject`, {
239
+ accountIdentifier: uiAccountDescription(targetAccountId),
240
+ projectName: projectConfig.name,
241
+ }),
242
+ });
243
+
245
244
  try {
246
- SpinniesManager.add('createProject', {
247
- text: i18n(`${i18nKey}.status.creatingProject`, {
248
- accountIdentifier: uiAccountDescription(targetAccountId),
249
- projectName: projectConfig.name,
250
- }),
251
- });
252
245
  await createProject(targetAccountId, projectConfig.name);
253
246
  SpinniesManager.succeed('createProject', {
254
247
  text: i18n(`${i18nKey}.status.createdProject`, {
@@ -258,6 +251,7 @@ exports.handler = async options => {
258
251
  succeedColor: 'white',
259
252
  });
260
253
  } catch (err) {
254
+ SpinniesManager.fail('createProject');
261
255
  logger.log(i18n(`${i18nKey}.status.failedToCreateProject`));
262
256
  process.exit(EXIT_CODES.ERROR);
263
257
  }
@@ -317,7 +311,7 @@ exports.handler = async options => {
317
311
 
318
312
  logger.log();
319
313
  failedSubTasks.forEach(failedSubTask => {
320
- console.log(failedSubTask.errorMessage);
314
+ console.error(failedSubTask.errorMessage);
321
315
  });
322
316
  logger.log();
323
317
 
package/lang/en.lyaml CHANGED
@@ -865,8 +865,8 @@ en:
865
865
  noCompatibleComponents: "Skipping call to {{ serverKey }} because there are no compatible components in the project."
866
866
  LocalDevManager:
867
867
  failedToInitialize: "Missing required arguments to initialize Local Dev"
868
+ noDeployedBuild: "There is no deployed build for this project in {{ accountIdentifier }}. Run {{ uploadCommand }} to upload and deploy your project."
868
869
  noComponents: "There are no components in this project."
869
- noDeployedBuild: "There is no deployed build for this project in {{ accountIdentifier }}."
870
870
  noRunnableComponents: "There are no components in this project that support local development."
871
871
  betaMessage: "HubSpot projects local development"
872
872
  running: "Running {{#bold}}{{ projectName }}{{/bold}} locally on {{ accountIdentifier }}, waiting for changes ..."
@@ -878,12 +878,11 @@ en:
878
878
  uploadWarning:
879
879
  appLabel: "[App]"
880
880
  uiExtensionLabel: "[UI Extension]"
881
- configEdit: "You edited the configuration file {{#bold}}{{ path }}{{/bold}}. Changes to configuration files cannot be handled by the local dev server."
882
881
  missingComponents: "The deployed build for this project does not contain {{#bold}}'{{ missingComponents }}'{{/bold}}. This may cause issues in local development."
883
- header: "{{ reason }} To reflect these changes:"
882
+ defaultWarning: "Changing project configuration requires a new project build."
883
+ header: "{{ warning }} To reflect these changes and continue testing:"
884
884
  stopDev: " * Stop {{ command }}"
885
885
  runUpload: " * Run {{ command }}"
886
- runUploadWithAccount: " * Run {{ command }}"
887
886
  restartDev: " * Re-run {{ command }}"
888
887
  devServer:
889
888
  cleanupError: "Failed to cleanup local dev server: {{ message }}"
@@ -64,12 +64,13 @@ class LocalDevManager {
64
64
 
65
65
  // Local dev currently relies on the existence of a deployed build in the target account
66
66
  if (!this.deployedBuild) {
67
- logger.log();
68
67
  logger.error(
69
68
  i18n(`${i18nKey}.noDeployedBuild`, {
70
69
  accountIdentifier: uiAccountDescription(this.targetAccountId),
70
+ uploadCommand: this.getUploadCommand(),
71
71
  })
72
72
  );
73
+ logger.log();
73
74
  process.exit(EXIT_CODES.SUCCESS);
74
75
  }
75
76
 
@@ -77,7 +78,6 @@ class LocalDevManager {
77
78
 
78
79
  // The project is empty, there is nothing to run locally
79
80
  if (!components.length) {
80
- logger.log();
81
81
  logger.error(i18n(`${i18nKey}.noComponents`));
82
82
  process.exit(EXIT_CODES.SUCCESS);
83
83
  }
@@ -88,15 +88,15 @@ class LocalDevManager {
88
88
 
89
89
  // The project does not contain any components that support local development
90
90
  if (!runnableComponents.length) {
91
- logger.log();
92
91
  logger.error(i18n(`${i18nKey}.noRunnableComponents`));
93
92
  process.exit(EXIT_CODES.SUCCESS);
94
93
  }
95
94
 
96
- logger.log();
97
95
  const setupSucceeded = await this.devServerSetup(runnableComponents);
98
96
 
99
- if (setupSucceeded || !this.debug) {
97
+ if (!setupSucceeded) {
98
+ process.exit(EXIT_CODES.ERROR);
99
+ } else if (!this.debug) {
100
100
  console.clear();
101
101
  }
102
102
 
@@ -165,43 +165,42 @@ class LocalDevManager {
165
165
  });
166
166
  }
167
167
 
168
+ getUploadCommand() {
169
+ const currentDefaultAccount = getConfigDefaultAccount();
170
+
171
+ return this.targetAccountId !== getAccountId(currentDefaultAccount)
172
+ ? uiCommandReference(
173
+ `hs project upload --account=${this.targetAccountId}`
174
+ )
175
+ : uiCommandReference('hs project upload');
176
+ }
177
+
168
178
  logUploadWarning(reason) {
179
+ const warning = reason || i18n(`${i18nKey}.uploadWarning.defaultWarning`);
180
+
169
181
  // Avoid logging the warning to the console if it is currently the most
170
182
  // recently logged warning. We do not want to spam the console with the same message.
171
- if (!this.uploadWarnings[reason]) {
172
- const currentDefaultAccount = getConfigDefaultAccount();
173
- const defaultAccountId = getAccountId(currentDefaultAccount);
174
-
183
+ if (!this.uploadWarnings[warning]) {
175
184
  logger.log();
176
- logger.warn(i18n(`${i18nKey}.uploadWarning.header`, { reason }));
185
+ logger.warn(i18n(`${i18nKey}.uploadWarning.header`, { warning }));
177
186
  logger.log(
178
187
  i18n(`${i18nKey}.uploadWarning.stopDev`, {
179
188
  command: uiCommandReference('hs project dev'),
180
189
  })
181
190
  );
182
- if (this.targetAccountId !== defaultAccountId) {
183
- logger.log(
184
- i18n(`${i18nKey}.uploadWarning.runUploadWithAccount`, {
185
- command: uiCommandReference(
186
- `hs project upload --account=${this.targetAccountId}`
187
- ),
188
- })
189
- );
190
- } else {
191
- logger.log(
192
- i18n(`${i18nKey}.uploadWarning.runUpload`, {
193
- command: uiCommandReference('hs project upload'),
194
- })
195
- );
196
- }
191
+ logger.log(
192
+ i18n(`${i18nKey}.uploadWarning.runUpload`, {
193
+ command: this.getUploadCommand(),
194
+ })
195
+ );
197
196
  logger.log(
198
197
  i18n(`${i18nKey}.uploadWarning.restartDev`, {
199
198
  command: uiCommandReference('hs project dev'),
200
199
  })
201
200
  );
202
201
 
203
- this.mostRecentUploadWarning = reason;
204
- this.uploadWarnings[reason] = true;
202
+ this.mostRecentUploadWarning = warning;
203
+ this.uploadWarnings[warning] = true;
205
204
  }
206
205
  }
207
206
 
@@ -245,7 +244,7 @@ class LocalDevManager {
245
244
  !deployedComponentNames.includes(cardConfig.data.title)
246
245
  ) {
247
246
  missingComponents.push(
248
- `${i18n(`${i18nKey}.uploadWarning.appLabel`)} ${
247
+ `${i18n(`${i18nKey}.uploadWarning.uiExtensionLabel`)} ${
249
248
  cardConfig.data.title
250
249
  }`
251
250
  );
@@ -298,11 +297,7 @@ class LocalDevManager {
298
297
 
299
298
  handleWatchEvent(filePath, event, configPaths) {
300
299
  if (configPaths.includes(filePath)) {
301
- this.logUploadWarning(
302
- i18n(`${i18nKey}.uploadWarning.configEdit`, {
303
- path: path.relative(this.projectDir, filePath),
304
- })
305
- );
300
+ this.logUploadWarning();
306
301
  } else {
307
302
  this.devServerFileChange(filePath, event);
308
303
  }
package/lib/projects.js CHANGED
@@ -133,24 +133,15 @@ const createProjectConfig = async (
133
133
  }`
134
134
  );
135
135
 
136
+ await downloadGitHubRepoContents(templateSource, template.path, projectPath);
137
+ const _config = JSON.parse(fs.readFileSync(projectConfigPath));
138
+ writeProjectConfig(projectConfigPath, {
139
+ ..._config,
140
+ name: projectName,
141
+ });
142
+
136
143
  if (template.name === 'no-template') {
137
144
  fs.ensureDirSync(path.join(projectPath, 'src'));
138
-
139
- writeProjectConfig(projectConfigPath, {
140
- name: projectName,
141
- srcDir: 'src',
142
- });
143
- } else {
144
- await downloadGitHubRepoContents(
145
- templateSource,
146
- template.path,
147
- projectPath
148
- );
149
- const _config = JSON.parse(fs.readFileSync(projectConfigPath));
150
- writeProjectConfig(projectConfigPath, {
151
- ..._config,
152
- name: projectName,
153
- });
154
145
  }
155
146
 
156
147
  return true;
@@ -26,7 +26,11 @@ const selectTargetAccountPrompt = async (accounts, defaultAccountConfig) => {
26
26
  logger.debug('Unable to fetch sandbox usage limits: ', err);
27
27
  }
28
28
 
29
- const sandboxAccounts = accounts.reverse().filter(isSandbox);
29
+ const sandboxAccounts = accounts
30
+ .reverse()
31
+ .filter(
32
+ config => isSandbox(config) && config.parentAccountId === defaultAccountId
33
+ );
30
34
  let disabledMessage = false;
31
35
 
32
36
  if (sandboxUsage['DEVELOPER'] && sandboxUsage['DEVELOPER'].available === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.2.1-beta.3",
3
+ "version": "4.2.1-beta.4",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  "dependencies": {
11
11
  "@hubspot/cli-lib": "^4.2.2",
12
12
  "@hubspot/serverless-dev-runtime": "4.2.1-beta.3",
13
- "@hubspot/ui-extensions-dev-server": "^0.7.0",
13
+ "@hubspot/ui-extensions-dev-server": "^0.7.2",
14
14
  "archiver": "^5.3.0",
15
15
  "chalk": "^4.1.2",
16
16
  "chokidar": "^3.0.1",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "e3e46fab20a9efb8c4c98f88b2aed1d13e6d0b1d"
45
+ "gitHead": "24d48c93e04bacc5db761cc15489b5bc82e17847"
46
46
  }