@hubspot/cli 7.1.1 → 7.2.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 (126) hide show
  1. package/commands/create/api-sample.js +14 -4
  2. package/commands/customObject/create.d.ts +11 -0
  3. package/commands/customObject/create.js +37 -28
  4. package/commands/customObject/schema/create.d.ts +10 -0
  5. package/commands/customObject/schema/create.js +40 -42
  6. package/commands/customObject/schema/delete.d.ts +11 -0
  7. package/commands/customObject/schema/delete.js +34 -27
  8. package/commands/customObject/schema/fetch-all.d.ts +10 -0
  9. package/commands/customObject/schema/fetch-all.js +31 -24
  10. package/commands/customObject/schema/fetch.d.ts +11 -0
  11. package/commands/customObject/schema/fetch.js +34 -42
  12. package/commands/customObject/schema/list.d.ts +7 -0
  13. package/commands/customObject/schema/list.js +23 -14
  14. package/commands/customObject/schema/update.d.ts +11 -0
  15. package/commands/customObject/schema/update.js +44 -46
  16. package/commands/customObject/schema.d.ts +5 -1
  17. package/commands/customObject/schema.js +49 -11
  18. package/commands/customObject.d.ts +4 -1
  19. package/commands/customObject.js +54 -21
  20. package/commands/filemanager/fetch.d.ts +12 -0
  21. package/commands/filemanager/fetch.js +33 -30
  22. package/commands/filemanager/upload.d.ts +11 -0
  23. package/commands/filemanager/upload.js +53 -47
  24. package/commands/filemanager.d.ts +4 -1
  25. package/commands/filemanager.js +41 -7
  26. package/commands/hubdb/clear.d.ts +11 -0
  27. package/commands/hubdb/clear.js +33 -30
  28. package/commands/hubdb/create.d.ts +10 -0
  29. package/commands/hubdb/create.js +46 -40
  30. package/commands/hubdb/delete.d.ts +10 -0
  31. package/commands/hubdb/delete.js +38 -35
  32. package/commands/hubdb/fetch.d.ts +11 -0
  33. package/commands/hubdb/fetch.js +30 -27
  34. package/commands/hubdb.d.ts +4 -1
  35. package/commands/hubdb.js +45 -11
  36. package/commands/project/add.js +62 -16
  37. package/commands/project/cloneApp.js +3 -3
  38. package/commands/project/create.js +70 -15
  39. package/commands/project/dev/deprecatedFlow.d.ts +5 -0
  40. package/commands/project/dev/deprecatedFlow.js +137 -0
  41. package/commands/project/dev/index.d.ts +6 -0
  42. package/commands/project/dev/index.js +52 -0
  43. package/commands/project/dev/unifiedFlow.d.ts +5 -0
  44. package/commands/project/dev/unifiedFlow.js +112 -0
  45. package/commands/project/migrateApp.js +3 -3
  46. package/commands/project/upload.js +7 -2
  47. package/commands/sandbox/create.d.ts +12 -0
  48. package/commands/sandbox/create.js +90 -72
  49. package/commands/sandbox/delete.d.ts +11 -0
  50. package/commands/sandbox/delete.js +112 -95
  51. package/commands/sandbox.d.ts +4 -1
  52. package/commands/sandbox.js +44 -10
  53. package/commands/secret/addSecret.d.ts +10 -0
  54. package/commands/secret/addSecret.js +32 -31
  55. package/commands/secret/deleteSecret.d.ts +11 -0
  56. package/commands/secret/deleteSecret.js +31 -29
  57. package/commands/secret/listSecret.d.ts +9 -0
  58. package/commands/secret/listSecret.js +41 -0
  59. package/commands/secret/updateSecret.d.ts +10 -0
  60. package/commands/secret/updateSecret.js +33 -31
  61. package/commands/secret.d.ts +4 -1
  62. package/commands/secret.js +46 -12
  63. package/commands/theme/generate-selectors.d.ts +9 -0
  64. package/commands/theme/generate-selectors.js +61 -43
  65. package/commands/theme/marketplace-validate.d.ts +10 -0
  66. package/commands/theme/marketplace-validate.js +32 -26
  67. package/commands/theme/preview.d.ts +16 -0
  68. package/commands/theme/preview.js +104 -97
  69. package/commands/theme.d.ts +4 -1
  70. package/commands/theme.js +44 -10
  71. package/lang/en.lyaml +36 -16
  72. package/lib/DevServerManagerV2.d.ts +34 -0
  73. package/lib/DevServerManagerV2.js +85 -0
  74. package/lib/LocalDevManager.d.ts +2 -2
  75. package/lib/LocalDevManagerV2.d.ts +64 -0
  76. package/lib/LocalDevManagerV2.js +382 -0
  77. package/lib/buildAccount.d.ts +2 -3
  78. package/lib/constants.d.ts +12 -3
  79. package/lib/constants.js +13 -4
  80. package/lib/customObject.d.ts +3 -0
  81. package/lib/customObject.js +15 -0
  82. package/lib/doctor/DiagnosticInfoBuilder.d.ts +6 -0
  83. package/lib/doctor/DiagnosticInfoBuilder.js +5 -0
  84. package/lib/doctor/Doctor.d.ts +1 -0
  85. package/lib/doctor/Doctor.js +10 -0
  86. package/lib/localDev.d.ts +3 -2
  87. package/lib/localDev.js +2 -2
  88. package/lib/marketplaceValidate.d.ts +2 -2
  89. package/lib/process.d.ts +1 -0
  90. package/lib/process.js +11 -10
  91. package/lib/projects/buildAndDeploy.js +4 -1
  92. package/lib/projects/create.d.ts +5 -0
  93. package/lib/projects/create.js +51 -0
  94. package/lib/projects/index.d.ts +1 -5
  95. package/lib/projects/index.js +1 -62
  96. package/lib/projects/structure.d.ts +4 -0
  97. package/lib/projects/structure.js +9 -0
  98. package/lib/projects/upload.d.ts +1 -1
  99. package/lib/projects/upload.js +2 -2
  100. package/lib/prompts/createProjectPrompt.d.ts +6 -8
  101. package/lib/prompts/createProjectPrompt.js +26 -54
  102. package/lib/prompts/projectAddPrompt.d.ts +3 -3
  103. package/lib/prompts/projectAddPrompt.js +16 -6
  104. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -2
  105. package/lib/prompts/sandboxesPrompt.d.ts +3 -2
  106. package/lib/prompts/sandboxesPrompt.js +1 -1
  107. package/lib/sandboxSync.js +6 -2
  108. package/lib/sandboxes.d.ts +2 -5
  109. package/lib/testUtils.d.ts +12 -0
  110. package/lib/testUtils.js +10 -0
  111. package/lib/ui/index.d.ts +2 -2
  112. package/lib/ui/index.js +1 -0
  113. package/lib/upload.d.ts +1 -1
  114. package/lib/upload.js +20 -20
  115. package/lib/validation.d.ts +1 -1
  116. package/package.json +6 -5
  117. package/types/ProjectComponents.d.ts +38 -0
  118. package/types/ProjectComponents.js +3 -0
  119. package/types/Projects.d.ts +1 -6
  120. package/types/Prompts.d.ts +7 -0
  121. package/types/Sandboxes.d.ts +2 -0
  122. package/types/Yargs.d.ts +15 -0
  123. package/commands/project/dev.d.ts +0 -1
  124. package/commands/project/dev.js +0 -146
  125. package/commands/secret/listSecrets.d.ts +0 -1
  126. package/commands/secret/listSecrets.js +0 -39
