@hubspot/cli 7.2.0-beta.0 → 7.2.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.
@@ -1,6 +1,8 @@
1
1
  import { ArgumentsCamelCase, Argv } from 'yargs';
2
- import { ProjectDevArgs } from '../../../types/Yargs';
2
+ import { CommonArgs, ConfigArgs, EnvironmentArgs } from '../../types/Yargs';
3
3
  export declare const command = "dev";
4
4
  export declare const describe: string | undefined;
5
+ type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs;
5
6
  export declare function handler(args: ArgumentsCamelCase<ProjectDevArgs>): Promise<void>;
6
7
  export declare function builder(yargs: Argv): Argv<ProjectDevArgs>;
8
+ export {};
@@ -3,25 +3,48 @@ 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.deprecatedProjectDevFlow = deprecatedProjectDevFlow;
6
+ exports.describe = exports.command = void 0;
7
+ exports.handler = handler;
8
+ exports.builder = builder;
9
+ const commonOpts_1 = require("../../lib/commonOpts");
10
+ const usageTracking_1 = require("../../lib/usageTracking");
11
+ const process_1 = require("../../lib/process");
12
+ const lang_1 = require("../../lib/lang");
7
13
  const logger_1 = require("@hubspot/local-dev-lib/logger");
8
14
  const config_1 = require("@hubspot/local-dev-lib/config");
15
+ const projects_1 = require("../../lib/projects");
16
+ const exitCodes_1 = require("../../lib/enums/exitCodes");
17
+ const ui_1 = require("../../lib/ui");
18
+ const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
19
+ const LocalDevManager_1 = __importDefault(require("../../lib/LocalDevManager"));
20
+ const accountTypes_1 = require("../../lib/accountTypes");
9
21
  const environment_1 = require("@hubspot/local-dev-lib/environment");
10
- const structure_1 = require("../../../lib/projects/structure");
11
- const Projects_1 = require("../../../types/Projects");
12
- const lang_1 = require("../../../lib/lang");
13
- const exitCodes_1 = require("../../../lib/enums/exitCodes");
14
- const ui_1 = require("../../../lib/ui");
15
- const SpinniesManager_1 = __importDefault(require("../../../lib/ui/SpinniesManager"));
16
- const LocalDevManager_1 = __importDefault(require("../../../lib/LocalDevManager"));
17
- const localDev_1 = require("../../../lib/localDev");
18
- const process_1 = require("../../../lib/process");
19
- const accountTypes_1 = require("../../../lib/accountTypes");
20
- const projects_1 = require("../../../lib/projects");
22
+ const Projects_1 = require("../../types/Projects");
23
+ const structure_1 = require("../../lib/projects/structure");
24
+ const localDev_1 = require("../../lib/localDev");
21
25
  const i18nKey = 'commands.project.subcommands.dev';
