@hubspot/cli 7.2.1-experimental.0 → 7.2.2-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 +52 -3
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +154 -0
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +62 -0
- package/commands/account/list.js +4 -0
- package/commands/account.js +4 -0
- package/commands/auth.js +9 -5
- package/commands/config/migrate.d.ts +10 -0
- package/commands/config/migrate.js +86 -0
- package/commands/config/set.d.ts +12 -0
- package/commands/config/set.js +30 -29
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -10
- package/commands/create/api-sample.js +4 -14
- package/commands/customObject/create.d.ts +0 -11
- package/commands/customObject/create.js +28 -37
- package/commands/customObject/schema/create.d.ts +0 -10
- package/commands/customObject/schema/create.js +42 -40
- package/commands/customObject/schema/delete.d.ts +0 -11
- package/commands/customObject/schema/delete.js +27 -34
- package/commands/customObject/schema/fetch-all.d.ts +0 -10
- package/commands/customObject/schema/fetch-all.js +24 -31
- package/commands/customObject/schema/fetch.d.ts +0 -11
- package/commands/customObject/schema/fetch.js +42 -34
- package/commands/customObject/schema/list.d.ts +0 -7
- package/commands/customObject/schema/list.js +14 -23
- package/commands/customObject/schema/update.d.ts +0 -11
- package/commands/customObject/schema/update.js +46 -44
- package/commands/customObject/schema.d.ts +1 -5
- package/commands/customObject/schema.js +11 -49
- package/commands/customObject.d.ts +1 -4
- package/commands/customObject.js +21 -54
- package/commands/filemanager/fetch.d.ts +0 -12
- package/commands/filemanager/fetch.js +30 -33
- package/commands/filemanager/upload.d.ts +0 -11
- package/commands/filemanager/upload.js +47 -53
- package/commands/filemanager.d.ts +1 -4
- package/commands/filemanager.js +7 -41
- package/commands/init.js +15 -26
- package/commands/project/add.js +16 -62
- package/commands/project/cloneApp.js +3 -3
- package/commands/project/create.js +15 -70
- package/commands/project/dev.d.ts +1 -0
- package/commands/project/dev.js +146 -0
- package/commands/project/migrateApp.js +3 -3
- package/commands/project/upload.js +2 -7
- package/commands/sandbox/create.d.ts +0 -12
- package/commands/sandbox/create.js +72 -90
- package/commands/sandbox/delete.d.ts +0 -11
- package/commands/sandbox/delete.js +95 -112
- package/commands/sandbox.d.ts +1 -4
- package/commands/sandbox.js +10 -44
- package/commands/theme/generate-selectors.d.ts +0 -9
- package/commands/theme/generate-selectors.js +43 -61
- package/commands/theme/marketplace-validate.d.ts +0 -10
- package/commands/theme/marketplace-validate.js +26 -32
- package/commands/theme/preview.d.ts +0 -16
- package/commands/theme/preview.js +97 -104
- package/commands/theme.d.ts +1 -4
- package/commands/theme.js +10 -44
- package/lang/en.lyaml +67 -40
- package/lib/LocalDevManager.d.ts +2 -2
- package/lib/buildAccount.d.ts +3 -2
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +83 -0
- package/lib/constants.d.ts +3 -12
- package/lib/constants.js +4 -13
- package/lib/doctor/Diagnosis.d.ts +1 -0
- package/lib/doctor/Diagnosis.js +7 -0
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -6
- package/lib/doctor/DiagnosticInfoBuilder.js +1 -5
- package/lib/doctor/Doctor.d.ts +1 -1
- package/lib/doctor/Doctor.js +14 -6
- package/lib/localDev.d.ts +1 -2
- package/lib/marketplaceValidate.d.ts +2 -2
- package/lib/projects/buildAndDeploy.js +1 -4
- package/lib/projects/index.d.ts +5 -1
- package/lib/projects/index.js +62 -1
- 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/accountNamePrompt.d.ts +1 -1
- package/lib/prompts/createProjectPrompt.d.ts +8 -6
- package/lib/prompts/createProjectPrompt.js +54 -26
- package/lib/prompts/projectAddPrompt.d.ts +3 -3
- package/lib/prompts/projectAddPrompt.js +6 -16
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -3
- package/lib/prompts/sandboxesPrompt.d.ts +2 -3
- package/lib/prompts/sandboxesPrompt.js +1 -1
- package/lib/sandboxSync.js +2 -6
- package/lib/sandboxes.d.ts +5 -2
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +0 -1
- package/lib/upload.d.ts +1 -1
- package/lib/upload.js +20 -20
- package/lib/usageTracking.d.ts +1 -1
- package/lib/validation.d.ts +1 -1
- package/package.json +4 -5
- package/types/Projects.d.ts +6 -1
- package/types/Prompts.d.ts +0 -7
- package/types/Sandboxes.d.ts +0 -2
- package/types/Yargs.d.ts +0 -8
- package/commands/project/dev/deprecatedFlow.d.ts +0 -5
- package/commands/project/dev/deprecatedFlow.js +0 -137
- package/commands/project/dev/index.d.ts +0 -6
- 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/lib/customObject.d.ts +0 -3
- package/lib/customObject.js +0 -15
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/create.js +0 -51
- package/lib/testUtils.d.ts +0 -12
- package/lib/testUtils.js +0 -10
- package/types/ProjectComponents.d.ts +0 -38
- package/types/ProjectComponents.js +0 -3
|
@@ -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,137 +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.deprecatedProjectDevFlow = deprecatedProjectDevFlow;
|
|
7
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
-
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
9
|
-
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");
|
|
21
|
-
const i18nKey = 'commands.project.subcommands.dev';
|
|
22
|
-
async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, projectDir) {
|
|
23
|
-
const { providedAccountId, derivedAccountId } = args;
|
|
24
|
-
const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
|
|
25
|
-
const components = await (0, structure_1.findProjectComponents)(projectDir);
|
|
26
|
-
const runnableComponents = components.filter(component => component.runnable);
|
|
27
|
-
const componentTypes = (0, structure_1.getProjectComponentTypes)(runnableComponents);
|
|
28
|
-
const hasPrivateApps = !!componentTypes[Projects_1.ComponentTypes.PrivateApp];
|
|
29
|
-
const hasPublicApps = !!componentTypes[Projects_1.ComponentTypes.PublicApp];
|
|
30
|
-
if (runnableComponents.length === 0) {
|
|
31
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noRunnableComponents`, {
|
|
32
|
-
projectDir,
|
|
33
|
-
command: (0, ui_1.uiCommandReference)('hs project add'),
|
|
34
|
-
}));
|
|
35
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
36
|
-
}
|
|
37
|
-
else if (hasPrivateApps && hasPublicApps) {
|
|
38
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidProjectComponents`));
|
|
39
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
40
|
-
}
|
|
41
|
-
const accounts = (0, config_1.getConfigAccounts)();
|
|
42
|
-
if (!accounts) {
|
|
43
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccountsInConfig`, {
|
|
44
|
-
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
45
|
-
}));
|
|
46
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
47
|
-
}
|
|
48
|
-
const defaultAccountIsRecommendedType = (0, accountTypes_1.isDeveloperTestAccount)(accountConfig) ||
|
|
49
|
-
(!hasPublicApps && (0, accountTypes_1.isSandbox)(accountConfig));
|
|
50
|
-
// targetProjectAccountId and targetTestingAccountId are set to null if --account flag is not provided.
|
|
51
|
-
// By setting them to null, we can later check if they need to be assigned based on the default account configuration and the type of app.
|
|
52
|
-
let targetProjectAccountId = providedAccountId ? derivedAccountId : null;
|
|
53
|
-
// The account that we are locally testing against
|
|
54
|
-
let targetTestingAccountId = providedAccountId ? derivedAccountId : null;
|
|
55
|
-
// Check that the default account or flag option is valid for the type of app in this project
|
|
56
|
-
if (providedAccountId) {
|
|
57
|
-
(0, localDev_1.checkIfAccountFlagIsSupported)(accountConfig, hasPublicApps);
|
|
58
|
-
if (hasPublicApps) {
|
|
59
|
-
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
(0, localDev_1.checkIfDefaultAccountIsSupported)(accountConfig, hasPublicApps);
|
|
64
|
-
}
|
|
65
|
-
// The user is targeting an account type that we recommend developing on
|
|
66
|
-
if (!targetProjectAccountId && defaultAccountIsRecommendedType) {
|
|
67
|
-
targetTestingAccountId = derivedAccountId;
|
|
68
|
-
await (0, localDev_1.confirmDefaultAccountIsTarget)(accountConfig);
|
|
69
|
-
if (hasPublicApps) {
|
|
70
|
-
(0, localDev_1.checkIfParentAccountIsAuthed)(accountConfig);
|
|
71
|
-
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
targetProjectAccountId = derivedAccountId;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
let createNewSandbox = false;
|
|
78
|
-
let createNewDeveloperTestAccount = false;
|
|
79
|
-
if (!targetProjectAccountId) {
|
|
80
|
-
const { targetAccountId, parentAccountId, createNestedAccount, notInConfigAccount, } = await (0, localDev_1.suggestRecommendedNestedAccount)(accounts, accountConfig, hasPublicApps);
|
|
81
|
-
targetProjectAccountId = hasPublicApps
|
|
82
|
-
? parentAccountId || null
|
|
83
|
-
: targetAccountId;
|
|
84
|
-
targetTestingAccountId = targetAccountId;
|
|
85
|
-
// Only used for developer test accounts that are not yet in the config
|
|
86
|
-
if (notInConfigAccount) {
|
|
87
|
-
await (0, localDev_1.useExistingDevTestAccount)(env, notInConfigAccount);
|
|
88
|
-
}
|
|
89
|
-
createNewSandbox = (0, accountTypes_1.isStandardAccount)(accountConfig) && createNestedAccount;
|
|
90
|
-
createNewDeveloperTestAccount =
|
|
91
|
-
(0, accountTypes_1.isAppDeveloperAccount)(accountConfig) && createNestedAccount;
|
|
92
|
-
}
|
|
93
|
-
if (createNewSandbox) {
|
|
94
|
-
targetProjectAccountId = await (0, localDev_1.createSandboxForLocalDev)(derivedAccountId, accountConfig, env);
|
|
95
|
-
// We will be running our tests against this new sandbox account
|
|
96
|
-
targetTestingAccountId = targetProjectAccountId;
|
|
97
|
-
}
|
|
98
|
-
if (createNewDeveloperTestAccount) {
|
|
99
|
-
targetTestingAccountId = await (0, localDev_1.createDeveloperTestAccountForLocalDev)(derivedAccountId, accountConfig, env);
|
|
100
|
-
targetProjectAccountId = derivedAccountId;
|
|
101
|
-
}
|
|
102
|
-
if (!targetProjectAccountId || !targetTestingAccountId) {
|
|
103
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccount`));
|
|
104
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
105
|
-
}
|
|
106
|
-
// eslint-disable-next-line prefer-const
|
|
107
|
-
let { projectExists, project } = await (0, projects_1.ensureProjectExists)(targetProjectAccountId, projectConfig.name, {
|
|
108
|
-
allowCreate: false,
|
|
109
|
-
noLogs: true,
|
|
110
|
-
withPolling: createNewSandbox,
|
|
111
|
-
});
|
|
112
|
-
let deployedBuild;
|
|
113
|
-
let isGithubLinked = false;
|
|
114
|
-
SpinniesManager_1.default.init();
|
|
115
|
-
if (projectExists && project) {
|
|
116
|
-
deployedBuild = project.deployedBuild;
|
|
117
|
-
isGithubLinked = Boolean(project.sourceIntegration && project.sourceIntegration.source === 'GITHUB');
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
project = await (0, localDev_1.createNewProjectForLocalDev)(projectConfig, targetProjectAccountId, createNewSandbox, hasPublicApps);
|
|
121
|
-
deployedBuild = await (0, localDev_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId);
|
|
122
|
-
}
|
|
123
|
-
const LocalDev = new LocalDevManager_1.default({
|
|
124
|
-
runnableComponents,
|
|
125
|
-
debug: args.debug,
|
|
126
|
-
deployedBuild,
|
|
127
|
-
isGithubLinked,
|
|
128
|
-
parentAccountId: targetProjectAccountId,
|
|
129
|
-
projectConfig,
|
|
130
|
-
projectDir,
|
|
131
|
-
projectId: project.id,
|
|
132
|
-
targetAccountId: targetTestingAccountId,
|
|
133
|
-
env,
|
|
134
|
-
});
|
|
135
|
-
await LocalDev.start();
|
|
136
|
-
(0, process_1.handleExit)(({ isSIGHUP }) => LocalDev.stop(!isSIGHUP));
|
|
137
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
-
import { ProjectDevArgs } from '../../../types/Yargs';
|
|
3
|
-
export declare const command = "dev";
|
|
4
|
-
export declare const describe: string | undefined;
|
|
5
|
-
export declare function handler(args: ArgumentsCamelCase<ProjectDevArgs>): Promise<void>;
|
|
6
|
-
export declare function builder(yargs: Argv): Argv<ProjectDevArgs>;
|
|
@@ -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;
|