create-windy 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +258 -121
- package/package.json +1 -1
- package/template/.windy-template.json +2 -2
- package/template/apps/agent-server/adk_web_agents/canonical_debug/agent.py +29 -9
- package/template/apps/agent-server/adk_web_agents/services.py +25 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +40 -11
- package/template/apps/agent-server/src/southwind_agent_server/adk_debug_sessions.py +325 -0
- package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +70 -6
- package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +1 -1
- package/template/apps/agent-server/src/southwind_agent_server/app.py +16 -4
- package/template/apps/agent-server/src/southwind_agent_server/approval_resolution.py +30 -0
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +9 -0
- package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +2 -1
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +3 -1
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +95 -130
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine_validation.py +133 -0
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +89 -20
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_insert.py +34 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_queries.py +234 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_replay.py +44 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_status.py +83 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_store.py +331 -0
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_summary.py +304 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_lifecycle.py +217 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_metrics.py +149 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_presenter.py +280 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_routes.py +126 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_store.py +344 -0
- package/template/apps/agent-server/src/southwind_agent_server/report_types.py +111 -0
- package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +31 -2
- package/template/apps/agent-server/src/southwind_agent_server/service.py +56 -51
- package/template/apps/agent-server/src/southwind_agent_server/signal_events.py +18 -1
- package/template/apps/agent-server/tests/test_adk_adapter.py +7 -9
- package/template/apps/agent-server/tests/test_adk_debug_sessions.py +215 -0
- package/template/apps/agent-server/tests/test_adk_web_canonical_debug.py +48 -1
- package/template/apps/agent-server/tests/test_openai_provider.py +58 -6
- package/template/apps/agent-server/tests/test_postgres_report_status.py +59 -0
- package/template/apps/agent-server/tests/test_postgres_report_summary.py +298 -0
- package/template/apps/agent-server/tests/test_provider_attempt_reporting.py +152 -0
- package/template/apps/agent-server/tests/test_report_attempt_lifecycle.py +126 -0
- package/template/apps/agent-server/tests/test_report_resilience.py +181 -0
- package/template/apps/agent-server/tests/test_report_store.py +286 -0
- package/template/apps/agent-server/tests/test_report_summary_parity.py +115 -0
- package/template/apps/agent-server/tests/test_report_terminal_sync.py +177 -0
- package/template/apps/server/src/agent/debug-session-facade-provider-failure.test.ts +269 -0
- package/template/apps/server/src/agent/debug-session-facade.test.ts +335 -0
- package/template/apps/server/src/agent/debug-session-facade.ts +302 -0
- package/template/apps/server/src/agent/debug-session-id.test.ts +37 -0
- package/template/apps/server/src/agent/debug-session-id.ts +37 -0
- package/template/apps/server/src/agent/debug-session-provider-reader.ts +54 -0
- package/template/apps/server/src/agent/debug-session-routes.test.ts +64 -0
- package/template/apps/server/src/agent/debug-session-routes.ts +73 -0
- package/template/apps/server/src/agent/debug-session-validation.ts +106 -0
- package/template/apps/server/src/agent/drizzle-run-binding-repository.ts +2 -0
- package/template/apps/server/src/agent/provider-input-governance.test.ts +18 -0
- package/template/apps/server/src/agent/provider-input-governance.ts +37 -1
- package/template/apps/server/src/agent/remote-runtime.test.ts +7 -0
- package/template/apps/server/src/agent/remote-runtime.ts +1 -0
- package/template/apps/server/src/agent/run-authorization.test.ts +98 -0
- package/template/apps/server/src/agent/run-authorization.ts +32 -1
- package/template/apps/server/src/agent/run-binding-repository.ts +1 -0
- package/template/apps/server/src/agent/run-contracts.ts +5 -0
- package/template/apps/server/src/agent/run-facade-adk-debug.test.ts +39 -0
- package/template/apps/server/src/agent/run-facade.test.ts +78 -0
- package/template/apps/server/src/agent/run-facade.ts +33 -3
- package/template/apps/server/src/agent/run-input-commitment.ts +50 -0
- package/template/apps/server/src/agent/run-input-verification.ts +41 -0
- package/template/apps/server/src/agent/runtime-bootstrap-report.test.ts +136 -0
- package/template/apps/server/src/agent/runtime-bootstrap.ts +66 -1
- package/template/apps/server/src/agent/tool-host.test.ts +1 -0
- package/template/apps/server/src/agent/unavailable-routes.ts +4 -0
- package/template/apps/server/src/ai-runtime-report/actor-directory.ts +94 -0
- package/template/apps/server/src/ai-runtime-report/actor-handle.test.ts +27 -0
- package/template/apps/server/src/ai-runtime-report/actor-handle.ts +81 -0
- package/template/apps/server/src/ai-runtime-report/contracts.ts +91 -0
- package/template/apps/server/src/ai-runtime-report/remote-parser.ts +212 -0
- package/template/apps/server/src/ai-runtime-report/remote-port.ts +138 -0
- package/template/apps/server/src/ai-runtime-report/routes.ts +172 -0
- package/template/apps/server/src/ai-runtime-report/scope.ts +63 -0
- package/template/apps/server/src/ai-runtime-report/service.test.ts +271 -0
- package/template/apps/server/src/ai-runtime-report/service.ts +206 -0
- package/template/apps/server/src/license/runtime-audit-reliability.test.ts +2 -0
- package/template/apps/server/src/license/runtime-service.test.ts +6 -0
- package/template/apps/server/src/module-host/ai-operation-port.test.ts +63 -0
- package/template/apps/server/src/module-host/ai-operation-port.ts +30 -5
- package/template/apps/server/src/module-host/debug-session-provider-registration.test.ts +162 -0
- package/template/apps/server/src/module-host/debug-session-provider-registration.ts +84 -0
- package/template/apps/server/src/module-host/initialize-contracts.ts +7 -0
- package/template/apps/server/src/module-host/initialize.ts +6 -197
- package/template/apps/server/src/module-host/request-context.ts +1 -0
- package/template/apps/server/src/module-host/scoped-host.ts +214 -0
- package/template/apps/server/src/module-host.ts +1 -0
- package/template/apps/server/src/runtime-adk-debug.test.ts +25 -1
- package/template/apps/server/src/runtime-adk-debug.ts +8 -2
- package/template/apps/server/src/system/operations.test.ts +54 -0
- package/template/apps/server/src/system/operations.ts +23 -1
- package/template/apps/server/src/system/seed.test.ts +4 -0
- package/template/apps/server/src/system/system-resource-monitoring.test.ts +82 -0
- package/template/apps/server/src/system/system-resource-monitoring.ts +300 -0
- package/template/apps/web/src/layout/AppSidebar.vue +6 -1
- package/template/apps/web/src/layout/AppSidebar.webtest.ts +2 -0
- package/template/apps/web/src/pages/auth/LoginPage.vue +6 -1
- package/template/apps/web/src/pages/settings/BrandingSettingsSection.vue +20 -3
- package/template/apps/web/src/pages/settings/BrandingSettingsSection.webtest.ts +80 -0
- package/template/apps/web/src/pages/system/AiRuntimePage.vue +129 -0
- package/template/apps/web/src/pages/system/SystemOperationsPage.vue +2 -1
- package/template/apps/web/src/pages/system/ai-runtime-presenter.ts +60 -0
- package/template/apps/web/src/pages/system/ai-runtime-presenter.webtest.ts +48 -0
- package/template/apps/web/src/pages/system/audit-time-range.ts +34 -2
- package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +4 -3
- package/template/apps/web/src/pages/system/components/AuditLogFilters.webtest.ts +26 -1
- package/template/apps/web/src/pages/system/components/OperationGpuMonitor.vue +98 -0
- package/template/apps/web/src/pages/system/components/OperationGpuMonitor.webtest.ts +61 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.vue +53 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.webtest.ts +20 -1
- package/template/apps/web/src/pages/system/components/SystemResourcePage.webtest.ts +14 -1
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeActivityChart.vue +85 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeCharts.webtest.ts +82 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeFilters.vue +98 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeFilters.webtest.ts +27 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunDetailDialog.vue +168 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeRunTable.vue +130 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeSummaryCards.vue +82 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeSummaryCards.webtest.ts +102 -0
- package/template/apps/web/src/pages/system/components/ai-runtime/AiRuntimeTokenByModelChart.vue +101 -0
- package/template/apps/web/src/pages/system/composables/useAiRuntimeReport.ts +185 -0
- package/template/apps/web/src/pages/system/composables/useAiRuntimeReport.webtest.ts +158 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.ts +21 -7
- package/template/apps/web/src/router/error-navigation.ts +22 -0
- package/template/apps/web/src/router/index.ts +12 -23
- package/template/apps/web/src/router/platform-admin-route-bindings.ts +4 -0
- package/template/apps/web/src/services/ai-runtime-api.ts +164 -0
- package/template/apps/web/src/services/ai-runtime-api.webtest.ts +111 -0
- package/template/apps/web/src/services/operations-api.ts +28 -0
- package/template/docker-compose.agent-debug.yml +1 -1
- package/template/docs/architecture/ai-runtime.md +2 -1
- package/template/docs/architecture/module-host.md +3 -0
- package/template/docs/platform/agent-run-attestation.md +65 -0
- package/template/docs/platform/agent-runtime-observability.md +135 -0
- package/template/docs/platform/agent-runtime.md +47 -3
- package/template/docs/platform/operations-overview.md +13 -0
- package/template/docs/platform/platform-authentication.md +4 -3
- package/template/packages/config/package.json +1 -1
- package/template/packages/database/drizzle/0045_tiny_cassandra_nova.sql +65 -0
- package/template/packages/database/drizzle/0046_tranquil_living_mummy.sql +6 -0
- package/template/packages/database/drizzle/0047_oval_luke_cage.sql +18 -0
- package/template/packages/database/drizzle/meta/0045_snapshot.json +8814 -0
- package/template/packages/database/drizzle/meta/0046_snapshot.json +8820 -0
- package/template/packages/database/drizzle/meta/0047_snapshot.json +8835 -0
- package/template/packages/database/drizzle/meta/_journal.json +21 -0
- package/template/packages/database/package.json +1 -1
- package/template/packages/database/src/agent-runtime-schema.test.ts +54 -0
- package/template/packages/database/src/schema/agent-runtime.ts +114 -0
- package/template/packages/jobs/package.json +1 -1
- package/template/packages/modules/package.json +1 -1
- package/template/packages/modules/src/system-admin-routes.ts +10 -0
- package/template/packages/modules/src/system-admin-ui-catalog.ts +1 -1
- package/template/packages/modules/src/system-api-control-plane.ts +17 -1
- package/template/packages/modules/src/system-audit-actions.ts +10 -0
- package/template/packages/modules/src/system-features.ts +8 -0
- package/template/packages/modules/src/system-module-catalog.test.ts +35 -0
- package/template/packages/modules/src/system-module-catalog.ts +15 -4
- package/template/packages/modules/src/system-modules-access.test.ts +69 -0
- package/template/packages/modules/src/system-modules.ts +13 -0
- package/template/packages/modules/src/system-permissions.ts +2 -0
- package/template/packages/server-sdk/index.ts +11 -0
- package/template/packages/server-sdk/package.json +2 -1
- package/template/packages/server-sdk/src/ai-operation-port.ts +5 -0
- package/template/packages/server-sdk/src/debug-session-provider.ts +63 -0
- package/template/packages/server-sdk/src/module-host.ts +5 -0
- package/template/packages/shared/index.ts +3 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/ai-runtime-report.ts +134 -0
- package/template/scripts/lib/postgres-regression.ts +201 -0
package/dist/cli.js
CHANGED
|
@@ -286,6 +286,7 @@ var optionalModuleManifests = [
|
|
|
286
286
|
"apps/speech-server",
|
|
287
287
|
"apps/embedding-server",
|
|
288
288
|
"apps/server/src/agent",
|
|
289
|
+
"apps/server/src/ai-runtime-report",
|
|
289
290
|
"apps/server/src/ai-artifact",
|
|
290
291
|
"apps/server/src/document",
|
|
291
292
|
"apps/server/src/speech",
|
|
@@ -293,17 +294,30 @@ var optionalModuleManifests = [
|
|
|
293
294
|
"apps/server/src/mcp",
|
|
294
295
|
"apps/server/src/runtime-adk-debug.ts",
|
|
295
296
|
"apps/server/src/runtime-adk-debug.test.ts",
|
|
297
|
+
"apps/server/src/module-host/ai-operation-port.ts",
|
|
298
|
+
"apps/server/src/module-host/ai-operation-port.test.ts",
|
|
296
299
|
"apps/server/src/module-host/tool-handlers.ts",
|
|
297
300
|
"apps/server/src/module-host/tool-handlers.test.ts",
|
|
301
|
+
"apps/web/src/pages/system/AiRuntimePage.vue",
|
|
302
|
+
"apps/web/src/pages/system/ai-runtime-presenter.ts",
|
|
303
|
+
"apps/web/src/pages/system/ai-runtime-presenter.webtest.ts",
|
|
304
|
+
"apps/web/src/pages/system/components/ai-runtime",
|
|
305
|
+
"apps/web/src/pages/system/composables/useAiRuntimeReport.ts",
|
|
306
|
+
"apps/web/src/pages/system/composables/useAiRuntimeReport.webtest.ts",
|
|
307
|
+
"apps/web/src/services/ai-runtime-api.ts",
|
|
308
|
+
"apps/web/src/services/ai-runtime-api.webtest.ts",
|
|
298
309
|
"docker-compose.agent-debug.yml",
|
|
299
310
|
"scripts/dev-adk-web.ts",
|
|
300
311
|
"packages/modules/src/system-agent-tools.ts",
|
|
301
|
-
"packages/database/src/agent-runtime-schema.test.ts"
|
|
312
|
+
"packages/database/src/agent-runtime-schema.test.ts",
|
|
313
|
+
"packages/shared/src/ai-runtime-report.ts"
|
|
302
314
|
],
|
|
303
315
|
documentation: [
|
|
304
316
|
"docs/architecture/ai-runtime.md",
|
|
305
317
|
"docs/architecture/mcp-business-capabilities.md",
|
|
318
|
+
"docs/platform/agent-run-attestation.md",
|
|
306
319
|
"docs/platform/agent-runtime.md",
|
|
320
|
+
"docs/platform/agent-runtime-observability.md",
|
|
307
321
|
"docs/platform/agent-tools.md",
|
|
308
322
|
"docs/platform/agent-tool-approval.md",
|
|
309
323
|
"docs/platform/agent-tool-sandbox.md",
|
|
@@ -320,7 +334,9 @@ var optionalModuleManifests = [
|
|
|
320
334
|
"agent_runtime_runs",
|
|
321
335
|
"agent_runtime_events",
|
|
322
336
|
"agent_evaluation_results",
|
|
323
|
-
"agent_run_bindings"
|
|
337
|
+
"agent_run_bindings",
|
|
338
|
+
"agent_runtime_report_runs",
|
|
339
|
+
"agent_runtime_report_attempts"
|
|
324
340
|
]
|
|
325
341
|
},
|
|
326
342
|
{
|
|
@@ -400,6 +416,7 @@ var optionalModuleManifests = [
|
|
|
400
416
|
"apps/web/src/pages/system/composables/useNotificationPermissions.ts",
|
|
401
417
|
"apps/web/src/services/notification-api.webtest.ts",
|
|
402
418
|
"scripts/notification-postgres-regression.ts",
|
|
419
|
+
"scripts/lib/postgres-regression.ts",
|
|
403
420
|
"packages/database/src/schema-notification-delivery.test.ts"
|
|
404
421
|
],
|
|
405
422
|
documentation: ["docs/platform/notifications.md"],
|
|
@@ -520,7 +537,7 @@ function module(name, label, description, dependencies) {
|
|
|
520
537
|
return {
|
|
521
538
|
name,
|
|
522
539
|
version: "0.1.0",
|
|
523
|
-
windyRange: "^0.
|
|
540
|
+
windyRange: "^0.5.0",
|
|
524
541
|
label,
|
|
525
542
|
description,
|
|
526
543
|
selection,
|
|
@@ -679,10 +696,14 @@ var platformModules = [
|
|
|
679
696
|
"apps/server/src/system/operations.ts",
|
|
680
697
|
"apps/server/src/system/operations.test.ts",
|
|
681
698
|
"apps/server/src/system/postgres-monitoring.ts",
|
|
699
|
+
"apps/server/src/system/system-resource-monitoring.ts",
|
|
700
|
+
"apps/server/src/system/system-resource-monitoring.test.ts",
|
|
682
701
|
"apps/web/src/pages/system/SystemOperationsPage.vue",
|
|
683
702
|
"apps/web/src/pages/system/SystemOperationsPage.webtest.ts",
|
|
684
703
|
"apps/web/src/pages/system/components/OperationCacheMonitor.vue",
|
|
685
704
|
"apps/web/src/pages/system/components/DiskUsageChart.vue",
|
|
705
|
+
"apps/web/src/pages/system/components/OperationGpuMonitor.vue",
|
|
706
|
+
"apps/web/src/pages/system/components/OperationGpuMonitor.webtest.ts",
|
|
686
707
|
"apps/web/src/pages/system/components/OperationOnlineUsers.vue",
|
|
687
708
|
"apps/web/src/pages/system/components/OperationOnlineUsers.webtest.ts",
|
|
688
709
|
"apps/web/src/pages/system/components/OperationServiceMonitor.vue",
|
|
@@ -748,7 +769,7 @@ function module2(name, label, description, selection, dependencies = []) {
|
|
|
748
769
|
return {
|
|
749
770
|
name,
|
|
750
771
|
version: "0.1.0",
|
|
751
|
-
windyRange: "^0.
|
|
772
|
+
windyRange: "^0.5.0",
|
|
752
773
|
label,
|
|
753
774
|
description,
|
|
754
775
|
selection,
|
|
@@ -3445,6 +3466,7 @@ var templateRootFiles = [
|
|
|
3445
3466
|
"module-schema.lineages.json",
|
|
3446
3467
|
"package.json",
|
|
3447
3468
|
"scripts/notification-postgres-regression.ts",
|
|
3469
|
+
"scripts/lib/postgres-regression.ts",
|
|
3448
3470
|
"scripts/dev-adk-web.ts"
|
|
3449
3471
|
];
|
|
3450
3472
|
var templateDirectories = [
|
|
@@ -3491,8 +3513,10 @@ var templateDocumentationFiles = [
|
|
|
3491
3513
|
"docs/development/module-lifecycle.md",
|
|
3492
3514
|
"docs/license/license-offline-activation-code.md",
|
|
3493
3515
|
"docs/operations/observability.md",
|
|
3516
|
+
"docs/platform/agent-run-attestation.md",
|
|
3494
3517
|
"docs/platform/agent-tools.md",
|
|
3495
3518
|
"docs/platform/agent-runtime.md",
|
|
3519
|
+
"docs/platform/agent-runtime-observability.md",
|
|
3496
3520
|
"docs/platform/agent-tool-sandbox.md",
|
|
3497
3521
|
"docs/platform/audit-reliability.md",
|
|
3498
3522
|
"docs/platform/bulk-data-jobs.md",
|
|
@@ -7529,6 +7553,11 @@ var recipes = [
|
|
|
7529
7553
|
id: "starter-0.4.0-to-0.4.1",
|
|
7530
7554
|
from: "0.4.0",
|
|
7531
7555
|
to: "0.4.1"
|
|
7556
|
+
},
|
|
7557
|
+
{
|
|
7558
|
+
id: "starter-0.4.1-to-0.5.0",
|
|
7559
|
+
from: "0.4.1",
|
|
7560
|
+
to: "0.5.0"
|
|
7532
7561
|
}
|
|
7533
7562
|
];
|
|
7534
7563
|
function resolveRecipeChain(sourceVersion, targetVersion) {
|
|
@@ -7574,8 +7603,8 @@ function parseVersion2(version) {
|
|
|
7574
7603
|
}
|
|
7575
7604
|
|
|
7576
7605
|
// src/update/updater.ts
|
|
7577
|
-
import { readFile as
|
|
7578
|
-
import { join as
|
|
7606
|
+
import { readFile as readFile23, rm as rm8 } from "fs/promises";
|
|
7607
|
+
import { join as join27 } from "path";
|
|
7579
7608
|
|
|
7580
7609
|
// src/update/artifacts.ts
|
|
7581
7610
|
import { mkdtemp, readFile as readFile14 } from "fs/promises";
|
|
@@ -7936,8 +7965,8 @@ async function readProjectName2(projectDirectory) {
|
|
|
7936
7965
|
}
|
|
7937
7966
|
|
|
7938
7967
|
// src/update/planner.ts
|
|
7939
|
-
import { readFile as
|
|
7940
|
-
import { dirname as dirname7, join as
|
|
7968
|
+
import { readFile as readFile21 } from "fs/promises";
|
|
7969
|
+
import { dirname as dirname7, join as join25 } from "path";
|
|
7941
7970
|
|
|
7942
7971
|
// src/update/docker-copy-update-plan.ts
|
|
7943
7972
|
async function deriveDockerfilePlans(files, snapshots, paths, targetWorkspaceManifests) {
|
|
@@ -8025,7 +8054,11 @@ function matchesWorkspace(pattern, directory) {
|
|
|
8025
8054
|
}
|
|
8026
8055
|
|
|
8027
8056
|
// src/update/migration-reconciler.ts
|
|
8028
|
-
import { readFile as
|
|
8057
|
+
import { readFile as readFile18 } from "fs/promises";
|
|
8058
|
+
import { join as join21 } from "path";
|
|
8059
|
+
|
|
8060
|
+
// src/update/migration-adoption.ts
|
|
8061
|
+
import { readFile as readFile17 } from "fs/promises";
|
|
8029
8062
|
import { join as join20 } from "path";
|
|
8030
8063
|
|
|
8031
8064
|
// src/update/migration-project-file.ts
|
|
@@ -8060,6 +8093,60 @@ function isMissingFileError(error) {
|
|
|
8060
8093
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
8061
8094
|
}
|
|
8062
8095
|
|
|
8096
|
+
// src/update/migration-history.ts
|
|
8097
|
+
import { readFile as readFile16 } from "fs/promises";
|
|
8098
|
+
var drizzleRoot = "packages/database/drizzle";
|
|
8099
|
+
var journalPath = `${drizzleRoot}/meta/_journal.json`;
|
|
8100
|
+
var migrationPattern = /^(\d{4})_(.+)$/;
|
|
8101
|
+
function snapshotPath(tag) {
|
|
8102
|
+
const match = migrationPattern.exec(tag);
|
|
8103
|
+
if (!match) {
|
|
8104
|
+
throw new Error(`${journalPath}\uFF1Amigration tag \u683C\u5F0F\u65E0\u6548\uFF1A${tag}`);
|
|
8105
|
+
}
|
|
8106
|
+
return `${drizzleRoot}/meta/${match[1]}_snapshot.json`;
|
|
8107
|
+
}
|
|
8108
|
+
function validateUniqueNames(journal, label, conflicts) {
|
|
8109
|
+
const seen = new Set;
|
|
8110
|
+
for (const { tag } of journal.entries) {
|
|
8111
|
+
const name = stableName(tag);
|
|
8112
|
+
if (seen.has(name)) {
|
|
8113
|
+
conflicts.push(`${journalPath}\uFF1A${label}\u5B58\u5728\u91CD\u590D migration \u540D\u79F0 ${name}`);
|
|
8114
|
+
}
|
|
8115
|
+
seen.add(name);
|
|
8116
|
+
}
|
|
8117
|
+
}
|
|
8118
|
+
function stableName(tag) {
|
|
8119
|
+
return migrationPattern.exec(tag)?.[2] ?? tag;
|
|
8120
|
+
}
|
|
8121
|
+
function highestPrefix(journal) {
|
|
8122
|
+
return Math.max(-1, ...journal.entries.map(({ tag }) => Number(migrationPattern.exec(tag)?.[1] ?? -1)));
|
|
8123
|
+
}
|
|
8124
|
+
function highestIndex(journal) {
|
|
8125
|
+
return Math.max(-1, ...journal.entries.map(({ idx }) => idx));
|
|
8126
|
+
}
|
|
8127
|
+
function isDrizzleHistoryPath(path2) {
|
|
8128
|
+
return path2 === journalPath || isMigrationArtifact(path2);
|
|
8129
|
+
}
|
|
8130
|
+
function isMigrationArtifact(path2) {
|
|
8131
|
+
return isSqlMigration(path2) || new RegExp(`^${drizzleRoot}/meta/\\d{4}_snapshot\\.json$`).test(path2);
|
|
8132
|
+
}
|
|
8133
|
+
function isSqlMigration(path2) {
|
|
8134
|
+
return new RegExp(`^${drizzleRoot}/\\d{4}_.+\\.sql$`).test(path2);
|
|
8135
|
+
}
|
|
8136
|
+
function managedEntry(path2, content) {
|
|
8137
|
+
return { path: path2, ownership: "windy-managed", hash: hashContent(content) };
|
|
8138
|
+
}
|
|
8139
|
+
function deduplicate(files) {
|
|
8140
|
+
return [...new Map(files.map((entry) => [entry.path, entry])).values()];
|
|
8141
|
+
}
|
|
8142
|
+
function encodeJson(value) {
|
|
8143
|
+
return new TextEncoder().encode(`${JSON.stringify(value, null, 2)}
|
|
8144
|
+
`);
|
|
8145
|
+
}
|
|
8146
|
+
async function readJson(path2) {
|
|
8147
|
+
return JSON.parse(await readFile16(path2, "utf8"));
|
|
8148
|
+
}
|
|
8149
|
+
|
|
8063
8150
|
// src/update/snapshot-delta.ts
|
|
8064
8151
|
function applySnapshotDelta(before, after, current, path2, conflicts, conflictPath) {
|
|
8065
8152
|
if (deepEqual(before, after))
|
|
@@ -8105,10 +8192,99 @@ function deepEqual(left, right) {
|
|
|
8105
8192
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
8106
8193
|
}
|
|
8107
8194
|
|
|
8195
|
+
// src/update/migration-adoption.ts
|
|
8196
|
+
async function inspectPreexistingMigrationAdoptions(input) {
|
|
8197
|
+
const conflicts = [];
|
|
8198
|
+
const adoptions = [];
|
|
8199
|
+
const projectByName = new Map(input.project.entries.map((entry) => [stableName(entry.tag), entry]));
|
|
8200
|
+
for (const candidate of input.candidates) {
|
|
8201
|
+
const name = stableName(candidate.tag);
|
|
8202
|
+
const projectEntry = projectByName.get(name);
|
|
8203
|
+
if (!projectEntry || input.managedNames.has(name))
|
|
8204
|
+
continue;
|
|
8205
|
+
const targetPosition = input.target.entries.indexOf(candidate);
|
|
8206
|
+
const projectPosition = input.project.entries.indexOf(projectEntry);
|
|
8207
|
+
const previousTarget = input.target.entries[targetPosition - 1];
|
|
8208
|
+
const previousProject = input.project.entries[projectPosition - 1];
|
|
8209
|
+
if (!previousTarget || !previousProject) {
|
|
8210
|
+
conflicts.push(`${journalPath}\uFF1A\u65E0\u6CD5\u91C7\u7EB3\u73B0\u6709\u5E73\u53F0 migration ${name}\uFF0C\u7F3A\u5C11\u524D\u7F6E\u5386\u53F2`);
|
|
8211
|
+
continue;
|
|
8212
|
+
}
|
|
8213
|
+
const projectSqlPath = `${drizzleRoot}/${projectEntry.tag}.sql`;
|
|
8214
|
+
const projectSnapshotPath = snapshotPath(projectEntry.tag);
|
|
8215
|
+
const [
|
|
8216
|
+
targetSql,
|
|
8217
|
+
projectSql,
|
|
8218
|
+
targetBefore,
|
|
8219
|
+
targetAfter,
|
|
8220
|
+
projectBeforeBytes,
|
|
8221
|
+
projectAfterBytes
|
|
8222
|
+
] = await Promise.all([
|
|
8223
|
+
readFile17(join20(input.targetDirectory, `${drizzleRoot}/${candidate.tag}.sql`)),
|
|
8224
|
+
readProjectFile(input, projectSqlPath),
|
|
8225
|
+
readJson(join20(input.targetDirectory, snapshotPath(previousTarget.tag))),
|
|
8226
|
+
readJson(join20(input.targetDirectory, snapshotPath(candidate.tag))),
|
|
8227
|
+
readProjectFile(input, snapshotPath(previousProject.tag)),
|
|
8228
|
+
readProjectFile(input, projectSnapshotPath)
|
|
8229
|
+
]);
|
|
8230
|
+
if (!projectSql || !projectBeforeBytes || !projectAfterBytes) {
|
|
8231
|
+
conflicts.push(`${journalPath}\uFF1A\u65E0\u6CD5\u91C7\u7EB3\u73B0\u6709\u5E73\u53F0 migration ${name}\uFF0C\u9879\u76EE migration \u6587\u4EF6\u4E0D\u5B8C\u6574`);
|
|
8232
|
+
continue;
|
|
8233
|
+
}
|
|
8234
|
+
const projectBefore = decodeSnapshot(projectBeforeBytes);
|
|
8235
|
+
const projectAfter = decodeSnapshot(projectAfterBytes);
|
|
8236
|
+
const reason = validateAdoption({
|
|
8237
|
+
targetSql,
|
|
8238
|
+
projectSql,
|
|
8239
|
+
targetBefore,
|
|
8240
|
+
targetAfter,
|
|
8241
|
+
projectBefore,
|
|
8242
|
+
projectAfter
|
|
8243
|
+
});
|
|
8244
|
+
if (reason) {
|
|
8245
|
+
conflicts.push(`${journalPath}\uFF1A\u65E0\u6CD5\u91C7\u7EB3\u73B0\u6709\u5E73\u53F0 migration ${name}\uFF0C${reason}`);
|
|
8246
|
+
continue;
|
|
8247
|
+
}
|
|
8248
|
+
adoptions.push({
|
|
8249
|
+
sqlPath: projectSqlPath,
|
|
8250
|
+
snapshotPath: projectSnapshotPath,
|
|
8251
|
+
sql: projectSql,
|
|
8252
|
+
snapshot: projectAfterBytes
|
|
8253
|
+
});
|
|
8254
|
+
}
|
|
8255
|
+
return { adoptions, conflicts };
|
|
8256
|
+
}
|
|
8257
|
+
function validateAdoption(input) {
|
|
8258
|
+
if (!equalBytes(input.targetSql, input.projectSql)) {
|
|
8259
|
+
return "SQL \u5185\u5BB9\u4E0D\u4E00\u81F4";
|
|
8260
|
+
}
|
|
8261
|
+
if (input.projectAfter.prevId !== input.projectBefore.id) {
|
|
8262
|
+
return "\u9879\u76EE snapshot lineage \u4E0D\u8FDE\u7EED";
|
|
8263
|
+
}
|
|
8264
|
+
const deltaConflicts = [];
|
|
8265
|
+
const expected = applySnapshotDelta(input.targetBefore, input.targetAfter, input.projectBefore, [], deltaConflicts, journalPath);
|
|
8266
|
+
if (deltaConflicts.length || canonicalSnapshot(expected) !== canonicalSnapshot(input.projectAfter)) {
|
|
8267
|
+
return "snapshot delta \u4E0E\u9879\u76EE\u5386\u53F2\u4E0D\u4E00\u81F4";
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
function decodeSnapshot(content) {
|
|
8271
|
+
return JSON.parse(new TextDecoder().decode(content));
|
|
8272
|
+
}
|
|
8273
|
+
function equalBytes(left, right) {
|
|
8274
|
+
return left.byteLength === right.byteLength && left.every((value, index) => value === right[index]);
|
|
8275
|
+
}
|
|
8276
|
+
function canonicalSnapshot(value) {
|
|
8277
|
+
return JSON.stringify(canonicalize(value, true));
|
|
8278
|
+
}
|
|
8279
|
+
function canonicalize(value, root = false) {
|
|
8280
|
+
if (Array.isArray(value))
|
|
8281
|
+
return value.map((item) => canonicalize(item));
|
|
8282
|
+
if (!value || typeof value !== "object")
|
|
8283
|
+
return value;
|
|
8284
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => !root || key !== "id" && key !== "prevId").sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, canonicalize(item)]));
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8108
8287
|
// src/update/migration-reconciler.ts
|
|
8109
|
-
var drizzleRoot = "packages/database/drizzle";
|
|
8110
|
-
var journalPath = `${drizzleRoot}/meta/_journal.json`;
|
|
8111
|
-
var migrationPattern = /^(\d{4})_(.+)$/;
|
|
8112
8288
|
async function reconcileDrizzleMigrations(input) {
|
|
8113
8289
|
const journals = await readJournals(input);
|
|
8114
8290
|
if (!journals) {
|
|
@@ -8126,16 +8302,25 @@ async function reconcileDrizzleMigrations(input) {
|
|
|
8126
8302
|
const projectNames = new Set(project.entries.map(({ tag }) => stableName(tag)));
|
|
8127
8303
|
const managedNames = new Set(input.sourceManifest.files.filter(({ path: path2 }) => isSqlMigration(path2)).map(({ path: path2 }) => stableName(path2.slice(drizzleRoot.length + 1, -4))));
|
|
8128
8304
|
const candidates = target.entries.filter(({ tag }) => !baseNames.has(stableName(tag)));
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8305
|
+
const adoption = await inspectPreexistingMigrationAdoptions({
|
|
8306
|
+
...input,
|
|
8307
|
+
project,
|
|
8308
|
+
target,
|
|
8309
|
+
candidates,
|
|
8310
|
+
managedNames
|
|
8311
|
+
});
|
|
8312
|
+
conflicts.push(...adoption.conflicts);
|
|
8135
8313
|
const additions = candidates.filter(({ tag }) => !projectNames.has(stableName(tag)));
|
|
8136
8314
|
const contentOverrides = new Map;
|
|
8137
8315
|
const files = await preservePublishedHistory(input.sourceManifest, input, contentOverrides);
|
|
8138
8316
|
const publishedPaths = new Set(files.map(({ path: path2 }) => path2));
|
|
8317
|
+
for (const adopted of adoption.adoptions) {
|
|
8318
|
+
contentOverrides.set(adopted.sqlPath, adopted.sql);
|
|
8319
|
+
contentOverrides.set(adopted.snapshotPath, adopted.snapshot);
|
|
8320
|
+
files.push(managedEntry(adopted.sqlPath, adopted.sql), managedEntry(adopted.snapshotPath, adopted.snapshot));
|
|
8321
|
+
publishedPaths.add(adopted.sqlPath);
|
|
8322
|
+
publishedPaths.add(adopted.snapshotPath);
|
|
8323
|
+
}
|
|
8139
8324
|
files.push(...input.targetManifest.files.filter(({ path: path2 }) => !isDrizzleHistoryPath(path2)));
|
|
8140
8325
|
if (!additions.length) {
|
|
8141
8326
|
const journalContent2 = encodeJson(project);
|
|
@@ -8164,14 +8349,14 @@ async function reconcileDrizzleMigrations(input) {
|
|
|
8164
8349
|
const name = stableName(addition.tag);
|
|
8165
8350
|
const tag = `${prefix}_${name}`;
|
|
8166
8351
|
const sqlPath = `${drizzleRoot}/${tag}.sql`;
|
|
8167
|
-
const
|
|
8168
|
-
const sql = await
|
|
8352
|
+
const snapshotPath2 = `${drizzleRoot}/meta/${prefix}_snapshot.json`;
|
|
8353
|
+
const sql = await readFile18(join21(input.targetDirectory, `${drizzleRoot}/${addition.tag}.sql`));
|
|
8169
8354
|
merged.id = targetAfter.id;
|
|
8170
8355
|
merged.prevId = currentSnapshot.id;
|
|
8171
8356
|
const snapshot = encodeJson(merged);
|
|
8172
8357
|
contentOverrides.set(sqlPath, sql);
|
|
8173
|
-
contentOverrides.set(
|
|
8174
|
-
files.push(managedEntry(sqlPath, sql), managedEntry(
|
|
8358
|
+
contentOverrides.set(snapshotPath2, snapshot);
|
|
8359
|
+
files.push(managedEntry(sqlPath, sql), managedEntry(snapshotPath2, snapshot));
|
|
8175
8360
|
previousWhen = Math.max(previousWhen + 1, addition.when);
|
|
8176
8361
|
mergedJournal.entries.push({
|
|
8177
8362
|
...addition,
|
|
@@ -8212,9 +8397,9 @@ function unchanged(targetManifest) {
|
|
|
8212
8397
|
async function readJournals(input) {
|
|
8213
8398
|
try {
|
|
8214
8399
|
const [base, project, target] = await Promise.all([
|
|
8215
|
-
readJson(
|
|
8400
|
+
readJson(join21(input.baseDirectory, journalPath)),
|
|
8216
8401
|
readProjectJson(input, journalPath),
|
|
8217
|
-
readJson(
|
|
8402
|
+
readJson(join21(input.targetDirectory, journalPath))
|
|
8218
8403
|
]);
|
|
8219
8404
|
return { base, project, target };
|
|
8220
8405
|
} catch (error) {
|
|
@@ -8237,79 +8422,31 @@ async function readLatestSnapshot(input, journal) {
|
|
|
8237
8422
|
const latest = journal.entries.at(-1);
|
|
8238
8423
|
if (!latest)
|
|
8239
8424
|
throw new Error(`${journalPath}\uFF1A\u5F53\u524D\u9879\u76EE\u6CA1\u6709 migration`);
|
|
8240
|
-
const
|
|
8241
|
-
|
|
8242
|
-
throw new Error(`${journalPath}\uFF1Amigration tag \u683C\u5F0F\u65E0\u6548\uFF1A${latest.tag}`);
|
|
8243
|
-
}
|
|
8244
|
-
const snapshotPath = `${drizzleRoot}/meta/${match[1]}_snapshot.json`;
|
|
8245
|
-
const content = await readProjectFile(input, snapshotPath);
|
|
8425
|
+
const path2 = snapshotPath(latest.tag);
|
|
8426
|
+
const content = await readProjectFile(input, path2);
|
|
8246
8427
|
if (!content) {
|
|
8247
|
-
throw new Error(`\u5F53\u524D\u9879\u76EE migration \u6587\u4EF6\u7F3A\u5931\uFF1A${
|
|
8428
|
+
throw new Error(`\u5F53\u524D\u9879\u76EE migration \u6587\u4EF6\u7F3A\u5931\uFF1A${path2}`);
|
|
8248
8429
|
}
|
|
8249
8430
|
return JSON.parse(new TextDecoder().decode(content));
|
|
8250
8431
|
}
|
|
8251
8432
|
async function readSnapshot(root, tag) {
|
|
8252
|
-
|
|
8253
|
-
if (!match)
|
|
8254
|
-
throw new Error(`${journalPath}\uFF1Amigration tag \u683C\u5F0F\u65E0\u6548\uFF1A${tag}`);
|
|
8255
|
-
return await readJson(join20(root, `${drizzleRoot}/meta/${match[1]}_snapshot.json`));
|
|
8256
|
-
}
|
|
8257
|
-
function validateUniqueNames(journal, label, conflicts) {
|
|
8258
|
-
const seen = new Set;
|
|
8259
|
-
for (const { tag } of journal.entries) {
|
|
8260
|
-
const name = stableName(tag);
|
|
8261
|
-
if (seen.has(name)) {
|
|
8262
|
-
conflicts.push(`${journalPath}\uFF1A${label}\u5B58\u5728\u91CD\u590D migration \u540D\u79F0 ${name}`);
|
|
8263
|
-
}
|
|
8264
|
-
seen.add(name);
|
|
8265
|
-
}
|
|
8266
|
-
}
|
|
8267
|
-
function stableName(tag) {
|
|
8268
|
-
return migrationPattern.exec(tag)?.[2] ?? tag;
|
|
8269
|
-
}
|
|
8270
|
-
function highestPrefix(journal) {
|
|
8271
|
-
return Math.max(-1, ...journal.entries.map(({ tag }) => Number(migrationPattern.exec(tag)?.[1] ?? -1)));
|
|
8272
|
-
}
|
|
8273
|
-
function highestIndex(journal) {
|
|
8274
|
-
return Math.max(-1, ...journal.entries.map(({ idx }) => idx));
|
|
8275
|
-
}
|
|
8276
|
-
function isDrizzleHistoryPath(path2) {
|
|
8277
|
-
return path2 === journalPath || isMigrationArtifact(path2);
|
|
8278
|
-
}
|
|
8279
|
-
function isMigrationArtifact(path2) {
|
|
8280
|
-
return isSqlMigration(path2) || new RegExp(`^${drizzleRoot}/meta/\\d{4}_snapshot\\.json$`).test(path2);
|
|
8281
|
-
}
|
|
8282
|
-
function isSqlMigration(path2) {
|
|
8283
|
-
return new RegExp(`^${drizzleRoot}/\\d{4}_.+\\.sql$`).test(path2);
|
|
8284
|
-
}
|
|
8285
|
-
function managedEntry(path2, content) {
|
|
8286
|
-
return { path: path2, ownership: "windy-managed", hash: hashContent(content) };
|
|
8287
|
-
}
|
|
8288
|
-
function deduplicate(files) {
|
|
8289
|
-
return [...new Map(files.map((entry) => [entry.path, entry])).values()];
|
|
8290
|
-
}
|
|
8291
|
-
function encodeJson(value) {
|
|
8292
|
-
return new TextEncoder().encode(`${JSON.stringify(value, null, 2)}
|
|
8293
|
-
`);
|
|
8294
|
-
}
|
|
8295
|
-
async function readJson(path2) {
|
|
8296
|
-
return JSON.parse(await readFile16(path2, "utf8"));
|
|
8433
|
+
return await readJson(join21(root, snapshotPath(tag)));
|
|
8297
8434
|
}
|
|
8298
8435
|
|
|
8299
8436
|
// src/update/planner-file.ts
|
|
8300
|
-
import { readFile as
|
|
8301
|
-
import { join as
|
|
8437
|
+
import { readFile as readFile19 } from "fs/promises";
|
|
8438
|
+
import { join as join23 } from "path";
|
|
8302
8439
|
|
|
8303
8440
|
// src/update/merge.ts
|
|
8304
8441
|
import { mkdtemp as mkdtemp2, rm as rm6, writeFile as writeFile12 } from "fs/promises";
|
|
8305
8442
|
import { tmpdir as tmpdir2 } from "os";
|
|
8306
|
-
import { join as
|
|
8443
|
+
import { join as join22 } from "path";
|
|
8307
8444
|
async function mergeTextFile(base, ours, theirs) {
|
|
8308
|
-
const root = await mkdtemp2(
|
|
8445
|
+
const root = await mkdtemp2(join22(tmpdir2(), "windy-merge-"));
|
|
8309
8446
|
try {
|
|
8310
|
-
const oursPath =
|
|
8311
|
-
const basePath =
|
|
8312
|
-
const theirsPath =
|
|
8447
|
+
const oursPath = join22(root, "ours");
|
|
8448
|
+
const basePath = join22(root, "base");
|
|
8449
|
+
const theirsPath = join22(root, "theirs");
|
|
8313
8450
|
await Promise.all([
|
|
8314
8451
|
writeFile12(oursPath, ours),
|
|
8315
8452
|
writeFile12(basePath, base),
|
|
@@ -8567,8 +8704,8 @@ function conflict(path2, reason, expectedProjectContent) {
|
|
|
8567
8704
|
// src/update/planner-file.ts
|
|
8568
8705
|
async function planFile(path2, baseRoot, targetRoot, source, target, ours, provenance, targetContentOverride, manageGeneratedProjectOwned = false, forcePlatformBaseline = false) {
|
|
8569
8706
|
const [base, theirs] = await Promise.all([
|
|
8570
|
-
readOptional(
|
|
8571
|
-
targetContentOverride ? Promise.resolve(targetContentOverride) : readOptional(
|
|
8707
|
+
readOptional(join23(baseRoot, path2)),
|
|
8708
|
+
targetContentOverride ? Promise.resolve(targetContentOverride) : readOptional(join23(targetRoot, path2))
|
|
8572
8709
|
]);
|
|
8573
8710
|
const ownership = source?.ownership ?? target?.ownership ?? classifyOwnership(path2);
|
|
8574
8711
|
const expected = expectationForSnapshot(ours);
|
|
@@ -8675,7 +8812,7 @@ function conflict2(path2, ownership, reason, expectedProjectContent) {
|
|
|
8675
8812
|
}
|
|
8676
8813
|
async function readOptional(path2) {
|
|
8677
8814
|
try {
|
|
8678
|
-
return await
|
|
8815
|
+
return await readFile19(path2);
|
|
8679
8816
|
} catch (error) {
|
|
8680
8817
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
8681
8818
|
return;
|
|
@@ -8700,27 +8837,27 @@ function resolveModuleRecipeIds(request) {
|
|
|
8700
8837
|
}
|
|
8701
8838
|
|
|
8702
8839
|
// src/update/planner-snapshots.ts
|
|
8703
|
-
import { readFile as
|
|
8704
|
-
import { join as
|
|
8840
|
+
import { readFile as readFile20, stat as stat2 } from "fs/promises";
|
|
8841
|
+
import { join as join24 } from "path";
|
|
8705
8842
|
async function snapshotProjectFiles(project, paths, seed) {
|
|
8706
8843
|
const snapshots = new Map(seed);
|
|
8707
8844
|
await Promise.all([...paths].filter((path2) => !snapshots.has(path2)).map(async (path2) => {
|
|
8708
|
-
snapshots.set(path2, await readOptional2(
|
|
8845
|
+
snapshots.set(path2, await readOptional2(join24(project, path2)));
|
|
8709
8846
|
}));
|
|
8710
8847
|
return snapshots;
|
|
8711
8848
|
}
|
|
8712
8849
|
async function snapshotProjectModes(project, paths) {
|
|
8713
|
-
return new Map(await Promise.all([...paths].map(async (path2) => [path2, await readModeOptional(
|
|
8850
|
+
return new Map(await Promise.all([...paths].map(async (path2) => [path2, await readModeOptional(join24(project, path2))])));
|
|
8714
8851
|
}
|
|
8715
8852
|
async function assertPlanSnapshots(project, expectations) {
|
|
8716
8853
|
const changed = [];
|
|
8717
8854
|
for (const expectation2 of expectations) {
|
|
8718
|
-
const actual = expectationForSnapshot(await readOptional2(
|
|
8855
|
+
const actual = expectationForSnapshot(await readOptional2(join24(project, expectation2.path)));
|
|
8719
8856
|
if (JSON.stringify(actual) !== JSON.stringify(expectation2.expected)) {
|
|
8720
8857
|
changed.push(expectation2.path);
|
|
8721
8858
|
continue;
|
|
8722
8859
|
}
|
|
8723
|
-
if ("mode" in expectation2 && await readModeOptional(
|
|
8860
|
+
if ("mode" in expectation2 && await readModeOptional(join24(project, expectation2.path)) !== expectation2.mode) {
|
|
8724
8861
|
changed.push(expectation2.path);
|
|
8725
8862
|
}
|
|
8726
8863
|
}
|
|
@@ -8752,7 +8889,7 @@ async function readSourceParentMode(path2) {
|
|
|
8752
8889
|
}
|
|
8753
8890
|
async function readOptional2(path2) {
|
|
8754
8891
|
try {
|
|
8755
|
-
return await
|
|
8892
|
+
return await readFile20(path2);
|
|
8756
8893
|
} catch (error) {
|
|
8757
8894
|
if (isMissing7(error))
|
|
8758
8895
|
return;
|
|
@@ -8796,8 +8933,8 @@ var oxcManagedPaths = new Set([
|
|
|
8796
8933
|
]);
|
|
8797
8934
|
async function createUpdatePlan(request, artifacts) {
|
|
8798
8935
|
await assertProjectReadyForUpdate(request.projectDirectory);
|
|
8799
|
-
const manifestPath =
|
|
8800
|
-
const expectedManifestHash = hashContent(await
|
|
8936
|
+
const manifestPath = join25(request.projectDirectory, ".windy/files.json");
|
|
8937
|
+
const expectedManifestHash = hashContent(await readFile21(manifestPath));
|
|
8801
8938
|
const generationSnapshot = await readGenerationProvenanceSnapshot(request.projectDirectory);
|
|
8802
8939
|
const provenance = generationSnapshot.provenance;
|
|
8803
8940
|
const targetModules = resolveUpdateTargetModules(provenance.modules.map(({ name }) => name), request.targetModules);
|
|
@@ -8843,8 +8980,8 @@ async function createUpdatePlan(request, artifacts) {
|
|
|
8843
8980
|
const paths = new Set([...sourceEntries.keys(), ...targetEntries.keys()]);
|
|
8844
8981
|
for (const path2 of paths) {
|
|
8845
8982
|
if (!projectSnapshots.has(path2)) {
|
|
8846
|
-
projectSnapshots.set(path2, await readOptional2(
|
|
8847
|
-
projectModes.set(path2, await readModeOptional(
|
|
8983
|
+
projectSnapshots.set(path2, await readOptional2(join25(request.projectDirectory, path2)));
|
|
8984
|
+
projectModes.set(path2, await readModeOptional(join25(request.projectDirectory, path2)));
|
|
8848
8985
|
}
|
|
8849
8986
|
}
|
|
8850
8987
|
const files = await planFiles({
|
|
@@ -8866,10 +9003,10 @@ async function createUpdatePlan(request, artifacts) {
|
|
|
8866
9003
|
for (const file of files) {
|
|
8867
9004
|
file.expectedProjectMode = projectModes.get(file.path);
|
|
8868
9005
|
if (file.action === "create" || file.action === "update") {
|
|
8869
|
-
file.mode = file.expectedProjectMode ?? await readModeOptional(
|
|
9006
|
+
file.mode = file.expectedProjectMode ?? await readModeOptional(join25(artifactSet.targetDirectory, file.path));
|
|
8870
9007
|
}
|
|
8871
9008
|
if (file.action === "create") {
|
|
8872
|
-
file.parentMode = await readSourceParentMode(
|
|
9009
|
+
file.parentMode = await readSourceParentMode(join25(artifactSet.targetDirectory, dirname7(file.path)));
|
|
8873
9010
|
}
|
|
8874
9011
|
}
|
|
8875
9012
|
const plannedPaths = new Set(files.map(({ path: path2 }) => path2));
|
|
@@ -8889,7 +9026,7 @@ async function createUpdatePlan(request, artifacts) {
|
|
|
8889
9026
|
...migrations.conflicts,
|
|
8890
9027
|
...files.flatMap((file) => file.conflict ? [`${file.path}\uFF1A${file.conflict}`] : [])
|
|
8891
9028
|
];
|
|
8892
|
-
if (hashContent(await
|
|
9029
|
+
if (hashContent(await readFile21(manifestPath)) !== expectedManifestHash) {
|
|
8893
9030
|
throw new Error("\u751F\u6210\u66F4\u65B0\u8BA1\u5212\u671F\u95F4\u53D7\u7BA1\u6E05\u5355\u53D1\u751F\u53D8\u5316");
|
|
8894
9031
|
}
|
|
8895
9032
|
await assertPlanSnapshots(request.projectDirectory, [
|
|
@@ -9014,9 +9151,9 @@ function frozenManifestHash(file, finalizedHashes) {
|
|
|
9014
9151
|
}
|
|
9015
9152
|
|
|
9016
9153
|
// src/update/format-stabilizer.ts
|
|
9017
|
-
import { mkdir as mkdir8, mkdtemp as mkdtemp3, readFile as
|
|
9154
|
+
import { mkdir as mkdir8, mkdtemp as mkdtemp3, readFile as readFile22, rm as rm7, writeFile as writeFile13 } from "fs/promises";
|
|
9018
9155
|
import { tmpdir as tmpdir3 } from "os";
|
|
9019
|
-
import { dirname as dirname8, extname as extname4, join as
|
|
9156
|
+
import { dirname as dirname8, extname as extname4, join as join26, resolve as resolve6, sep as sep5 } from "path";
|
|
9020
9157
|
var formattedExtensions = new Set([
|
|
9021
9158
|
".cjs",
|
|
9022
9159
|
".css",
|
|
@@ -9055,7 +9192,7 @@ async function stabilizeManagedContent(result2, execute, writeProjectFile) {
|
|
|
9055
9192
|
}
|
|
9056
9193
|
}
|
|
9057
9194
|
inputs.set(".windy/generation.json", new TextEncoder().encode(generationContent));
|
|
9058
|
-
const temporaryRoot = await mkdtemp3(
|
|
9195
|
+
const temporaryRoot = await mkdtemp3(join26(tmpdir3(), "windy-update-format-"));
|
|
9059
9196
|
try {
|
|
9060
9197
|
const stagedPaths = await stageInputs(temporaryRoot, inputs);
|
|
9061
9198
|
for (let offset = 0;offset < stagedPaths.length; offset += 80) {
|
|
@@ -9063,14 +9200,14 @@ async function stabilizeManagedContent(result2, execute, writeProjectFile) {
|
|
|
9063
9200
|
"x",
|
|
9064
9201
|
"oxfmt",
|
|
9065
9202
|
"--write",
|
|
9066
|
-
`--config=${
|
|
9203
|
+
`--config=${join26(result2.plan.projectDirectory, ".oxfmtrc.json")}`,
|
|
9067
9204
|
...stagedPaths.slice(offset, offset + 80)
|
|
9068
9205
|
], result2.plan.projectDirectory);
|
|
9069
9206
|
}
|
|
9070
9207
|
const hashes = plannedContentHashes(result2);
|
|
9071
9208
|
let formattedGeneration = generationContent;
|
|
9072
9209
|
for (const [path2, original] of inputs) {
|
|
9073
|
-
const formatted = await
|
|
9210
|
+
const formatted = await readFile22(safeTemporaryPath(temporaryRoot, path2));
|
|
9074
9211
|
if (path2 === ".windy/generation.json") {
|
|
9075
9212
|
formattedGeneration = formatted.toString();
|
|
9076
9213
|
continue;
|
|
@@ -9224,7 +9361,7 @@ class DefaultStarterUpdater {
|
|
|
9224
9361
|
const plannedPaths = new Set(result2.plan.files.map(({ path: path2 }) => path2));
|
|
9225
9362
|
replaceExpectations(result2, verificationSnapshot.filter(({ path: path2 }) => !metadataPaths2.has(path2) && !plannedPaths.has(path2)));
|
|
9226
9363
|
verificationExpectationsFrozen = true;
|
|
9227
|
-
const packageJson = JSON.parse(await
|
|
9364
|
+
const packageJson = JSON.parse(await readFile23(join27(result2.plan.projectDirectory, "package.json"), "utf8"));
|
|
9228
9365
|
for (const name of ["lint", "typecheck", "test", "build"]) {
|
|
9229
9366
|
if (!packageJson.scripts?.[name]) {
|
|
9230
9367
|
steps.push({ name: `bun run ${name}`, status: "skipped" });
|
|
@@ -10142,20 +10279,20 @@ import {
|
|
|
10142
10279
|
cp,
|
|
10143
10280
|
mkdir as mkdir9,
|
|
10144
10281
|
mkdtemp as mkdtemp4,
|
|
10145
|
-
readFile as
|
|
10282
|
+
readFile as readFile25,
|
|
10146
10283
|
readdir as readdir9,
|
|
10147
10284
|
rename as rename2,
|
|
10148
10285
|
rm as rm11,
|
|
10149
10286
|
writeFile as writeFile14
|
|
10150
10287
|
} from "fs/promises";
|
|
10151
|
-
import { dirname as dirname9, join as
|
|
10288
|
+
import { dirname as dirname9, join as join28, relative as relative6 } from "path";
|
|
10152
10289
|
|
|
10153
10290
|
// src/module-schema/config.ts
|
|
10154
|
-
import { readFile as
|
|
10291
|
+
import { readFile as readFile24 } from "fs/promises";
|
|
10155
10292
|
import { isAbsolute as isAbsolute2, relative as relative5, resolve as resolve9 } from "path";
|
|
10156
10293
|
async function readModuleSchemaLineageConfig(projectDirectory, configPath) {
|
|
10157
10294
|
const absolutePath = resolveProjectPath(projectDirectory, configPath);
|
|
10158
|
-
const parsed = JSON.parse(await
|
|
10295
|
+
const parsed = JSON.parse(await readFile24(absolutePath, "utf8"));
|
|
10159
10296
|
if (!isConfig(parsed)) {
|
|
10160
10297
|
throw new Error("Module schema lineage \u914D\u7F6E\u65E0\u6548");
|
|
10161
10298
|
}
|
|
@@ -10289,17 +10426,17 @@ async function handoffModuleSchemaLineages(options) {
|
|
|
10289
10426
|
async function stageModuleLineages(project, temporaryRoot, config, execute) {
|
|
10290
10427
|
const outputs = [];
|
|
10291
10428
|
for (const [index, module3] of config.modules.entries()) {
|
|
10292
|
-
const output =
|
|
10429
|
+
const output = join28(temporaryRoot, `module-${index}`);
|
|
10293
10430
|
await mkdir9(output, { recursive: true });
|
|
10294
|
-
const generatedConfig =
|
|
10431
|
+
const generatedConfig = join28(temporaryRoot, `module-${index}.config.ts`);
|
|
10295
10432
|
await writeDrizzleConfig(generatedConfig, project, module3.schema, relative6(temporaryRoot, output));
|
|
10296
10433
|
await execute(generatedConfig, temporaryRoot);
|
|
10297
10434
|
const sqlFiles = await listSqlFiles(output);
|
|
10298
10435
|
if (sqlFiles.length !== 1) {
|
|
10299
10436
|
throw new Error(`${module3.key} baseline \u5FC5\u987B\u6070\u597D\u751F\u6210\u4E00\u4E2A migration`);
|
|
10300
10437
|
}
|
|
10301
|
-
await writeFile14(
|
|
10302
|
-
await writeFile14(
|
|
10438
|
+
await writeFile14(join28(output, sqlFiles[0]), metadataOnlySql("module"));
|
|
10439
|
+
await writeFile14(join28(output, "lineage.json"), `${JSON.stringify({
|
|
10303
10440
|
schemaVersion: 1,
|
|
10304
10441
|
moduleKey: module3.key,
|
|
10305
10442
|
schema: module3.schema,
|
|
@@ -10313,25 +10450,25 @@ async function stageModuleLineages(project, temporaryRoot, config, execute) {
|
|
|
10313
10450
|
}
|
|
10314
10451
|
async function stagePlatformLineage(project, temporaryRoot, config, execute) {
|
|
10315
10452
|
const source = resolveProjectPath(project, config.platform.out);
|
|
10316
|
-
const output =
|
|
10453
|
+
const output = join28(temporaryRoot, "platform");
|
|
10317
10454
|
await cp(source, output, { recursive: true });
|
|
10318
10455
|
const before = new Set(await listSqlFiles(output));
|
|
10319
|
-
const generatedConfig =
|
|
10456
|
+
const generatedConfig = join28(temporaryRoot, "platform.config.ts");
|
|
10320
10457
|
await writeDrizzleConfig(generatedConfig, project, config.platform.schema, relative6(temporaryRoot, output));
|
|
10321
10458
|
await execute(generatedConfig, temporaryRoot);
|
|
10322
10459
|
const created = (await listSqlFiles(output)).filter((path2) => !before.has(path2));
|
|
10323
10460
|
if (created.length !== 1) {
|
|
10324
10461
|
throw new Error("\u5E73\u53F0 lineage handoff \u5FC5\u987B\u6070\u597D\u751F\u6210\u4E00\u4E2A migration");
|
|
10325
10462
|
}
|
|
10326
|
-
const sqlPath =
|
|
10463
|
+
const sqlPath = join28(output, created[0]);
|
|
10327
10464
|
const allowed = config.modules.flatMap(({ legacyPlatformTables }) => legacyPlatformTables);
|
|
10328
|
-
validatePlatformHandoffSql(await
|
|
10465
|
+
validatePlatformHandoffSql(await readFile25(sqlPath, "utf8"), allowed);
|
|
10329
10466
|
await writeFile14(sqlPath, metadataOnlySql("platform"));
|
|
10330
10467
|
return output;
|
|
10331
10468
|
}
|
|
10332
10469
|
async function installStagedLineages(project, temporaryRoot, config, stagedModules, stagedPlatform) {
|
|
10333
10470
|
const platform = resolveProjectPath(project, config.platform.out);
|
|
10334
|
-
const backup =
|
|
10471
|
+
const backup = join28(temporaryRoot, "platform-backup");
|
|
10335
10472
|
const installed = [];
|
|
10336
10473
|
await rename2(platform, backup);
|
|
10337
10474
|
try {
|
|
@@ -10378,9 +10515,9 @@ async function validateSchemaSources(project, config) {
|
|
|
10378
10515
|
}
|
|
10379
10516
|
}
|
|
10380
10517
|
async function createTemporaryRoot(project) {
|
|
10381
|
-
const windy =
|
|
10518
|
+
const windy = join28(project, ".windy");
|
|
10382
10519
|
await mkdir9(windy, { recursive: true });
|
|
10383
|
-
return await mkdtemp4(
|
|
10520
|
+
return await mkdtemp4(join28(windy, "module-schema-handoff-"));
|
|
10384
10521
|
}
|
|
10385
10522
|
async function listSqlFiles(root) {
|
|
10386
10523
|
return (await readdir9(root)).filter((path2) => path2.endsWith(".sql")).sort();
|