@windrun-huaiin/dev-scripts 14.1.0 → 14.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"diaomao-update.d.ts","sourceRoot":"","sources":["../../src/commands/diaomao-update.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAoN7D,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,GAAG,GAAE,MAA6D,GACjE,OAAO,CAAC,MAAM,CAAC,CAyKjB"}
1
+ {"version":3,"file":"diaomao-update.d.ts","sourceRoot":"","sources":["../../src/commands/diaomao-update.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAgT7D,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,GAAG,GAAE,MAA6D,GACjE,OAAO,CAAC,MAAM,CAAC,CA+MjB"}
@@ -3,6 +3,7 @@
3
3
  var fs = require('fs');
4
4
  var path = require('path');
5
5
  var https = require('https');
6
+ var child_process = require('child_process');
6
7
  var yaml = require('yaml');
7
8
  var semver = require('semver');
8
9
 
@@ -12,6 +13,14 @@ const DEPENDENCY_SECTIONS = [
12
13
  'peerDependencies',
13
14
  'optionalDependencies'
14
15
  ];
16
+ const UNKNOWN_VERSION = 'UNKNOWN';
17
+ const NPM_TARGET_PACKAGES = [
18
+ '@windrun-huaiin/base-ui',
19
+ '@windrun-huaiin/lib',
20
+ '@windrun-huaiin/third-ui',
21
+ '@windrun-huaiin/backend-core',
22
+ '@windrun-huaiin/dev-scripts'
23
+ ];
15
24
  function fetchText(url) {
16
25
  return new Promise((resolve, reject) => {
17
26
  const request = https.get(url, (response) => {
@@ -59,17 +68,31 @@ function stripProtocolPrefix(version) {
59
68
  }
60
69
  return version;
61
70
  }
71
+ function isTagVersion(version) {
72
+ return version === 'latest';
73
+ }
74
+ function getComparableMinVersion(version) {
75
+ try {
76
+ return semver.minVersion(version);
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
62
82
  function compareVersionSpecs(currentVersion, targetVersion) {
83
+ const normalizedCurrent = stripProtocolPrefix(currentVersion);
84
+ const normalizedTarget = stripProtocolPrefix(targetVersion);
85
+ if (isTagVersion(normalizedCurrent) || isTagVersion(normalizedTarget)) {
86
+ return 'uncomparable';
87
+ }
63
88
  if (currentVersion === targetVersion) {
64
89
  return 'same';
65
90
  }
66
- const normalizedCurrent = stripProtocolPrefix(currentVersion);
67
- const normalizedTarget = stripProtocolPrefix(targetVersion);
68
91
  if (normalizedCurrent === normalizedTarget) {
69
92
  return 'same';
70
93
  }
71
- const currentMin = semver.minVersion(normalizedCurrent);
72
- const targetMin = semver.minVersion(normalizedTarget);
94
+ const currentMin = getComparableMinVersion(normalizedCurrent);
95
+ const targetMin = getComparableMinVersion(normalizedTarget);
73
96
  if (currentMin && targetMin) {
74
97
  const comparison = semver.compare(currentMin, targetMin);
75
98
  if (comparison > 0) {
@@ -80,7 +103,7 @@ function compareVersionSpecs(currentVersion, targetVersion) {
80
103
  }
81
104
  return 'update';
82
105
  }
83
- return 'update';
106
+ return 'uncomparable';
84
107
  }
85
108
  function extractCatalog(workspaceContent) {
86
109
  const parsed = yaml.parse(workspaceContent);
@@ -157,6 +180,49 @@ function printSkipDetails(skipRows, compactLog) {
157
180
  console.log('\nSkipped:');
158
181
  console.log(renderTable(skipRows, ['Package', 'Before', 'After', 'Reason']));
159
182
  }
183
+ function resolveTargetVersions(remoteCatalog, allowedPackages, compactLog) {
184
+ const resolvedTargets = {};
185
+ const npmPackagesToResolve = NPM_TARGET_PACKAGES.filter((packageName) => allowedPackages.includes(packageName));
186
+ for (const [packageName, version] of Object.entries(remoteCatalog)) {
187
+ resolvedTargets[packageName] = {
188
+ version,
189
+ source: 'catalog'
190
+ };
191
+ }
192
+ for (const packageName of npmPackagesToResolve) {
193
+ const command = `npm view ${packageName} version`;
194
+ if (!compactLog) {
195
+ console.log(`[diaomao-update] resolving via npm: ${command}`);
196
+ }
197
+ try {
198
+ const version = child_process.execSync(command, {
199
+ encoding: 'utf8',
200
+ stdio: ['ignore', 'pipe', 'pipe']
201
+ }).trim() || UNKNOWN_VERSION;
202
+ resolvedTargets[packageName] = {
203
+ version,
204
+ source: 'npm'
205
+ };
206
+ if (!compactLog) {
207
+ console.log(`[diaomao-update] resolved ${packageName}: ${version}`);
208
+ }
209
+ }
210
+ catch (error) {
211
+ resolvedTargets[packageName] = {
212
+ version: UNKNOWN_VERSION,
213
+ source: 'npm'
214
+ };
215
+ if (!compactLog) {
216
+ const stderr = error instanceof Error && 'stderr' in error && typeof error.stderr === 'string'
217
+ ? error.stderr.trim()
218
+ : String(error);
219
+ console.log(`[diaomao-update] resolved ${packageName}: ${UNKNOWN_VERSION}`);
220
+ console.log(`[diaomao-update] npm query failed for ${packageName}: ${stderr || 'unknown error'}`);
221
+ }
222
+ }
223
+ }
224
+ return resolvedTargets;
225
+ }
160
226
  async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? process.cwd() : '.') {
161
227
  const updateConfig = config.diaomaoUpdate || {};
162
228
  const sourceUrl = updateConfig.sourceUrl || '';
@@ -179,12 +245,14 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
179
245
  console.log(`Reading update source: ${sourceUrl}`);
180
246
  const remoteWorkspaceContent = await fetchText(sourceUrl);
181
247
  const remoteCatalog = extractCatalog(remoteWorkspaceContent);
248
+ const resolvedTargets = resolveTargetVersions(remoteCatalog, allowedPackages, compactLog);
182
249
  const updatedRows = [];
183
250
  const skipRows = [];
184
251
  let packageJsonChanged = false;
185
252
  let workspaceChanged = false;
186
253
  for (const packageName of allowedPackages) {
187
- const targetVersion = remoteCatalog[packageName];
254
+ const resolvedTarget = resolvedTargets[packageName];
255
+ const targetVersion = resolvedTarget?.version;
188
256
  if (!targetVersion) {
189
257
  continue;
190
258
  }
@@ -235,6 +303,15 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
235
303
  });
236
304
  continue;
237
305
  }
306
+ if (decision === 'uncomparable') {
307
+ skipRows.push({
308
+ packageName,
309
+ currentVersion: localCatalogVersion,
310
+ targetVersion,
311
+ reason: 'skipped-uncomparable'
312
+ });
313
+ continue;
314
+ }
238
315
  localCatalog[packageName] = targetVersion;
239
316
  workspaceChanged = true;
240
317
  updatedRows.push({
@@ -242,6 +319,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
242
319
  currentVersion: localCatalogVersion,
243
320
  targetVersion
244
321
  });
322
+ if (!compactLog) {
323
+ console.log(`[diaomao-update] updated ${packageName} from ${localCatalogVersion} to ${targetVersion} (source: ${resolvedTarget.source})`);
324
+ }
245
325
  continue;
246
326
  }
247
327
  const decision = compareVersionSpecs(currentSpecifier, targetVersion);
@@ -263,6 +343,15 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
263
343
  });
264
344
  continue;
265
345
  }
346
+ if (decision === 'uncomparable') {
347
+ skipRows.push({
348
+ packageName,
349
+ currentVersion: currentSpecifier,
350
+ targetVersion,
351
+ reason: 'skipped-uncomparable'
352
+ });
353
+ continue;
354
+ }
266
355
  dependencies[packageName] = targetVersion;
267
356
  packageJsonChanged = true;
268
357
  updatedRows.push({
@@ -270,6 +359,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
270
359
  currentVersion: currentSpecifier,
271
360
  targetVersion
272
361
  });
362
+ if (!compactLog) {
363
+ console.log(`[diaomao-update] updated ${packageName} from ${currentSpecifier} to ${targetVersion} (source: ${resolvedTarget.source})`);
364
+ }
273
365
  }
274
366
  if (!matched) {
275
367
  skipRows.push({
@@ -298,6 +390,13 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
298
390
  console.log('');
299
391
  console.log(`Updated ${updatedRows.length} package version(s).`);
300
392
  printSkipDetails(skipRows, compactLog);
393
+ if (updatedRows.length > 0) {
394
+ console.log('\n执行 pnpm install中...');
395
+ child_process.execSync('pnpm install', {
396
+ cwd,
397
+ stdio: 'inherit'
398
+ });
399
+ }
301
400
  return 0;
302
401
  }
303
402
 
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import https from 'https';
4
+ import { execSync } from 'child_process';
4
5
  import { parse, stringify } from 'yaml';
5
6
  import semver from 'semver';
6
7
 
@@ -10,6 +11,14 @@ const DEPENDENCY_SECTIONS = [
10
11
  'peerDependencies',
11
12
  'optionalDependencies'
12
13
  ];
14
+ const UNKNOWN_VERSION = 'UNKNOWN';
15
+ const NPM_TARGET_PACKAGES = [
16
+ '@windrun-huaiin/base-ui',
17
+ '@windrun-huaiin/lib',
18
+ '@windrun-huaiin/third-ui',
19
+ '@windrun-huaiin/backend-core',
20
+ '@windrun-huaiin/dev-scripts'
21
+ ];
13
22
  function fetchText(url) {
14
23
  return new Promise((resolve, reject) => {
15
24
  const request = https.get(url, (response) => {
@@ -57,17 +66,31 @@ function stripProtocolPrefix(version) {
57
66
  }
58
67
  return version;
59
68
  }
69
+ function isTagVersion(version) {
70
+ return version === 'latest';
71
+ }
72
+ function getComparableMinVersion(version) {
73
+ try {
74
+ return semver.minVersion(version);
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ }
60
80
  function compareVersionSpecs(currentVersion, targetVersion) {
81
+ const normalizedCurrent = stripProtocolPrefix(currentVersion);
82
+ const normalizedTarget = stripProtocolPrefix(targetVersion);
83
+ if (isTagVersion(normalizedCurrent) || isTagVersion(normalizedTarget)) {
84
+ return 'uncomparable';
85
+ }
61
86
  if (currentVersion === targetVersion) {
62
87
  return 'same';
63
88
  }
64
- const normalizedCurrent = stripProtocolPrefix(currentVersion);
65
- const normalizedTarget = stripProtocolPrefix(targetVersion);
66
89
  if (normalizedCurrent === normalizedTarget) {
67
90
  return 'same';
68
91
  }
69
- const currentMin = semver.minVersion(normalizedCurrent);
70
- const targetMin = semver.minVersion(normalizedTarget);
92
+ const currentMin = getComparableMinVersion(normalizedCurrent);
93
+ const targetMin = getComparableMinVersion(normalizedTarget);
71
94
  if (currentMin && targetMin) {
72
95
  const comparison = semver.compare(currentMin, targetMin);
73
96
  if (comparison > 0) {
@@ -78,7 +101,7 @@ function compareVersionSpecs(currentVersion, targetVersion) {
78
101
  }
79
102
  return 'update';
80
103
  }
81
- return 'update';
104
+ return 'uncomparable';
82
105
  }
83
106
  function extractCatalog(workspaceContent) {
84
107
  const parsed = parse(workspaceContent);
@@ -155,6 +178,49 @@ function printSkipDetails(skipRows, compactLog) {
155
178
  console.log('\nSkipped:');
156
179
  console.log(renderTable(skipRows, ['Package', 'Before', 'After', 'Reason']));
157
180
  }
181
+ function resolveTargetVersions(remoteCatalog, allowedPackages, compactLog) {
182
+ const resolvedTargets = {};
183
+ const npmPackagesToResolve = NPM_TARGET_PACKAGES.filter((packageName) => allowedPackages.includes(packageName));
184
+ for (const [packageName, version] of Object.entries(remoteCatalog)) {
185
+ resolvedTargets[packageName] = {
186
+ version,
187
+ source: 'catalog'
188
+ };
189
+ }
190
+ for (const packageName of npmPackagesToResolve) {
191
+ const command = `npm view ${packageName} version`;
192
+ if (!compactLog) {
193
+ console.log(`[diaomao-update] resolving via npm: ${command}`);
194
+ }
195
+ try {
196
+ const version = execSync(command, {
197
+ encoding: 'utf8',
198
+ stdio: ['ignore', 'pipe', 'pipe']
199
+ }).trim() || UNKNOWN_VERSION;
200
+ resolvedTargets[packageName] = {
201
+ version,
202
+ source: 'npm'
203
+ };
204
+ if (!compactLog) {
205
+ console.log(`[diaomao-update] resolved ${packageName}: ${version}`);
206
+ }
207
+ }
208
+ catch (error) {
209
+ resolvedTargets[packageName] = {
210
+ version: UNKNOWN_VERSION,
211
+ source: 'npm'
212
+ };
213
+ if (!compactLog) {
214
+ const stderr = error instanceof Error && 'stderr' in error && typeof error.stderr === 'string'
215
+ ? error.stderr.trim()
216
+ : String(error);
217
+ console.log(`[diaomao-update] resolved ${packageName}: ${UNKNOWN_VERSION}`);
218
+ console.log(`[diaomao-update] npm query failed for ${packageName}: ${stderr || 'unknown error'}`);
219
+ }
220
+ }
221
+ }
222
+ return resolvedTargets;
223
+ }
158
224
  async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? process.cwd() : '.') {
159
225
  const updateConfig = config.diaomaoUpdate || {};
160
226
  const sourceUrl = updateConfig.sourceUrl || '';
@@ -177,12 +243,14 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
177
243
  console.log(`Reading update source: ${sourceUrl}`);
178
244
  const remoteWorkspaceContent = await fetchText(sourceUrl);
179
245
  const remoteCatalog = extractCatalog(remoteWorkspaceContent);
246
+ const resolvedTargets = resolveTargetVersions(remoteCatalog, allowedPackages, compactLog);
180
247
  const updatedRows = [];
181
248
  const skipRows = [];
182
249
  let packageJsonChanged = false;
183
250
  let workspaceChanged = false;
184
251
  for (const packageName of allowedPackages) {
185
- const targetVersion = remoteCatalog[packageName];
252
+ const resolvedTarget = resolvedTargets[packageName];
253
+ const targetVersion = resolvedTarget?.version;
186
254
  if (!targetVersion) {
187
255
  continue;
188
256
  }
@@ -233,6 +301,15 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
233
301
  });
234
302
  continue;
235
303
  }
304
+ if (decision === 'uncomparable') {
305
+ skipRows.push({
306
+ packageName,
307
+ currentVersion: localCatalogVersion,
308
+ targetVersion,
309
+ reason: 'skipped-uncomparable'
310
+ });
311
+ continue;
312
+ }
236
313
  localCatalog[packageName] = targetVersion;
237
314
  workspaceChanged = true;
238
315
  updatedRows.push({
@@ -240,6 +317,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
240
317
  currentVersion: localCatalogVersion,
241
318
  targetVersion
242
319
  });
320
+ if (!compactLog) {
321
+ console.log(`[diaomao-update] updated ${packageName} from ${localCatalogVersion} to ${targetVersion} (source: ${resolvedTarget.source})`);
322
+ }
243
323
  continue;
244
324
  }
245
325
  const decision = compareVersionSpecs(currentSpecifier, targetVersion);
@@ -261,6 +341,15 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
261
341
  });
262
342
  continue;
263
343
  }
344
+ if (decision === 'uncomparable') {
345
+ skipRows.push({
346
+ packageName,
347
+ currentVersion: currentSpecifier,
348
+ targetVersion,
349
+ reason: 'skipped-uncomparable'
350
+ });
351
+ continue;
352
+ }
264
353
  dependencies[packageName] = targetVersion;
265
354
  packageJsonChanged = true;
266
355
  updatedRows.push({
@@ -268,6 +357,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
268
357
  currentVersion: currentSpecifier,
269
358
  targetVersion
270
359
  });
360
+ if (!compactLog) {
361
+ console.log(`[diaomao-update] updated ${packageName} from ${currentSpecifier} to ${targetVersion} (source: ${resolvedTarget.source})`);
362
+ }
271
363
  }
272
364
  if (!matched) {
273
365
  skipRows.push({
@@ -296,6 +388,13 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
296
388
  console.log('');
297
389
  console.log(`Updated ${updatedRows.length} package version(s).`);
298
390
  printSkipDetails(skipRows, compactLog);
391
+ if (updatedRows.length > 0) {
392
+ console.log('\n执行 pnpm install中...');
393
+ execSync('pnpm install', {
394
+ cwd,
395
+ stdio: 'inherit'
396
+ });
397
+ }
299
398
  return 0;
300
399
  }
301
400
 
@@ -0,0 +1,103 @@
1
+ {
2
+ "i18n": {
3
+ "locales": ["en", "zh", "ja"],
4
+ "defaultLocale": "en",
5
+ "messageRoot": "messages"
6
+ },
7
+ "scan": {
8
+ "include": ["src/**/*.{tsx,ts,jsx,js}"],
9
+ "exclude": ["src/**/*.test.ts", "src/**/*.d.ts", "node_modules/**"]
10
+ },
11
+ "blog": {
12
+ "mdxDir": "src/mdx/blog",
13
+ "outputFile": "index.mdx",
14
+ "metaFile": "meta.json",
15
+ "iocSlug": "ioc",
16
+ "prefix": "blog"
17
+ },
18
+ "output": {
19
+ "logDir": "scripts",
20
+ "verbose": false
21
+ },
22
+ "diaomaoUpdate": {
23
+ "sourceUrl": "https://raw.githubusercontent.com/caofanCPU/next-ai-build/main/pnpm-workspace.yaml",
24
+ "allowedPackages": [
25
+ "@changesets/cli",
26
+ "@clerk/localizations",
27
+ "@clerk/nextjs",
28
+ "@clerk/shared",
29
+ "@clerk/themes",
30
+ "@fingerprintjs/fingerprintjs",
31
+ "@hookform/resolvers",
32
+ "@prisma/client",
33
+ "@radix-ui/react-alert-dialog",
34
+ "@radix-ui/react-dropdown-menu",
35
+ "@radix-ui/react-label",
36
+ "@radix-ui/react-slot",
37
+ "@tailwindcss/cli",
38
+ "@tailwindcss/postcss",
39
+ "@tailwindcss/typography",
40
+ "@types/hast",
41
+ "@types/mdx",
42
+ "@types/node",
43
+ "@types/nprogress",
44
+ "@types/react",
45
+ "@types/react-dom",
46
+ "@typescript-eslint/parser",
47
+ "@windrun-huaiin/backend-core",
48
+ "@windrun-huaiin/base-ui",
49
+ "@windrun-huaiin/dev-scripts",
50
+ "@windrun-huaiin/lib",
51
+ "@windrun-huaiin/third-ui",
52
+ "autoprefixer",
53
+ "baseline-browser-mapping",
54
+ "class-variance-authority",
55
+ "clsx",
56
+ "date-fns",
57
+ "eslint",
58
+ "eslint-config-next",
59
+ "eslint-plugin-unused-imports",
60
+ "fast-glob",
61
+ "fumadocs-core",
62
+ "fumadocs-docgen",
63
+ "fumadocs-mdx",
64
+ "fumadocs-typescript",
65
+ "fumadocs-ui",
66
+ "katex",
67
+ "lucide-react",
68
+ "mermaid",
69
+ "next",
70
+ "next-intl",
71
+ "next-themes",
72
+ "nprogress",
73
+ "postcss",
74
+ "prisma",
75
+ "react",
76
+ "react-dom",
77
+ "react-medium-image-zoom",
78
+ "rehype-katex",
79
+ "remark",
80
+ "remark-frontmatter",
81
+ "remark-gfm",
82
+ "remark-math",
83
+ "remark-mdx",
84
+ "shiki",
85
+ "stripe",
86
+ "svix",
87
+ "swiper",
88
+ "tailwind-merge",
89
+ "tailwindcss",
90
+ "tailwindcss-animate",
91
+ "ts-morph",
92
+ "ts-node",
93
+ "typescript",
94
+ "unist-util-visit",
95
+ "uuid",
96
+ "zod"
97
+ ],
98
+ "compactLog": true
99
+ },
100
+ "architectureConfig": {
101
+ ".": "RootProject"
102
+ }
103
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/dev-scripts",
3
- "version": "14.1.0",
3
+ "version": "14.1.2",
4
4
  "description": "Development scripts for multilingual projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  "dist",
27
27
  "bin",
28
28
  "package.json",
29
+ "example.config.json",
29
30
  "README.md",
30
31
  "LICENSE"
31
32
  ],