@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,32 +1,17 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateDefaultMode } = require('@hubspot/cli-lib/lib/config');
|
|
3
3
|
const inquirer = require('inquirer');
|
|
4
|
-
const {
|
|
5
|
-
Mode,
|
|
6
|
-
loadConfig,
|
|
7
|
-
validateConfig,
|
|
8
|
-
checkAndWarnGitInclusion,
|
|
9
|
-
} = require('@hubspot/cli-lib');
|
|
4
|
+
const { Mode } = require('@hubspot/cli-lib');
|
|
10
5
|
const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
|
|
11
6
|
|
|
12
|
-
const { getAccountId
|
|
7
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
13
8
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
14
|
-
const {
|
|
15
|
-
const {
|
|
9
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
10
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
16
11
|
|
|
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();
|
|
12
|
+
const i18nKey = 'cli.commands.config.subcommands.set.subcommands.defaultMode';
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
14
|
+
const ALL_MODES = Object.values(Mode);
|
|
30
15
|
|
|
31
16
|
const selectMode = async () => {
|
|
32
17
|
const { mode } = await inquirer.prompt([
|
|
@@ -35,7 +20,7 @@ const selectMode = async () => {
|
|
|
35
20
|
look: false,
|
|
36
21
|
name: 'mode',
|
|
37
22
|
pageSize: 20,
|
|
38
|
-
message:
|
|
23
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
39
24
|
choices: ALL_MODES,
|
|
40
25
|
default: Mode.publish,
|
|
41
26
|
},
|
|
@@ -45,10 +30,10 @@ const selectMode = async () => {
|
|
|
45
30
|
};
|
|
46
31
|
|
|
47
32
|
exports.command = 'default-mode [newDefault]';
|
|
48
|
-
exports.describe =
|
|
33
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
49
34
|
|
|
50
35
|
exports.handler = async options => {
|
|
51
|
-
loadAndValidateOptions(options);
|
|
36
|
+
await loadAndValidateOptions(options);
|
|
52
37
|
|
|
53
38
|
const accountId = getAccountId(options);
|
|
54
39
|
const { newMode: specifiedNewDefault } = options;
|
|
@@ -64,38 +49,34 @@ exports.handler = async options => {
|
|
|
64
49
|
) {
|
|
65
50
|
newDefault = specifiedNewDefault;
|
|
66
51
|
} else {
|
|
67
|
-
logger.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
logger.error(
|
|
53
|
+
i18n(`${i18nKey}.errors.invalidMode`, {
|
|
54
|
+
mode: specifiedNewDefault,
|
|
55
|
+
validModes: commaSeparatedValues(ALL_MODES),
|
|
56
|
+
})
|
|
71
57
|
);
|
|
72
58
|
newDefault = await selectMode();
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
updateDefaultMode(newDefault);
|
|
76
62
|
|
|
77
|
-
return logger.
|
|
63
|
+
return logger.success(
|
|
64
|
+
i18n(`${i18nKey}.success.modeUpdated`, {
|
|
65
|
+
mode: newDefault,
|
|
66
|
+
})
|
|
67
|
+
);
|
|
78
68
|
};
|
|
79
69
|
|
|
80
70
|
exports.builder = yargs => {
|
|
81
71
|
yargs.positional('newMode', {
|
|
82
|
-
describe:
|
|
72
|
+
describe: i18n(`${i18nKey}.positionals.newMode.describe`),
|
|
83
73
|
type: 'string',
|
|
84
74
|
});
|
|
85
75
|
|
|
86
76
|
yargs.example([
|
|
87
|
-
[
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
'$0 config set default-mode publish',
|
|
93
|
-
'Set the default mode in the config to "publish"',
|
|
94
|
-
],
|
|
95
|
-
[
|
|
96
|
-
'$0 config set default-mode draft',
|
|
97
|
-
'Set the default mode in the config to "draft"',
|
|
98
|
-
],
|
|
77
|
+
['$0 config set default-mode', i18n(`${i18nKey}.examples.default`)],
|
|
78
|
+
['$0 config set default-mode publish', i18n(`${i18nKey}.examples.publish`)],
|
|
79
|
+
['$0 config set default-mode draft', i18n(`${i18nKey}.examples.draft`)],
|
|
99
80
|
]);
|
|
100
81
|
|
|
101
82
|
return yargs;
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateHttpTimeout } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const {
|
|
4
|
-
loadConfig,
|
|
5
|
-
validateConfig,
|
|
6
|
-
checkAndWarnGitInclusion,
|
|
7
|
-
} = require('@hubspot/cli-lib');
|
|
8
3
|
|
|
9
|
-
const { getAccountId
|
|
4
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
10
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
11
|
-
const {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
setLogLevel(options);
|
|
16
|
-
logDebugInfo(options);
|
|
17
|
-
const { config: configPath } = options;
|
|
18
|
-
loadConfig(configPath, options);
|
|
19
|
-
checkAndWarnGitInclusion();
|
|
20
|
-
|
|
21
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
6
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
8
|
+
|
|
9
|
+
const i18nKey = 'cli.commands.config.subcommands.set.subcommands.httpTimeout';
|
|
25
10
|
|
|
26
11
|
exports.command = 'http-timeout [timeout]';
|
|
27
|
-
exports.describe =
|
|
12
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
28
13
|
|
|
29
14
|
exports.handler = async options => {
|
|
30
|
-
loadAndValidateOptions(options);
|
|
15
|
+
await loadAndValidateOptions(options);
|
|
31
16
|
|
|
32
17
|
const accountId = getAccountId(options);
|
|
33
18
|
const { timeout } = options;
|
|
@@ -36,21 +21,18 @@ exports.handler = async options => {
|
|
|
36
21
|
|
|
37
22
|
updateHttpTimeout(timeout);
|
|
38
23
|
|
|
39
|
-
return logger.
|
|
24
|
+
return logger.success(i18n(`${i18nKey}.success.timeoutUpdated`, { timeout }));
|
|
40
25
|
};
|
|
41
26
|
|
|
42
27
|
exports.builder = yargs => {
|
|
43
28
|
yargs.positional('timeout', {
|
|
44
|
-
describe:
|
|
29
|
+
describe: i18n(`${i18nKey}.positionals.timeout.describe`),
|
|
45
30
|
type: 'string',
|
|
46
31
|
default: 30000,
|
|
47
32
|
});
|
|
48
33
|
|
|
49
34
|
yargs.example([
|
|
50
|
-
[
|
|
51
|
-
'$0 config set http-timeout 30000',
|
|
52
|
-
'Set the http timeout value in the config to 30000ms',
|
|
53
|
-
],
|
|
35
|
+
['$0 config set http-timeout 30000', i18n(`${i18nKey}.examples.default`)],
|
|
54
36
|
]);
|
|
55
37
|
|
|
56
38
|
return yargs;
|
package/commands/config/set.js
CHANGED
|
@@ -3,9 +3,12 @@ const defaultAccount = require('./set/defaultAccount');
|
|
|
3
3
|
const defaultMode = require('./set/defaultMode');
|
|
4
4
|
const httpTimeout = require('./set/httpTimeout');
|
|
5
5
|
const allowUsageTracking = require('./set/allowUsageTracking');
|
|
6
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
7
|
+
|
|
8
|
+
const i18nKey = 'cli.commands.config.subcommands.set';
|
|
6
9
|
|
|
7
10
|
exports.command = 'set';
|
|
8
|
-
exports.describe =
|
|
11
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
9
12
|
|
|
10
13
|
exports.builder = yargs => {
|
|
11
14
|
addConfigOptions(yargs, true);
|
package/commands/config.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
2
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
2
3
|
const set = require('./config/set');
|
|
3
4
|
|
|
5
|
+
const i18nKey = 'cli.commands.config';
|
|
6
|
+
|
|
4
7
|
exports.command = 'config';
|
|
5
|
-
exports.describe =
|
|
8
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
6
9
|
|
|
7
10
|
exports.builder = yargs => {
|
|
8
11
|
addConfigOptions(yargs, true);
|
|
@@ -7,15 +7,16 @@ const ora = require('ora');
|
|
|
7
7
|
const { fetchJsonFromRepository } = require('@hubspot/cli-lib/github');
|
|
8
8
|
const { GITHUB_RELEASE_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
9
9
|
const { createProject } = require('@hubspot/cli-lib/projects');
|
|
10
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
11
|
+
|
|
12
|
+
const i18nKey = 'cli.commands.create.subcommands.apiSample';
|
|
10
13
|
|
|
11
14
|
module.exports = {
|
|
12
15
|
hidden: true,
|
|
13
16
|
dest: ({ dest }) => dest,
|
|
14
17
|
validate: ({ name }) => {
|
|
15
18
|
if (!name) {
|
|
16
|
-
logger.error(
|
|
17
|
-
"The 'name' argument is required when creating an API Sample."
|
|
18
|
-
);
|
|
19
|
+
logger.error(i18n(`${i18nKey}.errors.nameRequired`));
|
|
19
20
|
return false;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -31,7 +32,7 @@ module.exports = {
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
const downloadSpinner = ora(
|
|
35
|
+
const downloadSpinner = ora(i18n(`${i18nKey}.loading.apiSamples`));
|
|
35
36
|
downloadSpinner.start();
|
|
36
37
|
const samplesConfig = await fetchJsonFromRepository(
|
|
37
38
|
'sample-apps-list',
|
|
@@ -39,22 +40,21 @@ module.exports = {
|
|
|
39
40
|
);
|
|
40
41
|
downloadSpinner.stop();
|
|
41
42
|
if (!samplesConfig) {
|
|
42
|
-
logger.error(
|
|
43
|
-
`Currently there are no samples available, please, try again later.`
|
|
44
|
-
);
|
|
43
|
+
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
const { sampleType, sampleLanguage } = await createApiSamplePrompt(
|
|
48
47
|
samplesConfig
|
|
49
48
|
);
|
|
50
49
|
if (!sampleType || !sampleLanguage) {
|
|
51
|
-
logger.error(
|
|
52
|
-
`Currently there are no samples available, please, try again later.`
|
|
53
|
-
);
|
|
50
|
+
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
53
|
logger.info(
|
|
57
|
-
|
|
54
|
+
i18n(`${i18nKey}.info.sampleChosen`, {
|
|
55
|
+
sampleType,
|
|
56
|
+
sampleLanguage,
|
|
57
|
+
})
|
|
58
58
|
);
|
|
59
59
|
const created = await createProject(
|
|
60
60
|
filePath,
|
|
@@ -71,7 +71,9 @@ module.exports = {
|
|
|
71
71
|
fs.copySync(`${filePath}/.env.template`, `${filePath}/.env`);
|
|
72
72
|
}
|
|
73
73
|
logger.success(
|
|
74
|
-
|
|
74
|
+
i18n(`${i18nKey}.success.sampleCreated`, {
|
|
75
|
+
filePath,
|
|
76
|
+
})
|
|
75
77
|
);
|
|
76
78
|
}
|
|
77
79
|
},
|
|
@@ -2,6 +2,9 @@ const path = require('path');
|
|
|
2
2
|
const { createModulePrompt } = require('../../lib/createModulePrompt');
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
5
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
6
|
+
|
|
7
|
+
const i18nKey = 'cli.commands.create.subcommands.module';
|
|
5
8
|
|
|
6
9
|
const createModule = (moduleDefinition, name, dest) => {
|
|
7
10
|
const writeModuleMeta = ({ contentTypes, moduleLabel, global }, dest) => {
|
|
@@ -44,12 +47,24 @@ const createModule = (moduleDefinition, name, dest) => {
|
|
|
44
47
|
const folderName = name.endsWith('.module') ? name : `${name}.module`;
|
|
45
48
|
const destPath = path.join(dest, folderName);
|
|
46
49
|
if (fs.existsSync(destPath)) {
|
|
47
|
-
logger.error(
|
|
50
|
+
logger.error(
|
|
51
|
+
i18n(`${i18nKey}.errors.pathExists`, {
|
|
52
|
+
path: destPath,
|
|
53
|
+
})
|
|
54
|
+
);
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
50
|
-
logger.log(
|
|
57
|
+
logger.log(
|
|
58
|
+
i18n(`${i18nKey}.creatingPath`, {
|
|
59
|
+
path: destPath,
|
|
60
|
+
})
|
|
61
|
+
);
|
|
51
62
|
fs.mkdirp(destPath);
|
|
52
|
-
logger.log(
|
|
63
|
+
logger.log(
|
|
64
|
+
i18n(`${i18nKey}.creatingModule`, {
|
|
65
|
+
path: destPath,
|
|
66
|
+
})
|
|
67
|
+
);
|
|
53
68
|
fs.copySync(assetPath, destPath, { filter: moduleFileFilter });
|
|
54
69
|
};
|
|
55
70
|
|
|
@@ -57,9 +72,7 @@ module.exports = {
|
|
|
57
72
|
dest: ({ dest }) => dest,
|
|
58
73
|
validate: ({ name }) => {
|
|
59
74
|
if (!name) {
|
|
60
|
-
logger.error(
|
|
61
|
-
"The 'name' argument is required when creating a Custom Module."
|
|
62
|
-
);
|
|
75
|
+
logger.error(i18n(`${i18nKey}.errors.nameRequired`));
|
|
63
76
|
return false;
|
|
64
77
|
}
|
|
65
78
|
|
|
@@ -5,6 +5,9 @@ const {
|
|
|
5
5
|
} = require('@hubspot/cli-lib/projects');
|
|
6
6
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
7
7
|
const { createProjectPrompt } = require('../../lib/prompts/projects');
|
|
8
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
9
|
+
|
|
10
|
+
const i18nKey = 'cli.commands.create.subcommands.project';
|
|
8
11
|
|
|
9
12
|
module.exports = {
|
|
10
13
|
hidden: true,
|
|
@@ -20,6 +23,10 @@ module.exports = {
|
|
|
20
23
|
});
|
|
21
24
|
createProjectTemplateFiles(dest, template);
|
|
22
25
|
|
|
23
|
-
logger.success(
|
|
26
|
+
logger.success(
|
|
27
|
+
i18n(`${i18nKey}.success.projectCreated`, {
|
|
28
|
+
path: dest,
|
|
29
|
+
})
|
|
30
|
+
);
|
|
24
31
|
},
|
|
25
32
|
};
|
|
@@ -2,6 +2,9 @@ const { createTemplatePrompt } = require('../../lib/createTemplatePrompt');
|
|
|
2
2
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs-extra');
|
|
5
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
6
|
+
|
|
7
|
+
const i18nKey = 'cli.commands.create.subcommands.template';
|
|
5
8
|
|
|
6
9
|
const ASSET_PATHS = {
|
|
7
10
|
'page-template': path.resolve(__dirname, '../../defaults/page-template.html'),
|
|
@@ -33,12 +36,24 @@ const createTemplate = (name, dest, type = 'page-template') => {
|
|
|
33
36
|
const filename = name.endsWith('.html') ? name : `${name}.html`;
|
|
34
37
|
const filePath = path.join(dest, filename);
|
|
35
38
|
if (fs.existsSync(filePath)) {
|
|
36
|
-
logger.error(
|
|
39
|
+
logger.error(
|
|
40
|
+
i18n(`${i18nKey}.errors.pathExists`, {
|
|
41
|
+
path: filePath,
|
|
42
|
+
})
|
|
43
|
+
);
|
|
37
44
|
return;
|
|
38
45
|
}
|
|
39
|
-
logger.debug(
|
|
46
|
+
logger.debug(
|
|
47
|
+
i18n(`${i18nKey}.debug.creatingPath`, {
|
|
48
|
+
path: dest,
|
|
49
|
+
})
|
|
50
|
+
);
|
|
40
51
|
fs.mkdirp(dest);
|
|
41
|
-
logger.log(
|
|
52
|
+
logger.log(
|
|
53
|
+
i18n(`${i18nKey}.log.creatingFile`, {
|
|
54
|
+
path: filePath,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
42
57
|
fs.copySync(assetPath, filePath);
|
|
43
58
|
};
|
|
44
59
|
|
|
@@ -46,7 +61,7 @@ module.exports = {
|
|
|
46
61
|
dest: ({ dest }) => dest,
|
|
47
62
|
validate: ({ name }) => {
|
|
48
63
|
if (!name) {
|
|
49
|
-
logger.error(
|
|
64
|
+
logger.error(i18n(`${i18nKey}.errors.nameRequired`));
|
|
50
65
|
return false;
|
|
51
66
|
}
|
|
52
67
|
|
package/commands/create.js
CHANGED
|
@@ -31,13 +31,18 @@ const { logDebugInfo } = require('../lib/debugInfo');
|
|
|
31
31
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
32
32
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
33
33
|
const assets = require('./create/index');
|
|
34
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
35
|
+
|
|
36
|
+
const i18nKey = 'cli.commands.create';
|
|
34
37
|
|
|
35
38
|
const SUPPORTED_ASSET_TYPES = Object.keys(assets)
|
|
36
39
|
.filter(t => !assets[t].hidden)
|
|
37
40
|
.join(', ');
|
|
38
41
|
|
|
39
42
|
exports.command = 'create <type> [name] [dest]';
|
|
40
|
-
exports.describe =
|
|
43
|
+
exports.describe = i18n(`${i18nKey}.describe`, {
|
|
44
|
+
supportedAssetTypes: SUPPORTED_ASSET_TYPES,
|
|
45
|
+
});
|
|
41
46
|
|
|
42
47
|
exports.handler = async options => {
|
|
43
48
|
let { type: assetType, name, dest } = options;
|
|
@@ -48,14 +53,21 @@ exports.handler = async options => {
|
|
|
48
53
|
|
|
49
54
|
if (assetType === 'global-partial') {
|
|
50
55
|
logger.error(
|
|
51
|
-
|
|
56
|
+
i18n(`${i18nKey}.errors.deprecatedAssetType`, {
|
|
57
|
+
assetType,
|
|
58
|
+
newCommand: 'hs create template',
|
|
59
|
+
type: 'global partial',
|
|
60
|
+
})
|
|
52
61
|
);
|
|
53
62
|
return;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
if (!assetType || !assets[assetType]) {
|
|
57
66
|
logger.error(
|
|
58
|
-
|
|
67
|
+
i18n(`${i18nKey}.errors.unsupportedAssetType`, {
|
|
68
|
+
assetType,
|
|
69
|
+
supportedAssetTypes: SUPPORTED_ASSET_TYPES,
|
|
70
|
+
})
|
|
59
71
|
);
|
|
60
72
|
return;
|
|
61
73
|
}
|
|
@@ -67,7 +79,11 @@ exports.handler = async options => {
|
|
|
67
79
|
try {
|
|
68
80
|
await fs.ensureDir(dest);
|
|
69
81
|
} catch (e) {
|
|
70
|
-
logger.error(
|
|
82
|
+
logger.error(
|
|
83
|
+
i18n(`${i18nKey}.errors.unusablePath`, {
|
|
84
|
+
path: dest,
|
|
85
|
+
})
|
|
86
|
+
);
|
|
71
87
|
logFileSystemErrorInstance(e, {
|
|
72
88
|
filepath: dest,
|
|
73
89
|
write: true,
|
|
@@ -88,16 +104,15 @@ exports.handler = async options => {
|
|
|
88
104
|
|
|
89
105
|
exports.builder = yargs => {
|
|
90
106
|
yargs.positional('type', {
|
|
91
|
-
describe:
|
|
107
|
+
describe: i18n(`${i18nKey}.positionals.type.describe`),
|
|
92
108
|
type: 'string',
|
|
93
109
|
});
|
|
94
110
|
yargs.positional('name', {
|
|
95
|
-
describe:
|
|
111
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
96
112
|
type: 'string',
|
|
97
113
|
});
|
|
98
114
|
yargs.positional('dest', {
|
|
99
|
-
describe:
|
|
100
|
-
'Destination folder for the new asset, relative to your current working directory. If omitted, this argument will default to your current working directory.',
|
|
115
|
+
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
101
116
|
type: 'string',
|
|
102
117
|
});
|
|
103
118
|
|
|
@@ -1,58 +1,56 @@
|
|
|
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 { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
9
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isFileValidJSON,
|
|
6
|
+
loadAndValidateOptions,
|
|
7
|
+
} = require('../../lib/validation');
|
|
10
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
-
const {
|
|
12
|
-
const { logDebugInfo } = require('../../lib/debugInfo');
|
|
9
|
+
const { getAccountId } = require('../../lib/commonOpts');
|
|
13
10
|
const { batchCreateObjects } = require('@hubspot/cli-lib/api/customObject');
|
|
11
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
12
|
+
|
|
13
|
+
const i18nKey = 'cli.commands.customObject.subcommands.create';
|
|
14
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
14
15
|
|
|
15
16
|
exports.command = 'create <name> <definition>';
|
|
16
|
-
exports.describe =
|
|
17
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
18
|
|
|
18
19
|
exports.handler = async options => {
|
|
19
20
|
const { definition, name } = options;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
loadConfig(configPath);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
25
|
-
|
|
26
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
21
|
+
|
|
22
|
+
await loadAndValidateOptions(options);
|
|
23
|
+
|
|
29
24
|
const accountId = getAccountId(options);
|
|
30
25
|
|
|
31
26
|
trackCommandUsage('custom-object-batch-create', null, accountId);
|
|
32
27
|
|
|
33
28
|
const filePath = getAbsoluteFilePath(definition);
|
|
34
29
|
if (!isFileValidJSON(filePath)) {
|
|
35
|
-
process.exit(
|
|
30
|
+
process.exit(EXIT_CODES.ERROR);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
try {
|
|
39
34
|
await batchCreateObjects(accountId, name, filePath);
|
|
40
|
-
logger.success(`
|
|
35
|
+
logger.success(i18n(`${i18nKey}.success.objectsCreated`));
|
|
41
36
|
} catch (e) {
|
|
42
37
|
logErrorInstance(e, { accountId });
|
|
43
|
-
logger.error(
|
|
38
|
+
logger.error(
|
|
39
|
+
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
40
|
+
definition,
|
|
41
|
+
})
|
|
42
|
+
);
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
exports.builder = yargs => {
|
|
48
47
|
yargs.positional('name', {
|
|
49
|
-
describe:
|
|
48
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
50
49
|
type: 'string',
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
yargs.positional('definition', {
|
|
54
|
-
describe:
|
|
55
|
-
'Local path to the JSON file containing an array of object definitions',
|
|
53
|
+
describe: i18n(`${i18nKey}.positionals.definition.describe`),
|
|
56
54
|
type: 'string',
|
|
57
55
|
});
|
|
58
56
|
};
|
|
@@ -1,65 +1,67 @@
|
|
|
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 { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
9
|
-
const { validateAccount, isFileValidJSON } = require('../../../lib/validation');
|
|
10
|
-
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
11
4
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = require('../../../lib/
|
|
5
|
+
isFileValidJSON,
|
|
6
|
+
loadAndValidateOptions,
|
|
7
|
+
} = require('../../../lib/validation');
|
|
8
|
+
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
9
|
+
const { addTestingOptions, getAccountId } = require('../../../lib/commonOpts');
|
|
16
10
|
const { getEnv, isConfigFlagEnabled } = require('@hubspot/cli-lib/');
|
|
17
11
|
const { ENVIRONMENTS, ConfigFlags } = require('@hubspot/cli-lib/lib/constants');
|
|
18
|
-
const { logDebugInfo } = require('../../../lib/debugInfo');
|
|
19
12
|
const { createSchema } = require('@hubspot/cli-lib/api/schema');
|
|
20
13
|
const {
|
|
21
14
|
createSchema: createSchemaFromHubFile,
|
|
22
15
|
} = require('@hubspot/cli-lib/api/fileTransport');
|
|
23
16
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
17
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
18
|
+
|
|
19
|
+
const i18nKey =
|
|
20
|
+
'cli.commands.customObject.subcommands.schema.subcommands.create';
|
|
21
|
+
const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
24
22
|
|
|
25
23
|
exports.command = 'create <definition>';
|
|
26
|
-
exports.describe =
|
|
24
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
27
25
|
|
|
28
26
|
exports.handler = async options => {
|
|
29
27
|
const { definition } = options;
|
|
30
|
-
setLogLevel(options);
|
|
31
|
-
logDebugInfo(options);
|
|
32
|
-
const { config: configPath } = options;
|
|
33
|
-
loadConfig(configPath);
|
|
34
|
-
checkAndWarnGitInclusion();
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
29
|
+
await loadAndValidateOptions(options);
|
|
30
|
+
|
|
39
31
|
const accountId = getAccountId(options);
|
|
40
32
|
|
|
41
33
|
trackCommandUsage('custom-object-schema-create', null, accountId);
|
|
42
34
|
|
|
43
35
|
const filePath = getAbsoluteFilePath(definition);
|
|
44
36
|
if (!isFileValidJSON(filePath)) {
|
|
45
|
-
process.exit(
|
|
37
|
+
process.exit(EXIT_CODES.ERROR);
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
try {
|
|
49
41
|
if (isConfigFlagEnabled(ConfigFlags.USE_CUSTOM_OBJECT_HUBFILE)) {
|
|
50
42
|
await createSchemaFromHubFile(accountId, filePath);
|
|
51
|
-
logger.success(
|
|
43
|
+
logger.success(
|
|
44
|
+
i18n(`${i18nKey}.success.schemaCreated`, {
|
|
45
|
+
accountId,
|
|
46
|
+
})
|
|
47
|
+
);
|
|
52
48
|
} else {
|
|
53
49
|
const res = await createSchema(accountId, filePath);
|
|
54
50
|
logger.success(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
i18n(`${i18nKey}.success.schemaViewable`, {
|
|
52
|
+
url: `${getHubSpotWebsiteOrigin(
|
|
53
|
+
getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD
|
|
54
|
+
)}/contacts/${accountId}/objects/${res.objectTypeId}`,
|
|
55
|
+
})
|
|
58
56
|
);
|
|
59
57
|
}
|
|
60
58
|
} catch (e) {
|
|
61
59
|
logErrorInstance(e, { accountId });
|
|
62
|
-
logger.error(
|
|
60
|
+
logger.error(
|
|
61
|
+
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
62
|
+
definition,
|
|
63
|
+
})
|
|
64
|
+
);
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
|
|
@@ -67,7 +69,7 @@ exports.builder = yargs => {
|
|
|
67
69
|
addTestingOptions(yargs, true);
|
|
68
70
|
|
|
69
71
|
yargs.positional('definition', {
|
|
70
|
-
describe:
|
|
72
|
+
describe: i18n(`${i18nKey}.positionals.definition.describe`),
|
|
71
73
|
type: 'string',
|
|
72
74
|
});
|
|
73
75
|
};
|