@hubspot/cli 3.0.10-beta.12 → 3.0.10-beta.16
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 +1 -1
- package/bin/cli.js +0 -2
- package/commands/auth.js +3 -3
- package/commands/config/set/allowUsageTracking.js +2 -2
- package/commands/config/set/defaultAccount.js +2 -2
- package/commands/config/set/defaultMode.js +2 -2
- package/commands/create/api-sample.js +6 -2
- package/commands/create/function.js +3 -1
- package/commands/create/index.js +0 -1
- package/commands/create/module.js +1 -1
- package/commands/create/template.js +3 -1
- package/commands/functions/deploy.js +1 -1
- package/commands/init.js +2 -2
- package/commands/open.js +2 -2
- package/commands/project/create.js +4 -54
- package/commands/project/listBuilds.js +2 -2
- package/commands/project/logs.js +63 -51
- package/commands/project/watch.js +103 -0
- package/commands/project.js +2 -0
- package/commands/sandbox/create.js +2 -2
- package/commands/secrets/addSecret.js +1 -1
- package/commands/secrets/updateSecret.js +1 -1
- package/commands/server.js +2 -1
- package/lib/projects.js +3 -3
- 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} +10 -26
- package/lib/prompts/promptUtils.js +10 -0
- package/lib/prompts/{sandboxes.js → sandboxesPrompt.js} +5 -6
- package/lib/prompts/secretPrompt.js +25 -0
- package/lib/validation.js +2 -2
- package/package.json +4 -4
- package/commands/app/deploy.js +0 -110
- package/commands/app.js +0 -14
- package/commands/create/project.js +0 -32
- package/lib/prompts/projects.js +0 -43
- package/lib/secretPrompt.js +0 -22
package/commands/app/deploy.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const ora = require('ora');
|
|
2
|
-
const { getEnv } = require('@hubspot/cli-lib');
|
|
3
|
-
const {
|
|
4
|
-
logApiErrorInstance,
|
|
5
|
-
ApiErrorContext,
|
|
6
|
-
} = require('@hubspot/cli-lib/errorHandlers');
|
|
7
|
-
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
8
|
-
const { logger } = require('@hubspot/cli-lib/logger');
|
|
9
|
-
const { deployAppSync } = require('@hubspot/cli-lib/api/appPipeline');
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
getAccountId,
|
|
13
|
-
addUseEnvironmentOptions,
|
|
14
|
-
} = require('../../lib/commonOpts');
|
|
15
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
16
|
-
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
17
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
18
|
-
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
19
|
-
|
|
20
|
-
const i18nKey = 'cli.commands.app.subcommands.deploy';
|
|
21
|
-
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
22
|
-
|
|
23
|
-
const logServerlessBuildFailures = async errorDetails => {
|
|
24
|
-
const folderPaths = errorDetails.context.folderPath;
|
|
25
|
-
const buildLogUrls = errorDetails.context.serverlessBuildLogUrl;
|
|
26
|
-
for (let i = 0; i < buildLogUrls.length; i++) {
|
|
27
|
-
logger.log(`Building serverless functions in "${folderPaths[i]}":`);
|
|
28
|
-
await outputBuildLog(buildLogUrls[i]);
|
|
29
|
-
}
|
|
30
|
-
logger.error(
|
|
31
|
-
'Your app failed to build and deploy due to a problem building the serverless functions.'
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.command = 'deploy <path>';
|
|
36
|
-
exports.describe = false;
|
|
37
|
-
|
|
38
|
-
exports.handler = async options => {
|
|
39
|
-
await loadAndValidateOptions(options);
|
|
40
|
-
|
|
41
|
-
const { path: appPath } = options;
|
|
42
|
-
const accountId = getAccountId(options);
|
|
43
|
-
|
|
44
|
-
trackCommandUsage('app-deploy', {}, accountId);
|
|
45
|
-
|
|
46
|
-
let result;
|
|
47
|
-
|
|
48
|
-
const spinner = ora(
|
|
49
|
-
i18n(`${i18nKey}.building`, {
|
|
50
|
-
accountId,
|
|
51
|
-
appPath,
|
|
52
|
-
})
|
|
53
|
-
).start();
|
|
54
|
-
try {
|
|
55
|
-
result = await deployAppSync(accountId, appPath);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
spinner.fail();
|
|
58
|
-
if (error.response && error.response.body) {
|
|
59
|
-
const errorDetails = error.response.body;
|
|
60
|
-
if (
|
|
61
|
-
errorDetails.subCategory === 'PipelineErrors.SERVERLESS_BUILD_ERROR' &&
|
|
62
|
-
errorDetails.context &&
|
|
63
|
-
Array.isArray(errorDetails.context.serverlessBuildLogUrl)
|
|
64
|
-
) {
|
|
65
|
-
await logServerlessBuildFailures(errorDetails);
|
|
66
|
-
} else {
|
|
67
|
-
logApiErrorInstance(
|
|
68
|
-
error,
|
|
69
|
-
new ApiErrorContext({
|
|
70
|
-
accountId,
|
|
71
|
-
request: appPath,
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
logApiErrorInstance(
|
|
77
|
-
error,
|
|
78
|
-
new ApiErrorContext({
|
|
79
|
-
accountId,
|
|
80
|
-
request: appPath,
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
process.exit(EXIT_CODES.ERROR);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
spinner.succeed();
|
|
88
|
-
logger.success(
|
|
89
|
-
i18n(`${i18nKey}.success.deployed`, {
|
|
90
|
-
appUrl: `${getHubSpotWebsiteOrigin(getEnv())}/private-apps/${accountId}/${
|
|
91
|
-
result.appId
|
|
92
|
-
}`,
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
exports.builder = yargs => {
|
|
98
|
-
yargs.positional('path', {
|
|
99
|
-
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
100
|
-
type: 'string',
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
yargs.example([
|
|
104
|
-
['$0 app deploy /example-app', i18n(`${i18nKey}.examples.default`)],
|
|
105
|
-
]);
|
|
106
|
-
|
|
107
|
-
addUseEnvironmentOptions(yargs, true);
|
|
108
|
-
|
|
109
|
-
return yargs;
|
|
110
|
-
};
|
package/commands/app.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
2
|
-
const deploy = require('./app/deploy');
|
|
3
|
-
|
|
4
|
-
exports.command = 'app';
|
|
5
|
-
exports.describe = false;
|
|
6
|
-
|
|
7
|
-
exports.builder = yargs => {
|
|
8
|
-
addConfigOptions(yargs, true);
|
|
9
|
-
addAccountOptions(yargs, true);
|
|
10
|
-
|
|
11
|
-
yargs.command(deploy).demandCommand(1, '');
|
|
12
|
-
|
|
13
|
-
return yargs;
|
|
14
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const {
|
|
3
|
-
createProjectConfig,
|
|
4
|
-
createProjectTemplateFiles,
|
|
5
|
-
} = require('@hubspot/cli-lib/projects');
|
|
6
|
-
const { logger } = require('@hubspot/cli-lib/logger');
|
|
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';
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
hidden: true,
|
|
14
|
-
dest: ({ name, dest }) => path.join(dest || './', name),
|
|
15
|
-
execute: async ({ dest, name }) => {
|
|
16
|
-
const { label, description, template } = await createProjectPrompt({
|
|
17
|
-
label: name,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
createProjectConfig(dest, {
|
|
21
|
-
label,
|
|
22
|
-
description,
|
|
23
|
-
});
|
|
24
|
-
createProjectTemplateFiles(dest, template);
|
|
25
|
-
|
|
26
|
-
logger.success(
|
|
27
|
-
i18n(`${i18nKey}.success.projectCreated`, {
|
|
28
|
-
path: dest,
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
};
|
package/lib/prompts/projects.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const inquirer = require('inquirer');
|
|
2
|
-
const { PROJECT_TEMPLATE_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
3
|
-
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
4
|
-
|
|
5
|
-
const i18nKey = 'cli.lib.prompts.projects';
|
|
6
|
-
|
|
7
|
-
const createProjectPrompt = (promptOptions = {}) => {
|
|
8
|
-
const prompt = inquirer.createPromptModule();
|
|
9
|
-
return prompt([
|
|
10
|
-
{
|
|
11
|
-
type: 'list',
|
|
12
|
-
name: 'template',
|
|
13
|
-
message: i18n(`${i18nKey}.selectTemplate`),
|
|
14
|
-
default: PROJECT_TEMPLATE_TYPES.blank,
|
|
15
|
-
choices: Object.keys(PROJECT_TEMPLATE_TYPES),
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: 'label',
|
|
19
|
-
message: i18n(`${i18nKey}.enterLabel`),
|
|
20
|
-
validate(val) {
|
|
21
|
-
if (typeof val !== 'string') {
|
|
22
|
-
return i18n(`${i18nKey}.errors.invalidLabel`);
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
},
|
|
26
|
-
default: promptOptions.label || 'New project',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'description',
|
|
30
|
-
message: i18n(`${i18nKey}.enterDescription`),
|
|
31
|
-
validate(val) {
|
|
32
|
-
if (typeof val !== 'string') {
|
|
33
|
-
return i18n(`${i18nKey}.errors.invalidDescription`);
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
]);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
createProjectPrompt,
|
|
43
|
-
};
|
package/lib/secretPrompt.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const inquirer = require('inquirer');
|
|
2
|
-
|
|
3
|
-
const SECRET_VALUE_PROMPT = {
|
|
4
|
-
name: 'secretValue',
|
|
5
|
-
type: 'password',
|
|
6
|
-
mask: '*',
|
|
7
|
-
message: 'Enter a value for your secret',
|
|
8
|
-
validate(val) {
|
|
9
|
-
if (typeof val !== 'string') {
|
|
10
|
-
return 'You entered an invalid value. Please try again.';
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function secretValuePrompt() {
|
|
17
|
-
const prompt = inquirer.createPromptModule();
|
|
18
|
-
return prompt([SECRET_VALUE_PROMPT]);
|
|
19
|
-
}
|
|
20
|
-
module.exports = {
|
|
21
|
-
secretValuePrompt,
|
|
22
|
-
};
|