create-windy 0.10.0 → 0.10.1

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
@@ -9012,7 +9012,8 @@ var recipes = [
9012
9012
  { id: "starter-0.8.2-to-0.8.3", from: "0.8.2", to: "0.8.3" },
9013
9013
  { id: "starter-0.8.3-to-0.9.0", from: "0.8.3", to: "0.9.0" },
9014
9014
  { id: "starter-0.9.0-to-0.9.1", from: "0.9.0", to: "0.9.1" },
9015
- { id: "starter-0.9.1-to-0.10.0", from: "0.9.1", to: "0.10.0" }
9015
+ { id: "starter-0.9.1-to-0.10.0", from: "0.9.1", to: "0.10.0" },
9016
+ { id: "starter-0.10.0-to-0.10.1", from: "0.10.0", to: "0.10.1" }
9016
9017
  ];
9017
9018
  function resolveRecipeChain(sourceVersion, targetVersion) {
9018
9019
  if (compareVersions2(sourceVersion, minimumSupportedUpdateVersion) < 0) {
@@ -10975,11 +10976,64 @@ async function readJson(path2) {
10975
10976
  return JSON.parse(await readFile19(path2, "utf8"));
10976
10977
  }
10977
10978
 
10979
+ // src/update/migration-snapshot.ts
10980
+ function canonicalSnapshot(value) {
10981
+ return JSON.stringify(canonicalize(value, true));
10982
+ }
10983
+ function canonicalize(value, root = false) {
10984
+ if (Array.isArray(value))
10985
+ return value.map((item) => canonicalize(item));
10986
+ if (!value || typeof value !== "object")
10987
+ return value;
10988
+ 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)]));
10989
+ }
10990
+
10991
+ // src/update/migration-adoption-equivalence.ts
10992
+ var migrationName = "durable_job_lease_snapshot_lookup";
10993
+ var tableKey = "public.durable_job_leases";
10994
+ var indexName = "idx_durable_job_leases_job_acquired";
10995
+ var targetSql = 'CREATE INDEX "idx_durable_job_leases_job_acquired" ON "durable_job_leases" USING btree ("job_id","acquired_at");';
10996
+ var projectSql = `CREATE INDEX IF NOT EXISTS "idx_durable_job_leases_job_acquired" ON "durable_job_leases" USING btree ("job_id","acquired_at");
10997
+ `;
10998
+ var indexDefinition = {
10999
+ name: indexName,
11000
+ columns: ["job_id", "acquired_at"].map((expression) => ({
11001
+ expression,
11002
+ isExpression: false,
11003
+ asc: true,
11004
+ nulls: "last"
11005
+ })),
11006
+ isUnique: false,
11007
+ concurrently: false,
11008
+ method: "btree",
11009
+ with: {}
11010
+ };
11011
+ function isReviewedMigrationEquivalent(input) {
11012
+ return input.name === migrationName && hashContent(input.targetSql) === hashContent(targetSql) && hashContent(input.projectSql) === hashContent(projectSql) && isExactIndexAddition(input.targetBefore, input.targetAfter) && isExactIndexAddition(input.projectBefore, input.projectAfter);
11013
+ }
11014
+ function isExactIndexAddition(before, after) {
11015
+ if (before.version !== "7" || after.version !== "7" || before.dialect !== "postgresql" || after.dialect !== "postgresql")
11016
+ return false;
11017
+ const expected = structuredClone(before);
11018
+ if (!isRecord(expected.tables))
11019
+ return false;
11020
+ const table = expected.tables[tableKey];
11021
+ if (!isRecord(table) || table.name !== "durable_job_leases" || !isRecord(table.indexes))
11022
+ return false;
11023
+ if (Object.hasOwn(table.indexes, indexName))
11024
+ return false;
11025
+ table.indexes[indexName] = indexDefinition;
11026
+ return canonicalSnapshot(expected) === canonicalSnapshot(after);
11027
+ }
11028
+ function isRecord(value) {
11029
+ return !!value && typeof value === "object" && !Array.isArray(value);
11030
+ }
11031
+
10978
11032
  // src/update/snapshot-delta.ts
