@hubspot/cli 7.0.0-experimental.1 → 7.0.1-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +35 -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 +3 -3
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -38
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- 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 +4 -3
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +2 -1
- 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 +128 -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 +14 -7
- 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/validation.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { Arguments } from 'yargs';
|
|
2
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
3
|
+
export declare function validateAccount(options: Arguments<{
|
|
4
|
+
account?: string;
|
|
5
|
+
accountId?: string;
|
|
6
|
+
}>): Promise<boolean>;
|
|
7
|
+
export declare function validateCmsPublishMode(options: Arguments<{
|
|
8
|
+
cmsPublishMode?: CmsPublishMode;
|
|
9
|
+
}>): boolean;
|
|
10
|
+
export declare function fileExists(_path: string): boolean;
|
|
11
|
+
export declare function checkAndConvertToJson(_path: string): object | null;
|
package/lib/validation.js
CHANGED
|
@@ -1,163 +1,177 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
setLogLevel(options);
|
|
20
|
-
const { config: configPath } = options;
|
|
21
|
-
loadConfig(configPath, options);
|
|
22
|
-
checkAndWarnGitInclusion(getConfigPath());
|
|
23
|
-
let validAccount = true;
|
|
24
|
-
if (shouldValidateAccount) {
|
|
25
|
-
validAccount = await validateAccount(options);
|
|
26
|
-
}
|
|
27
|
-
if (!(validateConfig() && validAccount)) {
|
|
28
|
-
process.exit(EXIT_CODES.ERROR);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Validate that an account was passed to the command and that the account's configuration is valid
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {object} command options
|
|
36
|
-
* @returns {boolean}
|
|
37
|
-
*/
|
|
36
|
+
exports.validateAccount = validateAccount;
|
|
37
|
+
exports.validateCmsPublishMode = validateCmsPublishMode;
|
|
38
|
+
exports.fileExists = fileExists;
|
|
39
|
+
exports.checkAndConvertToJson = checkAndConvertToJson;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
43
|
+
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
44
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
45
|
+
const text_1 = require("@hubspot/local-dev-lib/text");
|
|
46
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
47
|
+
const oauth_1 = require("@hubspot/local-dev-lib/oauth");
|
|
48
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
49
|
+
const path_1 = require("@hubspot/local-dev-lib/path");
|
|
50
|
+
const commonOpts_1 = require("./commonOpts");
|
|
51
|
+
const index_1 = require("./errorHandlers/index");
|
|
38
52
|
async function validateAccount(options) {
|
|
39
|
-
const accountId = getAccountId(options);
|
|
40
|
-
const {
|
|
41
|
-
const accountOption = portalOption || _accountOption;
|
|
42
|
-
const accountIdOption = portalIdOption || _accountIdOption;
|
|
53
|
+
const accountId = (0, commonOpts_1.getAccountId)(options);
|
|
54
|
+
const { accountId: accountIdOption, account: accountOption } = options;
|
|
43
55
|
if (!accountId) {
|
|
44
56
|
if (accountOption) {
|
|
45
|
-
logger.error(`The account "${accountOption}" could not be found in the config`);
|
|
57
|
+
logger_1.logger.error(`The account "${accountOption}" could not be found in the config`);
|
|
46
58
|
}
|
|
47
59
|
else if (accountIdOption) {
|
|
48
|
-
logger.error(`The account "${accountIdOption}" could not be found in the config`);
|
|
60
|
+
logger_1.logger.error(`The account "${accountIdOption}" could not be found in the config`);
|
|
49
61
|
}
|
|
50
62
|
else {
|
|
51
|
-
logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
|
|
63
|
+
logger_1.logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
|
|
52
64
|
}
|
|
53
65
|
return false;
|
|
54
66
|
}
|
|
55
|
-
if (accountOption && loadConfigFromEnvironment()) {
|
|
67
|
+
if (accountOption && (0, config_1.loadConfigFromEnvironment)()) {
|
|
56
68
|
throw new Error('Cannot specify an account when environment variables are supplied. Please unset the environment variables or do not use the "--account" flag.');
|
|
57
69
|
}
|
|
58
|
-
const accountConfig = getAccountConfig(accountId);
|
|
70
|
+
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
59
71
|
if (!accountConfig) {
|
|
60
|
-
logger.error(`The account ${accountId} has not been configured`);
|
|
72
|
+
logger_1.logger.error(`The account ${accountId} has not been configured`);
|
|
61
73
|
return false;
|
|
62
74
|
}
|
|
63
75
|
const { authType, auth, apiKey, personalAccessKey } = accountConfig;
|
|
64
76
|
if (typeof authType === 'string' && authType !== authType.toLowerCase()) {
|
|
65
|
-
logger.error(`Invalid "authType" value "${authType}" for account "${accountId}" in config file: ${getConfigPath()}. Valid values are ${commaSeparatedValues([
|
|
66
|
-
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
67
|
-
OAUTH_AUTH_METHOD,
|
|
68
|
-
API_KEY_AUTH_METHOD,
|
|
77
|
+
logger_1.logger.error(`Invalid "authType" value "${authType}" for account "${accountId}" in config file: ${(0, config_1.getConfigPath)()}. Valid values are ${(0, text_1.commaSeparatedValues)([
|
|
78
|
+
auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
79
|
+
auth_1.OAUTH_AUTH_METHOD,
|
|
80
|
+
auth_1.API_KEY_AUTH_METHOD,
|
|
69
81
|
].map(method => method.value))}.`);
|
|
70
82
|
}
|
|
71
83
|
if (authType === 'oauth2') {
|
|
72
84
|
if (typeof auth !== 'object') {
|
|
73
|
-
logger.error(`The OAuth2 auth configuration for account ${accountId} is missing`);
|
|
85
|
+
logger_1.logger.error(`The OAuth2 auth configuration for account ${accountId} is missing`);
|
|
74
86
|
return false;
|
|
75
87
|
}
|
|
76
88
|
const { clientId, clientSecret, tokenInfo } = auth;
|
|
77
89
|
if (!clientId || !clientSecret || !tokenInfo || !tokenInfo.refreshToken) {
|
|
78
|
-
logger.error(`The OAuth2 configuration for account ${accountId} is incorrect`);
|
|
79
|
-
logger.error('Run "hs auth --type=oauth2" to reauthenticate');
|
|
90
|
+
logger_1.logger.error(`The OAuth2 configuration for account ${accountId} is incorrect`);
|
|
91
|
+
logger_1.logger.error('Run "hs auth --type=oauth2" to reauthenticate');
|
|
80
92
|
return false;
|
|
81
93
|
}
|
|
82
|
-
const oauth = getOauthManager(accountId, accountConfig);
|
|
94
|
+
const oauth = (0, oauth_1.getOauthManager)(accountId, accountConfig);
|
|
83
95
|
try {
|
|
84
|
-
|
|
96
|
+
let accessToken;
|
|
97
|
+
if (oauth) {
|
|
98
|
+
accessToken = await oauth.accessToken();
|
|
99
|
+
}
|
|
85
100
|
if (!accessToken) {
|
|
86
|
-
logger.error(`The OAuth2 access token could not be found for accountId ${accountId}`);
|
|
101
|
+
logger_1.logger.error(`The OAuth2 access token could not be found for accountId ${accountId}`);
|
|
87
102
|
return false;
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
catch (e) {
|
|
91
|
-
|
|
106
|
+
(0, index_1.logError)(e);
|
|
92
107
|
return false;
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
else if (authType === 'personalaccesskey') {
|
|
96
111
|
if (!personalAccessKey) {
|
|
97
|
-
logger.error(`The account "${accountId}" is configured to use a access key for authentication and is missing a "personalAccessKey" in the configuration file`);
|
|
112
|
+
logger_1.logger.error(`The account "${accountId}" is configured to use a access key for authentication and is missing a "personalAccessKey" in the configuration file`);
|
|
98
113
|
return false;
|
|
99
114
|
}
|
|
100
115
|
try {
|
|
101
|
-
const accessToken = await accessTokenForPersonalAccessKey(accountId);
|
|
116
|
+
const accessToken = await (0, personalAccessKey_1.accessTokenForPersonalAccessKey)(accountId);
|
|
102
117
|
if (!accessToken) {
|
|
103
|
-
logger.error(`An OAuth2 access token for account "${accountId} could not be retrieved using the "personalAccessKey" provided`);
|
|
118
|
+
logger_1.logger.error(`An OAuth2 access token for account "${accountId} could not be retrieved using the "personalAccessKey" provided`);
|
|
104
119
|
return false;
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
catch (e) {
|
|
108
|
-
logError(e);
|
|
123
|
+
(0, index_1.logError)(e);
|
|
109
124
|
return false;
|
|
110
125
|
}
|
|
111
126
|
}
|
|
112
127
|
else if (!apiKey) {
|
|
113
|
-
logger.error(`The accountId ${accountId} is missing authentication configuration`);
|
|
128
|
+
logger_1.logger.error(`The accountId ${accountId} is missing authentication configuration`);
|
|
114
129
|
return false;
|
|
115
130
|
}
|
|
116
131
|
return true;
|
|
117
132
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*/
|
|
122
|
-
function validateMode(options) {
|
|
123
|
-
const mode = getMode(options);
|
|
124
|
-
if (MODE[mode]) {
|
|
133
|
+
function validateCmsPublishMode(options) {
|
|
134
|
+
const cmsPublishMode = (0, commonOpts_1.getCmsPublishMode)(options);
|
|
135
|
+
if (files_1.CMS_PUBLISH_MODE[cmsPublishMode]) {
|
|
125
136
|
return true;
|
|
126
137
|
}
|
|
127
|
-
const modesMessage = `Available modes are: ${Object.values(
|
|
128
|
-
if (
|
|
129
|
-
logger.error([
|
|
138
|
+
const modesMessage = `Available CMS publish modes are: ${Object.values(files_1.CMS_PUBLISH_MODE).join(', ')}.`;
|
|
139
|
+
if (cmsPublishMode != null) {
|
|
140
|
+
logger_1.logger.error([
|
|
141
|
+
`The CMS publish mode "${cmsPublishMode}" is invalid.`,
|
|
142
|
+
modesMessage,
|
|
143
|
+
].join(' '));
|
|
130
144
|
}
|
|
131
145
|
else {
|
|
132
|
-
logger.error(['The mode option is missing.', modesMessage].join(' '));
|
|
146
|
+
logger_1.logger.error(['The CMS publish mode option is missing.', modesMessage].join(' '));
|
|
133
147
|
}
|
|
134
148
|
return false;
|
|
135
149
|
}
|
|
136
|
-
|
|
150
|
+
function fileExists(_path) {
|
|
137
151
|
let isFile;
|
|
138
152
|
try {
|
|
139
|
-
const absoluteSrcPath = path.resolve(getCwd(), _path);
|
|
153
|
+
const absoluteSrcPath = path.resolve((0, path_1.getCwd)(), _path);
|
|
140
154
|
if (!absoluteSrcPath)
|
|
141
155
|
return false;
|
|
142
156
|
const stats = fs.statSync(absoluteSrcPath);
|
|
143
157
|
isFile = stats.isFile();
|
|
144
158
|
if (!isFile) {
|
|
145
|
-
logger.error(`The path "${_path}" is not a path to a file`);
|
|
159
|
+
logger_1.logger.error(`The path "${_path}" is not a path to a file`);
|
|
146
160
|
return false;
|
|
147
161
|
}
|
|
148
162
|
}
|
|
149
163
|
catch (e) {
|
|
150
|
-
logger.error(`The path "${_path}" is not a path to a file`);
|
|
164
|
+
logger_1.logger.error(`The path "${_path}" is not a path to a file`);
|
|
151
165
|
return false;
|
|
152
166
|
}
|
|
153
167
|
return true;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const filePath = getAbsoluteFilePath(_path);
|
|
168
|
+
}
|
|
169
|
+
function checkAndConvertToJson(_path) {
|
|
170
|
+
const filePath = (0, path_1.getAbsoluteFilePath)(_path);
|
|
157
171
|
if (!fileExists(filePath))
|
|
158
|
-
return
|
|
159
|
-
if (getExt(_path) !== 'json') {
|
|
160
|
-
logger.error(`The file "${_path}" must be a valid JSON file`);
|
|
172
|
+
return null;
|
|
173
|
+
if ((0, path_1.getExt)(_path) !== 'json') {
|
|
174
|
+
logger_1.logger.error(`The file "${_path}" must be a valid JSON file`);
|
|
161
175
|
return null;
|
|
162
176
|
}
|
|
163
177
|
let result;
|
|
@@ -165,15 +179,8 @@ const checkAndConvertToJson = _path => {
|
|
|
165
179
|
result = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
166
180
|
}
|
|
167
181
|
catch (e) {
|
|
168
|
-
logger.error(`The file "${_path}" contains invalid JSON`);
|
|
182
|
+
logger_1.logger.error(`The file "${_path}" contains invalid JSON`);
|
|
169
183
|
result = null;
|
|
170
184
|
}
|
|
171
185
|
return result;
|
|
172
|
-
}
|
|
173
|
-
module.exports = {
|
|
174
|
-
validateMode,
|
|
175
|
-
validateAccount,
|
|
176
|
-
checkAndConvertToJson,
|
|
177
|
-
fileExists,
|
|
178
|
-
loadAndValidateOptions,
|
|
179
|
-
};
|
|
186
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "
|
|
8
|
+
"@hubspot/local-dev-lib": "3.1.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.0.1",
|
|
9
10
|
"@hubspot/serverless-dev-runtime": "7.0.0",
|
|
10
|
-
"@hubspot/theme-preview-dev-server": "0.0.
|
|
11
|
-
"@hubspot/ui-extensions-dev-server": "0.8.
|
|
11
|
+
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
|
+
"@hubspot/ui-extensions-dev-server": "0.8.33",
|
|
12
13
|
"archiver": "^7.0.1",
|
|
13
14
|
"chalk": "^4.1.2",
|
|
14
15
|
"chokidar": "^3.0.1",
|
|
@@ -26,13 +27,18 @@
|
|
|
26
27
|
"table": "^6.6.0",
|
|
27
28
|
"tmp": "^0.2.1",
|
|
28
29
|
"update-notifier": "^5.1.0",
|
|
29
|
-
"yargs": "17.7.2"
|
|
30
|
+
"yargs": "17.7.2",
|
|
31
|
+
"yargs-parser": "^21.1.1"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
34
|
+
"@types/archiver": "^6.0.3",
|
|
35
|
+
"@types/express": "^5.0.0",
|
|
36
|
+
"@types/findup-sync": "^4.0.5",
|
|
32
37
|
"@types/fs-extra": "^11.0.4",
|
|
33
38
|
"@types/jest": "^29.5.14",
|
|
34
39
|
"@types/js-yaml": "^4.0.9",
|
|
35
40
|
"@types/semver": "^7.5.8",
|
|
41
|
+
"@types/tmp": "^0.2.6",
|
|
36
42
|
"@types/yargs": "^17.0.33",
|
|
37
43
|
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
38
44
|
"@typescript-eslint/parser": "^8.11.0",
|
|
@@ -44,7 +50,7 @@
|
|
|
44
50
|
"lint-staged": "^10.5.4",
|
|
45
51
|
"madge": "^8.0.0",
|
|
46
52
|
"mock-stdin": "^1.0.0",
|
|
47
|
-
"prettier": "^
|
|
53
|
+
"prettier": "^3.4.2",
|
|
48
54
|
"semver": "^7.6.3",
|
|
49
55
|
"ts-jest": "^29.2.5",
|
|
50
56
|
"ts-node": "^10.9.2",
|
|
@@ -56,7 +62,8 @@
|
|
|
56
62
|
"scripts": {
|
|
57
63
|
"build": "ts-node ./scripts/build.ts",
|
|
58
64
|
"lint": "eslint . && prettier --list-different ./**/*.{js,json}",
|
|
59
|
-
"
|
|
65
|
+
"list-all-commands": "yarn ts-node ./scripts/get-all-commands.ts",
|
|
66
|
+
"prettier:write": "prettier --write ./**/*.{ts,js,json}",
|
|
60
67
|
"test": "jest",
|
|
61
68
|
"test-cli": "yarn --cwd 'acceptance-tests' test-ci",
|
|
62
69
|
"test-cli-debug": "yarn --cwd 'acceptance-tests' test-debug",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Build, SubbuildStatus } from '@hubspot/local-dev-lib/types/Build';
|
|
2
|
+
import { Deploy, SubdeployStatus } from '@hubspot/local-dev-lib/types/Deploy';
|
|
3
|
+
export type ProjectTemplate = {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
path: string;
|
|
7
|
+
insertPath: string;
|
|
8
|
+
};
|
|
9
|
+
export type ComponentTemplate = {
|
|
10
|
+
label: string;
|
|
11
|
+
path: string;
|
|
12
|
+
insertPath: string;
|
|
13
|
+
};
|
|
14
|
+
export type ProjectConfig = {
|
|
15
|
+
name: string;
|
|
16
|
+
srcDir: string;
|
|
17
|
+
platformVersion: string;
|
|
18
|
+
};
|
|
19
|
+
export type ProjectTaskStates = {
|
|
20
|
+
BUILDING?: string;
|
|
21
|
+
ENQUEUED?: string;
|
|
22
|
+
DEPLOYING?: string;
|
|
23
|
+
FAILURE: string;
|
|
24
|
+
PENDING: string;
|
|
25
|
+
SUCCESS: string;
|
|
26
|
+
};
|
|
27
|
+
export type ProjectTask = Build | Deploy;
|
|
28
|
+
export type ProjectSubtask = SubbuildStatus | SubdeployStatus;
|
|
29
|
+
export type ProjectPollStatusFunctionText = {
|
|
30
|
+
STATES: ProjectTaskStates;
|
|
31
|
+
STATUS_TEXT: string;
|
|
32
|
+
TYPE_KEY: string;
|
|
33
|
+
SUBTASK_NAME_KEY: string;
|
|
34
|
+
};
|
|
35
|
+
export type ProjectAddComponentData = {
|
|
36
|
+
path: string;
|
|
37
|
+
label: string;
|
|
38
|
+
insertPath: string;
|
|
39
|
+
};
|
|
40
|
+
export type ProjectTemplateRepoConfig = {
|
|
41
|
+
projects?: ProjectTemplate[];
|
|
42
|
+
components?: ComponentTemplate[];
|
|
43
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type GenericPromptResponse = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
type PromptType = 'confirm' | 'list' | 'checkbox' | 'input' | 'password' | 'number' | 'rawlist';
|
|
5
|
+
export type PromptChoices = Array<string | {
|
|
6
|
+
name: string;
|
|
7
|
+
value?: any;
|
|
8
|
+
disabled?: string | boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export type PromptWhen = boolean | (() => boolean);
|
|
11
|
+
type PromptOperand = string | number | boolean | string[] | boolean[] | null;
|
|
12
|
+
export type PromptConfig<T extends GenericPromptResponse> = {
|
|
13
|
+
name: keyof T;
|
|
14
|
+
type?: PromptType;
|
|
15
|
+
message?: string | ((answers: T) => string);
|
|
16
|
+
choices?: PromptChoices;
|
|
17
|
+
when?: PromptWhen;
|
|
18
|
+
pageSize?: number;
|
|
19
|
+
default?: PromptOperand | ((answers: T) => PromptOperand);
|
|
20
|
+
transformer?: (input: string) => string | undefined;
|
|
21
|
+
validate?: (answer?: any) => PromptOperand | Promise<PromptOperand>;
|
|
22
|
+
mask?: string;
|
|
23
|
+
filter?: (input: string) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
package/types/Prompts.js
ADDED
package/commands/accounts.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const { i18n } = require('../lib/lang');
|
|
6
|
-
const list = require('./accounts/list');
|
|
7
|
-
const rename = require('./accounts/rename');
|
|
8
|
-
const use = require('./accounts/use');
|
|
9
|
-
const info = require('./accounts/info');
|
|
10
|
-
const remove = require('./accounts/remove');
|
|
11
|
-
const clean = require('./accounts/clean');
|
|
12
|
-
const i18nKey = 'commands.accounts';
|
|
13
|
-
exports.command = 'accounts';
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
exports.builder = yargs => {
|
|
16
|
-
addConfigOptions(yargs);
|
|
17
|
-
addAccountOptions(yargs);
|
|
18
|
-
yargs
|
|
19
|
-
.command({
|
|
20
|
-
...list,
|
|
21
|
-
aliases: 'ls',
|
|
22
|
-
})
|
|
23
|
-
.command(rename)
|
|
24
|
-
.command(use)
|
|
25
|
-
.command(info)
|
|
26
|
-
.command(remove)
|
|
27
|
-
.command(clean)
|
|
28
|
-
.demandCommand(1, '');
|
|
29
|
-
return yargs;
|
|
30
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
|
-
const { retrieveDefaultModule } = require('@hubspot/local-dev-lib/cms/modules');
|
|
7
|
-
const { i18n } = require('../../lib/lang');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
-
const i18nKey = 'commands.cms.subcommands.reactModule';
|
|
11
|
-
exports.command = 'get-react-module [--name] [--dest]';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
exports.handler = async (options) => {
|
|
14
|
-
const { name, dest } = options;
|
|
15
|
-
trackCommandUsage('get-react-modules');
|
|
16
|
-
const destPath = dest
|
|
17
|
-
? path.join(dest, `${name}`)
|
|
18
|
-
: path.join(process.cwd(), `${name}`);
|
|
19
|
-
if (fs.existsSync(destPath)) {
|
|
20
|
-
logger.error(i18n(`${i18nKey}.errors.pathExists`, {
|
|
21
|
-
path: destPath,
|
|
22
|
-
}));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const modules = await retrieveDefaultModule(name, destPath);
|
|
27
|
-
if (!name) {
|
|
28
|
-
logger.group(i18n(`${i18nKey}.groupLabel`));
|
|
29
|
-
modules.forEach(module => {
|
|
30
|
-
logger.log(module.name);
|
|
31
|
-
});
|
|
32
|
-
logger.groupEnd(i18n(`${i18nKey}.groupLabel`));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
logger.success(i18n(`${i18nKey}.success.moduleDownloaded`, {
|
|
36
|
-
moduleName: name,
|
|
37
|
-
path: destPath,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
|
|
43
|
-
logger.error(i18n(`${i18nKey}.errors.invalidName`));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
logger.error(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.builder = yargs => {
|
|
51
|
-
yargs.option('name', {
|
|
52
|
-
describe: i18n(`${i18nKey}.options.name.describe`),
|
|
53
|
-
type: 'string',
|
|
54
|
-
});
|
|
55
|
-
yargs.option('dest', {
|
|
56
|
-
describe: i18n(`${i18nKey}.options.dest.describe`),
|
|
57
|
-
type: 'string',
|
|
58
|
-
});
|
|
59
|
-
return yargs;
|
|
60
|
-
};
|
package/commands/functions.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const list = require('./functions/list');
|
|
6
|
-
const deploy = require('./functions/deploy');
|
|
7
|
-
const server = require('./functions/server');
|
|
8
|
-
const { i18n } = require('../lib/lang');
|
|
9
|
-
const i18nKey = 'commands.functions';
|
|
10
|
-
exports.command = 'functions';
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
-
exports.builder = yargs => {
|
|
13
|
-
addConfigOptions(yargs);
|
|
14
|
-
addAccountOptions(yargs);
|
|
15
|
-
yargs
|
|
16
|
-
.command({
|
|
17
|
-
...list,
|
|
18
|
-
aliases: 'ls',
|
|
19
|
-
})
|
|
20
|
-
.command(deploy)
|
|
21
|
-
.command(server)
|
|
22
|
-
.demandCommand(1, '');
|
|
23
|
-
return yargs;
|
|
24
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
6
|
-
const { deleteSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
11
|
-
const { i18n } = require('../../lib/lang');
|
|
12
|
-
const i18nKey = 'commands.secrets.subcommands.delete';
|
|
13
|
-
exports.command = 'delete <name>';
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
exports.handler = async (options) => {
|
|
16
|
-
const { name: secretName } = options;
|
|
17
|
-
await loadAndValidateOptions(options);
|
|
18
|
-
const accountId = getAccountId(options);
|
|
19
|
-
trackCommandUsage('secrets-delete', null, accountId);
|
|
20
|
-
try {
|
|
21
|
-
await deleteSecret(accountId, secretName);
|
|
22
|
-
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
23
|
-
accountIdentifier: uiAccountDescription(accountId),
|
|
24
|
-
secretName,
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
logger.error(i18n(`${i18nKey}.errors.delete`, {
|
|
29
|
-
secretName,
|
|
30
|
-
}));
|
|
31
|
-
logError(err, new ApiErrorContext({
|
|
32
|
-
request: 'delete a secret',
|
|
33
|
-
accountId,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.builder = yargs => {
|
|
38
|
-
addConfigOptions(yargs);
|
|
39
|
-
addAccountOptions(yargs);
|
|
40
|
-
addUseEnvironmentOptions(yargs);
|
|
41
|
-
yargs.positional('name', {
|
|
42
|
-
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
43
|
-
type: 'string',
|
|
44
|
-
});
|
|
45
|
-
return yargs;
|
|
46
|
-
};
|
package/commands/secrets.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const addSecretCommand = require('./secrets/addSecret');
|
|
6
|
-
const listSecretsCommand = require('./secrets/listSecrets');
|
|
7
|
-
const deleteSecretCommand = require('./secrets/deleteSecret');
|
|
8
|
-
const updateSecretCommand = require('./secrets/updateSecret');
|
|
9
|
-
const { i18n } = require('../lib/lang');
|
|
10
|
-
const i18nKey = 'commands.secrets';
|
|
11
|
-
exports.command = 'secrets';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
exports.builder = yargs => {
|
|
14
|
-
addConfigOptions(yargs);
|
|
15
|
-
addAccountOptions(yargs);
|
|
16
|
-
yargs
|
|
17
|
-
.command(listSecretsCommand)
|
|
18
|
-
.command(addSecretCommand)
|
|
19
|
-
.command(updateSecretCommand)
|
|
20
|
-
.command(deleteSecretCommand)
|
|
21
|
-
.demandCommand(1, '');
|
|
22
|
-
return yargs;
|
|
23
|
-
};
|