@hubspot/cli 6.4.0 → 7.0.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.
- package/bin/cli.js +110 -16
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +4 -4
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -39
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/dependencyManagement.d.ts +4 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +11 -6
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +3 -2
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +12 -6
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
package/lib/doctor/Doctor.js
CHANGED
|
@@ -39,7 +39,8 @@ class Doctor {
|
|
|
39
39
|
SpinniesManager_1.default.add('runningDiagnostics', {
|
|
40
40
|
text: i18n(`${i18nKey}.runningDiagnostics`),
|
|
41
41
|
});
|
|
42
|
-
this.diagnosticInfo =
|
|
42
|
+
this.diagnosticInfo =
|
|
43
|
+
await this.diagnosticInfoBuilder.generateDiagnosticInfo();
|
|
43
44
|
this.projectConfig = this.diagnosticInfo?.project.config;
|
|
44
45
|
this.diagnosis = new Diagnosis_1.Diagnosis({
|
|
45
46
|
diagnosticInfo: this.diagnosticInfo,
|
|
@@ -189,8 +190,11 @@ class Doctor {
|
|
|
189
190
|
}
|
|
190
191
|
async checkCLIVersion() {
|
|
191
192
|
let latestCLIVersion;
|
|
193
|
+
let nextCliVersion;
|
|
192
194
|
try {
|
|
193
|
-
|
|
195
|
+
const { latest, next } = await (0, dependencyManagement_1.getLatestCliVersion)();
|
|
196
|
+
latestCLIVersion = latest;
|
|
197
|
+
nextCliVersion = next;
|
|
194
198
|
}
|
|
195
199
|
catch (e) {
|
|
196
200
|
return this.diagnosis?.addCliSection({
|
|
@@ -202,14 +206,15 @@ class Doctor {
|
|
|
202
206
|
}),
|
|
203
207
|
});
|
|
204
208
|
}
|
|
205
|
-
if (latestCLIVersion !== package_json_1.default.version) {
|
|
209
|
+
if (latestCLIVersion !== package_json_1.default.version && nextCliVersion !== package_json_1.default.version) {
|
|
210
|
+
const onNextTag = package_json_1.default.version.includes('beta');
|
|
206
211
|
this.diagnosis?.addCliSection({
|
|
207
212
|
type: 'warning',
|
|
208
213
|
message: i18n(`${i18nKey}.hsChecks.notLatest`, {
|
|
209
214
|
hsVersion: package_json_1.default.version,
|
|
210
215
|
}),
|
|
211
216
|
secondaryMessaging: i18n(`${i18nKey}.hsChecks.notLatestSecondary`, {
|
|
212
|
-
hsVersion:
|
|
217
|
+
hsVersion: onNextTag ? nextCliVersion : latestCLIVersion,
|
|
213
218
|
command: (0, ui_1.uiCommandReference)(`npm install -g ${package_json_1.default.name}`),
|
|
214
219
|
}),
|
|
215
220
|
});
|
|
@@ -229,7 +234,7 @@ class Doctor {
|
|
|
229
234
|
for (const packageFile of this.diagnosticInfo?.packageFiles || []) {
|
|
230
235
|
const packageDirName = path_1.default.dirname(packageFile);
|
|
231
236
|
try {
|
|
232
|
-
const needsInstall = await (0, dependencyManagement_1.hasMissingPackages)(path_1.default.join(this.projectConfig?.projectDir, packageDirName));
|
|
237
|
+
const needsInstall = await (0, dependencyManagement_1.hasMissingPackages)(path_1.default.join(this.projectConfig?.projectDir || '', packageDirName));
|
|
233
238
|
if (needsInstall) {
|
|
234
239
|
foundError = true;
|
|
235
240
|
this.diagnosis?.addProjectSection({
|
|
@@ -285,7 +290,7 @@ class Doctor {
|
|
|
285
290
|
async checkProjectConfigJsonFiles() {
|
|
286
291
|
let foundError = false;
|
|
287
292
|
for (const jsonFile of this.diagnosticInfo?.jsonFiles || []) {
|
|
288
|
-
const fileToCheck = path_1.default.join(this.projectConfig?.projectDir, jsonFile);
|
|
293
|
+
const fileToCheck = path_1.default.join(this.projectConfig?.projectDir || '', jsonFile);
|
|
289
294
|
if (!(await this.isValidJsonFile(fileToCheck))) {
|
|
290
295
|
foundError = true;
|
|
291
296
|
this.diagnosis?.addProjectSection({
|
|
@@ -1 +1,20 @@
|
|
|
1
|
+
export declare function getMaxFieldsDepth(): number;
|
|
2
|
+
export declare function findFieldsJsonPath(basePath: string): string | null;
|
|
3
|
+
export declare function combineThemeCss(basePath: string, cssString?: string): string | null;
|
|
4
|
+
type Field = {
|
|
5
|
+
name: string;
|
|
6
|
+
children: Field[];
|
|
7
|
+
selectors?: string[];
|
|
8
|
+
inherited_value?: {
|
|
9
|
+
property_value_paths?: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function setPreviewSelectors(fields: Field[], fieldPath: string[], selectors: string[], depth?: number): Field[];
|
|
15
|
+
export declare function generateInheritedSelectors(fields: Field[]): Field[];
|
|
16
|
+
type SelectorsMap = {
|
|
17
|
+
[key: string]: string[] | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare function generateSelectorsMap(fields: Field[], fieldKey?: string[]): SelectorsMap;
|
|
1
20
|
export {};
|
package/lib/generateSelectors.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
exports.getMaxFieldsDepth = getMaxFieldsDepth;
|
|
7
|
+
exports.findFieldsJsonPath = findFieldsJsonPath;
|
|
8
|
+
exports.combineThemeCss = combineThemeCss;
|
|
9
|
+
exports.setPreviewSelectors = setPreviewSelectors;
|
|
10
|
+
exports.generateInheritedSelectors = generateInheritedSelectors;
|
|
11
|
+
exports.generateSelectorsMap = generateSelectorsMap;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
15
|
+
const lang_1 = require("./lang");
|
|
8
16
|
const CSS_COMMENTS_REGEX = new RegExp(/\/\*.*\*\//, 'g');
|
|
9
17
|
const CSS_PSEUDO_CLASS_REGEX = new RegExp(/:active|:checked|:disabled|:empty|:enabled|:first-of-type|:focus|:hover|:in-range|:invalid|:link|:optional|:out-of-range|:read-only|:read-write|:required|:target|:valid|:visited/, 'g');
|
|
10
18
|
const i18nKey = 'commands.theme.subcommands.generateSelectors';
|
|
@@ -14,19 +22,19 @@ function getMaxFieldsDepth() {
|
|
|
14
22
|
}
|
|
15
23
|
function findFieldsJsonPath(basePath) {
|
|
16
24
|
const _path = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
17
|
-
if (!
|
|
18
|
-
logger.error(i18n(`${i18nKey}.errors.invalidPath`, {
|
|
25
|
+
if (!fs_1.default.existsSync(_path)) {
|
|
26
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
|
|
19
27
|
themePath: basePath,
|
|
20
28
|
}));
|
|
21
|
-
process.exit(EXIT_CODES.ERROR);
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
22
30
|
}
|
|
23
|
-
const files =
|
|
31
|
+
const files = fs_1.default.readdirSync(_path);
|
|
24
32
|
if (files.includes('fields.json')) {
|
|
25
33
|
return `${_path}/fields.json`;
|
|
26
34
|
}
|
|
27
35
|
for (let i = 0; i < files.length; i++) {
|
|
28
36
|
const fileName = files[i];
|
|
29
|
-
const isDirectory =
|
|
37
|
+
const isDirectory = fs_1.default.lstatSync(`${_path}/${fileName}`).isDirectory();
|
|
30
38
|
if (isDirectory && !fileName.includes('.module')) {
|
|
31
39
|
const fieldsJsonPath = findFieldsJsonPath(`${_path}/${fileName}`);
|
|
32
40
|
if (fieldsJsonPath)
|
|
@@ -37,16 +45,16 @@ function findFieldsJsonPath(basePath) {
|
|
|
37
45
|
}
|
|
38
46
|
function combineThemeCss(basePath, cssString = '') {
|
|
39
47
|
const _path = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
40
|
-
const isDirectory =
|
|
48
|
+
const isDirectory = fs_1.default.lstatSync(_path).isDirectory();
|
|
41
49
|
if (isDirectory) {
|
|
42
|
-
const filesList =
|
|
50
|
+
const filesList = fs_1.default.readdirSync(_path);
|
|
43
51
|
return filesList.reduce((css, fileName) => {
|
|
44
52
|
const newCss = combineThemeCss(`${_path}/${fileName}`);
|
|
45
53
|
return newCss ? `${css}\n${newCss}` : css;
|
|
46
54
|
}, cssString);
|
|
47
55
|
}
|
|
48
56
|
else if (_path.includes('.css') && !_path.includes('.module')) {
|
|
49
|
-
return `${cssString}\n${
|
|
57
|
+
return `${cssString}\n${fs_1.default.readFileSync(_path, 'utf8')}`;
|
|
50
58
|
}
|
|
51
59
|
return null;
|
|
52
60
|
}
|
|
@@ -78,7 +86,7 @@ function setPreviewSelectors(fields, fieldPath, selectors, depth = 0) {
|
|
|
78
86
|
}
|
|
79
87
|
function generateInheritedSelectors(fields) {
|
|
80
88
|
let finalFieldsJson = [...fields];
|
|
81
|
-
|
|
89
|
+
function _generateInheritedSelectors(fieldsToCheck) {
|
|
82
90
|
fieldsToCheck.forEach(field => {
|
|
83
91
|
if (field.children) {
|
|
84
92
|
_generateInheritedSelectors(field.children);
|
|
@@ -94,7 +102,7 @@ function generateInheritedSelectors(fields) {
|
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
104
|
});
|
|
97
|
-
}
|
|
105
|
+
}
|
|
98
106
|
_generateInheritedSelectors(fields);
|
|
99
107
|
return finalFieldsJson;
|
|
100
108
|
}
|
|
@@ -115,11 +123,3 @@ function generateSelectorsMap(fields, fieldKey = []) {
|
|
|
115
123
|
});
|
|
116
124
|
return selectorsMap;
|
|
117
125
|
}
|
|
118
|
-
module.exports = {
|
|
119
|
-
findFieldsJsonPath,
|
|
120
|
-
combineThemeCss,
|
|
121
|
-
setPreviewSelectors,
|
|
122
|
-
generateInheritedSelectors,
|
|
123
|
-
generateSelectorsMap,
|
|
124
|
-
getMaxFieldsDepth,
|
|
125
|
-
};
|
package/lib/localDev.js
CHANGED
|
@@ -19,7 +19,8 @@ const { i18n } = require('./lang');
|
|
|
19
19
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
20
20
|
const { trackCommandMetadataUsage } = require('./usageTracking');
|
|
21
21
|
const { isAppDeveloperAccount, isDeveloperTestAccount, } = require('./accountTypes');
|
|
22
|
-
const { handleProjectUpload
|
|
22
|
+
const { handleProjectUpload } = require('./projects/upload');
|
|
23
|
+
const { pollProjectBuildAndDeploy } = require('./projects/buildAndDeploy');
|
|
23
24
|
const { PROJECT_ERROR_TYPES, PROJECT_BUILD_TEXT, PROJECT_DEPLOY_TEXT, } = require('./constants');
|
|
24
25
|
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
25
26
|
const { PERSONAL_ACCESS_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
|
|
@@ -71,7 +72,7 @@ const checkIfParentAccountIsAuthed = accountConfig => {
|
|
|
71
72
|
// Confirm the default account is a developer account if developing public apps
|
|
72
73
|
const checkIfAccountFlagIsSupported = (accountConfig, hasPublicApps) => {
|
|
73
74
|
if (hasPublicApps) {
|
|
74
|
-
if (!isDeveloperTestAccount) {
|
|
75
|
+
if (!isDeveloperTestAccount(accountConfig)) {
|
|
75
76
|
logger.error(i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
|
|
76
77
|
useCommand: uiCommandReference('hs accounts use'),
|
|
77
78
|
devCommand: uiCommandReference('hs project dev'),
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { GetValidationResultsResponse } from '@hubspot/local-dev-lib/types/MarketplaceValidation';
|
|
2
|
+
export declare function kickOffValidation(accountId: number, assetType: string, src: string): Promise<number>;
|
|
3
|
+
export declare function pollForValidationFinish(accountId: number, validationId: string): Promise<void>;
|
|
4
|
+
export declare function fetchValidationResults(accountId: number, validationId: string): Promise<GetValidationResultsResponse>;
|
|
5
|
+
export declare function processValidationErrors(i18nKey: string, validationResults: GetValidationResultsResponse): void;
|
|
6
|
+
export declare function displayValidationResults(i18nKey: string, validationResults: GetValidationResultsResponse): void;
|
|
@@ -1,16 +1,23 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
6
|
+
exports.kickOffValidation = kickOffValidation;
|
|
7
|
+
exports.pollForValidationFinish = pollForValidationFinish;
|
|
8
|
+
exports.fetchValidationResults = fetchValidationResults;
|
|
9
|
+
exports.processValidationErrors = processValidationErrors;
|
|
10
|
+
exports.displayValidationResults = displayValidationResults;
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const marketplaceValidation_1 = require("@hubspot/local-dev-lib/api/marketplaceValidation");
|
|
13
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
|
+
const lang_1 = require("./lang");
|
|
15
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
9
16
|
const SLEEP_TIME = 2000;
|
|
10
|
-
|
|
17
|
+
async function kickOffValidation(accountId, assetType, src) {
|
|
11
18
|
const requestGroup = 'EXTERNAL_DEVELOPER';
|
|
12
19
|
try {
|
|
13
|
-
const { data: requestResult } = await requestValidation(accountId, {
|
|
20
|
+
const { data: requestResult } = await (0, marketplaceValidation_1.requestValidation)(accountId, {
|
|
14
21
|
path: src,
|
|
15
22
|
assetType,
|
|
16
23
|
requestGroup,
|
|
@@ -18,14 +25,14 @@ const kickOffValidation = async (accountId, assetType, src) => {
|
|
|
18
25
|
return requestResult;
|
|
19
26
|
}
|
|
20
27
|
catch (err) {
|
|
21
|
-
logger.debug(err);
|
|
22
|
-
process.exit(EXIT_CODES.ERROR);
|
|
28
|
+
logger_1.logger.debug(err);
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
23
30
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
31
|
+
}
|
|
32
|
+
async function pollForValidationFinish(accountId, validationId) {
|
|
26
33
|
try {
|
|
27
34
|
const checkValidationStatus = async () => {
|
|
28
|
-
const { data: validationStatus } = await getValidationStatus(accountId, {
|
|
35
|
+
const { data: validationStatus } = await (0, marketplaceValidation_1.getValidationStatus)(accountId, {
|
|
29
36
|
validationId,
|
|
30
37
|
});
|
|
31
38
|
if (validationStatus === 'REQUESTED') {
|
|
@@ -36,89 +43,81 @@ const pollForValidationFinish = async (accountId, validationId) => {
|
|
|
36
43
|
await checkValidationStatus();
|
|
37
44
|
}
|
|
38
45
|
catch (err) {
|
|
39
|
-
logger.debug(err);
|
|
40
|
-
process.exit(EXIT_CODES.ERROR);
|
|
46
|
+
logger_1.logger.debug(err);
|
|
47
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
41
48
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
49
|
+
}
|
|
50
|
+
async function fetchValidationResults(accountId, validationId) {
|
|
44
51
|
try {
|
|
45
|
-
const { data: validationResults } = await getValidationResults(accountId, {
|
|
52
|
+
const { data: validationResults } = await (0, marketplaceValidation_1.getValidationResults)(accountId, {
|
|
46
53
|
validationId,
|
|
47
54
|
});
|
|
48
55
|
return validationResults;
|
|
49
56
|
}
|
|
50
57
|
catch (err) {
|
|
51
|
-
logger.debug(err);
|
|
52
|
-
process.exit(EXIT_CODES.ERROR);
|
|
58
|
+
logger_1.logger.debug(err);
|
|
59
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
60
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
61
|
+
}
|
|
62
|
+
function processValidationErrors(i18nKey, validationResults) {
|
|
56
63
|
if (validationResults.errors.length) {
|
|
57
64
|
const { assetPath, errors } = validationResults;
|
|
58
65
|
errors.forEach(err => {
|
|
59
66
|
if (err.failureReasonType === 'DOWNLOAD_EMPTY') {
|
|
60
|
-
logger.error(i18n(`${i18nKey}.errors.invalidPath`, {
|
|
67
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
|
|
61
68
|
path: assetPath,
|
|
62
69
|
}));
|
|
63
70
|
}
|
|
64
71
|
else {
|
|
65
|
-
logger.error(`${err.context}`);
|
|
72
|
+
logger_1.logger.error(`${err.context}`);
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
|
-
process.exit(EXIT_CODES.ERROR);
|
|
75
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
69
76
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
displayFileInfo(val.file, val.line);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
if (status === 'PASS') {
|
|
101
|
-
logger.success(i18n(`${i18nKey}.results.noErrors`));
|
|
102
|
-
results.forEach(test => {
|
|
103
|
-
if (test.status === 'WARN') {
|
|
104
|
-
logger.warn(`${test.message}`);
|
|
105
|
-
displayFileInfo(test.file, test.line);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
77
|
+
}
|
|
78
|
+
function displayFileInfo(file, line, i18nKey) {
|
|
79
|
+
if (file) {
|
|
80
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.file`, {
|
|
81
|
+
file,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
if (line) {
|
|
85
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.lineNumber`, {
|
|
86
|
+
line,
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function displayResults(checks, i18nKey) {
|
|
91
|
+
if (checks) {
|
|
92
|
+
const { status, results } = checks;
|
|
93
|
+
if (status === 'FAIL') {
|
|
94
|
+
const failedValidations = results.filter(test => test.status === 'FAIL');
|
|
95
|
+
const warningValidations = results.filter(test => test.status === 'WARN');
|
|
96
|
+
failedValidations.forEach(val => {
|
|
97
|
+
logger_1.logger.error(`${val.message}`);
|
|
98
|
+
displayFileInfo(val.file, val.line, i18nKey);
|
|
99
|
+
});
|
|
100
|
+
warningValidations.forEach(val => {
|
|
101
|
+
logger_1.logger.warn(`${val.message}`);
|
|
102
|
+
displayFileInfo(val.file, val.line, i18nKey);
|
|
103
|
+
});
|
|
109
104
|
}
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
if (status === 'PASS') {
|
|
106
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.results.noErrors`));
|
|
107
|
+
results.forEach(test => {
|
|
108
|
+
if (test.status === 'WARN') {
|
|
109
|
+
logger_1.logger.warn(`${test.message}`);
|
|
110
|
+
displayFileInfo(test.file, test.line, i18nKey);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
function displayValidationResults(i18nKey, validationResults) {
|
|
112
118
|
Object.keys(validationResults.results).forEach(type => {
|
|
113
|
-
logger.log(
|
|
114
|
-
displayResults(validationResults.results[type]);
|
|
115
|
-
logger.log();
|
|
119
|
+
logger_1.logger.log(chalk_1.default.bold((0, lang_1.i18n)(`${i18nKey}.results.${type.toLowerCase()}`)));
|
|
120
|
+
displayResults(validationResults.results[type], i18nKey);
|
|
121
|
+
logger_1.logger.log();
|
|
116
122
|
});
|
|
117
|
-
}
|
|
118
|
-
module.exports = {
|
|
119
|
-
kickOffValidation,
|
|
120
|
-
pollForValidationFinish,
|
|
121
|
-
fetchValidationResults,
|
|
122
|
-
processValidationErrors,
|
|
123
|
-
displayValidationResults,
|
|
124
|
-
};
|
|
123
|
+
}
|
package/lib/oauth.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { OAuth2ManagerAccountConfig } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
|
+
export declare function authenticateWithOauth(accountConfig: OAuth2ManagerAccountConfig): Promise<void>;
|
package/lib/oauth.js
CHANGED
|
@@ -1,38 +1,53 @@
|
|
|
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
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
6
|
+
exports.authenticateWithOauth = authenticateWithOauth;
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const open_1 = __importDefault(require("open"));
|
|
9
|
+
const OAuth2Manager_1 = require("@hubspot/local-dev-lib/models/OAuth2Manager");
|
|
10
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
11
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
12
|
+
const oauth_1 = require("@hubspot/local-dev-lib/oauth");
|
|
13
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
14
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
15
|
+
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
16
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
17
|
+
const process_1 = require("./process");
|
|
18
|
+
const lang_1 = require("./lang");
|
|
19
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
13
20
|
const PORT = 3000;
|
|
14
21
|
const redirectUri = `http://localhost:${PORT}/oauth-callback`;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const i18nKey = 'lib.oauth';
|
|
23
|
+
function buildAuthUrl(oauthManager) {
|
|
24
|
+
const { env: accountEnv, clientId, scopes: accountScopes, } = oauthManager.account;
|
|
25
|
+
const env = accountEnv || environments_1.ENVIRONMENTS.PROD;
|
|
26
|
+
const scopes = accountScopes || auth_1.DEFAULT_OAUTH_SCOPES;
|
|
27
|
+
if (!clientId) {
|
|
28
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.missingClientId`));
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
|
+
}
|
|
31
|
+
return (`${(0, urls_1.getHubSpotWebsiteOrigin)(env)}/oauth/${oauthManager.account.accountId}/authorize` +
|
|
32
|
+
`?client_id=${encodeURIComponent(clientId)}` + // app's client ID
|
|
33
|
+
`&scope=${encodeURIComponent(scopes.join(' '))}` + // scopes being requested by the app
|
|
19
34
|
`&redirect_uri=${encodeURIComponent(redirectUri)}` // where to send the user after the consent page
|
|
20
35
|
);
|
|
21
|
-
}
|
|
22
|
-
|
|
36
|
+
}
|
|
37
|
+
function handleServerOnProcessEnd(server) {
|
|
23
38
|
const shutdownServerIfRunning = () => {
|
|
24
39
|
server?.close();
|
|
25
40
|
};
|
|
26
|
-
handleExit(shutdownServerIfRunning);
|
|
27
|
-
}
|
|
28
|
-
|
|
41
|
+
(0, process_1.handleExit)(shutdownServerIfRunning);
|
|
42
|
+
}
|
|
43
|
+
async function authorize(oauthManager) {
|
|
29
44
|
if (process.env.BROWSER !== 'none') {
|
|
30
|
-
|
|
45
|
+
(0, open_1.default)(buildAuthUrl(oauthManager), { url: true });
|
|
31
46
|
}
|
|
32
47
|
// eslint-disable-next-line no-async-promise-executor
|
|
33
48
|
return new Promise(async (resolve, reject) => {
|
|
34
49
|
let server;
|
|
35
|
-
const app =
|
|
50
|
+
const app = (0, express_1.default)();
|
|
36
51
|
app.get('/oauth-callback', async (req, res) => {
|
|
37
52
|
if (req.query.code) {
|
|
38
53
|
const authCodeProof = {
|
|
@@ -69,24 +84,21 @@ const authorize = async (oauthManager) => {
|
|
|
69
84
|
reject();
|
|
70
85
|
}
|
|
71
86
|
});
|
|
72
|
-
server = app.listen(PORT, () => logger.log(`Waiting for authorization...`));
|
|
87
|
+
server = app.listen(PORT, () => logger_1.logger.log(`Waiting for authorization...`));
|
|
73
88
|
handleServerOnProcessEnd(server);
|
|
74
89
|
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const accountId =
|
|
78
|
-
const config = getAccountConfig(accountId)
|
|
79
|
-
return new OAuth2Manager({
|
|
90
|
+
}
|
|
91
|
+
function setupOauth(accountConfig) {
|
|
92
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
93
|
+
const config = (0, config_1.getAccountConfig)(accountId);
|
|
94
|
+
return new OAuth2Manager_1.OAuth2Manager({
|
|
80
95
|
...accountConfig,
|
|
81
|
-
|
|
96
|
+
env: accountConfig.env || config?.env || environments_1.ENVIRONMENTS.PROD,
|
|
82
97
|
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const oauthManager = setupOauth(
|
|
86
|
-
logger.log('Authorizing');
|
|
98
|
+
}
|
|
99
|
+
async function authenticateWithOauth(accountConfig) {
|
|
100
|
+
const oauthManager = setupOauth(accountConfig);
|
|
101
|
+
logger_1.logger.log('Authorizing');
|
|
87
102
|
await authorize(oauthManager);
|
|
88
|
-
addOauthToAccountConfig(oauthManager);
|
|
89
|
-
}
|
|
90
|
-
module.exports = {
|
|
91
|
-
authenticateWithOauth,
|
|
92
|
-
};
|
|
103
|
+
(0, oauth_1.addOauthToAccountConfig)(oauthManager);
|
|
104
|
+
}
|
package/lib/polling.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
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';
|
|
4
|
+
type GenericPollingResponse = {
|
|
5
|
+
status: ValueOf<typeof POLLING_STATUS>;
|
|
6
|
+
};
|
|
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>;
|
|
1
9
|
export {};
|
package/lib/polling.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
exports.poll = poll;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
function poll(callback, accountId, taskId) {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
7
|
const pollInterval = setInterval(async () => {
|
|
8
8
|
try {
|
|
9
9
|
const { data: pollResp } = await callback(accountId, taskId);
|
|
10
10
|
const { status } = pollResp;
|
|
11
|
-
if (status === POLLING_STATUS.SUCCESS) {
|
|
11
|
+
if (status === constants_1.POLLING_STATUS.SUCCESS) {
|
|
12
12
|
clearInterval(pollInterval);
|
|
13
13
|
resolve(pollResp);
|
|
14
14
|
}
|
|
15
|
-
else if (status === POLLING_STATUS.ERROR ||
|
|
16
|
-
status === POLLING_STATUS.REVERTED ||
|
|
17
|
-
status === POLLING_STATUS.FAILURE) {
|
|
15
|
+
else if (status === constants_1.POLLING_STATUS.ERROR ||
|
|
16
|
+
status === constants_1.POLLING_STATUS.REVERTED ||
|
|
17
|
+
status === constants_1.POLLING_STATUS.FAILURE) {
|
|
18
18
|
clearInterval(pollInterval);
|
|
19
19
|
reject(pollResp);
|
|
20
20
|
}
|
|
@@ -23,9 +23,6 @@ const poll = (callback, accountId, taskId) => {
|
|
|
23
23
|
clearInterval(pollInterval);
|
|
24
24
|
reject(error);
|
|
25
25
|
}
|
|
26
|
-
}, POLLING_DELAY);
|
|
26
|
+
}, constants_1.POLLING_DELAY);
|
|
27
27
|
});
|
|
28
|
-
}
|
|
29
|
-
module.exports = {
|
|
30
|
-
poll,
|
|
31
|
-
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AppFunctionComponentMetadata } from '@hubspot/local-dev-lib/types/ComponentStructure';
|
|
2
|
+
declare class _ProjectLogsManager {
|
|
3
|
+
projectName: string | undefined;
|
|
4
|
+
projectId: number | undefined;
|
|
5
|
+
accountId: number | undefined;
|
|
6
|
+
functions: AppFunctionComponentMetadata[];
|
|
7
|
+
selectedFunction: AppFunctionComponentMetadata | undefined;
|
|
8
|
+
functionName: string | undefined;
|
|
9
|
+
appId: number | undefined;
|
|
10
|
+
isPublicFunction: boolean | undefined;
|
|
11
|
+
endpointName: string | undefined;
|
|
12
|
+
reset(): void;
|
|
13
|
+
constructor();
|
|
14
|
+
init(accountId: number): Promise<void>;
|
|
15
|
+
fetchFunctionDetails(): Promise<void>;
|
|
16
|
+
getFunctionNames(): string[];
|
|
17
|
+
setFunction(functionName: string): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const ProjectLogsManager: _ProjectLogsManager;
|
|
20
|
+
export {};
|