@hubspot/cli 8.0.10-experimental.7 → 8.0.11-experimental.1
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 -0
- package/commands/account/auth.js +12 -22
- package/commands/account/clean.js +5 -6
- package/commands/account/createOverride.js +7 -7
- package/commands/account/info.js +2 -1
- package/commands/account/list.js +3 -5
- package/commands/account/remove.js +2 -3
- package/commands/account/removeOverride.js +8 -10
- package/commands/account/rename.js +5 -6
- package/commands/account/use.js +8 -19
- package/commands/api.d.ts +10 -0
- package/commands/api.js +164 -0
- package/commands/app/migrate.js +8 -8
- package/commands/app/secret/add.js +6 -7
- package/commands/app/secret/delete.js +9 -10
- package/commands/app/secret/list.js +6 -7
- package/commands/app/secret/update.js +8 -9
- package/commands/auth.js +12 -12
- package/commands/cms/app/create.js +9 -5
- package/commands/cms/convertFields.js +8 -8
- package/commands/cms/delete.js +2 -3
- package/commands/cms/fetch.js +7 -7
- package/commands/cms/function/create.js +9 -5
- package/commands/cms/function/deploy.js +2 -3
- package/commands/cms/function/list.js +11 -7
- package/commands/cms/function/logs.js +17 -23
- package/commands/cms/function/server.js +2 -3
- package/commands/cms/getReactModule.js +7 -8
- package/commands/cms/lighthouseScore.js +25 -24
- package/commands/cms/lint.js +4 -5
- package/commands/cms/list.js +5 -6
- package/commands/cms/module/create.js +9 -5
- package/commands/cms/module/marketplace-validate.js +7 -8
- package/commands/cms/mv.js +2 -3
- package/commands/cms/template/create.js +10 -6
- package/commands/cms/theme/create.js +5 -5
- package/commands/cms/theme/generate-selectors.js +5 -4
- package/commands/cms/theme/marketplace-validate.js +8 -9
- package/commands/cms/theme/preview.js +16 -8
- package/commands/cms/upload.js +15 -12
- package/commands/cms/watch.js +5 -5
- package/commands/cms/webpack/create.js +5 -5
- package/commands/completion.js +3 -5
- package/commands/config/migrate.js +6 -7
- package/commands/config/set.js +5 -6
- package/commands/customObject/create.js +4 -5
- package/commands/customObject/createSchema.js +4 -5
- package/commands/customObject/deleteSchema.js +4 -5
- package/commands/customObject/fetchAllSchemas.js +2 -3
- package/commands/customObject/fetchSchema.js +2 -3
- package/commands/customObject/listSchemas.js +2 -3
- package/commands/customObject/updateSchema.js +4 -5
- package/commands/doctor.js +8 -8
- package/commands/feedback.js +6 -4
- package/commands/filemanager/fetch.js +5 -6
- package/commands/filemanager/upload.js +5 -5
- package/commands/getStarted.js +14 -16
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +4 -5
- package/commands/hubdb/delete.js +8 -9
- package/commands/hubdb/fetch.js +5 -6
- package/commands/hubdb/list.js +16 -14
- package/commands/init.js +14 -17
- package/commands/mcp/setup.js +5 -6
- package/commands/mcp/start.js +2 -3
- package/commands/open.js +4 -5
- package/commands/project/add.js +10 -5
- package/commands/project/create.js +10 -10
- package/commands/project/delete.d.ts +7 -0
- package/commands/project/delete.js +74 -0
- package/commands/project/deploy.js +36 -34
- package/commands/project/dev/deprecatedFlow.js +42 -15
- package/commands/project/dev/index.d.ts +3 -3
- package/commands/project/dev/index.js +24 -30
- package/commands/project/dev/unifiedFlow.js +37 -14
- package/commands/project/download.js +10 -11
- package/commands/project/info.d.ts +4 -0
- package/commands/project/info.js +67 -0
- package/commands/project/installDeps.js +9 -6
- package/commands/project/lint.js +11 -8
- package/commands/project/list.js +14 -14
- package/commands/project/listBuilds.js +8 -6
- package/commands/project/logs.js +5 -6
- package/commands/project/migrate.js +8 -8
- package/commands/project/open.js +5 -6
- package/commands/project/profile/add.js +12 -8
- package/commands/project/profile/delete.js +15 -11
- package/commands/project/updateDeps.js +9 -6
- package/commands/project/upload.js +31 -17
- package/commands/project/validate.js +11 -11
- package/commands/project/watch.js +20 -20
- package/commands/project.js +4 -0
- package/commands/sandbox/create.js +15 -15
- package/commands/sandbox/delete.js +13 -14
- package/commands/secret/addSecret.js +6 -7
- package/commands/secret/deleteSecret.js +5 -6
- package/commands/secret/listSecret.js +2 -3
- package/commands/secret/updateSecret.js +4 -5
- package/commands/testAccount/create.d.ts +1 -1
- package/commands/testAccount/create.js +20 -16
- package/commands/testAccount/createConfig.js +7 -8
- package/commands/testAccount/delete.js +27 -18
- package/commands/testAccount/importData.js +6 -7
- package/commands/upgrade.js +9 -10
- package/lang/en.d.ts +123 -5
- package/lang/en.js +121 -6
- package/lib/accountAuth.js +2 -2
- package/lib/buildAccount.js +3 -3
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +0 -1
- package/lib/doctor/Diagnosis.js +5 -5
- package/lib/errorHandlers/index.js +4 -3
- package/lib/errorHandlers/suppressError.js +4 -0
- package/lib/errors/PromptExitError.d.ts +4 -2
- package/lib/errors/PromptExitError.js +3 -0
- package/lib/hasFeature.js +1 -2
- package/lib/middleware/autoUpdateMiddleware.js +6 -3
- package/lib/process.d.ts +1 -1
- package/lib/process.js +10 -3
- package/lib/projects/create/v2.js +1 -2
- package/lib/projects/delete.d.ts +13 -0
- package/lib/projects/delete.js +193 -0
- package/lib/projects/localDev/AppDevModeInterface.js +11 -11
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +3 -1
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
- package/lib/projects/localDev/DevSessionManager.d.ts +6 -3
- package/lib/projects/localDev/DevSessionManager.js +31 -19
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.d.ts +3 -0
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +16 -12
- package/lib/projects/localDev/LocalDevProcess.js +6 -5
- package/lib/projects/localDev/LocalDevState.d.ts +3 -2
- package/lib/projects/localDev/LocalDevState.js +3 -1
- package/lib/projects/localDev/helpers/account.d.ts +4 -3
- package/lib/projects/localDev/helpers/account.js +16 -19
- package/lib/projects/localDev/helpers/process.d.ts +1 -1
- package/lib/projects/localDev/helpers/process.js +4 -10
- package/lib/projects/localDev/helpers/project.d.ts +4 -3
- package/lib/projects/localDev/helpers/project.js +31 -15
- package/lib/projects/projectInfo.d.ts +5 -0
- package/lib/projects/projectInfo.js +82 -0
- package/lib/projects/projectProfiles.d.ts +1 -2
- package/lib/projects/projectProfiles.js +5 -17
- package/lib/projects/upload.js +19 -0
- package/lib/projects/workspaces.d.ts +42 -0
- package/lib/projects/workspaces.js +350 -0
- package/lib/prompts/createApiSamplePrompt.js +4 -0
- package/lib/prompts/projectProfilePrompt.d.ts +2 -0
- package/lib/prompts/projectProfilePrompt.js +46 -0
- package/lib/prompts/promptUtils.js +3 -2
- package/lib/prompts/selectHubDBTablePrompt.js +2 -2
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +2 -2
- package/lib/theme/cmsDevServerProcess.d.ts +2 -0
- package/lib/theme/cmsDevServerProcess.js +7 -6
- package/lib/ui/SpinniesManager.d.ts +1 -0
- package/lib/ui/SpinniesManager.js +20 -6
- package/lib/ui/spinniesUtils.d.ts +0 -1
- package/lib/ui/spinniesUtils.js +6 -16
- package/lib/usageTracking.d.ts +3 -4
- package/lib/yargs/makeYargsBuilder.d.ts +13 -0
- package/lib/yargs/makeYargsBuilder.js +33 -0
- package/lib/yargs/makeYargsHandlerWithUsageTracking.d.ts +3 -0
- package/lib/yargs/makeYargsHandlerWithUsageTracking.js +95 -0
- package/lib/yargs/strictEnforceBoolean.d.ts +1 -0
- package/lib/yargs/strictEnforceBoolean.js +13 -0
- package/lib/yargsUtils.d.ts +3 -16
- package/lib/yargsUtils.js +3 -48
- package/package.json +5 -4
- package/types/LocalDev.d.ts +5 -0
- package/types/Projects.d.ts +19 -0
- package/types/Yargs.d.ts +18 -1
|
@@ -2,21 +2,25 @@ import moment from 'moment';
|
|
|
2
2
|
import { getRoutes } from '@hubspot/local-dev-lib/api/functions';
|
|
3
3
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
4
4
|
import { logError, ApiErrorContext } from '../../../lib/errorHandlers/index.js';
|
|
5
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
6
5
|
import { commands } from '../../../lang/en.js';
|
|
7
6
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
7
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
8
8
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
9
|
import { renderTable } from '../../../ui/render.js';
|
|
10
10
|
const command = ['list', 'ls'];
|
|
11
11
|
const describe = commands.cms.subcommands.function.subcommands.list.describe;
|
|
12
12
|
async function handler(args) {
|
|
13
|
-
const { derivedAccountId } = args;
|
|
14
|
-
trackCommandUsage('function-list', undefined, derivedAccountId);
|
|
13
|
+
const { derivedAccountId, exit } = args;
|
|
15
14
|
uiLogger.debug(commands.cms.subcommands.function.subcommands.list.debug.gettingFunctions);
|
|
16
|
-
|
|
15
|
+
let routesResp;
|
|
16
|
+
try {
|
|
17
|
+
const { data } = await getRoutes(derivedAccountId);
|
|
18
|
+
routesResp = data;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
17
21
|
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
18
|
-
|
|
19
|
-
}
|
|
22
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
23
|
+
}
|
|
20
24
|
if (!routesResp.objects.length) {
|
|
21
25
|
return uiLogger.info(commands.cms.subcommands.function.subcommands.list.info.noFunctions);
|
|
22
26
|
}
|
|
@@ -53,7 +57,7 @@ const builder = makeYargsBuilder(functionListBuilder, command, describe, {
|
|
|
53
57
|
const functionListCommand = {
|
|
54
58
|
command,
|
|
55
59
|
describe,
|
|
56
|
-
handler,
|
|
60
|
+
handler: makeYargsHandlerWithUsageTracking('function-list', handler),
|
|
57
61
|
builder,
|
|
58
62
|
};
|
|
59
63
|
export default functionListCommand;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
1
|
import { outputLogs } from '../../../lib/ui/serverlessFunctionLogs.js';
|
|
3
2
|
import { getFunctionLogs, getLatestFunctionLog, } from '@hubspot/local-dev-lib/api/functions';
|
|
4
3
|
import { tailLogs } from '../../../lib/serverlessLogs.js';
|
|
5
4
|
import { promptUser } from '../../../lib/prompts/promptUtils.js';
|
|
6
5
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
7
6
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
8
8
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
9
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
10
10
|
import { commands } from '../../../lang/en.js';
|
|
@@ -13,7 +13,7 @@ const handleLogsError = (e, accountId, functionPath) => {
|
|
|
13
13
|
uiLogger.error(commands.cms.subcommands.function.subcommands.logs.errors.noLogsFound(functionPath, accountId));
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
const endpointLog = async (accountId, functionPath, options) => {
|
|
16
|
+
const endpointLog = async (accountId, functionPath, options, exit) => {
|
|
17
17
|
const { limit, latest, follow, compact } = options;
|
|
18
18
|
const requestParams = {
|
|
19
19
|
limit,
|
|
@@ -35,27 +35,15 @@ const endpointLog = async (accountId, functionPath, options) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
await tailLogs(accountId, functionPath, fetchLatest, tailCall, compact);
|
|
38
|
-
|
|
38
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
39
39
|
}
|
|
40
40
|
else if (latest) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
logsResp = data;
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
handleLogsError(e, accountId, functionPath);
|
|
47
|
-
process.exit(EXIT_CODES.ERROR);
|
|
48
|
-
}
|
|
41
|
+
const { data } = await getLatestFunctionLog(accountId, functionPath);
|
|
42
|
+
logsResp = data;
|
|
49
43
|
}
|
|
50
44
|
else {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logsResp = data;
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
handleLogsError(e, accountId, functionPath);
|
|
57
|
-
process.exit(EXIT_CODES.ERROR);
|
|
58
|
-
}
|
|
45
|
+
const { data } = await getFunctionLogs(accountId, functionPath, requestParams);
|
|
46
|
+
logsResp = data;
|
|
59
47
|
}
|
|
60
48
|
if (logsResp) {
|
|
61
49
|
return outputLogs(logsResp, { compact });
|
|
@@ -64,14 +52,20 @@ const endpointLog = async (accountId, functionPath, options) => {
|
|
|
64
52
|
const command = 'logs [endpoint]';
|
|
65
53
|
const describe = commands.cms.subcommands.function.subcommands.logs.describe;
|
|
66
54
|
const handler = async (options) => {
|
|
67
|
-
const { endpoint: endpointArgValue, latest, derivedAccountId } = options;
|
|
68
|
-
|
|
55
|
+
const { endpoint: endpointArgValue, latest, derivedAccountId, exit, addUsageMetadata, } = options;
|
|
56
|
+
addUsageMetadata(latest ? { action: 'latest' } : {});
|
|
69
57
|
const { endpointPromptValue } = await promptUser({
|
|
70
58
|
name: 'endpointPromptValue',
|
|
71
59
|
message: commands.cms.subcommands.function.subcommands.logs.endpointPrompt,
|
|
72
60
|
when: !endpointArgValue,
|
|
73
61
|
});
|
|
74
|
-
|
|
62
|
+
try {
|
|
63
|
+
await endpointLog(derivedAccountId, endpointArgValue || endpointPromptValue, options, exit);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
handleLogsError(e, derivedAccountId, endpointArgValue || endpointPromptValue);
|
|
67
|
+
return exit(EXIT_CODES.ERROR);
|
|
68
|
+
}
|
|
75
69
|
};
|
|
76
70
|
function logsBuilder(yargs) {
|
|
77
71
|
yargs.positional('endpoint', {
|
|
@@ -131,6 +125,6 @@ const logsCommand = {
|
|
|
131
125
|
command,
|
|
132
126
|
describe,
|
|
133
127
|
builder,
|
|
134
|
-
handler,
|
|
128
|
+
handler: makeYargsHandlerWithUsageTracking('logs', handler),
|
|
135
129
|
};
|
|
136
130
|
export default logsCommand;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
1
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
3
2
|
// This package is not typed, so we need to use require
|
|
4
3
|
import { start as startTestServer } from '@hubspot/serverless-dev-runtime';
|
|
5
4
|
import { commands } from '../../../lang/en.js';
|
|
5
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
6
6
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
7
7
|
const command = 'server <path>';
|
|
8
8
|
const describe = undefined;
|
|
9
9
|
async function handler(args) {
|
|
10
10
|
const { path: functionPath, derivedAccountId } = args;
|
|
11
|
-
trackCommandUsage('functions-server', undefined, derivedAccountId);
|
|
12
11
|
uiLogger.debug(commands.cms.subcommands.function.subcommands.server.debug.startingServer(functionPath));
|
|
13
12
|
startTestServer({
|
|
14
13
|
accountId: derivedAccountId,
|
|
@@ -63,7 +62,7 @@ const builder = makeYargsBuilder(functionServerBuilder, command, describe, {
|
|
|
63
62
|
const functionServerCommand = {
|
|
64
63
|
command,
|
|
65
64
|
describe,
|
|
66
|
-
handler,
|
|
65
|
+
handler: makeYargsHandlerWithUsageTracking('functions-server', handler),
|
|
67
66
|
builder,
|
|
68
67
|
};
|
|
69
68
|
export default functionServerCommand;
|
|
@@ -5,15 +5,14 @@ import { retrieveDefaultModule } from '@hubspot/local-dev-lib/cms/modules';
|
|
|
5
5
|
import { commands } from '../../lang/en.js';
|
|
6
6
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
7
7
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
8
|
-
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
9
8
|
import { listPrompt } from '../../lib/prompts/promptUtils.js';
|
|
10
9
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
10
|
+
import { makeYargsHandlerWithUsageTracking } from '../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
11
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
12
12
|
const command = 'get-react-module [name] [dest]';
|
|
13
13
|
const describe = commands.cms.subcommands.getReactModule.describe;
|
|
14
14
|
async function handler(args) {
|
|
15
|
-
const { name, dest } = args;
|
|
16
|
-
trackCommandUsage('get-react-modules');
|
|
15
|
+
const { name, dest, exit } = args;
|
|
17
16
|
let moduleToRetrieve = name;
|
|
18
17
|
if (!moduleToRetrieve) {
|
|
19
18
|
let availableModules;
|
|
@@ -24,7 +23,7 @@ async function handler(args) {
|
|
|
24
23
|
logError(e);
|
|
25
24
|
}
|
|
26
25
|
if (!availableModules) {
|
|
27
|
-
|
|
26
|
+
return exit(EXIT_CODES.ERROR);
|
|
28
27
|
}
|
|
29
28
|
const moduleChoice = await listPrompt(commands.cms.subcommands.getReactModule.selectModulePrompt, {
|
|
30
29
|
choices: availableModules.map(module => module.name),
|
|
@@ -36,7 +35,7 @@ async function handler(args) {
|
|
|
36
35
|
: path.join(getCwd(), `${moduleToRetrieve}`);
|
|
37
36
|
if (fs.existsSync(destPath)) {
|
|
38
37
|
uiLogger.error(commands.cms.subcommands.getReactModule.errors.pathExists(destPath));
|
|
39
|
-
|
|
38
|
+
return exit(EXIT_CODES.ERROR);
|
|
40
39
|
}
|
|
41
40
|
try {
|
|
42
41
|
await retrieveDefaultModule(moduleToRetrieve, destPath);
|
|
@@ -50,9 +49,9 @@ async function handler(args) {
|
|
|
50
49
|
else {
|
|
51
50
|
logError(e);
|
|
52
51
|
}
|
|
53
|
-
|
|
52
|
+
return exit(EXIT_CODES.ERROR);
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
56
55
|
}
|
|
57
56
|
function cmsGetReactModuleBuilder(yargs) {
|
|
58
57
|
yargs.positional('name', {
|
|
@@ -71,7 +70,7 @@ const builder = makeYargsBuilder(cmsGetReactModuleBuilder, command, describe, {
|
|
|
71
70
|
const cmsGetReactModuleCommand = {
|
|
72
71
|
command,
|
|
73
72
|
describe,
|
|
74
|
-
handler,
|
|
73
|
+
handler: makeYargsHandlerWithUsageTracking('get-react-module', handler),
|
|
75
74
|
builder,
|
|
76
75
|
};
|
|
77
76
|
export default cmsGetReactModuleCommand;
|
|
@@ -7,6 +7,7 @@ import { requestLighthouseScore, getLighthouseScoreStatus, getLighthouseScore, }
|
|
|
7
7
|
import { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } from '../../lib/constants.js';
|
|
8
8
|
import { uiLink } from '../../lib/ui/index.js';
|
|
9
9
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
10
|
+
import { makeYargsHandlerWithUsageTracking } from '../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
10
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
11
12
|
import { renderTable } from '../../ui/render.js';
|
|
12
13
|
const DEFAULT_TABLE_HEADER = [
|
|
@@ -32,21 +33,15 @@ const command = 'lighthouse-score [--theme]';
|
|
|
32
33
|
const describe = undefined;
|
|
33
34
|
async function selectTheme(accountId) {
|
|
34
35
|
let themes = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
!themePath.startsWith(MARKETPLACE_FOLDER));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToFetchThemes);
|
|
49
|
-
process.exit(EXIT_CODES.ERROR);
|
|
36
|
+
const { data: result } = await fetchThemes(accountId, {
|
|
37
|
+
limit: 500,
|
|
38
|
+
sorting: 'MOST_USED',
|
|
39
|
+
});
|
|
40
|
+
if (result && result.objects) {
|
|
41
|
+
themes = result.objects
|
|
42
|
+
.map(({ theme }) => theme.path)
|
|
43
|
+
.filter(themePath => !themePath.startsWith(HUBSPOT_FOLDER) &&
|
|
44
|
+
!themePath.startsWith(MARKETPLACE_FOLDER));
|
|
50
45
|
}
|
|
51
46
|
const { theme: selectedTheme } = await promptUser([
|
|
52
47
|
{
|
|
@@ -59,7 +54,7 @@ async function selectTheme(accountId) {
|
|
|
59
54
|
return selectedTheme;
|
|
60
55
|
}
|
|
61
56
|
async function handler(args) {
|
|
62
|
-
const { target, verbose, theme, derivedAccountId } = args;
|
|
57
|
+
const { target, verbose, theme, derivedAccountId, exit } = args;
|
|
63
58
|
const includeDesktopScore = target === 'desktop' || !verbose;
|
|
64
59
|
const includeMobileScore = target === 'mobile' || !verbose;
|
|
65
60
|
let themeToCheck = theme;
|
|
@@ -76,11 +71,17 @@ async function handler(args) {
|
|
|
76
71
|
}
|
|
77
72
|
if (!isValidTheme) {
|
|
78
73
|
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.themeNotFound(themeToCheck));
|
|
79
|
-
|
|
74
|
+
return exit(EXIT_CODES.ERROR);
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
else {
|
|
83
|
-
|
|
78
|
+
try {
|
|
79
|
+
themeToCheck = await selectTheme(derivedAccountId);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToFetchThemes);
|
|
83
|
+
return exit(EXIT_CODES.ERROR);
|
|
84
|
+
}
|
|
84
85
|
uiLogger.log('');
|
|
85
86
|
}
|
|
86
87
|
// Kick off the scoring
|
|
@@ -96,7 +97,7 @@ async function handler(args) {
|
|
|
96
97
|
}
|
|
97
98
|
if (!requestResult || !requestResult.mobileId || !requestResult.desktopId) {
|
|
98
99
|
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore);
|
|
99
|
-
|
|
100
|
+
return exit(EXIT_CODES.ERROR);
|
|
100
101
|
}
|
|
101
102
|
// Poll till scoring is finished
|
|
102
103
|
try {
|
|
@@ -129,7 +130,7 @@ async function handler(args) {
|
|
|
129
130
|
}
|
|
130
131
|
catch (err) {
|
|
131
132
|
uiLogger.debug(err);
|
|
132
|
-
|
|
133
|
+
return exit(EXIT_CODES.ERROR);
|
|
133
134
|
}
|
|
134
135
|
// Fetch the scoring results
|
|
135
136
|
let desktopScoreResult;
|
|
@@ -164,14 +165,14 @@ async function handler(args) {
|
|
|
164
165
|
}
|
|
165
166
|
catch (err) {
|
|
166
167
|
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore);
|
|
167
|
-
|
|
168
|
+
return exit(EXIT_CODES.ERROR);
|
|
168
169
|
}
|
|
169
170
|
if (verbose) {
|
|
170
171
|
const scoreResult = target === 'desktop' ? desktopScoreResult : mobileScoreResult;
|
|
171
172
|
if (!verboseViewAverageScoreResult || !scoreResult) {
|
|
172
173
|
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors
|
|
173
174
|
.failedToGetLighthouseScore);
|
|
174
|
-
|
|
175
|
+
return exit(EXIT_CODES.ERROR);
|
|
175
176
|
}
|
|
176
177
|
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.themeToCheckTitle(themeToCheck, target));
|
|
177
178
|
const scores = verboseViewAverageScoreResult.scores
|
|
@@ -240,7 +241,7 @@ async function handler(args) {
|
|
|
240
241
|
}
|
|
241
242
|
uiLogger.log('');
|
|
242
243
|
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.poweredByLink);
|
|
243
|
-
|
|
244
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
244
245
|
}
|
|
245
246
|
function cmslighthouseScoreBuilder(yargs) {
|
|
246
247
|
yargs.option('theme', {
|
|
@@ -275,7 +276,7 @@ const builder = makeYargsBuilder(cmslighthouseScoreBuilder, command, describe, {
|
|
|
275
276
|
const cmslighthouseScoreCommand = {
|
|
276
277
|
command,
|
|
277
278
|
describe,
|
|
278
|
-
handler,
|
|
279
|
+
handler: makeYargsHandlerWithUsageTracking('lighthouse-score', handler),
|
|
279
280
|
builder,
|
|
280
281
|
};
|
|
281
282
|
export default cmslighthouseScoreCommand;
|
package/commands/cms/lint.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { lint } from '@hubspot/local-dev-lib/cms/validate';
|
|
2
2
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
|
-
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
3
|
import { commands } from '../../lang/en.js';
|
|
5
4
|
import { resolveLocalPath } from '../../lib/filesystem.js';
|
|
6
5
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
6
|
+
import { makeYargsHandlerWithUsageTracking } from '../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
7
7
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
8
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
9
|
const command = 'lint <path>';
|
|
@@ -42,10 +42,9 @@ function printHublValidationResult({ file, validation }) {
|
|
|
42
42
|
return count;
|
|
43
43
|
}
|
|
44
44
|
async function handler(args) {
|
|
45
|
-
const { path: lintPath, derivedAccountId } = args;
|
|
45
|
+
const { path: lintPath, derivedAccountId, exit } = args;
|
|
46
46
|
const localPath = resolveLocalPath(lintPath);
|
|
47
47
|
const groupName = commands.cms.subcommands.lint.groupName(localPath);
|
|
48
|
-
trackCommandUsage('lint', undefined, derivedAccountId);
|
|
49
48
|
uiLogger.group(groupName);
|
|
50
49
|
let count = 0;
|
|
51
50
|
try {
|
|
@@ -56,7 +55,7 @@ async function handler(args) {
|
|
|
56
55
|
catch (err) {
|
|
57
56
|
uiLogger.groupEnd();
|
|
58
57
|
logError(err, { accountId: derivedAccountId });
|
|
59
|
-
|
|
58
|
+
return exit(EXIT_CODES.ERROR);
|
|
60
59
|
}
|
|
61
60
|
uiLogger.groupEnd();
|
|
62
61
|
uiLogger.log(commands.cms.subcommands.lint.issuesFound(count));
|
|
@@ -77,7 +76,7 @@ const builder = makeYargsBuilder(lintBuilder, command, describe, {
|
|
|
77
76
|
const lintCommand = {
|
|
78
77
|
command,
|
|
79
78
|
describe,
|
|
80
|
-
handler,
|
|
79
|
+
handler: makeYargsHandlerWithUsageTracking('lint', handler),
|
|
81
80
|
builder,
|
|
82
81
|
};
|
|
83
82
|
export default lintCommand;
|
package/commands/cms/list.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
3
2
|
import { isPathFolder } from '../../lib/filesystem.js';
|
|
4
3
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
5
4
|
import { getDirectoryContentsByPath } from '@hubspot/local-dev-lib/api/fileMapper';
|
|
6
5
|
import { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } from '../../lib/constants.js';
|
|
7
6
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
7
|
+
import { makeYargsHandlerWithUsageTracking } from '../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
8
8
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
9
9
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
10
10
|
import { commands } from '../../lang/en.js';
|
|
@@ -37,10 +37,9 @@ function sortContents(a, b) {
|
|
|
37
37
|
const command = ['list [path]', 'ls [path]'];
|
|
38
38
|
const describe = commands.cms.subcommands.list.describe;
|
|
39
39
|
async function handler(args) {
|
|
40
|
-
const { path, derivedAccountId } = args;
|
|
40
|
+
const { path, derivedAccountId, exit } = args;
|
|
41
41
|
const directoryPath = path || '/';
|
|
42
42
|
let contentsResp;
|
|
43
|
-
trackCommandUsage('list', undefined, derivedAccountId);
|
|
44
43
|
uiLogger.debug(commands.cms.subcommands.list.gettingPathContents(directoryPath));
|
|
45
44
|
try {
|
|
46
45
|
const { data } = await getDirectoryContentsByPath(derivedAccountId, directoryPath);
|
|
@@ -48,7 +47,7 @@ async function handler(args) {
|
|
|
48
47
|
}
|
|
49
48
|
catch (e) {
|
|
50
49
|
logError(e);
|
|
51
|
-
|
|
50
|
+
return exit(EXIT_CODES.ERROR);
|
|
52
51
|
}
|
|
53
52
|
if (!contentsResp.folder) {
|
|
54
53
|
uiLogger.info(commands.cms.subcommands.list.noFilesFoundAtPath(directoryPath));
|
|
@@ -67,7 +66,7 @@ async function handler(args) {
|
|
|
67
66
|
.sort(sortContents)
|
|
68
67
|
.join('\n');
|
|
69
68
|
uiLogger.log(folderContentsOutput);
|
|
70
|
-
|
|
69
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
71
70
|
}
|
|
72
71
|
function cmsListBuilder(yargs) {
|
|
73
72
|
yargs.positional('path', {
|
|
@@ -90,7 +89,7 @@ const builder = makeYargsBuilder(cmsListBuilder, command, describe, {
|
|
|
90
89
|
const cmsListCommand = {
|
|
91
90
|
command,
|
|
92
91
|
describe,
|
|
93
|
-
handler,
|
|
92
|
+
handler: makeYargsHandlerWithUsageTracking('list', handler),
|
|
94
93
|
builder,
|
|
95
94
|
};
|
|
96
95
|
export default cmsListCommand;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
3
|
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
4
|
import { commands } from '../../../lang/en.js';
|
|
6
5
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
6
|
import { CONTENT_TYPES } from '../../../types/Cms.js';
|
|
8
7
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
8
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
9
9
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
10
|
+
import { isPromptExitError } from '../../../lib/errors/PromptExitError.js';
|
|
10
11
|
import assets from '../../../lib/cmsAssets/index.js';
|
|
11
12
|
const command = 'create <name> [dest]';
|
|
12
13
|
const describe = commands.cms.subcommands.module.subcommands.create.describe;
|
|
13
14
|
async function handler(args) {
|
|
14
|
-
const {
|
|
15
|
+
const { name, dest, exit, addUsageMetadata } = args;
|
|
15
16
|
const assetType = 'module';
|
|
16
|
-
|
|
17
|
+
addUsageMetadata({ assetType });
|
|
17
18
|
const asset = assets[assetType];
|
|
18
19
|
const argsToPass = {
|
|
19
20
|
commandArgs: args,
|
|
@@ -38,8 +39,11 @@ async function handler(args) {
|
|
|
38
39
|
await asset.execute(argsToPass);
|
|
39
40
|
}
|
|
40
41
|
catch (e) {
|
|
42
|
+
if (isPromptExitError(e)) {
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
41
45
|
logError(e);
|
|
42
|
-
|
|
46
|
+
return exit(EXIT_CODES.ERROR);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
function moduleCreateBuilder(yargs) {
|
|
@@ -79,6 +83,6 @@ const moduleCreateCommand = {
|
|
|
79
83
|
command,
|
|
80
84
|
describe,
|
|
81
85
|
builder,
|
|
82
|
-
handler,
|
|
86
|
+
handler: makeYargsHandlerWithUsageTracking('create', handler),
|
|
83
87
|
};
|
|
84
88
|
export default moduleCreateCommand;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import SpinniesManager from '../../../lib/ui/SpinniesManager.js';
|
|
2
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
3
2
|
import { kickOffValidation, pollForValidationFinish, fetchValidationResults, hasProcessValidationErrors, displayValidationResults, } from '../../../lib/marketplaceValidate.js';
|
|
4
3
|
import { commands } from '../../../lang/en.js';
|
|
4
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
5
5
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
6
6
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
7
7
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
8
8
|
const command = 'marketplace-validate <src>';
|
|
9
9
|
const describe = commands.cms.subcommands.module.subcommands.marketplaceValidate.describe;
|
|
10
10
|
async function handler(args) {
|
|
11
|
-
const { src, derivedAccountId } = args;
|
|
12
|
-
trackCommandUsage('validate', undefined, derivedAccountId);
|
|
11
|
+
const { src, derivedAccountId, exit } = args;
|
|
13
12
|
SpinniesManager.add('marketplaceValidation', {
|
|
14
13
|
text: commands.cms.subcommands.module.subcommands.marketplaceValidate.logs.validatingModule(src),
|
|
15
14
|
});
|
|
@@ -21,7 +20,7 @@ async function handler(args) {
|
|
|
21
20
|
}
|
|
22
21
|
catch (e) {
|
|
23
22
|
logError(e);
|
|
24
|
-
|
|
23
|
+
return exit(EXIT_CODES.ERROR);
|
|
25
24
|
}
|
|
26
25
|
SpinniesManager.remove('marketplaceValidation');
|
|
27
26
|
let validationResults;
|
|
@@ -30,15 +29,15 @@ async function handler(args) {
|
|
|
30
29
|
}
|
|
31
30
|
catch (e) {
|
|
32
31
|
logError(e);
|
|
33
|
-
|
|
32
|
+
return exit(EXIT_CODES.ERROR);
|
|
34
33
|
}
|
|
35
34
|
const hasErrors = hasProcessValidationErrors(commands.cms.subcommands.module.subcommands.marketplaceValidate.errors
|
|
36
35
|
.invalidPath, validationResults);
|
|
37
36
|
if (hasErrors) {
|
|
38
|
-
|
|
37
|
+
return exit(EXIT_CODES.ERROR);
|
|
39
38
|
}
|
|
40
39
|
displayValidationResults(commands.cms.subcommands.module.subcommands.marketplaceValidate.results, validationResults);
|
|
41
|
-
|
|
40
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
42
41
|
}
|
|
43
42
|
function marketplaceValidateBuilder(yargs) {
|
|
44
43
|
yargs.positional('src', {
|
|
@@ -56,7 +55,7 @@ const builder = makeYargsBuilder(marketplaceValidateBuilder, command, describe,
|
|
|
56
55
|
const marketplaceValidateCommand = {
|
|
57
56
|
command,
|
|
58
57
|
describe,
|
|
59
|
-
handler,
|
|
58
|
+
handler: makeYargsHandlerWithUsageTracking('validate', handler),
|
|
60
59
|
builder,
|
|
61
60
|
};
|
|
62
61
|
export default marketplaceValidateCommand;
|
package/commands/cms/mv.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { moveFile } from '@hubspot/local-dev-lib/api/fileMapper';
|
|
2
2
|
import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
|
|
3
3
|
import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
4
|
-
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
5
4
|
import { isPathFolder } from '../../lib/filesystem.js';
|
|
5
|
+
import { makeYargsHandlerWithUsageTracking } from '../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
6
6
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
7
7
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
8
8
|
import { commands } from '../../lang/en.js';
|
|
@@ -17,7 +17,6 @@ const command = 'mv <srcPath> <destPath>';
|
|
|
17
17
|
const describe = commands.cms.subcommands.mv.describe;
|
|
18
18
|
async function handler(args) {
|
|
19
19
|
const { srcPath, destPath, derivedAccountId } = args;
|
|
20
|
-
trackCommandUsage('mv', undefined, derivedAccountId);
|
|
21
20
|
try {
|
|
22
21
|
await moveFile(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
|
|
23
22
|
uiLogger.success(commands.cms.subcommands.mv.move(srcPath, destPath, derivedAccountId));
|
|
@@ -54,7 +53,7 @@ const builder = makeYargsBuilder(cmsMvBuilder, command, describe, {
|
|
|
54
53
|
const cmsMvCommand = {
|
|
55
54
|
command,
|
|
56
55
|
describe,
|
|
57
|
-
handler,
|
|
56
|
+
handler: makeYargsHandlerWithUsageTracking('mv', handler),
|
|
58
57
|
builder,
|
|
59
58
|
};
|
|
60
59
|
export default cmsMvCommand;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
3
|
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
4
|
import { commands } from '../../../lang/en.js';
|
|
6
5
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
|
-
import { TEMPLATE_TYPES
|
|
6
|
+
import { TEMPLATE_TYPES } from '../../../types/Cms.js';
|
|
8
7
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
8
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
9
9
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
10
|
+
import { isPromptExitError } from '../../../lib/errors/PromptExitError.js';
|
|
10
11
|
import assets from '../../../lib/cmsAssets/index.js';
|
|
11
12
|
const command = 'create <name> [dest]';
|
|
12
13
|
const describe = commands.cms.subcommands.template.subcommands.create.describe;
|
|
13
14
|
async function handler(args) {
|
|
14
|
-
const {
|
|
15
|
+
const { name, dest, exit, addUsageMetadata } = args;
|
|
15
16
|
const assetType = 'template';
|
|
16
|
-
|
|
17
|
+
addUsageMetadata({ assetType });
|
|
17
18
|
const asset = assets[assetType];
|
|
18
19
|
const argsToPass = {
|
|
19
20
|
commandArgs: args,
|
|
@@ -39,8 +40,11 @@ async function handler(args) {
|
|
|
39
40
|
await asset.execute(argsToPass);
|
|
40
41
|
}
|
|
41
42
|
catch (e) {
|
|
43
|
+
if (isPromptExitError(e)) {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
42
46
|
logError(e);
|
|
43
|
-
|
|
47
|
+
return exit(EXIT_CODES.ERROR);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
function templateCreateBuilder(yargs) {
|
|
@@ -67,6 +71,6 @@ const templateCreateCommand = {
|
|
|
67
71
|
command,
|
|
68
72
|
describe,
|
|
69
73
|
builder,
|
|
70
|
-
handler,
|
|
74
|
+
handler: makeYargsHandlerWithUsageTracking('create', handler),
|
|
71
75
|
};
|
|
72
76
|
export default templateCreateCommand;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
3
|
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
-
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
4
|
import { commands } from '../../../lang/en.js';
|
|
6
5
|
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
6
|
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
7
|
+
import { makeYargsHandlerWithUsageTracking } from '../../../lib/yargs/makeYargsHandlerWithUsageTracking.js';
|
|
8
8
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
9
|
import assets from '../../../lib/cmsAssets/index.js';
|
|
10
10
|
const command = 'create [dest]';
|
|
11
11
|
const describe = commands.cms.subcommands.theme.subcommands.create.describe;
|
|
12
12
|
async function handler(args) {
|
|
13
|
-
const {
|
|
13
|
+
const { dest, exit, addUsageMetadata } = args;
|
|
14
14
|
const assetType = 'website-theme';
|
|
15
|
-
|
|
15
|
+
addUsageMetadata({ assetType });
|
|
16
16
|
const asset = assets[assetType];
|
|
17
17
|
const argsToPass = {
|
|
18
18
|
commandArgs: args,
|
|
@@ -35,7 +35,7 @@ async function handler(args) {
|
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
37
|
logError(e);
|
|
38
|
-
|
|
38
|
+
return exit(EXIT_CODES.ERROR);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
function themeCreateBuilder(yargs) {
|
|
@@ -53,6 +53,6 @@ const themeCreateCommand = {
|
|
|
53
53
|
command,
|
|
54
54
|
describe,
|
|
55
55
|
builder,
|
|
56
|
-
handler,
|
|
56
|
+
handler: makeYargsHandlerWithUsageTracking('create', handler),
|
|
57
57
|
};
|
|
58
58
|
export default themeCreateCommand;
|