@@ -0,0 +1,5 @@
1
+ import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
2
+ import { ProjectTemplate, ComponentTemplate } from '../../types/Projects';
3
+ export declare const EMPTY_PROJECT_TEMPLATE_NAME = "no-template";
4
+ export declare function getProjectComponentListFromRepo(githubRef: string): Promise<ComponentTemplate[]>;
5
+ export declare function getProjectTemplateListFromRepo(templateSource: RepoPath, githubRef: string): Promise<ProjectTemplate[]>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_PROJECT_TEMPLATE_NAME = void 0;
4
+ exports.getProjectComponentListFromRepo = getProjectComponentListFromRepo;
5
+ exports.getProjectTemplateListFromRepo = getProjectTemplateListFromRepo;
6
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
7
+ const github_1 = require("@hubspot/local-dev-lib/api/github");
8
+ const constants_1 = require("../constants");
9
+ const exitCodes_1 = require("../enums/exitCodes");
10
+ const lang_1 = require("../lang");
11
+ const index_1 = require("../errorHandlers/index");
12
+ const i18nKey = 'lib.projects.create';
13
+ exports.EMPTY_PROJECT_TEMPLATE_NAME = 'no-template';
14
+ const PROJECT_TEMPLATE_PROPERTIES = ['name', 'label', 'path', 'insertPath'];
15
+ async function getProjectComponentListFromRepo(githubRef) {
16
+ let config;
17
+ try {
18
+ const { data } = await (0, github_1.fetchRepoFile)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', githubRef);
19
+ config = data;
20
+ }
21
+ catch (err) {
22
+ (0, index_1.debugError)(err);
23
+ }
24
+ if (config) {
25
+ return config[constants_1.PROJECT_COMPONENT_TYPES.COMPONENTS] || [];
26
+ }
27
+ return [];
28
+ }
29
+ async function getProjectTemplateListFromRepo(templateSource, githubRef) {
30
+ let config;
31
+ try {
32
+ const { data } = await (0, github_1.fetchRepoFile)(templateSource, 'config.json', githubRef);
33
+ config = data;
34
+ }
35
+ catch (e) {
36
+ (0, index_1.debugError)(e);
37
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingConfigFileTemplateSource`));
38
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
39
+ }
40
+ if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
41
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
42
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
43
+ }
44
+ const templates = config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS];
45
+ const templatesContainAllProperties = templates.every(config => PROJECT_TEMPLATE_PROPERTIES.every(p => Object.prototype.hasOwnProperty.call(config, p)));
46
+ if (!templatesContainAllProperties) {
47
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingPropertiesInConfig`));
48
+ return process.exit(exitCodes_1.EXIT_CODES.ERROR);
49
+ }
50
+ return templates;
51
+ }
@@ -1,13 +1,11 @@
1
- import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
2
1
  import { Project } from '@hubspot/local-dev-lib/types/Project';
