@hubspot/cli 7.0.1 → 7.0.2-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 +7 -2
- package/commands/account/info.d.ts +7 -0
- package/commands/account/info.js +28 -25
- package/commands/account/remove.js +4 -4
- package/commands/account/use.js +3 -3
- package/commands/auth.js +3 -3
- package/commands/function/deploy.js +1 -1
- package/commands/init.js +1 -1
- package/commands/logs.js +1 -7
- package/commands/project/cloneApp.js +1 -1
- package/commands/project/create.js +6 -0
- package/commands/project/dev.js +4 -3
- package/commands/project/installDeps.js +2 -4
- package/commands/project/migrateApp.js +1 -1
- package/commands/project/upload.js +4 -4
- package/commands/project/watch.js +4 -4
- package/commands/sandbox/create.js +7 -18
- package/commands/sandbox/delete.js +6 -10
- package/commands/theme/preview.js +3 -2
- package/lang/en.lyaml +11 -4
- package/lib/DevServerManager.d.ts +40 -1
- package/lib/DevServerManager.js +39 -30
- package/lib/LocalDevManager.d.ts +58 -1
- package/lib/LocalDevManager.js +162 -121
- package/lib/buildAccount.d.ts +12 -0
- package/lib/buildAccount.js +110 -95
- package/lib/commonOpts.d.ts +4 -8
- package/lib/commonOpts.js +2 -14
- package/lib/constants.d.ts +1 -7
- package/lib/constants.js +2 -8
- package/lib/dependencyManagement.d.ts +9 -4
- package/lib/dependencyManagement.js +45 -49
- package/lib/developerTestAccounts.d.ts +1 -0
- package/lib/developerTestAccounts.js +1 -0
- package/lib/errorHandlers/index.js +5 -2
- package/lib/localDev.d.ts +17 -1
- package/lib/localDev.js +203 -203
- package/lib/polling.d.ts +13 -5
- package/lib/polling.js +21 -7
- package/lib/projects/buildAndDeploy.d.ts +1 -7
- package/lib/projects/buildAndDeploy.js +3 -3
- package/lib/projects/index.js +9 -4
- package/lib/projects/structure.d.ts +5 -71
- package/lib/projects/structure.js +27 -10
- package/lib/projects/upload.d.ts +4 -3
- package/lib/projects/upload.js +3 -5
- package/lib/prompts/createProjectPrompt.js +8 -1
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -2
- package/lib/sandboxSync.d.ts +4 -1
- package/lib/sandboxSync.js +67 -68
- package/lib/sandboxes.d.ts +20 -1
- package/lib/sandboxes.js +77 -175
- package/lib/serverlessLogs.d.ts +4 -1
- package/lib/serverlessLogs.js +64 -60
- package/lib/ui/serverlessFunctionLogs.d.ts +8 -0
- package/lib/ui/serverlessFunctionLogs.js +1 -3
- package/lib/validation.d.ts +2 -0
- package/lib/validation.js +5 -8
- package/package.json +8 -7
- package/types/Projects.d.ts +74 -0
- package/types/Projects.js +7 -0
- package/types/Sandboxes.d.ts +3 -0
- package/types/Sandboxes.js +2 -0
- package/types/Yargs.d.ts +14 -0
- package/types/Yargs.js +2 -0
package/lib/buildAccount.js
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
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
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
6
|
+
exports.saveAccountToConfig = saveAccountToConfig;
|
|
7
|
+
exports.buildDeveloperTestAccount = buildDeveloperTestAccount;
|
|
8
|
+
exports.buildSandbox = buildSandbox;
|
|
9
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
10
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
11
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
14
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
15
|
+
const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
|
|
16
|
+
const personalAccessKeyPrompt_1 = require("./prompts/personalAccessKeyPrompt");
|
|
17
|
+
const lang_1 = require("./lang");
|
|
18
|
+
const accountNamePrompt_1 = require("./prompts/accountNamePrompt");
|
|
19
|
+
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
20
|
+
const index_1 = require("./errorHandlers/index");
|
|
21
|
+
const sandboxes_1 = require("./sandboxes");
|
|
22
|
+
const developerTestAccounts_2 = require("./developerTestAccounts");
|
|
23
|
+
async function saveAccountToConfig(accountId, accountName, env, personalAccessKey, force = false) {
|
|
19
24
|
if (!personalAccessKey) {
|
|
20
|
-
const configData = await personalAccessKeyPrompt({
|
|
25
|
+
const configData = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
|
|
21
26
|
env,
|
|
22
27
|
account: accountId,
|
|
23
28
|
});
|
|
24
29
|
personalAccessKey = configData.personalAccessKey;
|
|
25
30
|
}
|
|
26
|
-
const token = await getAccessToken(personalAccessKey, env);
|
|
27
|
-
const updatedConfig = await updateConfigWithAccessToken(token, personalAccessKey, env);
|
|
28
|
-
let validName = updatedConfig
|
|
29
|
-
if (!updatedConfig
|
|
31
|
+
const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
|
|
32
|
+
const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env);
|
|
33
|
+
let validName = updatedConfig?.name || '';
|
|
34
|
+
if (!updatedConfig?.name) {
|
|
30
35
|
const nameForConfig = accountName.toLowerCase().split(' ').join('-');
|
|
31
36
|
validName = nameForConfig;
|
|
32
|
-
const invalidAccountName = accountNameExistsInConfig(nameForConfig);
|
|
37
|
+
const invalidAccountName = (0, config_1.accountNameExistsInConfig)(nameForConfig);
|
|
33
38
|
if (invalidAccountName) {
|
|
34
39
|
if (!force) {
|
|
35
|
-
logger.log('');
|
|
36
|
-
logger.warn(i18n(`lib.prompts.accountNamePrompt.errors.accountNameExists`, {
|
|
40
|
+
logger_1.logger.log('');
|
|
41
|
+
logger_1.logger.warn((0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.accountNameExists`, {
|
|
37
42
|
name: nameForConfig,
|
|
38
43
|
}));
|
|
39
|
-
const { name: promptName } = await cliAccountNamePrompt(nameForConfig + `_${accountId}`);
|
|
44
|
+
const { name: promptName } = await (0, accountNamePrompt_1.cliAccountNamePrompt)(nameForConfig + `_${accountId}`);
|
|
40
45
|
validName = promptName;
|
|
41
46
|
}
|
|
42
47
|
else {
|
|
@@ -45,100 +50,110 @@ async function saveAccountToConfig({ env, personalAccessKey, accountName, accoun
|
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
|
-
updateAccountConfig({
|
|
53
|
+
(0, config_1.updateAccountConfig)({
|
|
49
54
|
...updatedConfig,
|
|
50
|
-
|
|
51
|
-
tokenInfo: updatedConfig
|
|
55
|
+
env: updatedConfig?.env,
|
|
56
|
+
tokenInfo: updatedConfig?.auth?.tokenInfo,
|
|
52
57
|
name: validName,
|
|
53
58
|
});
|
|
54
|
-
writeConfig();
|
|
55
|
-
logger.log('');
|
|
59
|
+
(0, config_1.writeConfig)();
|
|
60
|
+
logger_1.logger.log('');
|
|
56
61
|
return validName;
|
|
57
62
|
}
|
|
58
|
-
async function
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
async function buildDeveloperTestAccount(name, accountConfig, env, portalLimit) {
|
|
64
|
+
const i18nKey = 'lib.developerTestAccount.create.loading';
|
|
65
|
+
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
66
|
+
const accountId = (0, config_1.getAccountId)(id);
|
|
67
|
+
if (!accountId) {
|
|
68
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.fail`));
|
|
69
|
+
}
|
|
70
|
+
SpinniesManager_1.default.init({
|
|
61
71
|
succeedColor: 'white',
|
|
62
72
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
|
|
67
|
-
const isDeveloperTestAccount = accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
|
|
68
|
-
let result;
|
|
69
|
-
let spinniesI18nKey;
|
|
70
|
-
if (isSandbox) {
|
|
71
|
-
if (accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX) {
|
|
72
|
-
spinniesI18nKey = 'lib.sandbox.create.loading.standard';
|
|
73
|
-
}
|
|
74
|
-
if (accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
75
|
-
spinniesI18nKey = 'lib.sandbox.create.loading.developer';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (isDeveloperTestAccount) {
|
|
79
|
-
spinniesI18nKey = 'lib.developerTestAccount.create.loading';
|
|
80
|
-
}
|
|
81
|
-
logger.log('');
|
|
82
|
-
SpinniesManager.add('buildNewAccount', {
|
|
83
|
-
text: i18n(`${spinniesI18nKey}.add`, {
|
|
73
|
+
logger_1.logger.log('');
|
|
74
|
+
SpinniesManager_1.default.add('buildDeveloperTestAccount', {
|
|
75
|
+
text: (0, lang_1.i18n)(`${i18nKey}.add`, {
|
|
84
76
|
accountName: name,
|
|
85
77
|
}),
|
|
86
78
|
});
|
|
87
|
-
let
|
|
79
|
+
let developerTestAccount;
|
|
88
80
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
resultAccountId = result.sandbox.sandboxHubId;
|
|
94
|
-
}
|
|
95
|
-
else if (isDeveloperTestAccount) {
|
|
96
|
-
const { data } = await createDeveloperTestAccount(accountId, name);
|
|
97
|
-
result = data;
|
|
98
|
-
resultAccountId = result.id;
|
|
99
|
-
}
|
|
100
|
-
SpinniesManager.succeed('buildNewAccount', {
|
|
101
|
-
text: i18n(`${spinniesI18nKey}.succeed`, {
|
|
81
|
+
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(accountId, name);
|
|
82
|
+
developerTestAccount = data;
|
|
83
|
+
SpinniesManager_1.default.succeed('buildDeveloperTestAccount', {
|
|
84
|
+
text: (0, lang_1.i18n)(`${i18nKey}.succeed`, {
|
|
102
85
|
accountName: name,
|
|
103
|
-
accountId:
|
|
86
|
+
accountId: developerTestAccount.id,
|
|
104
87
|
}),
|
|
105
88
|
});
|
|
106
89
|
}
|
|
107
|
-
catch (
|
|
108
|
-
debugError(
|
|
109
|
-
|
|
110
|
-
text: i18n(`${
|
|
90
|
+
catch (e) {
|
|
91
|
+
(0, index_1.debugError)(e);
|
|
92
|
+
SpinniesManager_1.default.fail('buildDeveloperTestAccount', {
|
|
93
|
+
text: (0, lang_1.i18n)(`${i18nKey}.fail`, {
|
|
111
94
|
accountName: name,
|
|
112
95
|
}),
|
|
113
96
|
});
|
|
114
|
-
|
|
115
|
-
handleSandboxCreateError({ err, env, accountConfig, name, accountId });
|
|
116
|
-
}
|
|
117
|
-
if (isDeveloperTestAccount) {
|
|
118
|
-
handleDeveloperTestAccountCreateError(err, env, accountId, portalLimit);
|
|
119
|
-
}
|
|
97
|
+
(0, developerTestAccounts_2.handleDeveloperTestAccountCreateError)(e, accountId, env, portalLimit);
|
|
120
98
|
}
|
|
121
|
-
let configAccountName;
|
|
122
99
|
try {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
100
|
+
await saveAccountToConfig(accountId, name, env);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
(0, index_1.logError)(err);
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
return developerTestAccount;
|
|
107
|
+
}
|
|
108
|
+
async function buildSandbox(name, accountConfig, sandboxType, env, force = false) {
|
|
109
|
+
let i18nKey;
|
|
110
|
+
if (sandboxType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX) {
|
|
111
|
+
i18nKey = 'lib.sandbox.create.loading.standard';
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
i18nKey = 'lib.sandbox.create.loading.developer';
|
|
115
|
+
}
|
|
116
|
+
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
117
|
+
const accountId = (0, config_1.getAccountId)(id);
|
|
118
|
+
if (!accountId) {
|
|
119
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.fail`));
|
|
120
|
+
}
|
|
121
|
+
SpinniesManager_1.default.init({
|
|
122
|
+
succeedColor: 'white',
|
|
123
|
+
});
|
|
124
|
+
logger_1.logger.log('');
|
|
125
|
+
SpinniesManager_1.default.add('buildSandbox', {
|
|
126
|
+
text: (0, lang_1.i18n)(`${i18nKey}.add`, {
|
|
127
127
|
accountName: name,
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
let sandbox;
|
|
131
|
+
try {
|
|
132
|
+
const sandboxApiType = sandboxes_1.SANDBOX_API_TYPE_MAP[sandboxType];
|
|
133
|
+
const { data } = await (0, sandboxHubs_1.createSandbox)(accountId, name, sandboxApiType);
|
|
134
|
+
sandbox = { name, ...data };
|
|
135
|
+
SpinniesManager_1.default.succeed('buildSandbox', {
|
|
136
|
+
text: (0, lang_1.i18n)(`${i18nKey}.succeed`, {
|
|
137
|
+
accountName: name,
|
|
138
|
+
accountId: sandbox.sandbox.sandboxHubId,
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
(0, index_1.debugError)(e);
|
|
144
|
+
SpinniesManager_1.default.fail('buildSandbox', {
|
|
145
|
+
text: (0, lang_1.i18n)(`${i18nKey}.fail`, {
|
|
146
|
+
accountName: name,
|
|
147
|
+
}),
|
|
130
148
|
});
|
|
149
|
+
(0, sandboxes_1.handleSandboxCreateError)(e, env, name, accountId);
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
await saveAccountToConfig(accountId, name, env, sandbox.personalAccessKey, force);
|
|
131
153
|
}
|
|
132
154
|
catch (err) {
|
|
133
|
-
logError(err);
|
|
155
|
+
(0, index_1.logError)(err);
|
|
134
156
|
throw err;
|
|
135
157
|
}
|
|
136
|
-
return
|
|
137
|
-
configAccountName,
|
|
138
|
-
result,
|
|
139
|
-
};
|
|
158
|
+
return sandbox;
|
|
140
159
|
}
|
|
141
|
-
module.exports = {
|
|
142
|
-
buildNewAccount,
|
|
143
|
-
saveAccountToConfig,
|
|
144
|
-
};
|
package/lib/commonOpts.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
2
1
|
import { Argv, Arguments } from 'yargs';
|
|
2
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
3
|
+
import { ConfigArgs } from '../types/Yargs';
|
|
3
4
|
export declare function addGlobalOptions(yargs: Argv): Argv<{
|
|
4
5
|
debug: boolean;
|
|
5
6
|
}>;
|
|
6
7
|
export declare function addAccountOptions(yargs: Argv): Argv;
|
|
7
|
-
export declare function addConfigOptions(yargs: Argv): Argv
|
|
8
|
+
export declare function addConfigOptions(yargs: Argv): Argv<ConfigArgs>;
|
|
8
9
|
export declare function addOverwriteOptions(yargs: Argv): Argv;
|
|
9
10
|
export declare function addCmsPublishModeOptions(yargs: Argv, { read, write }: {
|
|
10
11
|
read?: boolean;
|
|
@@ -18,12 +19,7 @@ export declare function setLogLevel(options: Arguments<{
|
|
|
18
19
|
export declare function getCommandName(argv: Arguments<{
|
|
19
20
|
_?: string[];
|
|
20
21
|
}>): string;
|
|
21
|
-
/**
|
|
22
|
-
* Obtains accountId using supplied --account flag or from environment variables
|
|
23
|
-
*/
|
|
24
|
-
export declare function getAccountId(options: Arguments<{
|
|
25
|
-
account?: number | string;
|
|
26
|
-
}>): number | null;
|
|
27
22
|
export declare function getCmsPublishMode(options: Arguments<{
|
|
28
23
|
cmsPublishMode?: CmsPublishMode;
|
|
24
|
+
derivedAccountId?: number;
|
|
29
25
|
}>): CmsPublishMode;
|
package/lib/commonOpts.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.addTestingOptions = addTestingOptions;
|
|
|
9
9
|
exports.addUseEnvironmentOptions = addUseEnvironmentOptions;
|
|
10
10
|
exports.setLogLevel = setLogLevel;
|
|
11
11
|
exports.getCommandName = getCommandName;
|
|
12
|
-
exports.getAccountId = getAccountId;
|
|
13
12
|
exports.getCmsPublishMode = getCmsPublishMode;
|
|
14
13
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
15
14
|
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
@@ -83,16 +82,6 @@ function setLogLevel(options) {
|
|
|
83
82
|
function getCommandName(argv) {
|
|
84
83
|
return (argv && argv._ && argv._[0]) || '';
|
|
85
84
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Obtains accountId using supplied --account flag or from environment variables
|
|
88
|
-
*/
|
|
89
|
-
function getAccountId(options) {
|
|
90
|
-
const { account } = options || {};
|
|
91
|
-
if (options?.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
92
|
-
return parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
93
|
-
}
|
|
94
|
-
return (0, config_1.getAccountId)(account);
|
|
95
|
-
}
|
|
96
85
|
function getCmsPublishMode(options) {
|
|
97
86
|
// 1. --cmsPublishMode
|
|
98
87
|
const { cmsPublishMode } = options;
|
|
@@ -100,9 +89,8 @@ function getCmsPublishMode(options) {
|
|
|
100
89
|
return cmsPublishMode.toLowerCase();
|
|
101
90
|
}
|
|
102
91
|
// 2. config[account].defaultCmsPublishMode
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
92
|
+
if (options.derivedAccountId) {
|
|
93
|
+
const accountConfig = (0, config_1.getAccountConfig)(options.derivedAccountId);
|
|
106
94
|
if (accountConfig && accountConfig.defaultCmsPublishMode) {
|
|
107
95
|
return accountConfig.defaultCmsPublishMode;
|
|
108
96
|
}
|
package/lib/constants.d.ts
CHANGED
|
@@ -6,13 +6,7 @@ export declare const MARKETPLACE_FOLDER: "@marketplace";
|
|
|
6
6
|
export declare const CONFIG_FLAGS: {
|
|
7
7
|
readonly USE_CUSTOM_OBJECT_HUBFILE: "useCustomObjectHubfile";
|
|
8
8
|
};
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const POLLING_STATUS: {
|
|
11
|
-
readonly SUCCESS: "SUCCESS";
|
|
12
|
-
readonly ERROR: "ERROR";
|
|
13
|
-
readonly REVERTED: "REVERTED";
|
|
14
|
-
readonly FAILURE: "FAILURE";
|
|
15
|
-
};
|
|
9
|
+
export declare const DEFAULT_POLLING_DELAY = 2000;
|
|
16
10
|
export declare const PROJECT_CONFIG_FILE: "hsproject.json";
|
|
17
11
|
export declare const PROJECT_BUILD_STATES: {
|
|
18
12
|
readonly BUILDING: "BUILDING";
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.
|
|
3
|
+
exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
|
|
4
4
|
exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
|
|
5
5
|
exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
|
|
6
6
|
exports.FEEDBACK_INTERVAL = 10;
|
|
@@ -9,13 +9,7 @@ exports.MARKETPLACE_FOLDER = '@marketplace';
|
|
|
9
9
|
exports.CONFIG_FLAGS = {
|
|
10
10
|
USE_CUSTOM_OBJECT_HUBFILE: 'useCustomObjectHubfile',
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
13
|
-
exports.POLLING_STATUS = {
|
|
14
|
-
SUCCESS: 'SUCCESS',
|
|
15
|
-
ERROR: 'ERROR',
|
|
16
|
-
REVERTED: 'REVERTED',
|
|
17
|
-
FAILURE: 'FAILURE',
|
|
18
|
-
};
|
|
12
|
+
exports.DEFAULT_POLLING_DELAY = 2000;
|
|
19
13
|
exports.PROJECT_CONFIG_FILE = 'hsproject.json';
|
|
20
14
|
exports.PROJECT_BUILD_STATES = {
|
|
21
15
|
BUILDING: 'BUILDING',
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export declare function isGloballyInstalled(command:
|
|
2
|
-
export declare function getLatestCliVersion(): {
|
|
1
|
+
export declare function isGloballyInstalled(command: string): Promise<boolean>;
|
|
2
|
+
export declare function getLatestCliVersion(): Promise<{
|
|
3
3
|
latest: string;
|
|
4
4
|
next: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function
|
|
5
|
+
}>;
|
|
6
|
+
export declare function installPackages({ packages, installLocations, }: {
|
|
7
|
+
packages?: string[];
|
|
8
|
+
installLocations?: string[];
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
export declare function getProjectPackageJsonLocations(): Promise<string[]>;
|
|
11
|
+
export declare function hasMissingPackages(directory: string): Promise<boolean>;
|
|
@@ -1,32 +1,36 @@
|
|
|
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
6
|
exports.isGloballyInstalled = isGloballyInstalled;
|
|
4
7
|
exports.getLatestCliVersion = getLatestCliVersion;
|
|
8
|
+
exports.installPackages = installPackages;
|
|
9
|
+
exports.getProjectPackageJsonLocations = getProjectPackageJsonLocations;
|
|
5
10
|
exports.hasMissingPackages = hasMissingPackages;
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const pkg = require('../package.json');
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
const projects_1 = require("./projects");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const fs_1 = require("@hubspot/local-dev-lib/fs");
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const ui_1 = require("./ui");
|
|
17
|
+
const util_1 = __importDefault(require("util"));
|
|
18
|
+
const lang_1 = require("./lang");
|
|
19
|
+
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
20
|
+
const fs_2 = __importDefault(require("fs"));
|
|
21
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
18
22
|
const DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
19
23
|
const i18nKey = `commands.project.subcommands.installDeps`;
|
|
20
24
|
class NoPackageJsonFilesError extends Error {
|
|
21
25
|
constructor(projectName) {
|
|
22
|
-
super(i18n(`${i18nKey}.noPackageJsonInProject`, {
|
|
26
|
+
super((0, lang_1.i18n)(`${i18nKey}.noPackageJsonInProject`, {
|
|
23
27
|
projectName,
|
|
24
|
-
link: uiLink('Learn how to create a project from scratch.', 'https://developers.hubspot.com/beta-docs/guides/crm/intro/create-a-project'),
|
|
28
|
+
link: (0, ui_1.uiLink)('Learn how to create a project from scratch.', 'https://developers.hubspot.com/beta-docs/guides/crm/intro/create-a-project'),
|
|
25
29
|
}));
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
async function isGloballyInstalled(command) {
|
|
29
|
-
const exec =
|
|
33
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
30
34
|
try {
|
|
31
35
|
await exec(`${command} --version`);
|
|
32
36
|
return true;
|
|
@@ -36,28 +40,28 @@ async function isGloballyInstalled(command) {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
async function getLatestCliVersion() {
|
|
39
|
-
const exec =
|
|
40
|
-
const { stdout } = await exec(`npm info ${
|
|
43
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
44
|
+
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
41
45
|
const { latest, next } = JSON.parse(stdout);
|
|
42
46
|
return { latest, next };
|
|
43
47
|
}
|
|
44
|
-
async function installPackages({ packages, installLocations }) {
|
|
48
|
+
async function installPackages({ packages, installLocations, }) {
|
|
45
49
|
const installDirs = installLocations || (await getProjectPackageJsonLocations());
|
|
46
50
|
await Promise.all(installDirs.map(async (dir) => {
|
|
47
|
-
await installPackagesInDirectory(
|
|
51
|
+
await installPackagesInDirectory(dir, packages);
|
|
48
52
|
}));
|
|
49
53
|
}
|
|
50
|
-
async function installPackagesInDirectory(
|
|
54
|
+
async function installPackagesInDirectory(directory, packages) {
|
|
51
55
|
const spinner = `installingDependencies-${directory}`;
|
|
52
|
-
const relativeDir =
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const relativeDir = path_1.default.relative(process.cwd(), directory);
|
|
57
|
+
SpinniesManager_1.default.init();
|
|
58
|
+
SpinniesManager_1.default.add(spinner, {
|
|
55
59
|
text: packages && packages.length
|
|
56
|
-
? i18n(`${i18nKey}.addingDependenciesToLocation`, {
|
|
60
|
+
? (0, lang_1.i18n)(`${i18nKey}.addingDependenciesToLocation`, {
|
|
57
61
|
dependencies: `[${packages.join(', ')}]`,
|
|
58
62
|
directory: relativeDir,
|
|
59
63
|
})
|
|
60
|
-
: i18n(`${i18nKey}.installingDependencies`, {
|
|
64
|
+
: (0, lang_1.i18n)(`${i18nKey}.installingDependencies`, {
|
|
61
65
|
directory: relativeDir,
|
|
62
66
|
}),
|
|
63
67
|
});
|
|
@@ -65,23 +69,23 @@ async function installPackagesInDirectory(packages, directory) {
|
|
|
65
69
|
if (packages) {
|
|
66
70
|
installCommand = `${installCommand} ${packages.join(' ')}`;
|
|
67
71
|
}
|
|
68
|
-
logger.debug(`Running ${installCommand}`);
|
|
72
|
+
logger_1.logger.debug(`Running ${installCommand}`);
|
|
69
73
|
try {
|
|
70
|
-
const exec =
|
|
74
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
71
75
|
await exec(installCommand, { cwd: directory });
|
|
72
|
-
|
|
73
|
-
text: i18n(`${i18nKey}.installationSuccessful`, {
|
|
76
|
+
SpinniesManager_1.default.succeed(spinner, {
|
|
77
|
+
text: (0, lang_1.i18n)(`${i18nKey}.installationSuccessful`, {
|
|
74
78
|
directory: relativeDir,
|
|
75
79
|
}),
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
catch (e) {
|
|
79
|
-
|
|
80
|
-
text: i18n(`${i18nKey}.installingDependenciesFailed`, {
|
|
83
|
+
SpinniesManager_1.default.fail(spinner, {
|
|
84
|
+
text: (0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
|
|
81
85
|
directory: relativeDir,
|
|
82
86
|
}),
|
|
83
87
|
});
|
|
84
|
-
throw new Error(i18n(`${i18nKey}.installingDependenciesFailed`, {
|
|
88
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.installingDependenciesFailed`, {
|
|
85
89
|
directory: relativeDir,
|
|
86
90
|
}), {
|
|
87
91
|
cause: e,
|
|
@@ -89,24 +93,24 @@ async function installPackagesInDirectory(packages, directory) {
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
async function getProjectPackageJsonLocations() {
|
|
92
|
-
const projectConfig = await getProjectConfig();
|
|
96
|
+
const projectConfig = await (0, projects_1.getProjectConfig)();
|
|
93
97
|
if (!projectConfig ||
|
|
94
98
|
!projectConfig.projectDir ||
|
|
95
99
|
!projectConfig.projectConfig) {
|
|
96
|
-
throw new Error(i18n(`${i18nKey}.noProjectConfig`));
|
|
100
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.noProjectConfig`));
|
|
97
101
|
}
|
|
98
102
|
const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
|
|
99
103
|
if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
|
|
100
|
-
throw new Error(i18n(`${i18nKey}.packageManagerNotInstalled`, {
|
|
104
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.packageManagerNotInstalled`, {
|
|
101
105
|
packageManager: DEFAULT_PACKAGE_MANAGER,
|
|
102
|
-
link: uiLink(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
|
|
106
|
+
link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
|
|
103
107
|
}));
|
|
104
108
|
}
|
|
105
|
-
if (!
|
|
106
|
-
!
|
|
109
|
+
if (!fs_2.default.existsSync(projectConfig.projectDir) ||
|
|
110
|
+
!fs_2.default.existsSync(path_1.default.join(projectDir, srcDir))) {
|
|
107
111
|
throw new NoPackageJsonFilesError(name);
|
|
108
112
|
}
|
|
109
|
-
const packageJsonFiles = (await walk(
|
|
113
|
+
const packageJsonFiles = (await (0, fs_1.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
|
|
110
114
|
!file.includes('node_modules') &&
|
|
111
115
|
!file.includes('.vite'));
|
|
112
116
|
if (packageJsonFiles.length === 0) {
|
|
@@ -114,23 +118,15 @@ async function getProjectPackageJsonLocations() {
|
|
|
114
118
|
}
|
|
115
119
|
const packageParentDirs = [];
|
|
116
120
|
packageJsonFiles.forEach(packageJsonFile => {
|
|
117
|
-
const parentDir =
|
|
121
|
+
const parentDir = path_1.default.dirname(packageJsonFile);
|
|
118
122
|
packageParentDirs.push(parentDir);
|
|
119
123
|
});
|
|
120
124
|
return packageParentDirs;
|
|
121
125
|
}
|
|
122
126
|
async function hasMissingPackages(directory) {
|
|
123
|
-
const exec =
|
|
127
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
124
128
|
const { stdout } = await exec(`npm install --ignore-scripts --dry-run`, {
|
|
125
129
|
cwd: directory,
|
|
126
130
|
});
|
|
127
131
|
return !stdout?.includes('up to date in');
|
|
128
132
|
}
|
|
129
|
-
module.exports = {
|
|
130
|
-
isGloballyInstalled,
|
|
131
|
-
installPackages,
|
|
132
|
-
DEFAULT_PACKAGE_MANAGER,
|
|
133
|
-
getProjectPackageJsonLocations,
|
|
134
|
-
getLatestCliVersion,
|
|
135
|
-
hasMissingPackages,
|
|
136
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
2
|
import { FetchDeveloperTestAccountsResponse } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
3
3
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
export declare function getHasDevTestAccounts(appDeveloperAccountConfig: CLIAccount): boolean;
|
|
4
5
|
export declare function validateDevTestAccountUsageLimits(accountConfig: CLIAccount): Promise<FetchDeveloperTestAccountsResponse | null>;
|
|
5
6
|
export declare function handleDeveloperTestAccountCreateError(err: unknown, accountId: number, env: Environment, portalLimit: number): never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHasDevTestAccounts = getHasDevTestAccounts;
|
|
3
4
|
exports.validateDevTestAccountUsageLimits = validateDevTestAccountUsageLimits;
|
|
4
5
|
exports.handleDeveloperTestAccountCreateError = handleDeveloperTestAccountCreateError;
|
|
5
6
|
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
@@ -11,6 +11,7 @@ const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
|
11
11
|
const suppressError_1 = require("./suppressError");
|
|
12
12
|
const lang_1 = require("../lang");
|
|
13
13
|
const util_1 = __importDefault(require("util"));
|
|
14
|
+
const axios_1 = require("axios");
|
|
14
15
|
const i18nKey = 'lib.errorHandlers.index';
|
|
15
16
|
function logError(error, context) {
|
|
16
17
|
debugError(error, context);
|
|
@@ -49,9 +50,11 @@ function debugError(error, context) {
|
|
|
49
50
|
else {
|
|
50
51
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorOccurred`, { error: String(error) }));
|
|
51
52
|
}
|
|
52
|
-
if (error instanceof Error) {
|
|
53
|
+
if (error instanceof Error && error.cause) {
|
|
53
54
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorCause`, {
|
|
54
|
-
cause:
|
|
55
|
+
cause: (0, axios_1.isAxiosError)(error.cause)
|
|
56
|
+
? `${error.cause}`
|
|
57
|
+
: util_1.default.inspect(error.cause, false, null, true),
|
|
55
58
|
}));
|
|
56
59
|
}
|
|
57
60
|
if (context) {
|
package/lib/localDev.d.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
3
|
+
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
4
|
+
import { Project } from '@hubspot/local-dev-lib/types/Project';
|
|
5
|
+
import { ProjectConfig } from '../types/Projects';
|
|
6
|
+
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
7
|
+
export declare function confirmDefaultAccountIsTarget(accountConfig: CLIAccount): Promise<void>;
|
|
8
|
+
export declare function checkIfDefaultAccountIsSupported(accountConfig: CLIAccount, hasPublicApps: boolean): void;
|
|
9
|
+
export declare function checkIfParentAccountIsAuthed(accountConfig: CLIAccount): void;
|
|
10
|
+
export declare function checkIfAccountFlagIsSupported(accountConfig: CLIAccount, hasPublicApps: boolean): void;
|
|
11
|
+
export declare function suggestRecommendedNestedAccount(accounts: CLIAccount[], accountConfig: CLIAccount, hasPublicApps: boolean): Promise<CLIAccount | DeveloperTestAccount>;
|
|
12
|
+
export declare function createSandboxForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
13
|
+
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
14
|
+
export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
|
|
15
|
+
export declare function createNewProjectForLocalDev(projectConfig: ProjectConfig, targetAccountId: number, shouldCreateWithoutConfirmation: boolean, hasPublicApps: boolean): Promise<Project>;
|
|
16
|
+
export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number): Promise<Build>;
|
|
17
|
+
export declare function getAccountHomeUrl(accountId: number): string;
|