create-windy 0.2.13 → 0.2.15

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 CHANGED
@@ -4011,7 +4011,9 @@ var recipes = [
4011
4011
  { id: "starter-0.2.9-to-0.2.10", from: "0.2.9", to: "0.2.10" },
4012
4012
  { id: "starter-0.2.10-to-0.2.11", from: "0.2.10", to: "0.2.11" },
4013
4013
  { id: "starter-0.2.11-to-0.2.12", from: "0.2.11", to: "0.2.12" },
4014
- { id: "starter-0.2.12-to-0.2.13", from: "0.2.12", to: "0.2.13" }
4014
+ { id: "starter-0.2.12-to-0.2.13", from: "0.2.12", to: "0.2.13" },
4015
+ { id: "starter-0.2.13-to-0.2.14", from: "0.2.13", to: "0.2.14" },
4016
+ { id: "starter-0.2.14-to-0.2.15", from: "0.2.14", to: "0.2.15" }
4015
4017
  ];
4016
4018
  function resolveRecipeChain(sourceVersion, targetVersion) {
4017
4019
  if (sourceVersion === targetVersion)
@@ -4102,6 +4104,32 @@ async function readProjectName2(projectDirectory) {
4102
4104
  import { access as access3, readFile as readFile13 } from "node:fs/promises";
4103
4105
  import { join as join14 } from "node:path";
4104
4106
 
4107
+ // src/update/known-repairs.ts
4108
+ var wrongTextVersions = new Set(["0.2.12", "0.2.13"]);
4109
+ var wrongExampleDescription = "创建时包含了 `work-order` 示例模块,用于演示 Module Manifest 接入;它不是生产工单产品,可以在正式开发前替换。";
4110
+ var correctCoreDescription = "创建时未选择 `work-order` 示例模块,当前项目只包含平台模块。";
4111
+ var wrongExampleRow = /^\|\s*示例工单\s*\|\s*已包含\s*\|$/m;
4112
+ var correctCoreRow = /^\|\s*示例工单\s*\|\s*未包含\s*\|$/m;
4113
+ function repairKnownDerivedFile(input) {
4114
+ if (input.path !== "README.md" || input.includeExample || !input.targetContent.includes(correctCoreDescription) || !correctCoreRow.test(input.targetContent)) {
4115
+ return;
4116
+ }
4117
+ const targetRow = input.targetContent.match(correctCoreRow)?.[0];
4118
+ if (!targetRow)
4119
+ return;
4120
+ if (input.sourceVersion === "0.2.14") {
4121
+ const currentRow = input.content.match(correctCoreRow)?.[0];
4122
+ if (input.content.includes(correctCoreDescription) && currentRow && currentRow !== targetRow) {
4123
+ return input.content.replace(correctCoreRow, targetRow);
4124
+ }
4125
+ return;
4126
+ }
4127
+ if (!wrongTextVersions.has(input.sourceVersion) || !input.content.includes(wrongExampleDescription) || !wrongExampleRow.test(input.content)) {
4128
+ return;
4129
+ }
4130
+ return input.content.replace(wrongExampleDescription, correctCoreDescription).replace(wrongExampleRow, targetRow);
4131
+ }
4132
+
4105
4133
  // src/update/merge.ts
4106
4134
  import { mkdtemp as mkdtemp2, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
4107
4135
  import { tmpdir as tmpdir2 } from "node:os";
@@ -4208,7 +4236,7 @@ async function createUpdatePlan(request, artifacts) {
4208
4236
  for (const path2 of [...paths].sort()) {
4209
4237
  if (metadataPaths.has(path2))
4210
4238
  continue;
4211
- const file = await planFile(path2, request.projectDirectory, artifactSet.baseDirectory, artifactSet.targetDirectory, sourceEntries.get(path2), targetEntries.get(path2));
4239
+ const file = await planFile(path2, request.projectDirectory, artifactSet.baseDirectory, artifactSet.targetDirectory, sourceEntries.get(path2), targetEntries.get(path2), provenance);
4212
4240
  if (oxcManagedPaths.has(path2) && file.reason === "客户已修改") {
4213
4241
  file.action = "preserve";
4214
4242
  delete file.conflict;
@@ -4231,13 +4259,23 @@ async function createUpdatePlan(request, artifacts) {
4231
4259
  temporaryRoot: artifactSet.temporaryRoot
4232
4260
  };
4233
4261
  }
4234
- async function planFile(path2, project, baseRoot, targetRoot, source, target) {
4262
+ async function planFile(path2, project, baseRoot, targetRoot, source, target, provenance) {
4235
4263
  const [ours, base, theirs] = await Promise.all([
4236
4264
  readOptional(join14(project, path2)),
4237
4265
  readOptional(join14(baseRoot, path2)),
4238
4266
  readOptional(join14(targetRoot, path2))
4239
4267
  ]);
4240
4268
  const ownership = target?.ownership || source?.ownership || classifyOwnership(path2);
4269
+ const repaired = ours && theirs && provenance ? repairKnownDerivedFile({
4270
+ path: path2,
4271
+ sourceVersion: provenance.windyVersion,
4272
+ includeExample: provenance.choices.includeExample,
4273
+ content: new TextDecoder().decode(ours),
4274
+ targetContent: new TextDecoder().decode(theirs)
4275
+ }) : undefined;
4276
+ if (repaired !== undefined) {
4277
+ return ready(path2, ownership, "update", "修复已发布版本的模块选择派生文本", new TextEncoder().encode(repaired));
4278
+ }
4241
4279
  if (path2.startsWith("packages/database/drizzle/") && path2.endsWith(".sql")) {
4242
4280
  if (source && !target)
4243
4281
  return conflict(path2, ownership, "已发布 migration 不可删除");
@@ -4384,9 +4422,22 @@ class DefaultStarterUpdater {
4384
4422
  }
4385
4423
  async function finalize(result) {
4386
4424
  const root = result.plan.projectDirectory;
4387
- await writeFile11(join15(root, ".windy/generation.json"), `${JSON.stringify(result.plan.targetProvenance, null, 2)}
4388
- `);
4389
- await writeFile11(join15(root, ".windy/files.json"), `${JSON.stringify(result.plan.targetManifest, null, 2)}
4425
+ const generationContent = `${JSON.stringify(result.plan.targetProvenance, null, 2)}
4426
+ `;
4427
+ await writeFile11(join15(root, ".windy/generation.json"), generationContent);
4428
+ const refreshedPaths = new Set([
4429
+ ".windy/generation.json",
4430
+ ...result.plan.files.filter(({ action }) => action === "create" || action === "update").map(({ path: path2 }) => path2)
4431
+ ]);
4432
+ const refreshedHashes = new Map(await Promise.all([...refreshedPaths].map(async (path2) => [path2, hashContent(await readFile14(join15(root, path2)))])));
4433
+ const targetManifest = {
4434
+ ...result.plan.targetManifest,
4435
+ files: result.plan.targetManifest.files.map((entry) => ({
4436
+ ...entry,
4437
+ hash: refreshedHashes.get(entry.path) ?? entry.hash
4438
+ }))
4439
+ };
4440
+ await writeFile11(join15(root, ".windy/files.json"), `${JSON.stringify(targetManifest, null, 2)}
4390
4441
  `);
4391
4442
  }
4392
4443
  async function writeReport(result, steps, relativePath2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-windy",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "创建单组织、单租户、私有部署优先的 Windy 企业 Dashboard Starter",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "templateCommit": "51ba8808a74c2143803d3ec0584d2a35ba1c18e3",
4
- "generatorVersion": "0.2.13",
3
+ "templateCommit": "04fdbd359b0f4159d1e3fe6c1a2ba148f2be73ce",
4
+ "generatorVersion": "0.2.15",
5
5
  "modules": [
6
6
  {
7
7
  "name": "system",