@hubspot/cli 7.0.4-experimental.0 → 7.0.6-experimental.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ exports.handler = async (options) => {
38
38
  });
39
39
  try {
40
40
  const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
41
- const successResp = await poll(getBuildStatus, derivedAccountId, buildId);
41
+ const successResp = await poll(() => getBuildStatus(derivedAccountId, buildId));
42
42
  const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
43
43
  SpinniesManager.succeed('loading');
44
44
  await outputBuildLog(successResp.cdnUrl);
@@ -68,7 +68,7 @@ exports.handler = async (options) => {
68
68
  text: i18n(`${i18nKey}.cloneStatus.inProgress`),
69
69
  });
70
70
  const { data: { exportId }, } = await cloneApp(derivedAccountId, appId);
71
- const { status } = await poll(checkCloneStatus, derivedAccountId, exportId);
71
+ const { status } = await poll(() => checkCloneStatus(derivedAccountId, exportId));
72
72
  if (status === 'SUCCESS') {
73
73
  // Ensure correct project folder structure exists
74
74
  const baseDestPath = path.resolve(getCwd(), projectDest);
@@ -83,7 +83,7 @@ exports.handler = async (options) => {
83
83
  logger.error(i18n(`${i18nKey}.errors.noBuildId`));
84
84
  return process.exit(EXIT_CODES.ERROR);
85
85
  }
86
- const { data: deployResp } = await deployProject(derivedAccountId, projectName, buildIdToDeploy);
86
+ const { data: deployResp } = await deployProject(derivedAccountId, projectName, buildIdToDeploy, options.useV3);
87
87
  if (!deployResp || deployResp.error) {
88
88
  logger.error(i18n(`${i18nKey}.errors.deploy`, {
89
89
  details: deployResp.error.message,
@@ -123,6 +123,11 @@ exports.builder = yargs => {
123
123
  describe: i18n(`${i18nKey}.options.build.describe`),
124
124
  type: 'number',
125
125
  },
126
+ 'use-v3': {
127
+ hidden: true,
128
+ type: 'boolean',
129
+ default: false,
130
+ },
126
131
  });
127
132
  yargs.example([
128
133
  ['$0 project deploy', i18n(`${i18nKey}.examples.default`)],
@@ -126,7 +126,7 @@ exports.handler = async (options) => {
126
126
  });
127
127
  const { data: migrateResponse } = await migrateApp(derivedAccountId, appId, projectName);
128
128
  const { id } = migrateResponse;
129
- const pollResponse = await poll(checkMigrationStatus, derivedAccountId, id);
129
+ const pollResponse = await poll(() => checkMigrationStatus(derivedAccountId, id));
130
130
  const { status, project } = pollResponse;
131
131
  if (status === 'SUCCESS') {
132
132
  const absoluteDestPath = path.resolve(getCwd(), projectDest);
@@ -22,15 +22,15 @@ exports.handler = async (options) => {
22
22
  const { forceCreate, message, derivedAccountId } = options;
23
23
  const accountConfig = getAccountConfig(derivedAccountId);
24
24
  const accountType = accountConfig && accountConfig.accountType;
25
- trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
26
25
  const { projectConfig, projectDir } = await getProjectConfig();
26
+ trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
27
27
  validateProjectConfig(projectConfig, projectDir);
28
28
  await ensureProjectExists(derivedAccountId, projectConfig.name, {
29
29
  forceCreate,
30
30
  uploadCommand: true,
31
31
  });
32
32
  try {
33
- const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message);
33
+ const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, options.translate);
34
34
  if (uploadError) {
35
35
  if (isSpecifiedError(uploadError, {
36
36
  subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
@@ -80,6 +80,11 @@ exports.builder = yargs => {
80
80
  type: 'string',
81
81
  default: '',
82
82
  },
83
+ translate: {
84
+ hidden: true,
85
+ type: 'boolean',
86
+ default: false,
87
+ },
83
88
  });
84
89
  yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
85
90
  addConfigOptions(yargs);
package/lang/en.lyaml CHANGED
@@ -1113,7 +1113,6 @@ en:
1113
1113
  notFound: "Your project {{#bold}}{{ projectName }}{{/bold}} could not be found in {{#bold}}{{ accountIdentifier }}{{/bold}}."
1114
1114
  pollFetchProject:
1115
1115
  checkingProject: "Checking if project exists in {{ accountIdentifier }}"
1116
- unableToFindAutodeployStatus: "Unable to find the auto deploy for build #{{ buildId }}. This deploy may have been skipped. {{ viewDeploysLink }}."
1117
1116
  logFeedbackMessage:
1118
1117
  feedbackHeader: "We'd love to hear your feedback!"
1119
1118
  feedbackMessage: "How are you liking the new projects and developer tools? \n > Run `{{#yellow}}hs feedback{{/yellow}}` to let us know what you think!\n"
@@ -1129,6 +1128,7 @@ en:
1129
1128
  buildSucceededAutomaticallyDeploying: "Build #{{ buildId }} succeeded. {{#bold}}Automatically deploying{{/bold}} to {{ accountIdentifier }}\n"
1130
1129
  cleanedUpTempFile: "Cleaned up temporary file {{ path }}"
1131
1130
  viewDeploys: "View all deploys for this project in HubSpot"
1131
+ unableToFindAutodeployStatus: "Unable to find the auto deploy for build #{{ buildId }}. This deploy may have been skipped. {{ viewDeploysLink }}."
1132
1132
  projectUpload:
1133
1133
  uploadProjectFiles:
1134
1134
  add: "Uploading {{#bold}}{{ projectName }}{{/bold}} project files to {{ accountIdentifier }}"
@@ -6,13 +6,7 @@ export declare const MARKETPLACE_FOLDER: "@marketplace";
6
6
  export declare const CONFIG_FLAGS: {
7
7
  readonly USE_CUSTOM_OBJECT_HUBFILE: "useCustomObjectHubfile";
8
8
  };
9
- export declare const POLLING_DELAY = 2000;
10
- export declare const POLLING_STATUS: {
11
- readonly SUCCESS: "SUCCESS";
12
- readonly ERROR: "ERROR";
13
- readonly REVERTED: "REVERTED";
14
- readonly FAILURE: "FAILURE";
15
- };
9
+ export declare const DEFAULT_POLLING_DELAY = 2000;
16
10
  export declare const PROJECT_CONFIG_FILE: "hsproject.json";
17
11
  export declare const PROJECT_BUILD_STATES: {
18
12
  readonly BUILDING: "BUILDING";
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.POLLING_STATUS = exports.POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
3
+ exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
4
4
  exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
5
5
  exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
6
6
  exports.FEEDBACK_INTERVAL = 10;
@@ -9,13 +9,7 @@ exports.MARKETPLACE_FOLDER = '@marketplace';
9
9
  exports.CONFIG_FLAGS = {
10
10
  USE_CUSTOM_OBJECT_HUBFILE: 'useCustomObjectHubfile',
11
11
  };
12
- exports.POLLING_DELAY = 2000;
13
- exports.POLLING_STATUS = {
14
- SUCCESS: 'SUCCESS',
15
- ERROR: 'ERROR',
16
- REVERTED: 'REVERTED',
17
- FAILURE: 'FAILURE',
18
- };
12
+ exports.DEFAULT_POLLING_DELAY = 2000;
19
13
  exports.PROJECT_CONFIG_FILE = 'hsproject.json';
20
14
  exports.PROJECT_BUILD_STATES = {
21
15
  BUILDING: 'BUILDING',
package/lib/polling.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http';
2
- import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
3
- import { POLLING_STATUS } from './constants';
2
+ export declare const DEFAULT_POLLING_STATES: {
3
+ readonly STARTED: "STARTED";
4
+ readonly SUCCESS: "SUCCESS";
5
+ readonly ERROR: "ERROR";
6
+ readonly REVERTED: "REVERTED";
7
+ readonly FAILURE: "FAILURE";
8
+ };
4
9
  type GenericPollingResponse = {
5
- status: ValueOf<typeof POLLING_STATUS>;
10
+ status: string;
6
11
  };
7
- type PollingCallback<T extends GenericPollingResponse> = (accountId: number, taskId: number | string) => HubSpotPromise<T>;
8
- export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>, accountId: number, taskId: number | string): Promise<T>;
12
+ type PollingCallback<T extends GenericPollingResponse> = () => HubSpotPromise<T>;
13
+ export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>, statusLookup?: {
14
+ successStates: string[];
15
+ errorStates: string[];
16
+ }): Promise<T>;
9
17
  export {};
package/lib/polling.js CHANGED
@@ -1,20 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_POLLING_STATES = void 0;
3
4
  exports.poll = poll;
4
5
  const constants_1 = require("./constants");
5
- function poll(callback, accountId, taskId) {
6
+ exports.DEFAULT_POLLING_STATES = {
7
+ STARTED: 'STARTED',
8
+ SUCCESS: 'SUCCESS',
9
+ ERROR: 'ERROR',
10
+ REVERTED: 'REVERTED',
11
+ FAILURE: 'FAILURE',
12
+ };
13
+ const DEFAULT_POLLING_STATUS_LOOKUP = {
14
+ successStates: [exports.DEFAULT_POLLING_STATES.SUCCESS],
15
+ errorStates: [
16
+ exports.DEFAULT_POLLING_STATES.ERROR,
17
+ exports.DEFAULT_POLLING_STATES.REVERTED,
18
+ exports.DEFAULT_POLLING_STATES.FAILURE,
19
+ ],
20
+ };
21
+ function poll(callback, statusLookup = DEFAULT_POLLING_STATUS_LOOKUP) {
6
22
  return new Promise((resolve, reject) => {
7
23
  const pollInterval = setInterval(async () => {
8
24
  try {
9
- const { data: pollResp } = await callback(accountId, taskId);
25
+ const { data: pollResp } = await callback();
10
26
  const { status } = pollResp;
11
- if (status === constants_1.POLLING_STATUS.SUCCESS) {
27
+ if (statusLookup.successStates.includes(status)) {
12
28
  clearInterval(pollInterval);
13
29
  resolve(pollResp);
14
30
  }
15
- else if (status === constants_1.POLLING_STATUS.ERROR ||
16
- status === constants_1.POLLING_STATUS.REVERTED ||
17
- status === constants_1.POLLING_STATUS.FAILURE) {
31
+ else if (statusLookup.errorStates.includes(status)) {
18
32
  clearInterval(pollInterval);
19
33
  reject(pollResp);
20
34
  }
@@ -23,6 +37,6 @@ function poll(callback, accountId, taskId) {
23
37
  clearInterval(pollInterval);
24
38
  reject(error);
25
39
  }
26
- }, constants_1.POLLING_DELAY);
40
+ }, constants_1.DEFAULT_POLLING_DELAY);
27
41
  });
28
42
  }
@@ -197,13 +197,13 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
197
197
  resolve(taskStatus);
198
198
  }
199
199
  }
200
- }, constants_1.POLLING_DELAY);
200
+ }, constants_1.DEFAULT_POLLING_DELAY);
201
201
  });
202
202
  };