22
- async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, projectDir) {
23
- const { providedAccountId, derivedAccountId } = args;
26
+ exports.command = 'dev';
27
+ exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
28
+ async function handler(args) {
29
+ const { derivedAccountId, providedAccountId } = args;
30
+ const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
24
31
  const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
32
+ (0, usageTracking_1.trackCommandUsage)('project-dev', {}, derivedAccountId);
33
+ const { projectConfig, projectDir } = await (0, projects_1.getProjectConfig)();
34
+ (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.logs.betaMessage`));
35
+ logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.logs.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
36
+ if (!projectConfig || !projectDir) {
37
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectConfig`, {
38
+ accountId: derivedAccountId,
39
+ authCommand: (0, ui_1.uiCommandReference)('hs auth'),
40
+ }));
41
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
42
+ }
43
+ if (!accountConfig) {
44
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccount`));
45
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
46
+ }
47
+ (0, projects_1.validateProjectConfig)(projectConfig, projectDir);
25
48
  const components = await (0, structure_1.findProjectComponents)(projectDir);
26
49
  const runnableComponents = components.filter(component => component.runnable);
27
50
  const componentTypes = (0, structure_1.getProjectComponentTypes)(runnableComponents);
@@ -135,3 +158,10 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
135
158
  await LocalDev.start();
136
159
  (0, process_1.handleExit)(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP));
137
160
  }
161
+ function builder(yargs) {
162
+ (0, commonOpts_1.addConfigOptions)(yargs);
163
+ (0, commonOpts_1.addAccountOptions)(yargs);
164
+ (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
165
+ yargs.example([['$0 project dev', (0, lang_1.i18n)(`${i18nKey}.examples.default`)]]);
166
+ return yargs;
167
+ }
package/lang/en.lyaml CHANGED
@@ -529,7 +529,6 @@ en:
529
529
  noAccountsInConfig: "No accounts found in your config. Run {{ authCommand }} to configure a HubSpot account with the CLI."
530
530
  invalidProjectComponents: "Projects cannot contain both private and public apps. Move your apps to separate projects before attempting local development."
531
531
  noRunnableComponents: "No supported components were found in this project. Run {{ command }} to see a list of available components and add one to your project."
532
- invalidUnifiedAppsAccount: "Local development of Unified Apps is currently only supported in standard and developer accounts. Target a standard or developer account with {{ authCommand }} and try again."
533
532
  examples:
534
533
  default: "Start local dev for the current project"
535
534
  create:
@@ -62,15 +62,3 @@ export declare const PLATFORM_VERSION_ERROR_TYPES: {
62
62
  readonly PLATFORM_VERSION_RETIRED: "PlatformVersionErrorType.PLATFORM_VERSION_RETIRED";
63
63
  readonly PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST: "PlatformVersionErrorType.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST";
64
64
  };
65
- export declare const IR_COMPONENT_TYPES: {
66
- readonly APPLICATION: "APPLICATION";
67
- readonly CARD: "CARD";
68
- };
69
- export declare const APP_DISTRIBUTION_TYPES: {
70
- readonly MARKETPLACE: "marketplace";
71
- readonly PRIVATE: "private";
72
- };
73
- export declare const APP_AUTH_TYPES: {
74
- readonly OAUTH: "oauth";
75
- readonly STATIC: "static";
76
- };
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APP_AUTH_TYPES = exports.APP_DISTRIBUTION_TYPES = exports.IR_COMPONENT_TYPES = exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
3
+ exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
4
4
  exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
5
5
  exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
6
6
  exports.FEEDBACK_INTERVAL = 10;
@@ -57,15 +57,3 @@ exports.PLATFORM_VERSION_ERROR_TYPES = {
57
57
  PLATFORM_VERSION_RETIRED: 'PlatformVersionErrorType.PLATFORM_VERSION_RETIRED',
58
58
  PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST: 'PlatformVersionErrorType.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST',
59
59
  };
60
- exports.IR_COMPONENT_TYPES = {
61
- APPLICATION: 'APPLICATION',
62
- CARD: 'CARD',
63
- };
64
- exports.APP_DISTRIBUTION_TYPES = {
65
- MARKETPLACE: 'marketplace',
66
- PRIVATE: 'private',
67
- };
68
- exports.APP_AUTH_TYPES = {
69
- OAUTH: 'oauth',
70
- STATIC: 'static',
71
- };
package/lib/localDev.d.ts CHANGED
@@ -14,5 +14,5 @@ export declare function createSandboxForLocalDev(accountId: number, accountConfi
14
14
  export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
15
15
  export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
16
16
  export declare function createNewProjectForLocalDev(projectConfig: ProjectConfig, targetAccountId: number, shouldCreateWithoutConfirmation: boolean, hasPublicApps: boolean): Promise<Project>;
17
- export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number, sendIr?: boolean): Promise<Build>;
17
+ export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number): Promise<Build>;
18
18
  export declare function getAccountHomeUrl(accountId: number): string;
package/lib/localDev.js CHANGED
@@ -294,8 +294,8 @@ function projectUploadCallback(accountId, projectConfig, tempFile, buildId) {
294
294
  }
295
295
  // Create an initial build if the project was newly created in the account
296
296
  // Return the newly deployed build
297
- async function createInitialBuildForNewProject(projectConfig, projectDir, targetAccountId, sendIr) {
298
- const { result: initialUploadResult, uploadError } = await (0, upload_1.handleProjectUpload)(targetAccountId, projectConfig, projectDir, projectUploadCallback, (0, lang_1.i18n)(`${i18nKey}.createInitialBuildForNewProject.initialUploadMessage`), sendIr);
297
+ async function createInitialBuildForNewProject(projectConfig, projectDir, targetAccountId) {
298
+ const { result: initialUploadResult, uploadError } = await (0, upload_1.handleProjectUpload)(targetAccountId, projectConfig, projectDir, projectUploadCallback, (0, lang_1.i18n)(`${i18nKey}.createInitialBuildForNewProject.initialUploadMessage`));
299
299
  if (uploadError) {
300
300
  if ((0, index_1.isSpecifiedError)(uploadError, {
301
301
  subCategory: constants_1.PROJECT_ERROR_TYPES.PROJECT_LOCKED,
@@ -1,6 +1,4 @@
1
1
  import { ComponentTypes, Component, GenericComponentConfig, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
2
- import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
3
- import { AppIRNode, CardIRNode } from '../../types/ProjectComponents';
4
2
  export declare const CONFIG_FILES: {
5
3
  [k in ComponentTypes]: string;
6
4
  };
@@ -15,5 +13,3 @@ export declare function getProjectComponentTypes(components: Array<Component>):
15
13
  export declare function getComponentUid(component?: Component | null): string | null;
16
14
  export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
17
15
  export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
18
- export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev): component is AppIRNode;
19
- export declare function isCardIRNode(component: IntermediateRepresentationNodeLocalDev): component is CardIRNode;
@@ -43,15 +43,12 @@ exports.getProjectComponentTypes = getProjectComponentTypes;
43
43
  exports.getComponentUid = getComponentUid;
44
44
  exports.componentIsApp = componentIsApp;
45
45
  exports.componentIsPublicApp = componentIsPublicApp;
46
- exports.isAppIRNode = isAppIRNode;
47
- exports.isCardIRNode = isCardIRNode;
48
46
  const fs = __importStar(require("fs"));
49
47
  const path = __importStar(require("path"));
50
48
  const fs_1 = require("@hubspot/local-dev-lib/fs");
51
49
  const logger_1 = require("@hubspot/local-dev-lib/logger");
52
50
  const index_1 = require("../errorHandlers/index");
53
51
  const Projects_1 = require("../../types/Projects");
54
- const constants_1 = require("../constants");
55
52
  exports.CONFIG_FILES = {
56
53
  [Projects_1.ComponentTypes.PrivateApp]: 'app.json',
57
54
  [Projects_1.ComponentTypes.PublicApp]: 'public-app.json',
@@ -172,9 +169,3 @@ function componentIsApp(component) {
172
169
  function componentIsPublicApp(component) {
173
170
  return component?.type === Projects_1.ComponentTypes.PublicApp;
174
171
  }
175
- function isAppIRNode(component) {
176
- return component.componentType === constants_1.IR_COMPONENT_TYPES.APPLICATION;
177
- }
178
- function isCardIRNode(component) {
179
- return component.componentType === constants_1.IR_COMPONENT_TYPES.CARD;
180
- }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.2.0-beta.0",
3
+ "version": "7.2.0-experimental.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
7
7
  "dependencies": {
8
8
  "@hubspot/local-dev-lib": "3.3.2",
9
- "@hubspot/project-parsing-lib": "0.1.1",
9
+ "@hubspot/project-parsing-lib": "0.0.12-experimental.0",
10
10
  "@hubspot/serverless-dev-runtime": "7.0.2",
11
11
  "@hubspot/theme-preview-dev-server": "0.0.10",
12
- "@hubspot/ui-extensions-dev-server": "0.8.48",
12
+ "@hubspot/ui-extensions-dev-server": "0.8.42",
13
13
  "archiver": "7.0.1",
14
14
  "chalk": "4.1.2",
15
15
  "chokidar": "3.6.0",
package/types/Yargs.d.ts CHANGED
@@ -23,7 +23,6 @@ export type OverwriteArgs = Options & {
23
23
  export type StringArgType = Options & {
24
24
  type: 'string';
25
25
  };
26
- export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs;
27
26
  export type TestingArgs = {
28
27
  qa?: boolean;
29
28
  };
@@ -1,5 +0,0 @@
1
- import { ArgumentsCamelCase } from 'yargs';
2
- import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
3
- import { ProjectConfig } from '../../../types/Projects';
4
- import { ProjectDevArgs } from '../../../types/Yargs';
5
- export declare function deprecatedProjectDevFlow(args: ArgumentsCamelCase<ProjectDevArgs>, accountConfig: CLIAccount, projectConfig: ProjectConfig, projectDir: string): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.describe = exports.command = void 0;
4
- exports.handler = handler;
5
- exports.builder = builder;
6
- const commonOpts_1 = require("../../../lib/commonOpts");
7
- const usageTracking_1 = require("../../../lib/usageTracking");
8
- const lang_1 = require("../../../lib/lang");
9
- const logger_1 = require("@hubspot/local-dev-lib/logger");
10
- const config_1 = require("@hubspot/local-dev-lib/config");
11
- const projects_1 = require("../../../lib/projects");
12
- const exitCodes_1 = require("../../../lib/enums/exitCodes");
13
- const ui_1 = require("../../../lib/ui");
14
- const deprecatedFlow_1 = require("./deprecatedFlow");
15
- const unifiedFlow_1 = require("./unifiedFlow");
16
- const buildAndDeploy_1 = require("../../../lib/projects/buildAndDeploy");
17
- const i18nKey = 'commands.project.subcommands.dev';
18
- exports.command = 'dev';
19
- exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
20
- async function handler(args) {
21
- const { derivedAccountId } = args;
22
- const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
23
- (0, usageTracking_1.trackCommandUsage)('project-dev', {}, derivedAccountId);
24
- const { projectConfig, projectDir } = await (0, projects_1.getProjectConfig)();
25
- (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.logs.betaMessage`));
26
- logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.logs.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
27
- if (!projectConfig || !projectDir) {
28
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectConfig`, {
29
- accountId: derivedAccountId,
30
- authCommand: (0, ui_1.uiCommandReference)('hs auth'),
31
- }));
32
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
33
- }
34
- if (!accountConfig) {
35
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccount`));
36
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
37
- }
38
- (0, projects_1.validateProjectConfig)(projectConfig, projectDir);
39
- if ((0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion)) {
40
- await (0, unifiedFlow_1.unifiedProjectDevFlow)(args, accountConfig, projectConfig, projectDir);
41
- }
42
- else {
43
- await (0, deprecatedFlow_1.deprecatedProjectDevFlow)(args, accountConfig, projectConfig, projectDir);
44
- }
45
- }
46
- function builder(yargs) {
47
- (0, commonOpts_1.addConfigOptions)(yargs);
48
- (0, commonOpts_1.addAccountOptions)(yargs);
49
- (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
50
- yargs.example([['$0 project dev', (0, lang_1.i18n)(`${i18nKey}.examples.default`)]]);
51
- return yargs;
52
- }
@@ -1,5 +0,0 @@
1
- import { ArgumentsCamelCase } from 'yargs';
2
- import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
3
- import { ProjectDevArgs } from '../../../types/Yargs';
4
- import { ProjectConfig } from '../../../types/Projects';
5
- export declare function unifiedProjectDevFlow(args: ArgumentsCamelCase<ProjectDevArgs>, accountConfig: CLIAccount, projectConfig: ProjectConfig, projectDir: string): Promise<void>;
@@ -1,112 +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.unifiedProjectDevFlow = unifiedProjectDevFlow;
7
- const path_1 = __importDefault(require("path"));
8
- const util_1 = __importDefault(require("util"));
9
- const logger_1 = require("@hubspot/local-dev-lib/logger");
10
- const errors_1 = require("@hubspot/project-parsing-lib/src/lib/errors");
11
- const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
12
- const config_1 = require("@hubspot/local-dev-lib/config");
13
- const environment_1 = require("@hubspot/local-dev-lib/environment");
14
- const errorHandlers_1 = require("../../../lib/errorHandlers");
15
- const exitCodes_1 = require("../../../lib/enums/exitCodes");
16
- const projects_1 = require("../../../lib/projects");
17
- const localDev_1 = require("../../../lib/localDev");
18
- const projectDevTargetAccountPrompt_1 = require("../../../lib/prompts/projectDevTargetAccountPrompt");
19
- const SpinniesManager_1 = __importDefault(require("../../../lib/ui/SpinniesManager"));
20
- const LocalDevManagerV2_1 = __importDefault(require("../../../lib/LocalDevManagerV2"));
21
- const process_1 = require("../../../lib/process");
22
- const accountTypes_1 = require("../../../lib/accountTypes");
23
- const ui_1 = require("../../../lib/ui");
24
- const lang_1 = require("../../../lib/lang");
25
- const i18nKey = 'commands.project.subcommands.dev';
26
- async function unifiedProjectDevFlow(args, accountConfig, projectConfig, projectDir) {
27
- logger_1.logger.log('Unified Apps Local Dev');
28
- const targetProjectAccountId = args.derivedAccountId;
29
- const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(targetProjectAccountId));
30
- let projectNodes;
31
- // Get IR
32
- try {
33
- const intermediateRepresentation = await (0, project_parsing_lib_1.translateForLocalDev)({
34
- projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
35
- platformVersion: projectConfig.platformVersion,
36
- accountId: targetProjectAccountId,
37
- });
38
- projectNodes = intermediateRepresentation.intermediateNodesIndexedByUid;
39
- logger_1.logger.debug(util_1.default.inspect(projectNodes, false, null, true));
40
- }
41
- catch (e) {
42
- if ((0, errors_1.isTranslationError)(e)) {
43
- logger_1.logger.error(e.toString());
44
- }
45
- else {
46
- (0, errorHandlers_1.logError)(e);
47
- }
48
- return process.exit(exitCodes_1.EXIT_CODES.ERROR);
49
- }
50
- // @TODO Do we need to do more than this or leave it to the dev servers?
51
- if (!Object.keys(projectNodes).length) {
52
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noRunnableComponents`, {
53
- projectDir,
54
- command: (0, ui_1.uiCommandReference)('hs project add'),
55
- }));
56
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
57
- }
58
- // @TODO Validate component types (i.e. previously you could not have both private and public apps)
59
- const accounts = (0, config_1.getConfigAccounts)();
60
- // TODO Ideally this should require the user to target a Combined account
61
- // For now, check if the account is either developer or standard
62
- const derivedAccountIsRecommendedType = (0, accountTypes_1.isAppDeveloperAccount)(accountConfig) || (0, accountTypes_1.isStandardAccount)(accountConfig);
63
- if (!derivedAccountIsRecommendedType) {
64
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidUnifiedAppsAccount`), {
65
- authCommand: (0, ui_1.uiCommandReference)('hs auth'),
66
- });
67
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
68
- }
69
- let targetTestingAccountId = null;
70
- const devAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectDeveloperTestTargetAccountPrompt)(accounts, accountConfig);
71
- targetTestingAccountId = devAccountPromptResponse.targetAccountId;
72
- if (!!devAccountPromptResponse.notInConfigAccount) {
73
- // When the developer test account isn't configured in the CLI config yet
74
- // Walk the user through adding the account's PAK to the config
75
- await (0, localDev_1.useExistingDevTestAccount)(env, devAccountPromptResponse.notInConfigAccount);
76
- }
77
- else if (devAccountPromptResponse.createNestedAccount) {
78
- // Create a new developer test account and automatically add it to the CLI config
79
- targetTestingAccountId = await (0, localDev_1.createDeveloperTestAccountForLocalDev)(targetProjectAccountId, accountConfig, env);
80
- }
81
- // Check if project exists in HubSpot
82
- const { projectExists, project: uploadedProject } = await (0, projects_1.ensureProjectExists)(targetProjectAccountId, projectConfig.name, {
83
- allowCreate: false,
84
- noLogs: true,
85
- });
86
- let deployedBuild;
87
- let isGithubLinked = false;
88
- let project = uploadedProject;
89
- SpinniesManager_1.default.init();
90
- if (projectExists && project) {
91
- deployedBuild = project.deployedBuild;
92
- isGithubLinked = Boolean(project.sourceIntegration && project.sourceIntegration.source === 'GITHUB');
93
- }
94
- else {
95
- project = await (0, localDev_1.createNewProjectForLocalDev)(projectConfig, targetProjectAccountId, false, false);
96
- deployedBuild = await (0, localDev_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId, true);
97
- }
98
- const LocalDev = new LocalDevManagerV2_1.default({
99
- projectNodes,
100
- debug: args.debug,
101
- deployedBuild,
102
- isGithubLinked,
103
- targetProjectAccountId,
104
- targetTestingAccountId: targetTestingAccountId,
105
- projectConfig,
106
- projectDir,
107
- projectId: project.id,
108
- env,
109
- });
110
- await LocalDev.start();
111
- (0, process_1.handleExit)(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP));
112
- }
@@ -1,34 +0,0 @@
1
- import { ProjectConfig } from '../types/Projects';
2
- import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
3
- type DevServerInterface = {
4
- setup?: Function;
5
- start?: (options: object) => Promise<void>;
6
- fileChange?: (filePath: string, event: string) => Promise<void>;
7
- cleanup?: () => Promise<void>;
8
- };
9
- declare class DevServerManagerV2 {
10
- private initialized;
11
- private started;
12
- private devServers;
13
- constructor();
14
- iterateDevServers(callback: (serverInterface: DevServerInterface) => Promise<void>): Promise<void>;
15
- setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }: {
16
- projectNodes: {
17
- [key: string]: IntermediateRepresentationNodeLocalDev;
18
- };
19
- onUploadRequired: () => void;
20
- accountId: number;
21
- setActiveApp: (appUid: string | undefined) => Promise<void>;
22
- }): Promise<void>;
23
- start({ accountId, projectConfig, }: {
24
- accountId: number;
25
- projectConfig: ProjectConfig;
26
- }): Promise<void>;
27
- fileChange({ filePath, event, }: {
28
- filePath: string;
29
- event: string;
30
- }): Promise<void>;
31
- cleanup(): Promise<void>;
32
- }
33
- declare const Manager: DevServerManagerV2;
34
- export default Manager;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("@hubspot/local-dev-lib/logger");
4
- const lang_1 = require("./lang");
5
- const promptUtils_1 = require("./prompts/promptUtils");
6
- const ui_extensions_dev_server_1 = require("@hubspot/ui-extensions-dev-server");
7
- const portManager_1 = require("@hubspot/local-dev-lib/portManager");
8
- const urls_1 = require("@hubspot/local-dev-lib/urls");
9
- const config_1 = require("@hubspot/local-dev-lib/config");
10
- const i18nKey = 'lib.DevServerManager';
11
- class DevServerManagerV2 {
12
- initialized;
13
- started;
14
- devServers;
15
- constructor() {
16
- this.initialized = false;
17
- this.started = false;
18
- this.devServers = [ui_extensions_dev_server_1.DevModeUnifiedInterface];
19
- }
20
- async iterateDevServers(callback) {
21
- await Promise.all(this.devServers.map(devServer => callback(devServer)));
22
- }
23
- async setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }) {
24
- let env;
25
- const accountConfig = (0, config_1.getAccountConfig)(accountId);
26
- if (accountConfig) {
27
- env = accountConfig.env;
28
- }
29
- await (0, portManager_1.startPortManagerServer)();
30
- await this.iterateDevServers(async (serverInterface) => {
31
- if (serverInterface.setup) {
32
- await serverInterface.setup({
33
- components: projectNodes,
34
- onUploadRequired,
35
- promptUser: promptUtils_1.promptUser,
36
- logger: logger_1.logger,
37
- urls: {
38
- api: (0, urls_1.getHubSpotApiOrigin)(env),
39
- web: (0, urls_1.getHubSpotWebsiteOrigin)(env),
40
- },
41
- setActiveApp,
42
- });
43
- }
44
- });
45
- this.initialized = true;
46
- }
47
- async start({ accountId, projectConfig, }) {
48
- if (this.initialized) {
49
- await this.iterateDevServers(async (serverInterface) => {
50
- if (serverInterface.start) {
51
- await serverInterface.start({
52
- accountId,
53
- projectConfig,
54
- requestPorts: portManager_1.requestPorts,
55
- });
56
- }
57
- });
58
- }
59
- else {
60
- throw new Error((0, lang_1.i18n)(`${i18nKey}.notInitialized`));
61
- }
62
- this.started = true;
63
- }
64
- async fileChange({ filePath, event, }) {
65
- if (this.started) {
66
- this.iterateDevServers(async (serverInterface) => {
67
- if (serverInterface.fileChange) {
68
- await serverInterface.fileChange(filePath, event);
69
- }
70
- });
71
- }
72
- }
73
- async cleanup() {
74
- if (this.started) {
75
- await this.iterateDevServers(async (serverInterface) => {
76
- if (serverInterface.cleanup) {
77
- await serverInterface.cleanup();
78
- }
79
- });
80
- await (0, portManager_1.stopPortManagerServer)();
81
- }
82
- }
83
- }
84
- const Manager = new DevServerManagerV2();
85
- exports.default = Manager;
@@ -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,382 +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 constants_1 = require("./constants");
14
- const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
15
- const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
16
- const exitCodes_1 = require("./enums/exitCodes");
17
- const urls_1 = require("./projects/urls");
18
- const structure_1 = require("./projects/structure");
19
- const ui_1 = require("./ui");
20
- const index_1 = require("./errorHandlers/index");
21
- const installPublicAppPrompt_1 = require("./prompts/installPublicAppPrompt");
22
- const promptUtils_1 = require("./prompts/promptUtils");
23
- const lang_1 = require("./lang");
24
- const process_1 = require("./process");
25
- const WATCH_EVENTS = {
26
- add: 'add',
27
- change: 'change',
28
- unlink: 'unlink',
29
- unlinkDir: 'unlinkDir',
30
- };
31
- const i18nKey = 'lib.LocalDevManager';
32
- class LocalDevManagerV2 {
33
- targetProjectAccountId;
34
- targetTestingAccountId;
35
- projectConfig;
36
- projectDir;
37
- projectId;
38
- debug;
39
- deployedBuild;
40
- isGithubLinked;
41
- watcher;
42
- uploadWarnings;
43
- projectNodes;
44
- activeApp;
45
- activePublicAppData;
46
- env;
47
- publicAppActiveInstalls;
48
- projectSourceDir;
49
- mostRecentUploadWarning;
50
- constructor(options) {
51
- this.targetProjectAccountId = options.targetProjectAccountId;
52
- this.targetTestingAccountId = options.targetTestingAccountId;
53
- this.projectConfig = options.projectConfig;
54
- this.projectDir = options.projectDir;
55
- this.projectId = options.projectId;
56
- this.debug = options.debug || false;
57
- this.deployedBuild = options.deployedBuild;
58
- this.isGithubLinked = options.isGithubLinked;
59
- this.watcher = null;
60
- this.uploadWarnings = {};
61
- this.projectNodes = options.projectNodes;
62
- this.activeApp = null;
63
- this.activePublicAppData = null;
64
- this.env = options.env;
65
- this.publicAppActiveInstalls = null;
66
- this.mostRecentUploadWarning = null;
67
- this.projectSourceDir = path_1.default.join(this.projectDir, this.projectConfig.srcDir);
68
- if (!this.targetProjectAccountId ||
69
- !this.projectConfig ||
70
- !this.projectDir) {
71
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.failedToInitialize`));
72
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
73
- }
74
- }
75
- async setActiveApp(appUid) {
76
- if (!appUid) {
77
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.missingUid`, {
78
- devCommand: (0, ui_1.uiCommandReference)('hs project dev'),
79
- }));
80
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
81
- }
82
- const app = Object.values(this.projectNodes).find(component => component.uid === appUid) || null;
83
- if (app && (0, structure_1.isAppIRNode)(app)) {
84
- this.activeApp = app;
85
- if (app.config.distribution === constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE) {
86
- try {
87
- await this.setActivePublicAppData();
88
- await this.checkActivePublicAppInstalls();
89
- await this.checkPublicAppInstallation();
90
- }
91
- catch (e) {
92
- (0, index_1.logError)(e);
93
- }
94
- }
95
- }
96
- return;
97
- }
98
- async setActivePublicAppData() {
99
- const { data: { results: portalPublicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.targetProjectAccountId);
100
- const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === this.activeApp?.uid);
101
- if (!activePublicAppData) {
102
- return;
103
- }
104
- const { data: { uniquePortalInstallCount }, } = await (0, appsDev_1.fetchPublicAppProductionInstallCounts)(activePublicAppData.id, this.targetProjectAccountId);
105
- this.activePublicAppData = activePublicAppData;
106
- this.publicAppActiveInstalls = uniquePortalInstallCount;
107
- }
108
- async checkActivePublicAppInstalls() {
109
- if (!this.activePublicAppData ||
110
- !this.publicAppActiveInstalls ||
111
- this.publicAppActiveInstalls < 1) {
112
- return;
113
- }
114
- (0, ui_1.uiLine)();
115
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.installCount`, {
116
- appName: this.activePublicAppData.name,
117
- installCount: this.publicAppActiveInstalls,
118
- installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
119
- }));
120
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.explanation`));
121
- (0, ui_1.uiLine)();
122
- const proceed = await (0, promptUtils_1.confirmPrompt)((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.confirmationPrompt`), { defaultAnswer: false });
123
- if (!proceed) {
124
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
125
- }
126
- }
127
- async start() {
128
- SpinniesManager_1.default.stopAll();
129
- SpinniesManager_1.default.init();
130
- // Local dev currently relies on the existence of a deployed build in the target account
131
- if (!this.deployedBuild) {
132
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.noDeployedBuild`, {
133
- projectName: this.projectConfig.name,
134
- accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetProjectAccountId),
135
- uploadCommand: this.getUploadCommand(),
136
- }));
137
- logger_1.logger.log();
138
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
139
- }
140
- const setupSucceeded = await this.devServerSetup();
141
- if (!setupSucceeded) {
142
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
143
- }
144
- else if (!this.debug) {
145
- console.clear();
146
- }
147
- (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.betaMessage`));
148
- logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
149
- logger_1.logger.log();
150
- logger_1.logger.log(chalk_1.default.hex(ui_1.UI_COLORS.SORBET)((0, lang_1.i18n)(`${i18nKey}.running`, {
151
- accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetProjectAccountId),
152
- projectName: this.projectConfig.name,
153
- })));
154
- logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.viewProjectLink`), (0, urls_1.getProjectDetailUrl)(this.projectConfig.name, this.targetProjectAccountId) || ''));
155
- logger_1.logger.log();
156
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.quitHelper`));
157
- (0, ui_1.uiLine)();
158
- logger_1.logger.log();
159
- await this.devServerStart();
160
- // Initialize project file watcher to detect configuration file changes
161
- this.startWatching();
162
- this.updateKeypressListeners();
163
- this.monitorConsoleOutput();
164
- // Verify that there are no mismatches between components in the local project
165
- // and components in the deployed build of the project.
166
- this.compareLocalProjectToDeployed();
167
- }
168
- async stop(showProgress = true) {
169
- if (showProgress) {
170
- SpinniesManager_1.default.add('cleanupMessage', {
171
- text: (0, lang_1.i18n)(`${i18nKey}.exitingStart`),
172
- });
173
- }
174
- await this.stopWatching();
175
- const cleanupSucceeded = await this.devServerCleanup();
176
- if (!cleanupSucceeded) {
177
- if (showProgress) {
178
- SpinniesManager_1.default.fail('cleanupMessage', {
179
- text: (0, lang_1.i18n)(`${i18nKey}.exitingFail`),
180
- });
181
- }
182
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
183
- }
184
- if (showProgress) {
185
- SpinniesManager_1.default.succeed('cleanupMessage', {
186
- text: (0, lang_1.i18n)(`${i18nKey}.exitingSucceed`),
187
- });
188
- }
189
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
190
- }
191
- async checkPublicAppInstallation() {
192
- if (!this.activeApp || !this.activePublicAppData) {
193
- return;
194
- }
195
- 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);
196
- const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
197
- if (!isInstalledWithScopeGroups) {
198
- await (0, installPublicAppPrompt_1.installPublicAppPrompt)(this.env, this.targetTestingAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
199
- }
200
- }
201
- updateKeypressListeners() {
202
- (0, process_1.handleKeypress)(async (key) => {
203
- if ((key.ctrl && key.name === 'c') || key.name === 'q') {
204
- this.stop();
205
- }
206
- });
207
- }
208
- getUploadCommand() {
209
- const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)() || undefined;
210
- return this.targetProjectAccountId !== (0, config_1.getAccountId)(currentDefaultAccount)
211
- ? (0, ui_1.uiCommandReference)(`hs project upload --account=${this.targetProjectAccountId}`)
212
- : (0, ui_1.uiCommandReference)('hs project upload');
213
- }
214
- logUploadWarning(reason) {
215
- let warning;
216
- if (reason) {
217
- warning = reason;
218
- }
219
- else {
220
- warning =
221
- this.publicAppActiveInstalls && this.publicAppActiveInstalls > 0
222
- ? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultPublicAppWarning`, {
223
- installCount: this.publicAppActiveInstalls,
224
- installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
225
- })
226
- : (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultWarning`);
227
- }
228
- // Avoid logging the warning to the console if it is currently the most
229
- // recently logged warning. We do not want to spam the console with the same message.
230
- if (!this.uploadWarnings[warning]) {
231
- logger_1.logger.log();
232
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.uploadWarning.header`, { warning }));
233
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.stopDev`, {
234
- command: (0, ui_1.uiCommandReference)('hs project dev'),
235
- }));
236
- if (this.isGithubLinked) {
237
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.pushToGithub`));
238
- }
239
- else {
240
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.runUpload`, {
241
- command: this.getUploadCommand(),
242
- }));
243
- }
244
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.restartDev`, {
245
- command: (0, ui_1.uiCommandReference)('hs project dev'),
246
- }));
247
- this.mostRecentUploadWarning = warning;
248
- this.uploadWarnings[warning] = true;
249
- }
250
- }
251
- monitorConsoleOutput() {
252
- const originalStdoutWrite = process.stdout.write.bind(process.stdout);
253
- function customStdoutWrite(chunk, encoding, callback) {
254
- // Reset the most recently logged warning
255
- if (this.mostRecentUploadWarning &&
256
- this.uploadWarnings[this.mostRecentUploadWarning]) {
257
- delete this.uploadWarnings[this.mostRecentUploadWarning];
258
- }
259
- if (typeof encoding === 'function') {
260
- return originalStdoutWrite(chunk, callback);
261
- }
262
- return originalStdoutWrite(chunk, encoding, callback);
263
- }
264
- customStdoutWrite.bind(this);
265
- process.stdout.write = customStdoutWrite;
266
- }
267
- compareLocalProjectToDeployed() {
268
- const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
269
- const missingProjectNodes = [];
270
- Object.values(this.projectNodes).forEach(node => {
271
- if ((0, structure_1.isAppIRNode)(node) || (0, structure_1.isCardIRNode)(node)) {
272
- if (!deployedComponentNames.includes(node.uid)) {
273
- missingProjectNodes.push(`${(0, lang_1.i18n)(`${i18nKey}.uploadWarning.appLabel`)} ${node.uid}`);
274
- }
275
- }
276
- });
277
- if (missingProjectNodes.length) {
278
- this.logUploadWarning((0, lang_1.i18n)(`${i18nKey}.uploadWarning.missingComponents`, {
279
- missingComponents: missingProjectNodes.join(', '),
280
- }));
281
- }
282
- }
283
- startWatching() {
284
- this.watcher = chokidar_1.default.watch(this.projectDir, {
285
- ignoreInitial: true,
286
- });
287
- const configPaths = Object.values(this.projectNodes)
288
- .filter(structure_1.isAppIRNode)
289
- .map(component => component.localDev.componentConfigPath);
290
- const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
291
- configPaths.push(projectConfigPath);
292
- this.watcher.on('add', filePath => {
293
- this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
294
- });
295
- this.watcher.on('change', filePath => {
296
- this.handleWatchEvent(filePath, WATCH_EVENTS.change, configPaths);
297
- });
298
- this.watcher.on('unlink', filePath => {
299
- this.handleWatchEvent(filePath, WATCH_EVENTS.unlink, configPaths);
300
- });
301
- this.watcher.on('unlinkDir', filePath => {
302
- this.handleWatchEvent(filePath, WATCH_EVENTS.unlinkDir, configPaths);
303
- });
304
- }
305
- async stopWatching() {
306
- await this.watcher?.close();
307
- }
308
- handleWatchEvent(filePath, event, configPaths) {
309
- if (configPaths.includes(filePath)) {
310
- this.logUploadWarning();
311
- }
312
- else {
313
- this.devServerFileChange(filePath, event);
314
- }
315
- }
316
- async devServerSetup() {
317
- try {
318
- await DevServerManagerV2_1.default.setup({
319
- projectNodes: this.projectNodes,
320
- onUploadRequired: this.logUploadWarning.bind(this),
321
- accountId: this.targetTestingAccountId,
322
- setActiveApp: this.setActiveApp.bind(this),
323
- });
324
- return true;
325
- }
326
- catch (e) {
327
- if (this.debug) {
328
- logger_1.logger.error(e);
329
- }
330
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.setupError`, {
331
- message: e instanceof Error ? e.message : '',
332
- }));
333
- return false;
334
- }
335
- }
336
- async devServerStart() {
337
- try {
338
- await DevServerManagerV2_1.default.start({
339
- accountId: this.targetTestingAccountId,
340
- projectConfig: this.projectConfig,
341
- });
342
- }
343
- catch (e) {
344
- if (this.debug) {
345
- logger_1.logger.error(e);
346
- }
347
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.startError`, {
348
- message: e instanceof Error ? e.message : '',
349
- }));
350
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
351
- }
352
- }
353
- devServerFileChange(filePath, event) {
354
- try {
355
- DevServerManagerV2_1.default.fileChange({ filePath, event });
356
- }
357
- catch (e) {
358
- if (this.debug) {
359
- logger_1.logger.error(e);
360
- }
361
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.fileChangeError`, {
362
- message: e instanceof Error ? e.message : '',
363
- }));
364
- }
365
- }
366
- async devServerCleanup() {
367
- try {
368
- await DevServerManagerV2_1.default.cleanup();
369
- return true;
370
- }
371
- catch (e) {
372
- if (this.debug) {
373
- logger_1.logger.error(e);
374
- }
375
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.cleanupError`, {
376
- message: e instanceof Error ? e.message : '',
377
- }));
378
- return false;
379
- }
380
- }
381
- }
382
- exports.default = LocalDevManagerV2;
@@ -1,38 +0,0 @@
1
- import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
2
- import { IR_COMPONENT_TYPES, APP_DISTRIBUTION_TYPES, APP_AUTH_TYPES } from '../lib/constants';
3
- import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
4
- type AppDistributionType = ValueOf<typeof APP_DISTRIBUTION_TYPES>;
5
- type AppAuthType = ValueOf<typeof APP_AUTH_TYPES>;
6
- type AppConfig = {
7
- description: string;
8
- name: string;
9
- logo: string;
10
- distribution: AppDistributionType;
11
- auth: {
12
- type: AppAuthType;
13
- redirectUrls: string[];
14
- requiredScopes: string[];
15
- optionalScopes: string[];
16
- conditionallyRequiredScopes: string[];
17
- };
18
- };
19
- type CardConfig = {
20
- name: string;
21
- description: string;
22
- previewImage: {
23
- file: string;
24
- altText: string;
25
- };
26
- entrypoint: string;
27
- location: string;
28
- objectTypes: string[];
29
- };
30
- export interface AppIRNode extends IntermediateRepresentationNodeLocalDev {
31
- componentType: typeof IR_COMPONENT_TYPES.APPLICATION;
32
- config: AppConfig;
33
- }
34
- export interface CardIRNode extends IntermediateRepresentationNodeLocalDev {
35
- componentType: typeof IR_COMPONENT_TYPES.CARD;
36
- config: CardConfig;
37
- }
38
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- // These types are for Unified Apps and projects on platform version 2025.1 and above
3
- Object.defineProperty(exports, "__esModule", { value: true });