@hubspot/cli 7.8.12-experimental.1 → 7.9.0-beta.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/commands/__tests__/cms.test.js +44 -1
- package/commands/__tests__/customObject.test.js +22 -1
- package/commands/__tests__/project.test.js +2 -0
- package/commands/account/auth.js +1 -0
- package/commands/auth.js +1 -0
- package/commands/{__tests__/remove.test.js → cms/__tests__/delete.test.js} +8 -8
- package/commands/{__tests__ → cms/__tests__}/fetch.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/function.test.js +7 -3
- package/commands/{__tests__ → cms/__tests__}/lint.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/list.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/mv.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/theme.test.js +9 -2
- package/commands/cms/app/create.d.ts +9 -0
- package/commands/cms/app/create.js +82 -0
- package/commands/cms/app.d.ts +3 -0
- package/commands/cms/app.js +17 -0
- package/commands/cms/delete.d.ts +6 -0
- package/commands/cms/delete.js +43 -0
- package/commands/cms/fetch.d.ts +12 -0
- package/commands/cms/fetch.js +79 -0
- package/commands/{__tests__ → cms/function/__tests__}/logs.test.js +4 -5
- package/commands/cms/function/create.d.ts +12 -0
- package/commands/cms/function/create.js +84 -0
- package/commands/cms/function/deploy.d.ts +6 -0
- package/commands/cms/function/deploy.js +89 -0
- package/commands/cms/function/list.d.ts +6 -0
- package/commands/cms/function/list.js +60 -0
- package/commands/cms/function/logs.d.ts +10 -0
- package/commands/cms/function/logs.js +135 -0
- package/commands/cms/function/server.d.ts +10 -0
- package/commands/cms/function/server.js +69 -0
- package/commands/cms/function.d.ts +3 -0
- package/commands/cms/function.js +27 -0
- package/commands/cms/lint.d.ts +6 -0
- package/commands/cms/lint.js +83 -0
- package/commands/cms/list.d.ts +6 -0
- package/commands/cms/list.js +96 -0
- package/commands/cms/module/create.d.ts +11 -0
- package/commands/cms/module/create.js +84 -0
- package/commands/cms/module/marketplace-validate.d.ts +6 -0
- package/commands/cms/module/marketplace-validate.js +45 -0
- package/commands/cms/module.d.ts +3 -0
- package/commands/cms/module.js +17 -0
- package/commands/cms/mv.d.ts +7 -0
- package/commands/cms/mv.js +60 -0
- package/commands/cms/template/create.d.ts +9 -0
- package/commands/cms/template/create.js +72 -0
- package/commands/cms/template.d.ts +3 -0
- package/commands/cms/template.js +17 -0
- package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.js +2 -2
- package/commands/{theme → cms/theme}/__tests__/preview.test.js +2 -2
- package/commands/cms/theme/create.d.ts +6 -0
- package/commands/cms/theme/create.js +58 -0
- package/commands/cms/theme/generate-selectors.d.ts +6 -0
- package/commands/cms/theme/generate-selectors.js +171 -0
- package/commands/cms/theme/marketplace-validate.d.ts +6 -0
- package/commands/cms/theme/marketplace-validate.js +46 -0
- package/commands/cms/theme/preview.d.ts +12 -0
- package/commands/cms/theme/preview.js +224 -0
- package/commands/cms/theme.d.ts +3 -0
- package/commands/cms/theme.js +25 -0
- package/commands/cms/upload.d.ts +12 -0
- package/commands/cms/upload.js +212 -0
- package/commands/cms/watch.d.ts +14 -0
- package/commands/cms/watch.js +138 -0
- package/commands/cms/webpack/create.d.ts +6 -0
- package/commands/cms/webpack/create.js +58 -0
- package/commands/cms/webpack.d.ts +3 -0
- package/commands/cms/webpack.js +17 -0
- package/commands/cms.js +26 -0
- package/commands/create.js +4 -2
- package/commands/customObject/{schema/__tests__/create.test.js → __tests__/createSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/delete.test.js → __tests__/deleteSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch-all.test.js → __tests__/fetch-all-schemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch.test.js → __tests__/fetchSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/list.test.js → __tests__/listSchemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/update.test.js → __tests__/updateSchema.test.js} +5 -5
- package/commands/customObject/createSchema.d.ts +6 -0
- package/commands/customObject/createSchema.js +56 -0
- package/commands/customObject/deleteSchema.d.ts +7 -0
- package/commands/customObject/deleteSchema.js +69 -0
- package/commands/customObject/fetchAllSchemas.d.ts +6 -0
- package/commands/customObject/fetchAllSchemas.js +57 -0
- package/commands/customObject/fetchSchema.d.ts +7 -0
- package/commands/customObject/fetchSchema.js +67 -0
- package/commands/customObject/listSchemas.d.ts +4 -0
- package/commands/customObject/listSchemas.js +35 -0
- package/commands/customObject/schema/create.d.ts +4 -6
- package/commands/customObject/schema/create.js +13 -36
- package/commands/customObject/schema/delete.d.ts +4 -7
- package/commands/customObject/schema/delete.js +15 -50
- package/commands/customObject/schema/fetch-all.d.ts +4 -6
- package/commands/customObject/schema/fetch-all.js +14 -41
- package/commands/customObject/schema/fetch.d.ts +4 -7
- package/commands/customObject/schema/fetch.js +14 -49
- package/commands/customObject/schema/list.d.ts +4 -4
- package/commands/customObject/schema/list.js +10 -19
- package/commands/customObject/schema/update.d.ts +4 -7
- package/commands/customObject/schema/update.js +15 -50
- package/commands/customObject/schema.js +4 -2
- package/commands/customObject/updateSchema.d.ts +7 -0
- package/commands/customObject/updateSchema.js +71 -0
- package/commands/customObject.js +16 -1
- package/commands/feedback.js +1 -1
- package/commands/fetch.d.ts +4 -12
- package/commands/fetch.js +19 -46
- package/commands/function/deploy.d.ts +4 -6
- package/commands/function/deploy.js +14 -71
- package/commands/function/list.d.ts +4 -6
- package/commands/function/list.js +14 -40
- package/commands/function/server.d.ts +4 -10
- package/commands/function/server.js +22 -29
- package/commands/function.d.ts +2 -4
- package/commands/function.js +25 -14
- package/commands/lint.d.ts +4 -6
- package/commands/lint.js +13 -65
- package/commands/list.d.ts +4 -6
- package/commands/list.js +13 -74
- package/commands/logs.d.ts +4 -10
- package/commands/logs.js +24 -87
- package/commands/module/marketplace-validate.d.ts +4 -6
- package/commands/module/marketplace-validate.js +15 -27
- package/commands/module.d.ts +2 -2
- package/commands/module.js +17 -15
- package/commands/mv.d.ts +4 -7
- package/commands/mv.js +13 -39
- package/commands/project/__tests__/add.test.js +12 -12
- package/commands/project/__tests__/devUnifiedFlow.test.js +32 -0
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/migrate.test.js +1 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +3 -2
- package/commands/project/create.js +1 -1
- package/commands/project/dev/deprecatedFlow.js +2 -2
- package/commands/project/dev/index.js +5 -5
- package/commands/project/dev/unifiedFlow.js +8 -3
- package/commands/project/download.js +5 -2
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +1 -0
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/migrate.js +5 -2
- package/commands/project.js +2 -0
- package/commands/remove.d.ts +4 -6
- package/commands/remove.js +12 -24
- package/commands/testAccount/create.js +2 -2
- package/commands/testAccount/delete.js +1 -1
- package/commands/theme/generate-selectors.d.ts +4 -6
- package/commands/theme/generate-selectors.js +14 -152
- package/commands/theme/marketplace-validate.d.ts +4 -6
- package/commands/theme/marketplace-validate.js +14 -25
- package/commands/theme/preview.d.ts +4 -12
- package/commands/theme/preview.js +18 -180
- package/commands/theme.d.ts +2 -2
- package/commands/theme.js +19 -13
- package/commands/upload.d.ts +4 -12
- package/commands/upload.js +19 -169
- package/commands/watch.d.ts +4 -14
- package/commands/watch.js +23 -88
- package/lang/en.d.ts +561 -425
- package/lang/en.js +563 -427
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -2
- package/lib/__tests__/http.test.js +40 -0
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +7 -7
- package/lib/configMigrate.js +88 -9
- package/lib/constants.d.ts +9 -0
- package/lib/constants.js +9 -0
- package/lib/generateSelectors.js +1 -1
- package/lib/http.d.ts +1 -0
- package/lib/http.js +26 -0
- package/lib/middleware/autoUpdateMiddleware.d.ts +2 -1
- package/lib/middleware/autoUpdateMiddleware.js +12 -2
- package/lib/middleware/commandTargetingUtils.d.ts +1 -1
- package/lib/middleware/commandTargetingUtils.js +16 -20
- package/lib/projects/__tests__/AppDevModeInterface.test.js +95 -109
- package/lib/projects/__tests__/DevServerManager.test.d.ts +1 -0
- package/lib/projects/__tests__/DevServerManager.test.js +183 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +6 -5
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +6 -6
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +161 -0
- package/lib/projects/__tests__/deploy.test.js +9 -9
- package/lib/projects/__tests__/upload.test.js +2 -2
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +35 -35
- package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
- package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
- package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +2 -2
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +3 -3
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +10 -3
- package/lib/projects/localDev/AppDevModeInterface.js +132 -105
- package/lib/projects/localDev/DevServerManager.d.ts +10 -29
- package/lib/projects/localDev/DevServerManager.js +20 -76
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +6 -6
- package/lib/projects/localDev/LocalDevProcess.js +3 -2
- package/lib/projects/localDev/LocalDevState.d.ts +3 -0
- package/lib/projects/localDev/LocalDevState.js +9 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +4 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +39 -6
- package/lib/projects/localDev/UIExtensionsDevModeInterface.d.ts +13 -0
- package/lib/projects/localDev/UIExtensionsDevModeInterface.js +37 -0
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/process.d.ts +1 -0
- package/lib/projects/localDev/helpers/process.js +15 -0
- package/lib/projects/localDev/helpers/project.js +2 -3
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +3 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +9 -0
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- package/lib/prompts/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +1 -1
- package/lib/theme/__tests__/migrate.test.js +4 -4
- package/lib/ui/index.d.ts +2 -0
- package/lib/ui/index.js +8 -0
- package/lib/ui/uiMessages.d.ts +5 -0
- package/lib/ui/uiMessages.js +5 -0
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
- package/package.json +6 -5
- package/types/Cms.d.ts +6 -6
- package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
- package/lib/projects/localDev/DevServerManagerV2.js +0 -81
- /package/commands/{customObject/schema → cms}/__tests__/delete.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/fetch.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/function.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/lint.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/list.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/mv.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/theme.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/function/__tests__}/logs.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.js +0 -0
- /package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/preview.test.d.ts +0 -0
- /package/commands/{__tests__/remove.test.d.ts → customObject/__tests__/createSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/create.test.d.ts → __tests__/deleteSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch-all.test.d.ts → __tests__/fetch-all-schemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch.test.d.ts → __tests__/fetchSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/list.test.d.ts → __tests__/listSchemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/update.test.d.ts → __tests__/updateSchema.test.d.ts} +0 -0
- /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/list.test.d.ts} +0 -0
- /package/lib/{projects/create/__tests__/v3.test.d.ts → __tests__/http.test.d.ts} +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.js +0 -0
- /package/{commands/create → lib/cmsAssets}/app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/function.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/function.js +0 -0
- /package/{commands/create → lib/cmsAssets}/index.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/index.js +0 -0
- /package/{commands/create → lib/cmsAssets}/module.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/module.js +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/template.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/template.js +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.js +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.js +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
|
+
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
|
+
import { HTTP_METHODS } from '../../../types/Cms.js';
|
|
8
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
10
|
+
import assets from '../../../lib/cmsAssets/index.js';
|
|
11
|
+
const command = 'create [name] [dest]';
|
|
12
|
+
const describe = commands.cms.subcommands.function.subcommands.create.describe;
|
|
13
|
+
async function handler(args) {
|
|
14
|
+
const { derivedAccountId, name, dest } = args;
|
|
15
|
+
const assetType = 'function';
|
|
16
|
+
trackCommandUsage('create', { assetType }, derivedAccountId);
|
|
17
|
+
const asset = assets[assetType];
|
|
18
|
+
const argsToPass = {
|
|
19
|
+
commandArgs: args,
|
|
20
|
+
assetType,
|
|
21
|
+
name,
|
|
22
|
+
dest,
|
|
23
|
+
};
|
|
24
|
+
if (!argsToPass.dest) {
|
|
25
|
+
argsToPass.dest = resolveLocalPath(asset.dest(argsToPass));
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await fs.ensureDir(argsToPass.dest);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.create.errors.unusablePath(argsToPass.dest));
|
|
32
|
+
logError(e);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await asset.execute(argsToPass);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
logError(e);
|
|
40
|
+
process.exit(EXIT_CODES.ERROR);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function functionCreateBuilder(yargs) {
|
|
44
|
+
yargs.positional('name', {
|
|
45
|
+
describe: commands.cms.subcommands.function.subcommands.create.positionals.name,
|
|
46
|
+
type: 'string',
|
|
47
|
+
});
|
|
48
|
+
yargs.positional('dest', {
|
|
49
|
+
describe: commands.cms.subcommands.function.subcommands.create.positionals.dest,
|
|
50
|
+
type: 'string',
|
|
51
|
+
});
|
|
52
|
+
yargs.option('functions-folder', {
|
|
53
|
+
describe: commands.cms.subcommands.function.subcommands.create.options
|
|
54
|
+
.functionsFolder,
|
|
55
|
+
type: 'string',
|
|
56
|
+
});
|
|
57
|
+
yargs.option('filename', {
|
|
58
|
+
describe: commands.cms.subcommands.function.subcommands.create.options.filename,
|
|
59
|
+
type: 'string',
|
|
60
|
+
});
|
|
61
|
+
yargs.option('endpoint-method', {
|
|
62
|
+
describe: commands.cms.subcommands.function.subcommands.create.options
|
|
63
|
+
.endpointMethod,
|
|
64
|
+
type: 'string',
|
|
65
|
+
choices: [...HTTP_METHODS],
|
|
66
|
+
default: 'GET',
|
|
67
|
+
});
|
|
68
|
+
yargs.option('endpoint-path', {
|
|
69
|
+
describe: commands.cms.subcommands.function.subcommands.create.options.endpointPath,
|
|
70
|
+
type: 'string',
|
|
71
|
+
});
|
|
72
|
+
return yargs;
|
|
73
|
+
}
|
|
74
|
+
const builder = makeYargsBuilder(functionCreateBuilder, command, describe, {
|
|
75
|
+
useGlobalOptions: true,
|
|
76
|
+
useConfigOptions: true,
|
|
77
|
+
});
|
|
78
|
+
const functionCreateCommand = {
|
|
79
|
+
command,
|
|
80
|
+
describe,
|
|
81
|
+
builder,
|
|
82
|
+
handler,
|
|
83
|
+
};
|
|
84
|
+
export default functionCreateCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionDeployArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const functionDeployCommand: YargsCommandModule<unknown, FunctionDeployArgs>;
|
|
6
|
+
export default functionDeployCommand;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
2
|
+
import { buildPackage, getBuildStatus, } from '@hubspot/local-dev-lib/api/functions';
|
|
3
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
|
+
import SpinniesManager from '../../../lib/ui/SpinniesManager.js';
|
|
5
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
6
|
+
import { logError, ApiErrorContext } from '../../../lib/errorHandlers/index.js';
|
|
7
|
+
import { uiAccountDescription } from '../../../lib/ui/index.js';
|
|
8
|
+
import { poll } from '../../../lib/polling.js';
|
|
9
|
+
import { outputBuildLog } from '../../../lib/serverlessLogs.js';
|
|
10
|
+
import { commands } from '../../../lang/en.js';
|
|
11
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
12
|
+
function isFunctionBuildError(e) {
|
|
13
|
+
return (typeof e === 'object' && e !== null && 'status' in e && e.status === 'ERROR');
|
|
14
|
+
}
|
|
15
|
+
const command = 'deploy <path>';
|
|
16
|
+
const describe = undefined; // Hidden command
|
|
17
|
+
async function handler(args) {
|
|
18
|
+
const { path: functionPath, derivedAccountId } = args;
|
|
19
|
+
const splitFunctionPath = functionPath.split('.');
|
|
20
|
+
trackCommandUsage('function-deploy', undefined, derivedAccountId);
|
|
21
|
+
if (!splitFunctionPath.length ||
|
|
22
|
+
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
23
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.notFunctionsFolder(functionPath));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.deploy.debug.startingBuildAndDeploy(functionPath));
|
|
27
|
+
SpinniesManager.init();
|
|
28
|
+
SpinniesManager.add('loading', {
|
|
29
|
+
text: commands.cms.subcommands.function.subcommands.deploy.loading(functionPath, uiAccountDescription(derivedAccountId)),
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
|
|
33
|
+
const successResp = await poll(() => getBuildStatus(derivedAccountId, Number(buildId)));
|
|
34
|
+
if (successResp) {
|
|
35
|
+
const buildTimeSeconds = successResp.buildTime
|
|
36
|
+
? (successResp.buildTime / 1000).toFixed(2)
|
|
37
|
+
: 0;
|
|
38
|
+
SpinniesManager.succeed('loading');
|
|
39
|
+
if (successResp.cdnUrl) {
|
|
40
|
+
await outputBuildLog(successResp.cdnUrl);
|
|
41
|
+
}
|
|
42
|
+
uiLogger.success(commands.cms.subcommands.function.subcommands.deploy.success.deployed(functionPath, derivedAccountId, buildTimeSeconds));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
SpinniesManager.fail('loading', {
|
|
47
|
+
text: commands.cms.subcommands.function.subcommands.deploy.loadingFailed(functionPath, uiAccountDescription(derivedAccountId)),
|
|
48
|
+
});
|
|
49
|
+
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
50
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.noPackageJson(functionPath));
|
|
51
|
+
}
|
|
52
|
+
else if (isFunctionBuildError(e)) {
|
|
53
|
+
await outputBuildLog(e.cdnUrl);
|
|
54
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.buildError(String(e.errorReason)));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
logError(e, new ApiErrorContext({
|
|
58
|
+
accountId: derivedAccountId,
|
|
59
|
+
request: functionPath,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function functionDeployBuilder(yargs) {
|
|
65
|
+
yargs.positional('path', {
|
|
66
|
+
describe: commands.cms.subcommands.function.subcommands.deploy.positionals.path
|
|
67
|
+
.describe,
|
|
68
|
+
type: 'string',
|
|
69
|
+
});
|
|
70
|
+
yargs.example([
|
|
71
|
+
[
|
|
72
|
+
'$0 functions deploy myFunctionFolder.functions',
|
|
73
|
+
commands.cms.subcommands.function.subcommands.deploy.examples.default,
|
|
74
|
+
],
|
|
75
|
+
]);
|
|
76
|
+
return yargs;
|
|
77
|
+
}
|
|
78
|
+
const builder = makeYargsBuilder(functionDeployBuilder, command, describe, {
|
|
79
|
+
useConfigOptions: true,
|
|
80
|
+
useAccountOptions: true,
|
|
81
|
+
useEnvironmentOptions: true,
|
|
82
|
+
});
|
|
83
|
+
const functionDeployCommand = {
|
|
84
|
+
command,
|
|
85
|
+
describe,
|
|
86
|
+
handler,
|
|
87
|
+
builder,
|
|
88
|
+
};
|
|
89
|
+
export default functionDeployCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionListArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
json?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const functionListCommand: YargsCommandModule<unknown, FunctionListArgs>;
|
|
6
|
+
export default functionListCommand;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { getRoutes } from '@hubspot/local-dev-lib/api/functions';
|
|
3
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
4
|
+
import { logError, ApiErrorContext } from '../../../lib/errorHandlers/index.js';
|
|
5
|
+
import { getTableContents, getTableHeader } from '../../../lib/ui/table.js';
|
|
6
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
7
|
+
import { commands } from '../../../lang/en.js';
|
|
8
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
10
|
+
const command = ['list', 'ls'];
|
|
11
|
+
const describe = commands.cms.subcommands.function.subcommands.list.describe;
|
|
12
|
+
async function handler(args) {
|
|
13
|
+
const { derivedAccountId } = args;
|
|
14
|
+
trackCommandUsage('function-list', undefined, derivedAccountId);
|
|
15
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.list.debug.gettingFunctions);
|
|
16
|
+
const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
|
|
17
|
+
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
18
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
19
|
+
});
|
|
20
|
+
if (!routesResp.objects.length) {
|
|
21
|
+
return uiLogger.info(commands.cms.subcommands.function.subcommands.list.info.noFunctions);
|
|
22
|
+
}
|
|
23
|
+
if (args.json) {
|
|
24
|
+
return uiLogger.json(routesResp.objects);
|
|
25
|
+
}
|
|
26
|
+
const functionsAsArrays = routesResp.objects.map(func => {
|
|
27
|
+
const { route, method, created, updated, secretNames } = func;
|
|
28
|
+
return [
|
|
29
|
+
route,
|
|
30
|
+
method,
|
|
31
|
+
secretNames.join(', '),
|
|
32
|
+
moment(created).format(),
|
|
33
|
+
moment(updated).format(),
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
functionsAsArrays.unshift(getTableHeader(['Route', 'Method', 'Secrets', 'Created', 'Updated']));
|
|
37
|
+
return uiLogger.log(getTableContents(functionsAsArrays));
|
|
38
|
+
}
|
|
39
|
+
function functionListBuilder(yargs) {
|
|
40
|
+
yargs.options({
|
|
41
|
+
json: {
|
|
42
|
+
describe: commands.cms.subcommands.function.subcommands.list.options.json
|
|
43
|
+
.describe,
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return yargs;
|
|
48
|
+
}
|
|
49
|
+
const builder = makeYargsBuilder(functionListBuilder, command, describe, {
|
|
50
|
+
useConfigOptions: true,
|
|
51
|
+
useAccountOptions: true,
|
|
52
|
+
useEnvironmentOptions: true,
|
|
53
|
+
});
|
|
54
|
+
const functionListCommand = {
|
|
55
|
+
command,
|
|
56
|
+
describe,
|
|
57
|
+
handler,
|
|
58
|
+
builder,
|
|
59
|
+
};
|
|
60
|
+
export default functionListCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, YargsCommandModule, EnvironmentArgs } from '../../../types/Yargs.js';
|
|
2
|
+
export type LogsArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
latest?: boolean;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
follow?: boolean;
|
|
7
|
+
limit?: number;
|
|
8
|
+
};
|
|
9
|
+
declare const logsCommand: YargsCommandModule<unknown, LogsArgs>;
|
|
10
|
+
export default logsCommand;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
|
+
import { outputLogs } from '../../../lib/ui/serverlessFunctionLogs.js';
|
|
3
|
+
import { getFunctionLogs, getLatestFunctionLog, } from '@hubspot/local-dev-lib/api/functions';
|
|
4
|
+
import { tailLogs } from '../../../lib/serverlessLogs.js';
|
|
5
|
+
import { promptUser } from '../../../lib/prompts/promptUtils.js';
|
|
6
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
7
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
8
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
10
|
+
import { commands } from '../../../lang/en.js';
|
|
11
|
+
const handleLogsError = (e, accountId, functionPath) => {
|
|
12
|
+
if (isHubSpotHttpError(e) && (e.status === 404 || e.status == 400)) {
|
|
13
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.logs.errors.noLogsFound(functionPath, accountId));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const endpointLog = async (accountId, functionPath, options) => {
|
|
17
|
+
const { limit, latest, follow, compact } = options;
|
|
18
|
+
const requestParams = {
|
|
19
|
+
limit,
|
|
20
|
+
latest,
|
|
21
|
+
follow,
|
|
22
|
+
endpoint: functionPath,
|
|
23
|
+
};
|
|
24
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.logs.gettingLogs(latest, functionPath));
|
|
25
|
+
let logsResp;
|
|
26
|
+
if (follow) {
|
|
27
|
+
const tailCall = (after) => getFunctionLogs(accountId, functionPath, { after });
|
|
28
|
+
const fetchLatest = () => {
|
|
29
|
+
try {
|
|
30
|
+
return getLatestFunctionLog(accountId, functionPath);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
handleLogsError(e, accountId, functionPath);
|
|
34
|
+
return Promise.reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
await tailLogs(accountId, functionPath, fetchLatest, tailCall, compact);
|
|
38
|
+
}
|
|
39
|
+
else if (latest) {
|
|
40
|
+
try {
|
|
41
|
+
const { data } = await getLatestFunctionLog(accountId, functionPath);
|
|
42
|
+
logsResp = data;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
handleLogsError(e, accountId, functionPath);
|
|
46
|
+
process.exit(EXIT_CODES.ERROR);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
try {
|
|
51
|
+
const { data } = await getFunctionLogs(accountId, functionPath, requestParams);
|
|
52
|
+
logsResp = data;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
handleLogsError(e, accountId, functionPath);
|
|
56
|
+
process.exit(EXIT_CODES.ERROR);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (logsResp) {
|
|
60
|
+
return outputLogs(logsResp, { compact });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const command = 'logs [endpoint]';
|
|
64
|
+
const describe = commands.cms.subcommands.function.subcommands.logs.describe;
|
|
65
|
+
const handler = async (options) => {
|
|
66
|
+
const { endpoint: endpointArgValue, latest, derivedAccountId } = options;
|
|
67
|
+
trackCommandUsage('logs', latest ? { action: 'latest' } : {}, derivedAccountId);
|
|
68
|
+
const { endpointPromptValue } = await promptUser({
|
|
69
|
+
name: 'endpointPromptValue',
|
|
70
|
+
message: commands.cms.subcommands.function.subcommands.logs.endpointPrompt,
|
|
71
|
+
when: !endpointArgValue,
|
|
72
|
+
});
|
|
73
|
+
await endpointLog(derivedAccountId, endpointArgValue || endpointPromptValue, options);
|
|
74
|
+
};
|
|
75
|
+
function logsBuilder(yargs) {
|
|
76
|
+
yargs.positional('endpoint', {
|
|
77
|
+
describe: commands.cms.subcommands.function.subcommands.logs.positionals.endpoint
|
|
78
|
+
.describe,
|
|
79
|
+
type: 'string',
|
|
80
|
+
});
|
|
81
|
+
yargs
|
|
82
|
+
.options({
|
|
83
|
+
latest: {
|
|
84
|
+
alias: 'l',
|
|
85
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.latest
|
|
86
|
+
.describe,
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
},
|
|
89
|
+
compact: {
|
|
90
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.compact
|
|
91
|
+
.describe,
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
},
|
|
94
|
+
follow: {
|
|
95
|
+
alias: ['f'],
|
|
96
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.follow
|
|
97
|
+
.describe,
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
},
|
|
100
|
+
limit: {
|
|
101
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.limit
|
|
102
|
+
.describe,
|
|
103
|
+
type: 'number',
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
.conflicts('follow', 'limit');
|
|
107
|
+
yargs.example([
|
|
108
|
+
[
|
|
109
|
+
'$0 logs my-endpoint',
|
|
110
|
+
commands.cms.subcommands.function.subcommands.logs.examples.default,
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
'$0 logs my-endpoint --limit=10',
|
|
114
|
+
commands.cms.subcommands.function.subcommands.logs.examples.limit,
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
'$0 logs my-endpoint --follow',
|
|
118
|
+
commands.cms.subcommands.function.subcommands.logs.examples.follow,
|
|
119
|
+
],
|
|
120
|
+
]);
|
|
121
|
+
return yargs;
|
|
122
|
+
}
|
|
123
|
+
const builder = makeYargsBuilder(logsBuilder, command, describe, {
|
|
124
|
+
useGlobalOptions: true,
|
|
125
|
+
useConfigOptions: true,
|
|
126
|
+
useAccountOptions: true,
|
|
127
|
+
useEnvironmentOptions: true,
|
|
128
|
+
});
|
|
129
|
+
const logsCommand = {
|
|
130
|
+
command,
|
|
131
|
+
describe,
|
|
132
|
+
builder,
|
|
133
|
+
handler,
|
|
134
|
+
};
|
|
135
|
+
export default logsCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionServerArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
port?: string;
|
|
5
|
+
contact?: boolean;
|
|
6
|
+
watch?: boolean;
|
|
7
|
+
'log-output'?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const functionServerCommand: YargsCommandModule<unknown, FunctionServerArgs>;
|
|
10
|
+
export default functionServerCommand;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
3
|
+
// This package is not typed, so we need to use require
|
|
4
|
+
import { start as startTestServer } from '@hubspot/serverless-dev-runtime';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
7
|
+
const command = 'server <path>';
|
|
8
|
+
const describe = undefined;
|
|
9
|
+
async function handler(args) {
|
|
10
|
+
const { path: functionPath, derivedAccountId } = args;
|
|
11
|
+
trackCommandUsage('functions-server', undefined, derivedAccountId);
|
|
12
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.server.debug.startingServer(functionPath));
|
|
13
|
+
startTestServer({
|
|
14
|
+
accountId: derivedAccountId,
|
|
15
|
+
...args,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function functionServerBuilder(yargs) {
|
|
19
|
+
yargs.positional('path', {
|
|
20
|
+
describe: commands.cms.subcommands.function.subcommands.server.positionals.path
|
|
21
|
+
.describe,
|
|
22
|
+
type: 'string',
|
|
23
|
+
});
|
|
24
|
+
yargs.options({
|
|
25
|
+
port: {
|
|
26
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.port
|
|
27
|
+
.describe,
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: 5432,
|
|
30
|
+
},
|
|
31
|
+
contact: {
|
|
32
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.contact
|
|
33
|
+
.describe,
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
default: true,
|
|
36
|
+
},
|
|
37
|
+
watch: {
|
|
38
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.watch
|
|
39
|
+
.describe,
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
'log-output': {
|
|
44
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.logOutput
|
|
45
|
+
.describe,
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
yargs.example([
|
|
51
|
+
[
|
|
52
|
+
'$0 functions server ./tmp/myFunctionFolder.functions',
|
|
53
|
+
commands.cms.subcommands.function.subcommands.server.examples.default,
|
|
54
|
+
],
|
|
55
|
+
]);
|
|
56
|
+
return yargs;
|
|
57
|
+
}
|
|
58
|
+
const builder = makeYargsBuilder(functionServerBuilder, command, describe, {
|
|
59
|
+
useConfigOptions: true,
|
|
60
|
+
useAccountOptions: true,
|
|
61
|
+
useEnvironmentOptions: true,
|
|
62
|
+
});
|
|
63
|
+
const functionServerCommand = {
|
|
64
|
+
command,
|
|
65
|
+
describe,
|
|
66
|
+
handler,
|
|
67
|
+
builder,
|
|
68
|
+
};
|
|
69
|
+
export default functionServerCommand;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import createCommand from './function/create.js';
|
|
2
|
+
import listCommand from './function/list.js';
|
|
3
|
+
import deployCommand from './function/deploy.js';
|
|
4
|
+
import serverCommand from './function/server.js';
|
|
5
|
+
import logsCommand from './function/logs.js';
|
|
6
|
+
import { commands } from '../../lang/en.js';
|
|
7
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
|
+
const command = ['function', 'functions'];
|
|
9
|
+
const describe = commands.cms.subcommands.function.describe;
|
|
10
|
+
function functionBuilder(yargs) {
|
|
11
|
+
yargs
|
|
12
|
+
.command(createCommand)
|
|
13
|
+
.command(listCommand)
|
|
14
|
+
.command(deployCommand)
|
|
15
|
+
.command(serverCommand)
|
|
16
|
+
.command(logsCommand)
|
|
17
|
+
.demandCommand(1, '');
|
|
18
|
+
return yargs;
|
|
19
|
+
}
|
|
20
|
+
const builder = makeYargsBuilder(functionBuilder, command, describe);
|
|
21
|
+
const functionCommand = {
|
|
22
|
+
command,
|
|
23
|
+
describe,
|
|
24
|
+
builder,
|
|
25
|
+
handler: () => { },
|
|
26
|
+
};
|
|
27
|
+
export default functionCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccountArgs, CommonArgs, ConfigArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
export type LintArgs = CommonArgs & ConfigArgs & AccountArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const lintCommand: YargsCommandModule<unknown, LintArgs>;
|
|
6
|
+
export default lintCommand;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { lint } from '@hubspot/local-dev-lib/cms/validate';
|
|
2
|
+
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
|
+
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
5
|
+
import { resolveLocalPath } from '../../lib/filesystem.js';
|
|
6
|
+
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
7
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
|
+
const command = 'lint <path>';
|
|
10
|
+
// Hiding since this command is still experimental
|
|
11
|
+
const describe = undefined; //'Lint a file or folder for HubL syntax';
|
|
12
|
+
function getErrorsFromHublValidationObject(validation) {
|
|
13
|
+
return ((validation && validation.meta && validation.meta.template_errors) || []);
|
|
14
|
+
}
|
|
15
|
+
function printHublValidationError(err) {
|
|
16
|
+
const { severity, message, lineno, startPosition } = err;
|
|
17
|
+
if (severity === 'FATAL') {
|
|
18
|
+
uiLogger.error(`[${lineno}, ${startPosition}]: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
uiLogger.warn(`[${lineno}, ${startPosition}]: ${message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function printHublValidationResult({ file, validation }) {
|
|
25
|
+
let count = 0;
|
|
26
|
+
if (!validation) {
|
|
27
|
+
return count;
|
|
28
|
+
}
|
|
29
|
+
const errors = getErrorsFromHublValidationObject(validation);
|
|
30
|
+
if (!errors.length) {
|
|
31
|
+
return count;
|
|
32
|
+
}
|
|
33
|
+
uiLogger.group(file);
|
|
34
|
+
errors.forEach(err => {
|
|
35
|
+
if (err.reason !== 'SYNTAX_ERROR') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
++count;
|
|
39
|
+
printHublValidationError(err);
|
|
40
|
+
});
|
|
41
|
+
uiLogger.groupEnd();
|
|
42
|
+
return count;
|
|
43
|
+
}
|
|
44
|
+
async function handler(args) {
|
|
45
|
+
const { path: lintPath, derivedAccountId } = args;
|
|
46
|
+
const localPath = resolveLocalPath(lintPath);
|
|
47
|
+
const groupName = commands.cms.subcommands.lint.groupName(localPath);
|
|
48
|
+
trackCommandUsage('lint', undefined, derivedAccountId);
|
|
49
|
+
uiLogger.group(groupName);
|
|
50
|
+
let count = 0;
|
|
51
|
+
try {
|
|
52
|
+
await lint(derivedAccountId, localPath, (result) => {
|
|
53
|
+
return (count += printHublValidationResult(result));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
uiLogger.groupEnd();
|
|
58
|
+
logError(err, { accountId: derivedAccountId });
|
|
59
|
+
process.exit(EXIT_CODES.ERROR);
|
|
60
|
+
}
|
|
61
|
+
uiLogger.groupEnd();
|
|
62
|
+
uiLogger.log(commands.cms.subcommands.lint.issuesFound(count));
|
|
63
|
+
}
|
|
64
|
+
function lintBuilder(yargs) {
|
|
65
|
+
yargs.positional('path', {
|
|
66
|
+
describe: commands.cms.subcommands.lint.positionals.path.describe,
|
|
67
|
+
required: true,
|
|
68
|
+
type: 'string',
|
|
69
|
+
});
|
|
70
|
+
return yargs;
|
|
71
|
+
}
|
|
72
|
+
const builder = makeYargsBuilder(lintBuilder, command, describe, {
|
|
73
|
+
useGlobalOptions: true,
|
|
74
|
+
useConfigOptions: true,
|
|
75
|
+
useAccountOptions: true,
|
|
76
|
+
});
|
|
77
|
+
const lintCommand = {
|
|
78
|
+
command,
|
|
79
|
+
describe,
|
|
80
|
+
handler,
|
|
81
|
+
builder,
|
|
82
|
+
};
|
|
83
|
+
export default lintCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
export type ListArgs = CommonArgs & ConfigArgs & EnvironmentArgs & AccountArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const cmsListCommand: YargsCommandModule<unknown, ListArgs>;
|
|
6
|
+
export default cmsListCommand;
|