203
203
  }
204
204
  function pollBuildAutodeployStatus(accountId, taskName, buildId) {
205
205
  return new Promise((resolve, reject) => {
206
- let maxIntervals = (30 * 1000) / constants_1.POLLING_DELAY; // Num of intervals in ~30s
206
+ let maxIntervals = (30 * 1000) / constants_1.DEFAULT_POLLING_DELAY; // Num of intervals in ~30s
207
207
  const pollInterval = setInterval(async () => {
208
208
  let build;
209
209
  try {
@@ -224,7 +224,7 @@ function pollBuildAutodeployStatus(accountId, taskName, buildId) {
224
224
  else {
225
225
  maxIntervals -= 1;
226
226
  }
227
- }, constants_1.POLLING_DELAY);
227
+ }, constants_1.DEFAULT_POLLING_DELAY);
228
228
  });
229
229
  }
230
230
  exports.pollBuildStatus = makePollTaskStatusFunc({
@@ -171,7 +171,7 @@ async function pollFetchProject(accountId, projectName) {
171
171
  reject(err);
172
172
  }
173
173
  }
174
- }, constants_1.POLLING_DELAY);
174
+ }, constants_1.DEFAULT_POLLING_DELAY);
175
175
  });
176
176
  }
177
177
  async function ensureProjectExists(accountId, projectName, { forceCreate = false, allowCreate = true, noLogs = false, withPolling = false, uploadCommand = false, } = {}) {
@@ -5,5 +5,5 @@ type ProjectUploadResult<T> = {
5
5
  result?: T;
6
6
  uploadError?: unknown;
7
7
  };
8
- export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string): Promise<ProjectUploadResult<T>>;
8
+ export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string, sendIR?: boolean): Promise<ProjectUploadResult<T>>;
9
9
  export {};