10979
11033
  function applySnapshotDelta(before, after, current, path2, conflicts, conflictPath) {
10980
11034
  if (deepEqual(before, after))
10981
11035
  return structuredClone(current);
10982
- if (!isRecord(before) || !isRecord(after) || !isRecord(current)) {
11036
+ if (!isRecord2(before) || !isRecord2(after) || !isRecord2(current)) {
10983
11037
  if (deepEqual(current, before) || deepEqual(current, after)) {
10984
11038
  return structuredClone(after);
10985
11039
  }
@@ -11013,7 +11067,7 @@ function applySnapshotDelta(before, after, current, path2, conflicts, conflictPa
11013
11067
  }
11014
11068
  return merged;
11015
11069
  }
11016
- function isRecord(value) {
11070
+ function isRecord2(value) {
11017
11071
  return !!value && typeof value === "object" && !Array.isArray(value);
11018
11072
  }
11019
11073
  function deepEqual(left, right) {
@@ -11041,8 +11095,8 @@ async function inspectPreexistingMigrationAdoptions(input) {
11041
11095
  const projectSqlPath = `${drizzleRoot}/${projectEntry.tag}.sql`;
11042
11096
  const projectSnapshotPath = snapshotPath(projectEntry.tag);
11043
11097
  const [
11044
- targetSql,
11045
- projectSql,
11098
+ targetSql2,
11099
+ projectSql2,
11046
11100
  targetBefore,
11047
11101
  targetAfter,
11048
11102
  projectBeforeBytes,
@@ -11055,15 +11109,16 @@ async function inspectPreexistingMigrationAdoptions(input) {
11055
11109
  readProjectFile(input, snapshotPath(previousProject.tag)),
11056
11110
  readProjectFile(input, projectSnapshotPath)
11057
11111
  ]);
11058
- if (!projectSql || !projectBeforeBytes || !projectAfterBytes) {
11112
+ if (!projectSql2 || !projectBeforeBytes || !projectAfterBytes) {
11059
11113
  conflicts.push(`${journalPath}\uFF1A\u65E0\u6CD5\u91C7\u7EB3\u73B0\u6709\u5E73\u53F0 migration ${name}\uFF0C\u9879\u76EE migration \u6587\u4EF6\u4E0D\u5B8C\u6574`);
11060
11114
  continue;
11061
11115
  }
11062
11116
  const projectBefore = decodeSnapshot(projectBeforeBytes);
11063
11117
  const projectAfter = decodeSnapshot(projectAfterBytes);
11064
11118
  const reason = validateAdoption({
11065
- targetSql,
11066
- projectSql,
11119
+ name,
11120
+ targetSql: targetSql2,
11121
+ projectSql: projectSql2,
11067
11122
  targetBefore,
11068
11123
  targetAfter,
11069
11124
  projectBefore,
@@ -11076,19 +11131,22 @@ async function inspectPreexistingMigrationAdoptions(input) {
11076
11131
  adoptions.push({
11077
11132
  sqlPath: projectSqlPath,
11078
11133
  snapshotPath: projectSnapshotPath,
11079
- sql: projectSql,
11134
+ sql: projectSql2,
11080
11135
  snapshot: projectAfterBytes
11081
11136
  });
11082
11137
  }
11083
11138
  return { adoptions, conflicts };
11084
11139
  }
11085
11140
  function validateAdoption(input) {
11086
- if (!equalBytes(input.targetSql, input.projectSql)) {
11087
- return "SQL \u5185\u5BB9\u4E0D\u4E00\u81F4";
11141
+ if (typeof input.targetBefore.id !== "string" || typeof input.targetAfter.id !== "string" || !input.targetBefore.id || !input.targetAfter.id || input.targetAfter.id === input.targetBefore.id || input.targetAfter.prevId !== input.targetBefore.id) {
11142
+ return "\u76EE\u6807 snapshot lineage \u4E0D\u8FDE\u7EED";
11088
11143
  }
11089
- if (input.projectAfter.prevId !== input.projectBefore.id) {
11144
+ if (typeof input.projectBefore.id !== "string" || typeof input.projectAfter.id !== "string" || !input.projectBefore.id || !input.projectAfter.id || input.projectAfter.id === input.projectBefore.id || input.projectAfter.prevId !== input.projectBefore.id) {
11090
11145
  return "\u9879\u76EE snapshot lineage \u4E0D\u8FDE\u7EED";
11091
11146
  }
11147
+ if (!equalBytes(input.targetSql, input.projectSql) && !isReviewedMigrationEquivalent(input)) {
11148
+ return "SQL \u5185\u5BB9\u4E0D\u4E00\u81F4\u6216\u672A\u6EE1\u8DB3\u5DF2\u5BA1\u6838\u7B49\u4EF7\u89C4\u5219";
11149
+ }
11092
11150
  const deltaConflicts = [];
11093
11151
  const expected = applySnapshotDelta(input.targetBefore, input.targetAfter, input.projectBefore, [], deltaConflicts, journalPath);
11094
11152
  if (deltaConflicts.length || canonicalSnapshot(expected) !== canonicalSnapshot(input.projectAfter)) {
@@ -11101,16 +11159,6 @@ function decodeSnapshot(content) {
11101
11159
  function equalBytes(left, right) {
11102
11160
  return left.byteLength === right.byteLength && left.every((value, index) => value === right[index]);
11103
11161
  }
11104
- function canonicalSnapshot(value) {
11105
- return JSON.stringify(canonicalize(value, true));
11106
- }
11107
- function canonicalize(value, root = false) {
11108
- if (Array.isArray(value))
11109
- return value.map((item) => canonicalize(item));
11110
- if (!value || typeof value !== "object")
11111
- return value;
11112
- 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)]));
11113
- }
11114
11162
 
11115
11163
  // src/update/migration-reconciler.ts
11116
11164
  async function reconcileDrizzleMigrations(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-windy",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
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": "30a73d57ac4b83d1bee4bf412be7f6abbdc351f8",
4
- "generatorVersion": "0.10.0",
3
+ "templateCommit": "266b77d1fad69f8cfa00f96fc09c7b494c1dc71d",
4
+ "generatorVersion": "0.10.1",
5
5
  "modules": [
6
6
  {
7
7
  "name": "system",