@hubspot/cli 7.5.11-experimental.0 → 7.7.0-experimental.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 +5 -6
- package/bin/hsmcp.d.ts +2 -0
- package/bin/hsmcp.js +13 -0
- package/commands/account/auth.d.ts +3 -7
- package/commands/account/auth.js +19 -9
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +16 -9
- package/commands/account/createOverride.d.ts +3 -7
- package/commands/account/createOverride.js +23 -6
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +13 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +15 -8
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +21 -9
- package/commands/account/removeOverride.d.ts +3 -7
- package/commands/account/removeOverride.js +23 -6
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +14 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +35 -58
- package/commands/app/migrate.d.ts +1 -2
- package/commands/app/migrate.js +7 -8
- package/commands/app/secret/add.d.ts +7 -0
- package/commands/app/secret/add.js +64 -0
- package/commands/app/secret/delete.d.ts +8 -0
- package/commands/app/secret/delete.js +87 -0
- package/commands/app/secret/list.d.ts +6 -0
- package/commands/app/secret/list.js +64 -0
- package/commands/app/secret/update.d.ts +7 -0
- package/commands/app/secret/update.js +77 -0
- package/commands/app/secret.d.ts +3 -0
- package/commands/app/secret.js +30 -0
- package/commands/app.d.ts +2 -5
- package/commands/app.js +12 -8
- package/commands/auth.d.ts +3 -7
- package/commands/auth.js +12 -5
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +129 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +24 -15
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +25 -12
- package/commands/config/migrate.d.ts +3 -7
- package/commands/config/migrate.js +25 -15
- package/commands/config/set.d.ts +5 -6
- package/commands/config/set.js +38 -14
- package/commands/config.d.ts +3 -4
- package/commands/config.js +20 -44
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -38
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +64 -74
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +17 -10
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +17 -10
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +17 -10
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +20 -45
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +32 -21
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +40 -47
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -33
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +20 -41
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +24 -10
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +17 -10
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +17 -10
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +17 -10
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +17 -10
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +23 -45
- package/commands/init.d.ts +3 -7
- package/commands/init.js +12 -5
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +44 -43
- package/commands/list.d.ts +3 -7
- package/commands/list.js +19 -11
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -44
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -27
- package/commands/module.d.ts +3 -1
- package/commands/module.js +22 -10
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +19 -11
- package/commands/open.d.ts +3 -7
- package/commands/open.js +19 -11
- package/commands/project/cloneApp.d.ts +1 -1
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.js +3 -3
- package/commands/project/deploy.d.ts +1 -0
- package/commands/project/deploy.js +40 -12
- package/commands/project/dev/index.d.ts +1 -4
- package/commands/project/dev/index.js +48 -16
- package/commands/project/dev/unifiedFlow.d.ts +2 -1
- package/commands/project/dev/unifiedFlow.js +85 -30
- package/commands/project/migrate.d.ts +1 -0
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +209 -0
- package/commands/project/profile/delete.d.ts +6 -0
- package/commands/project/profile/delete.js +123 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +1 -0
- package/commands/project/upload.js +38 -8
- package/commands/project/validate.d.ts +4 -0
- package/commands/project/validate.js +53 -0
- package/commands/project.js +4 -0
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +19 -11
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +18 -11
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +18 -11
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +20 -43
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +17 -10
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +17 -10
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +17 -10
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +17 -10
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +25 -48
- package/commands/setupMcp.d.ts +8 -0
- package/commands/setupMcp.js +229 -0
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +14 -6
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +17 -10
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +16 -9
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +23 -46
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +118 -97
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +76 -65
- package/lang/en.d.ts +838 -574
- package/lang/en.js +630 -373
- package/lang/en.lyaml +30 -23
- package/lib/accountTypes.js +2 -1
- package/lib/app/migrate.d.ts +23 -0
- package/lib/app/migrate.js +14 -3
- package/lib/app/migrate_legacy.js +7 -7
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/configMigrate.js +24 -10
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -46
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +7 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +13 -39
- package/lib/doctor/Doctor.js +2 -1
- package/lib/filesystem.d.ts +1 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +8 -0
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/projectProfiles.d.ts +6 -0
- package/lib/projectProfiles.js +65 -0
- package/lib/projects/buildAndDeploy.js +17 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +26 -0
- package/lib/projects/localDev/AppDevModeInterface.js +156 -0
- package/lib/projects/localDev/DevServerManagerV2.d.ts +11 -22
- package/lib/projects/localDev/DevServerManagerV2.js +19 -15
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +158 -0
- package/lib/projects/localDev/LocalDevManager.js +12 -5
- package/lib/projects/localDev/LocalDevProcess.d.ts +27 -0
- package/lib/projects/localDev/LocalDevProcess.js +171 -0
- package/lib/projects/localDev/LocalDevState.d.ts +37 -0
- package/lib/projects/localDev/LocalDevState.js +78 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +56 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +17 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +92 -0
- package/lib/projects/localDev/helpers.d.ts +3 -2
- package/lib/projects/localDev/helpers.js +32 -2
- package/lib/projects/upload.d.ts +2 -1
- package/lib/projects/upload.js +2 -2
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/installAppPrompt.d.ts +1 -0
- package/lib/prompts/installAppPrompt.js +35 -0
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +6 -6
- package/lib/prompts/promptUtils.d.ts +2 -1
- package/lib/prompts/promptUtils.js +2 -1
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -8
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/index.js +4 -1
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +4 -0
- package/lib/yargsUtils.js +6 -0
- package/mcp-server/index.d.ts +1 -0
- package/mcp-server/index.js +17 -0
- package/mcp-server/mcpLoader.d.ts +5 -0
- package/mcp-server/mcpLoader.js +24 -0
- package/mcp-server/tools/ExplainProjectStructureTool.d.ts +33 -0
- package/mcp-server/tools/ExplainProjectStructureTool.js +266 -0
- package/mcp-server/tools/GenerateAppComponentTool.d.ts +99 -0
- package/mcp-server/tools/GenerateAppComponentTool.js +193 -0
- package/mcp-server/tools/GenerateCardComponentTool.d.ts +74 -0
- package/mcp-server/tools/GenerateCardComponentTool.js +146 -0
- package/mcp-server/tools/GenerateProjectConfigTool.d.ts +32 -0
- package/mcp-server/tools/GenerateProjectConfigTool.js +40 -0
- package/mcp-server/tools/HubSpotCLIHelper.d.ts +16 -0
- package/mcp-server/tools/HubSpotCLIHelper.js +74 -0
- package/mcp-server/tools/UploadProjectTool.d.ts +44 -0
- package/mcp-server/tools/UploadProjectTool.js +149 -0
- package/mcp-server/tools/ValidateProjectTool.d.ts +62 -0
- package/mcp-server/tools/ValidateProjectTool.js +315 -0
- package/package.json +13 -6
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +24 -0
- package/types/LocalDev.js +2 -0
- package/types/Prompts.d.ts +0 -7
- package/types/Yargs.d.ts +8 -1
- package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -41
|
@@ -3,23 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isGloballyInstalled = isGloballyInstalled;
|
|
7
|
-
exports.getLatestCliVersion = getLatestCliVersion;
|
|
8
6
|
exports.installPackages = installPackages;
|
|
9
7
|
exports.getProjectPackageJsonLocations = getProjectPackageJsonLocations;
|
|
10
8
|
exports.hasMissingPackages = hasMissingPackages;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const fs_1 = require("@hubspot/local-dev-lib/fs");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const util_1 = __importDefault(require("util"));
|
|
15
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const fs_2 = require("@hubspot/local-dev-lib/fs");
|
|
14
|
+
const config_1 = require("./projects/config");
|
|
16
15
|
const ui_1 = require("./ui");
|
|
17
|
-
const util_1 = __importDefault(require("util"));
|
|
18
16
|
const lang_1 = require("./lang");
|
|
19
17
|
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
20
|
-
const
|
|
21
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
22
|
-
const DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
18
|
+
const npm_1 = require("./npm");
|
|
23
19
|
class NoPackageJsonFilesError extends Error {
|
|
24
20
|
constructor(projectName) {
|
|
25
21
|
super((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noPackageJsonInProject`, {
|
|
@@ -28,22 +24,6 @@ class NoPackageJsonFilesError extends Error {
|
|
|
28
24
|
}));
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
async function isGloballyInstalled(command) {
|
|
32
|
-
const exec = util_1.default.promisify(child_process_1.exec);
|
|
33
|
-
try {
|
|
34
|
-
await exec(`${command} --version`);
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function getLatestCliVersion() {
|
|
42
|
-
const exec = util_1.default.promisify(child_process_1.exec);
|
|
43
|
-
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
44
|
-
const { latest, next } = JSON.parse(stdout);
|
|
45
|
-
return { latest, next };
|
|
46
|
-
}
|
|
47
27
|
async function installPackages({ packages, installLocations, }) {
|
|
48
28
|
const installDirs = installLocations || (await getProjectPackageJsonLocations());
|
|
49
29
|
await Promise.all(installDirs.map(async (dir) => {
|
|
@@ -64,14 +44,8 @@ async function installPackagesInDirectory(directory, packages) {
|
|
|
64
44
|
directory: relativeDir,
|
|
65
45
|
}),
|
|
66
46
|
});
|
|
67
|
-
let installCommand = `${DEFAULT_PACKAGE_MANAGER} install`;
|
|
68
|
-
if (packages) {
|
|
69
|
-
installCommand = `${installCommand} ${packages.join(' ')}`;
|
|
70
|
-
}
|
|
71
|
-
logger_1.logger.debug(`Running ${installCommand}`);
|
|
72
47
|
try {
|
|
73
|
-
|
|
74
|
-
await exec(installCommand, { cwd: directory });
|
|
48
|
+
await (0, npm_1.executeInstall)(packages, null, { cwd: directory });
|
|
75
49
|
SpinniesManager_1.default.succeed(spinner, {
|
|
76
50
|
text: (0, lang_1.i18n)(`commands.project.subcommands.installDeps.installationSuccessful`, {
|
|
77
51
|
directory: relativeDir,
|
|
@@ -99,17 +73,17 @@ async function getProjectPackageJsonLocations() {
|
|
|
99
73
|
throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.noProjectConfig`));
|
|
100
74
|
}
|
|
101
75
|
const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
|
|
102
|
-
if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
|
|
76
|
+
if (!(await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER))) {
|
|
103
77
|
throw new Error((0, lang_1.i18n)(`commands.project.subcommands.installDeps.packageManagerNotInstalled`, {
|
|
104
|
-
packageManager: DEFAULT_PACKAGE_MANAGER,
|
|
105
|
-
link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
|
|
78
|
+
packageManager: npm_1.DEFAULT_PACKAGE_MANAGER,
|
|
79
|
+
link: (0, ui_1.uiLink)(npm_1.DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
|
|
106
80
|
}));
|
|
107
81
|
}
|
|
108
|
-
if (!
|
|
109
|
-
!
|
|
82
|
+
if (!fs_1.default.existsSync(projectConfig.projectDir) ||
|
|
83
|
+
!fs_1.default.existsSync(path_1.default.join(projectDir, srcDir))) {
|
|
110
84
|
throw new NoPackageJsonFilesError(name);
|
|
111
85
|
}
|
|
112
|
-
const packageJsonFiles = (await (0,
|
|
86
|
+
const packageJsonFiles = (await (0, fs_2.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
|
|
113
87
|
!file.includes('node_modules') &&
|
|
114
88
|
!file.includes('.vite'));
|
|
115
89
|
if (packageJsonFiles.length === 0) {
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -8,6 +8,7 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
8
8
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
9
9
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
10
10
|
const dependencyManagement_1 = require("../dependencyManagement");
|
|
11
|
+
const npm_1 = require("../npm");
|
|
11
12
|
const util_1 = __importDefault(require("util"));
|
|
12
13
|
const fs_1 = __importDefault(require("fs"));
|
|
13
14
|
const path_1 = __importDefault(require("path"));
|
|
@@ -230,7 +231,7 @@ class Doctor {
|
|
|
230
231
|
let latestCLIVersion;
|
|
231
232
|
let nextCliVersion;
|
|
232
233
|
try {
|
|
233
|
-
const { latest, next } = await (0,
|
|
234
|
+
const { latest, next } = await (0, npm_1.getLatestCliVersion)();
|
|
234
235
|
latestCLIVersion = latest;
|
|
235
236
|
nextCliVersion = next;
|
|
236
237
|
}
|
package/lib/filesystem.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function resolveLocalPath(filepath
|
|
1
|
+
export declare function resolveLocalPath(filepath?: string): string;
|
|
2
2
|
export declare function isPathFolder(path: string): boolean;
|
package/lib/interpolation.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export declare const helpers: {
|
|
2
2
|
[key: string]: (stringValue: string) => string;
|
|
3
3
|
};
|
|
4
|
-
type InterpolationData = {
|
|
5
|
-
[identifier: string]: string | number;
|
|
4
|
+
export type InterpolationData = {
|
|
5
|
+
[identifier: string]: string | undefined | null | number | boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
|
|
8
|
-
export {};
|
package/lib/lang.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { InterpolationData } from './interpolation';
|
|
1
2
|
export declare const MISSING_LANGUAGE_DATA_PREFIX = "[Missing language data]";
|
|
2
3
|
type LanguageObject = {
|
|
3
4
|
[key: string]: string | LanguageObject;
|
|
4
5
|
};
|
|
5
|
-
export declare function i18n(lookupDotNotation: string, options?:
|
|
6
|
-
[identifier: string]: string | number;
|
|
7
|
-
}): string;
|
|
6
|
+
export declare function i18n(lookupDotNotation: string, options?: InterpolationData): string;
|
|
8
7
|
export declare function setLangData(newLocale: string, newLangObj: LanguageObject): void;
|
|
9
8
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function autoUpdateCLI(): Promise<void>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.autoUpdateCLI = autoUpdateCLI;
|
|
7
|
+
// Update-notifier is CommonJS, so we need to use require
|
|
8
|
+
const updateNotifier = require('update-notifier');
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const ui_1 = require("../ui");
|
|
12
|
+
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
13
|
+
const en_1 = require("../../lang/en");
|
|
14
|
+
const npm_1 = require("../npm");
|
|
15
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
16
|
+
const logger_1 = require("../ui/logger");
|
|
17
|
+
// Default behavior is to check for notifications at most once per day
|
|
18
|
+
// update-notifier stores the last checked date in the user's home directory
|
|
19
|
+
const notifier = updateNotifier({
|
|
20
|
+
pkg: { ...package_json_1.default, name: '@hubspot/cli' },
|
|
21
|
+
distTag: 'latest',
|
|
22
|
+
shouldNotifyInNpmScript: true,
|
|
23
|
+
});
|
|
24
|
+
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
25
|
+
function updateNotification() {
|
|
26
|
+
notifier.notify({
|
|
27
|
+
message: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
28
|
+
? en_1.lib.middleware.updateNotification.cmsUpdateNotification(CMS_CLI_PACKAGE_NAME)
|
|
29
|
+
: en_1.lib.middleware.updateNotification.cliUpdateNotification,
|
|
30
|
+
defer: false,
|
|
31
|
+
boxenOptions: {
|
|
32
|
+
borderColor: ui_1.UI_COLORS.MARIGOLD_DARK,
|
|
33
|
+
margin: 1,
|
|
34
|
+
padding: 1,
|
|
35
|
+
textAlignment: 'center',
|
|
36
|
+
borderStyle: 'round',
|
|
37
|
+
title: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
38
|
+
? null
|
|
39
|
+
: en_1.lib.middleware.updateNotification.notifyTitle,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function autoUpdateCLI() {
|
|
44
|
+
// This lets us back to default update-notifier behavior
|
|
45
|
+
let showManualInstallHelp = true;
|
|
46
|
+
if (notifier &&
|
|
47
|
+
notifier.update &&
|
|
48
|
+
!process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
|
|
49
|
+
(0, config_1.isConfigFlagEnabled)('allowAutoUpdates')) {
|
|
50
|
+
// Ignore all update notifications if the current version is a pre-release
|
|
51
|
+
if (!notifier.update.current.includes('-')) {
|
|
52
|
+
// Attempt auto-update if the current version is not the latest version
|
|
53
|
+
// Never auto-update for major version updates b/c they are breaking
|
|
54
|
+
if (!['major', 'latest'].includes(notifier.update.type)) {
|
|
55
|
+
SpinniesManager_1.default.init({
|
|
56
|
+
succeedColor: 'white',
|
|
57
|
+
});
|
|
58
|
+
SpinniesManager_1.default.add('cliAutoUpdate', {
|
|
59
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateAvailable(notifier.update.latest),
|
|
60
|
+
});
|
|
61
|
+
try {
|
|
62
|
+
if ((await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER)) &&
|
|
63
|
+
(await (0, npm_1.isGloballyInstalled)('hs'))) {
|
|
64
|
+
await (0, npm_1.executeInstall)(['@hubspot/cli@latest'], '-g');
|
|
65
|
+
showManualInstallHelp = false;
|
|
66
|
+
SpinniesManager_1.default.succeed('cliAutoUpdate', {
|
|
67
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateSucceeded(notifier.update.latest),
|
|
68
|
+
});
|
|
69
|
+
logger_1.uiLogger.log('');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
SpinniesManager_1.default.fail('cliAutoUpdate', {
|
|
73
|
+
text: en_1.lib.middleware.autoUpdateCLI.notInstalledGlobally,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
(0, errorHandlers_1.debugError)(e);
|
|
79
|
+
SpinniesManager_1.default.fail('cliAutoUpdate', {
|
|
80
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateFailed(notifier.update.latest),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (showManualInstallHelp) {
|
|
87
|
+
updateNotification();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -55,6 +55,7 @@ async function loadConfigMiddleware(argv) {
|
|
|
55
55
|
if (!(0, config_1.configFileExists)(true) &&
|
|
56
56
|
(0, utils_1.isTargetedCommand)(argv._, {
|
|
57
57
|
account: { target: false, subCommands: { auth: { target: true } } },
|
|
58
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
58
59
|
})) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
@@ -94,6 +95,12 @@ const sandboxesSubCommands = {
|
|
|
94
95
|
delete: { target: true },
|
|
95
96
|
},
|
|
96
97
|
};
|
|
98
|
+
const configSubCommands = {
|
|
99
|
+
target: false,
|
|
100
|
+
subCommands: {
|
|
101
|
+
migrate: { target: true },
|
|
102
|
+
},
|
|
103
|
+
};
|
|
97
104
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
98
105
|
init: { target: true },
|
|
99
106
|
auth: { target: true },
|
|
@@ -101,6 +108,7 @@ const SKIP_ACCOUNT_VALIDATION = {
|
|
|
101
108
|
accounts: accountsSubCommands,
|
|
102
109
|
sandbox: sandboxesSubCommands,
|
|
103
110
|
sandboxes: sandboxesSubCommands,
|
|
111
|
+
config: configSubCommands,
|
|
104
112
|
};
|
|
105
113
|
async function validateAccountOptions(argv) {
|
|
106
114
|
// Skip this when no command is provided
|
package/lib/npm.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
2
|
+
export declare function isGloballyInstalled(packageName: string): Promise<boolean>;
|
|
3
|
+
export declare function getLatestCliVersion(): Promise<{
|
|
4
|
+
latest: string;
|
|
5
|
+
next: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}): Promise<void>;
|
package/lib/npm.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_PACKAGE_MANAGER = void 0;
|
|
7
|
+
exports.isGloballyInstalled = isGloballyInstalled;
|
|
8
|
+
exports.getLatestCliVersion = getLatestCliVersion;
|
|
9
|
+
exports.executeInstall = executeInstall;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = __importDefault(require("util"));
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
14
|
+
exports.DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
15
|
+
async function isGloballyInstalled(packageName) {
|
|
16
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
17
|
+
try {
|
|
18
|
+
await exec(`${packageName} --version`);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function getLatestCliVersion() {
|
|
26
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
27
|
+
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
28
|
+
const { latest, next } = JSON.parse(stdout);
|
|
29
|
+
return { latest, next };
|
|
30
|
+
}
|
|
31
|
+
async function executeInstall(packages = [], flags, options) {
|
|
32
|
+
const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
|
|
33
|
+
logger_1.logger.debug('Running ', installCommand);
|
|
34
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
35
|
+
await exec(installCommand, options);
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HsProfileFile } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { ProjectConfig } from '../types/Projects';
|
|
3
|
+
export declare function logProfileHeader(profileName: string): void;
|
|
4
|
+
export declare function logProfileFooter(profile: HsProfileFile, includeVariables?: boolean): void;
|
|
5
|
+
export declare function loadProfile(projectConfig: ProjectConfig | null, projectDir: string | null, profileName: string): HsProfileFile | undefined;
|
|
6
|
+
export declare function exitIfUsingProfiles(projectConfig: ProjectConfig | null, projectDir: string | null): Promise<void>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logProfileHeader = logProfileHeader;
|
|
7
|
+
exports.logProfileFooter = logProfileFooter;
|
|
8
|
+
exports.loadProfile = loadProfile;
|
|
9
|
+
exports.exitIfUsingProfiles = exitIfUsingProfiles;
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
12
|
+
const en_1 = require("../lang/en");
|
|
13
|
+
const ui_1 = require("./ui");
|
|
14
|
+
const logger_1 = require("./ui/logger");
|
|
15
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
16
|
+
function logProfileHeader(profileName) {
|
|
17
|
+
(0, ui_1.uiLine)();
|
|
18
|
+
(0, ui_1.uiBetaTag)(en_1.lib.projectProfiles.logs.usingProfile((0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
|
|
19
|
+
logger_1.uiLogger.log('');
|
|
20
|
+
}
|
|
21
|
+
function logProfileFooter(profile, includeVariables = false) {
|
|
22
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileTargetAccount(profile.accountId));
|
|
23
|
+
if (includeVariables) {
|
|
24
|
+
logger_1.uiLogger.log('');
|
|
25
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileVariables);
|
|
26
|
+
Object.entries(profile.variables ?? {}).forEach(([key, value]) => {
|
|
27
|
+
logger_1.uiLogger.log(` ${key}: ${value}`);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
(0, ui_1.uiLine)();
|
|
31
|
+
logger_1.uiLogger.log('');
|
|
32
|
+
}
|
|
33
|
+
function loadProfile(projectConfig, projectDir, profileName) {
|
|
34
|
+
if (!projectConfig || !projectDir) {
|
|
35
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.noProjectConfig);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
39
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
40
|
+
try {
|
|
41
|
+
const profile = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileName);
|
|
42
|
+
if (!profile) {
|
|
43
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.profileNotFound(profileFilename));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!profile.accountId) {
|
|
47
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.missingAccountId(profileFilename));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
return profile;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.failedToLoadProfile(profileFilename));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function exitIfUsingProfiles(projectConfig, projectDir) {
|
|
58
|
+
if (projectConfig && projectDir) {
|
|
59
|
+
const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(path_1.default.join(projectDir, projectConfig.srcDir));
|
|
60
|
+
if (existingProfiles.length > 0) {
|
|
61
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.exitIfUsingProfiles.errors.noProfileSpecified);
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -17,6 +17,8 @@ const urls_1 = require("./urls");
|
|
|
17
17
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
18
18
|
const en_1 = require("../../lang/en");
|
|
19
19
|
const logger_1 = require("../ui/logger");
|
|
20
|
+
const constants_2 = require("@hubspot/project-parsing-lib/src/lib/constants");
|
|
21
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
20
22
|
const SPINNER_STATUS = {
|
|
21
23
|
SPINNING: 'spinning',
|
|
22
24
|
};
|
|
@@ -71,14 +73,27 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
71
73
|
structureFn(accountId, taskName, taskId),
|
|
72
74
|
]);
|
|
73
75
|
const subtasks = getSubtasks(initialTaskStatus);
|
|
74
|
-
const
|
|
76
|
+
const hiddenComponentBuildIds = [];
|
|
77
|
+
const tasksById = subtasks
|
|
78
|
+
.filter(subtask => {
|
|
79
|
+
// TODO: Remove this filtering logic when visible=false for SERVERLESS_PACKAGE
|
|
80
|
+
const shouldBeVisible = getSubtaskType(subtask) !== (0, project_parsing_lib_1.mapToInternalType)(constants_2.AppFunctionsPackageKey);
|
|
81
|
+
if (!shouldBeVisible) {
|
|
82
|
+
hiddenComponentBuildIds.push(subtask.id);
|
|
83
|
+
}
|
|
84
|
+
return shouldBeVisible;
|
|
85
|
+
})
|
|
86
|
+
.reduce((acc, subtask) => {
|
|
75
87
|
const { id, visible } = subtask;
|
|
76
88
|
if (visible) {
|
|
77
89
|
acc[id] = subtask;
|
|
78
90
|
}
|
|
79
91
|
return acc;
|
|
80
92
|
}, {});
|
|
81
|
-
const structuredTasks = Object.keys(taskStructure)
|
|
93
|
+
const structuredTasks = Object.keys(taskStructure)
|
|
94
|
+
// TODO: Remove this filtering logic when visible=false for SERVERLESS_PACKAGE
|
|
95
|
+
.filter(buildId => !hiddenComponentBuildIds.includes(buildId))
|
|
96
|
+
.map(key => {
|
|
82
97
|
return {
|
|
83
98
|
...tasksById[key],
|
|
84
99
|
subtasks: taskStructure[key]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PublicApp } from '@hubspot/local-dev-lib/types/Apps';
|
|
2
|
+
import { AppIRNode } from '../../../types/ProjectComponents';
|
|
3
|
+
import LocalDevState from './LocalDevState';
|
|
4
|
+
import LocalDevLogger from './LocalDevLogger';
|
|
5
|
+
type AppDevModeInterfaceConstructorOptions = {
|
|
6
|
+
localDevState: LocalDevState;
|
|
7
|
+
localDevLogger: LocalDevLogger;
|
|
8
|
+
};
|
|
9
|
+
declare class AppDevModeInterface {
|
|
10
|
+
localDevState: LocalDevState;
|
|
11
|
+
localDevLogger: LocalDevLogger;
|
|
12
|
+
_appNode?: AppIRNode | null;
|
|
13
|
+
appData?: PublicApp;
|
|
14
|
+
marketplaceAppInstalls?: number;
|
|
15
|
+
constructor(options: AppDevModeInterfaceConstructorOptions);
|
|
16
|
+
private get appNode();
|
|
17
|
+
private getAppInstallUrl;
|
|
18
|
+
private fetchAppData;
|
|
19
|
+
private checkMarketplaceAppInstalls;
|
|
20
|
+
private checkTestAccountAppInstallation;
|
|
21
|
+
setup(args: any): Promise<void>;
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
fileChange(filePath: string, event: string): Promise<void>;
|
|
24
|
+
cleanup(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export default AppDevModeInterface;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
4
|
+
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
5
|
+
const ui_extensions_dev_server_1 = require("@hubspot/ui-extensions-dev-server");
|
|
6
|
+
const portManager_1 = require("@hubspot/local-dev-lib/portManager");
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
9
|
+
const structure_1 = require("../../projects/structure");
|
|
10
|
+
const ui_1 = require("../../ui");
|
|
11
|
+
const index_1 = require("../../errorHandlers/index");
|
|
12
|
+
const installAppPrompt_1 = require("../../prompts/installAppPrompt");
|
|
13
|
+
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
14
|
+
const en_1 = require("../../../lang/en");
|
|
15
|
+
const logger_1 = require("../../ui/logger");
|
|
16
|
+
const urls_1 = require("../../app/urls");
|
|
17
|
+
class AppDevModeInterface {
|
|
18
|
+
localDevState;
|
|
19
|
+
localDevLogger;
|
|
20
|
+
_appNode;
|
|
21
|
+
appData;
|
|
22
|
+
marketplaceAppInstalls;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.localDevState = options.localDevState;
|
|
25
|
+
this.localDevLogger = options.localDevLogger;
|
|
26
|
+
// Static auth apps are currently only installable in the portal that the project resides in
|
|
27
|
+
// This limitation will eventually be removed, but in the meantime we need this check or the install
|
|
28
|
+
// will always fail with a confusing message
|
|
29
|
+
if (this.appNode?.config.auth.type === constants_1.APP_AUTH_TYPES.STATIC &&
|
|
30
|
+
this.localDevState.targetTestingAccountId !==
|
|
31
|
+
this.localDevState.targetProjectAccountId) {
|
|
32
|
+
logger_1.uiLogger.error(en_1.lib.LocalDevManager.staticAuthAccountsMustMatch);
|
|
33
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
34
|
+
}
|
|
35
|
+
if (!this.localDevState.targetProjectAccountId ||
|
|
36
|
+
!this.localDevState.projectConfig ||
|
|
37
|
+
!this.localDevState.projectDir) {
|
|
38
|
+
logger_1.uiLogger.error(en_1.lib.LocalDevManager.failedToInitialize);
|
|
39
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Assumes only one app per project
|
|
43
|
+
get appNode() {
|
|
44
|
+
if (this._appNode === undefined) {
|
|
45
|
+
this._appNode =
|
|
46
|
+
Object.values(this.localDevState.projectNodes).find(structure_1.isAppIRNode) ||
|
|
47
|
+
null;
|
|
48
|
+
}
|
|
49
|
+
return this._appNode;
|
|
50
|
+
}
|
|
51
|
+
async getAppInstallUrl() {
|
|
52
|
+
if (this.appNode?.config.auth.type === constants_1.APP_AUTH_TYPES.OAUTH) {
|
|
53
|
+
return (0, urls_1.getOauthAppInstallUrl)({
|
|
54
|
+
targetAccountId: this.localDevState.targetTestingAccountId,
|
|
55
|
+
env: this.localDevState.env,
|
|
56
|
+
clientId: this.appData.clientId, // This is only called after checking that appData exists
|
|
57
|
+
scopes: this.appNode.config.auth.requiredScopes,
|
|
58
|
+
redirectUrls: this.appNode.config.auth.redirectUrls,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const { data: { results }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.localDevState.targetProjectAccountId);
|
|
62
|
+
const app = results.find(app => app.sourceId === this.appNode?.uid);
|
|
63
|
+
if (!app) {
|
|
64
|
+
logger_1.uiLogger.error(en_1.lib.LocalDevManager.staticAuthAccountsMustMatch);
|
|
65
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
66
|
+
}
|
|
67
|
+
return (0, urls_1.getStaticAuthAppInstallUrl)({
|
|
68
|
+
targetAccountId: this.localDevState.targetTestingAccountId,
|
|
69
|
+
env: this.localDevState.env,
|
|
70
|
+
appId: `${app.id}`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async fetchAppData() {
|
|
74
|
+
const { data: { results: portalApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.localDevState.targetProjectAccountId);
|
|
75
|
+
const appData = portalApps.find(({ sourceId }) => sourceId === this.appNode?.uid);
|
|
76
|
+
if (!appData) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const { data: { uniquePortalInstallCount }, } = await (0, appsDev_1.fetchPublicAppProductionInstallCounts)(appData.id, this.localDevState.targetProjectAccountId);
|
|
80
|
+
this.appData = appData;
|
|
81
|
+
this.marketplaceAppInstalls = uniquePortalInstallCount;
|
|
82
|
+
}
|
|
83
|
+
async checkMarketplaceAppInstalls() {
|
|
84
|
+
if (!this.appData || !this.marketplaceAppInstalls) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
(0, ui_1.uiLine)();
|
|
88
|
+
logger_1.uiLogger.warn(en_1.lib.LocalDevManager.activeInstallWarning.installCount(this.appData.name, this.marketplaceAppInstalls));
|
|
89
|
+
logger_1.uiLogger.log(en_1.lib.LocalDevManager.activeInstallWarning.explanation);
|
|
90
|
+
(0, ui_1.uiLine)();
|
|
91
|
+
const proceed = await (0, promptUtils_1.confirmPrompt)(en_1.lib.LocalDevManager.activeInstallWarning.confirmationPrompt, { defaultAnswer: false });
|
|
92
|
+
if (!proceed) {
|
|
93
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
94
|
+
}
|
|
95
|
+
this.localDevLogger.addUploadWarning(en_1.lib.AppDevModeInterface.defaultMarketplaceAppWarning(this.marketplaceAppInstalls));
|
|
96
|
+
}
|
|
97
|
+
async checkTestAccountAppInstallation() {
|
|
98
|
+
if (!this.appNode || !this.appData) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// If the app is static auth, always prompt the user to install the app.
|
|
102
|
+
// We are currently going this because we have no method to determine if the static auth app
|
|
103
|
+
// is already installed in the portal
|
|
104
|
+
if (this.appNode.config.auth.type === constants_1.APP_AUTH_TYPES.STATIC) {
|
|
105
|
+
return (0, installAppPrompt_1.installAppPrompt)(await this.getAppInstallUrl(), false);
|
|
106
|
+
}
|
|
107
|
+
const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await (0, localDevAuth_1.fetchAppInstallationData)(this.localDevState.targetTestingAccountId, this.localDevState.projectId, this.appNode.uid, this.appNode.config.auth.requiredScopes, this.appNode.config.auth.optionalScopes);
|
|
108
|
+
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
109
|
+
if (!isInstalledWithScopeGroups) {
|
|
110
|
+
const installUrl = await this.getAppInstallUrl();
|
|
111
|
+
await (0, installAppPrompt_1.installAppPrompt)(installUrl, isReinstall);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
|
|
115
|
+
// In the future, update UIE Dev Server to use LocalDevState
|
|
116
|
+
async setup(args) {
|
|
117
|
+
if (!this.appNode) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
await this.fetchAppData();
|
|
122
|
+
if (this.appNode.config.distribution === constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
123
|
+
await this.checkMarketplaceAppInstalls();
|
|
124
|
+
}
|
|
125
|
+
await this.checkTestAccountAppInstallation();
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
(0, index_1.logError)(e);
|
|
129
|
+
}
|
|
130
|
+
return ui_extensions_dev_server_1.DevModeUnifiedInterface.setup(args);
|
|
131
|
+
}
|
|
132
|
+
async start() {
|
|
133
|
+
if (!this.appNode) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
return ui_extensions_dev_server_1.DevModeUnifiedInterface.start({
|
|
137
|
+
accountId: this.localDevState.targetTestingAccountId,
|
|
138
|
+
// @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
|
|
139
|
+
projectConfig: this.localDevState.projectConfig,
|
|
140
|
+
requestPorts: portManager_1.requestPorts,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async fileChange(filePath, event) {
|
|
144
|
+
if (!this.appNode) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
return ui_extensions_dev_server_1.DevModeUnifiedInterface.fileChange(filePath, event);
|
|
148
|
+
}
|
|
149
|
+
async cleanup() {
|
|
150
|
+
if (!this.appNode) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
return ui_extensions_dev_server_1.DevModeUnifiedInterface.cleanup();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.default = AppDevModeInterface;
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
fileChange?: (filePath: string, event: string) => Promise<void>;
|
|
7
|
-
cleanup?: () => Promise<void>;
|
|
1
|
+
import LocalDevState from './LocalDevState';
|
|
2
|
+
import LocalDevLogger from './LocalDevLogger';
|
|
3
|
+
type DevServerManagerV2ConstructorOptions = {
|
|
4
|
+
localDevState: LocalDevState;
|
|
5
|
+
logger: LocalDevLogger;
|
|
8
6
|
};
|
|
9
7
|
declare class DevServerManagerV2 {
|
|
10
8
|
private initialized;
|
|
11
9
|
private started;
|
|
12
10
|
private devServers;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
accountId: number;
|
|
20
|
-
setActiveApp: (appUid: string | undefined) => Promise<void>;
|
|
21
|
-
}): Promise<void>;
|
|
22
|
-
start({ accountId, projectConfig, }: {
|
|
23
|
-
accountId: number;
|
|
24
|
-
projectConfig: ProjectConfig;
|
|
25
|
-
}): Promise<void>;
|
|
11
|
+
private localDevState;
|
|
12
|
+
constructor(options: DevServerManagerV2ConstructorOptions);
|
|
13
|
+
private iterateDevServers;
|
|
14
|
+
setup(): Promise<void>;
|
|
15
|
+
start(): Promise<void>;
|
|
26
16
|
fileChange({ filePath, event, }: {
|
|
27
17
|
filePath: string;
|
|
28
18
|
event: string;
|
|
29
19
|
}): Promise<void>;
|
|
30
20
|
cleanup(): Promise<void>;
|
|
31
21
|
}
|
|
32
|
-
|
|
33
|
-
export default Manager;
|
|
22
|
+
export default DevServerManagerV2;
|