@hubspot/cli 6.4.0 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +110 -16
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +4 -4
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -39
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/dependencyManagement.d.ts +4 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +11 -6
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +3 -2
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +12 -6
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
package/types/Prompts.js
ADDED
package/commands/accounts.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const { i18n } = require('../lib/lang');
|
|
6
|
-
const list = require('./accounts/list');
|
|
7
|
-
const rename = require('./accounts/rename');
|
|
8
|
-
const use = require('./accounts/use');
|
|
9
|
-
const info = require('./accounts/info');
|
|
10
|
-
const remove = require('./accounts/remove');
|
|
11
|
-
const clean = require('./accounts/clean');
|
|
12
|
-
const i18nKey = 'commands.accounts';
|
|
13
|
-
exports.command = 'accounts';
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
exports.builder = yargs => {
|
|
16
|
-
addConfigOptions(yargs);
|
|
17
|
-
addAccountOptions(yargs);
|
|
18
|
-
yargs
|
|
19
|
-
.command({
|
|
20
|
-
...list,
|
|
21
|
-
aliases: 'ls',
|
|
22
|
-
})
|
|
23
|
-
.command(rename)
|
|
24
|
-
.command(use)
|
|
25
|
-
.command(info)
|
|
26
|
-
.command(remove)
|
|
27
|
-
.command(clean)
|
|
28
|
-
.demandCommand(1, '');
|
|
29
|
-
return yargs;
|
|
30
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
|
-
const { retrieveDefaultModule } = require('@hubspot/local-dev-lib/cms/modules');
|
|
7
|
-
const { i18n } = require('../../lib/lang');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
-
const i18nKey = 'commands.cms.subcommands.reactModule';
|
|
11
|
-
exports.command = 'get-react-module [--name] [--dest]';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
exports.handler = async (options) => {
|
|
14
|
-
const { name, dest } = options;
|
|
15
|
-
trackCommandUsage('get-react-modules');
|
|
16
|
-
const destPath = dest
|
|
17
|
-
? path.join(dest, `${name}`)
|
|
18
|
-
: path.join(process.cwd(), `${name}`);
|
|
19
|
-
if (fs.existsSync(destPath)) {
|
|
20
|
-
logger.error(i18n(`${i18nKey}.errors.pathExists`, {
|
|
21
|
-
path: destPath,
|
|
22
|
-
}));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const modules = await retrieveDefaultModule(name, destPath);
|
|
27
|
-
if (!name) {
|
|
28
|
-
logger.group(i18n(`${i18nKey}.groupLabel`));
|
|
29
|
-
modules.forEach(module => {
|
|
30
|
-
logger.log(module.name);
|
|
31
|
-
});
|
|
32
|
-
logger.groupEnd(i18n(`${i18nKey}.groupLabel`));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
logger.success(i18n(`${i18nKey}.success.moduleDownloaded`, {
|
|
36
|
-
moduleName: name,
|
|
37
|
-
path: destPath,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
|
|
43
|
-
logger.error(i18n(`${i18nKey}.errors.invalidName`));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
logger.error(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.builder = yargs => {
|
|
51
|
-
yargs.option('name', {
|
|
52
|
-
describe: i18n(`${i18nKey}.options.name.describe`),
|
|
53
|
-
type: 'string',
|
|
54
|
-
});
|
|
55
|
-
yargs.option('dest', {
|
|
56
|
-
describe: i18n(`${i18nKey}.options.dest.describe`),
|
|
57
|
-
type: 'string',
|
|
58
|
-
});
|
|
59
|
-
return yargs;
|
|
60
|
-
};
|
package/commands/functions.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const list = require('./functions/list');
|
|
6
|
-
const deploy = require('./functions/deploy');
|
|
7
|
-
const server = require('./functions/server');
|
|
8
|
-
const { i18n } = require('../lib/lang');
|
|
9
|
-
const i18nKey = 'commands.functions';
|
|
10
|
-
exports.command = 'functions';
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
-
exports.builder = yargs => {
|
|
13
|
-
addConfigOptions(yargs);
|
|
14
|
-
addAccountOptions(yargs);
|
|
15
|
-
yargs
|
|
16
|
-
.command({
|
|
17
|
-
...list,
|
|
18
|
-
aliases: 'ls',
|
|
19
|
-
})
|
|
20
|
-
.command(deploy)
|
|
21
|
-
.command(server)
|
|
22
|
-
.demandCommand(1, '');
|
|
23
|
-
return yargs;
|
|
24
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
6
|
-
const { deleteSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
|
-
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
11
|
-
const { i18n } = require('../../lib/lang');
|
|
12
|
-
const i18nKey = 'commands.secrets.subcommands.delete';
|
|
13
|
-
exports.command = 'delete <name>';
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
exports.handler = async (options) => {
|
|
16
|
-
const { name: secretName } = options;
|
|
17
|
-
await loadAndValidateOptions(options);
|
|
18
|
-
const accountId = getAccountId(options);
|
|
19
|
-
trackCommandUsage('secrets-delete', null, accountId);
|
|
20
|
-
try {
|
|
21
|
-
await deleteSecret(accountId, secretName);
|
|
22
|
-
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
23
|
-
accountIdentifier: uiAccountDescription(accountId),
|
|
24
|
-
secretName,
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
logger.error(i18n(`${i18nKey}.errors.delete`, {
|
|
29
|
-
secretName,
|
|
30
|
-
}));
|
|
31
|
-
logError(err, new ApiErrorContext({
|
|
32
|
-
request: 'delete a secret',
|
|
33
|
-
accountId,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.builder = yargs => {
|
|
38
|
-
addConfigOptions(yargs);
|
|
39
|
-
addAccountOptions(yargs);
|
|
40
|
-
addUseEnvironmentOptions(yargs);
|
|
41
|
-
yargs.positional('name', {
|
|
42
|
-
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
43
|
-
type: 'string',
|
|
44
|
-
});
|
|
45
|
-
return yargs;
|
|
46
|
-
};
|
package/commands/secrets.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
-
const addSecretCommand = require('./secrets/addSecret');
|
|
6
|
-
const listSecretsCommand = require('./secrets/listSecrets');
|
|
7
|
-
const deleteSecretCommand = require('./secrets/deleteSecret');
|
|
8
|
-
const updateSecretCommand = require('./secrets/updateSecret');
|
|
9
|
-
const { i18n } = require('../lib/lang');
|
|
10
|
-
const i18nKey = 'commands.secrets';
|
|
11
|
-
exports.command = 'secrets';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
exports.builder = yargs => {
|
|
14
|
-
addConfigOptions(yargs);
|
|
15
|
-
addAccountOptions(yargs);
|
|
16
|
-
yargs
|
|
17
|
-
.command(listSecretsCommand)
|
|
18
|
-
.command(addSecretCommand)
|
|
19
|
-
.command(updateSecretCommand)
|
|
20
|
-
.command(deleteSecretCommand)
|
|
21
|
-
.demandCommand(1, '');
|
|
22
|
-
return yargs;
|
|
23
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { getProjectConfig, ensureProjectExists } = require('./projects');
|
|
5
|
-
const { fetchProjectComponentsMetadata, } = require('@hubspot/local-dev-lib/api/projects');
|
|
6
|
-
const { i18n } = require('./lang');
|
|
7
|
-
const { uiLink } = require('./ui');
|
|
8
|
-
const i18nKey = 'commands.project.subcommands.logs';
|
|
9
|
-
class ProjectLogsManager {
|
|
10
|
-
reset() {
|
|
11
|
-
Object.keys(this).forEach(key => {
|
|
12
|
-
if (Object.hasOwn(this, key)) {
|
|
13
|
-
this[key] = undefined;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
async init(accountId) {
|
|
18
|
-
const { projectConfig } = await getProjectConfig();
|
|
19
|
-
if (!projectConfig || !projectConfig.name) {
|
|
20
|
-
throw new Error(i18n(`${i18nKey}.errors.noProjectConfig`));
|
|
21
|
-
}
|
|
22
|
-
const { name: projectName } = projectConfig;
|
|
23
|
-
this.projectName = projectName;
|
|
24
|
-
this.accountId = accountId;
|
|
25
|
-
this.functions = [];
|
|
26
|
-
const { project } = await ensureProjectExists(this.accountId, this.projectName, {
|
|
27
|
-
allowCreate: false,
|
|
28
|
-
});
|
|
29
|
-
if (!project ||
|
|
30
|
-
!project.deployedBuild ||
|
|
31
|
-
!project.deployedBuild.subbuildStatuses) {
|
|
32
|
-
throw new Error(i18n(`${i18nKey}.errors.failedToFetchProjectDetails`));
|
|
33
|
-
}
|
|
34
|
-
this.projectId = project.id;
|
|
35
|
-
await this.fetchFunctionDetails();
|
|
36
|
-
}
|
|
37
|
-
async fetchFunctionDetails() {
|
|
38
|
-
if (!this.projectId) {
|
|
39
|
-
throw new Error(i18n(`${i18nKey}.errors.noProjectConfig`));
|
|
40
|
-
}
|
|
41
|
-
const { data: { topLevelComponentMetadata }, } = await fetchProjectComponentsMetadata(this.accountId, this.projectId);
|
|
42
|
-
const apps = topLevelComponentMetadata.filter(componentMetadata => {
|
|
43
|
-
const { type } = componentMetadata;
|
|
44
|
-
return type && type.name === 'PRIVATE_APP';
|
|
45
|
-
});
|
|
46
|
-
if (!this.functions) {
|
|
47
|
-
this.functions = [];
|
|
48
|
-
}
|
|
49
|
-
apps.forEach(app => {
|
|
50
|
-
this.functions.push(...app.featureComponents.filter(component => component.type.name === 'APP_FUNCTION'));
|
|
51
|
-
});
|
|
52
|
-
if (this.functions.length === 0) {
|
|
53
|
-
throw new Error(i18n(`${i18nKey}.errors.noFunctionsInProject`, {
|
|
54
|
-
link: uiLink(i18n(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
getFunctionNames() {
|
|
59
|
-
if (!this.functions) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
return this.functions.map(serverlessFunction => serverlessFunction.componentName);
|
|
63
|
-
}
|
|
64
|
-
setFunction(functionName) {
|
|
65
|
-
if (!this.functions) {
|
|
66
|
-
throw new Error(i18n(`${i18nKey}.errors.noFunctionsInProject`, {
|
|
67
|
-
link: uiLink(i18n(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
|
|
68
|
-
}), {
|
|
69
|
-
projectName: this.projectName,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
this.selectedFunction = this.functions.find(serverlessFunction => serverlessFunction.componentName === functionName);
|
|
73
|
-
if (!this.selectedFunction) {
|
|
74
|
-
throw new Error(i18n(`${i18nKey}.errors.noFunctionWithName`, { name: functionName }));
|
|
75
|
-
}
|
|
76
|
-
this.functionName = functionName;
|
|
77
|
-
if (!this.selectedFunction.deployOutput) {
|
|
78
|
-
throw new Error(i18n(`${i18nKey}.errors.functionNotDeployed`, { name: functionName }));
|
|
79
|
-
}
|
|
80
|
-
this.appId = this.selectedFunction.deployOutput.appId;
|
|
81
|
-
if (this.selectedFunction.deployOutput.endpoint) {
|
|
82
|
-
this.endpointName = this.selectedFunction.deployOutput.endpoint.path;
|
|
83
|
-
this.method = this.selectedFunction.deployOutput.endpoint.method;
|
|
84
|
-
this.isPublicFunction = true;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this.isPublicFunction = false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
module.exports = new ProjectLogsManager();
|
package/lib/projectStructure.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const { walk } = require('@hubspot/local-dev-lib/fs');
|
|
7
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
|
-
const { logError } = require('./errorHandlers/index');
|
|
9
|
-
const COMPONENT_TYPES = Object.freeze({
|
|
10
|
-
privateApp: 'private-app',
|
|
11
|
-
publicApp: 'public-app',
|
|
12
|
-
hublTheme: 'hubl-theme',
|
|
13
|
-
});
|
|
14
|
-
const CONFIG_FILES = {
|
|
15
|
-
[COMPONENT_TYPES.privateApp]: 'app.json',
|
|
16
|
-
[COMPONENT_TYPES.publicApp]: 'public-app.json',
|
|
17
|
-
[COMPONENT_TYPES.hublTheme]: 'theme.json',
|
|
18
|
-
};
|
|
19
|
-
function getTypeFromConfigFile(configFile) {
|
|
20
|
-
for (const key in CONFIG_FILES) {
|
|
21
|
-
if (CONFIG_FILES[key] === configFile) {
|
|
22
|
-
return key;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
function loadConfigFile(configPath) {
|
|
28
|
-
if (configPath) {
|
|
29
|
-
try {
|
|
30
|
-
const source = fs.readFileSync(configPath);
|
|
31
|
-
const parsedConfig = JSON.parse(source);
|
|
32
|
-
return parsedConfig;
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
logger.debug(e);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
function getAppCardConfigs(appConfig, appPath) {
|
|
41
|
-
const cardConfigs = [];
|
|
42
|
-
let cards;
|
|
43
|
-
if (appConfig && appConfig.extensions && appConfig.extensions.crm) {
|
|
44
|
-
cards = appConfig.extensions.crm.cards;
|
|
45
|
-
}
|
|
46
|
-
if (cards) {
|
|
47
|
-
cards.forEach(({ file }) => {
|
|
48
|
-
if (typeof file === 'string') {
|
|
49
|
-
const cardConfigPath = path.join(appPath, file);
|
|
50
|
-
const cardConfig = loadConfigFile(cardConfigPath);
|
|
51
|
-
if (cardConfig) {
|
|
52
|
-
cardConfigs.push(cardConfig);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return cardConfigs;
|
|
58
|
-
}
|
|
59
|
-
function getIsLegacyApp(appConfig, appPath) {
|
|
60
|
-
const cardConfigs = getAppCardConfigs(appConfig, appPath);
|
|
61
|
-
if (!cardConfigs.length) {
|
|
62
|
-
// Assume any app that does not have any cards is not legacy
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
let hasAnyReactExtensions = false;
|
|
66
|
-
cardConfigs.forEach(cardConfig => {
|
|
67
|
-
if (!hasAnyReactExtensions) {
|
|
68
|
-
const isReactExtension = cardConfig &&
|
|
69
|
-
!!cardConfig.data &&
|
|
70
|
-
!!cardConfig.data.module &&
|
|
71
|
-
!!cardConfig.data.module.file;
|
|
72
|
-
hasAnyReactExtensions = isReactExtension;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return !hasAnyReactExtensions;
|
|
76
|
-
}
|
|
77
|
-
async function findProjectComponents(projectSourceDir) {
|
|
78
|
-
const components = [];
|
|
79
|
-
let projectFiles = [];
|
|
80
|
-
try {
|
|
81
|
-
projectFiles = await walk(projectSourceDir);
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
logError(e);
|
|
85
|
-
}
|
|
86
|
-
projectFiles.forEach(projectFile => {
|
|
87
|
-
// Find app components
|
|
88
|
-
const { base, dir } = path.parse(projectFile);
|
|
89
|
-
if (Object.values(CONFIG_FILES).includes(base)) {
|
|
90
|
-
const parsedAppConfig = loadConfigFile(projectFile);
|
|
91
|
-
if (parsedAppConfig) {
|
|
92
|
-
const isLegacy = getIsLegacyApp(parsedAppConfig, dir);
|
|
93
|
-
const isHublTheme = base === CONFIG_FILES[COMPONENT_TYPES.hublTheme];
|
|
94
|
-
components.push({
|
|
95
|
-
type: getTypeFromConfigFile(base),
|
|
96
|
-
config: parsedAppConfig,
|
|
97
|
-
runnable: !isLegacy && !isHublTheme,
|
|
98
|
-
path: dir,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return components;
|
|
104
|
-
}
|
|
105
|
-
function getProjectComponentTypes(components) {
|
|
106
|
-
const projectContents = {};
|
|
107
|
-
components.forEach(({ type }) => (projectContents[type] = true));
|
|
108
|
-
return projectContents;
|
|
109
|
-
}
|
|
110
|
-
module.exports = {
|
|
111
|
-
CONFIG_FILES,
|
|
112
|
-
COMPONENT_TYPES,
|
|
113
|
-
findProjectComponents,
|
|
114
|
-
getAppCardConfigs,
|
|
115
|
-
getProjectComponentTypes,
|
|
116
|
-
};
|
package/lib/projects.d.ts
DELETED