@hubspot/cli 3.0.9 → 3.0.10-beta.11
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/README.md +6 -0
- package/bin/cli.js +3 -2
- package/commands/accounts/list.js +18 -26
- package/commands/accounts/rename.js +13 -24
- package/commands/accounts.js +4 -1
- package/commands/app/deploy.js +22 -28
- package/commands/auth.js +30 -13
- package/commands/config/set/allowUsageTracking.js +15 -31
- package/commands/config/set/defaultAccount.js +22 -32
- package/commands/config/set/defaultMode.js +23 -42
- package/commands/config/set/httpTimeout.js +10 -28
- package/commands/config/set.js +4 -1
- package/commands/config.js +4 -1
- package/commands/create/api-sample.js +14 -12
- package/commands/create/module.js +19 -6
- package/commands/create/project.js +8 -1
- package/commands/create/template.js +19 -4
- package/commands/create.js +23 -8
- package/commands/customObject/create.js +22 -24
- package/commands/customObject/schema/create.js +30 -28
- package/commands/customObject/schema/delete.js +20 -20
- package/commands/customObject/schema/fetch-all.js +17 -24
- package/commands/customObject/schema/fetch.js +29 -24
- package/commands/customObject/schema/list.js +8 -17
- package/commands/customObject/schema/update.js +31 -29
- package/commands/customObject/schema.js +4 -1
- package/commands/customObject.js +10 -21
- package/commands/fetch.js +15 -30
- package/commands/filemanager/fetch.js +13 -25
- package/commands/filemanager/upload.js +47 -35
- package/commands/filemanager.js +4 -1
- package/commands/functions/deploy.js +34 -37
- package/commands/functions/list.js +9 -24
- package/commands/functions/server.js +13 -29
- package/commands/functions.js +4 -1
- package/commands/hubdb/clear.js +25 -21
- package/commands/hubdb/create.js +25 -22
- package/commands/hubdb/delete.js +19 -20
- package/commands/hubdb/fetch.js +15 -20
- package/commands/hubdb.js +4 -1
- package/commands/init.js +23 -11
- package/commands/lint.js +14 -23
- package/commands/list.js +19 -25
- package/commands/logs.js +41 -135
- package/commands/mv.js +21 -25
- package/commands/open.js +7 -5
- package/commands/project/create.js +111 -0
- package/commands/project/deploy.js +30 -34
- package/commands/project/listBuilds.js +160 -0
- package/commands/project/logs.js +192 -0
- package/commands/project/upload.js +108 -55
- package/commands/project.js +7 -8
- package/commands/remove.js +12 -20
- package/commands/sandbox/create.js +16 -11
- package/commands/secrets/addSecret.js +18 -21
- package/commands/secrets/deleteSecret.js +18 -21
- package/commands/secrets/listSecrets.js +10 -19
- package/commands/secrets/updateSecret.js +18 -21
- package/commands/secrets.js +4 -1
- package/commands/server.js +13 -5
- package/commands/{marketplaceValidate/validateTheme.js → theme/marketplace-validate.js} +26 -24
- package/commands/theme.js +5 -3
- package/commands/upload.js +66 -45
- package/commands/watch.js +33 -55
- package/lib/__tests__/serverlessLogs.js +8 -9
- package/lib/commonOpts.js +14 -11
- package/lib/enums/exitCodes.js +14 -0
- package/lib/projects.js +246 -235
- package/lib/prompts/projects.js +8 -5
- package/lib/prompts/sandboxes.js +5 -2
- package/lib/prompts.js +26 -27
- package/lib/serverlessLogs.js +11 -12
- package/lib/ui.js +48 -0
- package/lib/validation.js +2 -1
- package/package.json +9 -7
- package/commands/project/init.js +0 -108
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
loadConfig,
|
|
6
|
-
validateConfig,
|
|
7
|
-
checkAndWarnGitInclusion,
|
|
8
|
-
} = require('@hubspot/cli-lib');
|
|
9
4
|
const { uploadFolder } = require('@hubspot/cli-lib/fileManager');
|
|
10
5
|
const { uploadFile } = require('@hubspot/cli-lib/api/fileManager');
|
|
11
6
|
const { getCwd, convertToUnixPath } = require('@hubspot/cli-lib/path');
|
|
@@ -22,28 +17,22 @@ const {
|
|
|
22
17
|
addConfigOptions,
|
|
23
18
|
addAccountOptions,
|
|
24
19
|
addUseEnvironmentOptions,
|
|
25
|
-
setLogLevel,
|
|
26
20
|
getAccountId,
|
|
27
21
|
} = require('../../lib/commonOpts');
|
|
28
|
-
const {
|
|
29
|
-
const { validateAccount } = require('../../lib/validation');
|
|
22
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
30
23
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
24
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
25
|
+
|
|
26
|
+
const i18nKey = 'cli.commands.filemanager.subcommands.upload';
|
|
27
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
31
28
|
|
|
32
29
|
exports.command = 'upload <src> <dest>';
|
|
33
|
-
exports.describe =
|
|
34
|
-
'Upload a folder or file from your computer to the HubSpot File Manager';
|
|
30
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
35
31
|
|
|
36
32
|
exports.handler = async options => {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
setLogLevel(options);
|
|
40
|
-
logDebugInfo(options);
|
|
41
|
-
loadConfig(configPath, options);
|
|
42
|
-
checkAndWarnGitInclusion();
|
|
33
|
+
const { src, dest } = options;
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
35
|
+
await loadAndValidateOptions(options);
|
|
47
36
|
|
|
48
37
|
const accountId = getAccountId(options);
|
|
49
38
|
const absoluteSrcPath = path.resolve(getCwd(), src);
|
|
@@ -52,16 +41,24 @@ exports.handler = async options => {
|
|
|
52
41
|
try {
|
|
53
42
|
stats = fs.statSync(absoluteSrcPath);
|
|
54
43
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
55
|
-
logger.error(
|
|
44
|
+
logger.error(
|
|
45
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
46
|
+
path: src,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
56
49
|
return;
|
|
57
50
|
}
|
|
58
51
|
} catch (e) {
|
|
59
|
-
logger.error(
|
|
52
|
+
logger.error(
|
|
53
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
54
|
+
path: src,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
if (!dest) {
|
|
64
|
-
logger.error(
|
|
61
|
+
logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
|
|
65
62
|
return;
|
|
66
63
|
}
|
|
67
64
|
const normalizedDest = convertToUnixPath(dest);
|
|
@@ -77,26 +74,36 @@ exports.handler = async options => {
|
|
|
77
74
|
);
|
|
78
75
|
if (srcDestIssues.length) {
|
|
79
76
|
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
80
|
-
process.exit(
|
|
77
|
+
process.exit(EXIT_CODES.ERROR);
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
if (stats.isFile()) {
|
|
84
81
|
if (shouldIgnoreFile(absoluteSrcPath)) {
|
|
85
|
-
logger.error(
|
|
82
|
+
logger.error(
|
|
83
|
+
i18n(`${i18nKey}.errors.fileIgnored`, {
|
|
84
|
+
path: src,
|
|
85
|
+
})
|
|
86
|
+
);
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
uploadFile(accountId, absoluteSrcPath, normalizedDest)
|
|
90
91
|
.then(() => {
|
|
91
92
|
logger.success(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
i18n(`${i18nKey}.success.upload`, {
|
|
94
|
+
accountId,
|
|
95
|
+
dest: normalizedDest,
|
|
96
|
+
src,
|
|
97
|
+
})
|
|
96
98
|
);
|
|
97
99
|
})
|
|
98
100
|
.catch(error => {
|
|
99
|
-
logger.error(
|
|
101
|
+
logger.error(
|
|
102
|
+
i18n(`${i18nKey}.errors.upload`, {
|
|
103
|
+
dest: normalizedDest,
|
|
104
|
+
src,
|
|
105
|
+
})
|
|
106
|
+
);
|
|
100
107
|
logApiUploadErrorInstance(
|
|
101
108
|
error,
|
|
102
109
|
new ApiErrorContext({
|
|
@@ -108,16 +115,22 @@ exports.handler = async options => {
|
|
|
108
115
|
});
|
|
109
116
|
} else {
|
|
110
117
|
logger.log(
|
|
111
|
-
|
|
118
|
+
i18n(`${i18nKey}.logs.uploading`, {
|
|
119
|
+
accountId,
|
|
120
|
+
dest,
|
|
121
|
+
src,
|
|
122
|
+
})
|
|
112
123
|
);
|
|
113
124
|
uploadFolder(accountId, absoluteSrcPath, dest)
|
|
114
125
|
.then(() => {
|
|
115
126
|
logger.success(
|
|
116
|
-
|
|
127
|
+
i18n(`${i18nKey}.success.uploadComplete`, {
|
|
128
|
+
dest,
|
|
129
|
+
})
|
|
117
130
|
);
|
|
118
131
|
})
|
|
119
132
|
.catch(error => {
|
|
120
|
-
logger.error(
|
|
133
|
+
logger.error(i18n(`${i18nKey}.errors.uploadingFailed`));
|
|
121
134
|
logErrorInstance(error, {
|
|
122
135
|
accountId,
|
|
123
136
|
});
|
|
@@ -131,12 +144,11 @@ exports.builder = yargs => {
|
|
|
131
144
|
addUseEnvironmentOptions(yargs, true);
|
|
132
145
|
|
|
133
146
|
yargs.positional('src', {
|
|
134
|
-
describe:
|
|
135
|
-
'Path to the local file, relative to your current working directory',
|
|
147
|
+
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
136
148
|
type: 'string',
|
|
137
149
|
});
|
|
138
150
|
yargs.positional('dest', {
|
|
139
|
-
describe:
|
|
151
|
+
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
140
152
|
type: 'string',
|
|
141
153
|
});
|
|
142
154
|
};
|
package/commands/filemanager.js
CHANGED
|
@@ -5,9 +5,12 @@ const {
|
|
|
5
5
|
} = require('../lib/commonOpts');
|
|
6
6
|
const upload = require('./filemanager/upload');
|
|
7
7
|
const fetch = require('./filemanager/fetch');
|
|
8
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
9
|
+
|
|
10
|
+
const i18nKey = 'cli.commands.filemanager';
|
|
8
11
|
|
|
9
12
|
exports.command = 'filemanager';
|
|
10
|
-
exports.describe =
|
|
13
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
11
14
|
|
|
12
15
|
exports.builder = yargs => {
|
|
13
16
|
addOverwriteOptions(yargs, true);
|
|
@@ -2,17 +2,10 @@ const ora = require('ora');
|
|
|
2
2
|
const {
|
|
3
3
|
addAccountOptions,
|
|
4
4
|
addConfigOptions,
|
|
5
|
-
setLogLevel,
|
|
6
5
|
getAccountId,
|
|
7
6
|
addUseEnvironmentOptions,
|
|
8
7
|
} = require('../../lib/commonOpts');
|
|
9
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
-
const { logDebugInfo } = require('../../lib/debugInfo');
|
|
11
|
-
const {
|
|
12
|
-
loadConfig,
|
|
13
|
-
validateConfig,
|
|
14
|
-
checkAndWarnGitInclusion,
|
|
15
|
-
} = require('@hubspot/cli-lib');
|
|
16
9
|
const {
|
|
17
10
|
logApiErrorInstance,
|
|
18
11
|
ApiErrorContext,
|
|
@@ -23,14 +16,11 @@ const {
|
|
|
23
16
|
buildPackage,
|
|
24
17
|
getBuildStatus,
|
|
25
18
|
} = require('@hubspot/cli-lib/api/functions');
|
|
26
|
-
const {
|
|
19
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
27
20
|
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
21
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
28
22
|
|
|
29
|
-
const
|
|
30
|
-
return ora(
|
|
31
|
-
`${actionText} bundle for '${functionPath}' on account '${accountIdentifier}'.\n`
|
|
32
|
-
);
|
|
33
|
-
};
|
|
23
|
+
const i18nKey = 'cli.commands.functions.subcommands.deploy';
|
|
34
24
|
|
|
35
25
|
const pollBuildStatus = (accountId, buildId) => {
|
|
36
26
|
return new Promise((resolve, reject) => {
|
|
@@ -49,23 +39,11 @@ const pollBuildStatus = (accountId, buildId) => {
|
|
|
49
39
|
});
|
|
50
40
|
};
|
|
51
41
|
|
|
52
|
-
const loadAndValidateOptions = async options => {
|
|
53
|
-
setLogLevel(options);
|
|
54
|
-
logDebugInfo(options);
|
|
55
|
-
const { config: configPath } = options;
|
|
56
|
-
loadConfig(configPath, options);
|
|
57
|
-
checkAndWarnGitInclusion();
|
|
58
|
-
|
|
59
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
42
|
exports.command = 'deploy <path>';
|
|
65
43
|
exports.describe = false;
|
|
66
44
|
|
|
67
45
|
exports.handler = async options => {
|
|
68
|
-
loadAndValidateOptions(options);
|
|
46
|
+
await loadAndValidateOptions(options);
|
|
69
47
|
|
|
70
48
|
const { path: functionPath } = options;
|
|
71
49
|
const accountId = getAccountId(options);
|
|
@@ -78,19 +56,26 @@ exports.handler = async options => {
|
|
|
78
56
|
!splitFunctionPath.length ||
|
|
79
57
|
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions'
|
|
80
58
|
) {
|
|
81
|
-
logger.error(
|
|
59
|
+
logger.error(
|
|
60
|
+
i18n(`${i18nKey}.errors.notFunctionsFolder`, {
|
|
61
|
+
functionPath,
|
|
62
|
+
})
|
|
63
|
+
);
|
|
82
64
|
return;
|
|
83
65
|
}
|
|
84
66
|
|
|
85
67
|
logger.debug(
|
|
86
|
-
|
|
68
|
+
i18n(`${i18nKey}.debug.startingBuildAndDeploy`, {
|
|
69
|
+
functionPath,
|
|
70
|
+
})
|
|
87
71
|
);
|
|
88
72
|
|
|
89
73
|
try {
|
|
90
|
-
spinner =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
74
|
+
spinner = ora(
|
|
75
|
+
i18n(`${i18nKey}.loading`, {
|
|
76
|
+
accountId,
|
|
77
|
+
functionPath,
|
|
78
|
+
})
|
|
94
79
|
).start();
|
|
95
80
|
const buildId = await buildPackage(accountId, functionPath);
|
|
96
81
|
const successResp = await pollBuildStatus(accountId, buildId);
|
|
@@ -98,17 +83,29 @@ exports.handler = async options => {
|
|
|
98
83
|
spinner.stop();
|
|
99
84
|
await outputBuildLog(successResp.cdnUrl);
|
|
100
85
|
logger.success(
|
|
101
|
-
|
|
86
|
+
i18n(`${i18nKey}.success.deploy`, {
|
|
87
|
+
accountId,
|
|
88
|
+
buildTimeSeconds,
|
|
89
|
+
functionPath,
|
|
90
|
+
})
|
|
102
91
|
);
|
|
103
92
|
} catch (e) {
|
|
104
93
|
spinner && spinner.stop && spinner.stop();
|
|
105
94
|
if (e.statusCode === 404) {
|
|
106
|
-
logger.error(
|
|
95
|
+
logger.error(
|
|
96
|
+
i18n(`${i18nKey}.errors.noPackageJson`, {
|
|
97
|
+
functionPath,
|
|
98
|
+
})
|
|
99
|
+
);
|
|
107
100
|
} else if (e.statusCode === 400) {
|
|
108
101
|
logger.error(e.error.message);
|
|
109
102
|
} else if (e.status === 'ERROR') {
|
|
110
103
|
await outputBuildLog(e.cdnUrl);
|
|
111
|
-
logger.error(
|
|
104
|
+
logger.error(
|
|
105
|
+
i18n(`${i18nKey}.errors.buildError`, {
|
|
106
|
+
details: e.errorReason,
|
|
107
|
+
})
|
|
108
|
+
);
|
|
112
109
|
} else {
|
|
113
110
|
logApiErrorInstance(
|
|
114
111
|
accountId,
|
|
@@ -121,14 +118,14 @@ exports.handler = async options => {
|
|
|
121
118
|
|
|
122
119
|
exports.builder = yargs => {
|
|
123
120
|
yargs.positional('path', {
|
|
124
|
-
describe:
|
|
121
|
+
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
125
122
|
type: 'string',
|
|
126
123
|
});
|
|
127
124
|
|
|
128
125
|
yargs.example([
|
|
129
126
|
[
|
|
130
127
|
'$0 functions deploy myFunctionFolder.functions',
|
|
131
|
-
|
|
128
|
+
i18n(`${i18nKey}.examples.default`),
|
|
132
129
|
],
|
|
133
130
|
]);
|
|
134
131
|
|
|
@@ -5,11 +5,6 @@ const {
|
|
|
5
5
|
ApiErrorContext,
|
|
6
6
|
} = require('@hubspot/cli-lib/errorHandlers');
|
|
7
7
|
const { getFunctionArrays } = require('@hubspot/cli-lib/lib/functions');
|
|
8
|
-
const {
|
|
9
|
-
loadConfig,
|
|
10
|
-
validateConfig,
|
|
11
|
-
checkAndWarnGitInclusion,
|
|
12
|
-
} = require('@hubspot/cli-lib');
|
|
13
8
|
const {
|
|
14
9
|
getTableContents,
|
|
15
10
|
getTableHeader,
|
|
@@ -20,26 +15,16 @@ const {
|
|
|
20
15
|
addAccountOptions,
|
|
21
16
|
addUseEnvironmentOptions,
|
|
22
17
|
getAccountId,
|
|
23
|
-
setLogLevel,
|
|
24
18
|
} = require('../../lib/commonOpts');
|
|
25
19
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
26
|
-
const {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
const loadAndValidateOptions = async options => {
|
|
30
|
-
setLogLevel(options);
|
|
31
|
-
logDebugInfo(options);
|
|
32
|
-
const { config: configPath } = options;
|
|
33
|
-
loadConfig(configPath, options);
|
|
34
|
-
checkAndWarnGitInclusion();
|
|
20
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
21
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
};
|
|
23
|
+
const i18nKey = 'cli.commands.functions.subcommands.list';
|
|
24
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
40
25
|
|
|
41
26
|
exports.command = 'list';
|
|
42
|
-
exports.describe =
|
|
27
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
43
28
|
|
|
44
29
|
exports.handler = async options => {
|
|
45
30
|
loadAndValidateOptions(options);
|
|
@@ -49,15 +34,15 @@ exports.handler = async options => {
|
|
|
49
34
|
|
|
50
35
|
trackCommandUsage('functions-list', { json, compact }, accountId);
|
|
51
36
|
|
|
52
|
-
logger.debug(
|
|
37
|
+
logger.debug(i18n(`${i18nKey}.debug.gettingFunctions`));
|
|
53
38
|
|
|
54
39
|
const routesResp = await getRoutes(accountId).catch(async e => {
|
|
55
40
|
await logApiErrorInstance(accountId, e, new ApiErrorContext({ accountId }));
|
|
56
|
-
process.exit();
|
|
41
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
57
42
|
});
|
|
58
43
|
|
|
59
44
|
if (!routesResp.objects.length) {
|
|
60
|
-
return logger.info(
|
|
45
|
+
return logger.info(i18n(`${i18nKey}.info.noFunctions`));
|
|
61
46
|
}
|
|
62
47
|
|
|
63
48
|
if (options.json) {
|
|
@@ -78,7 +63,7 @@ exports.builder = yargs => {
|
|
|
78
63
|
|
|
79
64
|
yargs.options({
|
|
80
65
|
json: {
|
|
81
|
-
describe:
|
|
66
|
+
describe: i18n(`${i18nKey}.options.json.describe`),
|
|
82
67
|
type: 'boolean',
|
|
83
68
|
},
|
|
84
69
|
});
|
|
@@ -1,38 +1,22 @@
|
|
|
1
1
|
const {
|
|
2
2
|
addAccountOptions,
|
|
3
3
|
addConfigOptions,
|
|
4
|
-
setLogLevel,
|
|
5
4
|
getAccountId,
|
|
6
5
|
addUseEnvironmentOptions,
|
|
7
6
|
} = require('../../lib/commonOpts');
|
|
8
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { logDebugInfo } = require('../../lib/debugInfo');
|
|
10
|
-
const {
|
|
11
|
-
loadConfig,
|
|
12
|
-
validateConfig,
|
|
13
|
-
checkAndWarnGitInclusion,
|
|
14
|
-
} = require('@hubspot/cli-lib');
|
|
15
8
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
16
9
|
const { start: startTestServer } = require('@hubspot/serverless-dev-runtime');
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
const loadAndValidateOptions = async options => {
|
|
20
|
-
setLogLevel(options);
|
|
21
|
-
logDebugInfo(options);
|
|
22
|
-
const { config: configPath } = options;
|
|
23
|
-
loadConfig(configPath, options);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
10
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
13
|
+
const i18nKey = 'cli.commands.functions.subcommands.server';
|
|
30
14
|
|
|
31
15
|
exports.command = 'server <path>';
|
|
32
16
|
exports.describe = false;
|
|
33
17
|
|
|
34
18
|
exports.handler = async options => {
|
|
35
|
-
loadAndValidateOptions(options);
|
|
19
|
+
await loadAndValidateOptions(options);
|
|
36
20
|
|
|
37
21
|
const { path: functionPath } = options;
|
|
38
22
|
const accountId = getAccountId(options);
|
|
@@ -40,7 +24,9 @@ exports.handler = async options => {
|
|
|
40
24
|
trackCommandUsage('functions-server', { functionPath }, accountId);
|
|
41
25
|
|
|
42
26
|
logger.debug(
|
|
43
|
-
|
|
27
|
+
i18n(`${i18nKey}.debug.startingServer`, {
|
|
28
|
+
functionPath,
|
|
29
|
+
})
|
|
44
30
|
);
|
|
45
31
|
|
|
46
32
|
startTestServer({
|
|
@@ -51,28 +37,26 @@ exports.handler = async options => {
|
|
|
51
37
|
|
|
52
38
|
exports.builder = yargs => {
|
|
53
39
|
yargs.positional('path', {
|
|
54
|
-
describe:
|
|
40
|
+
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
55
41
|
type: 'string',
|
|
56
42
|
});
|
|
57
43
|
yargs.option('port', {
|
|
58
|
-
describe:
|
|
44
|
+
describe: i18n(`${i18nKey}.options.port.describe`),
|
|
59
45
|
type: 'string',
|
|
60
46
|
default: 5432,
|
|
61
47
|
});
|
|
62
48
|
yargs.option('contact', {
|
|
63
|
-
describe:
|
|
49
|
+
describe: i18n(`${i18nKey}.options.contact.describe`),
|
|
64
50
|
type: 'boolean',
|
|
65
51
|
default: true,
|
|
66
52
|
});
|
|
67
53
|
yargs.option('watch', {
|
|
68
|
-
describe:
|
|
69
|
-
'watch the specified .functions folder for changes and restart the server',
|
|
54
|
+
describe: i18n(`${i18nKey}.options.watch.describe`),
|
|
70
55
|
type: 'boolean',
|
|
71
56
|
default: true,
|
|
72
57
|
});
|
|
73
58
|
yargs.option('log-output', {
|
|
74
|
-
describe:
|
|
75
|
-
'output the response body from the serverless function execution (It is suggested not to use this in production environments as it can reveal any secure data returned by the function in logs)',
|
|
59
|
+
describe: i18n(`${i18nKey}.options.logOutput.describe`),
|
|
76
60
|
type: 'boolean',
|
|
77
61
|
default: false,
|
|
78
62
|
});
|
|
@@ -80,7 +64,7 @@ exports.builder = yargs => {
|
|
|
80
64
|
yargs.example([
|
|
81
65
|
[
|
|
82
66
|
'$0 functions server ./tmp/myFunctionFolder.functions',
|
|
83
|
-
|
|
67
|
+
i18n(`${i18nKey}.examples.default`),
|
|
84
68
|
],
|
|
85
69
|
]);
|
|
86
70
|
|
package/commands/functions.js
CHANGED
|
@@ -2,9 +2,12 @@ const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
|
2
2
|
const list = require('./functions/list');
|
|
3
3
|
const deploy = require('./functions/deploy');
|
|
4
4
|
const server = require('./functions/server');
|
|
5
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
6
|
+
|
|
7
|
+
const i18nKey = 'cli.commands.functions';
|
|
5
8
|
|
|
6
9
|
exports.command = 'functions';
|
|
7
|
-
exports.describe =
|
|
10
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
8
11
|
|
|
9
12
|
exports.builder = yargs => {
|
|
10
13
|
addConfigOptions(yargs, true);
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
const {
|
|
2
|
-
loadConfig,
|
|
3
|
-
validateConfig,
|
|
4
|
-
checkAndWarnGitInclusion,
|
|
5
|
-
} = require('@hubspot/cli-lib');
|
|
6
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
7
2
|
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
8
3
|
const { clearHubDbTableRows } = require('@hubspot/cli-lib/hubdb');
|
|
9
4
|
const { publishTable } = require('@hubspot/cli-lib/api/hubdb');
|
|
10
5
|
|
|
11
|
-
const {
|
|
6
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
12
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
13
8
|
|
|
14
9
|
const {
|
|
15
10
|
addConfigOptions,
|
|
16
11
|
addAccountOptions,
|
|
17
12
|
addUseEnvironmentOptions,
|
|
18
|
-
setLogLevel,
|
|
19
13
|
getAccountId,
|
|
20
14
|
} = require('../../lib/commonOpts');
|
|
21
|
-
const {
|
|
15
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
16
|
+
|
|
17
|
+
const i18nKey = 'cli.commands.hubdb.subcommands.clear';
|
|
22
18
|
|
|
23
19
|
exports.command = 'clear <tableId>';
|
|
24
|
-
exports.describe =
|
|
20
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
25
21
|
|
|
26
22
|
exports.handler = async options => {
|
|
27
|
-
const {
|
|
23
|
+
const { tableId } = options;
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
logDebugInfo(options);
|
|
31
|
-
loadConfig(configPath);
|
|
32
|
-
checkAndWarnGitInclusion();
|
|
25
|
+
await loadAndValidateOptions(options);
|
|
33
26
|
|
|
34
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
27
|
const accountId = getAccountId(options);
|
|
38
28
|
|
|
39
29
|
trackCommandUsage('hubdb-clear', {}, accountId);
|
|
@@ -41,11 +31,25 @@ exports.handler = async options => {
|
|
|
41
31
|
try {
|
|
42
32
|
const { deletedRowCount } = await clearHubDbTableRows(accountId, tableId);
|
|
43
33
|
if (deletedRowCount > 0) {
|
|
44
|
-
logger.log(
|
|
34
|
+
logger.log(
|
|
35
|
+
i18n(`${i18nKey}.logs.removedRows`, {
|
|
36
|
+
deletedRowCount,
|
|
37
|
+
tableId,
|
|
38
|
+
})
|
|
39
|
+
);
|
|
45
40
|
const { rowCount } = await publishTable(accountId, tableId);
|
|
46
|
-
logger.log(
|
|
41
|
+
logger.log(
|
|
42
|
+
i18n(`${i18nKey}.logs.rowCount`, {
|
|
43
|
+
rowCount,
|
|
44
|
+
tableId,
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
47
|
} else {
|
|
48
|
-
logger.log(
|
|
48
|
+
logger.log(
|
|
49
|
+
i18n(`${i18nKey}.logs.emptyTable`, {
|
|
50
|
+
tableId,
|
|
51
|
+
})
|
|
52
|
+
);
|
|
49
53
|
}
|
|
50
54
|
} catch (e) {
|
|
51
55
|
logErrorInstance(e);
|
|
@@ -58,7 +62,7 @@ exports.builder = yargs => {
|
|
|
58
62
|
addUseEnvironmentOptions(yargs, true);
|
|
59
63
|
|
|
60
64
|
yargs.positional('tableId', {
|
|
61
|
-
describe:
|
|
65
|
+
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
|
|
62
66
|
type: 'string',
|
|
63
67
|
});
|
|
64
68
|
};
|
package/commands/hubdb/create.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
3
|
-
loadConfig,
|
|
4
|
-
validateConfig,
|
|
5
|
-
checkAndWarnGitInclusion,
|
|
6
|
-
} = require('@hubspot/cli-lib');
|
|
2
|
+
|
|
7
3
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
8
4
|
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
9
5
|
const { getCwd } = require('@hubspot/cli-lib/path');
|
|
10
6
|
const { createHubDbTable } = require('@hubspot/cli-lib/hubdb');
|
|
11
7
|
|
|
12
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
isFileValidJSON,
|
|
10
|
+
loadAndValidateOptions,
|
|
11
|
+
} = require('../../lib/validation');
|
|
13
12
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
14
13
|
const {
|
|
15
14
|
addConfigOptions,
|
|
16
15
|
addAccountOptions,
|
|
17
16
|
addUseEnvironmentOptions,
|
|
18
|
-
setLogLevel,
|
|
19
17
|
getAccountId,
|
|
20
18
|
} = require('../../lib/commonOpts');
|
|
21
|
-
const {
|
|
19
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
20
|
+
|
|
21
|
+
const i18nKey = 'cli.commands.hubdb.subcommands.create';
|
|
22
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
22
23
|
|
|
23
24
|
exports.command = 'create <src>';
|
|
24
|
-
exports.describe =
|
|
25
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
25
26
|
|
|
26
27
|
exports.handler = async options => {
|
|
27
|
-
const {
|
|
28
|
+
const { src } = options;
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
logDebugInfo(options);
|
|
31
|
-
loadConfig(configPath, options);
|
|
32
|
-
checkAndWarnGitInclusion();
|
|
30
|
+
await loadAndValidateOptions(options);
|
|
33
31
|
|
|
34
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
32
|
const accountId = getAccountId(options);
|
|
38
33
|
|
|
39
34
|
trackCommandUsage('hubdb-create', {}, accountId);
|
|
@@ -41,18 +36,26 @@ exports.handler = async options => {
|
|
|
41
36
|
try {
|
|
42
37
|
const filePath = path.resolve(getCwd(), src);
|
|
43
38
|
if (!isFileValidJSON(filePath)) {
|
|
44
|
-
process.exit(
|
|
39
|
+
process.exit(EXIT_CODES.ERROR);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
const table = await createHubDbTable(
|
|
48
43
|
accountId,
|
|
49
44
|
path.resolve(getCwd(), src)
|
|
50
45
|
);
|
|
51
|
-
logger.
|
|
52
|
-
|
|
46
|
+
logger.success(
|
|
47
|
+
i18n(`${i18nKey}.success.create`, {
|
|
48
|
+
accountId,
|
|
49
|
+
rowCount: table.rowCount,
|
|
50
|
+
tableId: table.tableId,
|
|
51
|
+
})
|
|
53
52
|
);
|
|
54
53
|
} catch (e) {
|
|
55
|
-
logger.error(
|
|
54
|
+
logger.error(
|
|
55
|
+
i18n(`${i18nKey}.errors.create`, {
|
|
56
|
+
src,
|
|
57
|
+
})
|
|
58
|
+
);
|
|
56
59
|
logErrorInstance(e);
|
|
57
60
|
}
|
|
58
61
|
};
|
|
@@ -63,7 +66,7 @@ exports.builder = yargs => {
|
|
|
63
66
|
addUseEnvironmentOptions(yargs, true);
|
|
64
67
|
|
|
65
68
|
yargs.positional('src', {
|
|
66
|
-
describe:
|
|
69
|
+
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
67
70
|
type: 'string',
|
|
68
71
|
});
|
|
69
72
|
};
|