create-windy 0.3.1 → 0.3.2
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/README.md +5 -1
- package/dist/cli.js +255 -95
- package/package.json +1 -1
- package/template/.windy-template.json +2 -2
package/README.md
CHANGED
|
@@ -156,9 +156,13 @@ hash 的 missing tombstone 记住客户删除的 `project-owned` 路径;后续
|
|
|
156
156
|
|
|
157
157
|
公网 `0.2.34` 的默认推荐模块项目也先对账到 `0.3.0`。该 profile 只有在 Project
|
|
158
158
|
Lock、Oxfmt 配置、manifest 与来源 artifact 哈希全部精确命中时才启用专属 proof;
|
|
159
|
-
未知 formatter
|
|
159
|
+
未知 formatter 输出继续保持未决。当前公网默认项目实测为 11 个可证明、0 个未决,
|
|
160
160
|
而非默认的 sharp-sword 仍为 5 个可证明、2 个未决。
|
|
161
161
|
|
|
162
|
+
发布后隔离回归确认全新 `0.3.1` 默认 Git/Oxc 项目 doctor 为 `0/0`,但真实
|
|
163
|
+
`0.2.34` 经上述对账和更新后仍存在受管 hash 漂移。因此 `0.3.1` 暂不用于既有下游
|
|
164
|
+
最终升级验收;等待后续补丁重新取得公开历史升级的 `0/0` 证据。
|
|
165
|
+
|
|
162
166
|
本地 Web 默认使用 8746;如果该端口属于其它服务,会自动尝试 8747、8748 等端口。
|
|
163
167
|
如果检测到同一个项目已启动,则直接复用现有地址。
|
|
164
168
|
|
package/dist/cli.js
CHANGED
|
@@ -1145,6 +1145,10 @@ packages/database/src/schema/governance.ts|8884f7abe27bc2f4d1217bd731c5d69909ed3
|
|
|
1145
1145
|
packages/modules/src/system-module-catalog.test.ts|805545e8fb4f64e7ca737b5daa5b7025fc9ef689e93825e6bf6b76e42dffbc44|6d147dd812687626a756370b0cba7fbc411a2ddb74e467dca7a979f049bbb768
|
|
1146
1146
|
packages/modules/src/system-modules.test.ts|d183047dbbb8575fae2509bd5bb35cd8120cb833eeb4e5f76f9514a292f34b31|9fd7167a54162a044dd3ced2f4194b8d4303b9fec1e1ffb3189b3dba642d3794
|
|
1147
1147
|
packages/modules/src/system-modules.ts|31f2db476c7222f124c9b3cbb30f2ab2e0ed6402d780e2daed0e2b693f60f41b|515964c29005b3e9fd6df4f9c5913ed561bf6b04277df52debeabe427af75b51
|
|
1148
|
+
apps/server/src/system/routes.ts|ac853ab1327141ce9b320405b761f78fa574cc1ae18a137c4fecb5c35d3103f1|5a3d774a40621cb525c9069bd486e8bd31f66866451c8282902dae91811de78d
|
|
1149
|
+
apps/web/src/pages/system/components/SystemResourcePage.vue|0a338f3280fcbdef8467c769d0a7ea412fdd114e7a7b392e77db5694a6d2f54b|abe1925fb2ab1560f219e04b0a8839f6d9fa8a65949a054b543e7b119f2960d2
|
|
1150
|
+
packages/modules/src/system-modules.test.ts|e1d3c926db7207e6c3681af308cbde5339046c28c40e6595c0d60ad4cfe36ba5|a704820000bc66be16f7c27be3643724abee5f787b3cb57fac46d78c8d65e511
|
|
1151
|
+
packages/modules/src/system-modules.ts|377c9df768c0a8a44ee1aa1806b7499d5db9ff991bdc2f7f44511fa92786ee80|a12cab4500642d5408cab2e736f591c6a3552cb1e3d328826eacdf8311cfdf2c
|
|
1148
1152
|
`.trim().split(`
|
|
1149
1153
|
`).map((line) => line.split("|"));
|
|
1150
1154
|
var createWindy030ManagedFormatProofs = Object.freeze(formattedEntries2.map(([path, artifactHash, currentHash]) => Object.freeze({
|
|
@@ -1160,6 +1164,41 @@ var createWindy030ManagedFormatProofs = Object.freeze(formattedEntries2.map(([pa
|
|
|
1160
1164
|
cause: "post-manifest-oxfmt"
|
|
1161
1165
|
})));
|
|
1162
1166
|
|
|
1167
|
+
// src/reconcile/proof-catalog-0234-core.ts
|
|
1168
|
+
var createWindy0234CoreProfileId = "0.2.34-core-oxfmt-0.59";
|
|
1169
|
+
var formattedEntries3 = `
|
|
1170
|
+
apps/server/src/system/drizzle-system.ts|68bc34e374a90860a541d2e6b5210ff8a8a8a33fe50741238f56614033636d35|4edf6bbec9bd9c36e97aa0b1d4ae57b5711c2b06d600e424166688432633d929|b070a7bf7c9ce6351b250ea25f01be9dfc150a6f56147a2885ef1e4f8c7d23aa
|
|
1171
|
+
apps/server/src/system/routes.test.ts|16448fa8148fbaddd580f4be3e5e8dfd499609f5b7af314c183dc9e89d8f2d97|fc1b138ca6c226ac520b170b445e22aa1cc50f7249f4b3de28bb93760e28a98c|0ab1189ddedfe718f66efba91773285ab71850ec0caca72754dd98eb01edb4b2
|
|
1172
|
+
apps/server/src/system/routes.ts|c350189c46c7e4716ba8a4e37c695c823e856ac87333a2475ecd1bbddfb395bb|2efe876f5544fd0fa4b6a6c1c40503f22637e6f3f0222d0345d422b1ab430965|ac853ab1327141ce9b320405b761f78fa574cc1ae18a137c4fecb5c35d3103f1
|
|
1173
|
+
apps/web/src/composables/usePlatformSettings.ts|68e2959ac0b5d1fe3fb3611d1875d62b9e64694472093a1662c5350f7c776a86|c3d9b1d7c8f2d59563f7ed647b59b4e115c3a448f2b3717aadacbfe1e9533f1b|9a0bc4d8dff0bd1212b8c15b1f4e3dbbecce48c099bbd20d5d7ec6f2a097d937
|
|
1174
|
+
apps/web/src/pages/system/components/SystemResourceFilters.vue|45508adf2cb741d7f5b718b91272e9521a2630562512c9ce4c4aaaeb42488723|d82b8b8497b5378d22f40ef276cf37840d8daed823223d094b675980a2e49b13|989bf1117fc84d4e8ea769954b12340f609a8653c4529cc70cd690df2d1904de
|
|
1175
|
+
apps/web/src/pages/system/components/SystemResourcePage.vue|7ff844cd24170002b79ed5b7082dd8a0531f0c3927a00c3394496bc7b0c4179d|8df16b98beac92d4de712a3b1b36ea4c788bc9d2a4b7f623c4dc6cf239a18b1e|0a338f3280fcbdef8467c769d0a7ea412fdd114e7a7b392e77db5694a6d2f54b
|
|
1176
|
+
apps/web/src/pages/system/components/SystemResourcePage.webtest.ts|4b2e76b3042f1023cbc187e6f960127b0c157fdcebf1524eddcfa742db4b69ff|fbcebcb2ea2962fc4633a43b3c2bbcc36535f9dd0dbd8775665902017e568150|bfaeb5b1d6ea209603fc2946b3f0d70bf029d182cfd06d769c3c10482f2d9e6b
|
|
1177
|
+
apps/web/src/pages/system/resource-config.ts|e8ee83d2ce377dc6cfb41675f55a9093b0f2336179d7760c2acac61220c64d99|a7e76a44a1757483b626d4639ed0c64cca2e296ae4c6444756e42d0798bc0a55|cfb0fffb9cbbecd8d4fa630df6e5ddf2218181a8bf5b3535fd17bb36095890dd
|
|
1178
|
+
docs/platform/system-crud-api.md|3558368ac2ec7ab22423d34dc450666bf0983671422cb5b8d781e7716a390243|4aa4924ee0cbce3e488e350a1dfe73910d4eab4015d31899f93d238cc74e894a|86c485333ace7162a7dbd190ee1632215e04bd21627b57e4e308433b0cc0d38c
|
|
1179
|
+
packages/modules/src/system-modules.test.ts|887a23c30de141efe157b2cd70ee241965b766e5483975ac66981d9e2f818d02|5379d9ab37ca82393ff571e029ee91c233067c0fc57ee24820e63c25ffaa0f35|e1d3c926db7207e6c3681af308cbde5339046c28c40e6595c0d60ad4cfe36ba5
|
|
1180
|
+
packages/modules/src/system-modules.ts|377c9df768c0a8a44ee1aa1806b7499d5db9ff991bdc2f7f44511fa92786ee80|a12cab4500642d5408cab2e736f591c6a3552cb1e3d328826eacdf8311cfdf2c|377c9df768c0a8a44ee1aa1806b7499d5db9ff991bdc2f7f44511fa92786ee80
|
|
1181
|
+
`.trim().split(`
|
|
1182
|
+
`).map((line) => line.split("|"));
|
|
1183
|
+
var createWindy0234CoreProofs = Object.freeze(formattedEntries3.map(([path, artifactHash, currentHash, targetHash]) => Object.freeze({
|
|
1184
|
+
id: `${createWindy0234CoreProfileId}:${path}`,
|
|
1185
|
+
profileId: createWindy0234CoreProfileId,
|
|
1186
|
+
path,
|
|
1187
|
+
sourceVersion: "0.2.34",
|
|
1188
|
+
sourceIntegrity: createWindy0234Integrity,
|
|
1189
|
+
targetVersion: "0.3.0",
|
|
1190
|
+
targetIntegrity: createWindy030Integrity,
|
|
1191
|
+
artifactHash,
|
|
1192
|
+
currentHash,
|
|
1193
|
+
targetHash,
|
|
1194
|
+
cause: "post-manifest-oxfmt"
|
|
1195
|
+
})));
|
|
1196
|
+
var createWindy0234CoreProfile = Object.freeze({
|
|
1197
|
+
...createWindy0234DefaultProfile,
|
|
1198
|
+
id: createWindy0234CoreProfileId,
|
|
1199
|
+
generationHash: "d813160ddf27c1acf81e4518e3b576488201dcf30a2b7d4c9e7e533687e90c92"
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1163
1202
|
// src/reconcile/proof-catalog.ts
|
|
1164
1203
|
var source0234Integrity = "sha512-Gx1usyfuMKVwzybfuqWSAzxPJrI01tl4rW6MX5lJ4Q3wPHZm7nbSeCjrLYzWGtlZUM9THCryC4M49rFnph/8Ew==";
|
|
1165
1204
|
var target030Integrity = "sha512-iCEnmaRuxiB+P/ZK3tgBZCQ+q17fNl9lqJPjC68JgF+QEGywo+twjEb93vx++cfAaamVkMbec4MmsY3pyOK+NA==";
|
|
@@ -1173,6 +1212,7 @@ var legacyManagedFormatProofs = Object.freeze([
|
|
|
1173
1212
|
var releasedManagedFormatProofs = Object.freeze([
|
|
1174
1213
|
...legacyManagedFormatProofs,
|
|
1175
1214
|
...createWindy0234DefaultProofs,
|
|
1215
|
+
...createWindy0234CoreProofs,
|
|
1176
1216
|
...createWindy030ManagedFormatProofs
|
|
1177
1217
|
]);
|
|
1178
1218
|
function resolveProofIdentity(proofs, sourceVersion, targetVersion) {
|
|
@@ -1656,10 +1696,13 @@ var canonicalHashes = Object.freeze({
|
|
|
1656
1696
|
current: "72eb9e6c1f0763a151d6d8a8902ca65529dd035304c065eae3d15c8a8a29dc75"
|
|
1657
1697
|
});
|
|
1658
1698
|
var wideCharacter = /[\u1100-\u115f\u2329\u232a\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe10-\ufe19\ufe30-\ufe6f\uff00-\uff60\uffe0-\uffe6]/;
|
|
1659
|
-
async function resolveCreateWindy0234ReadmeProof(projectDirectory) {
|
|
1699
|
+
async function resolveCreateWindy0234ReadmeProof(projectDirectory, profileId = createWindy0234DefaultProfileId) {
|
|
1660
1700
|
const projectName = await readProjectName2(projectDirectory);
|
|
1661
1701
|
if (!projectName)
|
|
1662
1702
|
return;
|
|
1703
|
+
if (profileId === createWindy0234CoreProfileId) {
|
|
1704
|
+
return createCoreReadmeProof(projectName);
|
|
1705
|
+
}
|
|
1663
1706
|
const source = readme_template_0234_default.replaceAll(projectNamePlaceholder2, projectName);
|
|
1664
1707
|
const current = formatKnownMarkdown(source);
|
|
1665
1708
|
if (hash2(readme_template_0234_default) !== canonicalHashes.source || hash2(formatKnownMarkdown(readme_template_0234_default)) !== canonicalHashes.current) {
|
|
@@ -1682,6 +1725,36 @@ async function resolveCreateWindy0234ReadmeProof(projectDirectory) {
|
|
|
1682
1725
|
cause: "post-manifest-oxfmt"
|
|
1683
1726
|
});
|
|
1684
1727
|
}
|
|
1728
|
+
function createCoreReadmeProof(projectName) {
|
|
1729
|
+
const source = coreModuleSelection(readme_template_0234_default).replaceAll(projectNamePlaceholder2, projectName);
|
|
1730
|
+
const current = formatKnownMarkdown(source);
|
|
1731
|
+
const targetCurrent = coreModuleSelection(readme_template_030_default).replaceAll("WINDYPROJECTNAMEPLACEHOLDER030", projectName);
|
|
1732
|
+
const target = reverseKnownOxfmtChanges(targetCurrent);
|
|
1733
|
+
return Object.freeze({
|
|
1734
|
+
id: `${createWindy0234CoreProfileId}:README.md`,
|
|
1735
|
+
profileId: createWindy0234CoreProfileId,
|
|
1736
|
+
path: "README.md",
|
|
1737
|
+
sourceVersion: "0.2.34",
|
|
1738
|
+
sourceIntegrity: createWindy0234Integrity,
|
|
1739
|
+
targetVersion: "0.3.0",
|
|
1740
|
+
targetIntegrity: createWindy030Integrity,
|
|
1741
|
+
artifactHash: hash2(source),
|
|
1742
|
+
currentHash: hash2(current),
|
|
1743
|
+
targetHash: hash2(target),
|
|
1744
|
+
cause: "post-manifest-oxfmt"
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
function coreModuleSelection(content) {
|
|
1748
|
+
const coreOptionalModules = new Set([
|
|
1749
|
+
"system.settings",
|
|
1750
|
+
"system.configuration",
|
|
1751
|
+
"system.audit",
|
|
1752
|
+
"system.operations"
|
|
1753
|
+
]);
|
|
1754
|
+
return content.split(`
|
|
1755
|
+
`).map((line) => [...coreOptionalModules].some((name) => line.startsWith(`| \`${name}\``)) ? line.replace("\u5DF2\u5305\u542B", "\u672A\u5305\u542B") : line).join(`
|
|
1756
|
+
`);
|
|
1757
|
+
}
|
|
1685
1758
|
function formatKnownMarkdown(content) {
|
|
1686
1759
|
const lines = content.replace(`
|
|
1687
1760
|
|
|
@@ -1880,16 +1953,19 @@ async function readManagedFilesManifest(targetDirectory, trustedProofs = release
|
|
|
1880
1953
|
return (await readManagedFilesManifestSnapshot(targetDirectory, trustedProofs)).manifest;
|
|
1881
1954
|
}
|
|
1882
1955
|
async function readManagedFilesManifestSnapshot(targetDirectory, trustedProofs = releasedManagedFormatProofs) {
|
|
1883
|
-
const [content, readmeProof030, readmeProof0234] = await Promise.all([
|
|
1956
|
+
const [content, readmeProof030, readmeProof0234, readmeProof0234Core] = await Promise.all([
|
|
1884
1957
|
readFile4(join4(targetDirectory, managedFilesManifestPath)),
|
|
1885
1958
|
resolveCreateWindy030ReadmeProof(targetDirectory),
|
|
1886
|
-
resolveCreateWindy0234ReadmeProof(targetDirectory)
|
|
1959
|
+
resolveCreateWindy0234ReadmeProof(targetDirectory),
|
|
1960
|
+
resolveCreateWindy0234ReadmeProof(targetDirectory, createWindy0234CoreProfileId)
|
|
1887
1961
|
]);
|
|
1888
1962
|
const effectiveProofs = [...trustedProofs];
|
|
1889
1963
|
if (readmeProof030)
|
|
1890
1964
|
effectiveProofs.push(readmeProof030);
|
|
1891
1965
|
if (readmeProof0234)
|
|
1892
1966
|
effectiveProofs.push(readmeProof0234);
|
|
1967
|
+
if (readmeProof0234Core)
|
|
1968
|
+
effectiveProofs.push(readmeProof0234Core);
|
|
1893
1969
|
return {
|
|
1894
1970
|
content,
|
|
1895
1971
|
hash: hashContent(content),
|
|
@@ -5881,8 +5957,8 @@ function sentenceWithoutStop(value) {
|
|
|
5881
5957
|
}
|
|
5882
5958
|
|
|
5883
5959
|
// src/update/cli.ts
|
|
5884
|
-
import { rm as
|
|
5885
|
-
import { resolve as
|
|
5960
|
+
import { rm as rm10 } from "fs/promises";
|
|
5961
|
+
import { resolve as resolve7 } from "path";
|
|
5886
5962
|
|
|
5887
5963
|
// src/reconcile/managed-reconciler.ts
|
|
5888
5964
|
import { rm as rm6 } from "fs/promises";
|
|
@@ -8556,7 +8632,8 @@ var recipes = [
|
|
|
8556
8632
|
{ id: "starter-0.2.32-to-0.2.33", from: "0.2.32", to: "0.2.33" },
|
|
8557
8633
|
{ id: "starter-0.2.33-to-0.2.34", from: "0.2.33", to: "0.2.34" },
|
|
8558
8634
|
{ id: "starter-0.2.34-to-0.3.0", from: "0.2.34", to: "0.3.0" },
|
|
8559
|
-
{ id: "starter-0.3.0-to-0.3.1", from: "0.3.0", to: "0.3.1" }
|
|
8635
|
+
{ id: "starter-0.3.0-to-0.3.1", from: "0.3.0", to: "0.3.1" },
|
|
8636
|
+
{ id: "starter-0.3.1-to-0.3.2", from: "0.3.1", to: "0.3.2" }
|
|
8560
8637
|
];
|
|
8561
8638
|
function resolveRecipeChain(sourceVersion, targetVersion) {
|
|
8562
8639
|
if (sourceVersion === targetVersion)
|
|
@@ -8771,7 +8848,7 @@ function createReconcileId(sourceVersion, targetVersion) {
|
|
|
8771
8848
|
}
|
|
8772
8849
|
|
|
8773
8850
|
// src/reconcile/proof-profile.ts
|
|
8774
|
-
var releasedManagedProofProfiles = Object.freeze([createWindy0234DefaultProfile]);
|
|
8851
|
+
var releasedManagedProofProfiles = Object.freeze([createWindy0234DefaultProfile, createWindy0234CoreProfile]);
|
|
8775
8852
|
async function resolveManagedProofProfile(input) {
|
|
8776
8853
|
const candidates = (input.profiles ?? releasedManagedProofProfiles).filter((profile) => profile.sourceVersion === input.sourceVersion && profile.sourceIntegrity === input.sourceIntegrity && profile.targetVersion === input.targetVersion && profile.targetIntegrity === input.targetIntegrity && profile.generationHash === input.generationHash);
|
|
8777
8854
|
const matches2 = [];
|
|
@@ -8807,7 +8884,7 @@ async function resolveReconcileProofContext(input) {
|
|
|
8807
8884
|
const profileId = await resolveManagedProofProfile(input);
|
|
8808
8885
|
const [readme030, readme0234] = await Promise.all([
|
|
8809
8886
|
resolveCreateWindy030ReadmeProof(input.projectDirectory),
|
|
8810
|
-
profileId ? resolveCreateWindy0234ReadmeProof(input.projectDirectory) : null
|
|
8887
|
+
profileId ? resolveCreateWindy0234ReadmeProof(input.projectDirectory, profileId) : null
|
|
8811
8888
|
]);
|
|
8812
8889
|
const effectiveProofs = input.proofs.filter((proof2) => !proof2.profileId || proof2.profileId === profileId);
|
|
8813
8890
|
if (readme030)
|
|
@@ -9174,14 +9251,14 @@ class PublicReconcileArtifactProvider {
|
|
|
9174
9251
|
const temporaryRoot = await mkdtemp2(join26(tmpdir2(), "windy-reconcile-"));
|
|
9175
9252
|
try {
|
|
9176
9253
|
const provenance = await readGenerationProvenance(input.projectDirectory);
|
|
9177
|
-
const sourceArtifact = await
|
|
9254
|
+
const sourceArtifact = await downloadPublicArtifact(temporaryRoot, "source", input.sourceVersion, input.sourceIntegrity, this.#fetch);
|
|
9178
9255
|
if (sourceArtifact.identity.templateCommit !== provenance.templateCommit) {
|
|
9179
9256
|
throw new Error("Project Lock \u4E0E\u6765\u6E90 artifact \u7684 template commit \u4E0D\u4E00\u81F4");
|
|
9180
9257
|
}
|
|
9181
|
-
const targetArtifact = await
|
|
9258
|
+
const targetArtifact = await downloadPublicArtifact(temporaryRoot, "target", input.targetVersion, input.targetIntegrity, this.#fetch);
|
|
9182
9259
|
const projectName = await readArtifactProjectName(input.projectDirectory);
|
|
9183
|
-
const sourceDirectory = await
|
|
9184
|
-
const targetDirectory = await
|
|
9260
|
+
const sourceDirectory = await generatePublicArtifactProject(temporaryRoot, "source-project", projectName, sourceArtifact.root, provenance);
|
|
9261
|
+
const targetDirectory = await generatePublicArtifactProject(temporaryRoot, "target-project", projectName, targetArtifact.root, provenance);
|
|
9185
9262
|
return {
|
|
9186
9263
|
temporaryRoot,
|
|
9187
9264
|
sourceDirectory,
|
|
@@ -9195,9 +9272,9 @@ class PublicReconcileArtifactProvider {
|
|
|
9195
9272
|
}
|
|
9196
9273
|
}
|
|
9197
9274
|
}
|
|
9198
|
-
async function
|
|
9275
|
+
async function downloadPublicArtifact(temporaryRoot, label, version, expectedIntegrity, fetcher) {
|
|
9199
9276
|
const metadata = await fetchRegistryMetadata(version, fetcher);
|
|
9200
|
-
if (metadata.dist.integrity !== expectedIntegrity) {
|
|
9277
|
+
if (expectedIntegrity !== undefined && metadata.dist.integrity !== expectedIntegrity) {
|
|
9201
9278
|
throw new Error(`create-windy@${version} registry integrity \u4E0E\u4E0D\u53EF\u53D8 proof \u4E0D\u4E00\u81F4`);
|
|
9202
9279
|
}
|
|
9203
9280
|
const response = await fetchTrustedArtifact(metadata.dist.tarball, fetcher);
|
|
@@ -9347,7 +9424,7 @@ function verifyArchive(metadata, archive) {
|
|
|
9347
9424
|
throw new Error(`create-windy@${metadata.version} artifact \u5B8C\u6574\u6027\u6821\u9A8C\u5931\u8D25`);
|
|
9348
9425
|
}
|
|
9349
9426
|
}
|
|
9350
|
-
async function
|
|
9427
|
+
async function generatePublicArtifactProject(temporaryRoot, label, projectName, packageRoot2, provenance) {
|
|
9351
9428
|
const parent = join26(temporaryRoot, label);
|
|
9352
9429
|
await mkdir6(parent, { recursive: true });
|
|
9353
9430
|
const args = [
|
|
@@ -9437,20 +9514,28 @@ async function diagnoseProject(projectDirectory, repair = false) {
|
|
|
9437
9514
|
}
|
|
9438
9515
|
|
|
9439
9516
|
// src/update/updater.ts
|
|
9440
|
-
import { readFile as
|
|
9441
|
-
import { join as
|
|
9517
|
+
import { readFile as readFile23, rm as rm9 } from "fs/promises";
|
|
9518
|
+
import { join as join30 } from "path";
|
|
9442
9519
|
|
|
9443
9520
|
// src/update/artifacts.ts
|
|
9444
|
-
import {
|
|
9521
|
+
import { mkdtemp as mkdtemp3, readFile as readFile21 } from "fs/promises";
|
|
9445
9522
|
import { tmpdir as tmpdir3 } from "os";
|
|
9446
9523
|
import { basename as basename8, join as join28 } from "path";
|
|
9447
9524
|
class PublishedArtifactProvider {
|
|
9525
|
+
#fetch;
|
|
9526
|
+
constructor(fetcher = globalThis.fetch) {
|
|
9527
|
+
this.#fetch = fetcher;
|
|
9528
|
+
}
|
|
9448
9529
|
async prepare(projectDirectory, provenance) {
|
|
9449
9530
|
const temporaryRoot = await mkdtemp3(join28(tmpdir3(), "windy-update-"));
|
|
9450
9531
|
const projectName = await readProjectName3(projectDirectory);
|
|
9451
9532
|
const baseDirectory = join28(temporaryRoot, "base", projectName);
|
|
9452
9533
|
const targetDirectory = join28(temporaryRoot, "target", projectName);
|
|
9453
|
-
await
|
|
9534
|
+
const baseArtifact = await downloadPublicArtifact(temporaryRoot, "base", provenance.generatorVersion, undefined, this.#fetch);
|
|
9535
|
+
if (baseArtifact.identity.templateCommit !== provenance.templateCommit) {
|
|
9536
|
+
throw new Error("Project Lock \u4E0E\u6765\u6E90 registry artifact \u7684 template commit \u4E0D\u4E00\u81F4");
|
|
9537
|
+
}
|
|
9538
|
+
await generatePublicArtifactProject(temporaryRoot, "base", projectName, baseArtifact.root, provenance);
|
|
9454
9539
|
await generateProject({
|
|
9455
9540
|
sourceRoot: await resolveTemplateRoot(),
|
|
9456
9541
|
targetDirectory,
|
|
@@ -9465,42 +9550,13 @@ class PublishedArtifactProvider {
|
|
|
9465
9550
|
return { temporaryRoot, baseDirectory, targetDirectory };
|
|
9466
9551
|
}
|
|
9467
9552
|
}
|
|
9468
|
-
async function generatePublishedBase(temporaryRoot, projectName, provenance, expectedDirectory) {
|
|
9469
|
-
const parent = join28(temporaryRoot, "base");
|
|
9470
|
-
await mkdir7(parent, { recursive: true });
|
|
9471
|
-
const args = [
|
|
9472
|
-
"--bun",
|
|
9473
|
-
`create-windy@${provenance.generatorVersion}`,
|
|
9474
|
-
projectName,
|
|
9475
|
-
"--yes",
|
|
9476
|
-
"--skip-install",
|
|
9477
|
-
"--no-git",
|
|
9478
|
-
"--no-optional-modules",
|
|
9479
|
-
"--license",
|
|
9480
|
-
provenance.legalLicense
|
|
9481
|
-
];
|
|
9482
|
-
if (!provenance.choices.includeOxc)
|
|
9483
|
-
args.push("--no-oxc");
|
|
9484
|
-
if (provenance.legalLicense === "MIT") {
|
|
9485
|
-
args.push("--license-holder", "Windy project owner");
|
|
9486
|
-
}
|
|
9487
|
-
for (const { name } of provenance.modules) {
|
|
9488
|
-
if (!requiredModuleNames.includes(name)) {
|
|
9489
|
-
args.push("--module", name);
|
|
9490
|
-
}
|
|
9491
|
-
}
|
|
9492
|
-
await assertProcess("bunx", args, parent);
|
|
9493
|
-
if (join28(parent, projectName) !== expectedDirectory) {
|
|
9494
|
-
throw new Error("\u5386\u53F2 artifact \u751F\u6210\u76EE\u5F55\u5F02\u5E38");
|
|
9495
|
-
}
|
|
9496
|
-
}
|
|
9497
9553
|
async function readProjectName3(projectDirectory) {
|
|
9498
9554
|
const source = JSON.parse(await readFile21(join28(projectDirectory, "package.json"), "utf8"));
|
|
9499
9555
|
return source.name || basename8(projectDirectory);
|
|
9500
9556
|
}
|
|
9501
9557
|
|
|
9502
9558
|
// src/update/updater-final-manifest.ts
|
|
9503
|
-
function buildFinalManagedManifest(plan, generationContent) {
|
|
9559
|
+
function buildFinalManagedManifest(plan, generationContent, finalizedHashes = new Map) {
|
|
9504
9560
|
const source = new Map(plan.sourceManifest.files.map((entry) => [entry.path, entry]));
|
|
9505
9561
|
const target = new Map(plan.targetManifest.files.map((entry) => [entry.path, entry]));
|
|
9506
9562
|
const filePlans = new Map(plan.files.map((file) => [file.path, file]));
|
|
@@ -9536,7 +9592,7 @@ function buildFinalManagedManifest(plan, generationContent) {
|
|
|
9536
9592
|
files.push({
|
|
9537
9593
|
path: path2,
|
|
9538
9594
|
ownership: "project-owned",
|
|
9539
|
-
hash: frozenManifestHash(file)
|
|
9595
|
+
hash: frozenManifestHash(file, finalizedHashes)
|
|
9540
9596
|
});
|
|
9541
9597
|
continue;
|
|
9542
9598
|
}
|
|
@@ -9544,16 +9600,16 @@ function buildFinalManagedManifest(plan, generationContent) {
|
|
|
9544
9600
|
if (isMissingManagedFile(clean)) {
|
|
9545
9601
|
throw new Error(`\u6700\u7EC8\u53D7\u7BA1\u6E05\u5355\u4E0D\u80FD\u4E3A\u7F3A\u5931\u8DEF\u5F84\u5199\u5165 hash\uFF1A${path2}`);
|
|
9546
9602
|
}
|
|
9547
|
-
clean.hash = frozenManifestHash(file);
|
|
9603
|
+
clean.hash = frozenManifestHash(file, finalizedHashes);
|
|
9548
9604
|
files.push(clean);
|
|
9549
9605
|
}
|
|
9550
9606
|
return { ...plan.targetManifest, schemaVersion: 3, files };
|
|
9551
9607
|
}
|
|
9552
|
-
function frozenManifestHash(file) {
|
|
9608
|
+
function frozenManifestHash(file, finalizedHashes) {
|
|
9553
9609
|
if (file.action === "create" || file.action === "update") {
|
|
9554
9610
|
if (!file.content)
|
|
9555
9611
|
throw new Error(`\u66F4\u65B0\u8BA1\u5212\u7F3A\u5C11\u6587\u4EF6\u5185\u5BB9\uFF1A${file.path}`);
|
|
9556
|
-
return hashContent(file.content);
|
|
9612
|
+
return finalizedHashes.get(file.path) ?? hashContent(file.content);
|
|
9557
9613
|
}
|
|
9558
9614
|
if (file.expectedProjectContent.kind !== "hash") {
|
|
9559
9615
|
throw new Error(`\u4FDD\u7559\u8DEF\u5F84\u7F3A\u5C11\u51BB\u7ED3\u6B63\u6587\uFF1A${file.path}`);
|
|
@@ -9561,6 +9617,103 @@ function frozenManifestHash(file) {
|
|
|
9561
9617
|
return file.expectedProjectContent.value;
|
|
9562
9618
|
}
|
|
9563
9619
|
|
|
9620
|
+
// src/update/format-stabilizer.ts
|
|
9621
|
+
import { mkdir as mkdir7, mkdtemp as mkdtemp4, readFile as readFile22, rm as rm8, writeFile as writeFile11 } from "fs/promises";
|
|
9622
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
9623
|
+
import { dirname as dirname7, extname as extname4, join as join29, resolve as resolve6, sep as sep4 } from "path";
|
|
9624
|
+
var formattedExtensions = new Set([
|
|
9625
|
+
".cjs",
|
|
9626
|
+
".css",
|
|
9627
|
+
".cts",
|
|
9628
|
+
".html",
|
|
9629
|
+
".js",
|
|
9630
|
+
".json",
|
|
9631
|
+
".jsonc",
|
|
9632
|
+
".jsx",
|
|
9633
|
+
".less",
|
|
9634
|
+
".md",
|
|
9635
|
+
".mdx",
|
|
9636
|
+
".mjs",
|
|
9637
|
+
".mts",
|
|
9638
|
+
".scss",
|
|
9639
|
+
".ts",
|
|
9640
|
+
".tsx",
|
|
9641
|
+
".vue",
|
|
9642
|
+
".yaml",
|
|
9643
|
+
".yml"
|
|
9644
|
+
]);
|
|
9645
|
+
async function stabilizeManagedContent(result2, execute, writeProjectFile) {
|
|
9646
|
+
const generationContent = `${JSON.stringify(result2.plan.targetProvenance, null, 2)}
|
|
9647
|
+
`;
|
|
9648
|
+
if (result2.plan.detachedToolchain || !result2.plan.targetProvenance.choices.includeOxc) {
|
|
9649
|
+
return {
|
|
9650
|
+
generationContent,
|
|
9651
|
+
hashes: plannedContentHashes(result2),
|
|
9652
|
+
status: "skipped"
|
|
9653
|
+
};
|
|
9654
|
+
}
|
|
9655
|
+
const inputs = new Map;
|
|
9656
|
+
for (const file of result2.plan.files) {
|
|
9657
|
+
if ((file.action === "create" || file.action === "update") && file.content && formattedExtensions.has(extname4(file.path))) {
|
|
9658
|
+
inputs.set(file.path, file.content);
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
inputs.set(".windy/generation.json", new TextEncoder().encode(generationContent));
|
|
9662
|
+
const temporaryRoot = await mkdtemp4(join29(tmpdir4(), "windy-update-format-"));
|
|
9663
|
+
try {
|
|
9664
|
+
const stagedPaths = await stageInputs(temporaryRoot, inputs);
|
|
9665
|
+
for (let offset = 0;offset < stagedPaths.length; offset += 80) {
|
|
9666
|
+
await execute("bun", [
|
|
9667
|
+
"x",
|
|
9668
|
+
"oxfmt",
|
|
9669
|
+
"--write",
|
|
9670
|
+
`--config=${join29(result2.plan.projectDirectory, ".oxfmtrc.json")}`,
|
|
9671
|
+
...stagedPaths.slice(offset, offset + 80)
|
|
9672
|
+
], result2.plan.projectDirectory);
|
|
9673
|
+
}
|
|
9674
|
+
const hashes = plannedContentHashes(result2);
|
|
9675
|
+
let formattedGeneration = generationContent;
|
|
9676
|
+
for (const [path2, original] of inputs) {
|
|
9677
|
+
const formatted = await readFile22(safeTemporaryPath(temporaryRoot, path2));
|
|
9678
|
+
if (path2 === ".windy/generation.json") {
|
|
9679
|
+
formattedGeneration = formatted.toString();
|
|
9680
|
+
continue;
|
|
9681
|
+
}
|
|
9682
|
+
hashes.set(path2, hashContent(formatted));
|
|
9683
|
+
if (hashContent(formatted) !== hashContent(original)) {
|
|
9684
|
+
await writeProjectFile(path2, formatted);
|
|
9685
|
+
}
|
|
9686
|
+
}
|
|
9687
|
+
return {
|
|
9688
|
+
generationContent: formattedGeneration,
|
|
9689
|
+
hashes,
|
|
9690
|
+
status: "passed"
|
|
9691
|
+
};
|
|
9692
|
+
} finally {
|
|
9693
|
+
await rm8(temporaryRoot, { recursive: true, force: true });
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9696
|
+
function plannedContentHashes(result2) {
|
|
9697
|
+
return new Map(result2.plan.files.flatMap((file) => (file.action === "create" || file.action === "update") && file.content ? [[file.path, hashContent(file.content)]] : []));
|
|
9698
|
+
}
|
|
9699
|
+
async function stageInputs(temporaryRoot, inputs) {
|
|
9700
|
+
const paths = [];
|
|
9701
|
+
for (const [path2, content] of inputs) {
|
|
9702
|
+
const target = safeTemporaryPath(temporaryRoot, path2);
|
|
9703
|
+
await mkdir7(dirname7(target), { recursive: true });
|
|
9704
|
+
await writeFile11(target, content);
|
|
9705
|
+
paths.push(target);
|
|
9706
|
+
}
|
|
9707
|
+
return paths;
|
|
9708
|
+
}
|
|
9709
|
+
function safeTemporaryPath(root, path2) {
|
|
9710
|
+
const target = resolve6(root, path2);
|
|
9711
|
+
if (!target.startsWith(`${resolve6(root)}${sep4}`)) {
|
|
9712
|
+
throw new Error(`\u683C\u5F0F\u5316\u8DEF\u5F84\u8D8A\u51FA\u4E34\u65F6\u76EE\u5F55\uFF1A${path2}`);
|
|
9713
|
+
}
|
|
9714
|
+
return target;
|
|
9715
|
+
}
|
|
9716
|
+
|
|
9564
9717
|
// src/update/updater.ts
|
|
9565
9718
|
class DefaultStarterUpdater {
|
|
9566
9719
|
#artifacts;
|
|
@@ -9583,7 +9736,7 @@ class DefaultStarterUpdater {
|
|
|
9583
9736
|
}
|
|
9584
9737
|
return await applyTransaction(plan);
|
|
9585
9738
|
} catch (error) {
|
|
9586
|
-
await
|
|
9739
|
+
await rm9(plan.temporaryRoot, { recursive: true, force: true });
|
|
9587
9740
|
throw error;
|
|
9588
9741
|
}
|
|
9589
9742
|
}
|
|
@@ -9601,6 +9754,14 @@ class DefaultStarterUpdater {
|
|
|
9601
9754
|
});
|
|
9602
9755
|
await this.#execute("bun", ["install", "--force"], result2.plan.projectDirectory);
|
|
9603
9756
|
steps.push({ name: "bun install --force", status: "passed" });
|
|
9757
|
+
const stabilized = await stabilizeManagedContent(result2, this.#execute, async (path2, content) => {
|
|
9758
|
+
await writeOwnedTransactionFile(result2.plan.projectDirectory, path2, content, expectedForPath(result2, path2));
|
|
9759
|
+
replaceExpectations(result2, [expectationForContent(path2, content)]);
|
|
9760
|
+
});
|
|
9761
|
+
steps.push({
|
|
9762
|
+
name: "\u7A33\u5B9A Oxfmt \u4E0E\u53D7\u7BA1\u6587\u4EF6\u6E05\u5355",
|
|
9763
|
+
status: stabilized.status
|
|
9764
|
+
});
|
|
9604
9765
|
const verificationSnapshot = await captureOwnedTransactionExpectations(result2.plan.projectDirectory, result2.transactionOwnerToken, result2.backupEntries.map(({ path: path2 }) => path2));
|
|
9605
9766
|
const metadataPaths2 = new Set([
|
|
9606
9767
|
".windy/generation.json",
|
|
@@ -9610,7 +9771,7 @@ class DefaultStarterUpdater {
|
|
|
9610
9771
|
const plannedPaths = new Set(result2.plan.files.map(({ path: path2 }) => path2));
|
|
9611
9772
|
replaceExpectations(result2, verificationSnapshot.filter(({ path: path2 }) => !metadataPaths2.has(path2) && !plannedPaths.has(path2)));
|
|
9612
9773
|
verificationExpectationsFrozen = true;
|
|
9613
|
-
const packageJson = JSON.parse(await
|
|
9774
|
+
const packageJson = JSON.parse(await readFile23(join30(result2.plan.projectDirectory, "package.json"), "utf8"));
|
|
9614
9775
|
for (const name of ["lint", "typecheck", "test", "build"]) {
|
|
9615
9776
|
if (!packageJson.scripts?.[name]) {
|
|
9616
9777
|
steps.push({ name: `bun run ${name}`, status: "skipped" });
|
|
@@ -9619,11 +9780,11 @@ class DefaultStarterUpdater {
|
|
|
9619
9780
|
await this.#execute("bun", ["run", name], result2.plan.projectDirectory);
|
|
9620
9781
|
steps.push({ name: `bun run ${name}`, status: "passed" });
|
|
9621
9782
|
}
|
|
9622
|
-
const metadataExpectations = await finalize(result2);
|
|
9783
|
+
const metadataExpectations = await finalize(result2, stabilized);
|
|
9623
9784
|
const reportPath = `.windy/reports/${result2.plan.id}.md`;
|
|
9624
9785
|
const reportExpectation = await writeReport(result2, steps, reportPath);
|
|
9625
9786
|
replaceExpectations(result2, [...metadataExpectations, reportExpectation]);
|
|
9626
|
-
await
|
|
9787
|
+
await rm9(result2.plan.temporaryRoot, { recursive: true, force: true });
|
|
9627
9788
|
await this.#beforeTransactionFinalize?.({ result: result2, reportPath });
|
|
9628
9789
|
await this.#finalizeTransaction({
|
|
9629
9790
|
projectDirectory: result2.plan.projectDirectory,
|
|
@@ -9633,7 +9794,7 @@ class DefaultStarterUpdater {
|
|
|
9633
9794
|
});
|
|
9634
9795
|
return { updateId: result2.plan.id, status: "passed", steps, reportPath };
|
|
9635
9796
|
} catch (error) {
|
|
9636
|
-
await
|
|
9797
|
+
await rm9(result2.plan.temporaryRoot, { recursive: true, force: true });
|
|
9637
9798
|
if (error instanceof TransactionCommittedCleanupPendingError) {
|
|
9638
9799
|
throw error;
|
|
9639
9800
|
}
|
|
@@ -9659,16 +9820,15 @@ class DefaultStarterUpdater {
|
|
|
9659
9820
|
}
|
|
9660
9821
|
}
|
|
9661
9822
|
}
|
|
9662
|
-
async function finalize(result2) {
|
|
9823
|
+
async function finalize(result2, stabilized) {
|
|
9663
9824
|
const root = result2.plan.projectDirectory;
|
|
9664
|
-
const generationContent =
|
|
9665
|
-
`;
|
|
9825
|
+
const generationContent = stabilized.generationContent;
|
|
9666
9826
|
const generationExpectation = expectedForPath(result2, ".windy/generation.json");
|
|
9667
9827
|
await writeOwnedTransactionFile(root, ".windy/generation.json", generationContent, generationExpectation);
|
|
9668
9828
|
replaceExpectations(result2, [
|
|
9669
9829
|
expectationForContent(".windy/generation.json", generationContent)
|
|
9670
9830
|
]);
|
|
9671
|
-
const targetManifest = buildFinalManagedManifest(result2.plan, generationContent);
|
|
9831
|
+
const targetManifest = buildFinalManagedManifest(result2.plan, generationContent, stabilized.hashes);
|
|
9672
9832
|
await writeOwnedTransactionFile(root, ".windy/files.json", `${JSON.stringify(targetManifest, null, 2)}
|
|
9673
9833
|
`, expectedForPath(result2, ".windy/files.json"));
|
|
9674
9834
|
const manifestExpectation = expectationForContent(".windy/files.json", `${JSON.stringify(targetManifest, null, 2)}
|
|
@@ -9723,7 +9883,7 @@ async function runLifecycleCommand(args) {
|
|
|
9723
9883
|
if (command !== "doctor" && command !== "update" && command !== "reconcile" && command !== "sync-docker") {
|
|
9724
9884
|
return false;
|
|
9725
9885
|
}
|
|
9726
|
-
const projectDirectory =
|
|
9886
|
+
const projectDirectory = resolve7(readValue2(args, "--cwd") || process.cwd());
|
|
9727
9887
|
if (command === "sync-docker") {
|
|
9728
9888
|
const result2 = await planWebDockerfileInProject(projectDirectory, {
|
|
9729
9889
|
requireAnchors: true
|
|
@@ -9790,7 +9950,7 @@ async function runReconcile(args, projectDirectory) {
|
|
|
9790
9950
|
console.log(` unresolved ${item.path}\uFF08${item.reason}\uFF09`);
|
|
9791
9951
|
}
|
|
9792
9952
|
if (!args.includes("--apply")) {
|
|
9793
|
-
await
|
|
9953
|
+
await rm10(plan.temporaryRoot, { recursive: true, force: true });
|
|
9794
9954
|
console.log(`
|
|
9795
9955
|
\u6F14\u7EC3\u5B8C\u6210\uFF1A\u672A\u5199\u5165\u9879\u76EE\u6587\u4EF6\uFF1B\u4F7F\u7528 --apply \u4EC5\u63D0\u4EA4\u5BF9\u8D26\u5143\u6570\u636E`);
|
|
9796
9956
|
return;
|
|
@@ -9801,7 +9961,7 @@ async function runReconcile(args, projectDirectory) {
|
|
|
9801
9961
|
\u5BF9\u8D26\u5B8C\u6210\uFF1AProject Lock \u4ECD\u4E3A ${plan.sourceVersion}`);
|
|
9802
9962
|
console.log(`\u62A5\u544A\uFF1A${result2.reportPath}`);
|
|
9803
9963
|
} finally {
|
|
9804
|
-
await
|
|
9964
|
+
await rm10(plan.temporaryRoot, { recursive: true, force: true });
|
|
9805
9965
|
}
|
|
9806
9966
|
}
|
|
9807
9967
|
async function runUpdate(args, projectDirectory) {
|
|
@@ -9836,13 +9996,13 @@ async function runUpdate(args, projectDirectory) {
|
|
|
9836
9996
|
const plan = await updater.plan({ projectDirectory, targetVersion: target });
|
|
9837
9997
|
printPlan(plan);
|
|
9838
9998
|
if (args.includes("--dry-run")) {
|
|
9839
|
-
await
|
|
9999
|
+
await rm10(plan.temporaryRoot, { recursive: true, force: true });
|
|
9840
10000
|
console.log(`
|
|
9841
10001
|
\u6F14\u7EC3\u5B8C\u6210\uFF1A\u672A\u5199\u5165\u9879\u76EE\u6587\u4EF6`);
|
|
9842
10002
|
return;
|
|
9843
10003
|
}
|
|
9844
10004
|
if (plan.conflicts.length) {
|
|
9845
|
-
await
|
|
10005
|
+
await rm10(plan.temporaryRoot, { recursive: true, force: true });
|
|
9846
10006
|
throw new Error("\u5B58\u5728\u66F4\u65B0\u51B2\u7A81\uFF1B\u8BF7\u6309\u4E0A\u65B9\u6E05\u5355\u5904\u7406\u540E\u91CD\u65B0\u8FD0\u884C\uFF0C\u9879\u76EE\u672A\u88AB\u4FEE\u6539");
|
|
9847
10007
|
}
|
|
9848
10008
|
const result2 = await updater.apply(plan);
|
|
@@ -9927,28 +10087,28 @@ function compareVersions2(left, right) {
|
|
|
9927
10087
|
}
|
|
9928
10088
|
|
|
9929
10089
|
// src/module-schema/cli.ts
|
|
9930
|
-
import { resolve as
|
|
10090
|
+
import { resolve as resolve9 } from "path";
|
|
9931
10091
|
|
|
9932
10092
|
// src/module-schema/handoff.ts
|
|
9933
10093
|
import {
|
|
9934
10094
|
access as access2,
|
|
9935
10095
|
cp,
|
|
9936
10096
|
mkdir as mkdir8,
|
|
9937
|
-
mkdtemp as
|
|
9938
|
-
readFile as
|
|
10097
|
+
mkdtemp as mkdtemp5,
|
|
10098
|
+
readFile as readFile25,
|
|
9939
10099
|
readdir as readdir8,
|
|
9940
10100
|
rename,
|
|
9941
|
-
rm as
|
|
9942
|
-
writeFile as
|
|
10101
|
+
rm as rm11,
|
|
10102
|
+
writeFile as writeFile12
|
|
9943
10103
|
} from "fs/promises";
|
|
9944
|
-
import { dirname as
|
|
10104
|
+
import { dirname as dirname8, join as join31, relative as relative5 } from "path";
|
|
9945
10105
|
|
|
9946
10106
|
// src/module-schema/config.ts
|
|
9947
|
-
import { readFile as
|
|
9948
|
-
import { isAbsolute as isAbsolute2, relative as relative4, resolve as
|
|
10107
|
+
import { readFile as readFile24 } from "fs/promises";
|
|
10108
|
+
import { isAbsolute as isAbsolute2, relative as relative4, resolve as resolve8 } from "path";
|
|
9949
10109
|
async function readModuleSchemaLineageConfig(projectDirectory, configPath) {
|
|
9950
10110
|
const absolutePath = resolveProjectPath(projectDirectory, configPath);
|
|
9951
|
-
const parsed = JSON.parse(await
|
|
10111
|
+
const parsed = JSON.parse(await readFile24(absolutePath, "utf8"));
|
|
9952
10112
|
if (!isConfig(parsed)) {
|
|
9953
10113
|
throw new Error("Module schema lineage \u914D\u7F6E\u65E0\u6548");
|
|
9954
10114
|
}
|
|
@@ -9962,7 +10122,7 @@ async function readModuleSchemaLineageConfig(projectDirectory, configPath) {
|
|
|
9962
10122
|
function resolveProjectPath(projectDirectory, path2) {
|
|
9963
10123
|
if (isAbsolute2(path2))
|
|
9964
10124
|
throw new Error(`\u8DEF\u5F84\u5FC5\u987B\u76F8\u5BF9\u9879\u76EE\u6839\u76EE\u5F55\uFF1A${path2}`);
|
|
9965
|
-
const resolved =
|
|
10125
|
+
const resolved = resolve8(projectDirectory, path2);
|
|
9966
10126
|
const projectRelative = relative4(projectDirectory, resolved);
|
|
9967
10127
|
if (projectRelative.startsWith("..") || isAbsolute2(projectRelative)) {
|
|
9968
10128
|
throw new Error(`\u8DEF\u5F84\u8D8A\u51FA\u9879\u76EE\u6839\u76EE\u5F55\uFF1A${path2}`);
|
|
@@ -10072,7 +10232,7 @@ async function handoffModuleSchemaLineages(options) {
|
|
|
10072
10232
|
const stagedPlatform = await stagePlatformLineage(project, temporaryRoot, config, execute);
|
|
10073
10233
|
await installStagedLineages(project, temporaryRoot, config, stagedModules, stagedPlatform);
|
|
10074
10234
|
} finally {
|
|
10075
|
-
await
|
|
10235
|
+
await rm11(temporaryRoot, { recursive: true, force: true });
|
|
10076
10236
|
}
|
|
10077
10237
|
return {
|
|
10078
10238
|
moduleCount: config.modules.length,
|
|
@@ -10082,17 +10242,17 @@ async function handoffModuleSchemaLineages(options) {
|
|
|
10082
10242
|
async function stageModuleLineages(project, temporaryRoot, config, execute) {
|
|
10083
10243
|
const outputs = [];
|
|
10084
10244
|
for (const [index, module3] of config.modules.entries()) {
|
|
10085
|
-
const output =
|
|
10245
|
+
const output = join31(temporaryRoot, `module-${index}`);
|
|
10086
10246
|
await mkdir8(output, { recursive: true });
|
|
10087
|
-
const generatedConfig =
|
|
10247
|
+
const generatedConfig = join31(temporaryRoot, `module-${index}.config.ts`);
|
|
10088
10248
|
await writeDrizzleConfig(generatedConfig, project, module3.schema, relative5(temporaryRoot, output));
|
|
10089
10249
|
await execute(generatedConfig, temporaryRoot);
|
|
10090
10250
|
const sqlFiles = await listSqlFiles(output);
|
|
10091
10251
|
if (sqlFiles.length !== 1) {
|
|
10092
10252
|
throw new Error(`${module3.key} baseline \u5FC5\u987B\u6070\u597D\u751F\u6210\u4E00\u4E2A migration`);
|
|
10093
10253
|
}
|
|
10094
|
-
await
|
|
10095
|
-
await
|
|
10254
|
+
await writeFile12(join31(output, sqlFiles[0]), metadataOnlySql("module"));
|
|
10255
|
+
await writeFile12(join31(output, "lineage.json"), `${JSON.stringify({
|
|
10096
10256
|
schemaVersion: 1,
|
|
10097
10257
|
moduleKey: module3.key,
|
|
10098
10258
|
schema: module3.schema,
|
|
@@ -10106,25 +10266,25 @@ async function stageModuleLineages(project, temporaryRoot, config, execute) {
|
|
|
10106
10266
|
}
|
|
10107
10267
|
async function stagePlatformLineage(project, temporaryRoot, config, execute) {
|
|
10108
10268
|
const source = resolveProjectPath(project, config.platform.out);
|
|
10109
|
-
const output =
|
|
10269
|
+
const output = join31(temporaryRoot, "platform");
|
|
10110
10270
|
await cp(source, output, { recursive: true });
|
|
10111
10271
|
const before = new Set(await listSqlFiles(output));
|
|
10112
|
-
const generatedConfig =
|
|
10272
|
+
const generatedConfig = join31(temporaryRoot, "platform.config.ts");
|
|
10113
10273
|
await writeDrizzleConfig(generatedConfig, project, config.platform.schema, relative5(temporaryRoot, output));
|
|
10114
10274
|
await execute(generatedConfig, temporaryRoot);
|
|
10115
10275
|
const created = (await listSqlFiles(output)).filter((path2) => !before.has(path2));
|
|
10116
10276
|
if (created.length !== 1) {
|
|
10117
10277
|
throw new Error("\u5E73\u53F0 lineage handoff \u5FC5\u987B\u6070\u597D\u751F\u6210\u4E00\u4E2A migration");
|
|
10118
10278
|
}
|
|
10119
|
-
const sqlPath =
|
|
10279
|
+
const sqlPath = join31(output, created[0]);
|
|
10120
10280
|
const allowed = config.modules.flatMap(({ legacyPlatformTables }) => legacyPlatformTables);
|
|
10121
|
-
validatePlatformHandoffSql(await
|
|
10122
|
-
await
|
|
10281
|
+
validatePlatformHandoffSql(await readFile25(sqlPath, "utf8"), allowed);
|
|
10282
|
+
await writeFile12(sqlPath, metadataOnlySql("platform"));
|
|
10123
10283
|
return output;
|
|
10124
10284
|
}
|
|
10125
10285
|
async function installStagedLineages(project, temporaryRoot, config, stagedModules, stagedPlatform) {
|
|
10126
10286
|
const platform = resolveProjectPath(project, config.platform.out);
|
|
10127
|
-
const backup =
|
|
10287
|
+
const backup = join31(temporaryRoot, "platform-backup");
|
|
10128
10288
|
const installed = [];
|
|
10129
10289
|
await rename(platform, backup);
|
|
10130
10290
|
try {
|
|
@@ -10134,21 +10294,21 @@ async function installStagedLineages(project, temporaryRoot, config, stagedModul
|
|
|
10134
10294
|
if (await exists(output)) {
|
|
10135
10295
|
throw new Error(`${module3.key} lineage \u8F93\u51FA\u5DF2\u5B58\u5728\uFF0C\u7981\u6B62\u8986\u76D6`);
|
|
10136
10296
|
}
|
|
10137
|
-
await mkdir8(
|
|
10297
|
+
await mkdir8(dirname8(output), { recursive: true });
|
|
10138
10298
|
await rename(stagedModules[index], output);
|
|
10139
10299
|
installed.push(output);
|
|
10140
10300
|
}
|
|
10141
10301
|
} catch (error) {
|
|
10142
|
-
await
|
|
10302
|
+
await rm11(platform, { recursive: true, force: true });
|
|
10143
10303
|
await rename(backup, platform);
|
|
10144
10304
|
for (const output of installed)
|
|
10145
|
-
await
|
|
10305
|
+
await rm11(output, { recursive: true, force: true });
|
|
10146
10306
|
throw error;
|
|
10147
10307
|
}
|
|
10148
10308
|
}
|
|
10149
10309
|
async function writeDrizzleConfig(path2, project, schemas, out) {
|
|
10150
10310
|
const absoluteSchemas = schemas.map((schema) => resolveProjectPath(project, schema));
|
|
10151
|
-
await
|
|
10311
|
+
await writeFile12(path2, `import { defineConfig } from "drizzle-kit";
|
|
10152
10312
|
export default defineConfig(${JSON.stringify({
|
|
10153
10313
|
dialect: "postgresql",
|
|
10154
10314
|
schema: absoluteSchemas,
|
|
@@ -10171,9 +10331,9 @@ async function validateSchemaSources(project, config) {
|
|
|
10171
10331
|
}
|
|
10172
10332
|
}
|
|
10173
10333
|
async function createTemporaryRoot(project) {
|
|
10174
|
-
const windy =
|
|
10334
|
+
const windy = join31(project, ".windy");
|
|
10175
10335
|
await mkdir8(windy, { recursive: true });
|
|
10176
|
-
return await
|
|
10336
|
+
return await mkdtemp5(join31(windy, "module-schema-handoff-"));
|
|
10177
10337
|
}
|
|
10178
10338
|
async function listSqlFiles(root) {
|
|
10179
10339
|
return (await readdir8(root)).filter((path2) => path2.endsWith(".sql")).sort();
|
|
@@ -10203,7 +10363,7 @@ async function runModuleSchemaCommand(args) {
|
|
|
10203
10363
|
if (args[1] !== "handoff") {
|
|
10204
10364
|
throw new Error("\u5F53\u524D schema \u547D\u4EE4\u53EA\u652F\u6301 handoff");
|
|
10205
10365
|
}
|
|
10206
|
-
const projectDirectory =
|
|
10366
|
+
const projectDirectory = resolve9(readValue3(args, "--cwd") || process.cwd());
|
|
10207
10367
|
const result2 = await handoffModuleSchemaLineages({
|
|
10208
10368
|
projectDirectory,
|
|
10209
10369
|
configPath: readValue3(args, "--config")
|
package/package.json
CHANGED