3
- import { ProjectTemplate, ProjectConfig, ProjectAddComponentData, ComponentTemplate } from '../../types/Projects';
2
+ import { ProjectConfig } from '../../types/Projects';
4
3
  export declare function writeProjectConfig(configPath: string, config: ProjectConfig): boolean;
5
4
  export declare function getIsInProject(dir?: string): boolean;
6
5
  export declare function getProjectConfig(dir?: string): Promise<{
7
6
  projectDir: string | null;
8
7
  projectConfig: ProjectConfig | null;
9
8
  }>;
10
- export declare function createProjectConfig(projectPath: string, projectName: string, template: ProjectTemplate, templateSource: RepoPath, githubRef: string): Promise<boolean>;
11
9
  export declare function validateProjectConfig(projectConfig: ProjectConfig, projectDir: string): void;
12
10
  export declare function ensureProjectExists(accountId: number, projectName: string, { forceCreate, allowCreate, noLogs, withPolling, uploadCommand, }?: {
13
11
  forceCreate?: boolean | undefined;
@@ -20,5 +18,3 @@ export declare function ensureProjectExists(accountId: number, projectName: stri
20
18
  project?: Project;
21
19
  }>;
22
20
  export declare function logFeedbackMessage(buildId: number): void;
23
- export declare function createProjectComponent(component: ProjectAddComponentData, name: string, projectComponentsVersion: string): Promise<void>;
24
- export declare function getProjectComponentsByVersion(projectComponentsVersion: string): Promise<ComponentTemplate[]>;
@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeProjectConfig = writeProjectConfig;
7
7
  exports.getIsInProject = getIsInProject;
8
8
  exports.getProjectConfig = getProjectConfig;
9
- exports.createProjectConfig = createProjectConfig;
10
9
  exports.validateProjectConfig = validateProjectConfig;
11
10
  exports.ensureProjectExists = ensureProjectExists;
12
11
  exports.logFeedbackMessage = logFeedbackMessage;
13
- exports.createProjectComponent = createProjectComponent;
14
- exports.getProjectComponentsByVersion = getProjectComponentsByVersion;
15
12
  const fs_extra_1 = __importDefault(require("fs-extra"));
16
13
  const path_1 = __importDefault(require("path"));
17
14
  const findup_sync_1 = __importDefault(require("findup-sync"));
18
15
  const logger_1 = require("@hubspot/local-dev-lib/logger");
19
- const github_1 = require("@hubspot/local-dev-lib/github");
20
16
  const projects_1 = require("@hubspot/local-dev-lib/api/projects");
21
17
  const index_1 = require("@hubspot/local-dev-lib/errors/index");
22
18
  const path_2 = require("@hubspot/local-dev-lib/path");
@@ -53,7 +49,7 @@ function getProjectConfigPath(dir) {
53
49
  return configPath;
54
50
  }
55
51
  async function getProjectConfig(dir) {
56
- const configPath = await getProjectConfigPath(dir);
52
+ const configPath = getProjectConfigPath(dir);
57
53
  if (!configPath) {
58
54
  return { projectConfig: null, projectDir: null };
59
55
  }
@@ -70,45 +66,6 @@ async function getProjectConfig(dir) {
70
66
  return { projectConfig: null, projectDir: null };
71
67
  }
72
68
  }
73
- async function createProjectConfig(projectPath, projectName, template, templateSource, githubRef) {
74
- const { projectConfig, projectDir } = await getProjectConfig(projectPath);
75
- if (projectConfig) {
76
- logger_1.logger.warn(projectPath === projectDir
77
- ? 'A project already exists in that location.'
78
- : `Found an existing project definition in ${projectDir}.`);
79
- const { shouldContinue } = await (0, promptUtils_1.promptUser)([
80
- {
81
- name: 'shouldContinue',
82
- message: () => {
83
- return projectPath === projectDir
84
- ? 'Do you want to overwrite the existing project definition with a new one?'
85
- : `Continue creating a new project in ${projectPath}?`;
86
- },
87
- type: 'confirm',
88
- default: false,
89
- },
90
- ]);
91
- if (!shouldContinue) {
92
- return false;
93
- }
94
- }
95
- const projectConfigPath = path_1.default.join(projectPath, constants_1.PROJECT_CONFIG_FILE);
96
- logger_1.logger.log(`Creating project config in ${projectPath ? projectPath : 'the current folder'}`);
97
- const hasCustomTemplateSource = Boolean(templateSource);
98
- await (0, github_1.cloneGithubRepo)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, projectPath, {
99
- sourceDir: template.path,
100
- tag: hasCustomTemplateSource ? undefined : githubRef,
101
- });
102
- const _config = JSON.parse(fs_extra_1.default.readFileSync(projectConfigPath).toString());
103
- writeProjectConfig(projectConfigPath, {
104
- ..._config,
105
- name: projectName,
106
- });
107
- if (template.name === 'no-template') {
108
- fs_extra_1.default.ensureDirSync(path_1.default.join(projectPath, 'src'));
109
- }
110
- return true;
111
- }
112
69
  function validateProjectConfig(projectConfig, projectDir) {
113
70
  if (!projectConfig) {
114
71
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.validateProjectConfig.configNotFound`, {
@@ -235,21 +192,3 @@ function logFeedbackMessage(buildId) {
235
192
  logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logFeedbackMessage.feedbackMessage`));
236
193
  }
