@hubspot/cli 5.2.1-beta.0 → 5.2.1-beta.10
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/bin/hs +1 -1
- package/commands/accounts/clean.js +8 -8
- package/commands/accounts/info.js +3 -3
- package/commands/accounts/list.js +14 -13
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +3 -3
- package/commands/accounts/use.js +1 -1
- package/commands/accounts.js +3 -3
- package/commands/auth.js +7 -9
- package/commands/cms/convertFields.js +1 -1
- package/commands/cms/lighthouseScore.js +4 -4
- package/commands/cms/reactModules.js +1 -1
- package/commands/cms.js +3 -3
- package/commands/config/set/allowUsageTracking.js +1 -2
- package/commands/config/set/defaultMode.js +1 -1
- package/commands/config/set/httpTimeout.js +1 -1
- package/commands/config/set.js +1 -1
- package/commands/config.js +3 -3
- package/commands/create/api-sample.js +1 -1
- package/commands/create/module.js +1 -1
- package/commands/create/template.js +1 -1
- package/commands/create.js +1 -1
- package/commands/customObject/create.js +1 -1
- package/commands/customObject/schema/create.js +2 -3
- package/commands/customObject/schema/delete.js +1 -2
- package/commands/customObject/schema/fetch-all.js +1 -2
- package/commands/customObject/schema/fetch.js +1 -2
- package/commands/customObject/schema/list.js +1 -1
- package/commands/customObject/schema/update.js +2 -3
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -3
- package/commands/feedback.js +4 -6
- package/commands/fetch.js +6 -6
- package/commands/filemanager/fetch.js +4 -4
- package/commands/filemanager/upload.js +4 -4
- package/commands/filemanager.js +4 -4
- package/commands/functions/deploy.js +7 -23
- package/commands/functions/list.js +4 -4
- package/commands/functions/server.js +4 -4
- package/commands/functions.js +3 -3
- package/commands/hubdb/clear.js +4 -4
- package/commands/hubdb/create.js +4 -4
- package/commands/hubdb/delete.js +4 -4
- package/commands/hubdb/fetch.js +4 -4
- package/commands/hubdb.js +3 -3
- package/commands/init.js +6 -8
- package/commands/lint.js +3 -3
- package/commands/list.js +4 -4
- package/commands/logs.js +4 -4
- package/commands/module/marketplace-validate.js +5 -5
- package/commands/module.js +3 -3
- package/commands/mv.js +4 -4
- package/commands/open.js +4 -4
- package/commands/project/add.js +1 -1
- package/commands/project/create.js +4 -4
- package/commands/project/deploy.js +4 -4
- package/commands/project/dev.js +139 -264
- package/commands/project/download.js +11 -7
- package/commands/project/listBuilds.js +4 -4
- package/commands/project/logs.js +4 -4
- package/commands/project/migrateApp.js +227 -0
- package/commands/project/open.js +12 -8
- package/commands/project/upload.js +15 -7
- package/commands/project/watch.js +4 -4
- package/commands/project.js +5 -3
- package/commands/remove.js +4 -4
- package/commands/sandbox/create.js +16 -16
- package/commands/sandbox/delete.js +5 -5
- package/commands/sandbox/sync.js +11 -9
- package/commands/sandbox.js +3 -3
- package/commands/secrets/addSecret.js +4 -4
- package/commands/secrets/deleteSecret.js +4 -4
- package/commands/secrets/listSecrets.js +4 -4
- package/commands/secrets/updateSecret.js +4 -4
- package/commands/secrets.js +3 -3
- package/commands/theme/generate-selectors.js +1 -1
- package/commands/theme/marketplace-validate.js +5 -5
- package/commands/theme/preview.js +52 -17
- package/commands/theme.js +1 -1
- package/commands/upload.js +5 -5
- package/commands/watch.js +61 -18
- package/jest.config.js +1 -0
- package/lang/en.lyaml +1426 -1336
- package/lib/DevServerManager.js +3 -2
- package/lib/LocalDevManager.js +194 -38
- package/lib/__tests__/{commonOpts.js → commonOpts.test.js} +3 -0
- package/lib/__tests__/downloadProjectPrompt.test.js +31 -0
- package/lib/__tests__/projects.test.js +13 -17
- package/lib/__tests__/{serverlessLogs.js → serverlessLogs.test.js} +1 -0
- package/lib/accountTypes.js +34 -0
- package/lib/buildAccount.js +197 -0
- package/lib/commonOpts.js +1 -1
- package/lib/constants.js +10 -0
- package/lib/developerTestAccounts.js +98 -4
- package/lib/errorHandlers/apiErrors.js +1 -1
- package/lib/errorHandlers/overrideErrors.js +1 -1
- package/lib/errorHandlers/standardErrors.js +1 -1
- package/lib/generate-selectors.js +1 -1
- package/lib/localDev.js +451 -0
- package/lib/marketplace-validate.js +11 -3
- package/lib/polling.js +26 -0
- package/lib/process.js +1 -1
- package/lib/projectStructure.js +12 -2
- package/lib/projects.js +99 -10
- package/lib/projectsWatch.js +1 -1
- package/lib/prompts/accountNamePrompt.js +81 -0
- package/lib/prompts/accountsPrompt.js +1 -1
- package/lib/prompts/activeInstallConfirmationPrompt.js +20 -0
- package/lib/prompts/buildIdPrompt.js +1 -1
- package/lib/prompts/cleanUploadPrompt.js +1 -1
- package/lib/prompts/cmsFieldPrompt.js +1 -1
- package/lib/prompts/createApiSamplePrompt.js +1 -1
- package/lib/prompts/createFunctionPrompt.js +1 -1
- package/lib/prompts/createModulePrompt.js +1 -1
- package/lib/prompts/createProjectPrompt.js +32 -10
- package/lib/prompts/createTemplatePrompt.js +1 -1
- package/lib/prompts/downloadProjectPrompt.js +5 -6
- package/lib/prompts/feedbackPrompt.js +1 -1
- package/lib/prompts/folderOverwritePrompt.js +1 -1
- package/lib/prompts/installPublicAppPrompt.js +42 -0
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +19 -1
- package/lib/prompts/projectAddPrompt.js +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +127 -14
- package/lib/prompts/projectNamePrompt.js +2 -2
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/prompts/sandboxesPrompt.js +14 -43
- package/lib/prompts/secretPrompt.js +1 -1
- package/lib/prompts/selectPublicAppPrompt.js +69 -0
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -1
- package/lib/prompts/uploadPrompt.js +1 -1
- package/lib/sandboxSync.js +2 -2
- package/lib/sandboxes.js +168 -30
- package/lib/ui/git.js +1 -1
- package/lib/ui/index.js +5 -14
- package/lib/ui/serverlessFunctionLogs.js +1 -1
- package/package.json +6 -6
- package/lib/prompts/enterAccountNamePrompt.js +0 -33
- package/lib/sandboxCreate.js +0 -319
- /package/lib/__tests__/{validation.js → validation.test.js} +0 -0
package/lib/sandboxCreate.js
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
const SpinniesManager = require('./ui/SpinniesManager');
|
|
2
|
-
const {
|
|
3
|
-
getSandboxLimit,
|
|
4
|
-
getHasSandboxesByType,
|
|
5
|
-
sandboxApiTypeMap,
|
|
6
|
-
} = require('./sandboxes');
|
|
7
|
-
const { i18n } = require('./lang');
|
|
8
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
9
|
-
const {
|
|
10
|
-
debugErrorAndContext,
|
|
11
|
-
logErrorInstance,
|
|
12
|
-
} = require('./errorHandlers/standardErrors');
|
|
13
|
-
const {
|
|
14
|
-
isMissingScopeError,
|
|
15
|
-
isSpecifiedError,
|
|
16
|
-
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
17
|
-
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
18
|
-
const { getEnv, getAccountId } = require('@hubspot/local-dev-lib/config');
|
|
19
|
-
const { createSandbox } = require('@hubspot/local-dev-lib/sandboxes');
|
|
20
|
-
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
21
|
-
const {
|
|
22
|
-
getAccessToken,
|
|
23
|
-
updateConfigWithAccessToken,
|
|
24
|
-
} = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
25
|
-
const { uiAccountDescription } = require('./ui');
|
|
26
|
-
const {
|
|
27
|
-
personalAccessKeyPrompt,
|
|
28
|
-
} = require('./prompts/personalAccessKeyPrompt');
|
|
29
|
-
const { enterAccountNamePrompt } = require('./prompts/enterAccountNamePrompt');
|
|
30
|
-
const {
|
|
31
|
-
accountNameExistsInConfig,
|
|
32
|
-
writeConfig,
|
|
33
|
-
updateAccountConfig,
|
|
34
|
-
} = require('@hubspot/local-dev-lib/config');
|
|
35
|
-
const {
|
|
36
|
-
HUBSPOT_ACCOUNT_TYPES,
|
|
37
|
-
} = require('@hubspot/local-dev-lib/constants/config');
|
|
38
|
-
|
|
39
|
-
const i18nKey = 'cli.lib.sandbox.create';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {String} env - Environment (QA/Prod)
|
|
43
|
-
* @param {Object} result - Sandbox instance returned from API
|
|
44
|
-
* @param {Boolean} force - Force flag to skip prompt
|
|
45
|
-
* @returns {String} validName saved into config
|
|
46
|
-
*/
|
|
47
|
-
const saveSandboxToConfig = async (env, result, force = false) => {
|
|
48
|
-
let personalAccessKey = result.personalAccessKey;
|
|
49
|
-
if (!personalAccessKey) {
|
|
50
|
-
const configData = await personalAccessKeyPrompt({
|
|
51
|
-
env,
|
|
52
|
-
account: result.sandbox.sandboxHubId,
|
|
53
|
-
});
|
|
54
|
-
personalAccessKey = configData.personalAccessKey;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let updatedConfig;
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const token = await getAccessToken(personalAccessKey, env);
|
|
61
|
-
updatedConfig = await updateConfigWithAccessToken(
|
|
62
|
-
token,
|
|
63
|
-
personalAccessKey,
|
|
64
|
-
env
|
|
65
|
-
);
|
|
66
|
-
} catch (e) {
|
|
67
|
-
logErrorInstance(e);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!updatedConfig) {
|
|
71
|
-
throw new Error('Failed to update config with personal access key.');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let validName = updatedConfig.name;
|
|
75
|
-
if (!updatedConfig.name) {
|
|
76
|
-
const nameForConfig = result.sandbox.name
|
|
77
|
-
.toLowerCase()
|
|
78
|
-
.split(' ')
|
|
79
|
-
.join('-');
|
|
80
|
-
validName = nameForConfig;
|
|
81
|
-
const invalidAccountName = accountNameExistsInConfig(nameForConfig);
|
|
82
|
-
if (invalidAccountName) {
|
|
83
|
-
if (!force) {
|
|
84
|
-
logger.log('');
|
|
85
|
-
logger.warn(
|
|
86
|
-
i18n(
|
|
87
|
-
`cli.lib.prompts.enterAccountNamePrompt.errors.accountNameExists`,
|
|
88
|
-
{ name: nameForConfig }
|
|
89
|
-
)
|
|
90
|
-
);
|
|
91
|
-
const { name: promptName } = await enterAccountNamePrompt(
|
|
92
|
-
nameForConfig + `_${result.sandbox.sandboxHubId}`
|
|
93
|
-
);
|
|
94
|
-
validName = promptName;
|
|
95
|
-
} else {
|
|
96
|
-
// Basic invalid name handling when force flag is passed
|
|
97
|
-
validName = nameForConfig + `_${result.sandbox.sandboxHubId}`;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
updateAccountConfig({
|
|
102
|
-
...updatedConfig,
|
|
103
|
-
environment: updatedConfig.env,
|
|
104
|
-
tokenInfo: updatedConfig.auth.tokenInfo,
|
|
105
|
-
name: validName,
|
|
106
|
-
});
|
|
107
|
-
writeConfig();
|
|
108
|
-
|
|
109
|
-
logger.log('');
|
|
110
|
-
return validName;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @param {String} name - Name of sandbox
|
|
115
|
-
* @param {String} type - Sandbox type to be created (STANDARD_SANDBOX/DEVELOPMENT_SANDBOX)
|
|
116
|
-
* @param {Object} accountConfig - Account config of parent portal
|
|
117
|
-
* @param {String} env - Environment (QA/Prod)
|
|
118
|
-
* @returns {Object} Object containing sandboxConfigName string and sandbox instance from API
|
|
119
|
-
*/
|
|
120
|
-
const buildSandbox = async ({
|
|
121
|
-
name,
|
|
122
|
-
type,
|
|
123
|
-
accountConfig,
|
|
124
|
-
env,
|
|
125
|
-
force = false,
|
|
126
|
-
}) => {
|
|
127
|
-
SpinniesManager.init({
|
|
128
|
-
succeedColor: 'white',
|
|
129
|
-
});
|
|
130
|
-
const accountId = getAccountId(accountConfig.portalId);
|
|
131
|
-
|
|
132
|
-
let result;
|
|
133
|
-
const loadingLangKey =
|
|
134
|
-
type === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
|
|
135
|
-
? 'developer'
|
|
136
|
-
: 'standard';
|
|
137
|
-
const spinniesI18nKey = `${i18nKey}.loading.${loadingLangKey}`;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
logger.log('');
|
|
141
|
-
SpinniesManager.add('sandboxCreate', {
|
|
142
|
-
text: i18n(`${spinniesI18nKey}.add`, {
|
|
143
|
-
sandboxName: name,
|
|
144
|
-
}),
|
|
145
|
-
});
|
|
146
|
-
const sandboxApiType = sandboxApiTypeMap[type]; // API expects sandbox type as 1 or 2
|
|
147
|
-
result = await createSandbox(accountId, name, sandboxApiType);
|
|
148
|
-
|
|
149
|
-
SpinniesManager.succeed('sandboxCreate', {
|
|
150
|
-
text: i18n(`${spinniesI18nKey}.succeed`, {
|
|
151
|
-
name: result.sandbox.name,
|
|
152
|
-
sandboxHubId: result.sandbox.sandboxHubId,
|
|
153
|
-
}),
|
|
154
|
-
});
|
|
155
|
-
} catch (err) {
|
|
156
|
-
debugErrorAndContext(err);
|
|
157
|
-
|
|
158
|
-
SpinniesManager.fail('sandboxCreate', {
|
|
159
|
-
text: i18n(`${spinniesI18nKey}.fail`, {
|
|
160
|
-
sandboxName: name,
|
|
161
|
-
}),
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
if (isMissingScopeError(err)) {
|
|
165
|
-
logger.error(
|
|
166
|
-
i18n(`${i18nKey}.failure.scopes.message`, {
|
|
167
|
-
accountName: uiAccountDescription(accountId),
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
171
|
-
const url = `${websiteOrigin}/personal-access-key/${accountId}`;
|
|
172
|
-
logger.info(
|
|
173
|
-
i18n(`${i18nKey}.failure.scopes.instructions`, {
|
|
174
|
-
accountName: uiAccountDescription(accountId),
|
|
175
|
-
url,
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
} else if (
|
|
179
|
-
isSpecifiedError(err, {
|
|
180
|
-
statusCode: 403,
|
|
181
|
-
category: 'BANNED',
|
|
182
|
-
subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
|
|
183
|
-
})
|
|
184
|
-
) {
|
|
185
|
-
logger.log('');
|
|
186
|
-
logger.error(
|
|
187
|
-
i18n(`${i18nKey}.failure.invalidUser`, {
|
|
188
|
-
accountName: name,
|
|
189
|
-
parentAccountName: uiAccountDescription(accountId),
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
logger.log('');
|
|
193
|
-
} else if (
|
|
194
|
-
isSpecifiedError(err, {
|
|
195
|
-
statusCode: 403,
|
|
196
|
-
category: 'BANNED',
|
|
197
|
-
subCategory: 'SandboxErrors.DEVELOPMENT_SANDBOX_ACCESS_NOT_ALLOWED',
|
|
198
|
-
})
|
|
199
|
-
) {
|
|
200
|
-
logger.log('');
|
|
201
|
-
logger.error(
|
|
202
|
-
i18n(`${i18nKey}.failure.403Gating`, {
|
|
203
|
-
accountName: name,
|
|
204
|
-
parentAccountName: uiAccountDescription(accountId),
|
|
205
|
-
accountId,
|
|
206
|
-
})
|
|
207
|
-
);
|
|
208
|
-
logger.log('');
|
|
209
|
-
} else if (
|
|
210
|
-
isSpecifiedError(err, {
|
|
211
|
-
statusCode: 400,
|
|
212
|
-
category: 'VALIDATION_ERROR',
|
|
213
|
-
subCategory:
|
|
214
|
-
'SandboxErrors.NUM_DEVELOPMENT_SANDBOXES_LIMIT_EXCEEDED_ERROR',
|
|
215
|
-
}) &&
|
|
216
|
-
err.error &&
|
|
217
|
-
err.error.message
|
|
218
|
-
) {
|
|
219
|
-
logger.log('');
|
|
220
|
-
const devSandboxLimit = getSandboxLimit(err.error);
|
|
221
|
-
const plural = devSandboxLimit !== 1;
|
|
222
|
-
const hasDevelopmentSandboxes = getHasSandboxesByType(
|
|
223
|
-
accountConfig,
|
|
224
|
-
HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX
|
|
225
|
-
);
|
|
226
|
-
if (hasDevelopmentSandboxes) {
|
|
227
|
-
logger.error(
|
|
228
|
-
i18n(
|
|
229
|
-
`${i18nKey}.failure.alreadyInConfig.developer.${
|
|
230
|
-
plural ? 'other' : 'one'
|
|
231
|
-
}`,
|
|
232
|
-
{
|
|
233
|
-
accountName: uiAccountDescription(accountId),
|
|
234
|
-
limit: devSandboxLimit,
|
|
235
|
-
}
|
|
236
|
-
)
|
|
237
|
-
);
|
|
238
|
-
} else {
|
|
239
|
-
const baseUrl = getHubSpotWebsiteOrigin(getValidEnv(getEnv(accountId)));
|
|
240
|
-
logger.error(
|
|
241
|
-
i18n(
|
|
242
|
-
`${i18nKey}.failure.limit.developer.${plural ? 'other' : 'one'}`,
|
|
243
|
-
{
|
|
244
|
-
accountName: uiAccountDescription(accountId),
|
|
245
|
-
limit: devSandboxLimit,
|
|
246
|
-
link: `${baseUrl}/sandboxes-developer/${accountId}/development`,
|
|
247
|
-
}
|
|
248
|
-
)
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
logger.log('');
|
|
252
|
-
} else if (
|
|
253
|
-
isSpecifiedError(err, {
|
|
254
|
-
statusCode: 400,
|
|
255
|
-
category: 'VALIDATION_ERROR',
|
|
256
|
-
subCategory:
|
|
257
|
-
'SandboxErrors.NUM_STANDARD_SANDBOXES_LIMIT_EXCEEDED_ERROR',
|
|
258
|
-
}) &&
|
|
259
|
-
err.error &&
|
|
260
|
-
err.error.message
|
|
261
|
-
) {
|
|
262
|
-
logger.log('');
|
|
263
|
-
const standardSandboxLimit = getSandboxLimit(err.error);
|
|
264
|
-
const plural = standardSandboxLimit !== 1;
|
|
265
|
-
const hasStandardSandboxes = getHasSandboxesByType(
|
|
266
|
-
accountConfig,
|
|
267
|
-
HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
|
|
268
|
-
);
|
|
269
|
-
if (hasStandardSandboxes) {
|
|
270
|
-
logger.error(
|
|
271
|
-
i18n(
|
|
272
|
-
`${i18nKey}.failure.alreadyInConfig.standard.${
|
|
273
|
-
plural ? 'other' : 'one'
|
|
274
|
-
}`,
|
|
275
|
-
{
|
|
276
|
-
accountName: uiAccountDescription(accountId),
|
|
277
|
-
limit: standardSandboxLimit,
|
|
278
|
-
}
|
|
279
|
-
)
|
|
280
|
-
);
|
|
281
|
-
} else {
|
|
282
|
-
const baseUrl = getHubSpotWebsiteOrigin(getValidEnv(getEnv(accountId)));
|
|
283
|
-
logger.error(
|
|
284
|
-
i18n(
|
|
285
|
-
`${i18nKey}.failure.limit.standard.${plural ? 'other' : 'one'}`,
|
|
286
|
-
{
|
|
287
|
-
accountName: uiAccountDescription(accountId),
|
|
288
|
-
limit: standardSandboxLimit,
|
|
289
|
-
link: `${baseUrl}/sandboxes-developer/${accountId}/standard`,
|
|
290
|
-
}
|
|
291
|
-
)
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
logger.log('');
|
|
295
|
-
} else {
|
|
296
|
-
logErrorInstance(err);
|
|
297
|
-
}
|
|
298
|
-
throw err;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
let sandboxConfigName;
|
|
302
|
-
|
|
303
|
-
try {
|
|
304
|
-
// Response contains PAK, save to config here
|
|
305
|
-
sandboxConfigName = await saveSandboxToConfig(env, result, force);
|
|
306
|
-
} catch (err) {
|
|
307
|
-
logErrorInstance(err);
|
|
308
|
-
throw err;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
sandboxConfigName,
|
|
313
|
-
result,
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
module.exports = {
|
|
318
|
-
buildSandbox,
|
|
319
|
-
};
|
|
File without changes
|