@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
|
@@ -1,41 +1,43 @@
|
|
|
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
|
|
13
|
-
const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, DEFAULT_PROJECT_TEMPLATE_BRANCH, } = require('../constants');
|
|
6
|
+
exports.createProjectPrompt = createProjectPrompt;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
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
|
+
const promptUtils_1 = require("./promptUtils");
|
|
14
|
+
const lang_1 = require("../lang");
|
|
15
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
14
16
|
const i18nKey = 'lib.prompts.createProjectPrompt';
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return projectList.every(config =>
|
|
18
|
-
}
|
|
19
|
-
|
|
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) {
|
|
20
22
|
const hasCustomTemplateSource = Boolean(templateSource);
|
|
21
23
|
const branch = hasCustomTemplateSource
|
|
22
|
-
? DEFAULT_PROJECT_TEMPLATE_BRANCH
|
|
24
|
+
? constants_1.DEFAULT_PROJECT_TEMPLATE_BRANCH
|
|
23
25
|
: githubRef;
|
|
24
|
-
const config = await fetchFileFromRepository(templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
|
|
25
|
-
if (!config || !config[PROJECT_COMPONENT_TYPES.PROJECTS]) {
|
|
26
|
-
logger.error(i18n(`${i18nKey}.errors.noProjectsInConfig`));
|
|
27
|
-
process.exit(EXIT_CODES.ERROR);
|
|
26
|
+
const config = await (0, github_1.fetchFileFromRepository)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
|
|
27
|
+
if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
|
|
28
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
28
30
|
}
|
|
29
|
-
if (!hasAllProperties(config[PROJECT_COMPONENT_TYPES.PROJECTS])) {
|
|
30
|
-
logger.error(i18n(`${i18nKey}.errors.missingPropertiesInConfig`));
|
|
31
|
-
process.exit(EXIT_CODES.ERROR);
|
|
31
|
+
if (!hasAllProperties(config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS])) {
|
|
32
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingPropertiesInConfig`));
|
|
33
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
32
34
|
}
|
|
33
|
-
return config[PROJECT_COMPONENT_TYPES.PROJECTS];
|
|
34
|
-
}
|
|
35
|
+
return config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS];
|
|
36
|
+
}
|
|
35
37
|
function findTemplate(projectTemplates, templateNameOrLabel) {
|
|
36
38
|
return projectTemplates.find(t => t.name === templateNameOrLabel || t.label === templateNameOrLabel);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
async function createProjectPrompt(githubRef, promptOptions, skipTemplatePrompt = false) {
|
|
39
41
|
let projectTemplates = [];
|
|
40
42
|
let selectedTemplate;
|
|
41
43
|
if (!skipTemplatePrompt) {
|
|
@@ -44,40 +46,40 @@ const createProjectPrompt = async (githubRef, promptOptions = {}, skipTemplatePr
|
|
|
44
46
|
promptOptions.template &&
|
|
45
47
|
findTemplate(projectTemplates, promptOptions.template);
|
|
46
48
|
}
|
|
47
|
-
const result = await promptUser([
|
|
49
|
+
const result = await (0, promptUtils_1.promptUser)([
|
|
48
50
|
{
|
|
49
51
|
name: 'name',
|
|
50
|
-
message: i18n(`${i18nKey}.enterName`),
|
|
52
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
|
|
51
53
|
when: !promptOptions.name,
|
|
52
|
-
validate: input => {
|
|
54
|
+
validate: (input) => {
|
|
53
55
|
if (!input) {
|
|
54
|
-
return i18n(`${i18nKey}.errors.nameRequired`);
|
|
56
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.nameRequired`);
|
|
55
57
|
}
|
|
56
58
|
return true;
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
{
|
|
60
|
-
name: '
|
|
61
|
-
message: i18n(`${i18nKey}.
|
|
62
|
-
when: !promptOptions.
|
|
62
|
+
name: 'dest',
|
|
63
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
|
|
64
|
+
when: !promptOptions.dest,
|
|
63
65
|
default: answers => {
|
|
64
|
-
const projectName = sanitizeFileName(answers.name || promptOptions.name);
|
|
65
|
-
return
|
|
66
|
+
const projectName = (0, path_2.sanitizeFileName)(answers.name || promptOptions.name);
|
|
67
|
+
return path_1.default.resolve((0, path_2.getCwd)(), projectName);
|
|
66
68
|
},
|
|
67
|
-
validate: input => {
|
|
69
|
+
validate: (input) => {
|
|
68
70
|
if (!input) {
|
|
69
|
-
return i18n(`${i18nKey}.errors.
|
|
71
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
|
|
70
72
|
}
|
|
71
|
-
if (
|
|
72
|
-
return i18n(`${i18nKey}.errors.
|
|
73
|
+
if (fs_1.default.existsSync(input)) {
|
|
74
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidDest`);
|
|
73
75
|
}
|
|
74
|
-
if (!isValidPath(input)) {
|
|
75
|
-
return i18n(`${i18nKey}.errors.invalidCharacters`);
|
|
76
|
+
if (!(0, path_2.isValidPath)(input)) {
|
|
77
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidCharacters`);
|
|
76
78
|
}
|
|
77
79
|
return true;
|
|
78
80
|
},
|
|
79
81
|
filter: input => {
|
|
80
|
-
return untildify(input);
|
|
82
|
+
return (0, path_2.untildify)(input);
|
|
81
83
|
},
|
|
82
84
|
},
|
|
83
85
|
{
|
|
@@ -85,10 +87,10 @@ const createProjectPrompt = async (githubRef, promptOptions = {}, skipTemplatePr
|
|
|
85
87
|
message: () => {
|
|
86
88
|
return promptOptions.template &&
|
|
87
89
|
!findTemplate(projectTemplates, promptOptions.template)
|
|
88
|
-
? i18n(`${i18nKey}.errors.invalidTemplate`, {
|
|
90
|
+
? (0, lang_1.i18n)(`${i18nKey}.errors.invalidTemplate`, {
|
|
89
91
|
template: promptOptions.template,
|
|
90
92
|
})
|
|
91
|
-
: i18n(`${i18nKey}.selectTemplate`);
|
|
93
|
+
: (0, lang_1.i18n)(`${i18nKey}.selectTemplate`);
|
|
92
94
|
},
|
|
93
95
|
when: !skipTemplatePrompt && !selectedTemplate,
|
|
94
96
|
type: 'list',
|
|
@@ -104,7 +106,4 @@ const createProjectPrompt = async (githubRef, promptOptions = {}, skipTemplatePr
|
|
|
104
106
|
result.template = selectedTemplate;
|
|
105
107
|
}
|
|
106
108
|
return result;
|
|
107
|
-
}
|
|
108
|
-
module.exports = {
|
|
109
|
-
createProjectPrompt,
|
|
110
|
-
};
|
|
109
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
declare const templateTypeChoices: {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}[];
|
|
5
|
+
interface CreateTemplatePromptResponse {
|
|
6
|
+
templateType: (typeof templateTypeChoices)[number]['value'];
|
|
7
|
+
}
|
|
8
|
+
export declare function createTemplatePrompt(): Promise<CreateTemplatePromptResponse>;
|
|
1
9
|
export {};
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.createTemplatePrompt = createTemplatePrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
6
|
const i18nKey = 'lib.prompts.createTemplatePrompt';
|
|
7
|
+
const templateTypeChoices = [
|
|
8
|
+
{ name: 'page', value: 'page-template' },
|
|
9
|
+
{ name: 'email', value: 'email-template' },
|
|
10
|
+
{ name: 'partial', value: 'partial' },
|
|
11
|
+
{ name: 'global partial', value: 'global-partial' },
|
|
12
|
+
{ name: 'blog listing', value: 'blog-listing-template' },
|
|
13
|
+
{ name: 'blog post', value: 'blog-post-template' },
|
|
14
|
+
{ name: 'search results', value: 'search-template' },
|
|
15
|
+
];
|
|
7
16
|
const TEMPLATE_TYPE_PROMPT = {
|
|
8
17
|
type: 'list',
|
|
9
18
|
name: 'templateType',
|
|
10
|
-
message: i18n(`${i18nKey}.selectTemplate`),
|
|
19
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectTemplate`),
|
|
11
20
|
default: 'page',
|
|
12
|
-
choices:
|
|
13
|
-
{ name: 'page', value: 'page-template' },
|
|
14
|
-
{ name: 'email', value: 'email-template' },
|
|
15
|
-
{ name: 'partial', value: 'partial' },
|
|
16
|
-
{ name: 'global partial', value: 'global-partial' },
|
|
17
|
-
{ name: 'blog listing', value: 'blog-listing-template' },
|
|
18
|
-
{ name: 'blog post', value: 'blog-post-template' },
|
|
19
|
-
{ name: 'search results', value: 'search-template' },
|
|
20
|
-
],
|
|
21
|
+
choices: templateTypeChoices,
|
|
21
22
|
};
|
|
22
23
|
function createTemplatePrompt() {
|
|
23
|
-
return promptUser([TEMPLATE_TYPE_PROMPT]);
|
|
24
|
+
return (0, promptUtils_1.promptUser)([TEMPLATE_TYPE_PROMPT]);
|
|
24
25
|
}
|
|
25
|
-
module.exports = {
|
|
26
|
-
createTemplatePrompt,
|
|
27
|
-
};
|
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
exports.downloadProjectPrompt = downloadProjectPrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
6
|
+
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
7
|
+
const index_1 = require("../errorHandlers/index");
|
|
8
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
10
|
+
const lang_1 = require("../lang");
|
|
10
11
|
const i18nKey = 'lib.prompts.downloadProjectPrompt';
|
|
11
|
-
|
|
12
|
+
async function createProjectsList(accountId) {
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
if (accountId) {
|
|
15
|
+
const { data: projects } = await (0, projects_1.fetchProjects)(accountId);
|
|
16
|
+
return projects.results;
|
|
17
|
+
}
|
|
18
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountIdRequired`));
|
|
19
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
15
20
|
}
|
|
16
21
|
catch (e) {
|
|
17
|
-
logError(e, new ApiErrorContext({ accountId }));
|
|
18
|
-
process.exit(EXIT_CODES.ERROR);
|
|
22
|
+
(0, index_1.logError)(e, accountId ? new index_1.ApiErrorContext({ accountId }) : undefined);
|
|
23
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
19
24
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const accountId = getAccountId(promptOptions.account);
|
|
25
|
+
}
|
|
26
|
+
async function downloadProjectPrompt(promptOptions) {
|
|
27
|
+
const accountId = (0, config_1.getAccountId)(promptOptions.account);
|
|
23
28
|
const projectsList = await createProjectsList(accountId);
|
|
24
|
-
return promptUser([
|
|
29
|
+
return (0, promptUtils_1.promptUser)([
|
|
25
30
|
{
|
|
26
31
|
name: 'project',
|
|
27
32
|
message: () => {
|
|
28
33
|
return promptOptions.project &&
|
|
29
34
|
!projectsList.find(p => p.name === promptOptions.name)
|
|
30
|
-
? i18n(`${i18nKey}.errors.projectNotFound`, {
|
|
35
|
+
? (0, lang_1.i18n)(`${i18nKey}.errors.projectNotFound`, {
|
|
31
36
|
projectName: promptOptions.project,
|
|
32
|
-
accountId,
|
|
37
|
+
accountId: accountId || '',
|
|
33
38
|
})
|
|
34
|
-
: i18n(`${i18nKey}.selectProject`);
|
|
39
|
+
: (0, lang_1.i18n)(`${i18nKey}.selectProject`);
|
|
35
40
|
},
|
|
36
41
|
when: !promptOptions.project ||
|
|
37
42
|
!projectsList.find(p => p.name === promptOptions.project),
|
|
@@ -44,7 +49,4 @@ const downloadProjectPrompt = async (promptOptions = {}) => {
|
|
|
44
49
|
}),
|
|
45
50
|
},
|
|
46
51
|
]);
|
|
47
|
-
}
|
|
48
|
-
module.exports = {
|
|
49
|
-
downloadProjectPrompt,
|
|
50
|
-
};
|
|
52
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId: number, scopes: string[], redirectUrls: string[], isReinstall?: boolean): Promise<void>;
|
|
@@ -1,38 +1,40 @@
|
|
|
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
|
|
6
|
+
exports.installPublicAppPrompt = installPublicAppPrompt;
|
|
7
|
+
const open_1 = __importDefault(require("open"));
|
|
8
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const promptUtils_1 = require("./promptUtils");
|
|
11
|
+
const lang_1 = require("../lang");
|
|
12
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
10
13
|
const i18nKey = 'lib.prompts.installPublicAppPrompt';
|
|
11
|
-
|
|
12
|
-
logger.log('');
|
|
14
|
+
async function installPublicAppPrompt(env, targetAccountId, clientId, scopes, redirectUrls, isReinstall = false) {
|
|
15
|
+
logger_1.logger.log('');
|
|
13
16
|
if (isReinstall) {
|
|
14
|
-
logger.log(i18n(`${i18nKey}.reinstallExplanation`));
|
|
17
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.reinstallExplanation`));
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
logger.log(i18n(`${i18nKey}.explanation`));
|
|
20
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.explanation`));
|
|
18
21
|
}
|
|
19
|
-
const { shouldOpenBrowser } = await promptUser({
|
|
22
|
+
const { shouldOpenBrowser } = await (0, promptUtils_1.promptUser)({
|
|
20
23
|
name: 'shouldOpenBrowser',
|
|
21
24
|
type: 'confirm',
|
|
22
|
-
message: i18n(isReinstall ? `${i18nKey}.reinstallPrompt` : `${i18nKey}.prompt`),
|
|
25
|
+
message: (0, lang_1.i18n)(isReinstall ? `${i18nKey}.reinstallPrompt` : `${i18nKey}.prompt`),
|
|
23
26
|
});
|
|
24
27
|
if (!isReinstall && !shouldOpenBrowser) {
|
|
25
|
-
logger.log(i18n(`${i18nKey}.decline`));
|
|
26
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
28
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.decline`));
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
27
30
|
}
|
|
28
31
|
else if (!shouldOpenBrowser) {
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
|
-
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
34
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
32
35
|
const url = `${websiteOrigin}/oauth/${targetAccountId}/authorize` +
|
|
33
36
|
`?client_id=${encodeURIComponent(clientId)}` +
|
|
34
37
|
`&scope=${encodeURIComponent(scopes.join(' '))}` +
|
|
35
38
|
`&redirect_uri=${encodeURIComponent(redirectUrls[0])}`;
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
module.exports = { installPublicAppPrompt };
|
|
39
|
+
(0, open_1.default)(url);
|
|
40
|
+
}
|
|
@@ -1 +1,29 @@
|
|
|
1
|
+
import { PromptConfig } from '../../types/Prompts';
|
|
2
|
+
type PersonalAccessKeyPromptResponse = {
|
|
3
|
+
personalAccessKey: string;
|
|
4
|
+
env: string;
|
|
5
|
+
};
|
|
6
|
+
type AccountIdPromptResponse = {
|
|
7
|
+
accountId: number;
|
|
8
|
+
};
|
|
9
|
+
type ClientIdPromptResponse = {
|
|
10
|
+
clientId: string;
|
|
11
|
+
};
|
|
12
|
+
type ClientSecretPromptResponse = {
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
};
|
|
15
|
+
type ScopesPromptResponse = {
|
|
16
|
+
scopes: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Displays notification to user that we are about to open the browser,
|
|
20
|
+
* then opens their browser to the personal-access-key shortlink
|
|
21
|
+
*/
|
|
22
|
+
export declare function personalAccessKeyPrompt({ env, account, }: {
|
|
23
|
+
env: string;
|
|
24
|
+
account?: string;
|
|
25
|
+
}): Promise<PersonalAccessKeyPromptResponse>;
|
|
26
|
+
export declare const OAUTH_FLOW: (PromptConfig<{
|
|
27
|
+
name: string;
|
|
28
|
+
}> | PromptConfig<AccountIdPromptResponse> | PromptConfig<ClientIdPromptResponse> | PromptConfig<ClientSecretPromptResponse> | PromptConfig<ScopesPromptResponse>)[];
|
|
1
29
|
export {};
|
|
@@ -1,85 +1,89 @@
|
|
|
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
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
6
|
+
exports.OAUTH_FLOW = void 0;
|
|
7
|
+
exports.personalAccessKeyPrompt = personalAccessKeyPrompt;
|
|
8
|
+
const open_1 = __importDefault(require("open"));
|
|
9
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
10
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
11
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const promptUtils_1 = require("./promptUtils");
|
|
14
|
+
const accountNamePrompt_1 = require("./accountNamePrompt");
|
|
15
|
+
const lang_1 = require("../lang");
|
|
16
|
+
const ui_1 = require("../ui");
|
|
17
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
14
18
|
const i18nKey = 'lib.prompts.personalAccessKeyPrompt';
|
|
15
19
|
/**
|
|
16
20
|
* Displays notification to user that we are about to open the browser,
|
|
17
21
|
* then opens their browser to the personal-access-key shortlink
|
|
18
22
|
*/
|
|
19
|
-
|
|
20
|
-
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
23
|
+
async function personalAccessKeyPrompt({ env, account, }) {
|
|
24
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
21
25
|
let url = `${websiteOrigin}/l/personal-access-key`;
|
|
22
26
|
if (process.env.BROWSER !== 'none') {
|
|
23
|
-
uiInfoSection(i18n(`${i18nKey}.personalAccessKeySetupTitle`), () => {
|
|
24
|
-
logger.log(i18n(`${i18nKey}.personalAccessKeyBrowserOpenPrep`));
|
|
27
|
+
(0, ui_1.uiInfoSection)((0, lang_1.i18n)(`${i18nKey}.personalAccessKeySetupTitle`), () => {
|
|
28
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.personalAccessKeyBrowserOpenPrep`));
|
|
25
29
|
});
|
|
26
30
|
if (account) {
|
|
27
31
|
url = `${websiteOrigin}/personal-access-key/${account}`;
|
|
28
32
|
}
|
|
29
|
-
const { personalAcessKeyBrowserOpenPrep: shouldOpen } = await promptUser([
|
|
33
|
+
const { personalAcessKeyBrowserOpenPrep: shouldOpen } = await (0, promptUtils_1.promptUser)([
|
|
30
34
|
PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP,
|
|
31
35
|
]);
|
|
32
36
|
if (shouldOpen) {
|
|
33
|
-
|
|
37
|
+
(0, open_1.default)(url, { url: true });
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
|
-
deleteEmptyConfigFile();
|
|
37
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
40
|
+
(0, config_1.deleteEmptyConfigFile)();
|
|
41
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
logger.log(i18n(`${i18nKey}.logs.openingWebBrowser`, { url }));
|
|
41
|
-
const { personalAccessKey } = await promptUser(PERSONAL_ACCESS_KEY);
|
|
44
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.openingWebBrowser`, { url }));
|
|
45
|
+
const { personalAccessKey } = await (0, promptUtils_1.promptUser)(PERSONAL_ACCESS_KEY);
|
|
42
46
|
return {
|
|
43
47
|
personalAccessKey,
|
|
44
48
|
env,
|
|
45
49
|
};
|
|
46
|
-
}
|
|
50
|
+
}
|
|
47
51
|
const ACCOUNT_ID = {
|
|
48
52
|
name: 'accountId',
|
|
49
|
-
message: i18n(`${i18nKey}.enterAccountId`),
|
|
53
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterAccountId`),
|
|
50
54
|
type: 'number',
|
|
51
55
|
validate(val) {
|
|
52
|
-
if (!Number.isNaN(val) && val > 0) {
|
|
56
|
+
if (!Number.isNaN(val) && val !== undefined && val > 0) {
|
|
53
57
|
return true;
|
|
54
58
|
}
|
|
55
|
-
return i18n(`${i18nKey}.errors.invalidAccountId`);
|
|
59
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidAccountId`);
|
|
56
60
|
},
|
|
57
61
|
};
|
|
58
62
|
const CLIENT_ID = {
|
|
59
63
|
name: 'clientId',
|
|
60
|
-
message: i18n(`${i18nKey}.enterClientId`),
|
|
64
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterClientId`),
|
|
61
65
|
validate(val) {
|
|
62
66
|
if (typeof val !== 'string') {
|
|
63
|
-
return i18n(`${i18nKey}.errors.invalidOauthClientId`);
|
|
67
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidOauthClientId`);
|
|
64
68
|
}
|
|
65
69
|
else if (val.length !== 36) {
|
|
66
|
-
return i18n(`${i18nKey}.errors.invalidOauthClientIdLength`);
|
|
70
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidOauthClientIdLength`);
|
|
67
71
|
}
|
|
68
72
|
return true;
|
|
69
73
|
},
|
|
70
74
|
};
|
|
71
75
|
const CLIENT_SECRET = {
|
|
72
76
|
name: 'clientSecret',
|
|
73
|
-
message: i18n(`${i18nKey}.enterClientSecret`),
|
|
77
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterClientSecret`),
|
|
74
78
|
validate(val) {
|
|
75
79
|
if (typeof val !== 'string') {
|
|
76
|
-
return i18n(`${i18nKey}.errors.invalidOauthClientSecret`);
|
|
80
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidOauthClientSecret`);
|
|
77
81
|
}
|
|
78
82
|
else if (val.length !== 36) {
|
|
79
|
-
return i18n(`${i18nKey}.errors.invalidOauthClientSecretLength`);
|
|
83
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidOauthClientSecretLength`);
|
|
80
84
|
}
|
|
81
85
|
else if (val[0] === '*') {
|
|
82
|
-
return i18n(`${i18nKey}.errors.invalidOauthClientSecretCopy`);
|
|
86
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidOauthClientSecretCopy`);
|
|
83
87
|
}
|
|
84
88
|
return true;
|
|
85
89
|
},
|
|
@@ -87,12 +91,12 @@ const CLIENT_SECRET = {
|
|
|
87
91
|
const PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP = {
|
|
88
92
|
name: 'personalAcessKeyBrowserOpenPrep',
|
|
89
93
|
type: 'confirm',
|
|
90
|
-
message: i18n(`${i18nKey}.personalAccessKeyBrowserOpenPrompt`),
|
|
94
|
+
message: (0, lang_1.i18n)(`${i18nKey}.personalAccessKeyBrowserOpenPrompt`),
|
|
91
95
|
};
|
|
92
96
|
const PERSONAL_ACCESS_KEY = {
|
|
93
97
|
name: 'personalAccessKey',
|
|
94
|
-
message: i18n(`${i18nKey}.enterPersonalAccessKey`),
|
|
95
|
-
transformer: val => {
|
|
98
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterPersonalAccessKey`),
|
|
99
|
+
transformer: (val) => {
|
|
96
100
|
if (!val)
|
|
97
101
|
return val;
|
|
98
102
|
let res = '';
|
|
@@ -103,10 +107,10 @@ const PERSONAL_ACCESS_KEY = {
|
|
|
103
107
|
},
|
|
104
108
|
validate(val) {
|
|
105
109
|
if (!val || typeof val !== 'string') {
|
|
106
|
-
return i18n(`${i18nKey}.errors.invalidPersonalAccessKey`);
|
|
110
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidPersonalAccessKey`);
|
|
107
111
|
}
|
|
108
112
|
else if (val[0] === '•') {
|
|
109
|
-
return i18n(`${i18nKey}.errors.invalidPersonalAccessKeyCopy`);
|
|
113
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidPersonalAccessKeyCopy`);
|
|
110
114
|
}
|
|
111
115
|
return true;
|
|
112
116
|
},
|
|
@@ -114,24 +118,14 @@ const PERSONAL_ACCESS_KEY = {
|
|
|
114
118
|
const SCOPES = {
|
|
115
119
|
type: 'checkbox',
|
|
116
120
|
name: 'scopes',
|
|
117
|
-
message: i18n(`${i18nKey}.selectScopes`),
|
|
118
|
-
default: DEFAULT_OAUTH_SCOPES,
|
|
119
|
-
choices: OAUTH_SCOPES,
|
|
121
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectScopes`),
|
|
122
|
+
default: [...auth_1.DEFAULT_OAUTH_SCOPES],
|
|
123
|
+
choices: [...auth_1.OAUTH_SCOPES],
|
|
120
124
|
};
|
|
121
|
-
|
|
122
|
-
getCliAccountNamePromptConfig(),
|
|
125
|
+
exports.OAUTH_FLOW = [
|
|
126
|
+
(0, accountNamePrompt_1.getCliAccountNamePromptConfig)(),
|
|
123
127
|
ACCOUNT_ID,
|
|
124
128
|
CLIENT_ID,
|
|
125
129
|
CLIENT_SECRET,
|
|
126
130
|
SCOPES,
|
|
127
131
|
];
|
|
128
|
-
module.exports = {
|
|
129
|
-
personalAccessKeyPrompt,
|
|
130
|
-
CLIENT_ID,
|
|
131
|
-
CLIENT_SECRET,
|
|
132
|
-
ACCOUNT_ID,
|
|
133
|
-
SCOPES,
|
|
134
|
-
PERSONAL_ACCESS_KEY,
|
|
135
|
-
// Flows
|
|
136
|
-
OAUTH_FLOW,
|
|
137
|
-
};
|
|
@@ -1 +1,15 @@
|
|
|
1
|
+
type PreviewPromptResponse = {
|
|
2
|
+
src: string;
|
|
3
|
+
dest: string;
|
|
4
|
+
};
|
|
5
|
+
type PreviewProjectPromptResponse = {
|
|
6
|
+
themeComponentPath: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function previewPrompt(promptOptions?: {
|
|
9
|
+
src?: string;
|
|
10
|
+
dest?: string;
|
|
11
|
+
}): Promise<PreviewPromptResponse>;
|
|
12
|
+
export declare function previewProjectPrompt(themeComponents: {
|
|
13
|
+
path: string;
|
|
14
|
+
}[]): Promise<PreviewProjectPromptResponse>;
|
|
1
15
|
export {};
|