@hubspot/cli 7.2.3-experimental.0 → 7.2.4-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +0 -2
- package/commands/account/info.d.ts +1 -1
- package/commands/account/info.js +8 -5
- package/commands/auth.d.ts +9 -0
- package/commands/auth.js +89 -83
- package/commands/init.d.ts +11 -0
- package/commands/init.js +114 -100
- package/commands/list.d.ts +9 -0
- package/commands/list.js +63 -57
- package/commands/mv.d.ts +10 -0
- package/commands/mv.js +32 -32
- package/commands/open.d.ts +10 -0
- package/commands/open.js +37 -34
- package/commands/project/cloneApp.d.ts +1 -5
- package/commands/project/cloneApp.js +75 -78
- package/commands/project/create.js +2 -0
- package/commands/project/dev/deprecatedFlow.d.ts +5 -0
- package/commands/project/{dev.js → dev/deprecatedFlow.js} +14 -44
- package/commands/project/{dev.d.ts → dev/index.d.ts} +1 -3
- package/commands/project/dev/index.js +52 -0
- package/commands/project/dev/unifiedFlow.d.ts +5 -0
- package/commands/project/dev/unifiedFlow.js +112 -0
- package/commands/project/migrateApp.d.ts +1 -6
- package/commands/project/migrateApp.js +184 -17
- package/commands/project/upload.js +7 -2
- package/commands/remove.d.ts +9 -0
- package/commands/remove.js +25 -23
- package/lang/en.lyaml +19 -36
- package/lib/DevServerManagerV2.d.ts +34 -0
- package/lib/DevServerManagerV2.js +85 -0
- package/lib/LocalDevManager.js +1 -1
- package/lib/LocalDevManagerV2.d.ts +64 -0
- package/lib/LocalDevManagerV2.js +382 -0
- package/lib/commonOpts.d.ts +1 -0
- package/lib/commonOpts.js +30 -0
- package/lib/constants.d.ts +12 -0
- package/lib/constants.js +13 -1
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +6 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +5 -0
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +10 -0
- package/lib/localDev.d.ts +1 -1
- package/lib/localDev.js +2 -2
- package/lib/projects/structure.d.ts +4 -0
- package/lib/projects/structure.js +9 -0
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +2 -2
- package/lib/prompts/accountNamePrompt.d.ts +2 -3
- package/lib/prompts/createProjectPrompt.js +14 -12
- package/lib/prompts/personalAccessKeyPrompt.d.ts +4 -4
- package/lib/prompts/promptUtils.d.ts +3 -3
- package/lib/ui/index.d.ts +4 -4
- package/lib/ui/index.js +12 -15
- package/lib/ui/supportHyperlinks.js +2 -2
- package/lib/ui/supportsColor.js +2 -2
- package/lib/usageTracking.d.ts +1 -2
- package/lib/yargsUtils.d.ts +9 -0
- package/lib/yargsUtils.js +40 -0
- package/package.json +4 -4
- package/types/ProjectComponents.d.ts +38 -0
- package/types/ProjectComponents.js +3 -0
- package/types/Prompts.d.ts +2 -2
- package/types/Yargs.d.ts +1 -6
- package/commands/app/migrate.d.ts +0 -6
- package/commands/app/migrate.js +0 -80
- package/commands/app.d.ts +0 -4
- package/commands/app.js +0 -47
- package/lib/app/migrate.d.ts +0 -6
- package/lib/app/migrate.js +0 -277
- package/lib/hasFlag.d.ts +0 -1
- package/lib/hasFlag.js +0 -15
package/commands/list.js
CHANGED
|
@@ -1,37 +1,68 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
6
|
+
exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
11
|
+
const usageTracking_1 = require("../lib/usageTracking");
|
|
12
|
+
const filesystem_1 = require("../lib/filesystem");
|
|
13
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
|
+
const index_1 = require("../lib/errorHandlers/index");
|
|
15
|
+
const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
|
|
16
|
+
const constants_1 = require("../lib/constants");
|
|
17
|
+
const lang_1 = require("../lib/lang");
|
|
18
|
+
const exitCodes_1 = require("../lib/enums/exitCodes");
|
|
13
19
|
const i18nKey = 'commands.list';
|
|
14
|
-
|
|
20
|
+
function addColorToContents(fileOrFolder) {
|
|
21
|
+
if (!(0, filesystem_1.isPathFolder)(fileOrFolder)) {
|
|
22
|
+
return chalk_1.default.reset.cyan(fileOrFolder);
|
|
23
|
+
}
|
|
24
|
+
if (fileOrFolder === constants_1.HUBSPOT_FOLDER || fileOrFolder === constants_1.MARKETPLACE_FOLDER) {
|
|
25
|
+
return chalk_1.default.reset.bold.blue(fileOrFolder);
|
|
26
|
+
}
|
|
27
|
+
return chalk_1.default.reset.blue(fileOrFolder);
|
|
28
|
+
}
|
|
29
|
+
function sortContents(a, b) {
|
|
30
|
+
// Pin @hubspot folder to top
|
|
31
|
+
if (a === constants_1.HUBSPOT_FOLDER) {
|
|
32
|
+
return -1;
|
|
33
|
+
}
|
|
34
|
+
else if (b === constants_1.HUBSPOT_FOLDER) {
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
// Pin @marketplace folder to top
|
|
38
|
+
if (a === constants_1.MARKETPLACE_FOLDER) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
else if (b === constants_1.MARKETPLACE_FOLDER) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
return a.localeCompare(b);
|
|
45
|
+
}
|
|
15
46
|
exports.command = 'list [path]';
|
|
16
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
|
-
|
|
18
|
-
const { path, derivedAccountId } =
|
|
47
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
48
|
+
async function handler(args) {
|
|
49
|
+
const { path, derivedAccountId } = args;
|
|
19
50
|
const directoryPath = path || '/';
|
|
20
51
|
let contentsResp;
|
|
21
|
-
trackCommandUsage('list',
|
|
22
|
-
logger.debug(i18n(`${i18nKey}.gettingPathContents`, {
|
|
52
|
+
(0, usageTracking_1.trackCommandUsage)('list', undefined, derivedAccountId);
|
|
53
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.gettingPathContents`, {
|
|
23
54
|
path: directoryPath,
|
|
24
55
|
}));
|
|
25
56
|
try {
|
|
26
|
-
const { data } = await getDirectoryContentsByPath(derivedAccountId, directoryPath);
|
|
57
|
+
const { data } = await (0, fileMapper_1.getDirectoryContentsByPath)(derivedAccountId, directoryPath);
|
|
27
58
|
contentsResp = data;
|
|
28
59
|
}
|
|
29
60
|
catch (e) {
|
|
30
|
-
logError(e);
|
|
31
|
-
process.exit(EXIT_CODES.
|
|
61
|
+
(0, index_1.logError)(e);
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
32
63
|
}
|
|
33
64
|
if (!contentsResp.folder) {
|
|
34
|
-
logger.info(i18n(`${i18nKey}.noFilesFoundAtPath`, {
|
|
65
|
+
logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.noFilesFoundAtPath`, {
|
|
35
66
|
path: directoryPath,
|
|
36
67
|
}));
|
|
37
68
|
return;
|
|
@@ -41,7 +72,7 @@ exports.handler = async (options) => {
|
|
|
41
72
|
? ['@hubspot', ...contentsResp.children]
|
|
42
73
|
: contentsResp.children;
|
|
43
74
|
if (contents.length === 0) {
|
|
44
|
-
logger.info(i18n(`${i18nKey}.noFilesFoundAtPath`, {
|
|
75
|
+
logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.noFilesFoundAtPath`, {
|
|
45
76
|
path: directoryPath,
|
|
46
77
|
}));
|
|
47
78
|
return;
|
|
@@ -50,43 +81,18 @@ exports.handler = async (options) => {
|
|
|
50
81
|
.map(addColorToContents)
|
|
51
82
|
.sort(sortContents)
|
|
52
83
|
.join('\n');
|
|
53
|
-
logger.log(folderContentsOutput);
|
|
54
|
-
|
|
55
|
-
|
|
84
|
+
logger_1.logger.log(folderContentsOutput);
|
|
85
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
86
|
+
}
|
|
87
|
+
function builder(yargs) {
|
|
88
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
89
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
90
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
91
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
56
92
|
yargs.positional('path', {
|
|
57
|
-
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
93
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.path.describe`),
|
|
58
94
|
type: 'string',
|
|
59
95
|
});
|
|
60
|
-
yargs.example([['$0 list'], ['$0 list /'], ['$0 list
|
|
61
|
-
addConfigOptions(yargs);
|
|
62
|
-
addAccountOptions(yargs);
|
|
63
|
-
addUseEnvironmentOptions(yargs);
|
|
64
|
-
addGlobalOptions(yargs);
|
|
96
|
+
yargs.example([['$0 list'], ['$0 list /'], ['$0 list my-modules']]);
|
|
65
97
|
return yargs;
|
|
66
|
-
}
|
|
67
|
-
const addColorToContents = fileOrFolder => {
|
|
68
|
-
if (!isPathFolder(fileOrFolder)) {
|
|
69
|
-
return chalk.reset.cyan(fileOrFolder);
|
|
70
|
-
}
|
|
71
|
-
if (fileOrFolder === HUBSPOT_FOLDER || fileOrFolder === MARKETPLACE_FOLDER) {
|
|
72
|
-
return chalk.reset.bold.blue(fileOrFolder);
|
|
73
|
-
}
|
|
74
|
-
return chalk.reset.blue(fileOrFolder);
|
|
75
|
-
};
|
|
76
|
-
const sortContents = (a, b) => {
|
|
77
|
-
// Pin @hubspot folder to top
|
|
78
|
-
if (a === HUBSPOT_FOLDER) {
|
|
79
|
-
return -1;
|
|
80
|
-
}
|
|
81
|
-
else if (b === HUBSPOT_FOLDER) {
|
|
82
|
-
return 1;
|
|
83
|
-
}
|
|
84
|
-
// Pin @marketplace folder to top
|
|
85
|
-
if (a === MARKETPLACE_FOLDER) {
|
|
86
|
-
return -1;
|
|
87
|
-
}
|
|
88
|
-
else if (b === MARKETPLACE_FOLDER) {
|
|
89
|
-
return 1;
|
|
90
|
-
}
|
|
91
|
-
return a.localeCompare(b);
|
|
92
|
-
};
|
|
98
|
+
}
|
package/commands/mv.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, EnvironmentArgs } from '../types/Yargs';
|
|
3
|
+
export declare const command = "mv <srcPath> <destPath>";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
type MvArgs = CommonArgs & ConfigArgs & EnvironmentArgs & {
|
|
6
|
+
srcPath: string;
|
|
7
|
+
destPath: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function handler(args: ArgumentsCamelCase<MvArgs>): Promise<void>;
|
|
10
|
+
export declare function builder(yargs: Argv): Argv<MvArgs>;
|
|
1
11
|
export {};
|
package/commands/mv.js
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const fileMapper_1 = require("@hubspot/local-dev-lib/api/fileMapper");
|
|
8
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
9
|
+
const index_2 = require("../lib/errorHandlers/index");
|
|
10
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
11
|
+
const usageTracking_1 = require("../lib/usageTracking");
|
|
12
|
+
const filesystem_1 = require("../lib/filesystem");
|
|
13
|
+
const lang_1 = require("../lib/lang");
|
|
14
|
+
const ui_1 = require("../lib/ui");
|
|
13
15
|
const i18nKey = 'commands.mv';
|
|
14
|
-
|
|
15
|
-
if (!isPathFolder(srcPath)) {
|
|
16
|
+
function getCorrectedDestPath(srcPath, destPath) {
|
|
17
|
+
if (!(0, filesystem_1.isPathFolder)(srcPath)) {
|
|
16
18
|
return destPath;
|
|
17
19
|
}
|
|
18
20
|
// Makes sure that nested folders are moved independently
|
|
19
21
|
return `${destPath}/${srcPath.split('/').pop()}`;
|
|
20
|
-
}
|
|
22
|
+
}
|
|
21
23
|
exports.command = 'mv <srcPath> <destPath>';
|
|
22
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
23
|
-
|
|
24
|
-
const { srcPath, destPath, derivedAccountId } =
|
|
25
|
-
trackCommandUsage('mv',
|
|
24
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
25
|
+
async function handler(args) {
|
|
26
|
+
const { srcPath, destPath, derivedAccountId } = args;
|
|
27
|
+
(0, usageTracking_1.trackCommandUsage)('mv', undefined, derivedAccountId);
|
|
26
28
|
try {
|
|
27
|
-
await moveFile(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
|
|
28
|
-
logger.success(i18n(`${i18nKey}.move`, {
|
|
29
|
+
await (0, fileMapper_1.moveFile)(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
|
|
30
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.move`, {
|
|
29
31
|
accountId: derivedAccountId,
|
|
30
32
|
destPath,
|
|
31
33
|
srcPath,
|
|
32
34
|
}));
|
|
33
35
|
}
|
|
34
36
|
catch (error) {
|
|
35
|
-
logger.error(i18n(`${i18nKey}.errors.moveFailed`, {
|
|
37
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.moveFailed`, {
|
|
36
38
|
accountId: derivedAccountId,
|
|
37
39
|
destPath,
|
|
38
40
|
srcPath,
|
|
39
41
|
}));
|
|
40
|
-
if (isSpecifiedError(error, { statusCode: 409 })) {
|
|
41
|
-
logger.error(i18n(`${i18nKey}.errors.sourcePathExists`, {
|
|
42
|
+
if ((0, index_1.isSpecifiedError)(error, { statusCode: 409 })) {
|
|
43
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.sourcePathExists`, {
|
|
42
44
|
destPath,
|
|
43
45
|
srcPath,
|
|
44
46
|
}));
|
|
45
47
|
}
|
|
46
48
|
else {
|
|
47
|
-
logError(error, new ApiErrorContext({
|
|
49
|
+
(0, index_2.logError)(error, new index_2.ApiErrorContext({
|
|
48
50
|
accountId: derivedAccountId,
|
|
49
|
-
srcPath,
|
|
50
|
-
destPath,
|
|
51
51
|
}));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
54
|
+
}
|
|
55
|
+
function builder(yargs) {
|
|
56
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
57
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
58
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
59
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
56
60
|
yargs.positional('srcPath', {
|
|
57
61
|
describe: 'Remote hubspot path',
|
|
58
62
|
type: 'string',
|
|
@@ -61,9 +65,5 @@ exports.builder = yargs => {
|
|
|
61
65
|
describe: 'Remote hubspot path',
|
|
62
66
|
type: 'string',
|
|
63
67
|
});
|
|
64
|
-
addConfigOptions(yargs);
|
|
65
|
-
addAccountOptions(yargs);
|
|
66
|
-
addUseEnvironmentOptions(yargs);
|
|
67
|
-
addGlobalOptions(yargs);
|
|
68
68
|
return yargs;
|
|
69
|
-
}
|
|
69
|
+
}
|
package/commands/open.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, EnvironmentArgs, AccountArgs } from '../types/Yargs';
|
|
3
|
+
export declare const command = "open [shortcut]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type OpenArgs = CommonArgs & ConfigArgs & EnvironmentArgs & AccountArgs & {
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
list?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function handler(args: ArgumentsCamelCase<OpenArgs>): Promise<void>;
|
|
10
|
+
export declare function builder(yargs: Argv): Argv<OpenArgs>;
|
|
1
11
|
export {};
|
package/commands/open.js
CHANGED
|
@@ -1,50 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
7
|
+
const usageTracking_1 = require("../lib/usageTracking");
|
|
8
|
+
const links_1 = require("../lib/links");
|
|
9
|
+
const promptUtils_1 = require("../lib/prompts/promptUtils");
|
|
10
|
+
const lang_1 = require("../lib/lang");
|
|
4
11
|
const exitCodes_1 = require("../lib/enums/exitCodes");
|
|
5
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, addGlobalOptions, } = require('../lib/commonOpts');
|
|
6
|
-
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
7
|
-
const { logSiteLinks, getSiteLinksAsArray, openLink } = require('../lib/links');
|
|
8
|
-
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
9
|
-
const { i18n } = require('../lib/lang');
|
|
10
12
|
const i18nKey = 'commands.open';
|
|
11
13
|
const separator = ' => ';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]);
|
|
14
|
+
async function createListPrompt(accountId) {
|
|
15
|
+
return (0, promptUtils_1.promptUser)([
|
|
16
|
+
{
|
|
17
|
+
type: 'rawlist',
|
|
18
|
+
name: 'open',
|
|
19
|
+
pageSize: 20,
|
|
20
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectLink`),
|
|
21
|
+
choices: (0, links_1.getSiteLinksAsArray)(accountId).map(l => `${l.shortcut}${separator}${l.url}`),
|
|
22
|
+
filter: val => val.split(separator)[0],
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
23
26
|
exports.command = 'open [shortcut]';
|
|
24
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
25
|
-
|
|
26
|
-
const { shortcut, list, derivedAccountId } =
|
|
27
|
-
trackCommandUsage('open',
|
|
27
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
28
|
+
async function handler(args) {
|
|
29
|
+
const { shortcut, list, derivedAccountId } = args;
|
|
30
|
+
(0, usageTracking_1.trackCommandUsage)('open', undefined, derivedAccountId);
|
|
28
31
|
if (shortcut === undefined && !list) {
|
|
29
32
|
const choice = await createListPrompt(derivedAccountId);
|
|
30
|
-
openLink(derivedAccountId, choice.open);
|
|
33
|
+
(0, links_1.openLink)(derivedAccountId, choice.open);
|
|
31
34
|
}
|
|
32
35
|
else if (list) {
|
|
33
|
-
logSiteLinks(derivedAccountId);
|
|
36
|
+
(0, links_1.logSiteLinks)(derivedAccountId);
|
|
34
37
|
}
|
|
35
|
-
else {
|
|
36
|
-
openLink(derivedAccountId, shortcut);
|
|
38
|
+
else if (shortcut) {
|
|
39
|
+
(0, links_1.openLink)(derivedAccountId, shortcut);
|
|
37
40
|
}
|
|
38
41
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
39
|
-
}
|
|
40
|
-
|
|
42
|
+
}
|
|
43
|
+
function builder(yargs) {
|
|
44
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
45
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
46
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
47
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
41
48
|
yargs.positional('[shortcut]', {
|
|
42
|
-
describe: i18n(`${i18nKey}.positionals.shortcut.describe`),
|
|
49
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.shortcut.describe`),
|
|
43
50
|
type: 'string',
|
|
44
51
|
});
|
|
45
52
|
yargs.option('list', {
|
|
46
53
|
alias: 'l',
|
|
47
|
-
describe: i18n(`${i18nKey}.options.list.describe`),
|
|
54
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.list.describe`),
|
|
48
55
|
type: 'boolean',
|
|
49
56
|
});
|
|
50
57
|
yargs.example([
|
|
@@ -54,9 +61,5 @@ exports.builder = yargs => {
|
|
|
54
61
|
['$0 open settings/navigation'],
|
|
55
62
|
['$0 open sn'],
|
|
56
63
|
]);
|
|
57
|
-
addConfigOptions(yargs);
|
|
58
|
-
addAccountOptions(yargs);
|
|
59
|
-
addUseEnvironmentOptions(yargs);
|
|
60
|
-
addGlobalOptions(yargs);
|
|
61
64
|
return yargs;
|
|
62
|
-
}
|
|
65
|
+
}
|
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
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
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const migrate_1 = require("../../lib/app/migrate");
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
7
|
+
const { trackCommandUsage, trackCommandMetadataUsage, } = require('../../lib/usageTracking');
|
|
8
|
+
const { i18n } = require('../../lib/lang');
|
|
9
|
+
const { selectPublicAppPrompt, } = require('../../lib/prompts/selectPublicAppPrompt');
|
|
10
|
+
const { createProjectPrompt, } = require('../../lib/prompts/createProjectPrompt');
|
|
11
|
+
const { poll } = require('../../lib/polling');
|
|
12
|
+
const { uiBetaTag, uiLine, uiCommandReference, uiAccountDescription, } = require('../../lib/ui');
|
|
13
|
+
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
14
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
15
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
16
|
+
const { isAppDeveloperAccount } = require('../../lib/accountTypes');
|
|
17
|
+
const { writeProjectConfig } = require('../../lib/projects');
|
|
18
|
+
const { PROJECT_CONFIG_FILE } = require('../../lib/constants');
|
|
19
|
+
const { cloneApp, checkCloneStatus, downloadClonedProject, } = require('@hubspot/local-dev-lib/api/projects');
|
|
20
|
+
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
|
|
21
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
22
|
+
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
23
|
+
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
|
|
28
24
|
const i18nKey = 'commands.project.subcommands.cloneApp';
|
|
29
25
|
exports.command = 'clone-app';
|
|
30
|
-
exports.describe = (
|
|
26
|
+
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
31
27
|
exports.handler = async (options) => {
|
|
32
28
|
const { derivedAccountId } = options;
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
if (!accountConfig) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
const accountConfig = getAccountConfig(derivedAccountId);
|
|
30
|
+
const accountName = uiAccountDescription(derivedAccountId);
|
|
31
|
+
trackCommandUsage('clone-app', {}, derivedAccountId);
|
|
32
|
+
if (!isAppDeveloperAccount(accountConfig)) {
|
|
33
|
+
uiLine();
|
|
34
|
+
logger.error(i18n(`${i18nKey}.errors.invalidAccountTypeTitle`));
|
|
35
|
+
logger.log(i18n(`${i18nKey}.errors.invalidAccountTypeDescription`, {
|
|
36
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
37
|
+
authCommand: uiCommandReference('hs auth'),
|
|
38
|
+
}));
|
|
39
|
+
uiLine();
|
|
40
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
42
41
|
}
|
|
43
42
|
let appId;
|
|
44
43
|
let projectName;
|
|
@@ -46,98 +45,96 @@ exports.handler = async (options) => {
|
|
|
46
45
|
try {
|
|
47
46
|
appId = options.appId;
|
|
48
47
|
if (!appId) {
|
|
49
|
-
const appIdResponse = await
|
|
48
|
+
const appIdResponse = await selectPublicAppPrompt({
|
|
50
49
|
accountId: derivedAccountId,
|
|
51
50
|
accountName,
|
|
51
|
+
options,
|
|
52
52
|
isMigratingApp: false,
|
|
53
53
|
});
|
|
54
54
|
appId = appIdResponse.appId;
|
|
55
55
|
}
|
|
56
|
-
const createProjectPromptResponse = await
|
|
56
|
+
const createProjectPromptResponse = await createProjectPrompt(options);
|
|
57
57
|
projectName = createProjectPromptResponse.name;
|
|
58
58
|
projectDest = createProjectPromptResponse.dest;
|
|
59
59
|
}
|
|
60
60
|
catch (error) {
|
|
61
|
-
|
|
62
|
-
process.exit(
|
|
61
|
+
logError(error, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
62
|
+
process.exit(EXIT_CODES.ERROR);
|
|
63
63
|
}
|
|
64
|
-
await
|
|
64
|
+
await trackCommandMetadataUsage('clone-app', { status: 'STARTED' }, derivedAccountId);
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
text:
|
|
66
|
+
SpinniesManager.init();
|
|
67
|
+
SpinniesManager.add('cloneApp', {
|
|
68
|
+
text: i18n(`${i18nKey}.cloneStatus.inProgress`),
|
|
69
69
|
});
|
|
70
|
-
const { data: { exportId }, } = await
|
|
71
|
-
const { status } = await
|
|
70
|
+
const { data: { exportId }, } = await cloneApp(derivedAccountId, appId);
|
|
71
|
+
const { status } = await poll(() => checkCloneStatus(derivedAccountId, exportId));
|
|
72
72
|
if (status === 'SUCCESS') {
|
|
73
73
|
// Ensure correct project folder structure exists
|
|
74
|
-
const baseDestPath =
|
|
75
|
-
const absoluteDestPath =
|
|
76
|
-
|
|
74
|
+
const baseDestPath = path.resolve(getCwd(), projectDest);
|
|
75
|
+
const absoluteDestPath = path.resolve(baseDestPath, 'src', 'app');
|
|
76
|
+
fs.mkdirSync(absoluteDestPath, { recursive: true });
|
|
77
77
|
// Extract zipped app files and place them in correct directory
|
|
78
|
-
const { data: zippedApp } = await
|
|
79
|
-
await
|
|
78
|
+
const { data: zippedApp } = await downloadClonedProject(derivedAccountId, exportId);
|
|
79
|
+
await extractZipArchive(zippedApp, sanitizeFileName(projectName), absoluteDestPath, {
|
|
80
80
|
includesRootDir: true,
|
|
81
81
|
hideLogs: true,
|
|
82
82
|
});
|
|
83
83
|
// Create hsproject.json file
|
|
84
|
-
const configPath =
|
|
84
|
+
const configPath = path.join(baseDestPath, PROJECT_CONFIG_FILE);
|
|
85
85
|
const configContent = {
|
|
86
86
|
name: projectName,
|
|
87
87
|
srcDir: 'src',
|
|
88
88
|
platformVersion: '2023.2',
|
|
89
89
|
};
|
|
90
|
-
const success =
|
|
91
|
-
|
|
92
|
-
text:
|
|
90
|
+
const success = writeProjectConfig(configPath, configContent);
|
|
91
|
+
SpinniesManager.succeed('cloneApp', {
|
|
92
|
+
text: i18n(`${i18nKey}.cloneStatus.done`),
|
|
93
93
|
succeedColor: 'white',
|
|
94
94
|
});
|
|
95
95
|
if (!success) {
|
|
96
|
-
|
|
96
|
+
logger.error(i18n(`${i18nKey}.errors.couldNotWriteConfigPath`), configPath);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
process.exit(
|
|
98
|
+
logger.log('');
|
|
99
|
+
uiLine();
|
|
100
|
+
logger.success(i18n(`${i18nKey}.cloneStatus.success`, { dest }));
|
|
101
|
+
logger.log('');
|
|
102
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
106
|
-
await
|
|
107
|
-
|
|
108
|
-
text:
|
|
106
|
+
await trackCommandMetadataUsage('clone-app', { status: 'FAILURE' }, derivedAccountId);
|
|
107
|
+
SpinniesManager.fail('cloneApp', {
|
|
108
|
+
text: i18n(`${i18nKey}.cloneStatus.failure`),
|
|
109
109
|
failColor: 'white',
|
|
110
110
|
});
|
|
111
111
|
// Migrations endpoints return a response object with an errors property. The errors property contains an array of errors.
|
|
112
|
-
if (error &&
|
|
113
|
-
|
|
114
|
-
'errors' in error &&
|
|
115
|
-
Array.isArray(error.errors)) {
|
|
116
|
-
error.errors.forEach(e => (0, errorHandlers_1.logError)(e, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId })));
|
|
112
|
+
if (error.errors && Array.isArray(error.errors)) {
|
|
113
|
+
error.errors.forEach(e => logError(e, new ApiErrorContext({ accountId: derivedAccountId })));
|
|
117
114
|
}
|
|
118
115
|
else {
|
|
119
|
-
|
|
116
|
+
logError(error, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
|
-
await
|
|
123
|
-
process.exit(
|
|
119
|
+
await trackCommandMetadataUsage('clone-app', { status: 'SUCCESS' }, derivedAccountId);
|
|
120
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
124
121
|
};
|
|
125
|
-
exports.builder =
|
|
122
|
+
exports.builder = yargs => {
|
|
126
123
|
yargs.options({
|
|
127
124
|
dest: {
|
|
128
|
-
describe:
|
|
125
|
+
describe: i18n(`${i18nKey}.options.dest.describe`),
|
|
129
126
|
type: 'string',
|
|
130
127
|
},
|
|
131
128
|
'app-id': {
|
|
132
|
-
describe:
|
|
129
|
+
describe: i18n(`${i18nKey}.options.appId.describe`),
|
|
133
130
|
type: 'number',
|
|
134
131
|
},
|
|
135
132
|
});
|
|
136
133
|
yargs.example([
|
|
137
|
-
['$0 project clone-app',
|
|
134
|
+
['$0 project clone-app', i18n(`${i18nKey}.examples.default`)],
|
|
138
135
|
]);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
addConfigOptions(yargs);
|
|
137
|
+
addAccountOptions(yargs);
|
|
138
|
+
addUseEnvironmentOptions(yargs);
|
|
142
139
|
return yargs;
|
|
143
140
|
};
|
|
@@ -84,6 +84,8 @@ exports.handler = async (options) => {
|
|
|
84
84
|
logger.log('');
|
|
85
85
|
logger.log(chalk.bold(i18n(`${i18nKey}.logs.welcomeMessage`)));
|
|
86
86
|
uiFeatureHighlight([
|
|
87
|
+
'projectCommandTip',
|
|
88
|
+
'projectUploadCommand',
|
|
87
89
|
'projectDevCommand',
|
|
88
90
|
'projectHelpCommand',
|
|
89
91
|
'feedbackCommand',
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
3
|
+
import { ProjectConfig } from '../../../types/Projects';
|
|
4
|
+
import { ProjectDevArgs } from '../../../types/Yargs';
|
|
5
|
+
export declare function deprecatedProjectDevFlow(args: ArgumentsCamelCase<ProjectDevArgs>, accountConfig: CLIAccount, projectConfig: ProjectConfig, projectDir: string): Promise<void>;
|