@hubspot/cli 7.7.15-experimental.0 → 7.7.16-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 +4 -0
- package/bin/hs +1 -1
- package/commands/getStarted.d.ts +9 -0
- package/commands/getStarted.js +227 -0
- package/commands/init.js +6 -1
- package/commands/mcp/setup.d.ts +4 -10
- package/commands/mcp/setup.js +28 -220
- package/commands/mcp/start.d.ts +3 -9
- package/commands/mcp/start.js +18 -15
- package/commands/mcp.js +2 -1
- package/commands/project/deploy.d.ts +1 -0
- package/commands/project/deploy.js +29 -3
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +18 -23
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +82 -0
- package/commands/project.js +2 -0
- package/commands/testAccount/create.d.ts +6 -0
- package/commands/testAccount/create.js +110 -0
- package/commands/testAccount/createConfig.d.ts +10 -0
- package/commands/testAccount/createConfig.js +98 -0
- package/commands/testAccount/delete.d.ts +6 -0
- package/commands/testAccount/delete.js +48 -0
- package/commands/testAccount.d.ts +3 -0
- package/commands/testAccount.js +28 -0
- package/lang/en.d.ts +144 -29
- package/lang/en.js +144 -32
- package/lang/en.lyaml +9 -14
- package/lib/app/migrate.js +15 -3
- package/lib/commonOpts.d.ts +2 -0
- package/lib/commonOpts.js +21 -9
- package/lib/constants.d.ts +5 -0
- package/lib/constants.js +6 -1
- package/lib/doctor/Doctor.js +1 -1
- package/lib/errorHandlers/index.js +7 -0
- package/lib/mcp/setup.d.ts +21 -0
- package/lib/mcp/setup.js +218 -0
- package/lib/projectProfiles.d.ts +1 -0
- package/lib/projectProfiles.js +18 -0
- package/lib/projects/buildAndDeploy.js +1 -1
- package/lib/projects/localDev/AppDevModeInterface.d.ts +3 -0
- package/lib/projects/localDev/AppDevModeInterface.js +45 -16
- package/lib/projects/localDev/LocalDevManager.js +1 -1
- package/lib/projects/upload.d.ts +3 -0
- package/lib/projects/upload.js +56 -22
- package/lib/projects/urls.d.ts +2 -0
- package/lib/projects/urls.js +10 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +17 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +96 -0
- package/lib/prompts/installAppPrompt.d.ts +2 -1
- package/lib/prompts/installAppPrompt.js +12 -2
- package/lib/prompts/promptUtils.d.ts +1 -0
- package/lib/prompts/promptUtils.js +2 -0
- package/lib/ui/logger.d.ts +1 -0
- package/lib/ui/logger.js +1 -0
- package/lib/yargsUtils.d.ts +1 -0
- package/lib/yargsUtils.js +3 -0
- package/mcp-server/tools/index.js +2 -0
- package/mcp-server/tools/project/AddFeatureToProject.js +6 -29
- package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/CreateProjectTool.js +12 -31
- package/mcp-server/tools/project/DeployProject.js +4 -11
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +3 -16
- package/mcp-server/tools/project/UploadProjectTools.js +3 -7
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +17 -0
- package/mcp-server/tools/project/ValidateProjectTool.js +35 -0
- package/mcp-server/utils/content.d.ts +3 -0
- package/mcp-server/utils/content.js +21 -0
- package/package.json +10 -9
- package/types/LocalDev.d.ts +1 -0
- package/types/Yargs.d.ts +4 -0
|
@@ -22,6 +22,7 @@ const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
|
22
22
|
const ui_2 = require("../../lib/ui");
|
|
23
23
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
24
24
|
const projectProfiles_1 = require("../../lib/projectProfiles");
|
|
25
|
+
const constants_1 = require("../../lib/constants");
|
|
25
26
|
const command = 'deploy';
|
|
26
27
|
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.deploy.describe`), false);
|
|
27
28
|
function validateBuildId(buildId, deployedBuildId, latestBuildId, projectName, accountId) {
|
|
@@ -40,8 +41,22 @@ function validateBuildId(buildId, deployedBuildId, latestBuildId, projectName, a
|
|
|
40
41
|
}
|
|
41
42
|
return true;
|
|
42
43
|
}
|
|
44
|
+
function logDeployErrors(errorData) {
|
|
45
|
+
logger_1.logger.error(errorData.message);
|
|
46
|
+
errorData.errors.forEach(err => {
|
|
47
|
+
if (err.subCategory === constants_1.PROJECT_ERROR_TYPES.DEPLOY_CONTAINS_REMOVALS) {
|
|
48
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.deployContainsRemovals`, {
|
|
49
|
+
componentName: err.context.COMPONENT_NAME,
|
|
50
|
+
forceFlag: (0, ui_2.uiCommandReference)('--force'),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
logger_1.logger.log(err.message);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
43
58
|
async function handler(args) {
|
|
44
|
-
const { derivedAccountId, project: projectOption, buildId: buildIdOption, } = args;
|
|
59
|
+
const { derivedAccountId, project: projectOption, buildId: buildIdOption, force: forceOption, } = args;
|
|
45
60
|
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
46
61
|
const accountType = accountConfig && accountConfig.accountType;
|
|
47
62
|
let targetAccountId;
|
|
@@ -103,7 +118,7 @@ async function handler(args) {
|
|
|
103
118
|
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.noBuildId`));
|
|
104
119
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
105
120
|
}
|
|
106
|
-
const { data: deployResp } = await (0, projects_1.deployProject)(targetAccountId, projectName, buildIdToDeploy, (0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion));
|
|
121
|
+
const { data: deployResp } = await (0, projects_1.deployProject)(targetAccountId, projectName, buildIdToDeploy, (0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion), forceOption);
|
|
107
122
|
if (!deployResp) {
|
|
108
123
|
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.deploy`));
|
|
109
124
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
@@ -119,7 +134,12 @@ async function handler(args) {
|
|
|
119
134
|
}));
|
|
120
135
|
}
|
|
121
136
|
else if ((0, index_1.isHubSpotHttpError)(e) && e.status === 400) {
|
|
122
|
-
|
|
137
|
+
if (e.data?.message && e.data?.errors) {
|
|
138
|
+
logDeployErrors(e.data);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
logger_1.logger.error(e.message);
|
|
142
|
+
}
|
|
123
143
|
}
|
|
124
144
|
else {
|
|
125
145
|
(0, index_2.logError)(e, new index_2.ApiErrorContext({
|
|
@@ -147,6 +167,12 @@ function projectDeployBuilder(yargs) {
|
|
|
147
167
|
type: 'string',
|
|
148
168
|
hidden: true,
|
|
149
169
|
},
|
|
170
|
+
force: {
|
|
171
|
+
alias: ['f'],
|
|
172
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.deploy.options.force.describe`),
|
|
173
|
+
default: false,
|
|
174
|
+
type: 'boolean',
|
|
175
|
+
},
|
|
150
176
|
});
|
|
151
177
|
yargs.conflicts('profile', 'project');
|
|
152
178
|
yargs.conflicts('profile', 'account');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommonArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
-
type ProjectUploadArgs = CommonArgs & {
|
|
1
|
+
import { CommonArgs, JSONOutputArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
+
type ProjectUploadArgs = CommonArgs & JSONOutputArgs & {
|
|
3
3
|
forceCreate: boolean;
|
|
4
4
|
message: string;
|
|
5
5
|
m: string;
|
|
@@ -13,40 +13,26 @@ const usageTracking_1 = require("../../lib/usageTracking");
|
|
|
13
13
|
const config_2 = require("../../lib/projects/config");
|
|
14
14
|
const ui_2 = require("../../lib/projects/ui");
|
|
15
15
|
const upload_1 = require("../../lib/projects/upload");
|
|
16
|
+
const projectProfiles_1 = require("../../lib/projectProfiles");
|
|
16
17
|
const buildAndDeploy_2 = require("../../lib/projects/buildAndDeploy");
|
|
17
18
|
const lang_1 = require("../../lib/lang");
|
|
18
19
|
const constants_1 = require("../../lib/constants");
|
|
19
20
|
const index_2 = require("../../lib/errorHandlers/index");
|
|
20
21
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
21
22
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
22
|
-
const
|
|
23
|
+
const logger_2 = require("../../lib/ui/logger");
|
|
23
24
|
const command = 'upload';
|
|
24
25
|
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.upload.describe`), false);
|
|
25
26
|
async function handler(args) {
|
|
26
|
-
const { forceCreate, message, derivedAccountId,
|
|
27
|
+
const { forceCreate, message, derivedAccountId, skipValidation, formatOutputAsJson, profile, } = args;
|
|
28
|
+
const jsonOutput = {};
|
|
27
29
|
const { projectConfig, projectDir } = await (0, config_2.getProjectConfig)();
|
|
28
30
|
(0, config_2.validateProjectConfig)(projectConfig, projectDir);
|
|
29
|
-
let targetAccountId
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
(0, projectProfiles_1.logProfileHeader)(args.profile);
|
|
33
|
-
const profile = (0, projectProfiles_1.loadProfile)(projectConfig, projectDir, args.profile);
|
|
34
|
-
if (!profile) {
|
|
35
|
-
(0, ui_1.uiLine)();
|
|
36
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
37
|
-
}
|
|
38
|
-
targetAccountId = profile.accountId;
|
|
39
|
-
(0, projectProfiles_1.logProfileFooter)(profile, true);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
// A profile must be specified if this project has profiles configured
|
|
43
|
-
await (0, projectProfiles_1.exitIfUsingProfiles)(projectConfig, projectDir);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (!targetAccountId) {
|
|
47
|
-
// The user is not using profiles, so we can use the derived accountId
|
|
48
|
-
targetAccountId = derivedAccountId;
|
|
31
|
+
let targetAccountId;
|
|
32
|
+
if ((0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion)) {
|
|
33
|
+
targetAccountId = await (0, projectProfiles_1.loadAndValidateProfile)(projectConfig, projectDir, profile);
|
|
49
34
|
}
|
|
35
|
+
targetAccountId = targetAccountId || derivedAccountId;
|
|
50
36
|
const accountConfig = (0, config_1.getAccountConfig)(targetAccountId);
|
|
51
37
|
const accountType = accountConfig && accountConfig.accountType;
|
|
52
38
|
(0, usageTracking_1.trackCommandUsage)('project-upload', { type: accountType }, targetAccountId);
|
|
@@ -88,7 +74,12 @@ async function handler(args) {
|
|
|
88
74
|
}));
|
|
89
75
|
(0, ui_2.logFeedbackMessage)(result.buildId);
|
|
90
76
|
await (0, buildAndDeploy_2.displayWarnLogs)(targetAccountId, projectConfig.name, result.buildId);
|
|
91
|
-
|
|
77
|
+
}
|
|
78
|
+
if (result && result.succeeded && formatOutputAsJson) {
|
|
79
|
+
jsonOutput.buildId = result.buildId;
|
|
80
|
+
if (result.deployResult) {
|
|
81
|
+
jsonOutput.deployId = result.deployResult.deployId;
|
|
82
|
+
}
|
|
92
83
|
}
|
|
93
84
|
}
|
|
94
85
|
catch (e) {
|
|
@@ -98,6 +89,9 @@ async function handler(args) {
|
|
|
98
89
|
}));
|
|
99
90
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
100
91
|
}
|
|
92
|
+
if (formatOutputAsJson) {
|
|
93
|
+
logger_2.uiLogger.json(jsonOutput);
|
|
94
|
+
}
|
|
101
95
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
102
96
|
}
|
|
103
97
|
function projectUploadBuilder(yargs) {
|
|
@@ -139,6 +133,7 @@ const builder = (0, yargsUtils_1.makeYargsBuilder)(projectUploadBuilder, command
|
|
|
139
133
|
useConfigOptions: true,
|
|
140
134
|
useAccountOptions: true,
|
|
141
135
|
useEnvironmentOptions: true,
|
|
136
|
+
useJSONOutputOptions: true,
|
|
142
137
|
});
|
|
143
138
|
const projectUploadCommand = {
|
|
144
139
|
command,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const buildAndDeploy_1 = require("../../lib/projects/buildAndDeploy");
|
|
9
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
10
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
11
|
+
const config_2 = require("../../lib/projects/config");
|
|
12
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
13
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
14
|
+
const upload_1 = require("../../lib/projects/upload");
|
|
15
|
+
const en_1 = require("../../lang/en");
|
|
16
|
+
const projectProfiles_1 = require("../../lib/projectProfiles");
|
|
17
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
18
|
+
const command = 'validate';
|
|
19
|
+
const describe = undefined;
|
|
20
|
+
async function handler(args) {
|
|
21
|
+
const { derivedAccountId, profile } = args;
|
|
22
|
+
const { projectConfig, projectDir } = await (0, config_2.getProjectConfig)();
|
|
23
|
+
if (!projectConfig) {
|
|
24
|
+
logger_1.uiLogger.error(en_1.commands.project.validate.mustBeRanWithinAProject);
|
|
25
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
26
|
+
}
|
|
27
|
+
if (!(0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion)) {
|
|
28
|
+
logger_1.uiLogger.error(en_1.commands.project.validate.badVersion);
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
|
+
}
|
|
31
|
+
(0, config_2.validateProjectConfig)(projectConfig, projectDir);
|
|
32
|
+
let targetAccountId = await (0, projectProfiles_1.loadAndValidateProfile)(projectConfig, projectDir, profile);
|
|
33
|
+
targetAccountId = targetAccountId || derivedAccountId;
|
|
34
|
+
const accountConfig = (0, config_1.getAccountConfig)(targetAccountId);
|
|
35
|
+
const accountType = accountConfig && accountConfig.accountType;
|
|
36
|
+
(0, usageTracking_1.trackCommandUsage)('project-validate', { type: accountType }, targetAccountId);
|
|
37
|
+
const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
38
|
+
try {
|
|
39
|
+
(0, upload_1.validateSourceDirectory)(srcDir, projectConfig);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
(0, errorHandlers_1.logError)(e);
|
|
43
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await (0, upload_1.handleTranslate)(projectDir, projectConfig, targetAccountId, false, profile);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
(0, errorHandlers_1.logError)(e);
|
|
50
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
51
|
+
}
|
|
52
|
+
logger_1.uiLogger.success(en_1.commands.project.validate.success(projectConfig.name));
|
|
53
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
54
|
+
}
|
|
55
|
+
function projectValidateBuilder(yargs) {
|
|
56
|
+
yargs.options({
|
|
57
|
+
profile: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
alias: 'p',
|
|
60
|
+
describe: en_1.commands.project.validate.options.profile.describe,
|
|
61
|
+
hidden: true,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
yargs.conflicts('profile', 'account');
|
|
65
|
+
yargs.example([
|
|
66
|
+
['$0 project validate', en_1.commands.project.validate.examples.default],
|
|
67
|
+
]);
|
|
68
|
+
return yargs;
|
|
69
|
+
}
|
|
70
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectValidateBuilder, command, describe, {
|
|
71
|
+
useGlobalOptions: true,
|
|
72
|
+
useConfigOptions: true,
|
|
73
|
+
useAccountOptions: true,
|
|
74
|
+
useEnvironmentOptions: true,
|
|
75
|
+
});
|
|
76
|
+
const projectValidateCommand = {
|
|
77
|
+
command,
|
|
78
|
+
describe,
|
|
79
|
+
handler,
|
|
80
|
+
builder,
|
|
81
|
+
};
|
|
82
|
+
exports.default = projectValidateCommand;
|
package/commands/project.js
CHANGED
|
@@ -20,6 +20,7 @@ const migrateApp_1 = __importDefault(require("./project/migrateApp"));
|
|
|
20
20
|
const cloneApp_1 = __importDefault(require("./project/cloneApp"));
|
|
21
21
|
const installDeps_1 = __importDefault(require("./project/installDeps"));
|
|
22
22
|
const profile_1 = __importDefault(require("./project/profile"));
|
|
23
|
+
const validate_1 = __importDefault(require("./project/validate"));
|
|
23
24
|
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
24
25
|
const command = ['project', 'projects'];
|
|
25
26
|
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.describe`), false);
|
|
@@ -40,6 +41,7 @@ function projectBuilder(yargs) {
|
|
|
40
41
|
.command(cloneApp_1.default)
|
|
41
42
|
.command(installDeps_1.default)
|
|
42
43
|
.command(profile_1.default)
|
|
44
|
+
.command(validate_1.default)
|
|
43
45
|
.demandCommand(1, '');
|
|
44
46
|
return yargs;
|
|
45
47
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, TestingArgs, YargsCommandModule, EnvironmentArgs, JSONOutputArgs } from '../../types/Yargs';
|
|
2
|
+
type CreateTestAccountArgs = CommonArgs & AccountArgs & ConfigArgs & TestingArgs & EnvironmentArgs & JSONOutputArgs & {
|
|
3
|
+
configPath?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const createTestAccountCommand: YargsCommandModule<unknown, CreateTestAccountArgs>;
|
|
6
|
+
export default createTestAccountCommand;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
9
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
10
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
11
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
12
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
13
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
14
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
|
+
const validation_1 = require("../../lib/validation");
|
|
16
|
+
const en_1 = require("../../lang/en");
|
|
17
|
+
const createDeveloperTestAccountConfigPrompt_1 = require("../../lib/prompts/createDeveloperTestAccountConfigPrompt");
|
|
18
|
+
const command = 'create';
|
|
19
|
+
const describe = en_1.commands.testAccount.create.describe;
|
|
20
|
+
async function handler(args) {
|
|
21
|
+
const { derivedAccountId, configPath, formatOutputAsJson } = args;
|
|
22
|
+
(0, usageTracking_1.trackCommandUsage)('test-account-create', {}, derivedAccountId);
|
|
23
|
+
let accountConfigPath = configPath;
|
|
24
|
+
let testAccountConfig;
|
|
25
|
+
if (!accountConfigPath) {
|
|
26
|
+
const createTestAccountFromConfig = await (0, promptUtils_1.listPrompt)(en_1.commands.testAccount.create.createTestAccountFromConfigPrompt, {
|
|
27
|
+
choices: [
|
|
28
|
+
{
|
|
29
|
+
name: en_1.commands.testAccount.create.createFromConfigOption,
|
|
30
|
+
value: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: en_1.commands.testAccount.create.createFromScratchOption,
|
|
34
|
+
value: false,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
if (createTestAccountFromConfig) {
|
|
39
|
+
const configPathPromptResult = await (0, promptUtils_1.promptUser)({
|
|
40
|
+
name: 'configPath',
|
|
41
|
+
message: en_1.commands.testAccount.create.configPathPrompt,
|
|
42
|
+
type: 'input',
|
|
43
|
+
});
|
|
44
|
+
accountConfigPath = configPathPromptResult.configPath;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (accountConfigPath) {
|
|
48
|
+
const absoluteConfigPath = path_1.default.resolve((0, path_2.getCwd)(), accountConfigPath);
|
|
49
|
+
if (!(0, validation_1.fileExists)(absoluteConfigPath)) {
|
|
50
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.create.errors.configFileNotFound(absoluteConfigPath));
|
|
51
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
testAccountConfig = JSON.parse(fs_extra_1.default.readFileSync(absoluteConfigPath, 'utf8'));
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.create.errors.configFileParseFailed(absoluteConfigPath));
|
|
58
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
testAccountConfig = await (0, createDeveloperTestAccountConfigPrompt_1.createDeveloperTestAccountConfigPrompt)();
|
|
63
|
+
}
|
|
64
|
+
const jsonOutput = {};
|
|
65
|
+
try {
|
|
66
|
+
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(derivedAccountId, testAccountConfig);
|
|
67
|
+
if (formatOutputAsJson) {
|
|
68
|
+
jsonOutput.accountName = data.accountName;
|
|
69
|
+
jsonOutput.accountId = data.id;
|
|
70
|
+
jsonOutput.personalAccessKey = data.personalAccessKey;
|
|
71
|
+
}
|
|
72
|
+
logger_1.uiLogger.success(en_1.commands.testAccount.create.success.configFileUpdated(data.accountName, data.id));
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.create.errors.failedToCreate);
|
|
76
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
77
|
+
}
|
|
78
|
+
if (formatOutputAsJson) {
|
|
79
|
+
logger_1.uiLogger.json(jsonOutput);
|
|
80
|
+
}
|
|
81
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
82
|
+
}
|
|
83
|
+
function createTestAccountBuilder(yargs) {
|
|
84
|
+
yargs.option('config-path', {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: en_1.commands.testAccount.create.options.configPath,
|
|
87
|
+
});
|
|
88
|
+
yargs.example([
|
|
89
|
+
[
|
|
90
|
+
'$0 create --config-path ./test-account-config.json',
|
|
91
|
+
en_1.commands.testAccount.create.example('./test-account-config.json'),
|
|
92
|
+
],
|
|
93
|
+
]);
|
|
94
|
+
return yargs;
|
|
95
|
+
}
|
|
96
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(createTestAccountBuilder, command, describe, {
|
|
97
|
+
useGlobalOptions: true,
|
|
98
|
+
useEnvironmentOptions: true,
|
|
99
|
+
useAccountOptions: true,
|
|
100
|
+
useConfigOptions: true,
|
|
101
|
+
useTestingOptions: true,
|
|
102
|
+
useJSONOutputOptions: true,
|
|
103
|
+
});
|
|
104
|
+
const createTestAccountCommand = {
|
|
105
|
+
command,
|
|
106
|
+
describe,
|
|
107
|
+
handler,
|
|
108
|
+
builder,
|
|
109
|
+
};
|
|
110
|
+
exports.default = createTestAccountCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
+
import { HubConfig } from '../../lib/prompts/createDeveloperTestAccountConfigPrompt';
|
|
3
|
+
type CreateTestAccountConfigArgs = CommonArgs & {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
tiers?: HubConfig[];
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const createTestAccountConfigCommand: YargsCommandModule<unknown, CreateTestAccountConfigArgs>;
|
|
10
|
+
export default createTestAccountConfigCommand;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
9
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
10
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
11
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
12
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
13
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
14
|
+
const en_1 = require("../../lang/en");
|
|
15
|
+
const createDeveloperTestAccountConfigPrompt_1 = require("../../lib/prompts/createDeveloperTestAccountConfigPrompt");
|
|
16
|
+
const validation_1 = require("../../lib/validation");
|
|
17
|
+
const command = 'create-config';
|
|
18
|
+
const describe = en_1.commands.testAccount.createConfig.describe;
|
|
19
|
+
async function handler(args) {
|
|
20
|
+
const { derivedAccountId, name, tiers, description, path: configPath } = args;
|
|
21
|
+
(0, usageTracking_1.trackCommandUsage)('test-account-create-config', {}, derivedAccountId);
|
|
22
|
+
let accountConfigPath = configPath;
|
|
23
|
+
const testAccountConfig = await (0, createDeveloperTestAccountConfigPrompt_1.createDeveloperTestAccountConfigPrompt)({
|
|
24
|
+
name,
|
|
25
|
+
description,
|
|
26
|
+
tiers,
|
|
27
|
+
});
|
|
28
|
+
if (!accountConfigPath) {
|
|
29
|
+
const pathPromptResult = await (0, promptUtils_1.promptUser)({
|
|
30
|
+
name: 'path',
|
|
31
|
+
message: en_1.commands.testAccount.createConfig.pathPrompt,
|
|
32
|
+
type: 'input',
|
|
33
|
+
default: 'test-account-config.json',
|
|
34
|
+
validate: path => {
|
|
35
|
+
if (!path) {
|
|
36
|
+
return en_1.commands.testAccount.createConfig.errors.pathError;
|
|
37
|
+
}
|
|
38
|
+
else if (!path.endsWith('.json')) {
|
|
39
|
+
return en_1.commands.testAccount.createConfig.errors.pathFormatError;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
accountConfigPath = pathPromptResult.path;
|
|
45
|
+
}
|
|
46
|
+
if (!accountConfigPath) {
|
|
47
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.createConfig.errors.pathError);
|
|
48
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
49
|
+
}
|
|
50
|
+
if ((0, validation_1.fileExists)(accountConfigPath)) {
|
|
51
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.createConfig.errors.pathExistsError);
|
|
52
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
fs_extra_1.default.writeFileSync(path_1.default.resolve((0, path_2.getCwd)(), accountConfigPath), JSON.stringify(testAccountConfig, null, 2), 'utf8');
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.createConfig.errors.failedToCreate);
|
|
59
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
60
|
+
}
|
|
61
|
+
logger_1.uiLogger.success(en_1.commands.testAccount.createConfig.success.configFileCreated(accountConfigPath));
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
63
|
+
}
|
|
64
|
+
function createTestAccountConfigBuilder(yargs) {
|
|
65
|
+
yargs.option('name', {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: en_1.commands.testAccount.createConfig.options.name,
|
|
68
|
+
});
|
|
69
|
+
yargs.option('description', {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: en_1.commands.testAccount.createConfig.options.description,
|
|
72
|
+
});
|
|
73
|
+
yargs.option('tiers', {
|
|
74
|
+
type: 'array',
|
|
75
|
+
description: en_1.commands.testAccount.createConfig.options.tiers,
|
|
76
|
+
});
|
|
77
|
+
yargs.option('path', {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: en_1.commands.testAccount.createConfig.options.path,
|
|
80
|
+
});
|
|
81
|
+
yargs.example([
|
|
82
|
+
[
|
|
83
|
+
'$0 create-config --name my-account',
|
|
84
|
+
en_1.commands.testAccount.createConfig.example('my-account'),
|
|
85
|
+
],
|
|
86
|
+
]);
|
|
87
|
+
return yargs;
|
|
88
|
+
}
|
|
89
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(createTestAccountConfigBuilder, command, describe, {
|
|
90
|
+
useGlobalOptions: true,
|
|
91
|
+
});
|
|
92
|
+
const createTestAccountConfigCommand = {
|
|
93
|
+
command,
|
|
94
|
+
describe,
|
|
95
|
+
handler,
|
|
96
|
+
builder,
|
|
97
|
+
};
|
|
98
|
+
exports.default = createTestAccountConfigCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, TestingArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
|
+
type DeleteTestAccountArgs = CommonArgs & AccountArgs & ConfigArgs & TestingArgs & EnvironmentArgs & {
|
|
3
|
+
testAccountId: number;
|
|
4
|
+
};
|
|
5
|
+
declare const deleteTestAccountCommand: YargsCommandModule<unknown, DeleteTestAccountArgs>;
|
|
6
|
+
export default deleteTestAccountCommand;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
4
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
5
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
6
|
+
const logger_1 = require("../../lib/ui/logger");
|
|
7
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
8
|
+
const en_1 = require("../../lang/en");
|
|
9
|
+
const command = 'delete <test-account-id>';
|
|
10
|
+
const describe = en_1.commands.testAccount.delete.describe;
|
|
11
|
+
async function handler(args) {
|
|
12
|
+
const { derivedAccountId, testAccountId } = args;
|
|
13
|
+
(0, usageTracking_1.trackCommandUsage)('test-account-delete', {}, derivedAccountId);
|
|
14
|
+
try {
|
|
15
|
+
await (0, developerTestAccounts_1.deleteDeveloperTestAccount)(derivedAccountId, testAccountId, true);
|
|
16
|
+
logger_1.uiLogger.success(en_1.commands.testAccount.delete.success.testAccountDeleted(testAccountId));
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
logger_1.uiLogger.error(en_1.commands.testAccount.delete.errors.failedToDelete);
|
|
20
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
21
|
+
}
|
|
22
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
23
|
+
}
|
|
24
|
+
function deleteTestAccountBuilder(yargs) {
|
|
25
|
+
yargs.positional('test-account-id', {
|
|
26
|
+
type: 'number',
|
|
27
|
+
description: en_1.commands.testAccount.delete.positionals.testAccountId,
|
|
28
|
+
required: true,
|
|
29
|
+
});
|
|
30
|
+
yargs.example([
|
|
31
|
+
['$0 delete 1234567890', en_1.commands.testAccount.delete.example(1234567890)],
|
|
32
|
+
]);
|
|
33
|
+
return yargs;
|
|
34
|
+
}
|
|
35
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(deleteTestAccountBuilder, command, describe, {
|
|
36
|
+
useGlobalOptions: true,
|
|
37
|
+
useEnvironmentOptions: true,
|
|
38
|
+
useAccountOptions: true,
|
|
39
|
+
useConfigOptions: true,
|
|
40
|
+
useTestingOptions: true,
|
|
41
|
+
});
|
|
42
|
+
const deleteTestAccountCommand = {
|
|
43
|
+
command,
|
|
44
|
+
describe,
|
|
45
|
+
handler,
|
|
46
|
+
builder,
|
|
47
|
+
};
|
|
48
|
+
exports.default = deleteTestAccountCommand;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const create_1 = __importDefault(require("./testAccount/create"));
|
|
7
|
+
const createConfig_1 = __importDefault(require("./testAccount/createConfig"));
|
|
8
|
+
const delete_1 = __importDefault(require("./testAccount/delete"));
|
|
9
|
+
const yargsUtils_1 = require("../lib/yargsUtils");
|
|
10
|
+
const en_1 = require("../lang/en");
|
|
11
|
+
const command = ['test-account', 'test-accounts'];
|
|
12
|
+
const describe = undefined; //commands.testAccount.describe;
|
|
13
|
+
function testAccountBuilder(yargs) {
|
|
14
|
+
yargs
|
|
15
|
+
.command(create_1.default)
|
|
16
|
+
.command(createConfig_1.default)
|
|
17
|
+
.command(delete_1.default)
|
|
18
|
+
.demandCommand(1, '');
|
|
19
|
+
return yargs;
|
|
20
|
+
}
|
|
21
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(testAccountBuilder, command, en_1.commands.testAccount.describe);
|
|
22
|
+
const testAccountCommand = {
|
|
23
|
+
command,
|
|
24
|
+
describe,
|
|
25
|
+
builder,
|
|
26
|
+
handler: () => { },
|
|
27
|
+
};
|
|
28
|
+
exports.default = testAccountCommand;
|