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
|
@@ -66,13 +66,28 @@ interface VendorDiffOptions {
|
|
|
66
66
|
branch: string;
|
|
67
67
|
packages: string[];
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A single line change within a modified file.
|
|
71
|
+
*/
|
|
72
|
+
interface VendorLineDiff {
|
|
73
|
+
line: number;
|
|
74
|
+
type: "added" | "removed";
|
|
75
|
+
text: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A modified file with its line-level changes.
|
|
79
|
+
*/
|
|
80
|
+
interface VendorFileDiff {
|
|
81
|
+
file: string;
|
|
82
|
+
changes: VendorLineDiff[];
|
|
83
|
+
}
|
|
69
84
|
/**
|
|
70
85
|
* Diff result for a single vendored package.
|
|
71
86
|
*/
|
|
72
87
|
interface VendorPackageDiff {
|
|
73
88
|
name: string;
|
|
74
89
|
added: string[];
|
|
75
|
-
modified:
|
|
90
|
+
modified: VendorFileDiff[];
|
|
76
91
|
removed: string[];
|
|
77
92
|
}
|
|
78
93
|
/**
|
|
@@ -82,6 +97,12 @@ interface VendorDiffResult {
|
|
|
82
97
|
packages: VendorPackageDiff[];
|
|
83
98
|
totalChanges: number;
|
|
84
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Shape of the <root>/.alepha/vendor.json lock file.
|
|
102
|
+
*/
|
|
103
|
+
interface VendorLock {
|
|
104
|
+
commit: string;
|
|
105
|
+
}
|
|
85
106
|
/**
|
|
86
107
|
* Handles syncing and diffing vendored packages from a remote git repository.
|
|
87
108
|
*/
|
|
@@ -92,17 +113,18 @@ declare class VendorService {
|
|
|
92
113
|
/**
|
|
93
114
|
* Sync vendored packages from a remote repository.
|
|
94
115
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
116
|
+
* Without `force`: checks for local modifications by comparing the local
|
|
117
|
+
* copy against the last-synced commit (stored in .alepha/vendor.json).
|
|
118
|
+
* If modifications are found, aborts without touching local files.
|
|
119
|
+
*
|
|
120
|
+
* With `force` (or first sync): replaces local copies unconditionally.
|
|
99
121
|
*/
|
|
100
122
|
sync(options: VendorSyncOptions): Promise<VendorSyncResult>;
|
|
101
123
|
/**
|
|
102
|
-
* Diff vendored packages against
|
|
124
|
+
* Diff vendored packages against the last-synced commit.
|
|
103
125
|
*
|
|
104
|
-
*
|
|
105
|
-
* files to
|
|
126
|
+
* Reads the commit hash from .alepha/vendor.json, clones at that commit,
|
|
127
|
+
* and compares local files to detect modifications since last sync.
|
|
106
128
|
*/
|
|
107
129
|
diff(options: VendorDiffOptions): Promise<VendorDiffResult>;
|
|
108
130
|
/**
|
|
@@ -117,6 +139,22 @@ declare class VendorService {
|
|
|
117
139
|
* Clone a remote repository into a temporary directory.
|
|
118
140
|
*/
|
|
119
141
|
protected cloneRemote(remote: string, branch: string): Promise<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Clone a remote repository at a specific commit hash.
|
|
144
|
+
*/
|
|
145
|
+
protected cloneAtCommit(remote: string, commit: string): Promise<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Get the HEAD commit hash from a cloned repository.
|
|
148
|
+
*/
|
|
149
|
+
protected getCommitHash(repoDir: string): Promise<string>;
|
|
150
|
+
/**
|
|
151
|
+
* Read the vendor lock file.
|
|
152
|
+
*/
|
|
153
|
+
protected readLock(root: string): Promise<VendorLock | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Write the vendor lock file.
|
|
156
|
+
*/
|
|
157
|
+
protected writeLock(root: string, lock: VendorLock): Promise<void>;
|
|
120
158
|
/**
|
|
121
159
|
* Directories to ignore during diff comparisons.
|
|
122
160
|
*/
|
|
@@ -130,9 +168,20 @@ declare class VendorService {
|
|
|
130
168
|
*/
|
|
131
169
|
protected diffDirectories(localDir: string, remoteDir: string): Promise<{
|
|
132
170
|
added: string[];
|
|
133
|
-
modified:
|
|
171
|
+
modified: VendorFileDiff[];
|
|
134
172
|
removed: string[];
|
|
135
173
|
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Compute line-level differences between two file contents.
|
|
176
|
+
*
|
|
177
|
+
* Uses a longest-common-subsequence algorithm to produce minimal
|
|
178
|
+
* added/removed line changes with accurate line numbers.
|
|
179
|
+
*/
|
|
180
|
+
protected computeLineDiff(baseline: string, local: string): VendorLineDiff[];
|
|
181
|
+
/**
|
|
182
|
+
* Compute the longest common subsequence of two string arrays.
|
|
183
|
+
*/
|
|
184
|
+
protected longestCommonSubsequence(a: string[], b: string[]): string[];
|
|
136
185
|
}
|
|
137
186
|
//#endregion
|
|
138
187
|
//#region ../../src/cli/vendor/commands/VendorCommand.d.ts
|
|
@@ -161,6 +210,7 @@ declare class VendorCommand {
|
|
|
161
210
|
force: _$alepha.TOptional<_$alepha.TBoolean>;
|
|
162
211
|
}>, _$alepha.TSchema, _$alepha.TObject<_$alepha.TProperties>>;
|
|
163
212
|
protected readonly diff: _$alepha_command0.CommandPrimitive<_$alepha.TObject<_$alepha.TProperties>, _$alepha.TSchema, _$alepha.TObject<_$alepha.TProperties>>;
|
|
213
|
+
protected printPackageDiff(pkg: VendorPackageDiff): void;
|
|
164
214
|
readonly vendor: _$alepha_command0.CommandPrimitive<_$alepha.TObject<_$alepha.TProperties>, _$alepha.TSchema, _$alepha.TObject<_$alepha.TProperties>>;
|
|
165
215
|
}
|
|
166
216
|
//#endregion
|
|
@@ -197,5 +247,5 @@ declare module "alepha/cli/config" {
|
|
|
197
247
|
*/
|
|
198
248
|
declare const AlephaCliVendorPlugin: _$alepha.Service<_$alepha.Module>;
|
|
199
249
|
//#endregion
|
|
200
|
-
export { AlephaCliVendorPlugin, VendorCommand, VendorDiffOptions, VendorDiffResult, VendorOptions, VendorPackageDiff, VendorService, VendorSyncOptions, VendorSyncResult, vendorOptions };
|
|
250
|
+
export { AlephaCliVendorPlugin, VendorCommand, VendorDiffOptions, VendorDiffResult, VendorFileDiff, VendorLineDiff, VendorLock, VendorOptions, VendorPackageDiff, VendorService, VendorSyncOptions, VendorSyncResult, vendorOptions };
|
|
201
251
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"mappings":";;;;;;;;;;;;;;;cAQa,aAAA,EAAa,QAAA,CAAA,IAAA,CAAA,QAAA,CAAA,SAAA,UAAA,OAAA;;AAA1B;;;;6BA2BE,QAAA,CAAA,OAAA;;;;;;;EA3BwB;;;;;;;;;;KAgCd,aAAA,GAAgB,MAAA,QAAc,aAAA,CAAc,MAAA;;;;;;UCjCvC,iBAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA;EACA,KAAA;AAAA;;;;UAMe,gBAAA;EACf,MAAA;EACA,MAAA;EACA,OAAA,GAAU,gBAAA;AAAA;;;;UAMK,iBAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;UAMe,iBAAA;EACf,IAAA;EACA,KAAA;EACA,QAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"mappings":";;;;;;;;;;;;;;;cAQa,aAAA,EAAa,QAAA,CAAA,IAAA,CAAA,QAAA,CAAA,SAAA,UAAA,OAAA;;AAA1B;;;;6BA2BE,QAAA,CAAA,OAAA;;;;;;;EA3BwB;;;;;;;;;;KAgCd,aAAA,GAAgB,MAAA,QAAc,aAAA,CAAc,MAAA;;;;;;UCjCvC,iBAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA;EACA,KAAA;AAAA;;;;UAMe,gBAAA;EACf,MAAA;EACA,MAAA;EACA,OAAA,GAAU,gBAAA;AAAA;;;;UAMK,iBAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;UAMe,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|
+
* Without `force`: checks for local modifications by comparing the local
|
|
36
|
+
* copy against the last-synced commit (stored in .alepha/vendor.json).
|
|
37
|
+
* If modifications are found, aborts without touching local files.
|
|
38
|
+
*
|
|
39
|
+
* With `force` (or first sync): replaces local copies unconditionally.
|
|
39
40
|
*/
|
|
40
41
|
async sync(options) {
|
|
41
42
|
const synced = [];
|
|
42
43
|
const errors = [];
|
|
44
|
+
if (!options.force) {
|
|
45
|
+
const lock = await this.readLock(options.root);
|
|
46
|
+
if (lock) {
|
|
47
|
+
let baselineDir;
|
|
48
|
+
try {
|
|
49
|
+
baselineDir = await this.cloneAtCommit(options.remote, lock.commit);
|
|
50
|
+
const diffResult = await this.diffFromClone(options.root, baselineDir, options.packages);
|
|
51
|
+
if (diffResult.totalChanges > 0) return {
|
|
52
|
+
synced: [],
|
|
53
|
+
errors: [],
|
|
54
|
+
aborted: diffResult
|
|
55
|
+
};
|
|
56
|
+
} finally {
|
|
57
|
+
if (baselineDir) await this.fs.rm(baselineDir, {
|
|
58
|
+
recursive: true,
|
|
59
|
+
force: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
43
64
|
let tmpDir;
|
|
44
65
|
try {
|
|
45
66
|
tmpDir = await this.cloneRemote(options.remote, options.branch);
|
|
46
|
-
if (!options.force) {
|
|
47
|
-
const diffResult = await this.diffFromClone(options.root, tmpDir, options.packages);
|
|
48
|
-
if (diffResult.totalChanges > 0) return {
|
|
49
|
-
synced: [],
|
|
50
|
-
errors: [],
|
|
51
|
-
aborted: diffResult
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
67
|
for (const pkg of options.packages) {
|
|
55
68
|
const remotePkgDir = this.fs.join(tmpDir, "packages", pkg);
|
|
56
69
|
const localPkgDir = this.fs.join(options.root, "packages", pkg);
|
|
@@ -67,6 +80,8 @@ var VendorService = class {
|
|
|
67
80
|
await this.removeIgnoredFiles(localPkgDir);
|
|
68
81
|
synced.push(pkg);
|
|
69
82
|
}
|
|
83
|
+
const commit = await this.getCommitHash(tmpDir);
|
|
84
|
+
await this.writeLock(options.root, { commit });
|
|
70
85
|
} finally {
|
|
71
86
|
if (tmpDir) await this.fs.rm(tmpDir, {
|
|
72
87
|
recursive: true,
|
|
@@ -79,15 +94,20 @@ var VendorService = class {
|
|
|
79
94
|
};
|
|
80
95
|
}
|
|
81
96
|
/**
|
|
82
|
-
* Diff vendored packages against
|
|
97
|
+
* Diff vendored packages against the last-synced commit.
|
|
83
98
|
*
|
|
84
|
-
*
|
|
85
|
-
* files to
|
|
99
|
+
* Reads the commit hash from .alepha/vendor.json, clones at that commit,
|
|
100
|
+
* and compares local files to detect modifications since last sync.
|
|
86
101
|
*/
|
|
87
102
|
async diff(options) {
|
|
103
|
+
const lock = await this.readLock(options.root);
|
|
104
|
+
if (!lock) return {
|
|
105
|
+
packages: [],
|
|
106
|
+
totalChanges: 0
|
|
107
|
+
};
|
|
88
108
|
let tmpDir;
|
|
89
109
|
try {
|
|
90
|
-
tmpDir = await this.
|
|
110
|
+
tmpDir = await this.cloneAtCommit(options.remote, lock.commit);
|
|
91
111
|
return await this.diffFromClone(options.root, tmpDir, options.packages);
|
|
92
112
|
} finally {
|
|
93
113
|
if (tmpDir) await this.fs.rm(tmpDir, {
|
|
@@ -120,9 +140,9 @@ var VendorService = class {
|
|
|
120
140
|
const localFiles = await this.fs.ls(localPkgDir, { recursive: true });
|
|
121
141
|
results.push({
|
|
122
142
|
name: pkg,
|
|
123
|
-
added:
|
|
143
|
+
added: localFiles,
|
|
124
144
|
modified: [],
|
|
125
|
-
removed:
|
|
145
|
+
removed: []
|
|
126
146
|
});
|
|
127
147
|
totalChanges += localFiles.length;
|
|
128
148
|
continue;
|
|
@@ -131,9 +151,9 @@ var VendorService = class {
|
|
|
131
151
|
const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });
|
|
132
152
|
results.push({
|
|
133
153
|
name: pkg,
|
|
134
|
-
added:
|
|
154
|
+
added: [],
|
|
135
155
|
modified: [],
|
|
136
|
-
removed:
|
|
156
|
+
removed: remoteFiles
|
|
137
157
|
});
|
|
138
158
|
totalChanges += remoteFiles.length;
|
|
139
159
|
continue;
|
|
@@ -158,7 +178,7 @@ var VendorService = class {
|
|
|
158
178
|
*/
|
|
159
179
|
async removeIgnoredFiles(pkgDir) {
|
|
160
180
|
const allFiles = await this.fs.ls(pkgDir, { recursive: true });
|
|
161
|
-
for (const file of allFiles) if (file.endsWith(".spec.ts") || file.endsWith(".spec.tsx") || file === "LICENSE") await this.fs.rm(this.fs.join(pkgDir, file), { force: true });
|
|
181
|
+
for (const file of allFiles) if (file.endsWith(".spec.ts") || file.endsWith(".spec.tsx") || file === "LICENSE" || file === "tsdown.config.ts") await this.fs.rm(this.fs.join(pkgDir, file), { force: true });
|
|
162
182
|
for (const file of allFiles) for (const ignored of this.ignoredPaths) if (file === ignored || file.startsWith(`${ignored}/`) || file.includes(`/${ignored}/`) || file.endsWith(`/${ignored}`)) {
|
|
163
183
|
const idx = file.indexOf(ignored);
|
|
164
184
|
const dirPath = this.fs.join(pkgDir, file.substring(0, idx + ignored.length));
|
|
@@ -179,6 +199,41 @@ var VendorService = class {
|
|
|
179
199
|
return tmpDir;
|
|
180
200
|
}
|
|
181
201
|
/**
|
|
202
|
+
* Clone a remote repository at a specific commit hash.
|
|
203
|
+
*/
|
|
204
|
+
async cloneAtCommit(remote, commit) {
|
|
205
|
+
const tmpDir = this.fs.join(process.env.TMPDIR || "/tmp", `.alepha-vendor-${Date.now()}`);
|
|
206
|
+
this.log.debug(`Cloning ${remote}@${commit} into ${tmpDir}`);
|
|
207
|
+
await this.shell.run(`git init ${tmpDir}`, { capture: true });
|
|
208
|
+
await this.shell.run(`git -C ${tmpDir} remote add origin ${remote}`, { capture: true });
|
|
209
|
+
await this.shell.run(`git -C ${tmpDir} fetch --depth 1 origin ${commit}`, { capture: true });
|
|
210
|
+
await this.shell.run(`git -C ${tmpDir} checkout FETCH_HEAD`, { capture: true });
|
|
211
|
+
return tmpDir;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the HEAD commit hash from a cloned repository.
|
|
215
|
+
*/
|
|
216
|
+
async getCommitHash(repoDir) {
|
|
217
|
+
return (await this.shell.run(`git -C ${repoDir} rev-parse HEAD`, { capture: true })).trim();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Read the vendor lock file.
|
|
221
|
+
*/
|
|
222
|
+
async readLock(root) {
|
|
223
|
+
const lockPath = this.fs.join(root, ".alepha", "vendor.json");
|
|
224
|
+
if (!await this.fs.exists(lockPath)) return;
|
|
225
|
+
const content = await this.fs.readFile(lockPath);
|
|
226
|
+
return JSON.parse(content.toString());
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Write the vendor lock file.
|
|
230
|
+
*/
|
|
231
|
+
async writeLock(root, lock) {
|
|
232
|
+
const dir = this.fs.join(root, ".alepha");
|
|
233
|
+
await this.fs.mkdir(dir, { recursive: true });
|
|
234
|
+
await this.fs.writeFile(this.fs.join(dir, "vendor.json"), JSON.stringify(lock, null, 2));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
182
237
|
* Directories to ignore during diff comparisons.
|
|
183
238
|
*/
|
|
184
239
|
ignoredPaths = [
|
|
@@ -191,7 +246,7 @@ var VendorService = class {
|
|
|
191
246
|
* Check if a file path should be ignored during diff.
|
|
192
247
|
*/
|
|
193
248
|
isIgnored(filePath) {
|
|
194
|
-
if (filePath.endsWith(".spec.ts") || filePath.endsWith(".spec.tsx") || filePath === "LICENSE") return true;
|
|
249
|
+
if (filePath.endsWith(".spec.ts") || filePath.endsWith(".spec.tsx") || filePath === "LICENSE" || filePath === "tsdown.config.ts") return true;
|
|
195
250
|
return this.ignoredPaths.some((p) => filePath === p || filePath.startsWith(`${p}/`) || filePath.includes(`/${p}/`) || filePath.endsWith(`/${p}`));
|
|
196
251
|
}
|
|
197
252
|
/**
|
|
@@ -208,21 +263,96 @@ var VendorService = class {
|
|
|
208
263
|
const remoteSet = new Set(filteredRemote);
|
|
209
264
|
for (const file of filteredRemote) {
|
|
210
265
|
if (!localSet.has(file)) {
|
|
211
|
-
|
|
266
|
+
removed.push(file);
|
|
212
267
|
continue;
|
|
213
268
|
}
|
|
214
269
|
try {
|
|
215
270
|
const [localContent, remoteContent] = await Promise.all([this.fs.readFile(this.fs.join(localDir, file)), this.fs.readFile(this.fs.join(remoteDir, file))]);
|
|
216
|
-
if (!localContent.equals(remoteContent))
|
|
271
|
+
if (!localContent.equals(remoteContent)) {
|
|
272
|
+
const changes = this.computeLineDiff(remoteContent.toString(), localContent.toString());
|
|
273
|
+
modified.push({
|
|
274
|
+
file,
|
|
275
|
+
changes
|
|
276
|
+
});
|
|
277
|
+
}
|
|
217
278
|
} catch {}
|
|
218
279
|
}
|
|
219
|
-
for (const file of filteredLocal) if (!remoteSet.has(file))
|
|
280
|
+
for (const file of filteredLocal) if (!remoteSet.has(file)) added.push(file);
|
|
220
281
|
return {
|
|
221
282
|
added,
|
|
222
283
|
modified,
|
|
223
284
|
removed
|
|
224
285
|
};
|
|
225
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Compute line-level differences between two file contents.
|
|
289
|
+
*
|
|
290
|
+
* Uses a longest-common-subsequence algorithm to produce minimal
|
|
291
|
+
* added/removed line changes with accurate line numbers.
|
|
292
|
+
*/
|
|
293
|
+
computeLineDiff(baseline, local) {
|
|
294
|
+
const baseLines = baseline.split("\n");
|
|
295
|
+
const localLines = local.split("\n");
|
|
296
|
+
const lcs = this.longestCommonSubsequence(baseLines, localLines);
|
|
297
|
+
const changes = [];
|
|
298
|
+
let bi = 0;
|
|
299
|
+
let li = 0;
|
|
300
|
+
let ci = 0;
|
|
301
|
+
while (bi < baseLines.length || li < localLines.length) if (ci < lcs.length && bi < baseLines.length && li < localLines.length) if (baseLines[bi] === lcs[ci] && localLines[li] === lcs[ci]) {
|
|
302
|
+
bi++;
|
|
303
|
+
li++;
|
|
304
|
+
ci++;
|
|
305
|
+
} else if (baseLines[bi] !== lcs[ci]) {
|
|
306
|
+
changes.push({
|
|
307
|
+
line: bi + 1,
|
|
308
|
+
type: "removed",
|
|
309
|
+
text: baseLines[bi]
|
|
310
|
+
});
|
|
311
|
+
bi++;
|
|
312
|
+
} else {
|
|
313
|
+
changes.push({
|
|
314
|
+
line: li + 1,
|
|
315
|
+
type: "added",
|
|
316
|
+
text: localLines[li]
|
|
317
|
+
});
|
|
318
|
+
li++;
|
|
319
|
+
}
|
|
320
|
+
else if (bi < baseLines.length) {
|
|
321
|
+
changes.push({
|
|
322
|
+
line: bi + 1,
|
|
323
|
+
type: "removed",
|
|
324
|
+
text: baseLines[bi]
|
|
325
|
+
});
|
|
326
|
+
bi++;
|
|
327
|
+
} else {
|
|
328
|
+
changes.push({
|
|
329
|
+
line: li + 1,
|
|
330
|
+
type: "added",
|
|
331
|
+
text: localLines[li]
|
|
332
|
+
});
|
|
333
|
+
li++;
|
|
334
|
+
}
|
|
335
|
+
return changes;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Compute the longest common subsequence of two string arrays.
|
|
339
|
+
*/
|
|
340
|
+
longestCommonSubsequence(a, b) {
|
|
341
|
+
const m = a.length;
|
|
342
|
+
const n = b.length;
|
|
343
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
344
|
+
for (let i = 1; i <= m; i++) for (let j = 1; j <= n; j++) dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] + 1 : Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
345
|
+
const result = [];
|
|
346
|
+
let i = m;
|
|
347
|
+
let j = n;
|
|
348
|
+
while (i > 0 && j > 0) if (a[i - 1] === b[j - 1]) {
|
|
349
|
+
result.unshift(a[i - 1]);
|
|
350
|
+
i--;
|
|
351
|
+
j--;
|
|
352
|
+
} else if (dp[i - 1][j] > dp[i][j - 1]) i--;
|
|
353
|
+
else j--;
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
226
356
|
};
|
|
227
357
|
//#endregion
|
|
228
358
|
//#region ../../src/cli/vendor/commands/VendorCommand.ts
|
|
@@ -277,14 +407,7 @@ var VendorCommand = class {
|
|
|
277
407
|
if (result.aborted) {
|
|
278
408
|
run.end();
|
|
279
409
|
process.stdout.write(`\nLocal modifications detected. Use ${c.set("CYAN", "--force")} to overwrite.\n`);
|
|
280
|
-
for (const pkg of result.aborted.packages)
|
|
281
|
-
const count = pkg.added.length + pkg.modified.length + pkg.removed.length;
|
|
282
|
-
if (count === 0) continue;
|
|
283
|
-
process.stdout.write(`\n${c.set("CYAN", pkg.name)}: ${count} ${count === 1 ? "file differs" : "files differ"}\n`);
|
|
284
|
-
for (const file of pkg.added) process.stdout.write(` ${c.set("GREEN", "A")} ${file}\n`);
|
|
285
|
-
for (const file of pkg.modified) process.stdout.write(` ${c.set("ORANGE", "M")} ${file}\n`);
|
|
286
|
-
for (const file of pkg.removed) process.stdout.write(` ${c.set("RED", "D")} ${file}\n`);
|
|
287
|
-
}
|
|
410
|
+
for (const pkg of result.aborted.packages) this.printPackageDiff(pkg);
|
|
288
411
|
process.stdout.write("\n");
|
|
289
412
|
return;
|
|
290
413
|
}
|
|
@@ -323,21 +446,30 @@ var VendorCommand = class {
|
|
|
323
446
|
process.stdout.write("\nNo changes\n\n");
|
|
324
447
|
return;
|
|
325
448
|
}
|
|
326
|
-
const
|
|
327
|
-
for (const pkg of result.packages) {
|
|
328
|
-
const count = pkg.added.length + pkg.modified.length + pkg.removed.length;
|
|
329
|
-
if (count === 0) {
|
|
330
|
-
process.stdout.write(`\n${c.set("CYAN", pkg.name)}: no changes\n`);
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
process.stdout.write(`\n${c.set("CYAN", pkg.name)}: ${count} ${count === 1 ? "file differs" : "files differ"}\n`);
|
|
334
|
-
for (const file of pkg.added) process.stdout.write(` ${c.set("GREEN", "A")} ${file}\n`);
|
|
335
|
-
for (const file of pkg.modified) process.stdout.write(` ${c.set("ORANGE", "M")} ${file}\n`);
|
|
336
|
-
for (const file of pkg.removed) process.stdout.write(` ${c.set("RED", "D")} ${file}\n`);
|
|
337
|
-
}
|
|
449
|
+
for (const pkg of result.packages) this.printPackageDiff(pkg);
|
|
338
450
|
process.stdout.write("\n");
|
|
339
451
|
}
|
|
340
452
|
});
|
|
453
|
+
printPackageDiff(pkg) {
|
|
454
|
+
const c = this.color;
|
|
455
|
+
const count = pkg.added.length + pkg.modified.length + pkg.removed.length;
|
|
456
|
+
if (count === 0) {
|
|
457
|
+
process.stdout.write(`\n${c.set("CYAN", pkg.name)}: no changes\n`);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
process.stdout.write(`\n${c.set("CYAN", pkg.name)}: ${count} ${count === 1 ? "file differs" : "files differ"}\n`);
|
|
461
|
+
for (const file of pkg.added) process.stdout.write(` ${c.set("GREEN", "A")} ${file}\n`);
|
|
462
|
+
for (const fileDiff of pkg.modified) {
|
|
463
|
+
process.stdout.write(` ${c.set("ORANGE", "M")} ${fileDiff.file}\n`);
|
|
464
|
+
for (const change of fileDiff.changes) {
|
|
465
|
+
const prefix = change.type === "removed" ? "-" : "+";
|
|
466
|
+
const color = change.type === "removed" ? "RED" : "GREEN";
|
|
467
|
+
const lineNum = `L${change.line}`;
|
|
468
|
+
process.stdout.write(` ${c.set("DIM", lineNum.padEnd(5))} ${c.set(color, `${prefix} ${change.text}`)}\n`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
for (const file of pkg.removed) process.stdout.write(` ${c.set("RED", "D")} ${file}\n`);
|
|
472
|
+
}
|
|
341
473
|
vendor = $command({
|
|
342
474
|
name: "vendor",
|
|
343
475
|
description: "Vendor Alepha packages into the project",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Vendor configuration atom.\n *\n * Filled from the `vendor` section of `alepha.config.ts`.\n * Read by `VendorCommand` to resolve remote, branch, and packages.\n */\nexport const vendorOptions = $atom({\n name: \"alepha.cli.vendor.options\",\n description: \"Vendor synchronization configuration\",\n schema: t.optional(\n t.object({\n /**\n * Git remote URL.\n *\n * @default \"git@github.com:feunard/alepha.git\"\n */\n remote: t.optional(t.text()),\n\n /**\n * Branch to sync from.\n *\n * @default \"main\"\n */\n branch: t.optional(t.text()),\n\n /**\n * Package directory names under `packages/` to sync.\n *\n * @example [\"alepha\", \"@alepha/bucket-s3\"]\n */\n packages: t.array(t.text()),\n }),\n ),\n});\n\n/**\n * Type for vendor options.\n */\nexport type VendorOptions = Static<typeof vendorOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider, ShellProvider } from \"alepha/system\";\n\n/**\n * Options for syncing vendored packages from a remote repository.\n */\nexport interface VendorSyncOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n force?: boolean;\n}\n\n/**\n * Result of a vendor sync operation.\n */\nexport interface VendorSyncResult {\n synced: string[];\n errors: string[];\n aborted?: VendorDiffResult;\n}\n\n/**\n * Options for diffing vendored packages against a remote repository.\n */\nexport interface VendorDiffOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n}\n\n/**\n * Diff result for a single vendored package.\n */\nexport interface VendorPackageDiff {\n name: string;\n added: string[];\n modified: string[];\n removed: string[];\n}\n\n/**\n * Result of a vendor diff operation.\n */\nexport interface VendorDiffResult {\n packages: VendorPackageDiff[];\n totalChanges: number;\n}\n\n/**\n * Handles syncing and diffing vendored packages from a remote git repository.\n */\nexport class VendorService {\n protected readonly log = $logger();\n protected readonly shell = $inject(ShellProvider);\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Sync vendored packages from a remote repository.\n *\n * Shallow-clones the remote once, then:\n * - Without `force`: diffs first. If local modifications exist, aborts\n * and returns the diff result without touching local files.\n * - With `force` (or no changes): removes local copies and replaces them.\n */\n async sync(options: VendorSyncOptions): Promise<VendorSyncResult> {\n const synced: string[] = [];\n const errors: string[] = [];\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n\n if (!options.force) {\n const diffResult = await this.diffFromClone(\n options.root,\n tmpDir,\n options.packages,\n );\n if (diffResult.totalChanges > 0) {\n return { synced: [], errors: [], aborted: diffResult };\n }\n }\n\n for (const pkg of options.packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(options.root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n if (!remoteExists) {\n errors.push(`Package \"${pkg}\" not found in remote`);\n continue;\n }\n\n this.log.debug(`Syncing package: ${pkg}`);\n\n await this.fs.rm(localPkgDir, { recursive: true, force: true });\n await this.fs.cp(remotePkgDir, localPkgDir, { recursive: true });\n await this.removeIgnoredFiles(localPkgDir);\n\n synced.push(pkg);\n }\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n\n return { synced, errors };\n }\n\n /**\n * Diff vendored packages against a remote repository.\n *\n * Shallow-clones the remote, then for each package: recursively compares\n * files to identify added, modified, and removed files.\n */\n async diff(options: VendorDiffOptions): Promise<VendorDiffResult> {\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n return await this.diffFromClone(options.root, tmpDir, options.packages);\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n }\n\n /**\n * Diff local packages against an already-cloned remote.\n */\n protected async diffFromClone(\n root: string,\n tmpDir: string,\n packages: string[],\n ): Promise<VendorDiffResult> {\n const results: VendorPackageDiff[] = [];\n let totalChanges = 0;\n\n for (const pkg of packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n const localExists = await this.fs.exists(localPkgDir);\n\n if (!remoteExists && !localExists) {\n results.push({ name: pkg, added: [], modified: [], removed: [] });\n continue;\n }\n\n if (!remoteExists) {\n const localFiles = await this.fs.ls(localPkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: [],\n modified: [],\n removed: localFiles,\n });\n totalChanges += localFiles.length;\n continue;\n }\n\n if (!localExists) {\n const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: remoteFiles,\n modified: [],\n removed: [],\n });\n totalChanges += remoteFiles.length;\n continue;\n }\n\n const result = await this.diffDirectories(localPkgDir, remotePkgDir);\n const pkgChanges =\n result.added.length + result.modified.length + result.removed.length;\n totalChanges += pkgChanges;\n\n results.push({\n name: pkg,\n added: result.added,\n modified: result.modified,\n removed: result.removed,\n });\n }\n\n return { packages: results, totalChanges };\n }\n\n /**\n * Remove test files and ignored directories from a synced package.\n */\n protected async removeIgnoredFiles(pkgDir: string): Promise<void> {\n const allFiles = await this.fs.ls(pkgDir, { recursive: true });\n\n // Remove ignored files\n for (const file of allFiles) {\n if (\n file.endsWith(\".spec.ts\") ||\n file.endsWith(\".spec.tsx\") ||\n file === \"LICENSE\"\n ) {\n await this.fs.rm(this.fs.join(pkgDir, file), { force: true });\n }\n }\n\n // Remove ignored directories (find all occurrences at any depth)\n for (const file of allFiles) {\n for (const ignored of this.ignoredPaths) {\n if (\n file === ignored ||\n file.startsWith(`${ignored}/`) ||\n file.includes(`/${ignored}/`) ||\n file.endsWith(`/${ignored}`)\n ) {\n // Extract the path to the ignored directory itself\n const idx = file.indexOf(ignored);\n const dirPath = this.fs.join(\n pkgDir,\n file.substring(0, idx + ignored.length),\n );\n await this.fs.rm(dirPath, { recursive: true, force: true });\n }\n }\n }\n }\n\n /**\n * Clone a remote repository into a temporary directory.\n */\n protected async cloneRemote(remote: string, branch: string): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}#${branch} into ${tmpDir}`);\n\n const output = await this.shell.run(\n `git clone --depth 1 --branch ${branch} --filter=blob:none ${remote} ${tmpDir}`,\n { capture: true },\n );\n\n if (output) {\n this.log.debug(output);\n }\n\n return tmpDir;\n }\n\n /**\n * Directories to ignore during diff comparisons.\n */\n protected readonly ignoredPaths = [\n \"__tests__\",\n \"assets/swagger-ui\",\n \"node_modules\",\n \"dist\",\n ];\n\n /**\n * Check if a file path should be ignored during diff.\n */\n protected isIgnored(filePath: string): boolean {\n if (\n filePath.endsWith(\".spec.ts\") ||\n filePath.endsWith(\".spec.tsx\") ||\n filePath === \"LICENSE\"\n ) {\n return true;\n }\n return this.ignoredPaths.some(\n (p) =>\n filePath === p ||\n filePath.startsWith(`${p}/`) ||\n filePath.includes(`/${p}/`) ||\n filePath.endsWith(`/${p}`),\n );\n }\n\n /**\n * Recursively compare two directories and return the differences.\n */\n protected async diffDirectories(\n localDir: string,\n remoteDir: string,\n ): Promise<{ added: string[]; modified: string[]; removed: string[] }> {\n const added: string[] = [];\n const modified: string[] = [];\n const removed: string[] = [];\n\n const [localFiles, remoteFiles] = await Promise.all([\n this.fs.ls(localDir, { recursive: true }),\n this.fs.ls(remoteDir, { recursive: true }),\n ]);\n\n const filteredLocal = localFiles.filter((f) => !this.isIgnored(f));\n const filteredRemote = remoteFiles.filter((f) => !this.isIgnored(f));\n\n const localSet = new Set(filteredLocal);\n const remoteSet = new Set(filteredRemote);\n\n for (const file of filteredRemote) {\n if (!localSet.has(file)) {\n added.push(file);\n continue;\n }\n\n try {\n const [localContent, remoteContent] = await Promise.all([\n this.fs.readFile(this.fs.join(localDir, file)),\n this.fs.readFile(this.fs.join(remoteDir, file)),\n ]);\n\n if (!localContent.equals(remoteContent)) {\n modified.push(file);\n }\n } catch {\n // Skip directories and unreadable entries\n }\n }\n\n for (const file of filteredLocal) {\n if (!remoteSet.has(file)) {\n removed.push(file);\n }\n }\n\n return { added, modified, removed };\n }\n}\n","import { $inject, $state, AlephaError, t } from \"alepha\";\nimport { PackageManagerUtils } from \"alepha/cli\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { vendorOptions } from \"../atoms/vendorOptions.ts\";\nimport type {\n VendorDiffResult,\n VendorSyncResult,\n} from \"../services/VendorService.ts\";\nimport { VendorService } from \"../services/VendorService.ts\";\n\n/**\n * Default remote when none is configured.\n */\nconst DEFAULT_REMOTE = \"git@github.com:feunard/alepha.git\";\n\nexport class VendorCommand {\n protected readonly log = $logger();\n protected readonly options = $state(vendorOptions);\n protected readonly vendorService = $inject(VendorService);\n protected readonly color = $inject(ConsoleColorProvider);\n protected readonly pm = $inject(PackageManagerUtils);\n\n /**\n * Ensure vendor config is present and return resolved options.\n */\n protected resolveOptions() {\n if (!this.options) {\n throw new AlephaError(\n 'Missing vendor configuration. Add a \"vendor\" section to alepha.config.ts.',\n );\n }\n return {\n remote: this.options.remote ?? DEFAULT_REMOTE,\n branch: this.options.branch ?? \"main\",\n packages: this.options.packages,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor sync\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly syncFlags = t.object({\n force: t.optional(\n t.boolean({\n aliases: [\"f\"],\n description: \"Skip local modification check\",\n }),\n ),\n });\n\n protected readonly sync = $command({\n name: \"sync\",\n description: \"Replace local packages with remote source\",\n flags: this.syncFlags,\n handler: async ({ flags, root, run }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n let result: VendorSyncResult = { synced: [], errors: [] };\n\n await run({\n name: `Syncing from ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.sync({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n force: flags.force,\n });\n },\n });\n\n if (result.aborted) {\n run.end();\n\n process.stdout.write(\n `\\nLocal modifications detected. Use ${c.set(\"CYAN\", \"--force\")} to overwrite.\\n`,\n );\n\n for (const pkg of result.aborted.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) continue;\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n return;\n }\n\n if (result.synced.length > 0) {\n const pmName = await this.pm.getPackageManager(root);\n await run(`${pmName} install`, { root });\n }\n\n run.end();\n\n if (result.errors.length > 0) {\n for (const error of result.errors) {\n process.stdout.write(`${c.set(\"RED\", \" error\")} ${error}\\n`);\n }\n }\n\n if (result.synced.length > 0) {\n process.stdout.write(\n `\\nSynced ${c.set(\"CYAN\", String(result.synced.length))} ${result.synced.length === 1 ? \"package\" : \"packages\"} from ${c.set(\"CYAN\", opts.branch)}\\n`,\n );\n for (const pkg of result.synced) {\n process.stdout.write(` ${c.set(\"GREEN\", \"\\u2713\")} ${pkg}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor diff\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly diff = $command({\n name: \"diff\",\n description: \"Compare local packages against remote\",\n handler: async ({ root, run }) => {\n const opts = this.resolveOptions();\n\n let result: VendorDiffResult = { packages: [], totalChanges: 0 };\n\n await run({\n name: `Cloning ${opts.remote} at ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.diff({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n });\n },\n });\n\n run.end();\n\n if (result.totalChanges === 0) {\n process.stdout.write(\"\\nNo changes\\n\\n\");\n return;\n }\n\n const c = this.color;\n\n for (const pkg of result.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) {\n process.stdout.write(`\\n${c.set(\"CYAN\", pkg.name)}: no changes\\n`);\n continue;\n }\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // Parent command\n // ─────────────────────────────────────────────────────────────────────────\n\n public readonly vendor = $command({\n name: \"vendor\",\n description: \"Vendor Alepha packages into the project\",\n children: [this.sync, this.diff],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { cliConfigPlugins } from \"alepha/cli/config\";\nimport { type VendorOptions, vendorOptions } from \"./atoms/vendorOptions.ts\";\nimport { VendorCommand } from \"./commands/VendorCommand.ts\";\nimport { VendorService } from \"./services/VendorService.ts\";\n\n// ---------------------------------------------------------------------------\n\ndeclare module \"alepha/cli/config\" {\n interface AlephaCliConfig {\n vendor?: VendorOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for vendoring Alepha packages into external projects.\n *\n * Copies package source code from a git remote into the current project's\n * `packages/` directory. Useful for corporate projects that need a local\n * copy of Alepha for AI tooling, audits, documentation, or quick fixes.\n *\n * Commands:\n * - `alepha vendor sync` — replace local packages with remote source\n * - `alepha vendor diff` — compare local packages against remote HEAD\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { AlephaCliVendorPlugin } from \"alepha/cli/vendor\";\n *\n * export default defineConfig({\n * services: [AlephaCliVendorPlugin],\n * vendor: {\n * branch: \"main\",\n * packages: [\"alepha\", \"@alepha/bucket-s3\"],\n * },\n * });\n * ```\n */\nexport const AlephaCliVendorPlugin = $module({\n name: \"alepha.cli.plugins.vendor\",\n atoms: [vendorOptions],\n services: [VendorCommand, VendorService],\n});\n\n// ---------------------------------------------------------------------------\n\ncliConfigPlugins.push((config, alepha) => {\n if (config.vendor) {\n alepha.set(vendorOptions, config.vendor);\n }\n});\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/vendorOptions.ts\";\nexport * from \"./commands/VendorCommand.ts\";\nexport * from \"./services/VendorService.ts\";\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAa,gBAAgB,MAAM;CACjC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;EAMP,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;EAC5B,CAAC,CACH;CACF,CAAC;;;;;;ACoBF,IAAa,gBAAb,MAA2B;CACzB,MAAyB,SAAS;CAClC,QAA2B,QAAQ,cAAc;CACjD,KAAwB,QAAQ,mBAAmB;;;;;;;;;CAUnD,MAAM,KAAK,SAAuD;EAChE,MAAM,SAAmB,EAAE;EAC3B,MAAM,SAAmB,EAAE;EAC3B,IAAI;AAEJ,MAAI;AACF,YAAS,MAAM,KAAK,YAAY,QAAQ,QAAQ,QAAQ,OAAO;AAE/D,OAAI,CAAC,QAAQ,OAAO;IAClB,MAAM,aAAa,MAAM,KAAK,cAC5B,QAAQ,MACR,QACA,QAAQ,SACT;AACD,QAAI,WAAW,eAAe,EAC5B,QAAO;KAAE,QAAQ,EAAE;KAAE,QAAQ,EAAE;KAAE,SAAS;KAAY;;AAI1D,QAAK,MAAM,OAAO,QAAQ,UAAU;IAClC,MAAM,eAAe,KAA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,iBAAiB,eAAe,IACzF;AAED,SAAK,MAAM,QAAQ,IAAI,MACrB,SAAQ,OAAO,MAAM,KAAK,EAAE,IAAI,SAAS,IAAI,CAAC,GAAG,KAAK,IAAI;AAE5D,SAAK,MAAM,QAAQ,IAAI,SACrB,SAAQ,OAAO,MAAM,KAAK,EAAE,IAAI,UAAU,IAAI,CAAC,GAAG,KAAK,IAAI;AAE7D,SAAK,MAAM,QAAQ,IAAI,QACrB,SAAQ,OAAO,MAAM,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI;;AAI5D,WAAQ,OAAO,MAAM,KAAK;;EAE7B,CAAC;CAMF,SAAyB,SAAS;EAChC,MAAM;EACN,aAAa;EACb,UAAU,CAAC,KAAK,MAAM,KAAK,KAAK;EAChC,SAAS,OAAO,EAAE,WAAW;AAC3B,SAAM;;EAET,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjKJ,MAAa,wBAAwB,QAAQ;CAC3C,MAAM;CACN,OAAO,CAAC,cAAc;CACtB,UAAU,CAAC,eAAe,cAAc;CACzC,CAAC;AAIF,iBAAiB,MAAM,QAAQ,WAAW;AACxC,KAAI,OAAO,OACT,QAAO,IAAI,eAAe,OAAO,OAAO;EAE1C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Vendor configuration atom.\n *\n * Filled from the `vendor` section of `alepha.config.ts`.\n * Read by `VendorCommand` to resolve remote, branch, and packages.\n */\nexport const vendorOptions = $atom({\n name: \"alepha.cli.vendor.options\",\n description: \"Vendor synchronization configuration\",\n schema: t.optional(\n t.object({\n /**\n * Git remote URL.\n *\n * @default \"git@github.com:feunard/alepha.git\"\n */\n remote: t.optional(t.text()),\n\n /**\n * Branch to sync from.\n *\n * @default \"main\"\n */\n branch: t.optional(t.text()),\n\n /**\n * Package directory names under `packages/` to sync.\n *\n * @example [\"alepha\", \"@alepha/bucket-s3\"]\n */\n packages: t.array(t.text()),\n }),\n ),\n});\n\n/**\n * Type for vendor options.\n */\nexport type VendorOptions = Static<typeof vendorOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider, ShellProvider } from \"alepha/system\";\n\n/**\n * Options for syncing vendored packages from a remote repository.\n */\nexport interface VendorSyncOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n force?: boolean;\n}\n\n/**\n * Result of a vendor sync operation.\n */\nexport interface VendorSyncResult {\n synced: string[];\n errors: string[];\n aborted?: VendorDiffResult;\n}\n\n/**\n * Options for diffing vendored packages against a remote repository.\n */\nexport interface VendorDiffOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n}\n\n/**\n * A single line change within a modified file.\n */\nexport interface VendorLineDiff {\n line: number;\n type: \"added\" | \"removed\";\n text: string;\n}\n\n/**\n * A modified file with its line-level changes.\n */\nexport interface VendorFileDiff {\n file: string;\n changes: VendorLineDiff[];\n}\n\n/**\n * Diff result for a single vendored package.\n */\nexport interface VendorPackageDiff {\n name: string;\n added: string[];\n modified: VendorFileDiff[];\n removed: string[];\n}\n\n/**\n * Result of a vendor diff operation.\n */\nexport interface VendorDiffResult {\n packages: VendorPackageDiff[];\n totalChanges: number;\n}\n\n/**\n * Shape of the <root>/.alepha/vendor.json lock file.\n */\nexport interface VendorLock {\n commit: string;\n}\n\n/**\n * Handles syncing and diffing vendored packages from a remote git repository.\n */\nexport class VendorService {\n protected readonly log = $logger();\n protected readonly shell = $inject(ShellProvider);\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Sync vendored packages from a remote repository.\n *\n * Without `force`: checks for local modifications by comparing the local\n * copy against the last-synced commit (stored in .alepha/vendor.json).\n * If modifications are found, aborts without touching local files.\n *\n * With `force` (or first sync): replaces local copies unconditionally.\n */\n async sync(options: VendorSyncOptions): Promise<VendorSyncResult> {\n const synced: string[] = [];\n const errors: string[] = [];\n\n if (!options.force) {\n const lock = await this.readLock(options.root);\n\n if (lock) {\n let baselineDir: string | undefined;\n try {\n baselineDir = await this.cloneAtCommit(options.remote, lock.commit);\n const diffResult = await this.diffFromClone(\n options.root,\n baselineDir,\n options.packages,\n );\n\n if (diffResult.totalChanges > 0) {\n return { synced: [], errors: [], aborted: diffResult };\n }\n } finally {\n if (baselineDir) {\n await this.fs.rm(baselineDir, { recursive: true, force: true });\n }\n }\n }\n }\n\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n\n for (const pkg of options.packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(options.root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n if (!remoteExists) {\n errors.push(`Package \"${pkg}\" not found in remote`);\n continue;\n }\n\n this.log.debug(`Syncing package: ${pkg}`);\n\n await this.fs.rm(localPkgDir, { recursive: true, force: true });\n await this.fs.cp(remotePkgDir, localPkgDir, { recursive: true });\n await this.removeIgnoredFiles(localPkgDir);\n\n synced.push(pkg);\n }\n\n const commit = await this.getCommitHash(tmpDir);\n await this.writeLock(options.root, { commit });\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n\n return { synced, errors };\n }\n\n /**\n * Diff vendored packages against the last-synced commit.\n *\n * Reads the commit hash from .alepha/vendor.json, clones at that commit,\n * and compares local files to detect modifications since last sync.\n */\n async diff(options: VendorDiffOptions): Promise<VendorDiffResult> {\n const lock = await this.readLock(options.root);\n if (!lock) {\n return { packages: [], totalChanges: 0 };\n }\n\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneAtCommit(options.remote, lock.commit);\n return await this.diffFromClone(options.root, tmpDir, options.packages);\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n }\n\n /**\n * Diff local packages against an already-cloned remote.\n */\n protected async diffFromClone(\n root: string,\n tmpDir: string,\n packages: string[],\n ): Promise<VendorDiffResult> {\n const results: VendorPackageDiff[] = [];\n let totalChanges = 0;\n\n for (const pkg of packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n const localExists = await this.fs.exists(localPkgDir);\n\n if (!remoteExists && !localExists) {\n results.push({ name: pkg, added: [], modified: [], removed: [] });\n continue;\n }\n\n if (!remoteExists) {\n // No baseline = everything local was added by user\n const localFiles = await this.fs.ls(localPkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: localFiles,\n modified: [],\n removed: [],\n });\n totalChanges += localFiles.length;\n continue;\n }\n\n if (!localExists) {\n // Baseline exists but local doesn't = user deleted everything\n const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: [],\n modified: [],\n removed: remoteFiles,\n });\n totalChanges += remoteFiles.length;\n continue;\n }\n\n const result = await this.diffDirectories(localPkgDir, remotePkgDir);\n const pkgChanges =\n result.added.length + result.modified.length + result.removed.length;\n totalChanges += pkgChanges;\n\n results.push({\n name: pkg,\n added: result.added,\n modified: result.modified,\n removed: result.removed,\n });\n }\n\n return { packages: results, totalChanges };\n }\n\n /**\n * Remove test files and ignored directories from a synced package.\n */\n protected async removeIgnoredFiles(pkgDir: string): Promise<void> {\n const allFiles = await this.fs.ls(pkgDir, { recursive: true });\n\n // Remove ignored files\n for (const file of allFiles) {\n if (\n file.endsWith(\".spec.ts\") ||\n file.endsWith(\".spec.tsx\") ||\n file === \"LICENSE\" ||\n file === \"tsdown.config.ts\"\n ) {\n await this.fs.rm(this.fs.join(pkgDir, file), { force: true });\n }\n }\n\n // Remove ignored directories (find all occurrences at any depth)\n for (const file of allFiles) {\n for (const ignored of this.ignoredPaths) {\n if (\n file === ignored ||\n file.startsWith(`${ignored}/`) ||\n file.includes(`/${ignored}/`) ||\n file.endsWith(`/${ignored}`)\n ) {\n // Extract the path to the ignored directory itself\n const idx = file.indexOf(ignored);\n const dirPath = this.fs.join(\n pkgDir,\n file.substring(0, idx + ignored.length),\n );\n await this.fs.rm(dirPath, { recursive: true, force: true });\n }\n }\n }\n }\n\n /**\n * Clone a remote repository into a temporary directory.\n */\n protected async cloneRemote(remote: string, branch: string): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}#${branch} into ${tmpDir}`);\n\n const output = await this.shell.run(\n `git clone --depth 1 --branch ${branch} --filter=blob:none ${remote} ${tmpDir}`,\n { capture: true },\n );\n\n if (output) {\n this.log.debug(output);\n }\n\n return tmpDir;\n }\n\n /**\n * Clone a remote repository at a specific commit hash.\n */\n protected async cloneAtCommit(\n remote: string,\n commit: string,\n ): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}@${commit} into ${tmpDir}`);\n\n await this.shell.run(`git init ${tmpDir}`, { capture: true });\n await this.shell.run(`git -C ${tmpDir} remote add origin ${remote}`, {\n capture: true,\n });\n await this.shell.run(`git -C ${tmpDir} fetch --depth 1 origin ${commit}`, {\n capture: true,\n });\n await this.shell.run(`git -C ${tmpDir} checkout FETCH_HEAD`, {\n capture: true,\n });\n\n return tmpDir;\n }\n\n /**\n * Get the HEAD commit hash from a cloned repository.\n */\n protected async getCommitHash(repoDir: string): Promise<string> {\n const hash = await this.shell.run(`git -C ${repoDir} rev-parse HEAD`, {\n capture: true,\n });\n return hash.trim();\n }\n\n /**\n * Read the vendor lock file.\n */\n protected async readLock(root: string): Promise<VendorLock | undefined> {\n const lockPath = this.fs.join(root, \".alepha\", \"vendor.json\");\n const exists = await this.fs.exists(lockPath);\n if (!exists) {\n return undefined;\n }\n const content = await this.fs.readFile(lockPath);\n return JSON.parse(content.toString());\n }\n\n /**\n * Write the vendor lock file.\n */\n protected async writeLock(root: string, lock: VendorLock): Promise<void> {\n const dir = this.fs.join(root, \".alepha\");\n await this.fs.mkdir(dir, { recursive: true });\n await this.fs.writeFile(\n this.fs.join(dir, \"vendor.json\"),\n JSON.stringify(lock, null, 2),\n );\n }\n\n /**\n * Directories to ignore during diff comparisons.\n */\n protected readonly ignoredPaths = [\n \"__tests__\",\n \"assets/swagger-ui\",\n \"node_modules\",\n \"dist\",\n ];\n\n /**\n * Check if a file path should be ignored during diff.\n */\n protected isIgnored(filePath: string): boolean {\n if (\n filePath.endsWith(\".spec.ts\") ||\n filePath.endsWith(\".spec.tsx\") ||\n filePath === \"LICENSE\" ||\n filePath === \"tsdown.config.ts\"\n ) {\n return true;\n }\n return this.ignoredPaths.some(\n (p) =>\n filePath === p ||\n filePath.startsWith(`${p}/`) ||\n filePath.includes(`/${p}/`) ||\n filePath.endsWith(`/${p}`),\n );\n }\n\n /**\n * Recursively compare two directories and return the differences.\n */\n protected async diffDirectories(\n localDir: string,\n remoteDir: string,\n ): Promise<{\n added: string[];\n modified: VendorFileDiff[];\n removed: string[];\n }> {\n const added: string[] = [];\n const modified: VendorFileDiff[] = [];\n const removed: string[] = [];\n\n const [localFiles, remoteFiles] = await Promise.all([\n this.fs.ls(localDir, { recursive: true }),\n this.fs.ls(remoteDir, { recursive: true }),\n ]);\n\n const filteredLocal = localFiles.filter((f) => !this.isIgnored(f));\n const filteredRemote = remoteFiles.filter((f) => !this.isIgnored(f));\n\n const localSet = new Set(filteredLocal);\n const remoteSet = new Set(filteredRemote);\n\n // Files in baseline but not local = user deleted them\n for (const file of filteredRemote) {\n if (!localSet.has(file)) {\n removed.push(file);\n continue;\n }\n\n try {\n const [localContent, remoteContent] = await Promise.all([\n this.fs.readFile(this.fs.join(localDir, file)),\n this.fs.readFile(this.fs.join(remoteDir, file)),\n ]);\n\n if (!localContent.equals(remoteContent)) {\n const changes = this.computeLineDiff(\n remoteContent.toString(),\n localContent.toString(),\n );\n modified.push({ file, changes });\n }\n } catch {\n // Skip directories and unreadable entries\n }\n }\n\n // Files in local but not baseline = user added them\n for (const file of filteredLocal) {\n if (!remoteSet.has(file)) {\n added.push(file);\n }\n }\n\n return { added, modified, removed };\n }\n\n /**\n * Compute line-level differences between two file contents.\n *\n * Uses a longest-common-subsequence algorithm to produce minimal\n * added/removed line changes with accurate line numbers.\n */\n protected computeLineDiff(baseline: string, local: string): VendorLineDiff[] {\n const baseLines = baseline.split(\"\\n\");\n const localLines = local.split(\"\\n\");\n const lcs = this.longestCommonSubsequence(baseLines, localLines);\n const changes: VendorLineDiff[] = [];\n\n let bi = 0;\n let li = 0;\n let ci = 0;\n\n while (bi < baseLines.length || li < localLines.length) {\n if (ci < lcs.length && bi < baseLines.length && li < localLines.length) {\n if (baseLines[bi] === lcs[ci] && localLines[li] === lcs[ci]) {\n // Line is unchanged\n bi++;\n li++;\n ci++;\n } else if (baseLines[bi] !== lcs[ci]) {\n changes.push({ line: bi + 1, type: \"removed\", text: baseLines[bi] });\n bi++;\n } else {\n changes.push({ line: li + 1, type: \"added\", text: localLines[li] });\n li++;\n }\n } else if (bi < baseLines.length) {\n changes.push({ line: bi + 1, type: \"removed\", text: baseLines[bi] });\n bi++;\n } else {\n changes.push({ line: li + 1, type: \"added\", text: localLines[li] });\n li++;\n }\n }\n\n return changes;\n }\n\n /**\n * Compute the longest common subsequence of two string arrays.\n */\n protected longestCommonSubsequence(a: string[], b: string[]): string[] {\n const m = a.length;\n const n = b.length;\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n Array(n + 1).fill(0),\n );\n\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n dp[i][j] =\n a[i - 1] === b[j - 1]\n ? dp[i - 1][j - 1] + 1\n : Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n\n const result: string[] = [];\n let i = m;\n let j = n;\n while (i > 0 && j > 0) {\n if (a[i - 1] === b[j - 1]) {\n result.unshift(a[i - 1]);\n i--;\n j--;\n } else if (dp[i - 1][j] > dp[i][j - 1]) {\n i--;\n } else {\n j--;\n }\n }\n\n return result;\n }\n}\n","import { $inject, $state, AlephaError, t } from \"alepha\";\nimport { PackageManagerUtils } from \"alepha/cli\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { vendorOptions } from \"../atoms/vendorOptions.ts\";\nimport type {\n VendorDiffResult,\n VendorPackageDiff,\n VendorSyncResult,\n} from \"../services/VendorService.ts\";\nimport { VendorService } from \"../services/VendorService.ts\";\n\n/**\n * Default remote when none is configured.\n */\nconst DEFAULT_REMOTE = \"git@github.com:feunard/alepha.git\";\n\nexport class VendorCommand {\n protected readonly log = $logger();\n protected readonly options = $state(vendorOptions);\n protected readonly vendorService = $inject(VendorService);\n protected readonly color = $inject(ConsoleColorProvider);\n protected readonly pm = $inject(PackageManagerUtils);\n\n /**\n * Ensure vendor config is present and return resolved options.\n */\n protected resolveOptions() {\n if (!this.options) {\n throw new AlephaError(\n 'Missing vendor configuration. Add a \"vendor\" section to alepha.config.ts.',\n );\n }\n return {\n remote: this.options.remote ?? DEFAULT_REMOTE,\n branch: this.options.branch ?? \"main\",\n packages: this.options.packages,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor sync\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly syncFlags = t.object({\n force: t.optional(\n t.boolean({\n aliases: [\"f\"],\n description: \"Skip local modification check\",\n }),\n ),\n });\n\n protected readonly sync = $command({\n name: \"sync\",\n description: \"Replace local packages with remote source\",\n flags: this.syncFlags,\n handler: async ({ flags, root, run }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n let result: VendorSyncResult = { synced: [], errors: [] };\n\n await run({\n name: `Syncing from ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.sync({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n force: flags.force,\n });\n },\n });\n\n if (result.aborted) {\n run.end();\n\n process.stdout.write(\n `\\nLocal modifications detected. Use ${c.set(\"CYAN\", \"--force\")} to overwrite.\\n`,\n );\n\n for (const pkg of result.aborted.packages) {\n this.printPackageDiff(pkg);\n }\n\n process.stdout.write(\"\\n\");\n return;\n }\n\n if (result.synced.length > 0) {\n const pmName = await this.pm.getPackageManager(root);\n await run(`${pmName} install`, { root });\n }\n\n run.end();\n\n if (result.errors.length > 0) {\n for (const error of result.errors) {\n process.stdout.write(`${c.set(\"RED\", \" error\")} ${error}\\n`);\n }\n }\n\n if (result.synced.length > 0) {\n process.stdout.write(\n `\\nSynced ${c.set(\"CYAN\", String(result.synced.length))} ${result.synced.length === 1 ? \"package\" : \"packages\"} from ${c.set(\"CYAN\", opts.branch)}\\n`,\n );\n for (const pkg of result.synced) {\n process.stdout.write(` ${c.set(\"GREEN\", \"\\u2713\")} ${pkg}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor diff\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly diff = $command({\n name: \"diff\",\n description: \"Compare local packages against remote\",\n handler: async ({ root, run }) => {\n const opts = this.resolveOptions();\n\n let result: VendorDiffResult = { packages: [], totalChanges: 0 };\n\n await run({\n name: `Cloning ${opts.remote} at ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.diff({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n });\n },\n });\n\n run.end();\n\n if (result.totalChanges === 0) {\n process.stdout.write(\"\\nNo changes\\n\\n\");\n return;\n }\n\n for (const pkg of result.packages) {\n this.printPackageDiff(pkg);\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // Helpers\n // ─────────────────────────────────────────────────────────────────────────\n\n protected printPackageDiff(pkg: VendorPackageDiff) {\n const c = this.color;\n const count = pkg.added.length + pkg.modified.length + pkg.removed.length;\n\n if (count === 0) {\n process.stdout.write(`\\n${c.set(\"CYAN\", pkg.name)}: no changes\\n`);\n return;\n }\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n\n for (const fileDiff of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${fileDiff.file}\\n`);\n for (const change of fileDiff.changes) {\n const prefix = change.type === \"removed\" ? \"-\" : \"+\";\n const color = change.type === \"removed\" ? \"RED\" : \"GREEN\";\n const lineNum = `L${change.line}`;\n process.stdout.write(\n ` ${c.set(\"DIM\", lineNum.padEnd(5))} ${c.set(color, `${prefix} ${change.text}`)}\\n`,\n );\n }\n }\n\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Parent command\n // ─────────────────────────────────────────────────────────────────────────\n\n public readonly vendor = $command({\n name: \"vendor\",\n description: \"Vendor Alepha packages into the project\",\n children: [this.sync, this.diff],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { cliConfigPlugins } from \"alepha/cli/config\";\nimport { type VendorOptions, vendorOptions } from \"./atoms/vendorOptions.ts\";\nimport { VendorCommand } from \"./commands/VendorCommand.ts\";\nimport { VendorService } from \"./services/VendorService.ts\";\n\n// ---------------------------------------------------------------------------\n\ndeclare module \"alepha/cli/config\" {\n interface AlephaCliConfig {\n vendor?: VendorOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for vendoring Alepha packages into external projects.\n *\n * Copies package source code from a git remote into the current project's\n * `packages/` directory. Useful for corporate projects that need a local\n * copy of Alepha for AI tooling, audits, documentation, or quick fixes.\n *\n * Commands:\n * - `alepha vendor sync` — replace local packages with remote source\n * - `alepha vendor diff` — compare local packages against remote HEAD\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { AlephaCliVendorPlugin } from \"alepha/cli/vendor\";\n *\n * export default defineConfig({\n * services: [AlephaCliVendorPlugin],\n * vendor: {\n * branch: \"main\",\n * packages: [\"alepha\", \"@alepha/bucket-s3\"],\n * },\n * });\n * ```\n */\nexport const AlephaCliVendorPlugin = $module({\n name: \"alepha.cli.plugins.vendor\",\n atoms: [vendorOptions],\n services: [VendorCommand, VendorService],\n});\n\n// ---------------------------------------------------------------------------\n\ncliConfigPlugins.push((config, alepha) => {\n if (config.vendor) {\n alepha.set(vendorOptions, config.vendor);\n }\n});\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/vendorOptions.ts\";\nexport * from \"./commands/VendorCommand.ts\";\nexport * from \"./services/VendorService.ts\";\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAa,gBAAgB,MAAM;CACjC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;EAMP,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;EAC5B,CAAC,CACH;CACF,CAAC;;;;;;AC4CF,IAAa,gBAAb,MAA2B;CACzB,MAAyB,SAAS;CAClC,QAA2B,QAAQ,cAAc;CACjD,KAAwB,QAAQ,mBAAmB;;;;;;;;;;CAWnD,MAAM,KAAK,SAAuD;EAChE,MAAM,SAAmB,EAAE;EAC3B,MAAM,SAAmB,EAAE;AAE3B,MAAI,CAAC,QAAQ,OAAO;GAClB,MAAM,OAAO,MAAM,KAAK,SAAS,QAAQ,KAAK;AAE9C,OAAI,MAAM;IACR,IAAI;AACJ,QAAI;AACF,mBAAc,MAAM,KAAK,cAAc,QAAQ,QAAQ,KAAK,OAAO;KACnE,MAAM,aAAa,MAAM,KAAK,cAC5B,QAAQ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