@hubspot/cli 7.3.0-experimental.2 → 7.4.0-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.
Files changed (52) hide show
  1. package/bin/cli.js +27 -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/app/migrate.d.ts +7 -0
  9. package/commands/app/migrate.js +94 -0
  10. package/commands/app.d.ts +6 -0
  11. package/commands/app.js +23 -0
  12. package/commands/cms/convertFields.js +5 -6
  13. package/commands/cms/getReactModule.js +7 -8
  14. package/commands/cms/lighthouseScore.js +15 -16
  15. package/commands/config/set.js +6 -7
  16. package/commands/create/api-sample.js +6 -7
  17. package/commands/create/module.js +1 -2
  18. package/commands/create/template.js +1 -2
  19. package/commands/customObject/create.js +8 -9
  20. package/commands/customObject/schema/create.js +5 -6
  21. package/commands/customObject/schema/delete.js +9 -10
  22. package/commands/customObject/schema/fetch-all.js +7 -8
  23. package/commands/customObject/schema/fetch.js +9 -10
  24. package/commands/customObject/schema/list.js +2 -3
  25. package/commands/customObject/schema/update.js +7 -8
  26. package/commands/customObject/schema.js +1 -2
  27. package/commands/filemanager/fetch.js +5 -6
  28. package/commands/filemanager/upload.js +12 -13
  29. package/commands/function/deploy.js +9 -10
  30. package/commands/function/list.js +4 -5
  31. package/commands/function/server.js +7 -8
  32. package/commands/project/cloneApp.d.ts +9 -1
  33. package/commands/project/cloneApp.js +91 -76
  34. package/commands/project/migrateApp.d.ts +9 -1
  35. package/commands/project/migrateApp.js +43 -170
  36. package/lang/en.lyaml +32 -0
  37. package/lib/app/migrate.d.ts +7 -0
  38. package/lib/app/migrate.js +345 -0
  39. package/lib/dependencyManagement.d.ts +5 -0
  40. package/lib/dependencyManagement.js +47 -22
  41. package/lib/doctor/Doctor.js +1 -2
  42. package/lib/polling.d.ts +4 -0
  43. package/lib/polling.js +3 -3
  44. package/lib/prompts/promptUtils.d.ts +6 -4
  45. package/lib/prompts/promptUtils.js +3 -1
  46. package/lib/ui/index.d.ts +2 -2
  47. package/lib/ui/index.js +6 -5
  48. package/package.json +3 -3
  49. package/types/Prompts.d.ts +2 -2
  50. package/types/Yargs.d.ts +10 -0
  51. package/lib/npm.d.ts +0 -9
  52. package/lib/npm.js +0 -36
@@ -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
  }
package/lib/polling.d.ts CHANGED
@@ -6,6 +6,10 @@ export declare const DEFAULT_POLLING_STATES: {
6
6
  readonly REVERTED: "REVERTED";
7
7
  readonly FAILURE: "FAILURE";
8
8
  };
9
+ export declare const DEFAULT_POLLING_STATUS_LOOKUP: {
10
+ successStates: "SUCCESS"[];
11
+ errorStates: ("FAILURE" | "ERROR" | "REVERTED")[];
12
+ };
9
13
  type GenericPollingResponse = {
10
14
  status: string;
11
15
  };
package/lib/polling.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_POLLING_STATES = void 0;
3
+ exports.DEFAULT_POLLING_STATUS_LOOKUP = exports.DEFAULT_POLLING_STATES = void 0;
4
4
  exports.poll = poll;
5
5
  const constants_1 = require("./constants");
