@hubspot/cli 7.7.19-experimental.3 → 7.7.20-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/api/__tests__/migrate.test.d.ts +1 -0
- package/api/__tests__/migrate.test.js +183 -0
- package/commands/__tests__/account.test.d.ts +1 -0
- package/commands/__tests__/account.test.js +74 -0
- package/commands/__tests__/auth.test.d.ts +1 -0
- package/commands/__tests__/auth.test.js +43 -0
- package/commands/__tests__/cms.test.d.ts +1 -0
- package/commands/__tests__/cms.test.js +49 -0
- package/commands/__tests__/config.test.d.ts +1 -0
- package/commands/__tests__/config.test.js +49 -0
- package/commands/__tests__/create.test.d.ts +1 -0
- package/commands/__tests__/create.test.js +38 -0
- package/commands/__tests__/customObject.test.d.ts +1 -0
- package/commands/__tests__/customObject.test.js +54 -0
- package/commands/__tests__/doctor.test.d.ts +1 -0
- package/commands/__tests__/doctor.test.js +139 -0
- package/commands/__tests__/feedback.test.d.ts +1 -0
- package/commands/__tests__/feedback.test.js +62 -0
- package/commands/__tests__/fetch.test.d.ts +1 -0
- package/commands/__tests__/fetch.test.js +56 -0
- package/commands/__tests__/filemanager.test.d.ts +1 -0
- package/commands/__tests__/filemanager.test.js +50 -0
- package/commands/__tests__/function.test.d.ts +1 -0
- package/commands/__tests__/function.test.js +51 -0
- package/commands/__tests__/getStarted.test.d.ts +1 -0
- package/commands/__tests__/getStarted.test.js +170 -0
- package/commands/__tests__/hubdb.test.d.ts +1 -0
- package/commands/__tests__/hubdb.test.js +55 -0
- package/commands/__tests__/init.test.d.ts +1 -0
- package/commands/__tests__/init.test.js +47 -0
- package/commands/__tests__/lint.test.d.ts +1 -0
- package/commands/__tests__/lint.test.js +38 -0
- package/commands/__tests__/list.test.d.ts +1 -0
- package/commands/__tests__/list.test.js +47 -0
- package/commands/__tests__/logs.test.d.ts +1 -0
- package/commands/__tests__/logs.test.js +70 -0
- package/commands/__tests__/mcp.test.d.ts +1 -0
- package/commands/__tests__/mcp.test.js +51 -0
- package/commands/__tests__/mv.test.d.ts +1 -0
- package/commands/__tests__/mv.test.js +84 -0
- package/commands/__tests__/open.test.d.ts +1 -0
- package/commands/__tests__/open.test.js +96 -0
- package/commands/__tests__/project.test.d.ts +1 -0
- package/commands/__tests__/project.test.js +100 -0
- package/commands/__tests__/remove.test.d.ts +1 -0
- package/commands/__tests__/remove.test.js +77 -0
- package/commands/__tests__/sandbox.test.d.ts +1 -0
- package/commands/__tests__/sandbox.test.js +49 -0
- package/commands/__tests__/secret.test.d.ts +1 -0
- package/commands/__tests__/secret.test.js +54 -0
- package/commands/__tests__/testAccount.test.d.ts +1 -0
- package/commands/__tests__/testAccount.test.js +60 -0
- package/commands/__tests__/theme.test.d.ts +1 -0
- package/commands/__tests__/theme.test.js +52 -0
- package/commands/account/__tests__/auth.test.d.ts +1 -0
- package/commands/account/__tests__/auth.test.js +31 -0
- package/commands/account/__tests__/clean.test.d.ts +1 -0
- package/commands/account/__tests__/clean.test.js +33 -0
- package/commands/account/__tests__/createOverride.test.d.ts +1 -0
- package/commands/account/__tests__/createOverride.test.js +37 -0
- package/commands/account/__tests__/info.test.d.ts +1 -0
- package/commands/account/__tests__/info.test.js +33 -0
- package/commands/account/__tests__/list.test.d.ts +1 -0
- package/commands/account/__tests__/list.test.js +33 -0
- package/commands/account/__tests__/remove.test.d.ts +1 -0
- package/commands/account/__tests__/remove.test.js +41 -0
- package/commands/account/__tests__/removeOverride.d.ts +1 -0
- package/commands/account/__tests__/removeOverride.js +30 -0
- package/commands/account/__tests__/rename.test.d.ts +1 -0
- package/commands/account/__tests__/rename.test.js +47 -0
- package/commands/account/__tests__/use.test.d.ts +1 -0
- package/commands/account/__tests__/use.test.js +37 -0
- package/commands/app/__tests__/migrate.test.d.ts +1 -0
- package/commands/app/__tests__/migrate.test.js +129 -0
- package/commands/app/secret/__tests__/add.test.d.ts +1 -0
- package/commands/app/secret/__tests__/add.test.js +33 -0
- package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
- package/commands/app/secret/__tests__/delete.test.js +33 -0
- package/commands/app/secret/__tests__/list.test.d.ts +1 -0
- package/commands/app/secret/__tests__/list.test.js +30 -0
- package/commands/app/secret/__tests__/update.test.d.ts +1 -0
- package/commands/app/secret/__tests__/update.test.js +33 -0
- package/commands/app.js +1 -6
- package/commands/customObject/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/__tests__/create.test.js +45 -0
- package/commands/customObject/__tests__/schema.test.d.ts +1 -0
- package/commands/customObject/__tests__/schema.test.js +58 -0
- package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/create.test.js +33 -0
- package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/delete.test.js +47 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.js +46 -0
- package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch.test.js +50 -0
- package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/list.test.js +34 -0
- package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/update.test.js +45 -0
- package/commands/fetch.js +0 -1
- package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
- package/commands/filemanager/__tests__/fetch.test.js +37 -0
- package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
- package/commands/filemanager/__tests__/upload.test.js +35 -0
- package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
- package/commands/hubdb/__tests__/clear.test.js +33 -0
- package/commands/hubdb/__tests__/create.test.d.ts +1 -0
- package/commands/hubdb/__tests__/create.test.js +33 -0
- package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
- package/commands/hubdb/__tests__/delete.test.js +33 -0
- package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
- package/commands/hubdb/__tests__/fetch.test.js +33 -0
- package/commands/hubdb/__tests__/list.test.d.ts +1 -0
- package/commands/hubdb/__tests__/list.test.js +101 -0
- package/commands/logs.js +0 -1
- package/commands/mcp/__tests__/setup.test.d.ts +1 -0
- package/commands/mcp/__tests__/setup.test.js +31 -0
- package/commands/mcp/__tests__/start.test.d.ts +1 -0
- package/commands/mcp/__tests__/start.test.js +32 -0
- package/commands/project/__tests__/add.test.d.ts +1 -0
- package/commands/project/__tests__/add.test.js +48 -0
- package/commands/project/__tests__/create.test.d.ts +1 -0
- package/commands/project/__tests__/create.test.js +45 -0
- package/commands/project/__tests__/deploy.test.d.ts +1 -0
- package/commands/project/__tests__/deploy.test.js +344 -0
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
- package/commands/project/__tests__/devUnifiedFlow.test.js +419 -0
- package/commands/project/__tests__/download.test.d.ts +1 -0
- package/commands/project/__tests__/download.test.js +44 -0
- package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
- package/commands/project/__tests__/installDeps.test.d.ts +1 -0
- package/commands/project/__tests__/installDeps.test.js +180 -0
- package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
- package/commands/project/__tests__/listBuilds.test.js +43 -0
- package/commands/project/__tests__/logs.test.d.ts +1 -0
- package/commands/project/__tests__/logs.test.js +246 -0
- package/commands/project/__tests__/migrate.test.d.ts +1 -0
- package/commands/project/__tests__/migrate.test.js +116 -0
- package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
- package/commands/project/__tests__/migrateApp.test.js +87 -0
- package/commands/project/__tests__/open.test.d.ts +1 -0
- package/commands/project/__tests__/open.test.js +44 -0
- package/commands/project/__tests__/profile.test.d.ts +1 -0
- package/commands/project/__tests__/profile.test.js +47 -0
- package/commands/project/__tests__/upload.test.d.ts +1 -0
- package/commands/project/__tests__/upload.test.js +48 -0
- package/commands/project/__tests__/watch.test.d.ts +1 -0
- package/commands/project/__tests__/watch.test.js +40 -0
- package/commands/project/dev/unifiedFlow.js +1 -1
- package/commands/sandbox/__tests__/create.test.d.ts +1 -0
- package/commands/sandbox/__tests__/create.test.js +36 -0
- package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
- package/commands/sandbox/__tests__/delete.test.js +36 -0
- package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/addSecret.test.js +34 -0
- package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/deleteSecret.test.js +46 -0
- package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/listSecret.test.js +34 -0
- package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/updateSecret.test.js +34 -0
- package/commands/testAccount/__tests__/create.test.d.ts +1 -0
- package/commands/testAccount/__tests__/create.test.js +38 -0
- package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
- package/commands/testAccount/__tests__/createConfig.test.js +40 -0
- package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
- package/commands/testAccount/__tests__/delete.test.js +36 -0
- package/commands/testAccount/create.js +24 -14
- package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
- package/commands/theme/__tests__/generate-selectors.test.js +33 -0
- package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
- package/commands/theme/__tests__/marketplace-validate.test.js +41 -0
- package/commands/theme/__tests__/preview.test.d.ts +1 -0
- package/commands/theme/__tests__/preview.test.js +65 -0
- package/lang/en.d.ts +6 -65
- package/lang/en.js +6 -65
- package/lib/__tests__/accountTypes.test.d.ts +1 -0
- package/lib/__tests__/accountTypes.test.js +100 -0
- package/lib/__tests__/buildAccount.test.d.ts +1 -0
- package/lib/__tests__/buildAccount.test.js +231 -0
- package/lib/__tests__/commonOpts.test.d.ts +1 -0
- package/lib/__tests__/commonOpts.test.js +87 -0
- package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
- package/lib/__tests__/dependencyManagement.test.js +180 -0
- package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
- package/lib/__tests__/developerTestAccounts.test.js +180 -0
- package/lib/__tests__/hasFeature.test.d.ts +1 -0
- package/lib/__tests__/hasFeature.test.js +37 -0
- package/lib/__tests__/npm.test.d.ts +1 -0
- package/lib/__tests__/npm.test.js +62 -0
- package/lib/__tests__/oauth.test.d.ts +1 -0
- package/lib/__tests__/oauth.test.js +113 -0
- package/lib/__tests__/parsing.test.d.ts +1 -0
- package/lib/__tests__/parsing.test.js +36 -0
- package/lib/__tests__/polling.test.d.ts +1 -0
- package/lib/__tests__/polling.test.js +78 -0
- package/lib/__tests__/process.test.d.ts +1 -0
- package/lib/__tests__/process.test.js +90 -0
- package/lib/__tests__/projectProfiles.test.d.ts +1 -0
- package/lib/__tests__/projectProfiles.test.js +134 -0
- package/lib/__tests__/sandboxSync.test.d.ts +1 -0
- package/lib/__tests__/sandboxSync.test.js +131 -0
- package/lib/__tests__/sandboxes.test.d.ts +1 -0
- package/lib/__tests__/sandboxes.test.js +148 -0
- package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
- package/lib/__tests__/serverlessLogs.test.js +154 -0
- package/lib/__tests__/usageTracking.test.d.ts +1 -0
- package/lib/__tests__/usageTracking.test.js +171 -0
- package/lib/__tests__/validation.test.d.ts +1 -0
- package/lib/__tests__/validation.test.js +145 -0
- package/lib/__tests__/yargsUtils.test.d.ts +1 -0
- package/lib/__tests__/yargsUtils.test.js +74 -0
- package/lib/app/__tests__/migrate.test.d.ts +1 -0
- package/lib/app/__tests__/migrate.test.js +495 -0
- package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
- package/lib/app/__tests__/migrate_legacy.test.js +136 -0
- package/lib/buildAccount.d.ts +1 -7
- package/lib/buildAccount.js +4 -54
- package/lib/doctor/Diagnosis.js +11 -11
- package/lib/doctor/Doctor.js +42 -42
- package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
- package/lib/doctor/__tests__/Diagnosis.test.js +87 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +172 -0
- package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
- package/lib/doctor/__tests__/Doctor.test.js +398 -0
- package/lib/mcp/setup.js +18 -2
- package/lib/middleware/__test__/configMiddleware.test.js +12 -12
- package/lib/middleware/__test__/gitMiddleware.test.js +4 -4
- package/lib/middleware/__test__/notificationsMiddleware.test.js +2 -2
- package/lib/middleware/__test__/requestMiddleware.test.js +2 -2
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +7 -7
- package/lib/middleware/notificationsMiddleware.js +16 -13
- package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/AppDevModeInterface.test.js +517 -0
- package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +314 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +175 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.js +191 -0
- package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
- package/lib/projects/__tests__/buildAndDeploy.test.js +25 -0
- package/lib/projects/__tests__/components.test.d.ts +1 -0
- package/lib/projects/__tests__/components.test.js +186 -0
- package/lib/projects/__tests__/projects.test.d.ts +1 -0
- package/lib/projects/__tests__/projects.test.js +89 -0
- package/lib/projects/__tests__/structure.test.d.ts +1 -0
- package/lib/projects/__tests__/structure.test.js +249 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +206 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.js +190 -0
- package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
- package/lib/projects/create/__tests__/legacy.test.js +126 -0
- package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
- package/lib/projects/create/__tests__/v3.test.js +80 -0
- package/lib/projects/localDev/DevServerManager.js +0 -1
- package/lib/projects/localDev/helpers.d.ts +1 -1
- package/lib/projects/localDev/helpers.js +2 -2
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/upload.d.ts +1 -2
- package/lib/projects/upload.js +0 -1
- package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +30 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +42 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +43 -81
- package/lib/schema.js +5 -1
- package/lib/ui/SpinniesManager.js +0 -1
- package/lib/ui/supportHyperlinks.js +2 -2
- package/lib/ui/supportsColor.js +2 -2
- package/lib/utils/hasFlag.d.ts +1 -0
- package/lib/utils/hasFlag.js +15 -0
- package/lib/yargsUtils.d.ts +2 -1
- package/lib/yargsUtils.js +3 -13
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +152 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +129 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.js +120 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +127 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +108 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +111 -0
- package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/command.test.js +47 -0
- package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/project.test.js +81 -0
- package/package.json +8 -8
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -127
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ProjectLogsManager_1 = require("../ProjectLogsManager");
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const ensureProjectExists_1 = require("../ensureProjectExists");
|
|
6
|
+
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
7
|
+
const SUBCOMPONENT_TYPES = {
|
|
8
|
+
APP_ID: 'APP_ID',
|
|
9
|
+
PACKAGE_LOCK_FILE: 'PACKAGE_LOCK_FILE',
|
|
10
|
+
CRM_CARD_V2: 'CRM_CARD_V2',
|
|
11
|
+
CARD_V2: 'CARD_V2',
|
|
12
|
+
SERVERLESS_PKG: 'SERVERLESS_PKG',
|
|
13
|
+
SERVERLESS_ROUTE: 'SERVERLESS_ROUTE',
|
|
14
|
+
SERVERLESS_FUNCTION: 'SERVERLESS_FUNCTION',
|
|
15
|
+
APP_FUNCTION: 'APP_FUNCTION',
|
|
16
|
+
AUTOMATION_ACTION: 'AUTOMATION_ACTION',
|
|
17
|
+
REACT_EXTENSION: 'REACT_EXTENSION',
|
|
18
|
+
};
|
|
19
|
+
vi.mock('../../projects/config');
|
|
20
|
+
vi.mock('../../projects/ensureProjectExists');
|
|
21
|
+
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
22
|
+
describe('lib/projects/ProjectLogsManager', () => {
|
|
23
|
+
const accountId = 12345678;
|
|
24
|
+
const appId = 999999;
|
|
25
|
+
const projectName = 'super cool test project';
|
|
26
|
+
const projectConfig = { projectConfig: { name: projectName } };
|
|
27
|
+
const projectId = 987654321;
|
|
28
|
+
const projectDetails = {
|
|
29
|
+
project: {
|
|
30
|
+
id: projectId,
|
|
31
|
+
deployedBuild: {
|
|
32
|
+
subbuildStatuses: {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const function1 = {
|
|
37
|
+
componentName: 'function1',
|
|
38
|
+
type: {
|
|
39
|
+
name: SUBCOMPONENT_TYPES.APP_FUNCTION,
|
|
40
|
+
},
|
|
41
|
+
deployOutput: {
|
|
42
|
+
appId,
|
|
43
|
+
appFunctionName: 'function1',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const functions = [
|
|
47
|
+
function1,
|
|
48
|
+
{
|
|
49
|
+
componentName: 'function2',
|
|
50
|
+
type: {
|
|
51
|
+
name: SUBCOMPONENT_TYPES.APP_FUNCTION,
|
|
52
|
+
},
|
|
53
|
+
deployOutput: {
|
|
54
|
+
appId,
|
|
55
|
+
appFunctionName: 'function2',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
ProjectLogsManager_1.ProjectLogsManager.reset();
|
|
61
|
+
config_1.getProjectConfig.mockResolvedValue(projectConfig);
|
|
62
|
+
ensureProjectExists_1.ensureProjectExists.mockResolvedValue(projectDetails);
|
|
63
|
+
projects_1.fetchProjectComponentsMetadata.mockResolvedValue({
|
|
64
|
+
data: {
|
|
65
|
+
topLevelComponentMetadata: [
|
|
66
|
+
{
|
|
67
|
+
type: {
|
|
68
|
+
name: 'PRIVATE_APP',
|
|
69
|
+
},
|
|
70
|
+
deployOutput: {
|
|
71
|
+
appId,
|
|
72
|
+
},
|
|
73
|
+
featureComponents: [
|
|
74
|
+
...functions,
|
|
75
|
+
{
|
|
76
|
+
type: {
|
|
77
|
+
name: 'NOT_AN_APP_FUNCTION',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('init', () => {
|
|
87
|
+
it('should load the project config', async () => {
|
|
88
|
+
await ProjectLogsManager_1.ProjectLogsManager.init(accountId);
|
|
89
|
+
expect(config_1.getProjectConfig).toHaveBeenCalledTimes(1);
|
|
90
|
+
});
|
|
91
|
+
it('should throw an error if there is a problem with the config', async () => {
|
|
92
|
+
config_1.getProjectConfig.mockResolvedValue({});
|
|
93
|
+
await expect(async () => ProjectLogsManager_1.ProjectLogsManager.init(accountId)).rejects.toThrow('No project detected. Run this command again from a project directory.');
|
|
94
|
+
expect(config_1.getProjectConfig).toHaveBeenCalledTimes(1);
|
|
95
|
+
});
|
|
96
|
+
it('should ensure the project exists', async () => {
|
|
97
|
+
await ProjectLogsManager_1.ProjectLogsManager.init(accountId);
|
|
98
|
+
expect(ensureProjectExists_1.ensureProjectExists).toHaveBeenCalledTimes(1);
|
|
99
|
+
expect(ensureProjectExists_1.ensureProjectExists).toHaveBeenCalledWith(accountId, projectName, {
|
|
100
|
+
allowCreate: false,
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
it('should throw an error if there is data missing from the project details', async () => {
|
|
104
|
+
ensureProjectExists_1.ensureProjectExists.mockResolvedValue({});
|
|
105
|
+
await expect(async () => ProjectLogsManager_1.ProjectLogsManager.init(accountId)).rejects.toThrow(/There was an error fetching project details/);
|
|
106
|
+
});
|
|
107
|
+
it('should set all of the expected fields correctly', async () => {
|
|
108
|
+
await ProjectLogsManager_1.ProjectLogsManager.init(accountId);
|
|
109
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.projectId).toEqual(projectId);
|
|
110
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.projectName).toEqual(projectName);
|
|
111
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.accountId).toEqual(accountId);
|
|
112
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.functions).toEqual(functions);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
describe('fetchFunctionDetails', () => {
|
|
116
|
+
it('should throw an error if the projectId is null when the method is called', async () => {
|
|
117
|
+
await expect(async () => ProjectLogsManager_1.ProjectLogsManager.fetchFunctionDetails()).rejects.toThrow('No project detected. Run this command again from a project directory.');
|
|
118
|
+
});
|
|
119
|
+
it('should fetch the component metadata', async () => {
|
|
120
|
+
ProjectLogsManager_1.ProjectLogsManager.projectId = projectId;
|
|
121
|
+
ProjectLogsManager_1.ProjectLogsManager.accountId = accountId;
|
|
122
|
+
await ProjectLogsManager_1.ProjectLogsManager.fetchFunctionDetails();
|
|
123
|
+
expect(projects_1.fetchProjectComponentsMetadata).toHaveBeenCalledTimes(1);
|
|
124
|
+
expect(projects_1.fetchProjectComponentsMetadata).toHaveBeenCalledWith(accountId, projectId);
|
|
125
|
+
});
|
|
126
|
+
it('should set the functions correctly', async () => {
|
|
127
|
+
ProjectLogsManager_1.ProjectLogsManager.projectId = projectId;
|
|
128
|
+
ProjectLogsManager_1.ProjectLogsManager.accountId = accountId;
|
|
129
|
+
await ProjectLogsManager_1.ProjectLogsManager.fetchFunctionDetails();
|
|
130
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.functions).toEqual(functions);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('getFunctionNames', () => {
|
|
134
|
+
it('should return an empty array if functions is empty', async () => {
|
|
135
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = [];
|
|
136
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.getFunctionNames()).toEqual([]);
|
|
137
|
+
});
|
|
138
|
+
it('should return an array of the componentNames', async () => {
|
|
139
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = functions;
|
|
140
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.getFunctionNames()).toEqual([
|
|
141
|
+
'function1',
|
|
142
|
+
'function2',
|
|
143
|
+
]);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('setFunction', () => {
|
|
147
|
+
it('should throw an error when functions is empty', async () => {
|
|
148
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = [];
|
|
149
|
+
expect(() => ProjectLogsManager_1.ProjectLogsManager.setFunction('foo')).toThrow(`There aren't any functions in this project`);
|
|
150
|
+
});
|
|
151
|
+
it('should throw an error when the provided function is invalid', async () => {
|
|
152
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = functions;
|
|
153
|
+
const badName = 'foo';
|
|
154
|
+
expect(() => ProjectLogsManager_1.ProjectLogsManager.setFunction(badName)).toThrow(`No function with name "${badName}"`);
|
|
155
|
+
});
|
|
156
|
+
it('should set the data correctly for public functions', async () => {
|
|
157
|
+
const functionToChoose = {
|
|
158
|
+
componentName: 'function1',
|
|
159
|
+
type: {
|
|
160
|
+
name: SUBCOMPONENT_TYPES.APP_FUNCTION,
|
|
161
|
+
},
|
|
162
|
+
deployOutput: {
|
|
163
|
+
appId: 123,
|
|
164
|
+
appFunctionName: 'function1',
|
|
165
|
+
endpoint: { path: 'yooooooo', methods: ['GET'] },
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = [functionToChoose];
|
|
169
|
+
ProjectLogsManager_1.ProjectLogsManager.setFunction('function1');
|
|
170
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.functionName).toEqual('function1');
|
|
171
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.endpointName).toEqual('yooooooo');
|
|
172
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.selectedFunction).toEqual(functionToChoose);
|
|
173
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.isPublicFunction).toEqual(true);
|
|
174
|
+
});
|
|
175
|
+
it('should set the data correctly for public functions', async () => {
|
|
176
|
+
ProjectLogsManager_1.ProjectLogsManager.functions = functions;
|
|
177
|
+
ProjectLogsManager_1.ProjectLogsManager.setFunction('function1');
|
|
178
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.selectedFunction).toEqual(function1);
|
|
179
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.functionName).toEqual('function1');
|
|
180
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.isPublicFunction).toEqual(false);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
describe('reset', () => {
|
|
184
|
+
it('should reset all the values', async () => {
|
|
185
|
+
ProjectLogsManager_1.ProjectLogsManager.projectName = 'value';
|
|
186
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.projectName).toBeDefined();
|
|
187
|
+
ProjectLogsManager_1.ProjectLogsManager.reset();
|
|
188
|
+
expect(ProjectLogsManager_1.ProjectLogsManager.projectName).toBeUndefined();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
4
|
+
describe('buildAndDeploy', () => {
|
|
5
|
+
describe('useV3Api', () => {
|
|
6
|
+
it('returns true if platform version is UNSTABLE', () => {
|
|
7
|
+
expect((0, buildAndDeploy_1.useV3Api)('UNSTABLE')).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
it('returns true if platform version is equal to the minimum', () => {
|
|
10
|
+
expect((0, buildAndDeploy_1.useV3Api)('2025.2')).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
it('returns true if platform version is greater than the minimum', () => {
|
|
13
|
+
expect((0, buildAndDeploy_1.useV3Api)('2026.2')).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it('returns false if platform version is less than the minimum', () => {
|
|
16
|
+
expect((0, buildAndDeploy_1.useV3Api)('2025.0')).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
it('returns false if platform version is invalid', () => {
|
|
19
|
+
expect((0, buildAndDeploy_1.useV3Api)(null)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it('returns false for an invalid platform version', () => {
|
|
22
|
+
expect((0, buildAndDeploy_1.useV3Api)('notplaformversion')).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const components_1 = require("../components");
|
|
8
|
+
vi.mock('fs');
|
|
9
|
+
const mockedFs = vi.mocked(fs_1.default);
|
|
10
|
+
describe('lib/projects/components', () => {
|
|
11
|
+
describe('handleComponentCollision()', () => {
|
|
12
|
+
const mockCollision = {
|
|
13
|
+
dest: '/dest/path',
|
|
14
|
+
src: '/src/path',
|
|
15
|
+
collisions: [],
|
|
16
|
+
};
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
vi.resetAllMocks();
|
|
19
|
+
// Mock Date.now to return consistent values for testing
|
|
20
|
+
vi.spyOn(Date, 'now').mockReturnValue(1234567890);
|
|
21
|
+
});
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
vi.restoreAllMocks();
|
|
24
|
+
});
|
|
25
|
+
it('handles source file collisions by renaming them with timestamps', () => {
|
|
26
|
+
const collision = {
|
|
27
|
+
...mockCollision,
|
|
28
|
+
collisions: ['component.js', 'utils.ts'],
|
|
29
|
+
};
|
|
30
|
+
mockedFs.copyFileSync.mockImplementation(() => { });
|
|
31
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
32
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledTimes(2);
|
|
33
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledWith('/src/path/component.js', '/dest/path/component-1234567890.js');
|
|
34
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledWith('/src/path/utils.ts', '/dest/path/utils-1234567890.ts');
|
|
35
|
+
});
|
|
36
|
+
it('handles metafile collisions by renaming and updating references', () => {
|
|
37
|
+
const collision = {
|
|
38
|
+
...mockCollision,
|
|
39
|
+
collisions: ['component.module.meta.json', 'source.js'],
|
|
40
|
+
};
|
|
41
|
+
const mockMetaContent = JSON.stringify({
|
|
42
|
+
file: 'source.js',
|
|
43
|
+
label: 'Test Component',
|
|
44
|
+
});
|
|
45
|
+
mockedFs.readFileSync.mockReturnValue(mockMetaContent);
|
|
46
|
+
mockedFs.writeFileSync.mockImplementation(() => { });
|
|
47
|
+
mockedFs.copyFileSync.mockImplementation(() => { });
|
|
48
|
+
// Mock metafileExtension
|
|
49
|
+
Object.defineProperty(require('@hubspot/project-parsing-lib'), 'metafileExtension', {
|
|
50
|
+
value: '.module.meta.json',
|
|
51
|
+
writable: false,
|
|
52
|
+
});
|
|
53
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
54
|
+
expect(mockedFs.readFileSync).toHaveBeenCalledWith('/src/path/component.module.meta.json', 'utf-8');
|
|
55
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith('/dest/path/component-1234567890.module.meta.json', expect.stringContaining('source-1234567890.js'));
|
|
56
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledWith('/src/path/source.js', '/dest/path/source-1234567890.js');
|
|
57
|
+
});
|
|
58
|
+
it('handles package.json collisions by merging dependencies', () => {
|
|
59
|
+
const collision = {
|
|
60
|
+
...mockCollision,
|
|
61
|
+
collisions: ['package.json'],
|
|
62
|
+
};
|
|
63
|
+
const existingPackageJson = {
|
|
64
|
+
name: 'existing-package',
|
|
65
|
+
dependencies: {
|
|
66
|
+
existing: '1.0.0',
|
|
67
|
+
shared: '1.0.0',
|
|
68
|
+
},
|
|
69
|
+
devDependencies: {
|
|
70
|
+
'existing-dev': '1.0.0',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const newPackageJson = {
|
|
74
|
+
name: 'new-package',
|
|
75
|
+
dependencies: {
|
|
76
|
+
new: '2.0.0',
|
|
77
|
+
shared: '2.0.0',
|
|
78
|
+
},
|
|
79
|
+
devDependencies: {
|
|
80
|
+
'new-dev': '2.0.0',
|
|
81
|
+
'existing-dev': '2.0.0',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
mockedFs.readFileSync
|
|
85
|
+
.mockReturnValueOnce(JSON.stringify(existingPackageJson))
|
|
86
|
+
.mockReturnValueOnce(JSON.stringify(newPackageJson));
|
|
87
|
+
mockedFs.writeFileSync.mockImplementation(() => { });
|
|
88
|
+
// Mock console.log to avoid output during tests
|
|
89
|
+
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
90
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
91
|
+
const expectedMergedPackageJson = {
|
|
92
|
+
name: 'existing-package',
|
|
93
|
+
dependencies: {
|
|
94
|
+
new: '2.0.0',
|
|
95
|
+
shared: '1.0.0',
|
|
96
|
+
existing: '1.0.0',
|
|
97
|
+
},
|
|
98
|
+
devDependencies: {
|
|
99
|
+
'new-dev': '2.0.0',
|
|
100
|
+
'existing-dev': '1.0.0',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith('/dest/path/package.json', JSON.stringify(expectedMergedPackageJson, null, 2));
|
|
104
|
+
consoleSpy.mockRestore();
|
|
105
|
+
});
|
|
106
|
+
it('handles mixed collision types (source files, metafiles, and package.json)', () => {
|
|
107
|
+
const collision = {
|
|
108
|
+
...mockCollision,
|
|
109
|
+
collisions: [
|
|
110
|
+
'component.js',
|
|
111
|
+
'component.module.meta.json',
|
|
112
|
+
'package.json',
|
|
113
|
+
'utils.ts',
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
const mockMetaContent = JSON.stringify({
|
|
117
|
+
file: 'component.js',
|
|
118
|
+
label: 'Test Component',
|
|
119
|
+
});
|
|
120
|
+
const existingPackageJson = { name: 'existing' };
|
|
121
|
+
const newPackageJson = { name: 'new', dependencies: { test: '1.0.0' } };
|
|
122
|
+
mockedFs.readFileSync
|
|
123
|
+
.mockReturnValueOnce(mockMetaContent)
|
|
124
|
+
.mockReturnValueOnce(JSON.stringify(existingPackageJson))
|
|
125
|
+
.mockReturnValueOnce(JSON.stringify(newPackageJson));
|
|
126
|
+
mockedFs.writeFileSync.mockImplementation(() => { });
|
|
127
|
+
mockedFs.copyFileSync.mockImplementation(() => { });
|
|
128
|
+
// Mock metafileExtension
|
|
129
|
+
Object.defineProperty(require('@hubspot/project-parsing-lib'), 'metafileExtension', {
|
|
130
|
+
value: '.module.meta.json',
|
|
131
|
+
writable: false,
|
|
132
|
+
});
|
|
133
|
+
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
134
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
135
|
+
// Verify source files are copied with new names
|
|
136
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledWith('/src/path/component.js', '/dest/path/component-1234567890.js');
|
|
137
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledWith('/src/path/utils.ts', '/dest/path/utils-1234567890.ts');
|
|
138
|
+
// Verify metafile is updated and written with new name
|
|
139
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith('/dest/path/component-1234567890.module.meta.json', expect.stringContaining('component-1234567890.js'));
|
|
140
|
+
// Verify package.json is merged
|
|
141
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith('/dest/path/package.json', expect.stringContaining('"dependencies"'));
|
|
142
|
+
consoleSpy.mockRestore();
|
|
143
|
+
});
|
|
144
|
+
it('handles empty collisions array gracefully', () => {
|
|
145
|
+
const collision = {
|
|
146
|
+
...mockCollision,
|
|
147
|
+
collisions: [],
|
|
148
|
+
};
|
|
149
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
150
|
+
expect(mockedFs.copyFileSync).not.toHaveBeenCalled();
|
|
151
|
+
expect(mockedFs.readFileSync).not.toHaveBeenCalled();
|
|
152
|
+
expect(mockedFs.writeFileSync).not.toHaveBeenCalled();
|
|
153
|
+
});
|
|
154
|
+
it('correctly categorizes different file types', () => {
|
|
155
|
+
const collision = {
|
|
156
|
+
...mockCollision,
|
|
157
|
+
collisions: [
|
|
158
|
+
'regular.js',
|
|
159
|
+
'nested/path/file.ts',
|
|
160
|
+
'component.module.meta.json',
|
|
161
|
+
'another.meta.json',
|
|
162
|
+
'package.json',
|
|
163
|
+
'nested/package.json',
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
// Mock metafileExtension
|
|
167
|
+
Object.defineProperty(require('@hubspot/project-parsing-lib'), 'metafileExtension', {
|
|
168
|
+
value: '.meta.json',
|
|
169
|
+
writable: false,
|
|
170
|
+
});
|
|
171
|
+
const mockMetaContent = '{}';
|
|
172
|
+
mockedFs.readFileSync.mockReturnValue(mockMetaContent);
|
|
173
|
+
mockedFs.writeFileSync.mockImplementation(() => { });
|
|
174
|
+
mockedFs.copyFileSync.mockImplementation(() => { });
|
|
175
|
+
// Mock console.log for package.json handling
|
|
176
|
+
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
177
|
+
(0, components_1.handleComponentCollision)(collision);
|
|
178
|
+
// Should copy 2 source files
|
|
179
|
+
expect(mockedFs.copyFileSync).toHaveBeenCalledTimes(2);
|
|
180
|
+
// Should handle 2 metafiles
|
|
181
|
+
expect(mockedFs.readFileSync).toHaveBeenCalledWith('/src/path/component.module.meta.json', 'utf-8');
|
|
182
|
+
expect(mockedFs.readFileSync).toHaveBeenCalledWith('/src/path/another.meta.json', 'utf-8');
|
|
183
|
+
consoleSpy.mockRestore();
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
10
|
+
const config_1 = require("../../projects/config");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
13
|
+
describe('lib/projects', () => {
|
|
14
|
+
describe('validateProjectConfig()', () => {
|
|
15
|
+
let projectDir;
|
|
16
|
+
let exitMock;
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
projectDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'projects-'));
|
|
19
|
+
fs_1.default.mkdirSync(path_1.default.join(projectDir, 'src'));
|
|
20
|
+
});
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// @ts-expect-error - Mocking process.exit
|
|
23
|
+
exitMock = vi
|
|
24
|
+
.spyOn(process, 'exit')
|
|
25
|
+
.mockImplementation(() => undefined);
|
|
26
|
+
});
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
exitMock.mockRestore();
|
|
29
|
+
});
|
|
30
|
+
it('rejects undefined configuration', () => {
|
|
31
|
+
// @ts-ignore Testing invalid input
|
|
32
|
+
(0, config_1.validateProjectConfig)(null, projectDir);
|
|
33
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
34
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringMatching(/.*Unable to locate a project configuration file. Try running again from a project directory, or run*/));
|
|
35
|
+
});
|
|
36
|
+
it('rejects configuration with missing name', () => {
|
|
37
|
+
// @ts-ignore Testing invalid input
|
|
38
|
+
(0, config_1.validateProjectConfig)({ srcDir: '.' }, projectDir);
|
|
39
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
40
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringMatching(/.*missing required fields*/));
|
|
41
|
+
});
|
|
42
|
+
it('rejects configuration with missing srcDir', () => {
|
|
43
|
+
// @ts-ignore Testing invalid input
|
|
44
|
+
(0, config_1.validateProjectConfig)({ name: 'hello' }, projectDir);
|
|
45
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
46
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringMatching(/.*missing required fields.*/));
|
|
47
|
+
});
|
|
48
|
+
describe('rejects configuration with srcDir outside project directory', () => {
|
|
49
|
+
it('for parent directory', () => {
|
|
50
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: '..', platformVersion: '' }, projectDir);
|
|
51
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
52
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringContaining('srcDir: ".."'));
|
|
53
|
+
});
|
|
54
|
+
it('for root directory', () => {
|
|
55
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: '/', platformVersion: '' }, projectDir);
|
|
56
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
57
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringContaining('srcDir: "/"'));
|
|
58
|
+
});
|
|
59
|
+
it('for complicated directory', () => {
|
|
60
|
+
const srcDir = './src/././../src/../../src';
|
|
61
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir, platformVersion: '' }, projectDir);
|
|
62
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringContaining(`srcDir: "${srcDir}"`));
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it('rejects configuration with srcDir that does not exist', () => {
|
|
67
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: 'foo', platformVersion: '' }, projectDir);
|
|
68
|
+
expect(exitMock).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
69
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringMatching(/.*could not be found in.*/));
|
|
70
|
+
});
|
|
71
|
+
describe('accepts configuration with valid srcDir', () => {
|
|
72
|
+
it('for current directory', () => {
|
|
73
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: '.', platformVersion: '' }, projectDir);
|
|
74
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
75
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
it('for relative directory', () => {
|
|
78
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: './src', platformVersion: '' }, projectDir);
|
|
79
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
80
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
it('for implied relative directory', () => {
|
|
83
|
+
(0, config_1.validateProjectConfig)({ name: 'hello', srcDir: 'src', platformVersion: '' }, projectDir);
|
|
84
|
+
expect(exitMock).not.toHaveBeenCalled();
|
|
85
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|