@@ -15,8 +15,11 @@ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
15
15
  const ui_1 = require("../ui");
16
16
  const lang_1 = require("../lang");
17
17
  const exitCodes_1 = require("../enums/exitCodes");
18
+ const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
19
+ const errorHandlers_1 = require("../errorHandlers");
20
+ const node_util_1 = __importDefault(require("node:util"));
18
21
  const i18nKey = 'lib.projectUpload';
19
- async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion) {
22
+ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation) {
20
23
  SpinniesManager_1.default.init({});
21
24
  const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
22
25
  SpinniesManager_1.default.add('upload', {
@@ -29,7 +32,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
29
32
  let buildId;
30
33
  let error;
31
34
  try {
32
- const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion);
35
+ const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation);
33
36
  buildId = upload.buildId;
34
37
  SpinniesManager_1.default.succeed('upload', {
35
38
  text: (0, lang_1.i18n)(`${i18nKey}.uploadProjectFiles.succeed`, {
@@ -55,7 +58,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
55
58
  }
56
59
  return { buildId, error };
57
60
  }
58
- async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage) {
61
+ async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false) {
59
62
  const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
60
63
  const filenames = fs_extra_1.default.readdirSync(srcDir);
61
64
  if (!filenames || filenames.length === 0) {
@@ -74,7 +77,27 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
74
77
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.handleProjectUpload.compressed`, {
75
78
  byteCount: archive.pointer(),
76
79
  }));
77
- const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion);
80
+ let intermediateRepresentation;
81
+ if (sendIR) {
82
+ try {
83
+ intermediateRepresentation = await (0, project_parsing_lib_1.translate)({
84
+ projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
85
+ platformVersion: projectConfig.platformVersion,
86
+ accountId,
87
+ });
88
+ logger_1.logger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
89
+ }
90
+ catch (e) {
91
+ if ((0, project_parsing_lib_1.isTranslationError)(e)) {
92
+ logger_1.logger.error(e.toString());
93
+ }
94
+ else {
95
+ (0, errorHandlers_1.logError)(e);
96
+ }
97
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
98
+ }
99
+ }
100
+ const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion, intermediateRepresentation);
78
101
  if (error) {
79
102
  resolve({ uploadError: error });
80
103
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.0.4-experimental.0",
3
+ "version": "7.0.6-experimental.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
7
7
  "dependencies": {
8
- "@hubspot/local-dev-lib": "3.1.3",
8
+ "@hubspot/local-dev-lib": "0.1.1-experimental.0",
9
+ "@hubspot/project-parsing-lib": "^0.0.2-experimental.0",
9
10
  "@hubspot/serverless-dev-runtime": "7.0.1",
10
11
  "@hubspot/theme-preview-dev-server": "0.0.10",
11
12
  "@hubspot/ui-extensions-dev-server": "0.8.40",
@@ -55,6 +56,9 @@
55
56
  "ts-node": "^10.9.2",
56
57
  "typescript": "^5.6.2"
57
58
  },
59
+ "optionalDependencies": {
60
+ "@hubspot/cms-dev-server": "^0.18.10"
61
+ },
58
62
  "scripts": {
59
63
  "build": "ts-node ./scripts/build.ts",
60
64
  "lint": "eslint . && prettier --list-different ./**/*.{js,json}",