alepha 0.19.3 → 0.19.5
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/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/dist/api/invitations/index.d.ts +790 -0
- package/dist/api/invitations/index.d.ts.map +1 -0
- package/dist/api/invitations/index.js +665 -0
- package/dist/api/invitations/index.js.map +1 -0
- package/dist/api/issues/index.d.ts +810 -0
- package/dist/api/issues/index.d.ts.map +1 -0
- package/dist/api/issues/index.js +447 -0
- package/dist/api/issues/index.js.map +1 -0
- package/dist/api/jobs/index.browser.js +8 -9
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +99 -43
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +257 -40
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js +0 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +3 -3
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +0 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +112 -1
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +90 -3
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +79 -12
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/{billing → api/payments}/index.d.ts +67 -49
- package/dist/api/payments/index.d.ts.map +1 -0
- package/dist/{billing → api/payments}/index.js +108 -74
- package/dist/api/payments/index.js.map +1 -0
- package/dist/api/subscriptions/index.d.ts +1692 -0
- package/dist/api/subscriptions/index.d.ts.map +1 -0
- package/dist/api/subscriptions/index.js +1870 -0
- package/dist/api/subscriptions/index.js.map +1 -0
- package/dist/api/users/index.d.ts +24 -2
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +176 -36
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +13 -13
- package/dist/api/workflows/index.browser.js +246 -0
- package/dist/api/workflows/index.browser.js.map +1 -0
- package/dist/api/workflows/index.d.ts +1618 -0
- package/dist/api/workflows/index.d.ts.map +1 -0
- package/dist/api/workflows/index.js +1504 -0
- package/dist/api/workflows/index.js.map +1 -0
- package/dist/captcha/index.d.ts +142 -0
- package/dist/captcha/index.d.ts.map +1 -0
- package/dist/captcha/index.js +177 -0
- package/dist/captcha/index.js.map +1 -0
- package/dist/cli/core/index.d.ts +126 -30
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +106 -67
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +84 -10
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +92 -4
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/vendor/index.d.ts +60 -10
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js +177 -45
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2 -3
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +21 -2
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +33 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +21 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +21 -2
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +21 -2
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.js +24 -8
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +0 -18
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +6 -23
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +1 -13
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +6 -23
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +3 -3
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +3 -3
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/i18n/index.d.ts +1 -0
- package/dist/react/i18n/index.d.ts.map +1 -1
- package/dist/react/i18n/index.js +8 -4
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/router/index.browser.js +25 -3
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +16 -1
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +25 -3
- package/dist/react/router/index.js.map +1 -1
- package/dist/security/index.d.ts +28 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +28 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +145 -2
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +364 -63
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js.map +1 -1
- package/package.json +47 -20
- package/src/api/invitations/__tests__/InvitationService.spec.ts +439 -0
- package/src/api/invitations/controllers/AdminInvitationController.ts +86 -0
- package/src/api/invitations/controllers/InvitationController.ts +84 -0
- package/src/api/invitations/entities/invitations.ts +33 -0
- package/src/api/invitations/index.ts +65 -0
- package/src/api/invitations/jobs/InvitationJobs.ts +37 -0
- package/src/api/invitations/providers/InvitationProvider.ts +45 -0
- package/src/api/invitations/schemas/createInvitationSchema.ts +12 -0
- package/src/api/invitations/schemas/invitationConfigAtom.ts +20 -0
- package/src/api/invitations/schemas/invitationQuerySchema.ts +15 -0
- package/src/api/invitations/schemas/invitationResourceSchema.ts +6 -0
- package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +22 -0
- package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +10 -0
- package/src/api/invitations/services/InvitationService.ts +556 -0
- package/src/api/issues/__tests__/IssueService.spec.ts +263 -0
- package/src/api/issues/controllers/AdminIssueController.ts +149 -0
- package/src/api/issues/controllers/IssueController.ts +44 -0
- package/src/api/issues/entities/issues.ts +49 -0
- package/src/api/issues/index.ts +53 -0
- package/src/api/issues/schemas/createIssueSchema.ts +13 -0
- package/src/api/issues/schemas/issueConfigAtom.ts +13 -0
- package/src/api/issues/schemas/issueQuerySchema.ts +18 -0
- package/src/api/issues/schemas/issueResourceSchema.ts +6 -0
- package/src/api/issues/schemas/myIssueQuerySchema.ts +10 -0
- package/src/api/issues/schemas/updateIssueSchema.ts +13 -0
- package/src/api/issues/services/IssueService.ts +264 -0
- package/src/api/jobs/__tests__/$job.spec.ts +876 -0
- package/src/api/jobs/controllers/AdminJobController.ts +44 -0
- package/src/api/jobs/entities/jobExecutionEntity.ts +0 -2
- package/src/api/jobs/index.ts +0 -3
- package/src/api/jobs/primitives/$job.ts +22 -11
- package/src/api/jobs/providers/JobProvider.ts +229 -19
- package/src/api/jobs/schemas/jobConfigAtom.ts +4 -0
- package/src/api/jobs/schemas/jobCronInfoSchema.ts +1 -0
- package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +0 -1
- package/src/api/jobs/schemas/jobQueueDepthSchema.ts +1 -0
- package/src/api/jobs/schemas/jobRegistrationSchema.ts +1 -6
- package/src/api/jobs/services/JobService.ts +51 -12
- package/src/api/notifications/schemas/notificationQuerySchema.ts +0 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +327 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +29 -3
- package/src/api/parameters/index.browser.ts +12 -0
- package/src/api/parameters/primitives/$parameter.ts +20 -3
- package/src/api/parameters/services/ParameterProvider.ts +48 -7
- package/src/{billing → api/payments}/__tests__/PaymentMethodService.spec.ts +32 -6
- package/src/api/payments/__tests__/PaymentService.spec.ts +279 -0
- package/src/{billing/controllers/AdminBillingController.ts → api/payments/controllers/AdminPaymentController.ts} +26 -21
- package/src/{billing/controllers/BillingController.ts → api/payments/controllers/PaymentController.ts} +23 -11
- package/src/{billing → api/payments}/entities/paymentIntents.ts +1 -0
- package/src/{billing/errors/BillingError.ts → api/payments/errors/PaymentError.ts} +1 -1
- package/src/{billing → api/payments}/index.ts +31 -25
- package/src/{billing/providers/MemoryBillingProvider.ts → api/payments/providers/MemoryPaymentProvider.ts} +4 -4
- package/src/{billing/providers/BillingProvider.ts → api/payments/providers/PaymentProvider.ts} +9 -2
- package/src/{billing → api/payments}/services/PaymentMethodService.ts +5 -5
- package/src/{billing/services/BillingService.ts → api/payments/services/PaymentService.ts} +94 -18
- package/src/api/subscriptions/__tests__/BillingService.spec.ts +218 -0
- package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +278 -0
- package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +212 -0
- package/src/api/subscriptions/controllers/SubscriptionController.ts +189 -0
- package/src/api/subscriptions/entities/subscriptionEvents.ts +54 -0
- package/src/api/subscriptions/entities/subscriptions.ts +68 -0
- package/src/api/subscriptions/index.ts +144 -0
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +382 -0
- package/src/api/subscriptions/middleware/$requireLimit.ts +50 -0
- package/src/api/subscriptions/middleware/$requirePlan.ts +49 -0
- package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +110 -0
- package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +8 -0
- package/src/api/subscriptions/schemas/changePlanSchema.ts +9 -0
- package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +11 -0
- package/src/api/subscriptions/schemas/entitlementsSchema.ts +21 -0
- package/src/api/subscriptions/schemas/mrrSchema.ts +13 -0
- package/src/api/subscriptions/schemas/planDefinitionSchema.ts +71 -0
- package/src/api/subscriptions/schemas/planResourceSchema.ts +25 -0
- package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +8 -0
- package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +19 -0
- package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +6 -0
- package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +32 -0
- package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +23 -0
- package/src/api/subscriptions/services/BillingService.ts +437 -0
- package/src/api/subscriptions/services/SubscriptionConfig.ts +56 -0
- package/src/api/subscriptions/services/SubscriptionService.ts +867 -0
- package/src/api/subscriptions/services/UsageService.ts +118 -0
- package/src/api/users/__tests__/AdminUserController.spec.ts +80 -1
- package/src/api/users/__tests__/CredentialService.spec.ts +177 -0
- package/src/api/users/__tests__/EmailVerification.spec.ts +29 -18
- package/src/api/users/__tests__/PasswordReset.spec.ts +3 -0
- package/src/api/users/__tests__/RegistrationService.spec.ts +148 -1
- package/src/api/users/__tests__/SessionService.spec.ts +142 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +10 -1
- package/src/api/users/controllers/UserController.ts +3 -8
- package/src/api/users/notifications/UserNotifications.ts +23 -0
- package/src/api/users/primitives/$realm.ts +24 -0
- package/src/api/users/schemas/loginSchema.ts +1 -1
- package/src/api/users/services/CredentialService.ts +57 -7
- package/src/api/users/services/RegistrationService.ts +50 -11
- package/src/api/users/services/SessionService.ts +64 -9
- package/src/api/users/services/UserService.ts +21 -12
- package/src/api/workflows/__tests__/$workflow.spec.ts +616 -0
- package/src/api/workflows/controllers/AdminWorkflowController.ts +191 -0
- package/src/api/workflows/entities/workflowExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepLogs.ts +13 -0
- package/src/api/workflows/index.browser.ts +22 -0
- package/src/api/workflows/index.ts +124 -0
- package/src/api/workflows/jobs/WorkflowJobs.ts +77 -0
- package/src/api/workflows/primitives/$workflow.ts +202 -0
- package/src/api/workflows/providers/WorkflowProvider.ts +1284 -0
- package/src/api/workflows/schemas/workflowActivitySchema.ts +15 -0
- package/src/api/workflows/schemas/workflowConfigAtom.ts +51 -0
- package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +18 -0
- package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +26 -0
- package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +30 -0
- package/src/api/workflows/schemas/workflowRegistrationSchema.ts +26 -0
- package/src/api/workflows/schemas/workflowStatsSchema.ts +16 -0
- package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +15 -0
- package/src/api/workflows/services/WorkflowService.ts +382 -0
- package/src/captcha/__tests__/MemoryCaptchaProvider.spec.ts +74 -0
- package/src/captcha/index.ts +33 -0
- package/src/captcha/providers/CaptchaProvider.ts +17 -0
- package/src/captcha/providers/MemoryCaptchaProvider.ts +65 -0
- package/src/captcha/providers/TurnstileCaptchaProvider.ts +125 -0
- package/src/cli/core/atoms/buildOptions.ts +57 -0
- package/src/cli/core/commands/build.ts +2 -0
- package/src/cli/core/providers/ViteDevServerProvider.ts +1 -1
- package/src/cli/core/services/ViteUtils.ts +5 -2
- package/src/cli/core/tasks/BuildClientTask.ts +3 -1
- package/src/cli/core/tasks/BuildCloudflareTask.ts +4 -0
- package/src/cli/core/tasks/BuildPwaTask.ts +81 -0
- package/src/cli/core/templates/webAppRouterTs.ts +5 -58
- package/src/cli/platform/adapters/CloudflareAdapter.ts +24 -0
- package/src/cli/platform/atoms/platformOptions.ts +19 -3
- package/src/cli/platform/hooks/PlatformHook.ts +51 -0
- package/src/cli/platform/index.ts +1 -0
- package/src/cli/platform/services/CloudflareApi.ts +22 -1
- package/src/cli/platform/services/PlatformOrchestrator.ts +67 -2
- package/src/cli/vendor/__tests__/VendorService.spec.ts +322 -178
- package/src/cli/vendor/commands/VendorCommand.ts +41 -38
- package/src/cli/vendor/services/VendorService.ts +234 -31
- package/src/command/__tests__/CliProvider.spec.ts +45 -0
- package/src/command/providers/CliProvider.ts +3 -4
- package/src/core/__tests__/TypeProvider.spec.ts +4 -2
- package/src/core/providers/SchemaValidator.ts +1 -1
- package/src/core/providers/TypeProvider.ts +46 -3
- package/src/orm/__tests__/enums.spec.ts +22 -29
- package/src/orm/__tests__/orm-showcase-tests.ts +430 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +167 -0
- package/src/orm/core/providers/DatabaseTypeProvider.ts +0 -29
- package/src/orm/core/services/Repository.ts +20 -6
- package/src/orm/postgres/services/PostgresModelBuilder.ts +3 -6
- package/src/react/i18n/__tests__/I18nProvider.spec.ts +83 -0
- package/src/react/i18n/providers/I18nProvider.ts +12 -10
- package/src/react/router/__tests__/$page.browser.spec.tsx +157 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +39 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +22 -0
- package/src/security/__tests__/$secure-combinations.spec.ts +945 -0
- package/src/security/primitives/$issuer.ts +3 -1
- package/src/security/primitives/$secure.ts +28 -0
- package/src/server/auth/index.ts +7 -0
- package/src/server/auth/primitives/$auth.ts +37 -3
- package/src/server/auth/primitives/$authApple.ts +114 -4
- package/src/server/auth/primitives/$authFacebook.ts +98 -0
- package/src/server/auth/primitives/$authFranceConnect.ts +105 -0
- package/src/server/auth/primitives/$authGithub.ts +22 -16
- package/src/server/auth/primitives/$authMicrosoft.ts +88 -0
- package/src/server/auth/providers/ServerAuthProvider.ts +197 -72
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -0
- package/src/server/core/__tests__/ServerRouterProvider-errorHandler.spec.ts +1 -1
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -1
- package/dist/billing/index.d.ts.map +0 -1
- package/dist/billing/index.js.map +0 -1
- package/src/billing/__tests__/BillingService.spec.ts +0 -136
- /package/src/{billing → api/payments}/entities/paymentMethods.ts +0 -0
- /package/src/{billing → api/payments}/entities/refunds.ts +0 -0
- /package/src/{billing → api/payments}/schemas/intentSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/paymentMethodSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/refundSchemas.ts +0 -0
|
@@ -21,6 +21,38 @@ describe("VendorService", () => {
|
|
|
21
21
|
return { service, shell, fs };
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Helper to create a test service with a stubbed clone that returns
|
|
26
|
+
* a known directory, plus stubs getCommitHash to return a fixed hash.
|
|
27
|
+
*/
|
|
28
|
+
const createTestService = (shell: MemoryShellProvider) => {
|
|
29
|
+
class TestVendorService extends VendorService {
|
|
30
|
+
protected override async cloneRemote(): Promise<string> {
|
|
31
|
+
await shell.run(
|
|
32
|
+
"git clone --depth 1 --branch main --filter=blob:none remote /tmp/test-clone",
|
|
33
|
+
);
|
|
34
|
+
return "/tmp/test-clone";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected override async cloneAtCommit(): Promise<string> {
|
|
38
|
+
return "/tmp/test-baseline";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected override async getCommitHash(): Promise<string> {
|
|
42
|
+
return "abc123";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const alepha = Alepha.create()
|
|
47
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
48
|
+
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
service: alepha.inject(TestVendorService),
|
|
52
|
+
fs: alepha.inject(MemoryFileSystemProvider),
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
24
56
|
describe("sync", () => {
|
|
25
57
|
it("should clone the remote repository", async ({ expect }) => {
|
|
26
58
|
const { service, shell, fs } = createTestEnv();
|
|
@@ -48,40 +80,23 @@ describe("VendorService", () => {
|
|
|
48
80
|
});
|
|
49
81
|
|
|
50
82
|
it("should remove local package dir before copying", async ({ expect }) => {
|
|
51
|
-
const { service,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* to return a known path.
|
|
57
|
-
*/
|
|
58
|
-
class TestVendorService extends VendorService {
|
|
59
|
-
protected override async cloneRemote(): Promise<string> {
|
|
60
|
-
await shell.run(
|
|
61
|
-
"git clone --depth 1 --branch main --filter=blob:none remote /tmp/test-clone",
|
|
62
|
-
);
|
|
63
|
-
return "/tmp/test-clone";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const alepha = Alepha.create()
|
|
68
|
-
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
69
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
70
|
-
|
|
71
|
-
const testService = alepha.inject(TestVendorService);
|
|
72
|
-
const testFs = alepha.inject(MemoryFileSystemProvider);
|
|
83
|
+
const { service, fs } = createTestService(
|
|
84
|
+
Alepha.create()
|
|
85
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
86
|
+
.inject(MemoryShellProvider),
|
|
87
|
+
);
|
|
73
88
|
|
|
74
|
-
await
|
|
89
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", {
|
|
75
90
|
recursive: true,
|
|
76
91
|
});
|
|
77
|
-
await
|
|
92
|
+
await fs.writeFile(
|
|
78
93
|
"/tmp/test-clone/packages/my-pkg/index.ts",
|
|
79
94
|
"export {}",
|
|
80
95
|
);
|
|
81
|
-
await
|
|
82
|
-
await
|
|
96
|
+
await fs.mkdir("/project/packages/my-pkg", { recursive: true });
|
|
97
|
+
await fs.writeFile("/project/packages/my-pkg/old-file.ts", "old");
|
|
83
98
|
|
|
84
|
-
const result = await
|
|
99
|
+
const result = await service.sync({
|
|
85
100
|
root: "/project",
|
|
86
101
|
remote: "remote",
|
|
87
102
|
branch: "main",
|
|
@@ -91,28 +106,21 @@ describe("VendorService", () => {
|
|
|
91
106
|
|
|
92
107
|
expect(result.synced).toEqual(["my-pkg"]);
|
|
93
108
|
expect(result.errors).toEqual([]);
|
|
94
|
-
expect(
|
|
109
|
+
expect(fs.wasDeleted("/project/packages/my-pkg")).toBe(true);
|
|
95
110
|
});
|
|
96
111
|
|
|
97
112
|
it("should report errors for missing remote packages", async ({
|
|
98
113
|
expect,
|
|
99
114
|
}) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const alepha = Alepha.create()
|
|
107
|
-
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
108
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
109
|
-
|
|
110
|
-
const testService = alepha.inject(TestVendorService);
|
|
111
|
-
const testFs = alepha.inject(MemoryFileSystemProvider);
|
|
115
|
+
const { service, fs } = createTestService(
|
|
116
|
+
Alepha.create()
|
|
117
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
118
|
+
.inject(MemoryShellProvider),
|
|
119
|
+
);
|
|
112
120
|
|
|
113
|
-
await
|
|
121
|
+
await fs.mkdir("/tmp/test-clone/packages", { recursive: true });
|
|
114
122
|
|
|
115
|
-
const result = await
|
|
123
|
+
const result = await service.sync({
|
|
116
124
|
root: "/project",
|
|
117
125
|
remote: "remote",
|
|
118
126
|
branch: "main",
|
|
@@ -126,25 +134,18 @@ describe("VendorService", () => {
|
|
|
126
134
|
});
|
|
127
135
|
|
|
128
136
|
it("should sync multiple packages", async ({ expect }) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const alepha = Alepha.create()
|
|
136
|
-
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
137
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
138
|
-
|
|
139
|
-
const testService = alepha.inject(TestVendorService);
|
|
140
|
-
const testFs = alepha.inject(MemoryFileSystemProvider);
|
|
137
|
+
const { service, fs } = createTestService(
|
|
138
|
+
Alepha.create()
|
|
139
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
140
|
+
.inject(MemoryShellProvider),
|
|
141
|
+
);
|
|
141
142
|
|
|
142
|
-
await
|
|
143
|
-
await
|
|
144
|
-
await
|
|
145
|
-
await
|
|
143
|
+
await fs.mkdir("/tmp/test-clone/packages/pkg-a", { recursive: true });
|
|
144
|
+
await fs.writeFile("/tmp/test-clone/packages/pkg-a/index.ts", "a");
|
|
145
|
+
await fs.mkdir("/tmp/test-clone/packages/pkg-b", { recursive: true });
|
|
146
|
+
await fs.writeFile("/tmp/test-clone/packages/pkg-b/index.ts", "b");
|
|
146
147
|
|
|
147
|
-
const result = await
|
|
148
|
+
const result = await service.sync({
|
|
148
149
|
root: "/project",
|
|
149
150
|
remote: "remote",
|
|
150
151
|
branch: "main",
|
|
@@ -161,6 +162,10 @@ describe("VendorService", () => {
|
|
|
161
162
|
protected override async cloneRemote(): Promise<string> {
|
|
162
163
|
return "/tmp/test-clone";
|
|
163
164
|
}
|
|
165
|
+
|
|
166
|
+
protected override async getCommitHash(): Promise<string> {
|
|
167
|
+
return "abc123";
|
|
168
|
+
}
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
const alepha = Alepha.create()
|
|
@@ -195,102 +200,171 @@ describe("VendorService", () => {
|
|
|
195
200
|
|
|
196
201
|
testFs.cp = originalCp;
|
|
197
202
|
});
|
|
198
|
-
});
|
|
199
203
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
it("should write vendor.json after successful sync", async ({ expect }) => {
|
|
205
|
+
const { service, fs } = createTestService(
|
|
206
|
+
Alepha.create()
|
|
207
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
208
|
+
.inject(MemoryShellProvider),
|
|
209
|
+
);
|
|
203
210
|
|
|
204
|
-
await
|
|
211
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", { recursive: true });
|
|
212
|
+
await fs.writeFile("/tmp/test-clone/packages/my-pkg/index.ts", "code");
|
|
213
|
+
|
|
214
|
+
await service.sync({
|
|
205
215
|
root: "/project",
|
|
206
|
-
remote: "
|
|
216
|
+
remote: "remote",
|
|
207
217
|
branch: "main",
|
|
208
|
-
packages: [],
|
|
218
|
+
packages: ["my-pkg"],
|
|
209
219
|
});
|
|
210
220
|
|
|
211
|
-
expect(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
).toBe(true);
|
|
221
|
+
expect(fs.wasWritten("/project/.alepha/vendor.json")).toBe(true);
|
|
222
|
+
const content = await fs.readFile("/project/.alepha/vendor.json");
|
|
223
|
+
const lock = JSON.parse(content.toString());
|
|
224
|
+
expect(lock.commit).toBe("abc123");
|
|
216
225
|
});
|
|
217
226
|
|
|
218
|
-
it("should
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
it("should skip modification check on first sync (no vendor.json)", async ({
|
|
228
|
+
expect,
|
|
229
|
+
}) => {
|
|
230
|
+
const { service, fs } = createTestService(
|
|
231
|
+
Alepha.create()
|
|
232
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
233
|
+
.inject(MemoryShellProvider),
|
|
234
|
+
);
|
|
224
235
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
236
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", { recursive: true });
|
|
237
|
+
await fs.writeFile("/tmp/test-clone/packages/my-pkg/index.ts", "code");
|
|
228
238
|
|
|
229
|
-
const
|
|
230
|
-
|
|
239
|
+
const result = await service.sync({
|
|
240
|
+
root: "/project",
|
|
241
|
+
remote: "remote",
|
|
242
|
+
branch: "main",
|
|
243
|
+
packages: ["my-pkg"],
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
expect(result.synced).toEqual(["my-pkg"]);
|
|
247
|
+
expect(result.aborted).toBeUndefined();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("should abort when local modifications detected against baseline", async ({
|
|
251
|
+
expect,
|
|
252
|
+
}) => {
|
|
253
|
+
const { service, fs } = createTestService(
|
|
254
|
+
Alepha.create()
|
|
255
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
256
|
+
.inject(MemoryShellProvider),
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Baseline (last synced state)
|
|
260
|
+
await fs.mkdir("/tmp/test-baseline/packages/my-pkg", { recursive: true });
|
|
261
|
+
await fs.writeFile(
|
|
262
|
+
"/tmp/test-baseline/packages/my-pkg/index.ts",
|
|
263
|
+
"original",
|
|
264
|
+
);
|
|
231
265
|
|
|
232
|
-
|
|
233
|
-
await
|
|
234
|
-
await
|
|
266
|
+
// Local (user modified)
|
|
267
|
+
await fs.mkdir("/project/packages/my-pkg", { recursive: true });
|
|
268
|
+
await fs.writeFile("/project/packages/my-pkg/index.ts", "modified");
|
|
235
269
|
|
|
236
|
-
|
|
237
|
-
await
|
|
270
|
+
// Remote (latest)
|
|
271
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", { recursive: true });
|
|
272
|
+
await fs.writeFile("/tmp/test-clone/packages/my-pkg/index.ts", "latest");
|
|
238
273
|
|
|
239
|
-
|
|
274
|
+
// Vendor lock exists from a previous sync
|
|
275
|
+
await fs.mkdir("/project/.alepha", { recursive: true });
|
|
276
|
+
await fs.writeFile(
|
|
277
|
+
"/project/.alepha/vendor.json",
|
|
278
|
+
JSON.stringify({ commit: "old-hash" }),
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
const result = await service.sync({
|
|
240
282
|
root: "/project",
|
|
241
283
|
remote: "remote",
|
|
242
284
|
branch: "main",
|
|
243
|
-
packages: ["pkg"],
|
|
285
|
+
packages: ["my-pkg"],
|
|
244
286
|
});
|
|
245
287
|
|
|
246
|
-
expect(result.
|
|
247
|
-
expect(result.
|
|
248
|
-
expect(result.packages[0].modified).toEqual([]);
|
|
249
|
-
expect(result.packages[0].removed).toEqual([]);
|
|
250
|
-
expect(result.totalChanges).toBe(1);
|
|
288
|
+
expect(result.aborted).toBeDefined();
|
|
289
|
+
expect(result.synced).toEqual([]);
|
|
251
290
|
});
|
|
252
291
|
|
|
253
|
-
it("should
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
it("should sync when local matches baseline", async ({ expect }) => {
|
|
293
|
+
const { service, fs } = createTestService(
|
|
294
|
+
Alepha.create()
|
|
295
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
296
|
+
.inject(MemoryShellProvider),
|
|
297
|
+
);
|
|
259
298
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
299
|
+
// Baseline and local are identical
|
|
300
|
+
await fs.mkdir("/tmp/test-baseline/packages/my-pkg", { recursive: true });
|
|
301
|
+
await fs.writeFile("/tmp/test-baseline/packages/my-pkg/index.ts", "same");
|
|
263
302
|
|
|
264
|
-
|
|
265
|
-
|
|
303
|
+
await fs.mkdir("/project/packages/my-pkg", { recursive: true });
|
|
304
|
+
await fs.writeFile("/project/packages/my-pkg/index.ts", "same");
|
|
266
305
|
|
|
267
|
-
|
|
268
|
-
await
|
|
269
|
-
|
|
270
|
-
|
|
306
|
+
// Remote has updates
|
|
307
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", { recursive: true });
|
|
308
|
+
await fs.writeFile("/tmp/test-clone/packages/my-pkg/index.ts", "updated");
|
|
309
|
+
|
|
310
|
+
await fs.mkdir("/project/.alepha", { recursive: true });
|
|
311
|
+
await fs.writeFile(
|
|
312
|
+
"/project/.alepha/vendor.json",
|
|
313
|
+
JSON.stringify({ commit: "old-hash" }),
|
|
271
314
|
);
|
|
272
315
|
|
|
273
|
-
await
|
|
274
|
-
|
|
275
|
-
"
|
|
276
|
-
|
|
316
|
+
const result = await service.sync({
|
|
317
|
+
root: "/project",
|
|
318
|
+
remote: "remote",
|
|
319
|
+
branch: "main",
|
|
320
|
+
packages: ["my-pkg"],
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
expect(result.synced).toEqual(["my-pkg"]);
|
|
324
|
+
expect(result.aborted).toBeUndefined();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("should skip modification check with --force even when vendor.json exists", async ({
|
|
328
|
+
expect,
|
|
329
|
+
}) => {
|
|
330
|
+
const { service, fs } = createTestService(
|
|
331
|
+
Alepha.create()
|
|
332
|
+
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
333
|
+
.inject(MemoryShellProvider),
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
// Local has modifications
|
|
337
|
+
await fs.mkdir("/project/packages/my-pkg", { recursive: true });
|
|
338
|
+
await fs.writeFile("/project/packages/my-pkg/index.ts", "modified");
|
|
339
|
+
|
|
340
|
+
// Remote
|
|
341
|
+
await fs.mkdir("/tmp/test-clone/packages/my-pkg", { recursive: true });
|
|
342
|
+
await fs.writeFile("/tmp/test-clone/packages/my-pkg/index.ts", "latest");
|
|
343
|
+
|
|
344
|
+
await fs.mkdir("/project/.alepha", { recursive: true });
|
|
345
|
+
await fs.writeFile(
|
|
346
|
+
"/project/.alepha/vendor.json",
|
|
347
|
+
JSON.stringify({ commit: "old-hash" }),
|
|
277
348
|
);
|
|
278
349
|
|
|
279
|
-
const result = await
|
|
350
|
+
const result = await service.sync({
|
|
280
351
|
root: "/project",
|
|
281
352
|
remote: "remote",
|
|
282
353
|
branch: "main",
|
|
283
|
-
packages: ["pkg"],
|
|
354
|
+
packages: ["my-pkg"],
|
|
355
|
+
force: true,
|
|
284
356
|
});
|
|
285
357
|
|
|
286
|
-
expect(result.
|
|
287
|
-
expect(result.
|
|
358
|
+
expect(result.synced).toEqual(["my-pkg"]);
|
|
359
|
+
expect(result.aborted).toBeUndefined();
|
|
288
360
|
});
|
|
361
|
+
});
|
|
289
362
|
|
|
290
|
-
|
|
363
|
+
describe("diff", () => {
|
|
364
|
+
const createDiffTestService = () => {
|
|
291
365
|
class TestVendorService extends VendorService {
|
|
292
|
-
protected override async
|
|
293
|
-
return "/tmp/test-
|
|
366
|
+
protected override async cloneAtCommit(): Promise<string> {
|
|
367
|
+
return "/tmp/test-baseline";
|
|
294
368
|
}
|
|
295
369
|
}
|
|
296
370
|
|
|
@@ -298,110 +372,180 @@ describe("VendorService", () => {
|
|
|
298
372
|
.with({ provide: ShellProvider, use: MemoryShellProvider })
|
|
299
373
|
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
300
374
|
|
|
301
|
-
|
|
302
|
-
|
|
375
|
+
return {
|
|
376
|
+
service: alepha.inject(TestVendorService),
|
|
377
|
+
fs: alepha.inject(MemoryFileSystemProvider),
|
|
378
|
+
};
|
|
379
|
+
};
|
|
303
380
|
|
|
304
|
-
|
|
305
|
-
await
|
|
381
|
+
const writeVendorLock = async (fs: MemoryFileSystemProvider) => {
|
|
382
|
+
await fs.mkdir("/project/.alepha", { recursive: true });
|
|
383
|
+
await fs.writeFile(
|
|
384
|
+
"/project/.alepha/vendor.json",
|
|
385
|
+
JSON.stringify({ commit: "abc123" }),
|
|
386
|
+
);
|
|
387
|
+
};
|
|
306
388
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
389
|
+
it("should return no changes when no vendor.json exists", async ({
|
|
390
|
+
expect,
|
|
391
|
+
}) => {
|
|
392
|
+
const { service } = createDiffTestService();
|
|
310
393
|
|
|
311
|
-
const result = await
|
|
394
|
+
const result = await service.diff({
|
|
312
395
|
root: "/project",
|
|
313
396
|
remote: "remote",
|
|
314
397
|
branch: "main",
|
|
315
398
|
packages: ["pkg"],
|
|
316
399
|
});
|
|
317
400
|
|
|
318
|
-
expect(result.packages
|
|
319
|
-
expect(result.totalChanges).toBe(
|
|
401
|
+
expect(result.packages).toEqual([]);
|
|
402
|
+
expect(result.totalChanges).toBe(0);
|
|
320
403
|
});
|
|
321
404
|
|
|
322
|
-
it("should
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return "/tmp/test-clone";
|
|
326
|
-
}
|
|
327
|
-
}
|
|
405
|
+
it("should detect locally added files", async ({ expect }) => {
|
|
406
|
+
const { service, fs } = createDiffTestService();
|
|
407
|
+
await writeVendorLock(fs);
|
|
328
408
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
409
|
+
// Baseline (last synced state)
|
|
410
|
+
await fs.mkdir("/tmp/test-baseline/packages/pkg", { recursive: true });
|
|
411
|
+
await fs.writeFile("/tmp/test-baseline/packages/pkg/shared.ts", "same");
|
|
332
412
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
await
|
|
337
|
-
await testFs.mkdir("/project/packages/pkg", { recursive: true });
|
|
338
|
-
await testFs.writeFile("/project/packages/pkg/file.ts", "local");
|
|
413
|
+
// Local (user added a file)
|
|
414
|
+
await fs.mkdir("/project/packages/pkg", { recursive: true });
|
|
415
|
+
await fs.writeFile("/project/packages/pkg/shared.ts", "same");
|
|
416
|
+
await fs.writeFile("/project/packages/pkg/local-only.ts", "local");
|
|
339
417
|
|
|
340
|
-
const result = await
|
|
418
|
+
const result = await service.diff({
|
|
341
419
|
root: "/project",
|
|
342
420
|
remote: "remote",
|
|
343
421
|
branch: "main",
|
|
344
422
|
packages: ["pkg"],
|
|
345
423
|
});
|
|
346
424
|
|
|
347
|
-
expect(result.packages[0].
|
|
348
|
-
expect(result.packages[0].added).toEqual([]);
|
|
425
|
+
expect(result.packages[0].added).toEqual(["local-only.ts"]);
|
|
349
426
|
expect(result.totalChanges).toBe(1);
|
|
350
427
|
});
|
|
351
428
|
|
|
352
|
-
it("should
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return "/tmp/test-clone";
|
|
356
|
-
}
|
|
357
|
-
}
|
|
429
|
+
it("should detect locally modified files", async ({ expect }) => {
|
|
430
|
+
const { service, fs } = createDiffTestService();
|
|
431
|
+
await writeVendorLock(fs);
|
|
358
432
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
433
|
+
await fs.mkdir("/tmp/test-baseline/packages/pkg", { recursive: true });
|
|
434
|
+
await fs.writeFile("/tmp/test-baseline/packages/pkg/file.ts", "original");
|
|
362
435
|
|
|
363
|
-
|
|
364
|
-
|
|
436
|
+
await fs.mkdir("/project/packages/pkg", { recursive: true });
|
|
437
|
+
await fs.writeFile("/project/packages/pkg/file.ts", "modified by user");
|
|
365
438
|
|
|
366
|
-
await
|
|
367
|
-
|
|
439
|
+
const result = await service.diff({
|
|
440
|
+
root: "/project",
|
|
441
|
+
remote: "remote",
|
|
442
|
+
branch: "main",
|
|
443
|
+
packages: ["pkg"],
|
|
444
|
+
});
|
|
368
445
|
|
|
369
|
-
|
|
446
|
+
expect(result.packages[0].modified).toHaveLength(1);
|
|
447
|
+
expect(result.packages[0].modified[0].file).toBe("file.ts");
|
|
448
|
+
expect(result.packages[0].modified[0].changes).toEqual([
|
|
449
|
+
{ line: 1, type: "removed", text: "original" },
|
|
450
|
+
{ line: 1, type: "added", text: "modified by user" },
|
|
451
|
+
]);
|
|
452
|
+
expect(result.totalChanges).toBe(1);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it("should detect locally removed files", async ({ expect }) => {
|
|
456
|
+
const { service, fs } = createDiffTestService();
|
|
457
|
+
await writeVendorLock(fs);
|
|
458
|
+
|
|
459
|
+
// Baseline had two files
|
|
460
|
+
await fs.mkdir("/tmp/test-baseline/packages/pkg", { recursive: true });
|
|
461
|
+
await fs.writeFile("/tmp/test-baseline/packages/pkg/kept.ts", "same");
|
|
462
|
+
await fs.writeFile("/tmp/test-baseline/packages/pkg/deleted.ts", "gone");
|
|
463
|
+
|
|
464
|
+
// Local only has one
|
|
465
|
+
await fs.mkdir("/project/packages/pkg", { recursive: true });
|
|
466
|
+
await fs.writeFile("/project/packages/pkg/kept.ts", "same");
|
|
467
|
+
|
|
468
|
+
const result = await service.diff({
|
|
370
469
|
root: "/project",
|
|
371
470
|
remote: "remote",
|
|
372
471
|
branch: "main",
|
|
373
472
|
packages: ["pkg"],
|
|
374
473
|
});
|
|
375
474
|
|
|
376
|
-
expect(result.packages[0].
|
|
377
|
-
expect(result.packages[0].removed).toEqual([]);
|
|
475
|
+
expect(result.packages[0].removed).toEqual(["deleted.ts"]);
|
|
378
476
|
expect(result.totalChanges).toBe(1);
|
|
379
477
|
});
|
|
380
478
|
|
|
381
|
-
it("should
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
479
|
+
it("should report no changes when local matches baseline", async ({
|
|
480
|
+
expect,
|
|
481
|
+
}) => {
|
|
482
|
+
const { service, fs } = createDiffTestService();
|
|
483
|
+
await writeVendorLock(fs);
|
|
387
484
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
.with({ provide: FileSystemProvider, use: MemoryFileSystemProvider });
|
|
485
|
+
await fs.mkdir("/tmp/test-baseline/packages/pkg", { recursive: true });
|
|
486
|
+
await fs.writeFile("/tmp/test-baseline/packages/pkg/file.ts", "same");
|
|
391
487
|
|
|
392
|
-
|
|
393
|
-
|
|
488
|
+
await fs.mkdir("/project/packages/pkg", { recursive: true });
|
|
489
|
+
await fs.writeFile("/project/packages/pkg/file.ts", "same");
|
|
394
490
|
|
|
395
|
-
await
|
|
491
|
+
const result = await service.diff({
|
|
492
|
+
root: "/project",
|
|
493
|
+
remote: "remote",
|
|
494
|
+
branch: "main",
|
|
495
|
+
packages: ["pkg"],
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
expect(result.totalChanges).toBe(0);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it("should include line-level changes for multi-line modifications", async ({
|
|
502
|
+
expect,
|
|
503
|
+
}) => {
|
|
504
|
+
const { service, fs } = createDiffTestService();
|
|
505
|
+
await writeVendorLock(fs);
|
|
506
|
+
|
|
507
|
+
await fs.mkdir("/tmp/test-baseline/packages/pkg", { recursive: true });
|
|
508
|
+
await fs.writeFile(
|
|
509
|
+
"/tmp/test-baseline/packages/pkg/config.ts",
|
|
510
|
+
"const a = 1;\nconst b = 2;\nconst c = 3;",
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
await fs.mkdir("/project/packages/pkg", { recursive: true });
|
|
514
|
+
await fs.writeFile(
|
|
515
|
+
"/project/packages/pkg/config.ts",
|
|
516
|
+
"const a = 1;\nconst b = 99;\nconst c = 3;\nconst d = 4;",
|
|
517
|
+
);
|
|
396
518
|
|
|
397
|
-
await
|
|
519
|
+
const result = await service.diff({
|
|
520
|
+
root: "/project",
|
|
521
|
+
remote: "remote",
|
|
522
|
+
branch: "main",
|
|
523
|
+
packages: ["pkg"],
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const fileDiff = result.packages[0].modified[0];
|
|
527
|
+
expect(fileDiff.file).toBe("config.ts");
|
|
528
|
+
expect(fileDiff.changes).toEqual([
|
|
529
|
+
{ line: 2, type: "removed", text: "const b = 2;" },
|
|
530
|
+
{ line: 2, type: "added", text: "const b = 99;" },
|
|
531
|
+
{ line: 4, type: "added", text: "const d = 4;" },
|
|
532
|
+
]);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("should clean up temp directory after diff", async ({ expect }) => {
|
|
536
|
+
const { service, fs } = createDiffTestService();
|
|
537
|
+
await writeVendorLock(fs);
|
|
538
|
+
|
|
539
|
+
await fs.mkdir("/tmp/test-baseline/packages", { recursive: true });
|
|
540
|
+
|
|
541
|
+
await service.diff({
|
|
398
542
|
root: "/project",
|
|
399
543
|
remote: "remote",
|
|
400
544
|
branch: "main",
|
|
401
545
|
packages: [],
|
|
402
546
|
});
|
|
403
547
|
|
|
404
|
-
expect(
|
|
548
|
+
expect(fs.wasDeleted("/tmp/test-baseline")).toBe(true);
|
|
405
549
|
});
|
|
406
550
|
});
|
|
407
551
|
});
|