@hubspot/cli 5.2.1-beta.4 → 5.2.1-beta.6

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/hs CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node --no-deprecation
2
2
 
3
3
  require('./cli');
@@ -9,12 +9,7 @@ const {
9
9
  } = require('../../lib/commonOpts');
10
10
  const { trackCommandUsage } = require('../../lib/usageTracking');
11
11
  const { loadAndValidateOptions } = require('../../lib/validation');
12
- const { getSandboxName } = require('../../lib/sandboxes');
13
- const {
14
- isSandbox,
15
- isDeveloperTestAccount,
16
- isAppDeveloperAccount,
17
- } = require('../../lib/accountTypes');
12
+ const { isSandbox, isDeveloperTestAccount } = require('../../lib/accountTypes');
18
13
 
19
14
  const { i18n } = require('../../lib/lang');
20
15
  const {
@@ -63,23 +58,17 @@ const getPortalData = mappedPortalData => {
63
58
  p => p.portalId === parseInt(key, 10)
64
59
  )[0];
65
60
  set.forEach(portal => {
66
- let name = portal.name;
61
+ let name = `${portal.name} [${
62
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[portal.accountType]
63
+ }]`;
67
64
  if (isSandbox(portal)) {
68
- name = `${portal.name} ${getSandboxName(portal)}`;
69
65
  if (hasParentPortal && set.length > 1) {
70
66
  name = `↳ ${name}`;
71
67
  }
72
68
  } else if (isDeveloperTestAccount(portal)) {
73
- name = `${portal.name} [${
74
- HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
75
- }]`;
76
69
  if (hasParentPortal && set.length > 1) {
77
70
  name = `↳ ${name}`;
78
71
  }
79
- } else if (isAppDeveloperAccount(portal)) {
80
- name = `${portal.name} [${
81
- HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER]
82
- }]`;
83
72
  }
84
73
  portalData.push([name, portal.portalId, portal.authType]);
85
74
  });
@@ -1,7 +1,7 @@
1
1
  const open = require('open');
2
2
 
3
3
  const { i18n } = require('../lib/lang');
4
- const { FEEDBACK_OPTIONS, FEEDBACK_URLS } = require('../lib/constants');
4
+ const { FEEDBACK_URLS } = require('../lib/constants');
5
5
  const { logger } = require('@hubspot/local-dev-lib/logger');
6
6
 
7
7
  const {
@@ -22,10 +22,8 @@ exports.handler = async options => {
22
22
  const { shouldOpen } = await shouldOpenBrowserPrompt(type, usedTypeFlag);
23
23
 
24
24
  if (shouldOpen || usedTypeFlag) {
25
- const url =
26
- type === FEEDBACK_OPTIONS.BUG || bugFlag
27
- ? FEEDBACK_URLS.BUG
28
- : FEEDBACK_URLS.GENERAL;
25
+ // NOTE: for now, all feedback should go to the hubspot-cli repository
26
+ const url = FEEDBACK_URLS.BUG;
29
27
  open(url, { url: true });
30
28
  logger.success(i18n(`${i18nKey}.success`, { url }));
31
29
  }
@@ -79,8 +79,8 @@ exports.handler = async options => {
79
79
 
80
80
  const components = await findProjectComponents(projectDir);
81
81
  const componentTypes = getProjectComponentTypes(components);
82
- const hasPrivateApps = componentTypes[COMPONENT_TYPES.privateApp];
83
- const hasPublicApps = componentTypes[COMPONENT_TYPES.publicApp];
82
+ const hasPrivateApps = !!componentTypes[COMPONENT_TYPES.privateApp];
83
+ const hasPublicApps = !!componentTypes[COMPONENT_TYPES.publicApp];
84
84
 
85
85
  if (hasPrivateApps && hasPublicApps) {
86
86
  logger.error(i18n(`${i18nKey}.errors.invalidProjectComponents`));
@@ -178,7 +178,7 @@ exports.handler = async options => {
178
178
  targetProjectAccountId = accountId;
179
179
  }
180
180
 
181
- const { projectExists, project } = await ensureProjectExists(
181
+ let { projectExists, project } = await ensureProjectExists(
182
182
  targetProjectAccountId,
183
183
  projectConfig.name,
184
184
  {
@@ -199,7 +199,7 @@ exports.handler = async options => {
199
199
  project.sourceIntegration &&
200
200
  project.sourceIntegration.source === 'GITHUB';
201
201
  } else {
202
- await createNewProjectForLocalDev(
202
+ project = await createNewProjectForLocalDev(
203
203
  projectConfig,
204
204
  targetProjectAccountId,
205
205
  createNewSandbox,
@@ -93,7 +93,7 @@ exports.handler = async options => {
93
93
  uiLine();
94
94
  logFeedbackMessage(result.buildId);
95
95
 
96
- displayWarnLogs(accountId, projectConfig.name, result.buildId);
96
+ await displayWarnLogs(accountId, projectConfig.name, result.buildId);
97
97
  process.exit(EXIT_CODES.SUCCESS);
98
98
  }
99
99
  } catch (e) {
package/lang/en.lyaml CHANGED
@@ -648,7 +648,7 @@ en:
648
648
  bug:
649
649
  describe: "Open Github issues in your browser to report a bug."
650
650
  general:
651
- describe: "Open the projects feedback form in your browser."
651
+ describe: "Open Github issues in your browser to give feedback."
652
652
  remove:
653
653
  describe: "Delete a file or folder from HubSpot."
654
654
  deleted: "Deleted \"{{ path }}\" from account {{ accountId }}"
@@ -917,7 +917,7 @@ en:
917
917
  noCompatibleComponents: "Skipping call to {{ serverKey }} because there are no compatible components in the project."
918
918
  LocalDevManager:
919
919
  failedToInitialize: "Missing required arguments to initialize Local Dev"
920
- noDeployedBuild: "There is no deployed build for this project in {{ accountIdentifier }}. Run {{ uploadCommand }} to upload and deploy your project."
920
+ noDeployedBuild: "Your project {{#bold}}{{ projectName }}{{/bold}} exists in {{ accountIdentifier }}, but has no deployed build. Projects must be successfully deployed to be developed locally. Address any build and deploy errors your project may have, then run {{ uploadCommand }} to upload and deploy your project."
921
921
  noComponents: "There are no components in this project."
922
922
  noRunnableComponents: "No supported components were found under {{#bold}}{{ projectSourceDir }}{{/bold}}. Run {{ command }} to see a list of available components."
923
923
  betaMessage: "HubSpot projects local development"
@@ -933,11 +933,18 @@ en:
933
933
  uiExtensionLabel: "[UI Extension]"
934
934
  missingComponents: "Couldn't find the following components in the deployed build for this project: {{#bold}}'{{ missingComponents }}'{{/bold}}. This may cause issues in local development."
935
935
  defaultWarning: "Changing project configuration requires a new project build."
936
+ defaultPublicAppWarning: "Changing project configuration requires a new project build. This will affect existing users of your public app. If your app has users in production, we strongly recommend creating a copy of this app to test your changes before proceding."
936
937
  header: "{{ warning }} To reflect these changes and continue testing:"
937
938
  stopDev: " * Stop {{ command }}"
938
939
  runUpload: " * Run {{ command }}"
939
940
  restartDev: " * Re-run {{ command }}"
940
941
  pushToGithub: " * Commit and push your changes to GitHub"
942
+ activeInstallWarning:
943
+ installCount: "{{#bold}}The app {{ appName }} has {{ installCount }} production installs{{/bold}}"
944
+ genericHeader: "{{#bold}}Local development can affect existing installs of your public app.{{/bold}}"
945
+ genericExplanation: "Some changes made during local development may need to be synced to HubSpot, which will impact users with existing installs. You will always be asked to confirm these changes before uploading them. If your app has any production installs, we strongly recommend creating a copy of this app to develop on instead."
946
+ explanation: "Some changes made during local development may need to be synced to HubSpot, which will impact those existing installs. We strongly recommend creating a copy of this app to use instead."
947
+ confirmation: "You will always be asked to confirm any permanent changes to your app’s configuration before uploading them."
941
948
  devServer:
942
949
  cleanupError: "Failed to cleanup local dev server: {{ message }}"
943
950
  setupError: "Failed to setup local dev server: {{ message }}"
@@ -951,11 +958,11 @@ en:
951
958
  suggestRecommendedNestedAccount:
952
959
  nonSandboxWarning: "Testing in a sandbox is strongly recommended. To switch the target account, select an option below or run {{#bold}}`hs accounts use`{{/bold}} before running the command again."
953
960
  publicAppNonDeveloperTestAccountWarning: "Local development of public apps is only supported in {{#bold}}developer test accounts{{/bold}}."
954
- privateAppNonDeveloperTestAccountWarning: "Local development of private apps is only supported in {{#bold}}developer test accounts{{/bold}}"
961
+ privateAppInAppDeveloperAccountError: "Local development of private apps is not supported in {{#bold}}app developer accounts{{/bold}}"
955
962
  createNewProjectForLocalDev:
956
963
  projectMustExistExplanation: "The project {{ projectName }} does not exist in the target account {{ accountIdentifier}}. This command requires the project to exist in the target account."
957
964
  publicAppProjectMustExistExplanation: "The project {{ projectName }} does not exist in {{ accountIdentifier}}, the app developer account associated with your target account. This command requires the project to exist in this app developer account."
958
- createProject: "Create new project {{ projectName}} in {{#bold}}[{{ accountIdentifier }}]{{/bold}}?"
965
+ createProject: "Create new project {{ projectName}} in {{ accountIdentifier }}?"
959
966
  choseNotToCreateProject: "Exiting because this command requires the project to exist in the target account."
960
967
  creatingProject: "Creating project {{ projectName }} in {{ accountIdentifier }}"
961
968
  createdProject: "Created project {{ projectName }} in {{ accountIdentifier }}"
@@ -1217,7 +1224,7 @@ en:
1217
1224
  bug: "[--bug] Report a bug"
1218
1225
  general: "[--general] Tell us about your experience with HubSpot's developer tools"
1219
1226
  bugPrompt: "Create an issue on Github in your browser?"
1220
- generalPrompt: "Open the projects feedback form in your browser?"
1227
+ generalPrompt: "Create an issue on Github in your browser?"
1221
1228
  buildIdPrompt:
1222
1229
  enterBuildId: "[--build] Deploy which build?"
1223
1230
  errors:
@@ -111,6 +111,7 @@ class LocalDevManager {
111
111
  if (this.activeApp.type === COMPONENT_TYPES.publicApp) {
112
112
  try {
113
113
  await this.setActivePublicAppData();
114
+ await this.checkActivePublicAppInstalls();
114
115
  await this.checkPublicAppInstallation();
115
116
  } catch (e) {
116
117
  logErrorInstance(e);
@@ -134,6 +135,19 @@ class LocalDevManager {
134
135
  this.activePublicAppData = activePublicAppData;
135
136
  }
136
137
 
138
+ async checkActivePublicAppInstalls() {
139
+ // TODO: Add check for installs once we have that info
140
+ if (!this.activePublicAppData) {
141
+ return;
142
+ }
143
+ uiLine();
144
+ // TODO: Replace with final copy
145
+
146
+ logger.warn(i18n(`${i18nKey}.activeInstallWarning.genericHeader`));
147
+ logger.log(i18n(`${i18nKey}.activeInstallWarning.genericExplanation`));
148
+ uiLine();
149
+ }
150
+
137
151
  async start() {
138
152
  SpinniesManager.stopAll();
139
153
  SpinniesManager.init();
@@ -142,6 +156,7 @@ class LocalDevManager {
142
156
  if (!this.deployedBuild) {
143
157
  logger.error(
144
158
  i18n(`${i18nKey}.noDeployedBuild`, {
159
+ projectName: this.projectConfig.name,
145
160
  accountIdentifier: uiAccountDescription(this.targetProjectAccountId),
146
161
  uploadCommand: this.getUploadCommand(),
147
162
  })
@@ -268,7 +283,13 @@ class LocalDevManager {
268
283
  }
269
284
 
270
285
  logUploadWarning(reason) {
271
- const warning = reason || i18n(`${i18nKey}.uploadWarning.defaultWarning`);
286
+ let warning = reason;
287
+ if (!reason) {
288
+ warning =
289
+ this.activeApp.type === COMPONENT_TYPES.publicApp
290
+ ? i18n(`${i18nKey}.uploadWarning.defaultPublicAppWarning`)
291
+ : i18n(`${i18nKey}.uploadWarning.defaultWarning`);
292
+ }
272
293
 
273
294
  // Avoid logging the warning to the console if it is currently the most
274
295
  // recently logged warning. We do not want to spam the console with the same message.
package/lib/localDev.js CHANGED
@@ -23,7 +23,6 @@ const {
23
23
  const { confirmPrompt } = require('./prompts/promptUtils');
24
24
  const {
25
25
  validateSandboxUsageLimits,
26
- getSandboxTypeAsString,
27
26
  getAvailableSyncTypes,
28
27
  } = require('./sandboxes');
29
28
  const { buildSandbox } = require('./sandboxCreate');
@@ -70,9 +69,7 @@ const confirmDefaultAccountIsTarget = async accountConfig => {
70
69
  logger.log();
71
70
  const useDefaultAccount = await confirmDefaultAccountPrompt(
72
71
  accountConfig.name,
73
- isDeveloperTestAccount(accountConfig)
74
- ? HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
75
- : `${getSandboxTypeAsString(accountConfig.accountType)} sandbox`
72
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[accountConfig.accountType]
76
73
  );
77
74
 
78
75
  if (!useDefaultAccount) {
@@ -114,19 +111,20 @@ const suggestRecommendedNestedAccount = async (
114
111
  logger.log();
115
112
  uiLine();
116
113
  if (hasPublicApps) {
117
- logger.warn(
114
+ logger.log(
118
115
  i18n(
119
116
  `${i18nKey}.suggestRecommendedNestedAccount.publicAppNonDeveloperTestAccountWarning`
120
117
  )
121
118
  );
122
119
  } else if (isAppDeveloperAccount(accountConfig)) {
123
- logger.warn(
120
+ logger.error(
124
121
  i18n(
125
- `${i18nKey}.suggestRecommendedNestedAccount.publicAppNonDeveloperTestAccountWarning`
122
+ `${i18nKey}.suggestRecommendedNestedAccount.privateAppInAppDeveloperAccountError`
126
123
  )
127
124
  );
125
+ process.exit(EXIT_CODES.ERROR);
128
126
  } else {
129
- logger.warn(
127
+ logger.log(
130
128
  i18n(`${i18nKey}.suggestRecommendedNestedAccount.nonSandboxWarning`)
131
129
  );
132
130
  }
@@ -290,7 +288,7 @@ const useExistingDevTestAccount = async (env, account) => {
290
288
  }
291
289
  const devTestAcctConfigName = await saveDevTestAccountToConfig(env, account);
292
290
  logger.success(
293
- i18n(`cli.lib.developerTestAccount.create.success.configFileUpdated`, {
291
+ i18n(`lib.developerTestAccount.create.success.configFileUpdated`, {
294
292
  accountName: devTestAcctConfigName,
295
293
  authType: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
296
294
  })
@@ -319,7 +317,7 @@ const createNewProjectForLocalDev = async (
319
317
  );
320
318
  logger.log();
321
319
  uiLine();
322
- logger.warn(explanationString);
320
+ logger.log(explanationString);
323
321
  uiLine();
324
322
 
325
323
  shouldCreateProject = await confirmPrompt(
@@ -339,7 +337,7 @@ const createNewProjectForLocalDev = async (
339
337
  });
340
338
 
341
339
  try {
342
- await createProject(targetAccountId, projectConfig.name);
340
+ const project = await createProject(targetAccountId, projectConfig.name);
343
341
  SpinniesManager.succeed('createProject', {
344
342
  text: i18n(`${i18nKey}.createNewProjectForLocalDev.createdProject`, {
345
343
  accountIdentifier: uiAccountDescription(targetAccountId),
@@ -347,6 +345,7 @@ const createNewProjectForLocalDev = async (
347
345
  }),
348
346
  succeedColor: 'white',
349
347
  });
348
+ return project;
350
349
  } catch (err) {
351
350
  SpinniesManager.fail('createProject');
352
351
  logger.log(
@@ -417,7 +416,7 @@ const createInitialBuildForNewProject = async (
417
416
 
418
417
  logger.log();
419
418
  failedSubTasks.forEach(failedSubTask => {
420
- console.error(failedSubTask.errorMessage);
419
+ logger.error(failedSubTask.errorMessage);
421
420
  });
422
421
  logger.log();
423
422
 
package/lib/projects.js CHANGED
@@ -893,9 +893,17 @@ const displayWarnLogs = async (
893
893
  let result;
894
894
 
895
895
  if (isDeploy) {
896
- result = await fetchDeployWarnLogs(accountId, projectName, taskId);
896
+ try {
897
+ result = await fetchDeployWarnLogs(accountId, projectName, taskId);
898
+ } catch (e) {
899
+ logApiErrorInstance(e);
900
+ }
897
901
  } else {
898
- result = await fetchBuildWarnLogs(accountId, projectName, taskId);
902
+ try {
903
+ result = await fetchBuildWarnLogs(accountId, projectName, taskId);
904
+ } catch (e) {
905
+ logApiErrorInstance(e);
906
+ }
899
907
  }
900
908
 
901
909
  if (result && result.logs.length) {
@@ -33,8 +33,8 @@ const installPublicAppPrompt = async (
33
33
  const url =
34
34
  `${websiteOrigin}/oauth/${targetAccountId}/authorize` +
35
35
  `?client_id=${encodeURIComponent(clientId)}` +
36
- `&scope=${encodeURIComponent(scopes)}` +
37
- `&redirect_uri=${encodeURIComponent(redirectUrls)}`;
36
+ `&scope=${encodeURIComponent(scopes.join(' '))}` +
37
+ `&redirect_uri=${encodeURIComponent(redirectUrls[0])}`;
38
38
 
39
39
  open(url);
40
40
  };
package/lib/sandboxes.js CHANGED
@@ -39,9 +39,6 @@ const getSandboxTypeAsString = accountType => {
39
39
  return 'standard';
40
40
  };
41
41
 
42
- const getSandboxName = config =>
43
- `[${getSandboxTypeAsString(config.accountType)} sandbox] `;
44
-
45
42
  function getHasSandboxesByType(parentAccountConfig, type) {
46
43
  const config = getConfig();
47
44
  const parentPortalId = getAccountId(parentAccountConfig.portalId);
@@ -342,7 +339,6 @@ module.exports = {
342
339
  sandboxTypeMap,
343
340
  sandboxApiTypeMap,
344
341
  syncTypes,
345
- getSandboxName,
346
342
  getSandboxTypeAsString,
347
343
  getHasSandboxesByType,
348
344
  getSandboxLimit,
package/lib/ui/index.js CHANGED
@@ -3,17 +3,10 @@ const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
3
3
  const { logger } = require('@hubspot/local-dev-lib/logger');
4
4
  const supportsHyperlinks = require('./supportHyperlinks');
5
5
  const supportsColor = require('./supportsColor');
6
- const {
7
- isSandbox,
8
- isDeveloperTestAccount,
9
- isAppDeveloperAccount,
10
- } = require('../accountTypes');
11
- const { getSandboxName } = require('../sandboxes');
12
6
  const { i18n } = require('../lang');
13
7
 
14
8
  const {
15
9
  HUBSPOT_ACCOUNT_TYPE_STRINGS,
16
- HUBSPOT_ACCOUNT_TYPES,
17
10
  } = require('@hubspot/local-dev-lib/constants/config');
18
11
 
19
12
  const UI_COLORS = {
@@ -84,19 +77,9 @@ const uiLink = (linkText, url) => {
84
77
  */
85
78
  const uiAccountDescription = (accountId, bold = true) => {
86
79
  const account = getAccountConfig(accountId);
87
- let accountTypeString = '';
88
- if (isSandbox(account)) {
89
- accountTypeString = getSandboxName(account);
90
- } else if (isDeveloperTestAccount(account)) {
91
- accountTypeString = `[${
92
- HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]
93
- }] `;
94
- } else if (isAppDeveloperAccount(account)) {
95
- accountTypeString = `[${
96
- HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER]
97
- }] `;
98
- }
99
- const message = `${account.name} ${accountTypeString}(${account.portalId})`;
80
+ const message = `${account.name} [${
81
+ HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]
82
+ }] (${account.portalId})`;
100
83
  return bold ? chalk.bold(message) : message;
101
84
  };
102
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "5.2.1-beta.4",
3
+ "version": "5.2.1-beta.6",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,10 +8,10 @@
8
8
  "url": "https://github.com/HubSpot/hubspot-cms-tools"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/local-dev-lib": "1.1.0",
12
- "@hubspot/serverless-dev-runtime": "5.2.1-beta.4",
13
- "@hubspot/theme-preview-dev-server": "0.0.5",
14
- "@hubspot/ui-extensions-dev-server": "0.8.16",
11
+ "@hubspot/local-dev-lib": "1.2.0",
12
+ "@hubspot/serverless-dev-runtime": "5.2.1-beta.6",
13
+ "@hubspot/theme-preview-dev-server": "0.0.6",
14
+ "@hubspot/ui-extensions-dev-server": "0.8.19",
15
15
  "archiver": "^5.3.0",
16
16
  "chalk": "^4.1.2",
17
17
  "chokidar": "^3.0.1",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "59dbc8bff2ca377c95e1eea4dcc52389e98ac644"
48
+ "gitHead": "399851070db3e2fd91ade022044981bd45c28574"
49
49
  }