@hubspot/cli 7.4.0-beta.0 → 7.4.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/project/dev/index.js +1 -1
- package/commands/project/installDeps.d.ts +9 -1
- package/commands/project/installDeps.js +43 -30
- package/commands/project/logs.d.ts +13 -1
- package/commands/project/logs.js +69 -62
- package/commands/project/upload.d.ts +12 -0
- package/commands/project/upload.js +62 -49
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +1 -1
- package/lib/projects/index.d.ts +1 -1
- package/lib/projects/upload.d.ts +1 -1
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ async function handler(args) {
|
|
|
36
36
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
37
37
|
}
|
|
38
38
|
(0, projects_1.validateProjectConfig)(projectConfig, projectDir);
|
|
39
|
-
if ((0, buildAndDeploy_1.useV3Api)(projectConfig
|
|
39
|
+
if ((0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion)) {
|
|
40
40
|
await (0, unifiedFlow_1.unifiedProjectDevFlow)(args, accountConfig, projectConfig, projectDir);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "install-deps [packages..]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
export type ProjectInstallDepsArgs = CommonArgs & {
|
|
6
|
+
packages?: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<ProjectInstallDepsArgs>): Promise<void>;
|
|
9
|
+
export declare const builder: (yargs: Argv) => Promise<Argv<ProjectInstallDepsArgs>>;
|
|
@@ -1,43 +1,49 @@
|
|
|
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
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
6
|
+
exports.builder = exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const dependencyManagement_1 = require("../../lib/dependencyManagement");
|
|
10
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
11
|
+
const projects_1 = require("../../lib/projects");
|
|
12
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const lang_1 = require("../../lib/lang");
|
|
15
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
16
|
+
const ui_1 = require("../../lib/ui");
|
|
17
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
18
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
13
19
|
const i18nKey = `commands.project.subcommands.installDeps`;
|
|
14
20
|
exports.command = 'install-deps [packages..]';
|
|
15
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.help.describe`), false);
|
|
16
|
-
|
|
17
|
-
const { derivedAccountId, packages } =
|
|
21
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.help.describe`), false);
|
|
22
|
+
async function handler(args) {
|
|
23
|
+
const { derivedAccountId, packages } = args;
|
|
18
24
|
try {
|
|
19
|
-
trackCommandUsage('project-install-deps',
|
|
20
|
-
const projectConfig = await getProjectConfig();
|
|
25
|
+
(0, usageTracking_1.trackCommandUsage)('project-install-deps', undefined, derivedAccountId);
|
|
26
|
+
const projectConfig = await (0, projects_1.getProjectConfig)();
|
|
21
27
|
if (!projectConfig || !projectConfig.projectDir) {
|
|
22
|
-
logger.error(i18n(`${i18nKey}.noProjectConfig`));
|
|
23
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
28
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.noProjectConfig`));
|
|
29
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
24
30
|
}
|
|
25
31
|
const { projectDir } = projectConfig;
|
|
26
|
-
let installLocations = await getProjectPackageJsonLocations();
|
|
32
|
+
let installLocations = await (0, dependencyManagement_1.getProjectPackageJsonLocations)();
|
|
27
33
|
if (packages) {
|
|
28
|
-
const { selectedInstallLocations } = await promptUser([
|
|
34
|
+
const { selectedInstallLocations } = await (0, promptUtils_1.promptUser)([
|
|
29
35
|
{
|
|
30
36
|
name: 'selectedInstallLocations',
|
|
31
37
|
type: 'checkbox',
|
|
32
38
|
when: () => packages && packages.length > 0,
|
|
33
|
-
message: i18n(`${i18nKey}.installLocationPrompt`),
|
|
39
|
+
message: (0, lang_1.i18n)(`${i18nKey}.installLocationPrompt`),
|
|
34
40
|
choices: installLocations.map(dir => ({
|
|
35
|
-
name:
|
|
41
|
+
name: path_1.default.relative(projectDir, dir),
|
|
36
42
|
value: dir,
|
|
37
43
|
})),
|
|
38
44
|
validate: choices => {
|
|
39
45
|
if (choices === undefined || choices.length === 0) {
|
|
40
|
-
return i18n(`${i18nKey}.installLocationPromptRequired`);
|
|
46
|
+
return (0, lang_1.i18n)(`${i18nKey}.installLocationPromptRequired`);
|
|
41
47
|
}
|
|
42
48
|
return true;
|
|
43
49
|
},
|
|
@@ -47,23 +53,30 @@ exports.handler = async (options) => {
|
|
|
47
53
|
installLocations = selectedInstallLocations;
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
|
-
await installPackages({
|
|
56
|
+
await (0, dependencyManagement_1.installPackages)({
|
|
51
57
|
packages,
|
|
52
58
|
installLocations,
|
|
53
59
|
});
|
|
54
60
|
}
|
|
55
61
|
catch (e) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
62
|
+
(0, errorHandlers_1.logError)(e);
|
|
63
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
59
64
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
65
|
+
}
|
|
66
|
+
function projectInstallDepsBuilder(yargs) {
|
|
62
67
|
yargs.example([
|
|
63
|
-
['$0 project install-deps', i18n(`${i18nKey}.help.installAppDepsExample`)],
|
|
68
|
+
['$0 project install-deps', (0, lang_1.i18n)(`${i18nKey}.help.installAppDepsExample`)],
|
|
64
69
|
[
|
|
65
70
|
'$0 project install-deps dependency1 dependency2',
|
|
66
|
-
i18n(`${i18nKey}.help.addDepToSubComponentExample`),
|
|
71
|
+
(0, lang_1.i18n)(`${i18nKey}.help.addDepToSubComponentExample`),
|
|
67
72
|
],
|
|
68
73
|
]);
|
|
74
|
+
return yargs;
|
|
75
|
+
}
|
|
76
|
+
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(projectInstallDepsBuilder, exports.command, exports.describe);
|
|
77
|
+
module.exports = {
|
|
78
|
+
command: exports.command,
|
|
79
|
+
describe: exports.describe,
|
|
80
|
+
builder: exports.builder,
|
|
81
|
+
handler,
|
|
69
82
|
};
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "logs";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
export type ProjectLogsArgs = CommonArgs & {
|
|
6
|
+
function?: string;
|
|
7
|
+
latest?: boolean;
|
|
8
|
+
compact?: boolean;
|
|
9
|
+
tail?: boolean;
|
|
10
|
+
limit?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const handler: (args: ArgumentsCamelCase<ProjectLogsArgs>) => Promise<never>;
|
|
13
|
+
export declare const builder: (yargs: Argv) => Promise<Argv<ProjectLogsArgs>>;
|
package/commands/project/logs.js
CHANGED
|
@@ -1,110 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
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
|
|
3
|
+
exports.builder = exports.handler = exports.describe = exports.command = void 0;
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
6
|
+
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
7
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
9
|
+
const table_1 = require("../../lib/ui/table");
|
|
10
|
+
const errorHandlers_1 = require("../../lib/errorHandlers/");
|
|
11
|
+
const ui_1 = require("../../lib/ui");
|
|
12
|
+
const projectsLogsPrompt_1 = require("../../lib/prompts/projectsLogsPrompt");
|
|
13
|
+
const lang_1 = require("../../lib/lang");
|
|
14
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
15
|
+
const ProjectLogsManager_1 = require("../../lib/projects/ProjectLogsManager");
|
|
16
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
17
17
|
const i18nKey = 'commands.project.subcommands.logs';
|
|
18
|
-
|
|
19
|
-
const baseUrl = getHubSpotWebsiteOrigin(getEnv(accountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
|
|
18
|
+
function getPrivateAppsUrl(accountId) {
|
|
19
|
+
const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)((0, config_1.getEnv)(accountId) === 'qa' ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD);
|
|
20
20
|
return `${baseUrl}/private-apps/${accountId}`;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
function logTable(tableHeader, logsInfo) {
|
|
23
|
-
logger.log(i18n(`${i18nKey}.logs.showingLogs`));
|
|
24
|
-
logger.log(getTableContents([tableHeader, logsInfo], { border: { bodyLeft: ' ' } }));
|
|
23
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.showingLogs`));
|
|
24
|
+
logger_1.logger.log((0, table_1.getTableContents)([tableHeader, logsInfo], { border: { bodyLeft: ' ' } }));
|
|
25
25
|
}
|
|
26
26
|
function logPreamble() {
|
|
27
|
-
if (ProjectLogsManager.isPublicFunction) {
|
|
28
|
-
logTable(getTableHeader([
|
|
29
|
-
i18n(`${i18nKey}.table.accountHeader`),
|
|
30
|
-
i18n(`${i18nKey}.table.functionHeader`),
|
|
31
|
-
i18n(`${i18nKey}.table.endpointHeader`),
|
|
27
|
+
if (ProjectLogsManager_1.ProjectLogsManager.isPublicFunction) {
|
|
28
|
+
logTable((0, table_1.getTableHeader)([
|
|
29
|
+
(0, lang_1.i18n)(`${i18nKey}.table.accountHeader`),
|
|
30
|
+
(0, lang_1.i18n)(`${i18nKey}.table.functionHeader`),
|
|
31
|
+
(0, lang_1.i18n)(`${i18nKey}.table.endpointHeader`),
|
|
32
32
|
]), [
|
|
33
|
-
ProjectLogsManager.accountId,
|
|
34
|
-
ProjectLogsManager.functionName,
|
|
35
|
-
ProjectLogsManager.endpointName,
|
|
33
|
+
ProjectLogsManager_1.ProjectLogsManager.accountId,
|
|
34
|
+
ProjectLogsManager_1.ProjectLogsManager.functionName,
|
|
35
|
+
ProjectLogsManager_1.ProjectLogsManager.endpointName,
|
|
36
36
|
]);
|
|
37
|
-
logger.log(uiLink(i18n(`${i18nKey}.logs.hubspotLogsDirectLink`), `${getPrivateAppsUrl(ProjectLogsManager.accountId)}/${ProjectLogsManager.appId}/logs/serverlessGatewayExecution?path=${ProjectLogsManager.endpointName}`));
|
|
37
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.logs.hubspotLogsDirectLink`), `${getPrivateAppsUrl(ProjectLogsManager_1.ProjectLogsManager.accountId)}/${ProjectLogsManager_1.ProjectLogsManager.appId}/logs/serverlessGatewayExecution?path=${ProjectLogsManager_1.ProjectLogsManager.endpointName}`));
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
logTable(getTableHeader([
|
|
41
|
-
i18n(`${i18nKey}.table.accountHeader`),
|
|
42
|
-
i18n(`${i18nKey}.table.functionHeader`),
|
|
43
|
-
]), [ProjectLogsManager.accountId, ProjectLogsManager.functionName]);
|
|
44
|
-
logger.log(uiLink(i18n(`${i18nKey}.logs.hubspotLogsDirectLink`), `${getPrivateAppsUrl(ProjectLogsManager.accountId)}/${ProjectLogsManager.appId}/logs/crm?serverlessFunction=${ProjectLogsManager.functionName}`));
|
|
40
|
+
logTable((0, table_1.getTableHeader)([
|
|
41
|
+
(0, lang_1.i18n)(`${i18nKey}.table.accountHeader`),
|
|
42
|
+
(0, lang_1.i18n)(`${i18nKey}.table.functionHeader`),
|
|
43
|
+
]), [ProjectLogsManager_1.ProjectLogsManager.accountId, ProjectLogsManager_1.ProjectLogsManager.functionName]);
|
|
44
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.logs.hubspotLogsDirectLink`), `${getPrivateAppsUrl(ProjectLogsManager_1.ProjectLogsManager.accountId)}/${ProjectLogsManager_1.ProjectLogsManager.appId}/logs/crm?serverlessFunction=${ProjectLogsManager_1.ProjectLogsManager.functionName}`));
|
|
45
45
|
}
|
|
46
|
-
logger.log();
|
|
47
|
-
uiLine();
|
|
46
|
+
logger_1.logger.log();
|
|
47
|
+
(0, ui_1.uiLine)();
|
|
48
48
|
}
|
|
49
49
|
exports.command = 'logs';
|
|
50
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
51
|
-
|
|
52
|
-
const { derivedAccountId } =
|
|
53
|
-
trackCommandUsage('project-logs',
|
|
50
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
51
|
+
const handler = async (args) => {
|
|
52
|
+
const { derivedAccountId } = args;
|
|
53
|
+
(0, usageTracking_1.trackCommandUsage)('project-logs', undefined, derivedAccountId);
|
|
54
54
|
try {
|
|
55
|
-
await ProjectLogsManager.init(derivedAccountId);
|
|
56
|
-
const { functionName } = await projectLogsPrompt({
|
|
57
|
-
functionChoices: ProjectLogsManager.getFunctionNames(),
|
|
58
|
-
promptOptions:
|
|
59
|
-
projectName: ProjectLogsManager.projectName,
|
|
55
|
+
await ProjectLogsManager_1.ProjectLogsManager.init(derivedAccountId);
|
|
56
|
+
const { functionName } = await (0, projectsLogsPrompt_1.projectLogsPrompt)({
|
|
57
|
+
functionChoices: ProjectLogsManager_1.ProjectLogsManager.getFunctionNames(),
|
|
58
|
+
promptOptions: args,
|
|
59
|
+
projectName: ProjectLogsManager_1.ProjectLogsManager.projectName,
|
|
60
60
|
});
|
|
61
|
-
ProjectLogsManager.setFunction(functionName);
|
|
61
|
+
ProjectLogsManager_1.ProjectLogsManager.setFunction(functionName);
|
|
62
62
|
logPreamble();
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
logError(e, {
|
|
65
|
+
(0, errorHandlers_1.logError)(e, {
|
|
66
66
|
accountId: derivedAccountId,
|
|
67
|
-
projectName: ProjectLogsManager.projectName,
|
|
67
|
+
projectName: ProjectLogsManager_1.ProjectLogsManager.projectName,
|
|
68
68
|
});
|
|
69
|
-
return process.exit(EXIT_CODES.ERROR);
|
|
69
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
70
70
|
}
|
|
71
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
71
72
|
};
|
|
72
|
-
exports.
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
exports.handler = handler;
|
|
74
|
+
function projectLogsBuilder(yargs) {
|
|
75
|
+
yargs.options({
|
|
75
76
|
function: {
|
|
76
77
|
alias: 'function',
|
|
77
|
-
describe: i18n(`${i18nKey}.options.function.describe`),
|
|
78
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.function.describe`),
|
|
78
79
|
requiresArg: true,
|
|
79
80
|
type: 'string',
|
|
80
81
|
},
|
|
81
82
|
latest: {
|
|
82
83
|
alias: 'l',
|
|
83
|
-
describe: i18n(`${i18nKey}.options.latest.describe`),
|
|
84
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.latest.describe`),
|
|
84
85
|
type: 'boolean',
|
|
85
86
|
},
|
|
86
87
|
compact: {
|
|
87
|
-
describe: i18n(`${i18nKey}.options.compact.describe`),
|
|
88
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.compact.describe`),
|
|
88
89
|
type: 'boolean',
|
|
89
90
|
},
|
|
90
91
|
tail: {
|
|
91
92
|
alias: ['t', 'follow'],
|
|
92
|
-
describe: i18n(`${i18nKey}.options.tail.describe`),
|
|
93
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.tail.describe`),
|
|
93
94
|
type: 'boolean',
|
|
94
95
|
},
|
|
95
96
|
limit: {
|
|
96
|
-
describe: i18n(`${i18nKey}.options.limit.describe`),
|
|
97
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.limit.describe`),
|
|
97
98
|
type: 'number',
|
|
98
99
|
},
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
['$0 project logs', i18n(`${i18nKey}.examples.default`)],
|
|
100
|
+
});
|
|
101
|
+
yargs.conflicts('tail', 'limit');
|
|
102
|
+
yargs.example([
|
|
103
|
+
['$0 project logs', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
103
104
|
[
|
|
104
105
|
'$0 project logs --function=my-function',
|
|
105
|
-
i18n(`${i18nKey}.examples.withOptions`),
|
|
106
|
+
(0, lang_1.i18n)(`${i18nKey}.examples.withOptions`),
|
|
106
107
|
],
|
|
107
108
|
]);
|
|
108
|
-
addUseEnvironmentOptions(yargs);
|
|
109
109
|
return yargs;
|
|
110
|
+
}
|
|
111
|
+
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(projectLogsBuilder, exports.command, exports.describe, { useEnvironmentOptions: true });
|
|
112
|
+
module.exports = {
|
|
113
|
+
command: exports.command,
|
|
114
|
+
describe: exports.describe,
|
|
115
|
+
builder: exports.builder,
|
|
116
|
+
handler: exports.handler,
|
|
110
117
|
};
|
|
@@ -1 +1,13 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "upload";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type ProjectUploadArgs = CommonArgs & {
|
|
6
|
+
forceCreate: boolean;
|
|
7
|
+
message: string;
|
|
8
|
+
m: string;
|
|
9
|
+
skipValidation: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function handler(args: ArgumentsCamelCase<ProjectUploadArgs>): Promise<void>;
|
|
12
|
+
export declare const builder: (yargs: Argv) => Promise<Argv<ProjectUploadArgs>>;
|
|
1
13
|
export {};
|
|
@@ -1,83 +1,88 @@
|
|
|
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
|
-
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
|
|
6
|
+
exports.builder = exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
11
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
12
|
+
const buildAndDeploy_1 = require("../../lib/projects/buildAndDeploy");
|
|
13
|
+
const ui_1 = require("../../lib/ui");
|
|
14
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
|
+
const projects_1 = require("../../lib/projects");
|
|
16
|
+
const upload_1 = require("../../lib/projects/upload");
|
|
17
|
+
const buildAndDeploy_2 = require("../../lib/projects/buildAndDeploy");
|
|
18
|
+
const lang_1 = require("../../lib/lang");
|
|
19
|
+
const constants_1 = require("../../lib/constants");
|
|
20
|
+
const index_2 = require("../../lib/errorHandlers/index");
|
|
21
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
22
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
19
23
|
const i18nKey = 'commands.project.subcommands.upload';
|
|
20
24
|
exports.command = 'upload';
|
|
21
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
22
|
-
|
|
23
|
-
const { forceCreate, message, derivedAccountId, skipValidation } =
|
|
24
|
-
const accountConfig = getAccountConfig(derivedAccountId);
|
|
25
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
26
|
+
async function handler(args) {
|
|
27
|
+
const { forceCreate, message, derivedAccountId, skipValidation } = args;
|
|
28
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
25
29
|
const accountType = accountConfig && accountConfig.accountType;
|
|
26
|
-
const { projectConfig, projectDir } = await getProjectConfig();
|
|
27
|
-
trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
|
|
28
|
-
validateProjectConfig(projectConfig, projectDir);
|
|
29
|
-
await ensureProjectExists(derivedAccountId, projectConfig.name, {
|
|
30
|
+
const { projectConfig, projectDir } = await (0, projects_1.getProjectConfig)();
|
|
31
|
+
(0, usageTracking_1.trackCommandUsage)('project-upload', { type: accountType }, derivedAccountId);
|
|
32
|
+
(0, projects_1.validateProjectConfig)(projectConfig, projectDir);
|
|
33
|
+
await (0, projects_1.ensureProjectExists)(derivedAccountId, projectConfig.name, {
|
|
30
34
|
forceCreate,
|
|
31
35
|
uploadCommand: true,
|
|
32
36
|
});
|
|
33
37
|
try {
|
|
34
|
-
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, useV3Api(projectConfig
|
|
38
|
+
const { result, uploadError } = await (0, upload_1.handleProjectUpload)(derivedAccountId, projectConfig, projectDir, buildAndDeploy_2.pollProjectBuildAndDeploy, message, (0, buildAndDeploy_1.useV3Api)(projectConfig.platformVersion), skipValidation);
|
|
35
39
|
if (uploadError) {
|
|
36
|
-
if (isSpecifiedError(uploadError, {
|
|
37
|
-
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
40
|
+
if ((0, index_1.isSpecifiedError)(uploadError, {
|
|
41
|
+
subCategory: constants_1.PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
38
42
|
})) {
|
|
39
|
-
logger.log();
|
|
40
|
-
logger.error(i18n(`${i18nKey}.errors.projectLockedError`));
|
|
41
|
-
logger.log();
|
|
43
|
+
logger_1.logger.log();
|
|
44
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.projectLockedError`));
|
|
45
|
+
logger_1.logger.log();
|
|
42
46
|
}
|
|
43
47
|
else {
|
|
44
|
-
logError(uploadError, new ApiErrorContext({
|
|
48
|
+
(0, index_2.logError)(uploadError, new index_2.ApiErrorContext({
|
|
45
49
|
accountId: derivedAccountId,
|
|
46
50
|
request: 'project upload',
|
|
47
51
|
}));
|
|
48
52
|
}
|
|
49
|
-
process.exit(EXIT_CODES.ERROR);
|
|
53
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
50
54
|
}
|
|
51
|
-
if (result.succeeded && !result.buildResult.isAutoDeployEnabled) {
|
|
52
|
-
logger.log(
|
|
55
|
+
if (result && result.succeeded && !result.buildResult.isAutoDeployEnabled) {
|
|
56
|
+
logger_1.logger.log(chalk_1.default.bold((0, lang_1.i18n)(`${i18nKey}.logs.buildSucceeded`, {
|
|
53
57
|
buildId: result.buildId,
|
|
54
58
|
})));
|
|
55
|
-
logger.log(i18n(`${i18nKey}.logs.autoDeployDisabled`, {
|
|
56
|
-
deployCommand: uiCommandReference(`hs project deploy --build=${result.buildId}`),
|
|
59
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.autoDeployDisabled`, {
|
|
60
|
+
deployCommand: (0, ui_1.uiCommandReference)(`hs project deploy --build=${result.buildId}`),
|
|
57
61
|
}));
|
|
58
|
-
logFeedbackMessage(result.buildId);
|
|
59
|
-
await displayWarnLogs(derivedAccountId, projectConfig.name, result.buildId);
|
|
60
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
62
|
+
(0, projects_1.logFeedbackMessage)(result.buildId);
|
|
63
|
+
await (0, buildAndDeploy_2.displayWarnLogs)(derivedAccountId, projectConfig.name, result.buildId);
|
|
64
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
catch (e) {
|
|
64
|
-
logError(e, new ApiErrorContext({
|
|
68
|
+
(0, index_2.logError)(e, new index_2.ApiErrorContext({
|
|
65
69
|
accountId: derivedAccountId,
|
|
66
70
|
request: 'project upload',
|
|
67
71
|
}));
|
|
68
|
-
process.exit(EXIT_CODES.ERROR);
|
|
72
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
75
|
+
}
|
|
76
|
+
function projectUploadBuilder(yargs) {
|
|
72
77
|
yargs.options({
|
|
73
78
|
'force-create': {
|
|
74
|
-
describe: i18n(`${i18nKey}.options.forceCreate.describe`),
|
|
79
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.forceCreate.describe`),
|
|
75
80
|
type: 'boolean',
|
|
76
81
|
default: false,
|
|
77
82
|
},
|
|
78
83
|
message: {
|
|
79
84
|
alias: 'm',
|
|
80
|
-
describe: i18n(`${i18nKey}.options.message.describe`),
|
|
85
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.message.describe`),
|
|
81
86
|
type: 'string',
|
|
82
87
|
default: '',
|
|
83
88
|
},
|
|
@@ -87,9 +92,17 @@ exports.builder = yargs => {
|
|
|
87
92
|
default: false,
|
|
88
93
|
},
|
|
89
94
|
});
|
|
90
|
-
yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
|
|
91
|
-
addConfigOptions(yargs);
|
|
92
|
-
addAccountOptions(yargs);
|
|
93
|
-
addUseEnvironmentOptions(yargs);
|
|
95
|
+
yargs.example([['$0 project upload', (0, lang_1.i18n)(`${i18nKey}.examples.default`)]]);
|
|
94
96
|
return yargs;
|
|
97
|
+
}
|
|
98
|
+
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(projectUploadBuilder, exports.command, exports.describe, {
|
|
99
|
+
useConfigOptions: true,
|
|
100
|
+
useAccountOptions: true,
|
|
101
|
+
useEnvironmentOptions: true,
|
|
102
|
+
});
|
|
103
|
+
module.exports = {
|
|
104
|
+
command: exports.command,
|
|
105
|
+
describe: exports.describe,
|
|
106
|
+
builder: exports.builder,
|
|
107
|
+
handler,
|
|
95
108
|
};
|
|
@@ -14,7 +14,7 @@ declare class _ProjectLogsManager {
|
|
|
14
14
|
init(accountId: number): Promise<void>;
|
|
15
15
|
fetchFunctionDetails(): Promise<void>;
|
|
16
16
|
getFunctionNames(): string[];
|
|
17
|
-
setFunction(functionName
|
|
17
|
+
setFunction(functionName?: string): void;
|
|
18
18
|
}
|
|
19
19
|
export declare const ProjectLogsManager: _ProjectLogsManager;
|
|
20
20
|
export {};
|
|
@@ -79,7 +79,7 @@ class _ProjectLogsManager {
|
|
|
79
79
|
return this.functions.map(serverlessFunction => serverlessFunction.componentName);
|
|
80
80
|
}
|
|
81
81
|
setFunction(functionName) {
|
|
82
|
-
if (!
|
|
82
|
+
if (!functionName || this.functions.length === 0) {
|
|
83
83
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noFunctionsInProject`, {
|
|
84
84
|
link: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
|
|
85
85
|
}));
|
package/lib/projects/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function getProjectConfig(dir?: string): Promise<{
|
|
|
6
6
|
projectDir: string | null;
|
|
7
7
|
projectConfig: ProjectConfig | null;
|
|
8
8
|
}>;
|
|
9
|
-
export declare function validateProjectConfig(projectConfig: ProjectConfig | null, projectDir: string | null):
|
|
9
|
+
export declare function validateProjectConfig(projectConfig: ProjectConfig | null, projectDir: string | null): asserts projectConfig is ProjectConfig;
|
|
10
10
|
export declare function ensureProjectExists(accountId: number, projectName: string, { forceCreate, allowCreate, noLogs, withPolling, uploadCommand, }?: {
|
|
11
11
|
forceCreate?: boolean | undefined;
|
|
12
12
|
allowCreate?: boolean | undefined;
|
package/lib/projects/upload.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileResult } from 'tmp';
|
|
2
2
|
import { ProjectConfig } from '../../types/Projects';
|
|
3
|
-
type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId
|
|
3
|
+
type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId: number) => Promise<T>;
|
|
4
4
|
type ProjectUploadResult<T> = {
|
|
5
5
|
result?: T;
|
|
6
6
|
uploadError?: unknown;
|