6
6
  exports.DEFAULT_POLLING_STATES = {
@@ -10,7 +10,7 @@ exports.DEFAULT_POLLING_STATES = {
10
10
  REVERTED: 'REVERTED',
11
11
  FAILURE: 'FAILURE',
12
12
  };
13
- const DEFAULT_POLLING_STATUS_LOOKUP = {
13
+ exports.DEFAULT_POLLING_STATUS_LOOKUP = {
14
14
  successStates: [exports.DEFAULT_POLLING_STATES.SUCCESS],
15
15
  errorStates: [
16
16
  exports.DEFAULT_POLLING_STATES.ERROR,
@@ -18,7 +18,7 @@ const DEFAULT_POLLING_STATUS_LOOKUP = {
18
18
  exports.DEFAULT_POLLING_STATES.FAILURE,
19
19
  ],
20
20
  };
21
- function poll(callback, statusLookup = DEFAULT_POLLING_STATUS_LOOKUP) {
21
+ function poll(callback, statusLookup = exports.DEFAULT_POLLING_STATUS_LOOKUP) {
22
22
  return new Promise((resolve, reject) => {
23
23
  const pollInterval = setInterval(async () => {
24
24
  try {
@@ -4,10 +4,12 @@ export declare function confirmPrompt(message: string, options?: {
4
4
  defaultAnswer?: boolean;
5
5
  when?: PromptWhen;
6
6
  }): Promise<boolean>;
7
- export declare function listPrompt(message: string, { choices, when, }: {
8
- choices: PromptChoices;
7
+ export declare function listPrompt<T = string>(message: string, { choices, when, }: {
8
+ choices: PromptChoices<T>;
9
9
  when?: PromptWhen;
10
- }): Promise<string>;
11
- export declare function inputPrompt(message: string, { when, }?: {
10
+ }): Promise<T>;
11
+ export declare function inputPrompt(message: string, { when, validate, defaultAnswer, }?: {
12
12
  when?: boolean | (() => boolean);
13
+ validate?: (input: string) => boolean | string;
14
+ defaultAnswer?: string;
13
15
  }): Promise<string>;
@@ -34,13 +34,15 @@ async function listPrompt(message, { choices, when, }) {
34
34
  ]);
35
35
  return choice;
36
36
  }
37
- async function inputPrompt(message, { when, } = {}) {
37
+ async function inputPrompt(message, { when, validate, defaultAnswer, } = {}) {
38
38
  const { input } = await promptUser([
39
39
  {
40
40
  name: 'input',
41
41
  type: 'input',
42
+ default: defaultAnswer,
42
43
  message,
43
44
  when,
45
+ validate,
44
46
  },
45
47
  ]);
46
48
  return input;
package/lib/ui/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare function uiCommandReference(command: string, withQuotes?: boolean
11
11
  export declare function uiFeatureHighlight(features: string[], title?: string): void;
12
12
  export declare function uiBetaTag(message: string, log?: true): undefined;
13
13
  export declare function uiBetaTag(message: string, log: false): string;
14
- export declare function uiDeprecatedTag(message: string): void;
14
+ export declare function uiDeprecatedTag(message: string, log?: boolean): string | undefined;
15
15
  export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
16
- export declare function uiDeprecatedDescription(message: string, command: string, url?: string): void;
16
+ export declare function uiDeprecatedDescription(message: string, command: string, url?: string): string | undefined;
17
17
  export declare function uiDeprecatedMessage(command: string, url?: string, message?: string): void;
package/lib/ui/index.js CHANGED
@@ -102,16 +102,17 @@ function uiBetaTag(message, log = true) {
102
102
  logger_1.logger.log(result);
103
103
  return;
104
104
  }
105
- else {
106
- return result;
107
- }
105
+ return result;
108
106
  }
109
- function uiDeprecatedTag(message) {
107
+ function uiDeprecatedTag(message, log = true) {
110
108
  const i18nKey = 'lib.ui';
111
109
  const terminalUISupport = getTerminalUISupport();
112
110
  const tag = (0, lang_1.i18n)(`${i18nKey}.deprecatedTag`);
113
111
  const result = `${terminalUISupport.color ? chalk_1.default.yellow(tag) : tag} ${message}`;
114
- logger_1.logger.log(result);
112
+ if (log) {
113
+ logger_1.logger.log(result);
114
+ }
115
+ return result;
115
116
  }
116
117
  function uiCommandDisabledBanner(command, url, message) {
117
118
  const i18nKey = 'lib.ui';
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.4.0-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.4.1",
8
+ "@hubspot/local-dev-lib": "0.3.0-experimental.0",
9
9
  "@hubspot/project-parsing-lib": "0.1.4",
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",
@@ -3,9 +3,9 @@ export type GenericPromptResponse = {
3
3
  [key: string]: any;
4
4
  };
5
5
  type PromptType = 'confirm' | 'list' | 'checkbox' | 'input' | 'password' | 'number' | 'rawlist';
6
- export type PromptChoices = Array<string | {
6
+ export type PromptChoices<T = any> = Array<string | {
7
7
  name: string;
8
- value?: any;
8
+ value?: T;
9
9
  disabled?: string | boolean;
10
10
  }>;
11
11
  export type PromptWhen = boolean | (() => boolean);
package/types/Yargs.d.ts CHANGED
@@ -27,3 +27,13 @@ export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs;
27
27
  export type TestingArgs = {
28
28
  qa?: boolean;
29
29
  };
30
+ export type MigrateAppOptions = CommonArgs & AccountArgs & EnvironmentArgs & ConfigArgs & {
31
+ name: string;
32
+ dest: string;
33
+ appId: number;
34
+ platformVersion: string;
35
+ };
36
+ export type CloneAppArgs = ConfigArgs & EnvironmentArgs & AccountArgs & CommonArgs & {
37
+ dest: string;
38
+ appId: number;
39
+ };
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>;
package/lib/npm.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_PACKAGE_MANAGER = void 0;
7
- exports.isGloballyInstalled = isGloballyInstalled;
8
- exports.getLatestCliVersion = getLatestCliVersion;
9
- exports.executeInstall = executeInstall;
10
- const child_process_1 = require("child_process");
11
- const util_1 = __importDefault(require("util"));
12
- const logger_1 = require("@hubspot/local-dev-lib/logger");
13
- const package_json_1 = __importDefault(require("../package.json"));
14
- exports.DEFAULT_PACKAGE_MANAGER = 'npm';
15
- async function isGloballyInstalled() {
16
- const exec = util_1.default.promisify(child_process_1.exec);
17
- try {
18
- await exec(`${exports.DEFAULT_PACKAGE_MANAGER} --version`);
19
- return true;
20
- }
21
- catch (e) {
22
- return false;
23
- }
24
- }
25
- async function getLatestCliVersion() {
26
- const exec = util_1.default.promisify(child_process_1.exec);
27
- const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
28
- const { latest, next } = JSON.parse(stdout);
29
- return { latest, next };
30
- }
31
- async function executeInstall(packages = [], flags, options) {
32
- const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
33
- logger_1.logger.debug('Running ', installCommand);
34
- const exec = util_1.default.promisify(child_process_1.exec);
35
- await exec(installCommand, options);
36
- }