237
194
  }
238
- async function createProjectComponent(component, name, projectComponentsVersion) {
239
- const i18nKey = 'commands.project.subcommands.add';
240
- const componentName = name;
241
- const configInfo = await getProjectConfig();
242
- if (!configInfo.projectDir || !configInfo.projectConfig) {
243
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.error.locationInProject`));
244
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
245
- }
246
- const componentPath = path_1.default.join(configInfo.projectDir, configInfo.projectConfig.srcDir, component.insertPath, componentName);
247
- await (0, github_1.cloneGithubRepo)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, componentPath, {
248
- sourceDir: component.path,
249
- tag: projectComponentsVersion,
250
- });
251
- }
252
- async function getProjectComponentsByVersion(projectComponentsVersion) {
253
- const config = await (0, github_1.fetchFileFromRepository)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', projectComponentsVersion);
254
- return config[constants_1.PROJECT_COMPONENT_TYPES.COMPONENTS] || [];
255
- }
@@ -1,4 +1,6 @@
1
1
  import { ComponentTypes, Component, GenericComponentConfig, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
2
+ import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
3
+ import { AppIRNode, CardIRNode } from '../../types/ProjectComponents';
2
4
  export declare const CONFIG_FILES: {
3
5
  [k in ComponentTypes]: string;
4
6
  };
@@ -13,3 +15,5 @@ export declare function getProjectComponentTypes(components: Array<Component>):
13
15
  export declare function getComponentUid(component?: Component | null): string | null;
14
16
  export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
15
17
  export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
18
+ export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev): component is AppIRNode;
19
+ export declare function isCardIRNode(component: IntermediateRepresentationNodeLocalDev): component is CardIRNode;
@@ -43,12 +43,15 @@ exports.getProjectComponentTypes = getProjectComponentTypes;
43
43
  exports.getComponentUid = getComponentUid;
44
44
  exports.componentIsApp = componentIsApp;
45
45
  exports.componentIsPublicApp = componentIsPublicApp;
46
+ exports.isAppIRNode = isAppIRNode;
47
+ exports.isCardIRNode = isCardIRNode;
46
48
  const fs = __importStar(require("fs"));
47
49
  const path = __importStar(require("path"));
48
50
  const fs_1 = require("@hubspot/local-dev-lib/fs");
49
51
  const logger_1 = require("@hubspot/local-dev-lib/logger");
50
52
  const index_1 = require("../errorHandlers/index");
51
53
  const Projects_1 = require("../../types/Projects");
54
+ const constants_1 = require("../constants");
52
55
  exports.CONFIG_FILES = {
53
56
  [Projects_1.ComponentTypes.PrivateApp]: 'app.json',
54
57
  [Projects_1.ComponentTypes.PublicApp]: 'public-app.json',
@@ -169,3 +172,9 @@ function componentIsApp(component) {
169
172
  function componentIsPublicApp(component) {
170
173
  return component?.type === Projects_1.ComponentTypes.PublicApp;
171
174
  }
175
+ function isAppIRNode(component) {
176
+ return component.componentType === constants_1.IR_COMPONENT_TYPES.APPLICATION;
177
+ }
178
+ function isCardIRNode(component) {
179
+ return component.componentType === constants_1.IR_COMPONENT_TYPES.CARD;
180
+ }
@@ -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, sendIR?: boolean): Promise<ProjectUploadResult<T>>;
8
+ export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string, sendIR?: boolean, skipValidation?: boolean): Promise<ProjectUploadResult<T>>;
9
9
  export {};
@@ -58,7 +58,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
58
58
  }
59
59
  return { buildId, error };
60
60
  }
61
- async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false) {
61
+ async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false, skipValidation = false) {
62
62
  const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
63
63
  const filenames = fs_extra_1.default.readdirSync(srcDir);
64
64
  if (!filenames || filenames.length === 0) {
@@ -84,7 +84,7 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
84
84
  projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
85
85
  platformVersion: projectConfig.platformVersion,
86
86
  accountId,
87
- });
87
+ }, { skipValidation });
88
88
  logger_1.logger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
89
89
  }
90
90
  catch (e) {
@@ -1,14 +1,12 @@
1
- import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
2
1
  import { ProjectTemplate } from '../../types/Projects';
3
2
  type CreateProjectPromptResponse = {
4
3
  name: string;
5
4
  dest: string;
6
- template: ProjectTemplate;
5
+ projectTemplate?: ProjectTemplate;
7
6
  };
8
- export declare function createProjectPrompt(githubRef: string, promptOptions: {
9
- name: string;
10
- dest: string;
11
- template: string;
12
- templateSource: RepoPath;
13
- }, skipTemplatePrompt?: boolean): Promise<CreateProjectPromptResponse>;
7
+ export declare function createProjectPrompt(promptOptions: {
8
+ name?: string;
9
+ dest?: string;
10
+ template?: string;
11
+ }, projectTemplates?: ProjectTemplate[]): Promise<CreateProjectPromptResponse>;
14
12
  export {};
@@ -7,52 +7,17 @@ exports.createProjectPrompt = createProjectPrompt;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const path_2 = require("@hubspot/local-dev-lib/path");
10
- const github_1 = require("@hubspot/local-dev-lib/github");
11
- const logger_1 = require("@hubspot/local-dev-lib/logger");
12
- const constants_1 = require("../constants");
13
10
  const promptUtils_1 = require("./promptUtils");
14
11
  const lang_1 = require("../lang");
15
- const exitCodes_1 = require("../enums/exitCodes");
16
12
  const i18nKey = 'lib.prompts.createProjectPrompt';
17
- const PROJECT_TEMPLATE_PROPERTIES = ['name', 'label', 'path', 'insertPath'];
18
- function hasAllProperties(projectList) {
19
- return projectList.every(config => PROJECT_TEMPLATE_PROPERTIES.every(p => Object.prototype.hasOwnProperty.call(config, p)));
20
- }
21
- async function createTemplateOptions(templateSource, githubRef) {
22
- const hasCustomTemplateSource = Boolean(templateSource);
23
- const branch = hasCustomTemplateSource
24
- ? constants_1.DEFAULT_PROJECT_TEMPLATE_BRANCH
25
- : githubRef;
26
- let config;
27
- try {
28
- config = await (0, github_1.fetchFileFromRepository)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
29
- }
30
- catch (e) {
31
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingConfigFileTemplateSource`));
32
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
33
- }
34
- if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
35
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
36
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
37
- }
38
- if (!hasAllProperties(config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS])) {
39
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingPropertiesInConfig`));
40
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
41
- }
42
- return config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS];
43
- }
44
- function findTemplate(projectTemplates, templateNameOrLabel) {
13
+ function findTemplateByNameOrLabel(projectTemplates, templateNameOrLabel) {
45
14
  return projectTemplates.find(t => t.name === templateNameOrLabel || t.label === templateNameOrLabel);
46
15
  }
47
- async function createProjectPrompt(githubRef, promptOptions, skipTemplatePrompt = false) {
48
- let projectTemplates = [];
49
- let selectedTemplate;
50
- if (!skipTemplatePrompt) {
51
- projectTemplates = await createTemplateOptions(promptOptions.templateSource, githubRef);
52
- selectedTemplate =
53
- promptOptions.template &&
54
- findTemplate(projectTemplates, promptOptions.template);
55
- }
16
+ async function createProjectPrompt(promptOptions, projectTemplates) {
17
+ const createProjectFromTemplate = !!projectTemplates && projectTemplates.length > 0;
18
+ const providedTemplateIsValid = createProjectFromTemplate &&
19
+ !!promptOptions.template &&
20
+ !!findTemplateByNameOrLabel(projectTemplates, promptOptions.template);
56
21
  const result = await (0, promptUtils_1.promptUser)([
57
22
  {
58
23
  name: 'name',
@@ -70,7 +35,7 @@ async function createProjectPrompt(githubRef, promptOptions, skipTemplatePrompt
70
35
  message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
71
36
  when: !promptOptions.dest,
72
37
  default: answers => {
73
- const projectName = (0, path_2.sanitizeFileName)(answers.name || promptOptions.name);
38
+ const projectName = (0, path_2.sanitizeFileName)(promptOptions.name || answers.name);
74
39
  return path_1.default.resolve((0, path_2.getCwd)(), projectName);
75
40
  },
76
41
  validate: (input) => {
@@ -90,27 +55,34 @@ async function createProjectPrompt(githubRef, promptOptions, skipTemplatePrompt
90
55
  },
91
56
  },
92
57
  {
93
- name: 'template',
58
+ name: 'projectTemplate',
94
59
  message: () => {
95
- return promptOptions.template &&
96
- !findTemplate(projectTemplates, promptOptions.template)
60
+ return promptOptions.template && !providedTemplateIsValid
97
61
  ? (0, lang_1.i18n)(`${i18nKey}.errors.invalidTemplate`, {
98
62
  template: promptOptions.template,
99
63
  })
100
64
  : (0, lang_1.i18n)(`${i18nKey}.selectTemplate`);
101
65
  },
102
- when: !skipTemplatePrompt && !selectedTemplate,
66
+ when: createProjectFromTemplate && !providedTemplateIsValid,
103
67
  type: 'list',
104
- choices: projectTemplates.map(template => {
105
- return {
106
- name: template.label,
107
- value: template,
108
- };
109
- }),
68
+ choices: createProjectFromTemplate
69
+ ? projectTemplates.map(template => {
70
+ return {
71
+ name: template.label,
72
+ value: template,
73
+ };
74
+ })
75
+ : undefined,
110
76
  },
111
77
  ]);
112
- if (selectedTemplate) {
113
- result.template = selectedTemplate;
78
+ if (!result.name) {
79
+ result.name = promptOptions.name;
80
+ }
81
+ if (!result.dest) {
82
+ result.dest = promptOptions.dest;
83
+ }
84
+ if (providedTemplateIsValid) {
85
+ result.projectTemplate = findTemplateByNameOrLabel(projectTemplates, promptOptions.template);
114
86
  }
115
87
  return result;
116
88
  }
@@ -1,9 +1,9 @@
1
- import { ProjectAddComponentData } from '../../types/Projects';
1
+ import { ComponentTemplate } from '../../types/Projects';
2
2
  type ProjectAddPromptResponse = {
3
- component: ProjectAddComponentData;
3
+ componentTemplate: ComponentTemplate;
4
4
  name: string;
5
5
  };
6
- export declare function projectAddPrompt(components: ProjectAddComponentData[], promptOptions?: {
6
+ export declare function projectAddPrompt(components: ComponentTemplate[], promptOptions?: {
7
7
  name?: string;
8
8
  type?: string;
9
9
  }): Promise<ProjectAddPromptResponse>;
@@ -4,20 +4,23 @@ exports.projectAddPrompt = projectAddPrompt;
4
4
  const promptUtils_1 = require("./promptUtils");
5
5
  const lang_1 = require("../lang");
6
6
  const i18nKey = 'lib.prompts.projectAddPrompt';
7
+ function findComponentByPathOrLabel(components, componentPathOrLabel) {
8
+ return components.find(c => c.path === componentPathOrLabel || c.label === componentPathOrLabel);
9
+ }
7
10
  async function projectAddPrompt(components, promptOptions = {}) {
8
- return (0, promptUtils_1.promptUser)([
11
+ const providedTypeIsValid = !!promptOptions.type &&
12
+ !!findComponentByPathOrLabel(components, promptOptions.type);
13
+ const result = await (0, promptUtils_1.promptUser)([
9
14
  {
10
- name: 'component',
15
+ name: 'componentTemplate',
11
16
  message: () => {
12
- return promptOptions.type &&
13
- !components.find(t => t.path === promptOptions.type)
17
+ return promptOptions.type && !providedTypeIsValid
14
18
  ? (0, lang_1.i18n)(`${i18nKey}.errors.invalidType`, {
15
19
  type: promptOptions.type,
16
20
  })
17
21
  : (0, lang_1.i18n)(`${i18nKey}.selectType`);
18
22
  },
19
- when: !promptOptions.type ||
20
- !components.find(t => t.path === promptOptions.type),
23
+ when: !providedTypeIsValid,
21
24
  type: 'list',
22
25
  choices: components.map(type => {
23
26
  return {
@@ -38,4 +41,11 @@ async function projectAddPrompt(components, promptOptions = {}) {
38
41
  },
39
42
  },
40
43
  ]);
44
+ if (!result.name) {
45
+ result.name = promptOptions.name;
46
+ }
47
+ if (providedTypeIsValid) {
48
+ result.componentTemplate = findComponentByPathOrLabel(components, promptOptions.type);
49
+ }
50
+ return result;
41
51
  }
@@ -1,6 +1,7 @@
1
1
  import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
2
  import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
3
- export declare function selectSandboxTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
4
- export declare function selectDeveloperTestTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
3
+ import { ProjectDevTargetAccountPromptResponse } from '../../types/Prompts';
4
+ export declare function selectSandboxTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<ProjectDevTargetAccountPromptResponse>;
5
+ export declare function selectDeveloperTestTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<ProjectDevTargetAccountPromptResponse>;
5
6
  export declare function confirmDefaultAccountPrompt(accountName: string, accountType: string): Promise<boolean>;
6
7
  export declare function confirmUseExistingDeveloperTestAccountPrompt(account: DeveloperTestAccount): Promise<boolean>;
@@ -1,9 +1,10 @@
1
+ import { SandboxAccountType } from '../../types/Sandboxes';
1
2
  type SandboxTypePromptResponse = {
2
- type: string;
3
+ type: SandboxAccountType;
3
4
  };
4
5
  type DeleteSandboxPromptResponse = {
5
6
  account: string;
6
7
  };
7
8
  export declare function sandboxTypePrompt(): Promise<SandboxTypePromptResponse>;
8
- export declare function deleteSandboxPrompt(promptParentAccount?: boolean): Promise<DeleteSandboxPromptResponse> | void;
9
+ export declare function deleteSandboxPrompt(promptParentAccount?: boolean): Promise<DeleteSandboxPromptResponse | undefined>;
9
10
  export {};
@@ -52,7 +52,7 @@ function deleteSandboxPrompt(promptParentAccount = false) {
52
52
  ? mapNonSandboxAccountChoices(accountsList)
53
53
  : mapSandboxAccountChoices(accountsList);
54
54
  if (!choices.length) {
55
- return;
55
+ return Promise.resolve(undefined);
56
56
  }
57
57
  return (0, promptUtils_1.promptUser)([
58
58
  {
@@ -26,8 +26,12 @@ async function syncSandbox(accountConfig, parentAccountConfig, env, syncTasks, s
26
26
  const isDevSandbox = (0, accountTypes_1.isDevelopmentSandbox)(accountConfig);
27
27
  if (!accountId || !parentAccountId) {
28
28
  throw new Error((0, lang_1.i18n)(`${i18nKey}.failure.invalidUser`, {
29
- accountName: (0, ui_1.uiAccountDescription)(accountId),
30
- parentAccountName: (0, ui_1.uiAccountDescription)(parentAccountId),
29
+ accountName: accountId
30
+ ? (0, ui_1.uiAccountDescription)(accountId)
31
+ : id.toString(),
32
+ parentAccountName: parentAccountId
33
+ ? (0, ui_1.uiAccountDescription)(parentAccountId)
34
+ : parentId.toString(),
31
35
  }));
32
36
  }
33
37
  SpinniesManager_1.default.init({
@@ -1,14 +1,11 @@
1
1
  import { AccountType, CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
2
  import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
- import { SandboxSyncTask } from '../types/Sandboxes';
3
+ import { SandboxSyncTask, SandboxAccountType } from '../types/Sandboxes';
4
4
  export declare const SYNC_TYPES: {
5
5
  readonly OBJECT_RECORDS: "object-records";
6
6
  };
7
7
  export declare const SANDBOX_TYPE_MAP: {
8
- readonly dev: "DEVELOPMENT_SANDBOX";
9
- readonly developer: "DEVELOPMENT_SANDBOX";
10
- readonly development: "DEVELOPMENT_SANDBOX";
11
- readonly standard: "STANDARD_SANDBOX";
8
+ [key: string]: SandboxAccountType;
12
9
  };
13
10
  export declare const SANDBOX_API_TYPE_MAP: {
14
11
  readonly STANDARD_SANDBOX: 1;
@@ -0,0 +1,12 @@
1
+ import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError';
2
+ type MockResponse = {
3
+ status: number;
4
+ data: {
5
+ message?: string;
6
+ errorType?: string;
7
+ category?: string;
8
+ subCategory?: string;
9
+ };
10
+ };
11
+ export declare const makeHubSpotHttpError: (message: string, response: MockResponse) => HubSpotHttpError;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeHubSpotHttpError = void 0;
4
+ const HubSpotHttpError_1 = require("@hubspot/local-dev-lib/models/HubSpotHttpError");
5
+ const makeHubSpotHttpError = (message, response) => {
6
+ return new HubSpotHttpError_1.HubSpotHttpError(message, {
7
+ cause: { isAxiosError: true, response },
8
+ });
9
+ };
10
+ exports.makeHubSpotHttpError = makeHubSpotHttpError;
package/lib/ui/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export declare function uiLink(linkText: string, url: string): string;
8
8
  export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
9
9
  export declare function uiInfoSection(title: string, logContent: () => void): void;
10
10
  export declare function uiCommandReference(command: string): string;
11
- export declare function uiFeatureHighlight(commands: string[], title: string): void;
12
- export declare function uiBetaTag(message: string, log?: boolean): void | string;
11
+ export declare function uiFeatureHighlight(commands: string[], title?: string): void;
12
+ export declare function uiBetaTag(message: string, log?: boolean): string | undefined;
13
13
  export declare function uiDeprecatedTag(message: string): void;
14
14
  export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
15
15
  export declare function uiDeprecatedDescription(message: string, command: string, url?: string): void;
package/lib/ui/index.js CHANGED
@@ -100,6 +100,7 @@ function uiBetaTag(message, log = true) {
100
100
  const result = `${terminalUISupport.color ? chalk_1.default.hex(exports.UI_COLORS.SORBET)(tag) : tag} ${message}`;
101
101
  if (log) {
102
102
  logger_1.logger.log(result);
103
+ return;
103
104
  }
104
105
  else {
105
106
  return result;
package/lib/upload.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export declare function getUploadableFileList(src: string, convertFields: boolean): Promise<string[]>;
package/lib/upload.js CHANGED
@@ -1,46 +1,49 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const path = require('path');
5
- const { walk } = require('@hubspot/local-dev-lib/fs');
6
- const { createIgnoreFilter } = require('@hubspot/local-dev-lib/ignoreRules');
7
- const { fieldsJsPrompt } = require('./prompts/cmsFieldPrompt');
8
- const { isAllowedExtension } = require('@hubspot/local-dev-lib/path');
9
- const { isConvertableFieldJs, } = require('@hubspot/local-dev-lib/cms/handleFieldsJS');
10
- const { logError } = require('./errorHandlers/index');
6
+ exports.getUploadableFileList = getUploadableFileList;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = require("@hubspot/local-dev-lib/fs");
9
+ const ignoreRules_1 = require("@hubspot/local-dev-lib/ignoreRules");
10
+ const handleFieldsJS_1 = require("@hubspot/local-dev-lib/cms/handleFieldsJS");
11
+ const path_2 = require("@hubspot/local-dev-lib/path");
12
+ const cmsFieldPrompt_1 = require("./prompts/cmsFieldPrompt");
13
+ const index_1 = require("./errorHandlers/index");
11
14
  /*
12
15
  * Walks the src folder for files, filters them based on ignore filter.
13
16
  * If convertFields is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
14
17
  */
15
- const getUploadableFileList = async (src, convertFields) => {
18
+ async function getUploadableFileList(src, convertFields) {
16
19
  let filePaths = [];
17
20
  try {
18
- filePaths = await walk(src);
21
+ filePaths = await (0, fs_1.walk)(src);
19
22
  }
20
23
  catch (e) {
21
- logError(e);
24
+ (0, index_1.logError)(e);
22
25
  }
23
26
  const allowedFiles = filePaths
24
27
  .filter(file => {
25
- if (!isAllowedExtension(file)) {
28
+ if (!(0, path_2.isAllowedExtension)(file)) {
26
29
  return false;
27
30
  }
28
31
  return true;
29
32
  })
30
- .filter(createIgnoreFilter());
33
+ .filter((0, ignoreRules_1.createIgnoreFilter)(false));
31
34
  if (!convertFields) {
32
35
  return allowedFiles;
33
36
  }
34
37
  const uploadableFiles = [];
35
38
  let skipFiles = [];
36
39
  for (const filePath of allowedFiles) {
37
- const fileName = path.basename(filePath);
40
+ const fileName = path_1.default.basename(filePath);
38
41
  if (skipFiles.includes(filePath))
39
42
  continue;
40
- const isConvertable = isConvertableFieldJs(src, filePath, convertFields);
43
+ const isConvertable = (0, handleFieldsJS_1.isConvertableFieldJs)(src, filePath, convertFields);
41
44
  if (isConvertable || fileName == 'fields.json') {
42
45
  // This prompt checks if there are multiple field files in the folder and gets user to choose.
43
- const [choice, updatedSkipFiles] = await fieldsJsPrompt(filePath, src, skipFiles);
46
+ const [choice, updatedSkipFiles] = await (0, cmsFieldPrompt_1.fieldsJsPrompt)(filePath, src, skipFiles);
44
47
  skipFiles = updatedSkipFiles;
45
48
  // If they chose something other than the current file, move on.
46
49
  if (choice !== filePath)
@@ -49,7 +52,4 @@ const getUploadableFileList = async (src, convertFields) => {
49
52
  uploadableFiles.push(filePath);
50
53
  }
51
54
  return uploadableFiles;
52
- };
53
- module.exports = {
54
- getUploadableFileList,
55
- };
55
+ }
@@ -10,4 +10,4 @@ export declare function validateCmsPublishMode(options: Arguments<{
10
10
  cmsPublishMode?: CmsPublishMode;
11
11
  }>): boolean;
12
12
  export declare function fileExists(_path: string): boolean;
13
- export declare function checkAndConvertToJson(_path: string): object | null;
13
+ export declare function checkAndConvertToJson(_path: string): unknown | null;