@hubspot/cli 7.3.0-experimental.2 → 7.3.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 +25 -83
- package/commands/account/clean.js +9 -10
- package/commands/account/info.js +9 -11
- package/commands/account/list.js +7 -8
- package/commands/account/remove.js +8 -9
- package/commands/account/rename.js +4 -5
- package/commands/account/use.js +7 -8
- package/commands/cms/convertFields.js +5 -6
- package/commands/cms/getReactModule.js +7 -8
- package/commands/cms/lighthouseScore.js +15 -16
- package/commands/config/set.js +6 -7
- package/commands/create/api-sample.js +6 -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 +9 -10
- package/commands/customObject/schema/fetch-all.js +7 -8
- package/commands/customObject/schema/fetch.js +9 -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/project/create.js +1 -0
- package/lang/en.js +6 -1
- package/lang/en.lyaml +4 -0
- package/lib/DevServerManagerV2.d.ts +1 -2
- package/lib/DevServerManagerV2.js +1 -2
- package/lib/LocalDevManagerV2.js +10 -15
- package/lib/dependencyManagement.d.ts +5 -0
- package/lib/dependencyManagement.js +47 -22
- package/lib/doctor/Doctor.js +1 -2
- package/lib/projects/structure.d.ts +1 -2
- package/lib/projects/structure.js +0 -4
- package/package.json +3 -3
- package/types/ProjectComponents.d.ts +0 -15
- package/lib/npm.d.ts +0 -9
- package/lib/npm.js +0 -36
|
@@ -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/lang/en.js
CHANGED
|
@@ -2841,7 +2841,7 @@ export const lib = {
|
|
|
2841
2841
|
disabledUrlText: 'See all HubSpot CLI commands here.',
|
|
2842
2842
|
featureHighlight: {
|
|
2843
2843
|
defaultTitle: "What's next?",
|
|
2844
|
-
|
|
2844
|
+
featureKeys: {
|
|
2845
2845
|
accountOption: {
|
|
2846
2846
|
command: '--account',
|
|
2847
2847
|
message: command =>
|
|
@@ -2895,6 +2895,11 @@ export const lib = {
|
|
|
2895
2895
|
message: command =>
|
|
2896
2896
|
`Run ${command} to set up your test environment and start local development`,
|
|
2897
2897
|
},
|
|
2898
|
+
projectInstallDepsCommand: {
|
|
2899
|
+
command: 'hs project install-deps',
|
|
2900
|
+
message: command =>
|
|
2901
|
+
`Run ${command} to install dependencies for your project components`,
|
|
2902
|
+
},
|
|
2898
2903
|
sampleProjects: {
|
|
2899
2904
|
linkText: "HubSpot's sample projects",
|
|
2900
2905
|
url: 'https://developers.hubspot.com/docs/platform/sample-projects?utm_source=cli&utm_content=project_create_whats_next',
|
package/lang/en.lyaml
CHANGED
|
@@ -1077,6 +1077,7 @@ en:
|
|
|
1077
1077
|
missingComponents: "Couldn't find the following components in the deployed build for this project: {{#bold}}'{{ missingComponents }}'{{/bold}}. This may cause issues in local development."
|
|
1078
1078
|
defaultWarning: "{{#bold}}Changing project configuration requires a new project build.{{/bold}}"
|
|
1079
1079
|
defaultPublicAppWarning: "{{#bold}}Changing project configuration requires a new project build.{{/bold}}\n\nThis will affect your public app's {{#bold}}{{ installCount }} existing {{ installText }}{{/bold}}. If your app has users in production, we strongly recommend creating a copy of this app to test your changes before proceding."
|
|
1080
|
+
defaultMarketplaceAppWarning: "{{#bold}}Changing project configuration requires creating a new project build.{{/bold}}\n\nYour marketplace app is currently installed in {{#bold}}{{ installCount }} {{ accountText }}{{/bold}}. Any uploaded changes will impact your app's users. We strongly recommend creating a copy of this app to test your changes before proceding."
|
|
1080
1081
|
header: "{{ warning }} To reflect these changes and continue testing:"
|
|
1081
1082
|
stopDev: " * Stop {{ command }}"
|
|
1082
1083
|
runUpload: " * Run {{ command }}"
|
|
@@ -1212,6 +1213,9 @@ en:
|
|
|
1212
1213
|
projectDevCommand:
|
|
1213
1214
|
command: "hs project dev"
|
|
1214
1215
|
message: "Run {{ command }} to set up your test environment and start local development"
|
|
1216
|
+
projectInstallDepsCommand:
|
|
1217
|
+
command: "hs project install-deps"
|
|
1218
|
+
message: "Run {{ command }} to install dependencies for your project components"
|
|
1215
1219
|
projectCommandTip:
|
|
1216
1220
|
message: "Tip: All project commands must be run from within a project directory"
|
|
1217
1221
|
sampleProjects:
|
|
@@ -12,11 +12,10 @@ declare class DevServerManagerV2 {
|
|
|
12
12
|
private devServers;
|
|
13
13
|
constructor();
|
|
14
14
|
iterateDevServers(callback: (serverInterface: DevServerInterface) => Promise<void>): Promise<void>;
|
|
15
|
-
setup({ projectNodes,
|
|
15
|
+
setup({ projectNodes, accountId, setActiveApp, }: {
|
|
16
16
|
projectNodes: {
|
|
17
17
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
18
18
|
};
|
|
19
|
-
onUploadRequired: () => void;
|
|
20
19
|
accountId: number;
|
|
21
20
|
setActiveApp: (appUid: string | undefined) => Promise<void>;
|
|
22
21
|
}): Promise<void>;
|
|
@@ -20,7 +20,7 @@ class DevServerManagerV2 {
|
|
|
20
20
|
async iterateDevServers(callback) {
|
|
21
21
|
await Promise.all(this.devServers.map(devServer => callback(devServer)));
|
|
22
22
|
}
|
|
23
|
-
async setup({ projectNodes,
|
|
23
|
+
async setup({ projectNodes, accountId, setActiveApp, }) {
|
|
24
24
|
let env;
|
|
25
25
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
26
26
|
if (accountConfig) {
|
|
@@ -31,7 +31,6 @@ class DevServerManagerV2 {
|
|
|
31
31
|
if (serverInterface.setup) {
|
|
32
32
|
await serverInterface.setup({
|
|
33
33
|
components: projectNodes,
|
|
34
|
-
onUploadRequired,
|
|
35
34
|
promptUser: promptUtils_1.promptUser,
|
|
36
35
|
logger: logger_1.logger,
|
|
37
36
|
urls: {
|
package/lib/LocalDevManagerV2.js
CHANGED
|
@@ -10,6 +10,7 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
10
10
|
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
11
11
|
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
12
12
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
13
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
13
14
|
const constants_1 = require("./constants");
|
|
14
15
|
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
15
16
|
const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
|
|
@@ -212,16 +213,13 @@ class LocalDevManagerV2 {
|
|
|
212
213
|
: (0, ui_1.uiCommandReference)('hs project upload');
|
|
213
214
|
}
|
|
214
215
|
logUploadWarning(reason) {
|
|
215
|
-
let warning;
|
|
216
|
-
if (
|
|
217
|
-
warning = reason;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
216
|
+
let warning = reason;
|
|
217
|
+
if (!warning) {
|
|
220
218
|
warning =
|
|
221
219
|
this.publicAppActiveInstalls && this.publicAppActiveInstalls > 0
|
|
222
|
-
? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.
|
|
220
|
+
? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultMarketplaceAppWarning`, {
|
|
223
221
|
installCount: this.publicAppActiveInstalls,
|
|
224
|
-
|
|
222
|
+
accountText: this.publicAppActiveInstalls === 1 ? 'account' : 'accounts',
|
|
225
223
|
})
|
|
226
224
|
: (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultWarning`);
|
|
227
225
|
}
|
|
@@ -268,10 +266,10 @@ class LocalDevManagerV2 {
|
|
|
268
266
|
const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
|
|
269
267
|
const missingProjectNodes = [];
|
|
270
268
|
Object.values(this.projectNodes).forEach(node => {
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
269
|
+
if (!deployedComponentNames.includes(node.uid)) {
|
|
270
|
+
const userFriendlyName = (0, project_parsing_lib_1.mapToUserFriendlyName)(node.componentType);
|
|
271
|
+
const label = userFriendlyName ? `[${userFriendlyName}] ` : '';
|
|
272
|
+
missingProjectNodes.push(`${label}${node.uid}`);
|
|
275
273
|
}
|
|
276
274
|
});
|
|
277
275
|
if (missingProjectNodes.length) {
|
|
@@ -284,9 +282,7 @@ class LocalDevManagerV2 {
|
|
|
284
282
|
this.watcher = chokidar_1.default.watch(this.projectDir, {
|
|
285
283
|
ignoreInitial: true,
|
|
286
284
|
});
|
|
287
|
-
const configPaths = Object.values(this.projectNodes)
|
|
288
|
-
.filter(structure_1.isAppIRNode)
|
|
289
|
-
.map(component => component.localDev.componentConfigPath);
|
|
285
|
+
const configPaths = Object.values(this.projectNodes).map(component => component.localDev.componentConfigPath);
|
|
290
286
|
const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
|
|
291
287
|
configPaths.push(projectConfigPath);
|
|
292
288
|
this.watcher.on('add', filePath => {
|
|
@@ -317,7 +313,6 @@ class LocalDevManagerV2 {
|
|
|
317
313
|
try {
|
|
318
314
|
await DevServerManagerV2_1.default.setup({
|
|
319
315
|
projectNodes: this.projectNodes,
|
|
320
|
-
onUploadRequired: this.logUploadWarning.bind(this),
|
|
321
316
|
accountId: this.targetTestingAccountId,
|
|
322
317
|
setActiveApp: this.setActiveApp.bind(this),
|
|
323
318
|
});
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare function isGloballyInstalled(command: string): Promise<boolean>;
|
|
2
|
+
export declare function getLatestCliVersion(): Promise<{
|
|
3
|
+
latest: string;
|
|
4
|
+
next: string;
|
|
5
|
+
}>;
|
|
1
6
|
export declare function installPackages({ packages, installLocations, }: {
|
|
2
7
|
packages?: string[];
|
|
3
8
|
installLocations?: string[];
|
|
@@ -3,28 +3,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isGloballyInstalled = isGloballyInstalled;
|
|
7
|
+
exports.getLatestCliVersion = getLatestCliVersion;
|
|
6
8
|
exports.installPackages = installPackages;
|
|
7
9
|
exports.getProjectPackageJsonLocations = getProjectPackageJsonLocations;
|
|
8
10
|
exports.hasMissingPackages = hasMissingPackages;
|
|
9
|
-
const
|
|
10
|
-
const util_1 = __importDefault(require("util"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const child_process_1 = require("child_process");
|
|
13
|
-
const fs_2 = require("@hubspot/local-dev-lib/fs");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
12
|
const projects_1 = require("./projects");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const fs_1 = require("@hubspot/local-dev-lib/fs");
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
15
16
|
const ui_1 = require("./ui");
|
|
17
|
+
const util_1 = __importDefault(require("util"));
|
|
16
18
|
const lang_1 = require("./lang");
|
|
17
19
|
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
+
const fs_2 = __importDefault(require("fs"));
|
|
21
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
22
|
+
const DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
20
23
|
class NoPackageJsonFilesError extends Error {
|
|
21
24
|
constructor(projectName) {
|
|
22
|
-
super((0, lang_1.i18n)(
|
|
25
|
+
super((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noPackageJsonInProject`, {
|
|
23
26
|
projectName,
|
|
24
27
|
link: (0, ui_1.uiLink)('Learn how to create a project from scratch.', 'https://developers.hubspot.com/beta-docs/guides/crm/intro/create-a-project'),
|
|
25
28
|
}));
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
async function isGloballyInstalled(command) {
|
|
32
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
33
|
+
try {
|
|
34
|
+
await exec(`${command} --version`);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function getLatestCliVersion() {
|
|
42
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
43
|
+
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
44
|
+
const { latest, next } = JSON.parse(stdout);
|
|
45
|
+
return { latest, next };
|
|
46
|
+
}
|
|
28
47
|
async function installPackages({ packages, installLocations, }) {
|
|
29
48
|
const installDirs = installLocations || (await getProjectPackageJsonLocations());
|
|
30
49
|
await Promise.all(installDirs.map(async (dir) => {
|
|
@@ -37,29 +56,35 @@ async function installPackagesInDirectory(directory, packages) {
|
|
|
37
56
|
SpinniesManager_1.default.init();
|
|
38
57
|
SpinniesManager_1.default.add(spinner, {
|
|
39
58
|
text: packages && packages.length
|
|
40
|
-
? (0, lang_1.i18n)(
|
|
59
|
+
? (0, lang_1.i18n)(`commands.project.subcommands.installDeps.addingDependenciesToLocation`, {
|
|
41
60
|
dependencies: `[${packages.join(', ')}]`,
|
|
42
61
|
directory: relativeDir,
|
|
43
62
|
})
|
|
44
|
-
: (0, lang_1.i18n)(
|
|
63
|
+
: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependencies`, {
|
|
45
64
|
directory: relativeDir,
|
|
46
65
|
}),
|
|
47
66
|
});
|
|
67
|
+
let installCommand = `${DEFAULT_PACKAGE_MANAGER} install`;
|
|
68
|
+
if (packages) {
|
|
69
|
+
installCommand = `${installCommand} ${packages.join(' ')}`;
|
|
70
|
+
}
|
|
71
|
+
logger_1.logger.debug(`Running ${installCommand}`);
|
|
48
72
|
try {
|
|
49
|
-
|
|
73
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
74
|
+
await exec(installCommand, { cwd: directory });
|
|
50
75
|
SpinniesManager_1.default.succeed(spinner, {
|
|
51
|
-
text: (0, lang_1.i18n)(
|
|
76
|
+
text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installationSuccessful`, {
|
|
52
77
|
directory: relativeDir,
|
|
53
78
|
}),
|
|
54
79
|
});
|
|
55
80
|
}
|
|
56
81
|
catch (e) {
|
|
57
82
|
SpinniesManager_1.default.fail(spinner, {
|
|
58
|
-
text: (0, lang_1.i18n)(
|
|
83
|
+
text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
|
|
59
84
|
directory: relativeDir,
|
|
60
85
|
}),
|
|
61
86
|
});
|
|
62
|
-
throw new Error((0, lang_1.i18n)(
|
|
87
|
+
throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.installingDependenciesFailed`, {
|
|
63
88
|
directory: relativeDir,
|
|
64
89
|
}), {
|
|
65
90
|
cause: e,
|
|
@@ -71,20 +96,20 @@ async function getProjectPackageJsonLocations() {
|
|
|
71
96
|
if (!projectConfig ||
|
|
72
97
|
!projectConfig.projectDir ||
|
|
73
98
|
!projectConfig.projectConfig) {
|
|
74
|
-
throw new Error((0, lang_1.i18n)(
|
|
99
|
+
throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noProjectConfig`));
|
|
75
100
|
}
|
|
76
101
|
const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
|
|
77
|
-
if (!(await
|
|
78
|
-
throw new Error((0, lang_1.i18n)(
|
|
79
|
-
packageManager:
|
|
80
|
-
link: (0, ui_1.uiLink)(
|
|
102
|
+
if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
|
|
103
|
+
throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.packageManagerNotInstalled`, {
|
|
104
|
+
packageManager: DEFAULT_PACKAGE_MANAGER,
|
|
105
|
+
link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
|
|
81
106
|
}));
|
|
82
107
|
}
|
|
83
|
-
if (!
|
|
84
|
-
!
|
|
108
|
+
if (!fs_2.default.existsSync(projectConfig.projectDir) ||
|
|
109
|
+
!fs_2.default.existsSync(path_1.default.join(projectDir, srcDir))) {
|
|
85
110
|
throw new NoPackageJsonFilesError(name);
|
|
86
111
|
}
|
|
87
|
-
const packageJsonFiles = (await (0,
|
|
112
|
+
const packageJsonFiles = (await (0, fs_1.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
|
|
88
113
|
!file.includes('node_modules') &&
|
|
89
114
|
!file.includes('.vite'));
|
|
90
115
|
if (packageJsonFiles.length === 0) {
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -8,7 +8,6 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
8
8
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
9
9
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
10
10
|
const dependencyManagement_1 = require("../dependencyManagement");
|
|
11
|
-
const npm_1 = require("../npm");
|
|
12
11
|
const util_1 = __importDefault(require("util"));
|
|
13
12
|
const fs_1 = __importDefault(require("fs"));
|
|
14
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -216,7 +215,7 @@ class Doctor {
|
|
|
216
215
|
let latestCLIVersion;
|
|
217
216
|
let nextCliVersion;
|
|
218
217
|
try {
|
|
219
|
-
const { latest, next } = await (0,
|
|
218
|
+
const { latest, next } = await (0, dependencyManagement_1.getLatestCliVersion)();
|
|
220
219
|
latestCLIVersion = latest;
|
|
221
220
|
nextCliVersion = next;
|
|
222
221
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentTypes, Component, GenericComponentConfig, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
|
|
2
2
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
|
-
import { AppIRNode
|
|
3
|
+
import { AppIRNode } from '../../types/ProjectComponents';
|
|
4
4
|
export declare const CONFIG_FILES: {
|
|
5
5
|
[k in ComponentTypes]: string;
|
|
6
6
|
};
|
|
@@ -16,4 +16,3 @@ export declare function getComponentUid(component?: Component | null): string |
|
|
|
16
16
|
export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
|
|
17
17
|
export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
|
|
18
18
|
export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev): component is AppIRNode;
|
|
19
|
-
export declare function isCardIRNode(component: IntermediateRepresentationNodeLocalDev): component is CardIRNode;
|
|
@@ -44,7 +44,6 @@ exports.getComponentUid = getComponentUid;
|
|
|
44
44
|
exports.componentIsApp = componentIsApp;
|
|
45
45
|
exports.componentIsPublicApp = componentIsPublicApp;
|
|
46
46
|
exports.isAppIRNode = isAppIRNode;
|
|
47
|
-
exports.isCardIRNode = isCardIRNode;
|
|
48
47
|
const fs = __importStar(require("fs"));
|
|
49
48
|
const path = __importStar(require("path"));
|
|
50
49
|
const fs_1 = require("@hubspot/local-dev-lib/fs");
|
|
@@ -175,6 +174,3 @@ function componentIsPublicApp(component) {
|
|
|
175
174
|
function isAppIRNode(component) {
|
|
176
175
|
return component.componentType === constants_1.IR_COMPONENT_TYPES.APPLICATION;
|
|
177
176
|
}
|
|
178
|
-
function isCardIRNode(component) {
|
|
179
|
-
return component.componentType === constants_1.IR_COMPONENT_TYPES.CARD;
|
|
180
|
-
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.3.0
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@hubspot/local-dev-lib": "3.4.1",
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.1.
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.1.5",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.2",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
|
-
"@hubspot/ui-extensions-dev-server": "0.8.
|
|
12
|
+
"@hubspot/ui-extensions-dev-server": "0.8.52",
|
|
13
13
|
"archiver": "7.0.1",
|
|
14
14
|
"chalk": "4.1.2",
|
|
15
15
|
"chokidar": "3.6.0",
|
|
@@ -16,23 +16,8 @@ type AppConfig = {
|
|
|
16
16
|
conditionallyRequiredScopes: string[];
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
type CardConfig = {
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
previewImage: {
|
|
23
|
-
file: string;
|
|
24
|
-
altText: string;
|
|
25
|
-
};
|
|
26
|
-
entrypoint: string;
|
|
27
|
-
location: string;
|
|
28
|
-
objectTypes: string[];
|
|
29
|
-
};
|
|
30
19
|
export interface AppIRNode extends IntermediateRepresentationNodeLocalDev {
|
|
31
20
|
componentType: typeof IR_COMPONENT_TYPES.APPLICATION;
|
|
32
21
|
config: AppConfig;
|
|
33
22
|
}
|
|
34
|
-
export interface CardIRNode extends IntermediateRepresentationNodeLocalDev {
|
|
35
|
-
componentType: typeof IR_COMPONENT_TYPES.CARD;
|
|
36
|
-
config: CardConfig;
|
|
37
|
-
}
|
|
38
23
|
export {};
|
package/lib/npm.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
2
|
-
export declare function isGloballyInstalled(): Promise<boolean>;
|
|
3
|
-
export declare function getLatestCliVersion(): Promise<{
|
|
4
|
-
latest: string;
|
|
5
|
-
next: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
|
|
8
|
-
cwd?: string;
|
|
9
|
-
}): Promise<void>;
|