@hubspot/cli 7.3.0-experimental.2 → 7.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/migrate.d.ts +61 -0
- package/api/migrate.js +44 -0
- package/bin/cli.js +10 -241
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +168 -0
- package/commands/account/clean.js +45 -13
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +104 -0
- package/commands/account/info.js +43 -11
- package/commands/account/list.js +27 -10
- package/commands/account/remove.js +42 -9
- package/commands/account/removeOverride.d.ts +10 -0
- package/commands/account/removeOverride.js +76 -0
- package/commands/account/rename.js +4 -5
- package/commands/account/use.js +29 -8
- package/commands/account.js +7 -2
- package/commands/app/migrate.d.ts +7 -0
- package/commands/app/migrate.js +95 -0
- package/commands/app.d.ts +6 -0
- package/commands/app.js +23 -0
- package/commands/auth.js +6 -2
- package/commands/cms/convertFields.js +5 -6
- package/commands/cms/getReactModule.js +7 -8
- package/commands/cms/lighthouseScore.js +19 -16
- package/commands/config/migrate.d.ts +10 -0
- package/commands/config/migrate.js +84 -0
- package/commands/config/set.d.ts +10 -0
- package/commands/config/set.js +34 -30
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -11
- package/commands/create/api-sample.js +8 -7
- package/commands/create/module.js +1 -2
- package/commands/create/template.js +1 -2
- package/commands/customObject/create.js +8 -9
- package/commands/customObject/schema/create.js +5 -6
- package/commands/customObject/schema/delete.js +12 -10
- package/commands/customObject/schema/fetch-all.js +8 -8
- package/commands/customObject/schema/fetch.js +10 -10
- package/commands/customObject/schema/list.js +2 -3
- package/commands/customObject/schema/update.js +7 -8
- package/commands/customObject/schema.js +1 -2
- package/commands/filemanager/fetch.js +5 -6
- package/commands/filemanager/upload.js +12 -13
- package/commands/function/deploy.js +9 -10
- package/commands/function/list.js +4 -5
- package/commands/function/server.js +7 -8
- package/commands/init.js +9 -10
- package/commands/project/cloneApp.d.ts +9 -1
- package/commands/project/cloneApp.js +91 -76
- package/commands/project/create.js +1 -0
- package/commands/project/migrateApp.d.ts +9 -1
- package/commands/project/migrateApp.js +43 -170
- package/commands/project/watch.js +12 -0
- package/lang/en.js +11 -3
- package/lang/en.lyaml +125 -10
- package/lib/DevServerManagerV2.d.ts +1 -2
- package/lib/DevServerManagerV2.js +1 -2
- package/lib/LocalDevManagerV2.js +10 -15
- package/lib/app/migrate.d.ts +5 -0
- package/lib/app/migrate.js +242 -0
- package/lib/app/migrate_legacy.d.ts +4 -0
- package/lib/app/migrate_legacy.js +129 -0
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +104 -0
- package/lib/dependencyManagement.d.ts +5 -0
- package/lib/dependencyManagement.js +47 -22
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +10 -6
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +1 -0
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +19 -2
- package/lib/middleware/__test__/configMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/configMiddleware.test.js +194 -0
- package/lib/middleware/__test__/gitMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/gitMiddleware.test.js +76 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +10 -0
- package/lib/middleware/__test__/requestMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/requestMiddleware.test.js +20 -0
- package/lib/middleware/__test__/utils.test.d.ts +1 -0
- package/lib/middleware/__test__/utils.test.js +53 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +81 -0
- package/lib/middleware/configMiddleware.d.ts +13 -0
- package/lib/middleware/configMiddleware.js +109 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +137 -0
- package/lib/middleware/gitMiddleware.d.ts +2 -0
- package/lib/middleware/gitMiddleware.js +14 -0
- package/lib/middleware/notificationsMiddleware.d.ts +1 -0
- package/lib/middleware/notificationsMiddleware.js +38 -0
- package/lib/middleware/requestMiddleware.d.ts +1 -0
- package/lib/middleware/requestMiddleware.js +11 -0
- package/lib/middleware/utils.d.ts +8 -0
- package/lib/middleware/utils.js +17 -0
- package/lib/middleware/yargsChecksMiddleware.d.ts +4 -0
- package/lib/middleware/yargsChecksMiddleware.js +24 -0
- package/lib/polling.d.ts +4 -0
- package/lib/polling.js +3 -3
- package/lib/projects/structure.d.ts +1 -2
- package/lib/projects/structure.js +0 -4
- package/lib/prompts/promptUtils.d.ts +6 -4
- package/lib/prompts/promptUtils.js +3 -1
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/index.d.ts +3 -2
- package/lib/ui/index.js +11 -5
- package/lib/ui/spinniesUtils.d.ts +5 -5
- package/package.json +8 -7
- package/types/ProjectComponents.d.ts +0 -15
- package/types/Prompts.d.ts +2 -2
- package/types/Yargs.d.ts +10 -0
- package/lib/npm.d.ts +0 -9
- package/lib/npm.js +0 -36
|
@@ -11,13 +11,12 @@ const usageTracking_1 = require("../../lib/usageTracking");
|
|
|
11
11
|
const lang_1 = require("../../lib/lang");
|
|
12
12
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
13
13
|
const index_1 = require("../../lib/errorHandlers/index");
|
|
14
|
-
const i18nKey = 'commands.filemanager.subcommands.fetch';
|
|
15
14
|
exports.command = 'fetch <src> [dest]';
|
|
16
|
-
exports.describe = (0, lang_1.i18n)(
|
|
15
|
+
exports.describe = (0, lang_1.i18n)(`commands.filemanager.subcommands.fetch.describe`);
|
|
17
16
|
async function handler(args) {
|
|
18
17
|
const { src, includeArchived, derivedAccountId, overwrite } = args;
|
|
19
18
|
if (typeof src !== 'string') {
|
|
20
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
19
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.fetch.errors.sourceRequired`));
|
|
21
20
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
22
21
|
}
|
|
23
22
|
const dest = (0, filesystem_1.resolveLocalPath)(args.dest);
|
|
@@ -38,16 +37,16 @@ function builder(yargs) {
|
|
|
38
37
|
(0, commonOpts_1.addOverwriteOptions)(yargs);
|
|
39
38
|
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
40
39
|
yargs.positional('src', {
|
|
41
|
-
describe: (0, lang_1.i18n)(
|
|
40
|
+
describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.fetch.positionals.src.describe`),
|
|
42
41
|
type: 'string',
|
|
43
42
|
});
|
|
44
43
|
yargs.positional('dest', {
|
|
45
|
-
describe: (0, lang_1.i18n)(
|
|
44
|
+
describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.fetch.positionals.dest.describe`),
|
|
46
45
|
type: 'string',
|
|
47
46
|
});
|
|
48
47
|
yargs.option('include-archived', {
|
|
49
48
|
alias: ['i'],
|
|
50
|
-
describe: (0, lang_1.i18n)(
|
|
49
|
+
describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.fetch.options.includeArchived.describe`),
|
|
51
50
|
type: 'boolean',
|
|
52
51
|
});
|
|
53
52
|
return yargs;
|
|
@@ -19,9 +19,8 @@ const commonOpts_1 = require("../../lib/commonOpts");
|
|
|
19
19
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
20
20
|
const lang_1 = require("../../lib/lang");
|
|
21
21
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
22
|
-
const i18nKey = 'commands.filemanager.subcommands.upload';
|
|
23
22
|
exports.command = 'upload <src> <dest>';
|
|
24
|
-
exports.describe = (0, lang_1.i18n)(
|
|
23
|
+
exports.describe = (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.describe`);
|
|
25
24
|
async function handler(args) {
|
|
26
25
|
const { src, dest, derivedAccountId } = args;
|
|
27
26
|
const absoluteSrcPath = path_1.default.resolve((0, path_2.getCwd)(), src);
|
|
@@ -29,20 +28,20 @@ async function handler(args) {
|
|
|
29
28
|
try {
|
|
30
29
|
stats = fs_1.default.statSync(absoluteSrcPath);
|
|
31
30
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
32
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
31
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.invalidPath`, {
|
|
33
32
|
path: src,
|
|
34
33
|
}));
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
catch (e) {
|
|
39
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
38
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.invalidPath`, {
|
|
40
39
|
path: src,
|
|
41
40
|
}));
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
44
43
|
if (!dest) {
|
|
45
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
44
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.destinationRequired`));
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
const normalizedDest = (0, path_2.convertToUnixPath)(dest);
|
|
@@ -54,21 +53,21 @@ async function handler(args) {
|
|
|
54
53
|
}
|
|
55
54
|
if (stats.isFile()) {
|
|
56
55
|
if ((0, ignoreRules_1.shouldIgnoreFile)(absoluteSrcPath)) {
|
|
57
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
56
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.fileIgnored`, {
|
|
58
57
|
path: src,
|
|
59
58
|
}));
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
62
61
|
(0, fileManager_2.uploadFile)(derivedAccountId, absoluteSrcPath, normalizedDest)
|
|
63
62
|
.then(() => {
|
|
64
|
-
logger_1.logger.success((0, lang_1.i18n)(
|
|
63
|
+
logger_1.logger.success((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.success.upload`, {
|
|
65
64
|
accountId: derivedAccountId,
|
|
66
65
|
dest: normalizedDest,
|
|
67
66
|
src,
|
|
68
67
|
}));
|
|
69
68
|
})
|
|
70
69
|
.catch(error => {
|
|
71
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
70
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.upload`, {
|
|
72
71
|
dest: normalizedDest,
|
|
73
72
|
src,
|
|
74
73
|
}));
|
|
@@ -80,19 +79,19 @@ async function handler(args) {
|
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
81
|
else {
|
|
83
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
82
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.logs.uploading`, {
|
|
84
83
|
accountId: derivedAccountId,
|
|
85
84
|
dest,
|
|
86
85
|
src,
|
|
87
86
|
}));
|
|
88
87
|
(0, fileManager_1.uploadFolder)(derivedAccountId, absoluteSrcPath, dest)
|
|
89
88
|
.then(() => {
|
|
90
|
-
logger_1.logger.success((0, lang_1.i18n)(
|
|
89
|
+
logger_1.logger.success((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.success.uploadComplete`, {
|
|
91
90
|
dest,
|
|
92
91
|
}));
|
|
93
92
|
})
|
|
94
93
|
.catch(error => {
|
|
95
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
94
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.filemanager.subcommands.upload.errors.uploadingFailed`));
|
|
96
95
|
(0, index_1.logError)(error, {
|
|
97
96
|
accountId: derivedAccountId,
|
|
98
97
|
});
|
|
@@ -105,11 +104,11 @@ function builder(yargs) {
|
|
|
105
104
|
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
106
105
|
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
107
106
|
yargs.positional('src', {
|
|
108
|
-
describe: (0, lang_1.i18n)(
|
|
107
|
+
describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.positionals.src.describe`),
|
|
109
108
|
type: 'string',
|
|
110
109
|
});
|
|
111
110
|
yargs.positional('dest', {
|
|
112
|
-
describe: (0, lang_1.i18n)(
|
|
111
|
+
describe: (0, lang_1.i18n)(`commands.filemanager.subcommands.upload.positionals.dest.describe`),
|
|
113
112
|
type: 'string',
|
|
114
113
|
});
|
|
115
114
|
return yargs;
|
|
@@ -12,7 +12,6 @@ const { buildPackage, getBuildStatus, } = require('@hubspot/local-dev-lib/api/fu
|
|
|
12
12
|
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
13
13
|
const { i18n } = require('../../lib/lang');
|
|
14
14
|
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
15
|
-
const i18nKey = 'commands.function.subcommands.deploy';
|
|
16
15
|
exports.command = 'deploy <path>';
|
|
17
16
|
exports.describe = false;
|
|
18
17
|
exports.handler = async (options) => {
|
|
@@ -21,17 +20,17 @@ exports.handler = async (options) => {
|
|
|
21
20
|
trackCommandUsage('functions-deploy', null, derivedAccountId);
|
|
22
21
|
if (!splitFunctionPath.length ||
|
|
23
22
|
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
24
|
-
logger.error(i18n(
|
|
23
|
+
logger.error(i18n('commands.function.subcommands.deploy.errors.notFunctionsFolder', {
|
|
25
24
|
functionPath,
|
|
26
25
|
}));
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
logger.debug(i18n(
|
|
28
|
+
logger.debug(i18n('commands.function.subcommands.deploy.debug.startingBuildAndDeploy', {
|
|
30
29
|
functionPath,
|
|
31
30
|
}));
|
|
32
31
|
SpinniesManager.init();
|
|
33
32
|
SpinniesManager.add('loading', {
|
|
34
|
-
text: i18n(
|
|
33
|
+
text: i18n('commands.function.subcommands.deploy.loading', {
|
|
35
34
|
account: uiAccountDescription(derivedAccountId),
|
|
36
35
|
functionPath,
|
|
37
36
|
}),
|
|
@@ -42,7 +41,7 @@ exports.handler = async (options) => {
|
|
|
42
41
|
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
|
|
43
42
|
SpinniesManager.succeed('loading');
|
|
44
43
|
await outputBuildLog(successResp.cdnUrl);
|
|
45
|
-
logger.success(i18n(
|
|
44
|
+
logger.success(i18n('commands.function.subcommands.deploy.success.deployed', {
|
|
46
45
|
accountId: derivedAccountId,
|
|
47
46
|
buildTimeSeconds,
|
|
48
47
|
functionPath,
|
|
@@ -50,19 +49,19 @@ exports.handler = async (options) => {
|
|
|
50
49
|
}
|
|
51
50
|
catch (e) {
|
|
52
51
|
SpinniesManager.fail('loading', {
|
|
53
|
-
text: i18n(
|
|
52
|
+
text: i18n('commands.function.subcommands.deploy.loadingFailed', {
|
|
54
53
|
account: uiAccountDescription(derivedAccountId),
|
|
55
54
|
functionPath,
|
|
56
55
|
}),
|
|
57
56
|
});
|
|
58
57
|
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
59
|
-
logger.error(i18n(
|
|
58
|
+
logger.error(i18n('commands.function.subcommands.deploy.errors.noPackageJson', {
|
|
60
59
|
functionPath,
|
|
61
60
|
}));
|
|
62
61
|
}
|
|
63
62
|
else if (e.status === 'ERROR') {
|
|
64
63
|
await outputBuildLog(e.cdnUrl);
|
|
65
|
-
logger.error(i18n(
|
|
64
|
+
logger.error(i18n('commands.function.subcommands.deploy.errors.buildError', {
|
|
66
65
|
details: e.errorReason,
|
|
67
66
|
}));
|
|
68
67
|
}
|
|
@@ -76,13 +75,13 @@ exports.handler = async (options) => {
|
|
|
76
75
|
};
|
|
77
76
|
exports.builder = yargs => {
|
|
78
77
|
yargs.positional('path', {
|
|
79
|
-
describe: i18n(
|
|
78
|
+
describe: i18n('commands.function.subcommands.deploy.positionals.path.describe'),
|
|
80
79
|
type: 'string',
|
|
81
80
|
});
|
|
82
81
|
yargs.example([
|
|
83
82
|
[
|
|
84
83
|
'$0 functions deploy myFunctionFolder.functions',
|
|
85
|
-
i18n(
|
|
84
|
+
i18n('commands.function.subcommands.deploy.examples.default'),
|
|
86
85
|
],
|
|
87
86
|
]);
|
|
88
87
|
addConfigOptions(yargs);
|
|
@@ -9,20 +9,19 @@ const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
|
9
9
|
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
|
-
const i18nKey = 'commands.function.subcommands.list';
|
|
13
12
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
14
13
|
exports.command = ['list', 'ls'];
|
|
15
|
-
exports.describe = i18n(
|
|
14
|
+
exports.describe = i18n('commands.function.subcommands.list.describe');
|
|
16
15
|
exports.handler = async (options) => {
|
|
17
16
|
const { derivedAccountId } = options;
|
|
18
17
|
trackCommandUsage('functions-list', null, derivedAccountId);
|
|
19
|
-
logger.debug(i18n(
|
|
18
|
+
logger.debug(i18n('commands.function.subcommands.list.debug.gettingFunctions'));
|
|
20
19
|
const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
|
|
21
20
|
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
22
21
|
process.exit(EXIT_CODES.SUCCESS);
|
|
23
22
|
});
|
|
24
23
|
if (!routesResp.objects.length) {
|
|
25
|
-
return logger.info(i18n(
|
|
24
|
+
return logger.info(i18n('commands.function.subcommands.list.info.noFunctions'));
|
|
26
25
|
}
|
|
27
26
|
if (options.json) {
|
|
28
27
|
return logger.log(routesResp.objects);
|
|
@@ -46,7 +45,7 @@ exports.builder = yargs => {
|
|
|
46
45
|
addUseEnvironmentOptions(yargs);
|
|
47
46
|
yargs.options({
|
|
48
47
|
json: {
|
|
49
|
-
describe: i18n(
|
|
48
|
+
describe: i18n('commands.function.subcommands.list.options.json.describe'),
|
|
50
49
|
type: 'boolean',
|
|
51
50
|
},
|
|
52
51
|
});
|
|
@@ -6,13 +6,12 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { start: startTestServer } = require('@hubspot/serverless-dev-runtime');
|
|
8
8
|
const { i18n } = require('../../lib/lang');
|
|
9
|
-
const i18nKey = 'commands.function.subcommands.server';
|
|
10
9
|
exports.command = 'server <path>';
|
|
11
10
|
exports.describe = false;
|
|
12
11
|
exports.handler = async (options) => {
|
|
13
12
|
const { path: functionPath, derivedAccountId } = options;
|
|
14
13
|
trackCommandUsage('functions-server', null, derivedAccountId);
|
|
15
|
-
logger.debug(i18n(
|
|
14
|
+
logger.debug(i18n('commands.function.subcommands.server.debug.startingServer', {
|
|
16
15
|
functionPath,
|
|
17
16
|
}));
|
|
18
17
|
startTestServer({
|
|
@@ -22,33 +21,33 @@ exports.handler = async (options) => {
|
|
|
22
21
|
};
|
|
23
22
|
exports.builder = yargs => {
|
|
24
23
|
yargs.positional('path', {
|
|
25
|
-
describe: i18n(
|
|
24
|
+
describe: i18n('commands.function.subcommands.server.positionals.path.describe'),
|
|
26
25
|
type: 'string',
|
|
27
26
|
});
|
|
28
27
|
yargs.option('port', {
|
|
29
|
-
describe: i18n(
|
|
28
|
+
describe: i18n('commands.function.subcommands.server.options.port.describe'),
|
|
30
29
|
type: 'string',
|
|
31
30
|
default: 5432,
|
|
32
31
|
});
|
|
33
32
|
yargs.option('contact', {
|
|
34
|
-
describe: i18n(
|
|
33
|
+
describe: i18n('commands.function.subcommands.server.options.contact.describe'),
|
|
35
34
|
type: 'boolean',
|
|
36
35
|
default: true,
|
|
37
36
|
});
|
|
38
37
|
yargs.option('watch', {
|
|
39
|
-
describe: i18n(
|
|
38
|
+
describe: i18n('commands.function.subcommands.server.options.watch.describe'),
|
|
40
39
|
type: 'boolean',
|
|
41
40
|
default: true,
|
|
42
41
|
});
|
|
43
42
|
yargs.option('log-output', {
|
|
44
|
-
describe: i18n(
|
|
43
|
+
describe: i18n('commands.function.subcommands.server.options.logOutput.describe'),
|
|
45
44
|
type: 'boolean',
|
|
46
45
|
default: false,
|
|
47
46
|
});
|
|
48
47
|
yargs.example([
|
|
49
48
|
[
|
|
50
49
|
'$0 functions server ./tmp/myFunctionFolder.functions',
|
|
51
|
-
i18n(
|
|
50
|
+
i18n('commands.function.subcommands.server.examples.default'),
|
|
52
51
|
],
|
|
53
52
|
]);
|
|
54
53
|
addConfigOptions(yargs);
|
package/commands/init.js
CHANGED
|
@@ -78,6 +78,13 @@ async function handler(args) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
|
|
81
|
+
if ((0, config_1.configFileExists)(true)) {
|
|
82
|
+
const globalConfigPath = (0, config_1.getConfigPath)('', true);
|
|
83
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.globalConfigFileExists`, {
|
|
84
|
+
configPath: globalConfigPath,
|
|
85
|
+
}));
|
|
86
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
87
|
+
}
|
|
81
88
|
if (fs_extra_1.default.existsSync(configPath)) {
|
|
82
89
|
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.configFileExists`, {
|
|
83
90
|
configPath: configPath,
|
|
@@ -114,19 +121,16 @@ async function handler(args) {
|
|
|
114
121
|
accountId = oauthResult.accountId;
|
|
115
122
|
name = oauthResult.name;
|
|
116
123
|
}
|
|
124
|
+
const configPath = (0, config_1.getConfigPath)();
|
|
117
125
|
try {
|
|
118
126
|
(0, gitignore_1.checkAndAddConfigToGitignore)(configPath);
|
|
119
127
|
}
|
|
120
128
|
catch (e) {
|
|
121
129
|
(0, index_1.debugError)(e);
|
|
122
130
|
}
|
|
123
|
-
let newConfigPath = configPath;
|
|
124
|
-
if (!newConfigPath && !useHiddenConfig) {
|
|
125
|
-
newConfigPath = `${(0, path_2.getCwd)()}/${config_2.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME}`;
|
|
126
|
-
}
|
|
127
131
|
logger_1.logger.log('');
|
|
128
132
|
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileCreated`, {
|
|
129
|
-
configPath:
|
|
133
|
+
configPath: configPath,
|
|
130
134
|
}));
|
|
131
135
|
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileUpdated`, {
|
|
132
136
|
authType: AUTH_TYPE_NAMES[authType],
|
|
@@ -167,11 +171,6 @@ function initBuilder(yargs) {
|
|
|
167
171
|
hidden: true,
|
|
168
172
|
default: false,
|
|
169
173
|
},
|
|
170
|
-
'use-hidden-config': {
|
|
171
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.useHiddenConfig.describe`),
|
|
172
|
-
hidden: true,
|
|
173
|
-
type: 'boolean',
|
|
174
|
-
},
|
|
175
174
|
});
|
|
176
175
|
yargs.conflicts('use-hidden-config', 'config');
|
|
177
176
|
return yargs;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
|
|
2
|
+
import { CloneAppArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "clone-app";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
export declare const deprecated = true;
|
|
6
|
+
export declare const handler: (options: ArgumentsCamelCase<CloneAppArgs>) => Promise<never>;
|
|
7
|
+
export declare const builder: (yargs: Argv) => Argv<CloneAppArgs>;
|
|
8
|
+
declare const cloneAppCommand: CommandModule<unknown, CloneAppArgs>;
|
|
9
|
+
export default cloneAppCommand;
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
6
|
+
exports.builder = exports.handler = exports.deprecated = exports.describe = exports.command = void 0;
|
|
7
|
+
const ui_1 = require("../../lib/ui");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
11
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
12
|
+
const lang_1 = require("../../lib/lang");
|
|
13
|
+
const selectPublicAppPrompt_1 = require("../../lib/prompts/selectPublicAppPrompt");
|
|
14
|
+
const createProjectPrompt_1 = require("../../lib/prompts/createProjectPrompt");
|
|
15
|
+
const polling_1 = require("../../lib/polling");
|
|
16
|
+
const ui_2 = require("../../lib/ui");
|
|
17
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
18
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
19
|
+
const accountTypes_1 = require("../../lib/accountTypes");
|
|
20
|
+
const projects_1 = require("../../lib/projects");
|
|
21
|
+
const constants_1 = require("../../lib/constants");
|
|
22
|
+
const projects_2 = require("@hubspot/local-dev-lib/api/projects");
|
|
23
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
24
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
25
|
+
const archive_1 = require("@hubspot/local-dev-lib/archive");
|
|
26
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
27
|
+
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
28
|
+
const migrate_1 = require("../../lib/app/migrate");
|
|
24
29
|
const i18nKey = 'commands.project.subcommands.cloneApp';
|
|
25
30
|
exports.command = 'clone-app';
|
|
26
|
-
exports.describe =
|
|
27
|
-
exports.
|
|
31
|
+
exports.describe = (0, ui_1.uiDeprecatedTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
32
|
+
exports.deprecated = true;
|
|
33
|
+
const handler = async (options) => {
|
|
28
34
|
const { derivedAccountId } = options;
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}));
|
|
39
|
-
uiLine();
|
|
40
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
35
|
+
await (0, usageTracking_1.trackCommandUsage)('clone-app', {}, derivedAccountId);
|
|
36
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
37
|
+
const accountName = (0, ui_2.uiAccountDescription)(derivedAccountId);
|
|
38
|
+
if (!accountConfig) {
|
|
39
|
+
throw new Error((0, lang_1.i18n)(`commands.projects.subcommands.cloneApp.errors.noAccountConfig`));
|
|
40
|
+
}
|
|
41
|
+
if (!(0, accountTypes_1.isAppDeveloperAccount)(accountConfig)) {
|
|
42
|
+
(0, migrate_1.logInvalidAccountError)(i18nKey);
|
|
43
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
41
44
|
}
|
|
42
45
|
let appId;
|
|
43
46
|
let projectName;
|
|
@@ -45,96 +48,108 @@ exports.handler = async (options) => {
|
|
|
45
48
|
try {
|
|
46
49
|
appId = options.appId;
|
|
47
50
|
if (!appId) {
|
|
48
|
-
const appIdResponse = await selectPublicAppPrompt({
|
|
51
|
+
const appIdResponse = await (0, selectPublicAppPrompt_1.selectPublicAppPrompt)({
|
|
49
52
|
accountId: derivedAccountId,
|
|
50
53
|
accountName,
|
|
51
|
-
options,
|
|
52
54
|
isMigratingApp: false,
|
|
53
55
|
});
|
|
54
56
|
appId = appIdResponse.appId;
|
|
55
57
|
}
|
|
56
|
-
const createProjectPromptResponse = await createProjectPrompt(options);
|
|
58
|
+
const createProjectPromptResponse = await (0, createProjectPrompt_1.createProjectPrompt)(options);
|
|
57
59
|
projectName = createProjectPromptResponse.name;
|
|
58
60
|
projectDest = createProjectPromptResponse.dest;
|
|
59
61
|
}
|
|
60
62
|
catch (error) {
|
|
61
|
-
logError(error, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
62
|
-
process.exit(EXIT_CODES.ERROR);
|
|
63
|
+
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
64
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
65
|
}
|
|
64
|
-
await trackCommandMetadataUsage('clone-app', {
|
|
66
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('clone-app', { step: 'STARTED' }, derivedAccountId);
|
|
65
67
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
text: i18n(`${i18nKey}.cloneStatus.inProgress`),
|
|
68
|
+
SpinniesManager_1.default.init();
|
|
69
|
+
SpinniesManager_1.default.add('cloneApp', {
|
|
70
|
+
text: (0, lang_1.i18n)(`${i18nKey}.cloneStatus.inProgress`),
|
|
69
71
|
});
|
|
70
|
-
const { data: { exportId }, } = await cloneApp(derivedAccountId, appId);
|
|
71
|
-
const { status } = await poll(() => checkCloneStatus(derivedAccountId, exportId));
|
|
72
|
+
const { data: { exportId }, } = await (0, projects_2.cloneApp)(derivedAccountId, appId);
|
|
73
|
+
const { status } = await (0, polling_1.poll)(() => (0, projects_2.checkCloneStatus)(derivedAccountId, exportId));
|
|
72
74
|
if (status === 'SUCCESS') {
|
|
73
75
|
// Ensure correct project folder structure exists
|
|
74
|
-
const baseDestPath =
|
|
75
|
-
const absoluteDestPath =
|
|
76
|
-
|
|
76
|
+
const baseDestPath = path_1.default.resolve((0, path_2.getCwd)(), projectDest);
|
|
77
|
+
const absoluteDestPath = path_1.default.resolve(baseDestPath, 'src', 'app');
|
|
78
|
+
fs_1.default.mkdirSync(absoluteDestPath, { recursive: true });
|
|
77
79
|
// Extract zipped app files and place them in correct directory
|
|
78
|
-
const { data: zippedApp } = await downloadClonedProject(derivedAccountId, exportId);
|
|
79
|
-
await extractZipArchive(zippedApp, sanitizeFileName(projectName), absoluteDestPath, {
|
|
80
|
+
const { data: zippedApp } = await (0, projects_2.downloadClonedProject)(derivedAccountId, exportId);
|
|
81
|
+
await (0, archive_1.extractZipArchive)(zippedApp, (0, path_2.sanitizeFileName)(projectName), absoluteDestPath, {
|
|
80
82
|
includesRootDir: true,
|
|
81
83
|
hideLogs: true,
|
|
82
84
|
});
|
|
83
85
|
// Create hsproject.json file
|
|
84
|
-
const configPath =
|
|
86
|
+
const configPath = path_1.default.join(baseDestPath, constants_1.PROJECT_CONFIG_FILE);
|
|
85
87
|
const configContent = {
|
|
86
88
|
name: projectName,
|
|
87
89
|
srcDir: 'src',
|
|
88
90
|
platformVersion: '2023.2',
|
|
89
91
|
};
|
|
90
|
-
const success = writeProjectConfig(configPath, configContent);
|
|
91
|
-
|
|
92
|
-
text: i18n(`${i18nKey}.cloneStatus.done`),
|
|
92
|
+
const success = (0, projects_1.writeProjectConfig)(configPath, configContent);
|
|
93
|
+
SpinniesManager_1.default.succeed('cloneApp', {
|
|
94
|
+
text: (0, lang_1.i18n)(`${i18nKey}.cloneStatus.done`),
|
|
93
95
|
succeedColor: 'white',
|
|
94
96
|
});
|
|
95
97
|
if (!success) {
|
|
96
|
-
logger.error(i18n(`${i18nKey}.errors.couldNotWriteConfigPath`), configPath);
|
|
98
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.couldNotWriteConfigPath`), configPath);
|
|
97
99
|
}
|
|
98
|
-
logger.log('');
|
|
99
|
-
uiLine();
|
|
100
|
-
logger.success(i18n(`${i18nKey}.cloneStatus.success`, { dest }));
|
|
101
|
-
logger.log('');
|
|
102
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
100
|
+
logger_1.logger.log('');
|
|
101
|
+
(0, ui_2.uiLine)();
|
|
102
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.cloneStatus.success`, { dest: projectDest }));
|
|
103
|
+
logger_1.logger.log('');
|
|
104
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
catch (error) {
|
|
106
|
-
await trackCommandMetadataUsage('clone-app', {
|
|
107
|
-
|
|
108
|
-
text: i18n(`${i18nKey}.cloneStatus.failure`),
|
|
108
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('clone-app', { successful: false }, derivedAccountId);
|
|
109
|
+
SpinniesManager_1.default.fail('cloneApp', {
|
|
110
|
+
text: (0, lang_1.i18n)(`${i18nKey}.cloneStatus.failure`),
|
|
109
111
|
failColor: 'white',
|
|
110
112
|
});
|
|
111
113
|
// Migrations endpoints return a response object with an errors property. The errors property contains an array of errors.
|
|
112
|
-
if (error
|
|
113
|
-
error
|
|
114
|
+
if (error &&
|
|
115
|
+
typeof error === 'object' &&
|
|
116
|
+
'errors' in error &&
|
|
117
|
+
Array.isArray(error.errors)) {
|
|
118
|
+
error.errors.forEach(e => (0, errorHandlers_1.logError)(e, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId })));
|
|
114
119
|
}
|
|
115
120
|
else {
|
|
116
|
-
logError(error, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
121
|
+
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
|
-
await trackCommandMetadataUsage('clone-app', {
|
|
120
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
124
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('clone-app', { successful: true }, derivedAccountId);
|
|
125
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
121
126
|
};
|
|
122
|
-
exports.
|
|
127
|
+
exports.handler = handler;
|
|
128
|
+
const builder = (yargs) => {
|
|
123
129
|
yargs.options({
|
|
124
130
|
dest: {
|
|
125
|
-
describe: i18n(`${i18nKey}.options.dest.describe`),
|
|
131
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.dest.describe`),
|
|
126
132
|
type: 'string',
|
|
127
133
|
},
|
|
128
134
|
'app-id': {
|
|
129
|
-
describe: i18n(`${i18nKey}.options.appId.describe`),
|
|
135
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.appId.describe`),
|
|
130
136
|
type: 'number',
|
|
131
137
|
},
|
|
132
138
|
});
|
|
133
139
|
yargs.example([
|
|
134
|
-
['$0 project clone-app', i18n(`${i18nKey}.examples.default`)],
|
|
140
|
+
['$0 project clone-app', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
135
141
|
]);
|
|
136
|
-
addConfigOptions(yargs);
|
|
137
|
-
addAccountOptions(yargs);
|
|
138
|
-
addUseEnvironmentOptions(yargs);
|
|
142
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
143
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
144
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
139
145
|
return yargs;
|
|
140
146
|
};
|
|
147
|
+
exports.builder = builder;
|
|
148
|
+
const cloneAppCommand = {
|
|
149
|
+
command: exports.command,
|
|
150
|
+
describe: exports.describe,
|
|
151
|
+
handler: exports.handler,
|
|
152
|
+
builder: exports.builder,
|
|
153
|
+
deprecated: exports.deprecated,
|
|
154
|
+
};
|
|
155
|
+
exports.default = cloneAppCommand;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
|
|
2
|
+
import { MigrateAppOptions } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "migrate-app";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
export declare const deprecated = true;
|
|
6
|
+
export declare function handler(yargs: ArgumentsCamelCase<MigrateAppOptions>): Promise<void>;
|
|
7
|
+
export declare function builder(yargs: Argv): Argv<MigrateAppOptions>;
|
|
8
|
+
declare const migrateAppCommand: CommandModule<unknown, MigrateAppOptions>;
|
|
9
|
+
export default migrateAppCommand;
|