@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
package/types/Yargs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Options, CommandModule, Argv } from 'yargs';
|
|
2
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
2
3
|
export type CommonArgs = {
|
|
3
4
|
derivedAccountId: number;
|
|
4
5
|
providedAccountId?: number;
|
|
@@ -23,10 +24,16 @@ export type OverwriteArgs = Options & {
|
|
|
23
24
|
export type StringArgType = Options & {
|
|
24
25
|
type: 'string';
|
|
25
26
|
};
|
|
26
|
-
export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs
|
|
27
|
+
export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs & {
|
|
28
|
+
profile?: string;
|
|
29
|
+
};
|
|
27
30
|
export type TestingArgs = {
|
|
28
31
|
qa?: boolean;
|
|
29
32
|
};
|
|
33
|
+
export type CmsPublishModeArgs = {
|
|
34
|
+
'cms-publish-mode'?: CmsPublishMode;
|
|
35
|
+
m?: CmsPublishMode;
|
|
36
|
+
};
|
|
30
37
|
export interface YargsCommandModule<T, U> extends CommandModule<T, U> {
|
|
31
38
|
builder: (yargs: Argv) => Promise<Argv<U>>;
|
|
32
39
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { FSWatcher } from 'chokidar';
|
|
2
|
-
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
|
-
import { PublicApp } from '@hubspot/local-dev-lib/types/Apps';
|
|
4
|
-
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
5
|
-
import { ProjectConfig } from '../../../types/Projects';
|
|
6
|
-
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
7
|
-
import { AppIRNode } from '../../../types/ProjectComponents';
|
|
8
|
-
type LocalDevManagerConstructorOptions = {
|
|
9
|
-
targetProjectAccountId: number;
|
|
10
|
-
targetTestingAccountId: number;
|
|
11
|
-
projectConfig: ProjectConfig;
|
|
12
|
-
projectDir: string;
|
|
13
|
-
projectId: number;
|
|
14
|
-
debug?: boolean;
|
|
15
|
-
deployedBuild?: Build;
|
|
16
|
-
isGithubLinked: boolean;
|
|
17
|
-
projectNodes: {
|
|
18
|
-
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
19
|
-
};
|
|
20
|
-
env: Environment;
|
|
21
|
-
};
|
|
22
|
-
declare class LocalDevManagerV2 {
|
|
23
|
-
targetProjectAccountId: number;
|
|
24
|
-
targetTestingAccountId: number;
|
|
25
|
-
projectConfig: ProjectConfig;
|
|
26
|
-
projectDir: string;
|
|
27
|
-
projectId: number;
|
|
28
|
-
debug: boolean;
|
|
29
|
-
deployedBuild?: Build;
|
|
30
|
-
isGithubLinked: boolean;
|
|
31
|
-
watcher: FSWatcher | null;
|
|
32
|
-
uploadWarnings: {
|
|
33
|
-
[key: string]: boolean;
|
|
34
|
-
};
|
|
35
|
-
projectNodes: {
|
|
36
|
-
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
37
|
-
};
|
|
38
|
-
activeApp: AppIRNode | null;
|
|
39
|
-
activePublicAppData: PublicApp | null;
|
|
40
|
-
env: Environment;
|
|
41
|
-
publicAppActiveInstalls: number | null;
|
|
42
|
-
projectSourceDir: string;
|
|
43
|
-
mostRecentUploadWarning: string | null;
|
|
44
|
-
constructor(options: LocalDevManagerConstructorOptions);
|
|
45
|
-
setActiveApp(appUid?: string): Promise<void>;
|
|
46
|
-
setActivePublicAppData(): Promise<void>;
|
|
47
|
-
checkActivePublicAppInstalls(): Promise<void>;
|
|
48
|
-
start(): Promise<void>;
|
|
49
|
-
stop(showProgress?: boolean): Promise<void>;
|
|
50
|
-
checkPublicAppInstallation(): Promise<void>;
|
|
51
|
-
updateKeypressListeners(): void;
|
|
52
|
-
getUploadCommand(): string;
|
|
53
|
-
logUploadWarning(reason?: string): void;
|
|
54
|
-
monitorConsoleOutput(): void;
|
|
55
|
-
compareLocalProjectToDeployed(): void;
|
|
56
|
-
startWatching(): void;
|
|
57
|
-
stopWatching(): Promise<void>;
|
|
58
|
-
handleWatchEvent(filePath: string, event: string, configPaths: string[]): void;
|
|
59
|
-
devServerSetup(): Promise<boolean>;
|
|
60
|
-
devServerStart(): Promise<void>;
|
|
61
|
-
devServerFileChange(filePath: string, event: string): void;
|
|
62
|
-
devServerCleanup(): Promise<boolean>;
|
|
63
|
-
}
|
|
64
|
-
export default LocalDevManagerV2;
|
|
@@ -1,345 +0,0 @@
|
|
|
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
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
-
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
11
|
-
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
12
|
-
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
13
|
-
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
14
|
-
const constants_1 = require("../../constants");
|
|
15
|
-
const SpinniesManager_1 = __importDefault(require("../../ui/SpinniesManager"));
|
|
16
|
-
const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
|
|
17
|
-
const exitCodes_1 = require("../../enums/exitCodes");
|
|
18
|
-
const urls_1 = require("../../projects/urls");
|
|
19
|
-
const structure_1 = require("../../projects/structure");
|
|
20
|
-
const ui_1 = require("../../ui");
|
|
21
|
-
const index_1 = require("../../errorHandlers/index");
|
|
22
|
-
const installPublicAppPrompt_1 = require("../../prompts/installPublicAppPrompt");
|
|
23
|
-
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
24
|
-
const process_1 = require("../../process");
|
|
25
|
-
const en_1 = require("../../../lang/en");
|
|
26
|
-
const logger_2 = require("../../ui/logger");
|
|
27
|
-
const WATCH_EVENTS = {
|
|
28
|
-
add: 'add',
|
|
29
|
-
change: 'change',
|
|
30
|
-
unlink: 'unlink',
|
|
31
|
-
unlinkDir: 'unlinkDir',
|
|
32
|
-
};
|
|
33
|
-
class LocalDevManagerV2 {
|
|
34
|
-
targetProjectAccountId;
|
|
35
|
-
targetTestingAccountId;
|
|
36
|
-
projectConfig;
|
|
37
|
-
projectDir;
|
|
38
|
-
projectId;
|
|
39
|
-
debug;
|
|
40
|
-
deployedBuild;
|
|
41
|
-
isGithubLinked;
|
|
42
|
-
watcher;
|
|
43
|
-
uploadWarnings;
|
|
44
|
-
projectNodes;
|
|
45
|
-
activeApp;
|
|
46
|
-
activePublicAppData;
|
|
47
|
-
env;
|
|
48
|
-
publicAppActiveInstalls;
|
|
49
|
-
projectSourceDir;
|
|
50
|
-
mostRecentUploadWarning;
|
|
51
|
-
constructor(options) {
|
|
52
|
-
this.targetProjectAccountId = options.targetProjectAccountId;
|
|
53
|
-
this.targetTestingAccountId = options.targetTestingAccountId;
|
|
54
|
-
this.projectConfig = options.projectConfig;
|
|
55
|
-
this.projectDir = options.projectDir;
|
|
56
|
-
this.projectId = options.projectId;
|
|
57
|
-
this.debug = options.debug || false;
|
|
58
|
-
this.deployedBuild = options.deployedBuild;
|
|
59
|
-
this.isGithubLinked = options.isGithubLinked;
|
|
60
|
-
this.watcher = null;
|
|
61
|
-
this.uploadWarnings = {};
|
|
62
|
-
this.projectNodes = options.projectNodes;
|
|
63
|
-
this.activeApp = null;
|
|
64
|
-
this.activePublicAppData = null;
|
|
65
|
-
this.env = options.env;
|
|
66
|
-
this.publicAppActiveInstalls = null;
|
|
67
|
-
this.mostRecentUploadWarning = null;
|
|
68
|
-
this.projectSourceDir = path_1.default.join(this.projectDir, this.projectConfig.srcDir);
|
|
69
|
-
if (!this.targetProjectAccountId ||
|
|
70
|
-
!this.projectConfig ||
|
|
71
|
-
!this.projectDir) {
|
|
72
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.failedToInitialize);
|
|
73
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async setActiveApp(appUid) {
|
|
77
|
-
if (!appUid) {
|
|
78
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.missingUid);
|
|
79
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
80
|
-
}
|
|
81
|
-
const app = Object.values(this.projectNodes).find(component => component.uid === appUid) || null;
|
|
82
|
-
if (app && (0, structure_1.isAppIRNode)(app)) {
|
|
83
|
-
this.activeApp = app;
|
|
84
|
-
if (app.config.distribution === constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
85
|
-
try {
|
|
86
|
-
await this.setActivePublicAppData();
|
|
87
|
-
await this.checkActivePublicAppInstalls();
|
|
88
|
-
await this.checkPublicAppInstallation();
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
(0, index_1.logError)(e);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
async setActivePublicAppData() {
|
|
98
|
-
const { data: { results: portalPublicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.targetProjectAccountId);
|
|
99
|
-
const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === this.activeApp?.uid);
|
|
100
|
-
if (!activePublicAppData) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const { data: { uniquePortalInstallCount }, } = await (0, appsDev_1.fetchPublicAppProductionInstallCounts)(activePublicAppData.id, this.targetProjectAccountId);
|
|
104
|
-
this.activePublicAppData = activePublicAppData;
|
|
105
|
-
this.publicAppActiveInstalls = uniquePortalInstallCount;
|
|
106
|
-
}
|
|
107
|
-
async checkActivePublicAppInstalls() {
|
|
108
|
-
if (!this.activePublicAppData ||
|
|
109
|
-
!this.publicAppActiveInstalls ||
|
|
110
|
-
this.publicAppActiveInstalls < 1) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
(0, ui_1.uiLine)();
|
|
114
|
-
logger_2.uiLogger.warn(en_1.lib.LocalDevManager.activeInstallWarning.installCount(this.activePublicAppData.name, this.publicAppActiveInstalls, this.publicAppActiveInstalls === 1 ? 'account' : 'accounts'));
|
|
115
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.activeInstallWarning.explanation);
|
|
116
|
-
(0, ui_1.uiLine)();
|
|
117
|
-
const proceed = await (0, promptUtils_1.confirmPrompt)(en_1.lib.LocalDevManager.activeInstallWarning.confirmationPrompt, { defaultAnswer: false });
|
|
118
|
-
if (!proceed) {
|
|
119
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async start() {
|
|
123
|
-
SpinniesManager_1.default.stopAll();
|
|
124
|
-
SpinniesManager_1.default.init();
|
|
125
|
-
// Local dev currently relies on the existence of a deployed build in the target account
|
|
126
|
-
if (!this.deployedBuild) {
|
|
127
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.noDeployedBuild(this.projectConfig.name, (0, ui_1.uiAccountDescription)(this.targetProjectAccountId), this.getUploadCommand()));
|
|
128
|
-
logger_2.uiLogger.log('');
|
|
129
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
130
|
-
}
|
|
131
|
-
const setupSucceeded = await this.devServerSetup();
|
|
132
|
-
if (!setupSucceeded) {
|
|
133
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
134
|
-
}
|
|
135
|
-
else if (!this.debug) {
|
|
136
|
-
console.clear();
|
|
137
|
-
}
|
|
138
|
-
(0, ui_1.uiBetaTag)(en_1.lib.LocalDevManager.betaMessage);
|
|
139
|
-
logger_2.uiLogger.log((0, ui_1.uiLink)(en_1.lib.LocalDevManager.learnMoreLocalDevServer, 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
140
|
-
logger_2.uiLogger.log('');
|
|
141
|
-
logger_2.uiLogger.log(chalk_1.default.hex(ui_1.UI_COLORS.SORBET)(en_1.lib.LocalDevManager.running(this.projectConfig.name, (0, ui_1.uiAccountDescription)(this.targetProjectAccountId))));
|
|
142
|
-
logger_2.uiLogger.log((0, ui_1.uiLink)(en_1.lib.LocalDevManager.viewProjectLink, (0, urls_1.getProjectDetailUrl)(this.projectConfig.name, this.targetProjectAccountId) || ''));
|
|
143
|
-
logger_2.uiLogger.log('');
|
|
144
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.quitHelper);
|
|
145
|
-
(0, ui_1.uiLine)();
|
|
146
|
-
logger_2.uiLogger.log('');
|
|
147
|
-
await this.devServerStart();
|
|
148
|
-
// Initialize project file watcher to detect configuration file changes
|
|
149
|
-
this.startWatching();
|
|
150
|
-
this.updateKeypressListeners();
|
|
151
|
-
this.monitorConsoleOutput();
|
|
152
|
-
// Verify that there are no mismatches between components in the local project
|
|
153
|
-
// and components in the deployed build of the project.
|
|
154
|
-
this.compareLocalProjectToDeployed();
|
|
155
|
-
}
|
|
156
|
-
async stop(showProgress = true) {
|
|
157
|
-
if (showProgress) {
|
|
158
|
-
SpinniesManager_1.default.add('cleanupMessage', {
|
|
159
|
-
text: en_1.lib.LocalDevManager.exitingStart,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
await this.stopWatching();
|
|
163
|
-
const cleanupSucceeded = await this.devServerCleanup();
|
|
164
|
-
if (!cleanupSucceeded) {
|
|
165
|
-
if (showProgress) {
|
|
166
|
-
SpinniesManager_1.default.fail('cleanupMessage', {
|
|
167
|
-
text: en_1.lib.LocalDevManager.exitingFail,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
171
|
-
}
|
|
172
|
-
if (showProgress) {
|
|
173
|
-
SpinniesManager_1.default.succeed('cleanupMessage', {
|
|
174
|
-
text: en_1.lib.LocalDevManager.exitingSucceed,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
178
|
-
}
|
|
179
|
-
async checkPublicAppInstallation() {
|
|
180
|
-
if (!this.activeApp || !this.activePublicAppData) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await (0, localDevAuth_1.fetchAppInstallationData)(this.targetTestingAccountId, this.projectId, this.activeApp.uid, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.optionalScopes);
|
|
184
|
-
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
185
|
-
if (!isInstalledWithScopeGroups) {
|
|
186
|
-
await (0, installPublicAppPrompt_1.installPublicAppPrompt)(this.env, this.targetTestingAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
updateKeypressListeners() {
|
|
190
|
-
(0, process_1.handleKeypress)(async (key) => {
|
|
191
|
-
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
192
|
-
this.stop();
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
getUploadCommand() {
|
|
197
|
-
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)() || undefined;
|
|
198
|
-
return this.targetProjectAccountId !== (0, config_1.getAccountId)(currentDefaultAccount)
|
|
199
|
-
? (0, ui_1.uiCommandReference)(`hs project upload --account=${this.targetProjectAccountId}`)
|
|
200
|
-
: (0, ui_1.uiCommandReference)('hs project upload');
|
|
201
|
-
}
|
|
202
|
-
logUploadWarning(reason) {
|
|
203
|
-
let warning = reason;
|
|
204
|
-
if (!warning) {
|
|
205
|
-
warning =
|
|
206
|
-
this.publicAppActiveInstalls && this.publicAppActiveInstalls > 0
|
|
207
|
-
? en_1.lib.LocalDevManager.uploadWarning.defaultMarketplaceAppWarning(this.publicAppActiveInstalls, this.publicAppActiveInstalls === 1 ? 'account' : 'accounts')
|
|
208
|
-
: en_1.lib.LocalDevManager.uploadWarning.defaultWarning;
|
|
209
|
-
}
|
|
210
|
-
// Avoid logging the warning to the console if it is currently the most
|
|
211
|
-
// recently logged warning. We do not want to spam the console with the same message.
|
|
212
|
-
if (!this.uploadWarnings[warning]) {
|
|
213
|
-
logger_2.uiLogger.log('');
|
|
214
|
-
logger_2.uiLogger.warn(en_1.lib.LocalDevManager.uploadWarning.header(warning));
|
|
215
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.uploadWarning.stopDev);
|
|
216
|
-
if (this.isGithubLinked) {
|
|
217
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.uploadWarning.pushToGithub);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.uploadWarning.runUpload(this.getUploadCommand()));
|
|
221
|
-
}
|
|
222
|
-
logger_2.uiLogger.log(en_1.lib.LocalDevManager.uploadWarning.restartDev);
|
|
223
|
-
this.mostRecentUploadWarning = warning;
|
|
224
|
-
this.uploadWarnings[warning] = true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
monitorConsoleOutput() {
|
|
228
|
-
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
229
|
-
function customStdoutWrite(chunk, encoding, callback) {
|
|
230
|
-
// Reset the most recently logged warning
|
|
231
|
-
if (this.mostRecentUploadWarning &&
|
|
232
|
-
this.uploadWarnings[this.mostRecentUploadWarning]) {
|
|
233
|
-
delete this.uploadWarnings[this.mostRecentUploadWarning];
|
|
234
|
-
}
|
|
235
|
-
if (typeof encoding === 'function') {
|
|
236
|
-
return originalStdoutWrite(chunk, callback);
|
|
237
|
-
}
|
|
238
|
-
return originalStdoutWrite(chunk, encoding, callback);
|
|
239
|
-
}
|
|
240
|
-
customStdoutWrite.bind(this);
|
|
241
|
-
process.stdout.write = customStdoutWrite;
|
|
242
|
-
}
|
|
243
|
-
compareLocalProjectToDeployed() {
|
|
244
|
-
const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
|
|
245
|
-
const missingProjectNodes = [];
|
|
246
|
-
Object.values(this.projectNodes).forEach(node => {
|
|
247
|
-
if (!deployedComponentNames.includes(node.uid)) {
|
|
248
|
-
const userFriendlyName = (0, project_parsing_lib_1.mapToUserFriendlyName)(node.componentType);
|
|
249
|
-
const label = userFriendlyName ? `[${userFriendlyName}] ` : '';
|
|
250
|
-
missingProjectNodes.push(`${label}${node.uid}`);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
if (missingProjectNodes.length) {
|
|
254
|
-
this.logUploadWarning(en_1.lib.LocalDevManager.uploadWarning.missingComponents(missingProjectNodes.join(', ')));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
startWatching() {
|
|
258
|
-
this.watcher = chokidar_1.default.watch(this.projectDir, {
|
|
259
|
-
ignoreInitial: true,
|
|
260
|
-
});
|
|
261
|
-
const configPaths = Object.values(this.projectNodes).map(component => component.localDev.componentConfigPath);
|
|
262
|
-
const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
|
|
263
|
-
configPaths.push(projectConfigPath);
|
|
264
|
-
this.watcher.on('add', filePath => {
|
|
265
|
-
this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
|
|
266
|
-
});
|
|
267
|
-
this.watcher.on('change', filePath => {
|
|
268
|
-
this.handleWatchEvent(filePath, WATCH_EVENTS.change, configPaths);
|
|
269
|
-
});
|
|
270
|
-
this.watcher.on('unlink', filePath => {
|
|
271
|
-
this.handleWatchEvent(filePath, WATCH_EVENTS.unlink, configPaths);
|
|
272
|
-
});
|
|
273
|
-
this.watcher.on('unlinkDir', filePath => {
|
|
274
|
-
this.handleWatchEvent(filePath, WATCH_EVENTS.unlinkDir, configPaths);
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
async stopWatching() {
|
|
278
|
-
await this.watcher?.close();
|
|
279
|
-
}
|
|
280
|
-
handleWatchEvent(filePath, event, configPaths) {
|
|
281
|
-
if (configPaths.includes(filePath)) {
|
|
282
|
-
this.logUploadWarning();
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
this.devServerFileChange(filePath, event);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
async devServerSetup() {
|
|
289
|
-
try {
|
|
290
|
-
await DevServerManagerV2_1.default.setup({
|
|
291
|
-
projectNodes: this.projectNodes,
|
|
292
|
-
accountId: this.targetTestingAccountId,
|
|
293
|
-
setActiveApp: this.setActiveApp.bind(this),
|
|
294
|
-
});
|
|
295
|
-
return true;
|
|
296
|
-
}
|
|
297
|
-
catch (e) {
|
|
298
|
-
if (this.debug) {
|
|
299
|
-
logger_1.logger.error(e);
|
|
300
|
-
}
|
|
301
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.devServer.setupError(e instanceof Error ? e.message : ''));
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
async devServerStart() {
|
|
306
|
-
try {
|
|
307
|
-
await DevServerManagerV2_1.default.start({
|
|
308
|
-
accountId: this.targetTestingAccountId,
|
|
309
|
-
projectConfig: this.projectConfig,
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
catch (e) {
|
|
313
|
-
if (this.debug) {
|
|
314
|
-
logger_1.logger.error(e);
|
|
315
|
-
}
|
|
316
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.devServer.startError(e instanceof Error ? e.message : ''));
|
|
317
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
devServerFileChange(filePath, event) {
|
|
321
|
-
try {
|
|
322
|
-
DevServerManagerV2_1.default.fileChange({ filePath, event });
|
|
323
|
-
}
|
|
324
|
-
catch (e) {
|
|
325
|
-
if (this.debug) {
|
|
326
|
-
logger_1.logger.error(e);
|
|
327
|
-
}
|
|
328
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.devServer.fileChangeError(e instanceof Error ? e.message : ''));
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
async devServerCleanup() {
|
|
332
|
-
try {
|
|
333
|
-
await DevServerManagerV2_1.default.cleanup();
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
catch (e) {
|
|
337
|
-
if (this.debug) {
|
|
338
|
-
logger_1.logger.error(e);
|
|
339
|
-
}
|
|
340
|
-
logger_2.uiLogger.error(en_1.lib.LocalDevManager.devServer.cleanupError(e instanceof Error ? e.message : ''));
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
exports.default = LocalDevManagerV2;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId: string, scopes: string[], redirectUrls: string[], isReinstall?: boolean): Promise<void>;
|
|
@@ -1,41 +0,0 @@
|
|
|
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.installPublicAppPrompt = installPublicAppPrompt;
|
|
7
|
-
const open_1 = __importDefault(require("open"));
|
|
8
|
-
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
9
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
-
const promptUtils_1 = require("./promptUtils");
|
|
11
|
-
const lang_1 = require("../lang");
|
|
12
|
-
const exitCodes_1 = require("../enums/exitCodes");
|
|
13
|
-
async function installPublicAppPrompt(env, targetAccountId, clientId, scopes, redirectUrls, isReinstall = false) {
|
|
14
|
-
logger_1.logger.log('');
|
|
15
|
-
if (isReinstall) {
|
|
16
|
-
logger_1.logger.log((0, lang_1.i18n)(`lib.prompts.installPublicAppPrompt.reinstallExplanation`));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
logger_1.logger.log((0, lang_1.i18n)(`lib.prompts.installPublicAppPrompt.explanation`));
|
|
20
|
-
}
|
|
21
|
-
const { shouldOpenBrowser } = await (0, promptUtils_1.promptUser)({
|
|
22
|
-
name: 'shouldOpenBrowser',
|
|
23
|
-
type: 'confirm',
|
|
24
|
-
message: (0, lang_1.i18n)(isReinstall
|
|
25
|
-
? `lib.prompts.installPublicAppPrompt.reinstallPrompt`
|
|
26
|
-
: `lib.prompts.installPublicAppPrompt.prompt`),
|
|
27
|
-
});
|
|
28
|
-
if (!isReinstall && !shouldOpenBrowser) {
|
|
29
|
-
logger_1.logger.log((0, lang_1.i18n)(`lib.prompts.installPublicAppPrompt.decline`));
|
|
30
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
31
|
-
}
|
|
32
|
-
else if (!shouldOpenBrowser) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
36
|
-
const url = `${websiteOrigin}/oauth/${targetAccountId}/authorize` +
|
|
37
|
-
`?client_id=${encodeURIComponent(clientId)}` +
|
|
38
|
-
`&scope=${encodeURIComponent(scopes.join(' '))}` +
|
|
39
|
-
`&redirect_uri=${encodeURIComponent(redirectUrls[0])}`;
|
|
40
|
-
(0, open_1.default)(url);
|
|
41
|
-
}
|