@hubspot/cli 7.2.1-experimental.0 → 7.2.3-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 +2 -0
- package/commands/app/migrate.d.ts +6 -0
- package/commands/app/migrate.js +80 -0
- package/commands/app.d.ts +4 -0
- package/commands/app.js +47 -0
- package/commands/project/cloneApp.d.ts +5 -1
- package/commands/project/cloneApp.js +78 -75
- package/commands/project/{dev/index.d.ts → dev.d.ts} +3 -1
- package/commands/project/{dev/deprecatedFlow.js → dev.js} +44 -14
- package/commands/project/migrateApp.d.ts +6 -1
- package/commands/project/migrateApp.js +17 -184
- package/commands/project/upload.js +2 -7
- package/lang/en.lyaml +26 -4
- package/lib/app/migrate.d.ts +6 -0
- package/lib/app/migrate.js +277 -0
- package/lib/constants.d.ts +0 -12
- package/lib/constants.js +1 -13
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -6
- package/lib/doctor/DiagnosticInfoBuilder.js +0 -5
- package/lib/doctor/Doctor.d.ts +0 -1
- package/lib/doctor/Doctor.js +0 -10
- package/lib/projects/structure.d.ts +0 -4
- package/lib/projects/structure.js +0 -9
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +2 -2
- package/lib/prompts/promptUtils.d.ts +3 -3
- package/lib/ui/index.d.ts +2 -2
- package/lib/ui/index.js +7 -4
- package/lib/usageTracking.d.ts +1 -0
- package/package.json +4 -4
- package/types/Prompts.d.ts +2 -2
- package/types/Yargs.d.ts +6 -1
- package/commands/project/dev/deprecatedFlow.d.ts +0 -5
- package/commands/project/dev/index.js +0 -52
- package/commands/project/dev/unifiedFlow.d.ts +0 -5
- package/commands/project/dev/unifiedFlow.js +0 -112
- package/lib/DevServerManagerV2.d.ts +0 -34
- package/lib/DevServerManagerV2.js +0 -85
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -382
- package/types/ProjectComponents.d.ts +0 -38
- package/types/ProjectComponents.js +0 -3
|
@@ -27,7 +27,6 @@ const configFiles = [
|
|
|
27
27
|
];
|
|
28
28
|
class DiagnosticInfoBuilder {
|
|
29
29
|
accountId;
|
|
30
|
-
configSettings;
|
|
31
30
|
env;
|
|
32
31
|
authType;
|
|
33
32
|
accountType;
|
|
@@ -40,9 +39,6 @@ class DiagnosticInfoBuilder {
|
|
|
40
39
|
constructor(processInfo) {
|
|
41
40
|
this.accountId = (0, config_1.getAccountId)();
|
|
42
41
|
const accountConfig = (0, config_2.getAccountConfig)(this.accountId);
|
|
43
|
-
this.configSettings = {
|
|
44
|
-
httpUseLocalhost: (0, config_1.isConfigFlagEnabled)('httpUseLocalhost'),
|
|
45
|
-
};
|
|
46
42
|
this.env = accountConfig?.env;
|
|
47
43
|
this.authType = accountConfig?.authType;
|
|
48
44
|
this.accountType = accountConfig?.accountType;
|
|
@@ -64,7 +60,6 @@ class DiagnosticInfoBuilder {
|
|
|
64
60
|
arch,
|
|
65
61
|
path: mainModule?.path,
|
|
66
62
|
config: (0, config_2.getConfigPath)(),
|
|
67
|
-
configSettings: this.configSettings,
|
|
68
63
|
versions: {
|
|
69
64
|
[hubspotCli]: package_json_1.default.version,
|
|
70
65
|
node,
|
package/lib/doctor/Doctor.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class Doctor {
|
|
|
10
10
|
private performCliChecks;
|
|
11
11
|
private performProjectChecks;
|
|
12
12
|
private performCliConfigChecks;
|
|
13
|
-
private performCliConfigSettingsChecks;
|
|
14
13
|
private checkIfAccessTokenValid;
|
|
15
14
|
private checkIfNodeIsInstalled;
|
|
16
15
|
private checkIfNpmIsInstalled;
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -51,7 +51,6 @@ class Doctor {
|
|
|
51
51
|
...this.performCliConfigChecks(),
|
|
52
52
|
...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
|
|
53
53
|
]);
|
|
54
|
-
this.performCliConfigSettingsChecks();
|
|
55
54
|
SpinniesManager_1.default.succeed('runningDiagnostics', {
|
|
56
55
|
text: i18n(`${i18nKey}.diagnosticsComplete`),
|
|
57
56
|
succeedColor: 'white',
|
|
@@ -88,15 +87,6 @@ class Doctor {
|
|
|
88
87
|
}
|
|
89
88
|
return [this.checkIfAccessTokenValid()];
|
|
90
89
|
}
|
|
91
|
-
performCliConfigSettingsChecks() {
|
|
92
|
-
if (this.diagnosticInfo?.configSettings.httpUseLocalhost) {
|
|
93
|
-
this.diagnosis?.addCLIConfigSection({
|
|
94
|
-
type: 'warning',
|
|
95
|
-
message: i18n(`${i18nKey}.diagnosis.cliConfig.settings.httpUseLocalhost`),
|
|
96
|
-
secondaryMessaging: i18n(`${i18nKey}.diagnosis.cliConfig.settings.httpUseLocalhostSecondary`),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
90
|
async checkIfAccessTokenValid() {
|
|
101
91
|
const localI18nKey = `${i18nKey}.accountChecks`;
|
|
102
92
|
try {
|
|
@@ -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/lib/projects/upload.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ type ProjectUploadResult<T> = {
|
|
|
5
5
|
result?: T;
|
|
6
6
|
uploadError?: unknown;
|
|
7
7
|
};
|
|
8
|
-
export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string, sendIR?: boolean
|
|
8
|
+
export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string, sendIR?: boolean): Promise<ProjectUploadResult<T>>;
|
|
9
9
|
export {};
|
package/lib/projects/upload.js
CHANGED
|
@@ -58,7 +58,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
58
58
|
}
|
|
59
59
|
return { buildId, error };
|
|
60
60
|
}
|
|
61
|
-
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false
|
|
61
|
+
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false) {
|
|
62
62
|
const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
63
63
|
const filenames = fs_extra_1.default.readdirSync(srcDir);
|
|
64
64
|
if (!filenames || filenames.length === 0) {
|
|
@@ -84,7 +84,7 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
84
84
|
projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
|
|
85
85
|
platformVersion: projectConfig.platformVersion,
|
|
86
86
|
accountId,
|
|
87
|
-
}
|
|
87
|
+
});
|
|
88
88
|
logger_1.logger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
|
|
89
89
|
}
|
|
90
90
|
catch (e) {
|
|
@@ -4,10 +4,10 @@ export declare function confirmPrompt(message: string, options?: {
|
|
|
4
4
|
defaultAnswer?: boolean;
|
|
5
5
|
when?: PromptWhen;
|
|
6
6
|
}): Promise<boolean>;
|
|
7
|
-
export declare function listPrompt(message: string, { choices, when, }: {
|
|
8
|
-
choices: PromptChoices
|
|
7
|
+
export declare function listPrompt<T = string>(message: string, { choices, when, }: {
|
|
8
|
+
choices: PromptChoices<T>;
|
|
9
9
|
when?: PromptWhen;
|
|
10
|
-
}): Promise<
|
|
10
|
+
}): Promise<T>;
|
|
11
11
|
export declare function inputPrompt(message: string, { when, }?: {
|
|
12
12
|
when?: boolean | (() => boolean);
|
|
13
13
|
}): Promise<string>;
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare function uiInfoSection(title: string, logContent: () => void): vo
|
|
|
10
10
|
export declare function uiCommandReference(command: string): string;
|
|
11
11
|
export declare function uiFeatureHighlight(commands: string[], title?: string): void;
|
|
12
12
|
export declare function uiBetaTag(message: string, log?: boolean): string | undefined;
|
|
13
|
-
export declare function uiDeprecatedTag(message: string):
|
|
13
|
+
export declare function uiDeprecatedTag(message: string, log?: boolean): string | undefined;
|
|
14
14
|
export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
|
|
15
|
-
export declare function uiDeprecatedDescription(message: string, command: string, url?: string):
|
|
15
|
+
export declare function uiDeprecatedDescription(message: string, command: string, url?: string): string | undefined;
|
|
16
16
|
export declare function uiDeprecatedMessage(command: string, url?: string, message?: string): void;
|
package/lib/ui/index.js
CHANGED
|
@@ -102,16 +102,19 @@ function uiBetaTag(message, log = true) {
|
|
|
102
102
|
logger_1.logger.log(result);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
105
|
+
return result;
|
|
108
106
|
}
|
|
109
|
-
function uiDeprecatedTag(message) {
|
|
107
|
+
function uiDeprecatedTag(message, log = true) {
|
|
110
108
|
const i18nKey = 'lib.ui';
|
|
111
109
|
const terminalUISupport = getTerminalUISupport();
|
|
112
110
|
const tag = (0, lang_1.i18n)(`${i18nKey}.deprecatedTag`);
|
|
113
111
|
const result = `${terminalUISupport.color ? chalk_1.default.yellow(tag) : tag} ${message}`;
|
|
114
112
|
logger_1.logger.log(result);
|
|
113
|
+
if (log) {
|
|
114
|
+
logger_1.logger.log(result);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
115
118
|
}
|
|
116
119
|
function uiCommandDisabledBanner(command, url, message) {
|
|
117
120
|
const i18nKey = 'lib.ui';
|
package/lib/usageTracking.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ type Meta = {
|
|
|
12
12
|
type?: string | number;
|
|
13
13
|
file?: boolean;
|
|
14
14
|
successful?: boolean;
|
|
15
|
+
status?: string;
|
|
15
16
|
};
|
|
16
17
|
export declare function trackCommandUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
|
|
17
18
|
export declare function trackHelpUsage(command: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3-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
|
-
"@hubspot/local-dev-lib": "
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.
|
|
8
|
+
"@hubspot/local-dev-lib": "0.2.6-experimental.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.0.5",
|
|
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.
|
|
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/Prompts.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export type GenericPromptResponse = {
|
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
};
|
|
5
5
|
type PromptType = 'confirm' | 'list' | 'checkbox' | 'input' | 'password' | 'number' | 'rawlist';
|
|
6
|
-
export type PromptChoices = Array<string | {
|
|
6
|
+
export type PromptChoices<T = any> = Array<string | {
|
|
7
7
|
name: string;
|
|
8
|
-
value?:
|
|
8
|
+
value?: T;
|
|
9
9
|
disabled?: string | boolean;
|
|
10
10
|
}>;
|
|
11
11
|
export type PromptWhen = boolean | (() => boolean);
|
package/types/Yargs.d.ts
CHANGED
|
@@ -23,7 +23,12 @@ 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
|
};
|
|
29
|
+
export interface MigrateAppOptions extends CommonArgs, AccountArgs, EnvironmentArgs, ConfigArgs {
|
|
30
|
+
name: string;
|
|
31
|
+
dest: string;
|
|
32
|
+
appId: number;
|
|
33
|
+
platformVersion: string;
|
|
34
|
+
}
|
|
@@ -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);
|
|
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;
|