@hubspot/cli 7.0.14-experimental.0 → 7.0.15-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/commands/filemanager/fetch.d.ts +12 -0
- package/commands/filemanager/fetch.js +33 -30
- package/commands/filemanager/upload.d.ts +11 -0
- package/commands/filemanager/upload.js +53 -47
- package/commands/filemanager.d.ts +4 -1
- package/commands/filemanager.js +41 -7
- package/commands/project/dev.d.ts +7 -0
- package/commands/project/dev.js +96 -75
- package/commands/project/upload.js +7 -2
- package/commands/sandbox/create.d.ts +12 -0
- package/commands/sandbox/create.js +90 -72
- package/commands/sandbox/delete.d.ts +11 -0
- package/commands/sandbox/delete.js +112 -95
- package/commands/sandbox.d.ts +4 -1
- package/commands/sandbox.js +44 -10
- package/lang/en.lyaml +9 -4
- package/lib/LocalDevManager.d.ts +2 -2
- package/lib/buildAccount.d.ts +2 -3
- package/lib/localDev.d.ts +2 -1
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +2 -2
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -2
- package/lib/prompts/sandboxesPrompt.d.ts +3 -2
- package/lib/prompts/sandboxesPrompt.js +1 -1
- package/lib/sandboxSync.js +6 -2
- package/lib/sandboxes.d.ts +2 -5
- package/lib/testUtils.d.ts +12 -0
- package/lib/testUtils.js +10 -0
- package/lib/ui/index.d.ts +2 -2
- package/lib/ui/index.js +1 -0
- package/package.json +2 -2
- package/types/Prompts.d.ts +7 -0
- package/types/Sandboxes.d.ts +2 -0
- package/types/Yargs.d.ts +7 -0
|
@@ -1 +1,13 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, OverwriteArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "fetch <src> [dest]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type CombinedArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & OverwriteArgs;
|
|
6
|
+
type FileManagerFetchArgs = CombinedArgs & {
|
|
7
|
+
src: string;
|
|
8
|
+
dest: string;
|
|
9
|
+
includeArchived?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function handler(args: ArgumentsCamelCase<FileManagerFetchArgs>): Promise<void>;
|
|
12
|
+
export declare function builder(yargs: Argv): Argv<FileManagerFetchArgs>;
|
|
1
13
|
export {};
|
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const fileManager_1 = require("@hubspot/local-dev-lib/fileManager");
|
|
7
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
+
const filesystem_1 = require("../../lib/filesystem");
|
|
9
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
11
|
+
const lang_1 = require("../../lib/lang");
|
|
12
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
13
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
10
14
|
const i18nKey = 'commands.filemanager.subcommands.fetch';
|
|
11
|
-
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
12
|
-
const { logError } = require('../../lib/errorHandlers/index');
|
|
13
15
|
exports.command = 'fetch <src> [dest]';
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
|
|
16
|
-
const { src, includeArchived, derivedAccountId, overwrite } =
|
|
16
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
17
|
+
async function handler(args) {
|
|
18
|
+
const { src, includeArchived, derivedAccountId, overwrite } = args;
|
|
17
19
|
if (typeof src !== 'string') {
|
|
18
|
-
logger.error(i18n(`${i18nKey}.errors.sourceRequired`));
|
|
19
|
-
process.exit(EXIT_CODES.ERROR);
|
|
20
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.sourceRequired`));
|
|
21
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
20
22
|
}
|
|
21
|
-
const dest = resolveLocalPath(
|
|
22
|
-
trackCommandUsage('filemanager-fetch',
|
|
23
|
+
const dest = (0, filesystem_1.resolveLocalPath)(args.dest);
|
|
24
|
+
(0, usageTracking_1.trackCommandUsage)('filemanager-fetch', {}, derivedAccountId);
|
|
23
25
|
try {
|
|
24
26
|
// Fetch and write file/folder.
|
|
25
|
-
await downloadFileOrFolder(derivedAccountId, src, dest, overwrite, includeArchived || false);
|
|
27
|
+
await (0, fileManager_1.downloadFileOrFolder)(derivedAccountId, src, dest, overwrite, includeArchived || false);
|
|
26
28
|
}
|
|
27
29
|
catch (err) {
|
|
28
|
-
logError(err);
|
|
29
|
-
process.exit(EXIT_CODES.ERROR);
|
|
30
|
+
(0, index_1.logError)(err);
|
|
31
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
32
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
addGlobalOptions(yargs);
|
|
34
|
-
addConfigOptions(yargs);
|
|
35
|
-
addAccountOptions(yargs);
|
|
36
|
-
addOverwriteOptions(yargs);
|
|
37
|
-
addUseEnvironmentOptions(yargs);
|
|
33
|
+
}
|
|
34
|
+
function builder(yargs) {
|
|
35
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
36
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
37
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
38
|
+
(0, commonOpts_1.addOverwriteOptions)(yargs);
|
|
39
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
38
40
|
yargs.positional('src', {
|
|
39
|
-
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
41
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.src.describe`),
|
|
40
42
|
type: 'string',
|
|
41
43
|
});
|
|
42
44
|
yargs.positional('dest', {
|
|
43
|
-
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
45
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.dest.describe`),
|
|
44
46
|
type: 'string',
|
|
45
47
|
});
|
|
46
48
|
yargs.option('include-archived', {
|
|
47
49
|
alias: ['i'],
|
|
48
|
-
describe: i18n(`${i18nKey}.options.includeArchived.describe`),
|
|
50
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.includeArchived.describe`),
|
|
49
51
|
type: 'boolean',
|
|
50
52
|
});
|
|
51
|
-
|
|
53
|
+
return yargs;
|
|
54
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "upload <src> <dest>";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type CombinedArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs;
|
|
6
|
+
type FileManagerUploadArgs = CombinedArgs & {
|
|
7
|
+
src: string;
|
|
8
|
+
dest: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function handler(args: ArgumentsCamelCase<FileManagerUploadArgs>): Promise<void>;
|
|
11
|
+
export declare function builder(yargs: Argv): Argv<FileManagerUploadArgs>;
|
|
1
12
|
export {};
|
|
@@ -1,73 +1,78 @@
|
|
|
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
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
6
|
+
exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fileManager_1 = require("@hubspot/local-dev-lib/fileManager");
|
|
12
|
+
const fileManager_2 = require("@hubspot/local-dev-lib/api/fileManager");
|
|
13
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
14
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
15
|
+
const modules_1 = require("@hubspot/local-dev-lib/cms/modules");
|
|
16
|
+
const ignoreRules_1 = require("@hubspot/local-dev-lib/ignoreRules");
|
|
17
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
18
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
19
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
20
|
+
const lang_1 = require("../../lib/lang");
|
|
21
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
16
22
|
const i18nKey = 'commands.filemanager.subcommands.upload';
|
|
17
|
-
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
18
23
|
exports.command = 'upload <src> <dest>';
|
|
19
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
20
|
-
|
|
21
|
-
const { src, dest, derivedAccountId } =
|
|
22
|
-
const absoluteSrcPath =
|
|
24
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
25
|
+
async function handler(args) {
|
|
26
|
+
const { src, dest, derivedAccountId } = args;
|
|
27
|
+
const absoluteSrcPath = path_1.default.resolve((0, path_2.getCwd)(), src);
|
|
23
28
|
let stats;
|
|
24
29
|
try {
|
|
25
|
-
stats =
|
|
30
|
+
stats = fs_1.default.statSync(absoluteSrcPath);
|
|
26
31
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
27
|
-
logger.error(i18n(`${i18nKey}.errors.invalidPath`, {
|
|
32
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
|
|
28
33
|
path: src,
|
|
29
34
|
}));
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
catch (e) {
|
|
34
|
-
logger.error(i18n(`${i18nKey}.errors.invalidPath`, {
|
|
39
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
|
|
35
40
|
path: src,
|
|
36
41
|
}));
|
|
37
42
|
return;
|
|
38
43
|
}
|
|
39
44
|
if (!dest) {
|
|
40
|
-
logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
|
|
45
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.destinationRequired`));
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
|
-
const normalizedDest = convertToUnixPath(dest);
|
|
44
|
-
trackCommandUsage('filemanager-upload', { type: stats.isFile() ? 'file' : 'folder' }, derivedAccountId);
|
|
45
|
-
const srcDestIssues = await validateSrcAndDestPaths({ isLocal: true, path: src }, { isHubSpot: true, path: dest });
|
|
48
|
+
const normalizedDest = (0, path_2.convertToUnixPath)(dest);
|
|
49
|
+
(0, usageTracking_1.trackCommandUsage)('filemanager-upload', { type: stats.isFile() ? 'file' : 'folder' }, derivedAccountId);
|
|
50
|
+
const srcDestIssues = await (0, modules_1.validateSrcAndDestPaths)({ isLocal: true, path: src }, { isHubSpot: true, path: dest });
|
|
46
51
|
if (srcDestIssues.length) {
|
|
47
|
-
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
48
|
-
process.exit(EXIT_CODES.ERROR);
|
|
52
|
+
srcDestIssues.forEach(({ message }) => logger_1.logger.error(message));
|
|
53
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
49
54
|
}
|
|
50
55
|
if (stats.isFile()) {
|
|
51
|
-
if (shouldIgnoreFile(absoluteSrcPath)) {
|
|
52
|
-
logger.error(i18n(`${i18nKey}.errors.fileIgnored`, {
|
|
56
|
+
if ((0, ignoreRules_1.shouldIgnoreFile)(absoluteSrcPath)) {
|
|
57
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.fileIgnored`, {
|
|
53
58
|
path: src,
|
|
54
59
|
}));
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
|
-
uploadFile(derivedAccountId, absoluteSrcPath, normalizedDest)
|
|
62
|
+
(0, fileManager_2.uploadFile)(derivedAccountId, absoluteSrcPath, normalizedDest)
|
|
58
63
|
.then(() => {
|
|
59
|
-
logger.success(i18n(`${i18nKey}.success.upload`, {
|
|
64
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.upload`, {
|
|
60
65
|
accountId: derivedAccountId,
|
|
61
66
|
dest: normalizedDest,
|
|
62
67
|
src,
|
|
63
68
|
}));
|
|
64
69
|
})
|
|
65
70
|
.catch(error => {
|
|
66
|
-
logger.error(i18n(`${i18nKey}.errors.upload`, {
|
|
71
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.upload`, {
|
|
67
72
|
dest: normalizedDest,
|
|
68
73
|
src,
|
|
69
74
|
}));
|
|
70
|
-
logError(error, new ApiErrorContext({
|
|
75
|
+
(0, index_1.logError)(error, new index_1.ApiErrorContext({
|
|
71
76
|
accountId: derivedAccountId,
|
|
72
77
|
request: normalizedDest,
|
|
73
78
|
payload: src,
|
|
@@ -75,36 +80,37 @@ exports.handler = async (options) => {
|
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
else {
|
|
78
|
-
logger.log(i18n(`${i18nKey}.logs.uploading`, {
|
|
83
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.uploading`, {
|
|
79
84
|
accountId: derivedAccountId,
|
|
80
85
|
dest,
|
|
81
86
|
src,
|
|
82
87
|
}));
|
|
83
|
-
uploadFolder(derivedAccountId, absoluteSrcPath, dest)
|
|
88
|
+
(0, fileManager_1.uploadFolder)(derivedAccountId, absoluteSrcPath, dest)
|
|
84
89
|
.then(() => {
|
|
85
|
-
logger.success(i18n(`${i18nKey}.success.uploadComplete`, {
|
|
90
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.uploadComplete`, {
|
|
86
91
|
dest,
|
|
87
92
|
}));
|
|
88
93
|
})
|
|
89
94
|
.catch(error => {
|
|
90
|
-
logger.error(i18n(`${i18nKey}.errors.uploadingFailed`));
|
|
91
|
-
logError(error, {
|
|
95
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.uploadingFailed`));
|
|
96
|
+
(0, index_1.logError)(error, {
|
|
92
97
|
accountId: derivedAccountId,
|
|
93
98
|
});
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
addGlobalOptions(yargs);
|
|
99
|
-
addConfigOptions(yargs);
|
|
100
|
-
addAccountOptions(yargs);
|
|
101
|
-
addUseEnvironmentOptions(yargs);
|
|
101
|
+
}
|
|
102
|
+
function builder(yargs) {
|
|
103
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
104
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
105
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
106
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
102
107
|
yargs.positional('src', {
|
|
103
|
-
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
108
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.src.describe`),
|
|
104
109
|
type: 'string',
|
|
105
110
|
});
|
|
106
111
|
yargs.positional('dest', {
|
|
107
|
-
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
112
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.dest.describe`),
|
|
108
113
|
type: 'string',
|
|
109
114
|
});
|
|
110
|
-
|
|
115
|
+
return yargs;
|
|
116
|
+
}
|
package/commands/filemanager.js
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
36
|
+
exports.describe = exports.command = void 0;
|
|
37
|
+
exports.builder = builder;
|
|
38
|
+
const upload = __importStar(require("./filemanager/upload"));
|
|
39
|
+
const fetch = __importStar(require("./filemanager/fetch"));
|
|
40
|
+
const lang_1 = require("../lib/lang");
|
|
7
41
|
const i18nKey = 'commands.filemanager';
|
|
8
42
|
exports.command = 'filemanager';
|
|
9
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
10
|
-
|
|
43
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
44
|
+
function builder(yargs) {
|
|
11
45
|
yargs.command(upload).command(fetch).demandCommand(1, '');
|
|
12
46
|
return yargs;
|
|
13
|
-
}
|
|
47
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, EnvironmentArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "dev";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs;
|
|
6
|
+
export declare function handler(args: ArgumentsCamelCase<ProjectDevArgs>): Promise<void>;
|
|
7
|
+
export declare function builder(yargs: Argv): Argv<ProjectDevArgs>;
|
|
1
8
|
export {};
|
package/commands/project/dev.js
CHANGED
|
@@ -1,57 +1,75 @@
|
|
|
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
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
6
|
+
exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
11
|
+
const process_1 = require("../../lib/process");
|
|
12
|
+
const lang_1 = require("../../lib/lang");
|
|
13
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
15
|
+
const projects_1 = require("../../lib/projects");
|
|
16
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
17
|
+
const ui_1 = require("../../lib/ui");
|
|
18
|
+
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
19
|
+
const LocalDevManager_1 = __importDefault(require("../../lib/LocalDevManager"));
|
|
20
|
+
const accountTypes_1 = require("../../lib/accountTypes");
|
|
21
|
+
const environment_1 = require("@hubspot/local-dev-lib/environment");
|
|
22
|
+
const Projects_1 = require("../../types/Projects");
|
|
23
|
+
const structure_1 = require("../../lib/projects/structure");
|
|
24
|
+
const localDev_1 = require("../../lib/localDev");
|
|
20
25
|
const i18nKey = 'commands.project.subcommands.dev';
|
|
21
26
|
exports.command = 'dev';
|
|
22
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
23
|
-
|
|
24
|
-
const { derivedAccountId, providedAccountId } =
|
|
25
|
-
const accountConfig = getAccountConfig(derivedAccountId);
|
|
26
|
-
const env = getValidEnv(getEnv(derivedAccountId));
|
|
27
|
-
trackCommandUsage('project-dev',
|
|
28
|
-
const { projectConfig, projectDir } = await getProjectConfig();
|
|
29
|
-
uiBetaTag(i18n(`${i18nKey}.logs.betaMessage`));
|
|
30
|
-
logger.log(uiLink(i18n(`${i18nKey}.logs.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
31
|
-
if (!projectConfig) {
|
|
32
|
-
logger.error(i18n(`${i18nKey}.errors.noProjectConfig
|
|
33
|
-
|
|
27
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
28
|
+
async function handler(args) {
|
|
29
|
+
const { derivedAccountId, providedAccountId } = args;
|
|
30
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
31
|
+
const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
|
|
32
|
+
(0, usageTracking_1.trackCommandUsage)('project-dev', {}, derivedAccountId);
|
|
33
|
+
const { projectConfig, projectDir } = await (0, projects_1.getProjectConfig)();
|
|
34
|
+
(0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.logs.betaMessage`));
|
|
35
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.logs.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
36
|
+
if (!projectConfig || !projectDir) {
|
|
37
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectConfig`, {
|
|
38
|
+
accountId: derivedAccountId,
|
|
39
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
40
|
+
}));
|
|
41
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
if (!accountConfig) {
|
|
44
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccount`));
|
|
45
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
46
|
+
}
|
|
47
|
+
(0, projects_1.validateProjectConfig)(projectConfig, projectDir);
|
|
48
|
+
const components = await (0, structure_1.findProjectComponents)(projectDir);
|
|
37
49
|
const runnableComponents = components.filter(component => component.runnable);
|
|
38
|
-
const componentTypes = getProjectComponentTypes(runnableComponents);
|
|
39
|
-
const hasPrivateApps = !!componentTypes[ComponentTypes.PrivateApp];
|
|
40
|
-
const hasPublicApps = !!componentTypes[ComponentTypes.PublicApp];
|
|
50
|
+
const componentTypes = (0, structure_1.getProjectComponentTypes)(runnableComponents);
|
|
51
|
+
const hasPrivateApps = !!componentTypes[Projects_1.ComponentTypes.PrivateApp];
|
|
52
|
+
const hasPublicApps = !!componentTypes[Projects_1.ComponentTypes.PublicApp];
|
|
41
53
|
if (runnableComponents.length === 0) {
|
|
42
|
-
logger.error(i18n(`${i18nKey}.errors.noRunnableComponents`, {
|
|
54
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noRunnableComponents`, {
|
|
43
55
|
projectDir,
|
|
44
|
-
command: uiCommandReference('hs project add'),
|
|
56
|
+
command: (0, ui_1.uiCommandReference)('hs project add'),
|
|
45
57
|
}));
|
|
46
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
58
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
47
59
|
}
|
|
48
60
|
else if (hasPrivateApps && hasPublicApps) {
|
|
49
|
-
logger.error(i18n(`${i18nKey}.errors.invalidProjectComponents`));
|
|
50
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
61
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidProjectComponents`));
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
63
|
+
}
|
|
64
|
+
const accounts = (0, config_1.getConfigAccounts)();
|
|
65
|
+
if (!accounts) {
|
|
66
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccountsInConfig`, {
|
|
67
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
68
|
+
}));
|
|
69
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
51
70
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
(!hasPublicApps && isSandbox(accountConfig));
|
|
71
|
+
const defaultAccountIsRecommendedType = (0, accountTypes_1.isDeveloperTestAccount)(accountConfig) ||
|
|
72
|
+
(!hasPublicApps && (0, accountTypes_1.isSandbox)(accountConfig));
|
|
55
73
|
// targetProjectAccountId and targetTestingAccountId are set to null if --account flag is not provided.
|
|
56
74
|
// By setting them to null, we can later check if they need to be assigned based on the default account configuration and the type of app.
|
|
57
75
|
let targetProjectAccountId = providedAccountId ? derivedAccountId : null;
|
|
@@ -59,21 +77,21 @@ exports.handler = async (options) => {
|
|
|
59
77
|
let targetTestingAccountId = providedAccountId ? derivedAccountId : null;
|
|
60
78
|
// Check that the default account or flag option is valid for the type of app in this project
|
|
61
79
|
if (providedAccountId) {
|
|
62
|
-
checkIfAccountFlagIsSupported(accountConfig, hasPublicApps);
|
|
80
|
+
(0, localDev_1.checkIfAccountFlagIsSupported)(accountConfig, hasPublicApps);
|
|
63
81
|
if (hasPublicApps) {
|
|
64
|
-
targetProjectAccountId = accountConfig.parentAccountId;
|
|
82
|
+
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
else {
|
|
68
|
-
checkIfDefaultAccountIsSupported(accountConfig, hasPublicApps);
|
|
86
|
+
(0, localDev_1.checkIfDefaultAccountIsSupported)(accountConfig, hasPublicApps);
|
|
69
87
|
}
|
|
70
88
|
// The user is targeting an account type that we recommend developing on
|
|
71
89
|
if (!targetProjectAccountId && defaultAccountIsRecommendedType) {
|
|
72
90
|
targetTestingAccountId = derivedAccountId;
|
|
73
|
-
await
|
|
91
|
+
await (0, localDev_1.confirmDefaultAccountIsTarget)(accountConfig);
|
|
74
92
|
if (hasPublicApps) {
|
|
75
|
-
checkIfParentAccountIsAuthed(accountConfig);
|
|
76
|
-
targetProjectAccountId = accountConfig.parentAccountId;
|
|
93
|
+
(0, localDev_1.checkIfParentAccountIsAuthed)(accountConfig);
|
|
94
|
+
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
77
95
|
}
|
|
78
96
|
else {
|
|
79
97
|
targetProjectAccountId = derivedAccountId;
|
|
@@ -82,48 +100,52 @@ exports.handler = async (options) => {
|
|
|
82
100
|
let createNewSandbox = false;
|
|
83
101
|
let createNewDeveloperTestAccount = false;
|
|
84
102
|
if (!targetProjectAccountId) {
|
|
85
|
-
const { targetAccountId, parentAccountId, createNestedAccount, notInConfigAccount, } = await suggestRecommendedNestedAccount(accounts, accountConfig, hasPublicApps);
|
|
86
|
-
targetProjectAccountId = hasPublicApps
|
|
103
|
+
const { targetAccountId, parentAccountId, createNestedAccount, notInConfigAccount, } = await (0, localDev_1.suggestRecommendedNestedAccount)(accounts, accountConfig, hasPublicApps);
|
|
104
|
+
targetProjectAccountId = hasPublicApps
|
|
105
|
+
? parentAccountId || null
|
|
106
|
+
: targetAccountId;
|
|
87
107
|
targetTestingAccountId = targetAccountId;
|
|
88
108
|
// Only used for developer test accounts that are not yet in the config
|
|
89
109
|
if (notInConfigAccount) {
|
|
90
|
-
await useExistingDevTestAccount(env, notInConfigAccount);
|
|
110
|
+
await (0, localDev_1.useExistingDevTestAccount)(env, notInConfigAccount);
|
|
91
111
|
}
|
|
92
|
-
createNewSandbox = isStandardAccount(accountConfig) && createNestedAccount;
|
|
112
|
+
createNewSandbox = (0, accountTypes_1.isStandardAccount)(accountConfig) && createNestedAccount;
|
|
93
113
|
createNewDeveloperTestAccount =
|
|
94
|
-
isAppDeveloperAccount(accountConfig) && createNestedAccount;
|
|
114
|
+
(0, accountTypes_1.isAppDeveloperAccount)(accountConfig) && createNestedAccount;
|
|
95
115
|
}
|
|
96
116
|
if (createNewSandbox) {
|
|
97
|
-
targetProjectAccountId = await createSandboxForLocalDev(derivedAccountId, accountConfig, env);
|
|
117
|
+
targetProjectAccountId = await (0, localDev_1.createSandboxForLocalDev)(derivedAccountId, accountConfig, env);
|
|
98
118
|
// We will be running our tests against this new sandbox account
|
|
99
119
|
targetTestingAccountId = targetProjectAccountId;
|
|
100
120
|
}
|
|
101
121
|
if (createNewDeveloperTestAccount) {
|
|
102
|
-
targetTestingAccountId = await createDeveloperTestAccountForLocalDev(derivedAccountId, accountConfig, env);
|
|
122
|
+
targetTestingAccountId = await (0, localDev_1.createDeveloperTestAccountForLocalDev)(derivedAccountId, accountConfig, env);
|
|
103
123
|
targetProjectAccountId = derivedAccountId;
|
|
104
124
|
}
|
|
125
|
+
if (!targetProjectAccountId || !targetTestingAccountId) {
|
|
126
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccount`));
|
|
127
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
128
|
+
}
|
|
105
129
|
// eslint-disable-next-line prefer-const
|
|
106
|
-
let { projectExists, project } = await ensureProjectExists(targetProjectAccountId, projectConfig.name, {
|
|
130
|
+
let { projectExists, project } = await (0, projects_1.ensureProjectExists)(targetProjectAccountId, projectConfig.name, {
|
|
107
131
|
allowCreate: false,
|
|
108
132
|
noLogs: true,
|
|
109
133
|
withPolling: createNewSandbox,
|
|
110
134
|
});
|
|
111
135
|
let deployedBuild;
|
|
112
|
-
let isGithubLinked;
|
|
113
|
-
|
|
114
|
-
if (projectExists) {
|
|
136
|
+
let isGithubLinked = false;
|
|
137
|
+
SpinniesManager_1.default.init();
|
|
138
|
+
if (projectExists && project) {
|
|
115
139
|
deployedBuild = project.deployedBuild;
|
|
116
|
-
isGithubLinked =
|
|
117
|
-
project.sourceIntegration &&
|
|
118
|
-
project.sourceIntegration.source === 'GITHUB';
|
|
140
|
+
isGithubLinked = Boolean(project.sourceIntegration && project.sourceIntegration.source === 'GITHUB');
|
|
119
141
|
}
|
|
120
142
|
else {
|
|
121
|
-
project = await createNewProjectForLocalDev(projectConfig, targetProjectAccountId, createNewSandbox, hasPublicApps);
|
|
122
|
-
deployedBuild = await createInitialBuildForNewProject(projectConfig, projectDir, targetProjectAccountId);
|
|
143
|
+
project = await (0, localDev_1.createNewProjectForLocalDev)(projectConfig, targetProjectAccountId, createNewSandbox, hasPublicApps);
|
|
144
|
+
deployedBuild = await (0, localDev_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId);
|
|
123
145
|
}
|
|
124
|
-
const LocalDev = new
|
|
146
|
+
const LocalDev = new LocalDevManager_1.default({
|
|
125
147
|
runnableComponents,
|
|
126
|
-
debug:
|
|
148
|
+
debug: args.debug,
|
|
127
149
|
deployedBuild,
|
|
128
150
|
isGithubLinked,
|
|
129
151
|
parentAccountId: targetProjectAccountId,
|
|
@@ -134,13 +156,12 @@ exports.handler = async (options) => {
|
|
|
134
156
|
env,
|
|
135
157
|
});
|
|
136
158
|
await LocalDev.start();
|
|
137
|
-
handleExit(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
addConfigOptions(yargs);
|
|
141
|
-
addAccountOptions(yargs);
|
|
142
|
-
addUseEnvironmentOptions(yargs);
|
|
143
|
-
|
|
144
|
-
yargs.example([['$0 project dev', i18n(`${i18nKey}.examples.default`)]]);
|
|
159
|
+
(0, process_1.handleExit)(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP));
|
|
160
|
+
}
|
|
161
|
+
function builder(yargs) {
|
|
162
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
163
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
164
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
165
|
+
yargs.example([['$0 project dev', (0, lang_1.i18n)(`${i18nKey}.examples.default`)]]);
|
|
145
166
|
return yargs;
|
|
146
|
-
}
|
|
167
|
+
}
|
|
@@ -20,7 +20,7 @@ const i18nKey = 'commands.project.subcommands.upload';
|
|
|
20
20
|
exports.command = 'upload';
|
|
21
21
|
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
22
22
|
exports.handler = async (options) => {
|
|
23
|
-
const { forceCreate, message, derivedAccountId } = options;
|
|
23
|
+
const { forceCreate, message, derivedAccountId, bypassValidation } = options;
|
|
24
24
|
const accountConfig = getAccountConfig(derivedAccountId);
|
|
25
25
|
const accountType = accountConfig && accountConfig.accountType;
|
|
26
26
|
const { projectConfig, projectDir } = await getProjectConfig();
|
|
@@ -31,7 +31,7 @@ exports.handler = async (options) => {
|
|
|
31
31
|
uploadCommand: true,
|
|
32
32
|
});
|
|
33
33
|
try {
|
|
34
|
-
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, useV3Api(projectConfig?.platformVersion));
|
|
34
|
+
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, useV3Api(projectConfig?.platformVersion), bypassValidation);
|
|
35
35
|
if (uploadError) {
|
|
36
36
|
if (isSpecifiedError(uploadError, {
|
|
37
37
|
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
@@ -81,6 +81,11 @@ exports.builder = yargs => {
|
|
|
81
81
|
type: 'string',
|
|
82
82
|
default: '',
|
|
83
83
|
},
|
|
84
|
+
'bypass-validation': {
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
hidden: true,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
84
89
|
});
|
|
85
90
|
yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
|
|
86
91
|
addConfigOptions(yargs);
|
|
@@ -1 +1,13 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, TestingArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "create";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs & TestingArgs;
|
|
6
|
+
type SandboxCreateArgs = CommonArgs & CombinedArgs & {
|
|
7
|
+
name?: string;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
type?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function handler(args: ArgumentsCamelCase<SandboxCreateArgs>): Promise<void>;
|
|
12
|
+
export declare function builder(yargs: Argv): Argv<SandboxCreateArgs>;
|
|
1
13
|
export {};
|