@hubspot/cli 6.1.1 → 6.2.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 +2 -2
- package/commands/accounts/clean.js +5 -7
- package/commands/auth.js +5 -5
- package/commands/cms/convertFields.js +2 -2
- package/commands/cms/lighthouseScore.js +47 -36
- package/commands/create/function.js +2 -2
- package/commands/create/module.js +2 -2
- package/commands/create/template.js +2 -2
- package/commands/create.js +3 -5
- package/commands/customObject/create.js +2 -2
- package/commands/customObject/schema/create.js +4 -4
- package/commands/customObject/schema/delete.js +2 -3
- package/commands/customObject/schema/fetch-all.js +2 -5
- package/commands/customObject/schema/fetch.js +2 -4
- package/commands/customObject/schema/list.js +2 -4
- package/commands/customObject/schema/update.js +4 -4
- package/commands/fetch.js +2 -2
- package/commands/filemanager/fetch.js +2 -2
- package/commands/filemanager/upload.js +3 -7
- package/commands/functions/deploy.js +6 -11
- package/commands/functions/list.js +3 -6
- package/commands/hubdb/clear.js +5 -3
- package/commands/hubdb/create.js +2 -2
- package/commands/hubdb/delete.js +2 -2
- package/commands/hubdb/fetch.js +2 -2
- package/commands/init.js +4 -7
- package/commands/lint.js +2 -2
- package/commands/list.js +4 -6
- package/commands/logs.js +6 -3
- package/commands/mv.js +3 -6
- package/commands/project/__tests__/deploy.test.js +37 -26
- package/commands/project/__tests__/logs.test.js +4 -5
- package/commands/project/add.js +2 -2
- package/commands/project/cloneApp.js +14 -10
- package/commands/project/create.js +2 -6
- package/commands/project/deploy.js +9 -12
- package/commands/project/dev.js +6 -5
- package/commands/project/download.js +7 -9
- package/commands/project/listBuilds.js +8 -12
- package/commands/project/logs.js +2 -2
- package/commands/project/migrateApp.js +20 -15
- package/commands/project/upload.js +4 -10
- package/commands/project/watch.js +8 -13
- package/commands/remove.js +2 -5
- package/commands/sandbox/create.js +4 -6
- package/commands/sandbox/delete.js +6 -12
- package/commands/secrets/addSecret.js +2 -5
- package/commands/secrets/deleteSecret.js +2 -5
- package/commands/secrets/listSecrets.js +5 -6
- package/commands/secrets/updateSecret.js +2 -5
- package/commands/theme/preview.js +2 -5
- package/commands/upload.js +3 -7
- package/commands/watch.js +3 -7
- package/lang/en.lyaml +12 -15
- package/lib/LocalDevManager.js +8 -6
- package/lib/__tests__/downloadProjectPrompt.test.js +1 -1
- package/lib/__tests__/projectLogsManager.test.js +19 -17
- package/lib/__tests__/serverlessLogs.test.js +13 -9
- package/lib/buildAccount.js +10 -10
- package/lib/developerTestAccounts.js +27 -27
- package/lib/errorHandlers/index.js +101 -0
- package/lib/errorHandlers/{overrideErrors.js → suppressError.js} +7 -7
- package/lib/hasFeature.js +15 -0
- package/lib/localDev.js +26 -19
- package/lib/marketplace-validate.js +3 -3
- package/lib/oauth.js +1 -1
- package/lib/polling.js +1 -1
- package/lib/projectLogsManager.js +3 -4
- package/lib/projectStructure.js +2 -2
- package/lib/projects.js +34 -24
- package/lib/projectsWatch.js +7 -12
- package/lib/prompts/createProjectPrompt.js +14 -5
- package/lib/prompts/downloadProjectPrompt.js +3 -6
- package/lib/prompts/projectDevTargetAccountPrompt.js +8 -6
- package/lib/prompts/selectPublicAppPrompt.js +3 -3
- package/lib/sandboxSync.js +7 -7
- package/lib/sandboxes.js +11 -7
- package/lib/schema.js +2 -2
- package/lib/serverlessLogs.js +67 -15
- package/lib/upload.js +2 -2
- package/lib/validation.js +2 -2
- package/package.json +6 -6
- package/lib/errorHandlers/apiErrors.js +0 -145
- package/lib/errorHandlers/fileSystemErrors.js +0 -20
- package/lib/errorHandlers/standardErrors.js +0 -103
package/commands/hubdb/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
4
|
-
const {
|
|
4
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
5
5
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
6
6
|
const { createHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
7
7
|
|
|
@@ -56,7 +56,7 @@ exports.handler = async options => {
|
|
|
56
56
|
src,
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
|
-
|
|
59
|
+
logError(e);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
3
3
|
const { deleteTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
4
4
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
5
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -40,7 +40,7 @@ exports.handler = async options => {
|
|
|
40
40
|
tableId,
|
|
41
41
|
})
|
|
42
42
|
);
|
|
43
|
-
|
|
43
|
+
logError(e);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
package/commands/hubdb/fetch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
3
3
|
const { downloadHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
4
4
|
|
|
5
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -37,7 +37,7 @@ exports.handler = async options => {
|
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
} catch (e) {
|
|
40
|
-
|
|
40
|
+
logError(e);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
package/commands/init.js
CHANGED
|
@@ -11,10 +11,7 @@ const { handleExit } = require('../lib/process');
|
|
|
11
11
|
const {
|
|
12
12
|
checkAndAddConfigToGitignore,
|
|
13
13
|
} = require('@hubspot/local-dev-lib/gitignore');
|
|
14
|
-
const {
|
|
15
|
-
logErrorInstance,
|
|
16
|
-
debugErrorAndContext,
|
|
17
|
-
} = require('../lib/errorHandlers/standardErrors');
|
|
14
|
+
const { debugError, logError } = require('../lib/errorHandlers/index');
|
|
18
15
|
const {
|
|
19
16
|
OAUTH_AUTH_METHOD,
|
|
20
17
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
@@ -71,7 +68,7 @@ const personalAccessKeyConfigCreationFlow = async (env, account) => {
|
|
|
71
68
|
true
|
|
72
69
|
);
|
|
73
70
|
} catch (e) {
|
|
74
|
-
|
|
71
|
+
logError(e);
|
|
75
72
|
}
|
|
76
73
|
return updatedConfig;
|
|
77
74
|
};
|
|
@@ -140,7 +137,7 @@ exports.handler = async options => {
|
|
|
140
137
|
try {
|
|
141
138
|
checkAndAddConfigToGitignore(configPath);
|
|
142
139
|
} catch (e) {
|
|
143
|
-
|
|
140
|
+
debugError(e);
|
|
144
141
|
}
|
|
145
142
|
|
|
146
143
|
logger.log('');
|
|
@@ -165,7 +162,7 @@ exports.handler = async options => {
|
|
|
165
162
|
);
|
|
166
163
|
process.exit(EXIT_CODES.SUCCESS);
|
|
167
164
|
} catch (err) {
|
|
168
|
-
|
|
165
|
+
logError(err);
|
|
169
166
|
await trackAuthAction('init', authType, TRACKING_STATUS.ERROR);
|
|
170
167
|
process.exit(EXIT_CODES.ERROR);
|
|
171
168
|
}
|
package/commands/lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { lint } = require('@hubspot/local-dev-lib/cms/validate');
|
|
2
2
|
const { printHublValidationResult } = require('../lib/hublValidate');
|
|
3
3
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
4
|
-
const {
|
|
4
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
addConfigOptions,
|
|
@@ -41,7 +41,7 @@ exports.handler = async options => {
|
|
|
41
41
|
});
|
|
42
42
|
} catch (err) {
|
|
43
43
|
logger.groupEnd(groupName);
|
|
44
|
-
|
|
44
|
+
logError(err, { accountId });
|
|
45
45
|
process.exit(EXIT_CODES.ERROR);
|
|
46
46
|
}
|
|
47
47
|
logger.groupEnd(groupName);
|
package/commands/list.js
CHANGED
|
@@ -9,10 +9,7 @@ const { trackCommandUsage } = require('../lib/usageTracking');
|
|
|
9
9
|
const { isPathFolder } = require('../lib/filesystem');
|
|
10
10
|
|
|
11
11
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
12
|
-
const {
|
|
13
|
-
logApiErrorInstance,
|
|
14
|
-
ApiErrorContext,
|
|
15
|
-
} = require('../lib/errorHandlers/apiErrors');
|
|
12
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
16
13
|
const {
|
|
17
14
|
getDirectoryContentsByPath,
|
|
18
15
|
} = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
@@ -43,9 +40,10 @@ exports.handler = async options => {
|
|
|
43
40
|
);
|
|
44
41
|
|
|
45
42
|
try {
|
|
46
|
-
|
|
43
|
+
const { data } = await getDirectoryContentsByPath(accountId, directoryPath);
|
|
44
|
+
contentsResp = data;
|
|
47
45
|
} catch (e) {
|
|
48
|
-
|
|
46
|
+
logError(e);
|
|
49
47
|
process.exit(EXIT_CODES.SUCCESS);
|
|
50
48
|
}
|
|
51
49
|
|
package/commands/logs.js
CHANGED
|
@@ -15,11 +15,12 @@ const { tailLogs } = require('../lib/serverlessLogs');
|
|
|
15
15
|
const { loadAndValidateOptions } = require('../lib/validation');
|
|
16
16
|
const { i18n } = require('../lib/lang');
|
|
17
17
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
18
|
+
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
18
19
|
|
|
19
20
|
const i18nKey = 'commands.logs';
|
|
20
21
|
|
|
21
22
|
const handleLogsError = (e, accountId, functionPath) => {
|
|
22
|
-
if (e.
|
|
23
|
+
if (isHubSpotHttpError(e) && (e.status === 404 || e.status == 400)) {
|
|
23
24
|
logger.error(
|
|
24
25
|
i18n(`${i18nKey}.errors.noLogsFound`, {
|
|
25
26
|
accountId,
|
|
@@ -61,14 +62,16 @@ const endpointLog = async (accountId, options) => {
|
|
|
61
62
|
});
|
|
62
63
|
} else if (latest) {
|
|
63
64
|
try {
|
|
64
|
-
|
|
65
|
+
const { data } = await getLatestFunctionLog(accountId, functionPath);
|
|
66
|
+
logsResp = data;
|
|
65
67
|
} catch (e) {
|
|
66
68
|
handleLogsError(e, accountId, functionPath);
|
|
67
69
|
process.exit(EXIT_CODES.ERROR);
|
|
68
70
|
}
|
|
69
71
|
} else {
|
|
70
72
|
try {
|
|
71
|
-
|
|
73
|
+
const { data } = await getFunctionLogs(accountId, functionPath, options);
|
|
74
|
+
logsResp = data;
|
|
72
75
|
} catch (e) {
|
|
73
76
|
handleLogsError(e, accountId, functionPath);
|
|
74
77
|
process.exit(EXIT_CODES.ERROR);
|
package/commands/mv.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
2
|
const { moveFile } = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
3
|
-
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/
|
|
4
|
-
const {
|
|
5
|
-
logApiErrorInstance,
|
|
6
|
-
ApiErrorContext,
|
|
7
|
-
} = require('../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
4
|
+
const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
|
|
8
5
|
const {
|
|
9
6
|
addConfigOptions,
|
|
10
7
|
addAccountOptions,
|
|
@@ -64,7 +61,7 @@ exports.handler = async options => {
|
|
|
64
61
|
})
|
|
65
62
|
);
|
|
66
63
|
} else {
|
|
67
|
-
|
|
64
|
+
logError(
|
|
68
65
|
error,
|
|
69
66
|
new ApiErrorContext({
|
|
70
67
|
accountId,
|
|
@@ -57,6 +57,9 @@ const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
|
57
57
|
const { AxiosError, HttpStatusCode } = require('axios');
|
|
58
58
|
|
|
59
59
|
const chalk = require('chalk');
|
|
60
|
+
const {
|
|
61
|
+
HubSpotHttpError,
|
|
62
|
+
} = require('@hubspot/local-dev-lib/models/HubSpotHttpError');
|
|
60
63
|
|
|
61
64
|
describe('commands/project/deploy', () => {
|
|
62
65
|
const projectFlag = 'project';
|
|
@@ -163,8 +166,8 @@ describe('commands/project/deploy', () => {
|
|
|
163
166
|
});
|
|
164
167
|
getAccountId.mockReturnValue(accountId);
|
|
165
168
|
getAccountConfig.mockReturnValue({ accountType });
|
|
166
|
-
fetchProject.mockResolvedValue(projectDetails);
|
|
167
|
-
deployProject.mockResolvedValue(deployDetails);
|
|
169
|
+
fetchProject.mockResolvedValue({ data: projectDetails });
|
|
170
|
+
deployProject.mockResolvedValue({ data: deployDetails });
|
|
168
171
|
deployBuildIdPrompt.mockResolvedValue({
|
|
169
172
|
buildId: projectDetails.latestBuild.buildId,
|
|
170
173
|
});
|
|
@@ -251,7 +254,7 @@ describe('commands/project/deploy', () => {
|
|
|
251
254
|
});
|
|
252
255
|
|
|
253
256
|
it('should log an error and exit when latest build is not defined', async () => {
|
|
254
|
-
fetchProject.mockResolvedValue({});
|
|
257
|
+
fetchProject.mockResolvedValue({ data: {} });
|
|
255
258
|
await handler(options);
|
|
256
259
|
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
257
260
|
expect(logger.error).toHaveBeenCalledWith(
|
|
@@ -332,7 +335,9 @@ describe('commands/project/deploy', () => {
|
|
|
332
335
|
it('should log an error and exit when the deploy fails', async () => {
|
|
333
336
|
const errorMessage = `Just wasn't feeling it`;
|
|
334
337
|
deployProject.mockResolvedValue({
|
|
335
|
-
|
|
338
|
+
data: {
|
|
339
|
+
error: { message: errorMessage },
|
|
340
|
+
},
|
|
336
341
|
});
|
|
337
342
|
|
|
338
343
|
await handler(options);
|
|
@@ -361,13 +366,15 @@ describe('commands/project/deploy', () => {
|
|
|
361
366
|
uiCommandReference.mockReturnValue(commandReference);
|
|
362
367
|
uiAccountDescription.mockReturnValue(accountDescription);
|
|
363
368
|
fetchProject.mockImplementation(() => {
|
|
364
|
-
throw new
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
throw new HubSpotHttpError('OH NO', {
|
|
370
|
+
cause: new AxiosError(
|
|
371
|
+
'OH NO',
|
|
372
|
+
'',
|
|
373
|
+
{},
|
|
374
|
+
{},
|
|
375
|
+
{ status: HttpStatusCode.NotFound }
|
|
376
|
+
),
|
|
377
|
+
});
|
|
371
378
|
});
|
|
372
379
|
await handler(options);
|
|
373
380
|
|
|
@@ -388,18 +395,20 @@ describe('commands/project/deploy', () => {
|
|
|
388
395
|
uiAccountDescription.mockReturnValue(accountDescription);
|
|
389
396
|
const errorMessage = 'Something bad happened';
|
|
390
397
|
fetchProject.mockImplementation(() => {
|
|
391
|
-
throw new
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
+
throw new HubSpotHttpError(errorMessage, {
|
|
399
|
+
cause: new AxiosError(
|
|
400
|
+
errorMessage,
|
|
401
|
+
'',
|
|
402
|
+
{},
|
|
403
|
+
{},
|
|
404
|
+
{ status: HttpStatusCode.BadRequest }
|
|
405
|
+
),
|
|
406
|
+
});
|
|
398
407
|
});
|
|
399
408
|
await handler(options);
|
|
400
409
|
|
|
401
410
|
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
402
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
411
|
+
expect(logger.error).toHaveBeenCalledWith('The request was bad.');
|
|
403
412
|
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
404
413
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
405
414
|
});
|
|
@@ -411,13 +420,15 @@ describe('commands/project/deploy', () => {
|
|
|
411
420
|
uiAccountDescription.mockReturnValue(accountDescription);
|
|
412
421
|
const errorMessage = 'Something bad happened';
|
|
413
422
|
fetchProject.mockImplementation(() => {
|
|
414
|
-
throw new
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
423
|
+
throw new HubSpotHttpError('OH NO', {
|
|
424
|
+
cause: new AxiosError(
|
|
425
|
+
errorMessage,
|
|
426
|
+
'',
|
|
427
|
+
{},
|
|
428
|
+
{},
|
|
429
|
+
{ status: HttpStatusCode.MethodNotAllowed }
|
|
430
|
+
),
|
|
431
|
+
});
|
|
421
432
|
});
|
|
422
433
|
await handler(options);
|
|
423
434
|
|
|
@@ -4,10 +4,9 @@ jest.mock('../../../lib/validation');
|
|
|
4
4
|
jest.mock('../../../lib/projectLogsManager');
|
|
5
5
|
jest.mock('../../../lib/prompts/projectsLogsPrompt');
|
|
6
6
|
jest.mock('@hubspot/local-dev-lib/logger');
|
|
7
|
-
jest.mock('../../../lib/errorHandlers/apiErrors');
|
|
8
7
|
jest.mock('../../../lib/ui/table');
|
|
9
8
|
jest.mock('../../../lib/ui');
|
|
10
|
-
jest.mock('../../../lib/errorHandlers
|
|
9
|
+
jest.mock('../../../lib/errorHandlers');
|
|
11
10
|
|
|
12
11
|
// Deps where we don't want mocks
|
|
13
12
|
const libUi = jest.requireActual('../../../lib/ui');
|
|
@@ -27,7 +26,6 @@ const {
|
|
|
27
26
|
const { getTableContents, getTableHeader } = require('../../../lib/ui/table');
|
|
28
27
|
|
|
29
28
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
30
|
-
const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
|
|
31
29
|
|
|
32
30
|
const {
|
|
33
31
|
handler,
|
|
@@ -36,6 +34,7 @@ const {
|
|
|
36
34
|
builder,
|
|
37
35
|
} = require('../logs');
|
|
38
36
|
const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
37
|
+
const { logError } = require('../../../lib/errorHandlers');
|
|
39
38
|
|
|
40
39
|
describe('commands/project/logs', () => {
|
|
41
40
|
let processExitSpy;
|
|
@@ -292,8 +291,8 @@ describe('commands/project/logs', () => {
|
|
|
292
291
|
|
|
293
292
|
await handler({});
|
|
294
293
|
|
|
295
|
-
expect(
|
|
296
|
-
expect(
|
|
294
|
+
expect(logError).toHaveBeenCalledTimes(1);
|
|
295
|
+
expect(logError).toHaveBeenCalledWith(error, {
|
|
297
296
|
accountId: accountId,
|
|
298
297
|
projectName: ProjectLogsManager.projectName,
|
|
299
298
|
});
|
package/commands/project/add.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
2
|
const { getAccountId } = require('@hubspot/local-dev-lib/config');
|
|
3
|
-
const {
|
|
3
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
4
4
|
const { fetchReleaseData } = require('@hubspot/local-dev-lib/github');
|
|
5
5
|
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -58,7 +58,7 @@ exports.handler = async options => {
|
|
|
58
58
|
})
|
|
59
59
|
);
|
|
60
60
|
} catch (error) {
|
|
61
|
-
|
|
61
|
+
logError(error);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
@@ -26,10 +26,7 @@ const {
|
|
|
26
26
|
uiAccountDescription,
|
|
27
27
|
} = require('../../lib/ui');
|
|
28
28
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
29
|
-
const {
|
|
30
|
-
logApiErrorInstance,
|
|
31
|
-
ApiErrorContext,
|
|
32
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
29
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
33
30
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
34
31
|
const { isAppDeveloperAccount } = require('../../lib/accountTypes');
|
|
35
32
|
const { writeProjectConfig } = require('../../lib/projects');
|
|
@@ -90,7 +87,7 @@ exports.handler = async options => {
|
|
|
90
87
|
name = projectResponse.name;
|
|
91
88
|
location = projectResponse.location;
|
|
92
89
|
} catch (error) {
|
|
93
|
-
|
|
90
|
+
logError(error, new ApiErrorContext({ accountId }));
|
|
94
91
|
process.exit(EXIT_CODES.ERROR);
|
|
95
92
|
}
|
|
96
93
|
try {
|
|
@@ -100,8 +97,12 @@ exports.handler = async options => {
|
|
|
100
97
|
text: i18n(`${i18nKey}.cloneStatus.inProgress`),
|
|
101
98
|
});
|
|
102
99
|
|
|
103
|
-
const {
|
|
104
|
-
|
|
100
|
+
const {
|
|
101
|
+
data: { exportId },
|
|
102
|
+
} = await cloneApp(accountId, appId);
|
|
103
|
+
const {
|
|
104
|
+
data: { status },
|
|
105
|
+
} = await poll(checkCloneStatus, accountId, exportId);
|
|
105
106
|
if (status === 'SUCCESS') {
|
|
106
107
|
// Ensure correct project folder structure exists
|
|
107
108
|
const baseDestPath = path.resolve(getCwd(), location);
|
|
@@ -109,7 +110,10 @@ exports.handler = async options => {
|
|
|
109
110
|
fs.mkdirSync(absoluteDestPath, { recursive: true });
|
|
110
111
|
|
|
111
112
|
// Extract zipped app files and place them in correct directory
|
|
112
|
-
const zippedApp = await downloadClonedProject(
|
|
113
|
+
const { data: zippedApp } = await downloadClonedProject(
|
|
114
|
+
accountId,
|
|
115
|
+
exportId
|
|
116
|
+
);
|
|
113
117
|
await extractZipArchive(
|
|
114
118
|
zippedApp,
|
|
115
119
|
sanitizeFileName(name),
|
|
@@ -169,10 +173,10 @@ exports.handler = async options => {
|
|
|
169
173
|
// Migrations endpoints return a response object with an errors property. The errors property contains an array of errors.
|
|
170
174
|
if (error.errors && Array.isArray(error.errors)) {
|
|
171
175
|
error.errors.forEach(e =>
|
|
172
|
-
|
|
176
|
+
logError(e, new ApiErrorContext({ accountId }))
|
|
173
177
|
);
|
|
174
178
|
} else {
|
|
175
|
-
|
|
179
|
+
logError(error, new ApiErrorContext({ accountId }));
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
};
|
|
@@ -47,16 +47,12 @@ exports.handler = async options => {
|
|
|
47
47
|
options
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
trackCommandUsage(
|
|
51
|
-
'project-create',
|
|
52
|
-
{ type: options.template || template },
|
|
53
|
-
accountId
|
|
54
|
-
);
|
|
50
|
+
trackCommandUsage('project-create', { type: template.name }, accountId);
|
|
55
51
|
|
|
56
52
|
await createProjectConfig(
|
|
57
53
|
path.resolve(getCwd(), options.location || location),
|
|
58
54
|
options.name || name,
|
|
59
|
-
template
|
|
55
|
+
template,
|
|
60
56
|
options.templateSource,
|
|
61
57
|
githubRef
|
|
62
58
|
);
|
|
@@ -6,10 +6,7 @@ const {
|
|
|
6
6
|
addUseEnvironmentOptions,
|
|
7
7
|
} = require('../../lib/commonOpts');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const {
|
|
10
|
-
logApiErrorInstance,
|
|
11
|
-
ApiErrorContext,
|
|
12
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
9
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
13
10
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
14
11
|
const {
|
|
15
12
|
deployProject,
|
|
@@ -32,6 +29,7 @@ const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
|
32
29
|
const i18nKey = 'commands.project.subcommands.deploy';
|
|
33
30
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
34
31
|
const { uiCommandReference, uiAccountDescription } = require('../../lib/ui');
|
|
32
|
+
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
35
33
|
|
|
36
34
|
exports.command = 'deploy';
|
|
37
35
|
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
@@ -94,10 +92,9 @@ exports.handler = async options => {
|
|
|
94
92
|
let buildIdToDeploy = buildIdOption;
|
|
95
93
|
|
|
96
94
|
try {
|
|
97
|
-
const {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
95
|
+
const {
|
|
96
|
+
data: { latestBuild, deployedBuildId },
|
|
97
|
+
} = await fetchProject(accountId, projectName);
|
|
101
98
|
|
|
102
99
|
if (!latestBuild || !latestBuild.buildId) {
|
|
103
100
|
logger.error(i18n(`${i18nKey}.errors.noBuilds`));
|
|
@@ -137,7 +134,7 @@ exports.handler = async options => {
|
|
|
137
134
|
return process.exit(EXIT_CODES.ERROR);
|
|
138
135
|
}
|
|
139
136
|
|
|
140
|
-
const deployResp = await deployProject(
|
|
137
|
+
const { data: deployResp } = await deployProject(
|
|
141
138
|
accountId,
|
|
142
139
|
projectName,
|
|
143
140
|
buildIdToDeploy
|
|
@@ -159,7 +156,7 @@ exports.handler = async options => {
|
|
|
159
156
|
buildIdToDeploy
|
|
160
157
|
);
|
|
161
158
|
} catch (e) {
|
|
162
|
-
if (e
|
|
159
|
+
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
163
160
|
logger.error(
|
|
164
161
|
i18n(`${i18nKey}.errors.projectNotFound`, {
|
|
165
162
|
projectName: chalk.bold(projectName),
|
|
@@ -167,10 +164,10 @@ exports.handler = async options => {
|
|
|
167
164
|
command: uiCommandReference('hs project upload'),
|
|
168
165
|
})
|
|
169
166
|
);
|
|
170
|
-
} else if (e
|
|
167
|
+
} else if (isHubSpotHttpError(e) && e.status === 400) {
|
|
171
168
|
logger.error(e.message);
|
|
172
169
|
} else {
|
|
173
|
-
|
|
170
|
+
logError(
|
|
174
171
|
e,
|
|
175
172
|
new ApiErrorContext({ accountId, request: 'project deploy' })
|
|
176
173
|
);
|
package/commands/project/dev.js
CHANGED
|
@@ -40,13 +40,13 @@ const {
|
|
|
40
40
|
const {
|
|
41
41
|
confirmDefaultAccountIsTarget,
|
|
42
42
|
suggestRecommendedNestedAccount,
|
|
43
|
-
|
|
43
|
+
checkIfDefaultAccountIsSupported,
|
|
44
44
|
createSandboxForLocalDev,
|
|
45
45
|
createDeveloperTestAccountForLocalDev,
|
|
46
46
|
createNewProjectForLocalDev,
|
|
47
47
|
createInitialBuildForNewProject,
|
|
48
48
|
useExistingDevTestAccount,
|
|
49
|
-
|
|
49
|
+
checkIfAccountFlagIsSupported,
|
|
50
50
|
checkIfParentAccountIsAuthed,
|
|
51
51
|
} = require('../../lib/localDev');
|
|
52
52
|
|
|
@@ -111,12 +111,15 @@ exports.handler = async options => {
|
|
|
111
111
|
// The account that we are locally testing against
|
|
112
112
|
let targetTestingAccountId = options.account ? accountId : null;
|
|
113
113
|
|
|
114
|
+
// Check that the default account or flag option is valid for the type of app in this project
|
|
114
115
|
if (options.account) {
|
|
115
|
-
|
|
116
|
+
checkIfAccountFlagIsSupported(accountConfig, hasPublicApps);
|
|
116
117
|
|
|
117
118
|
if (hasPublicApps) {
|
|
118
119
|
targetProjectAccountId = accountConfig.parentAccountId;
|
|
119
120
|
}
|
|
121
|
+
} else {
|
|
122
|
+
checkIfDefaultAccountIsSupported(accountConfig, hasPublicApps);
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
// The user is targeting an account type that we recommend developing on
|
|
@@ -131,8 +134,6 @@ exports.handler = async options => {
|
|
|
131
134
|
} else {
|
|
132
135
|
targetProjectAccountId = accountId;
|
|
133
136
|
}
|
|
134
|
-
} else if (!targetProjectAccountId && hasPublicApps) {
|
|
135
|
-
checkIfAppDeveloperAccount(accountConfig);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
let createNewSandbox = false;
|
|
@@ -7,10 +7,7 @@ const {
|
|
|
7
7
|
} = require('../../lib/commonOpts');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
9
|
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
|
|
10
|
-
const {
|
|
11
|
-
logApiErrorInstance,
|
|
12
|
-
ApiErrorContext,
|
|
13
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
10
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
14
11
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
15
12
|
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
|
|
16
13
|
const {
|
|
@@ -75,9 +72,10 @@ exports.handler = async options => {
|
|
|
75
72
|
let buildNumberToDownload = buildNumber;
|
|
76
73
|
|
|
77
74
|
if (!buildNumberToDownload) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const { data: projectBuildsResult } = await fetchProjectBuilds(
|
|
76
|
+
accountId,
|
|
77
|
+
projectName
|
|
78
|
+
);
|
|
81
79
|
|
|
82
80
|
const { results: projectBuilds } = projectBuildsResult;
|
|
83
81
|
|
|
@@ -87,7 +85,7 @@ exports.handler = async options => {
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
const zippedProject = await downloadProject(
|
|
88
|
+
const { data: zippedProject } = await downloadProject(
|
|
91
89
|
accountId,
|
|
92
90
|
projectName,
|
|
93
91
|
buildNumberToDownload
|
|
@@ -108,7 +106,7 @@ exports.handler = async options => {
|
|
|
108
106
|
);
|
|
109
107
|
process.exit(EXIT_CODES.SUCCESS);
|
|
110
108
|
} catch (e) {
|
|
111
|
-
|
|
109
|
+
logError(
|
|
112
110
|
e,
|
|
113
111
|
new ApiErrorContext({ accountId, request: 'project download' })
|
|
114
112
|
);
|
|
@@ -8,10 +8,7 @@ const {
|
|
|
8
8
|
} = require('../../lib/commonOpts');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
|
-
const {
|
|
12
|
-
logApiErrorInstance,
|
|
13
|
-
ApiErrorContext,
|
|
14
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
11
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
15
12
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
16
13
|
const {
|
|
17
14
|
fetchProject,
|
|
@@ -28,6 +25,7 @@ const {
|
|
|
28
25
|
} = require('../../lib/projects');
|
|
29
26
|
const moment = require('moment');
|
|
30
27
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
28
|
+
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
31
29
|
|
|
32
30
|
const i18nKey = 'commands.project.subcommands.listBuilds';
|
|
33
31
|
|
|
@@ -50,11 +48,9 @@ exports.handler = async options => {
|
|
|
50
48
|
logger.debug(`Fetching builds for project at path: ${projectPath}`);
|
|
51
49
|
|
|
52
50
|
const fetchAndDisplayBuilds = async (project, options) => {
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
options
|
|
57
|
-
);
|
|
51
|
+
const {
|
|
52
|
+
data: { results, paging },
|
|
53
|
+
} = await fetchProjectBuilds(accountId, project.name, options);
|
|
58
54
|
const currentDeploy = project.deployedBuildId;
|
|
59
55
|
if (options && options.after) {
|
|
60
56
|
logger.log(
|
|
@@ -120,14 +116,14 @@ exports.handler = async options => {
|
|
|
120
116
|
};
|
|
121
117
|
|
|
122
118
|
try {
|
|
123
|
-
const project = await fetchProject(accountId, projectConfig.name);
|
|
119
|
+
const { data: project } = await fetchProject(accountId, projectConfig.name);
|
|
124
120
|
|
|
125
121
|
await fetchAndDisplayBuilds(project, { limit });
|
|
126
122
|
} catch (e) {
|
|
127
|
-
if (e
|
|
123
|
+
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
128
124
|
logger.error(`Project ${projectConfig.name} not found. `);
|
|
129
125
|
} else {
|
|
130
|
-
|
|
126
|
+
logError(
|
|
131
127
|
e,
|
|
132
128
|
new ApiErrorContext({ accountId, projectName: projectConfig.name })
|
|
133
129
|
);
|
package/commands/project/logs.js
CHANGED
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
11
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
12
12
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
13
|
-
const {
|
|
13
|
+
const { logError } = require('../../lib/errorHandlers/');
|
|
14
14
|
|
|
15
15
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
16
16
|
const { uiBetaTag, uiLine, uiLink } = require('../../lib/ui');
|
|
@@ -103,7 +103,7 @@ exports.handler = async options => {
|
|
|
103
103
|
|
|
104
104
|
logPreamble();
|
|
105
105
|
} catch (e) {
|
|
106
|
-
|
|
106
|
+
logError(e, {
|
|
107
107
|
accountId: getAccountId(),
|
|
108
108
|
projectName: ProjectLogsManager.projectName,
|
|
109
109
|
});
|