@hubspot/cli 3.0.10-beta.6 → 3.0.10
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 +7 -1
- package/bin/cli.js +3 -4
- package/commands/accounts/list.js +18 -26
- package/commands/accounts/rename.js +13 -24
- package/commands/accounts.js +4 -1
- package/commands/auth.js +33 -16
- package/commands/config/set/allowUsageTracking.js +17 -33
- package/commands/config/set/defaultAccount.js +24 -34
- package/commands/config/set/defaultMode.js +25 -44
- 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 +20 -14
- package/commands/create/function.js +3 -1
- package/commands/create/index.js +0 -1
- package/commands/create/module.js +20 -7
- package/commands/create/template.js +22 -5
- package/commands/create/website-theme.js +12 -1
- 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 +25 -13
- package/commands/lint.js +14 -23
- package/commands/list.js +19 -25
- package/commands/logs.js +23 -44
- package/commands/mv.js +21 -25
- package/commands/open.js +9 -7
- package/commands/project/create.js +26 -42
- package/commands/project/deploy.js +35 -36
- package/commands/project/listBuilds.js +160 -0
- package/commands/project/logs.js +87 -79
- package/commands/project/upload.js +74 -78
- package/commands/project/watch.js +103 -0
- package/commands/project.js +5 -6
- package/commands/remove.js +12 -20
- package/commands/sandbox/create.js +18 -13
- package/commands/secrets/addSecret.js +19 -22
- package/commands/secrets/deleteSecret.js +18 -21
- package/commands/secrets/listSecrets.js +10 -19
- package/commands/secrets/updateSecret.js +19 -22
- package/commands/secrets.js +4 -1
- package/commands/server.js +15 -6
- 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/commonOpts.js +14 -11
- package/lib/enums/exitCodes.js +14 -0
- package/lib/links.js +0 -10
- package/lib/projects.js +121 -77
- package/lib/{createApiSamplePrompt.js → prompts/createApiSamplePrompt.js} +10 -11
- package/lib/{createFunctionPrompt.js → prompts/createFunctionPrompt.js} +27 -21
- package/lib/{createModulePrompt.js → prompts/createModulePrompt.js} +12 -9
- package/lib/prompts/createProjectPrompt.js +68 -0
- package/lib/{createTemplatePrompt.js → prompts/createTemplatePrompt.js} +7 -4
- package/lib/prompts/folderOverwritePrompt.js +17 -0
- package/lib/{prompts.js → prompts/personalAccessKeyPrompt.js} +25 -42
- package/lib/prompts/promptUtils.js +10 -0
- package/lib/prompts/sandboxesPrompt.js +24 -0
- package/lib/prompts/secretPrompt.js +25 -0
- package/lib/serverlessLogs.js +4 -3
- package/lib/ui.js +48 -0
- package/lib/validation.js +4 -3
- package/package.json +8 -7
- package/commands/app/deploy.js +0 -116
- package/commands/app.js +0 -14
- package/commands/create/project.js +0 -25
- package/lib/prompts/projects.js +0 -40
- package/lib/prompts/sandboxes.js +0 -22
- package/lib/secretPrompt.js +0 -22
|
@@ -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);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
1
|
+
const {
|
|
2
|
+
createApiSamplePrompt,
|
|
3
|
+
} = require('../../lib/prompts/createApiSamplePrompt');
|
|
4
|
+
const {
|
|
5
|
+
folderOverwritePrompt,
|
|
6
|
+
} = require('../../lib/prompts/folderOverwritePrompt');
|
|
3
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
4
8
|
const path = require('path');
|
|
5
9
|
const fs = require('fs-extra');
|
|
@@ -7,15 +11,16 @@ const ora = require('ora');
|
|
|
7
11
|
const { fetchJsonFromRepository } = require('@hubspot/cli-lib/github');
|
|
8
12
|
const { GITHUB_RELEASE_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
9
13
|
const { createProject } = require('@hubspot/cli-lib/projects');
|
|
14
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
15
|
+
|
|
16
|
+
const i18nKey = 'cli.commands.create.subcommands.apiSample';
|
|
10
17
|
|
|
11
18
|
module.exports = {
|
|
12
19
|
hidden: true,
|
|
13
20
|
dest: ({ dest }) => dest,
|
|
14
21
|
validate: ({ name }) => {
|
|
15
22
|
if (!name) {
|
|
16
|
-
logger.error(
|
|
17
|
-
"The 'name' argument is required when creating an API Sample."
|
|
18
|
-
);
|
|
23
|
+
logger.error(i18n(`${i18nKey}.errors.nameRequired`));
|
|
19
24
|
return false;
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -31,7 +36,7 @@ module.exports = {
|
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
|
-
const downloadSpinner = ora(
|
|
39
|
+
const downloadSpinner = ora(i18n(`${i18nKey}.loading.apiSamples`));
|
|
35
40
|
downloadSpinner.start();
|
|
36
41
|
const samplesConfig = await fetchJsonFromRepository(
|
|
37
42
|
'sample-apps-list',
|
|
@@ -39,22 +44,21 @@ module.exports = {
|
|
|
39
44
|
);
|
|
40
45
|
downloadSpinner.stop();
|
|
41
46
|
if (!samplesConfig) {
|
|
42
|
-
logger.error(
|
|
43
|
-
`Currently there are no samples available, please, try again later.`
|
|
44
|
-
);
|
|
47
|
+
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
const { sampleType, sampleLanguage } = await createApiSamplePrompt(
|
|
48
51
|
samplesConfig
|
|
49
52
|
);
|
|
50
53
|
if (!sampleType || !sampleLanguage) {
|
|
51
|
-
logger.error(
|
|
52
|
-
`Currently there are no samples available, please, try again later.`
|
|
53
|
-
);
|
|
54
|
+
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
logger.info(
|
|
57
|
-
|
|
58
|
+
i18n(`${i18nKey}.info.sampleChosen`, {
|
|
59
|
+
sampleType,
|
|
60
|
+
sampleLanguage,
|
|
61
|
+
})
|
|
58
62
|
);
|
|
59
63
|
const created = await createProject(
|
|
60
64
|
filePath,
|
|
@@ -71,7 +75,9 @@ module.exports = {
|
|
|
71
75
|
fs.copySync(`${filePath}/.env.template`, `${filePath}/.env`);
|
|
72
76
|
}
|
|
73
77
|
logger.success(
|
|
74
|
-
|
|
78
|
+
i18n(`${i18nKey}.success.sampleCreated`, {
|
|
79
|
+
filePath,
|
|
80
|
+
})
|
|
75
81
|
);
|
|
76
82
|
}
|
|
77
83
|
},
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { createFunction } = require('@hubspot/cli-lib/functions');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
createFunctionPrompt,
|
|
4
|
+
} = require('../../lib/prompts/createFunctionPrompt');
|
|
3
5
|
|
|
4
6
|
module.exports = {
|
|
5
7
|
dest: ({ name }) => name,
|
package/commands/create/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const { createModulePrompt } = require('../../lib/createModulePrompt');
|
|
2
|
+
const { createModulePrompt } = require('../../lib/prompts/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
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
createTemplatePrompt,
|
|
3
|
+
} = require('../../lib/prompts/createTemplatePrompt');
|
|
2
4
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
3
5
|
const path = require('path');
|
|
4
6
|
const fs = require('fs-extra');
|
|
7
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
8
|
+
|
|
9
|
+
const i18nKey = 'cli.commands.create.subcommands.template';
|
|
5
10
|
|
|
6
11
|
const ASSET_PATHS = {
|
|
7
12
|
'page-template': path.resolve(__dirname, '../../defaults/page-template.html'),
|
|
@@ -33,12 +38,24 @@ const createTemplate = (name, dest, type = 'page-template') => {
|
|
|
33
38
|
const filename = name.endsWith('.html') ? name : `${name}.html`;
|
|
34
39
|
const filePath = path.join(dest, filename);
|
|
35
40
|
if (fs.existsSync(filePath)) {
|
|
36
|
-
logger.error(
|
|
41
|
+
logger.error(
|
|
42
|
+
i18n(`${i18nKey}.errors.pathExists`, {
|
|
43
|
+
path: filePath,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
37
46
|
return;
|
|
38
47
|
}
|
|
39
|
-
logger.debug(
|
|
48
|
+
logger.debug(
|
|
49
|
+
i18n(`${i18nKey}.debug.creatingPath`, {
|
|
50
|
+
path: dest,
|
|
51
|
+
})
|
|
52
|
+
);
|
|
40
53
|
fs.mkdirp(dest);
|
|
41
|
-
logger.log(
|
|
54
|
+
logger.log(
|
|
55
|
+
i18n(`${i18nKey}.log.creatingFile`, {
|
|
56
|
+
path: filePath,
|
|
57
|
+
})
|
|
58
|
+
);
|
|
42
59
|
fs.copySync(assetPath, filePath);
|
|
43
60
|
};
|
|
44
61
|
|
|
@@ -46,7 +63,7 @@ module.exports = {
|
|
|
46
63
|
dest: ({ dest }) => dest,
|
|
47
64
|
validate: ({ name }) => {
|
|
48
65
|
if (!name) {
|
|
49
|
-
logger.error(
|
|
66
|
+
logger.error(i18n(`${i18nKey}.errors.nameRequired`));
|
|
50
67
|
return false;
|
|
51
68
|
}
|
|
52
69
|
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
const { createProject } = require('@hubspot/cli-lib/projects');
|
|
2
|
+
const { GITHUB_RELEASE_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
3
|
+
const { getIsInProject } = require('../../lib/projects');
|
|
4
|
+
|
|
5
|
+
const PROJECT_BOILERPLATE_REF = 'cms-boilerplate-developer-projects';
|
|
2
6
|
|
|
3
7
|
module.exports = {
|
|
4
8
|
dest: ({ name, assetType }) => name || assetType,
|
|
5
|
-
execute: ({ dest, assetType, options }) => {
|
|
9
|
+
execute: async ({ dest, assetType, options }) => {
|
|
10
|
+
const isInProject = await getIsInProject(dest);
|
|
11
|
+
|
|
12
|
+
if (isInProject) {
|
|
13
|
+
options.ref = PROJECT_BOILERPLATE_REF;
|
|
14
|
+
// releaseType has to be 'REPOSITORY' to download a specific branch
|
|
15
|
+
options.releaseType = GITHUB_RELEASE_TYPES.REPOSITORY;
|
|
16
|
+
}
|
|
6
17
|
createProject(dest, assetType, 'cms-theme-boilerplate', 'src', options);
|
|
7
18
|
},
|
|
8
19
|
};
|
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
|
};
|
|
@@ -1,51 +1,51 @@
|
|
|
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
|
|
|
9
|
-
const {
|
|
4
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
10
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
11
|
-
const {
|
|
12
|
-
const { logDebugInfo } = require('../../../lib/debugInfo');
|
|
6
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
13
7
|
const { deleteSchema } = require('@hubspot/cli-lib/api/schema');
|
|
8
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
9
|
+
|
|
10
|
+
const i18nKey =
|
|
11
|
+
'cli.commands.customObject.subcommands.schema.subcommands.delete';
|
|
14
12
|
|
|
15
13
|
exports.command = 'delete <name>';
|
|
16
|
-
exports.describe =
|
|
14
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
15
|
|
|
18
16
|
exports.handler = async options => {
|
|
19
17
|
let { name } = options;
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
logDebugInfo(options);
|
|
23
|
-
loadConfig(options.config);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
19
|
+
await loadAndValidateOptions(options);
|
|
25
20
|
|
|
26
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
21
|
const accountId = getAccountId(options);
|
|
30
22
|
|
|
31
23
|
trackCommandUsage('custom-object-schema-delete', null, accountId);
|
|
32
24
|
|
|
33
25
|
try {
|
|
34
26
|
await deleteSchema(accountId, name);
|
|
35
|
-
logger.success(
|
|
27
|
+
logger.success(
|
|
28
|
+
i18n(`${i18nKey}.success.delete`, {
|
|
29
|
+
name,
|
|
30
|
+
})
|
|
31
|
+
);
|
|
36
32
|
} catch (e) {
|
|
37
33
|
logErrorInstance(e);
|
|
38
|
-
logger.error(
|
|
34
|
+
logger.error(
|
|
35
|
+
i18n(`${i18nKey}.errors.delete`, {
|
|
36
|
+
name,
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
exports.builder = yargs => {
|
|
43
43
|
yargs.example([
|
|
44
|
-
['$0 schema delete schemaName',
|
|
44
|
+
['$0 schema delete schemaName', i18n(`${i18nKey}.examples.default`)],
|
|
45
45
|
]);
|
|
46
46
|
|
|
47
47
|
yargs.positional('name', {
|
|
48
|
-
describe:
|
|
48
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
49
49
|
type: 'string',
|
|
50
50
|
});
|
|
51
51
|
};
|