create-windy 0.2.12 → 0.2.14

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
@@ -1849,11 +1849,12 @@ async function generateProject(input) {
1849
1849
  validateProjectName(input.projectName);
1850
1850
  await assertTargetAvailable(input.targetDirectory);
1851
1851
  await mkdir3(input.targetDirectory, { recursive: true });
1852
- const includeExample = input.includeExample ?? true;
1852
+ const requestedIncludeExample = input.includeExample ?? true;
1853
1853
  const includeOxc = input.includeOxc ?? true;
1854
1854
  const projectLicense = input.projectLicense ?? "UNLICENSED";
1855
1855
  const templateMetadata = await readTemplateMetadata(input.sourceRoot);
1856
- const selectedModules = input.selectedModules ?? templateMetadata.modules.filter(({ name }) => includeExample || name !== "work-order").map(({ name }) => name);
1856
+ const selectedModules = input.selectedModules ?? templateMetadata.modules.filter(({ name }) => requestedIncludeExample || name !== "work-order").map(({ name }) => name);
1857
+ const includeExample = selectedModules.includes("work-order");
1857
1858
  for (const relativePath2 of generationTemplatePaths(true, includeOxc)) {
1858
1859
  await copyTree(await resolveTemplateSource(input.sourceRoot, relativePath2), join9(input.targetDirectory, relativePath2));
1859
1860
  }
@@ -4009,7 +4010,9 @@ var recipes = [
4009
4010
  { id: "starter-0.2.8-to-0.2.9", from: "0.2.8", to: "0.2.9" },
4010
4011
  { id: "starter-0.2.9-to-0.2.10", from: "0.2.9", to: "0.2.10" },
4011
4012
  { id: "starter-0.2.10-to-0.2.11", from: "0.2.10", to: "0.2.11" },
4012
- { id: "starter-0.2.11-to-0.2.12", from: "0.2.11", to: "0.2.12" }
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" },
4015
+ { id: "starter-0.2.13-to-0.2.14", from: "0.2.13", to: "0.2.14" }
4013
4016
  ];
4014
4017
  function resolveRecipeChain(sourceVersion, targetVersion) {
4015
4018
  if (sourceVersion === targetVersion)
@@ -4053,6 +4056,7 @@ class PublishedArtifactProvider {
4053
4056
  targetDirectory,
4054
4057
  projectName,
4055
4058
  selectedModules: provenance.modules.map(({ name }) => name),
4059
+ includeExample: provenance.choices.includeExample,
4056
4060
  includeOxc: provenance.choices.includeOxc,
4057
4061
  projectLicense: provenance.legalLicense,
4058
4062
  licenseHolder: provenance.legalLicense === "MIT" ? "Windy project owner" : undefined,
@@ -4099,6 +4103,22 @@ async function readProjectName2(projectDirectory) {
4099
4103
  import { access as access3, readFile as readFile13 } from "node:fs/promises";
4100
4104
  import { join as join14 } from "node:path";
4101
4105
 
4106
+ // src/update/known-repairs.ts
4107
+ var affectedVersions = new Set(["0.2.12", "0.2.13"]);
4108
+ var wrongExampleDescription = "创建时包含了 `work-order` 示例模块,用于演示 Module Manifest 接入;它不是生产工单产品,可以在正式开发前替换。";
4109
+ var correctCoreDescription = "创建时未选择 `work-order` 示例模块,当前项目只包含平台模块。";
4110
+ var wrongExampleRow = /^\|\s*示例工单\s*\|\s*已包含\s*\|$/m;
4111
+ var correctCoreRow = /^\|\s*示例工单\s*\|\s*未包含\s*\|$/m;
4112
+ function repairKnownDerivedFile(input) {
4113
+ if (input.path !== "README.md" || input.includeExample || !affectedVersions.has(input.sourceVersion) || !input.content.includes(wrongExampleDescription) || !wrongExampleRow.test(input.content) || !input.targetContent.includes(correctCoreDescription) || !correctCoreRow.test(input.targetContent)) {
4114
+ return;
4115
+ }
4116
+ const targetRow = input.targetContent.match(correctCoreRow)?.[0];
4117
+ if (!targetRow)
4118
+ return;
4119
+ return input.content.replace(wrongExampleDescription, correctCoreDescription).replace(wrongExampleRow, targetRow);
4120
+ }
4121
+
4102
4122
  // src/update/merge.ts
4103
4123
  import { mkdtemp as mkdtemp2, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
4104
4124
  import { tmpdir as tmpdir2 } from "node:os";
@@ -4205,7 +4225,7 @@ async function createUpdatePlan(request, artifacts) {
4205
4225
  for (const path2 of [...paths].sort()) {
4206
4226
  if (metadataPaths.has(path2))
4207
4227
  continue;
4208
- const file = await planFile(path2, request.projectDirectory, artifactSet.baseDirectory, artifactSet.targetDirectory, sourceEntries.get(path2), targetEntries.get(path2));
4228
+ const file = await planFile(path2, request.projectDirectory, artifactSet.baseDirectory, artifactSet.targetDirectory, sourceEntries.get(path2), targetEntries.get(path2), provenance);
4209
4229
  if (oxcManagedPaths.has(path2) && file.reason === "客户已修改") {
4210
4230
  file.action = "preserve";
4211
4231
  delete file.conflict;
@@ -4228,13 +4248,23 @@ async function createUpdatePlan(request, artifacts) {
4228
4248
  temporaryRoot: artifactSet.temporaryRoot
4229
4249
  };
4230
4250
  }
4231
- async function planFile(path2, project, baseRoot, targetRoot, source, target) {
4251
+ async function planFile(path2, project, baseRoot, targetRoot, source, target, provenance) {
4232
4252
  const [ours, base, theirs] = await Promise.all([
4233
4253
  readOptional(join14(project, path2)),
4234
4254
  readOptional(join14(baseRoot, path2)),
4235
4255
  readOptional(join14(targetRoot, path2))
4236
4256
  ]);
4237
4257
  const ownership = target?.ownership || source?.ownership || classifyOwnership(path2);
4258
+ const repaired = ours && theirs && provenance ? repairKnownDerivedFile({
4259
+ path: path2,
4260
+ sourceVersion: provenance.windyVersion,
4261
+ includeExample: provenance.choices.includeExample,
4262
+ content: new TextDecoder().decode(ours),
4263
+ targetContent: new TextDecoder().decode(theirs)
4264
+ }) : undefined;
4265
+ if (repaired !== undefined) {
4266
+ return ready(path2, ownership, "update", "修复已发布版本的模块选择派生文本", new TextEncoder().encode(repaired));
4267
+ }
4238
4268
  if (path2.startsWith("packages/database/drizzle/") && path2.endsWith(".sql")) {
4239
4269
  if (source && !target)
4240
4270
  return conflict(path2, ownership, "已发布 migration 不可删除");
@@ -4381,9 +4411,14 @@ class DefaultStarterUpdater {
4381
4411
  }
4382
4412
  async function finalize(result) {
4383
4413
  const root = result.plan.projectDirectory;
4384
- await writeFile11(join15(root, ".windy/generation.json"), `${JSON.stringify(result.plan.targetProvenance, null, 2)}
4385
- `);
4386
- await writeFile11(join15(root, ".windy/files.json"), `${JSON.stringify(result.plan.targetManifest, null, 2)}
4414
+ const generationContent = `${JSON.stringify(result.plan.targetProvenance, null, 2)}
4415
+ `;
4416
+ await writeFile11(join15(root, ".windy/generation.json"), generationContent);
4417
+ const targetManifest = {
4418
+ ...result.plan.targetManifest,
4419
+ files: result.plan.targetManifest.files.map((entry) => entry.path === ".windy/generation.json" ? { ...entry, hash: hashContent(generationContent) } : entry)
4420
+ };
4421
+ await writeFile11(join15(root, ".windy/files.json"), `${JSON.stringify(targetManifest, null, 2)}
4387
4422
  `);
4388
4423
  }
4389
4424
  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.12",
3
+ "version": "0.2.14",
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": "8b610ccf38a29d887666d0c7f4730b84a3334027",
4
- "generatorVersion": "0.2.12",
3
+ "templateCommit": "3086f275efa558dab15015be61bc93e10968b60a",
4
+ "generatorVersion": "0.2.14",
5
5
  "modules": [
6
6
  {
7
7
  "name": "system",