@windrun-huaiin/dev-scripts 14.1.1 → 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;AA0O7D,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,GAAG,GAAE,MAA6D,GACjE,OAAO,CAAC,MAAM,CAAC,CA6LjB"}
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) => {
@@ -171,6 +180,49 @@ function printSkipDetails(skipRows, compactLog) {
171
180
  console.log('\nSkipped:');
172
181
  console.log(renderTable(skipRows, ['Package', 'Before', 'After', 'Reason']));
173
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
+ }
174
226
  async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? process.cwd() : '.') {
175
227
  const updateConfig = config.diaomaoUpdate || {};
176
228
  const sourceUrl = updateConfig.sourceUrl || '';
@@ -193,12 +245,14 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
193
245
  console.log(`Reading update source: ${sourceUrl}`);
194
246
  const remoteWorkspaceContent = await fetchText(sourceUrl);
195
247
  const remoteCatalog = extractCatalog(remoteWorkspaceContent);
248
+ const resolvedTargets = resolveTargetVersions(remoteCatalog, allowedPackages, compactLog);
196
249
  const updatedRows = [];
197
250
  const skipRows = [];
198
251
  let packageJsonChanged = false;
199
252
  let workspaceChanged = false;
200
253
  for (const packageName of allowedPackages) {
201
- const targetVersion = remoteCatalog[packageName];
254
+ const resolvedTarget = resolvedTargets[packageName];
255
+ const targetVersion = resolvedTarget?.version;
202
256
  if (!targetVersion) {
203
257
  continue;
204
258
  }
@@ -265,6 +319,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
265
319
  currentVersion: localCatalogVersion,
266
320
  targetVersion
267
321
  });
322
+ if (!compactLog) {
323
+ console.log(`[diaomao-update] updated ${packageName} from ${localCatalogVersion} to ${targetVersion} (source: ${resolvedTarget.source})`);
324
+ }
268
325
  continue;
269
326
  }
270
327
  const decision = compareVersionSpecs(currentSpecifier, targetVersion);
@@ -302,6 +359,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
302
359
  currentVersion: currentSpecifier,
303
360
  targetVersion
304
361
  });
362
+ if (!compactLog) {
363
+ console.log(`[diaomao-update] updated ${packageName} from ${currentSpecifier} to ${targetVersion} (source: ${resolvedTarget.source})`);
364
+ }
305
365
  }
306
366
  if (!matched) {
307
367
  skipRows.push({
@@ -330,6 +390,13 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
330
390
  console.log('');
331
391
  console.log(`Updated ${updatedRows.length} package version(s).`);
332
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
+ }
333
400
  return 0;
334
401
  }
335
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) => {
@@ -169,6 +178,49 @@ function printSkipDetails(skipRows, compactLog) {
169
178
  console.log('\nSkipped:');
170
179
  console.log(renderTable(skipRows, ['Package', 'Before', 'After', 'Reason']));
171
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
+ }
172
224
  async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? process.cwd() : '.') {
173
225
  const updateConfig = config.diaomaoUpdate || {};
174
226
  const sourceUrl = updateConfig.sourceUrl || '';
@@ -191,12 +243,14 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
191
243
  console.log(`Reading update source: ${sourceUrl}`);
192
244
  const remoteWorkspaceContent = await fetchText(sourceUrl);
193
245
  const remoteCatalog = extractCatalog(remoteWorkspaceContent);
246
+ const resolvedTargets = resolveTargetVersions(remoteCatalog, allowedPackages, compactLog);
194
247
  const updatedRows = [];
195
248
  const skipRows = [];
196
249
  let packageJsonChanged = false;
197
250
  let workspaceChanged = false;
198
251
  for (const packageName of allowedPackages) {
199
- const targetVersion = remoteCatalog[packageName];
252
+ const resolvedTarget = resolvedTargets[packageName];
253
+ const targetVersion = resolvedTarget?.version;
200
254
  if (!targetVersion) {
201
255
  continue;
202
256
  }
@@ -263,6 +317,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
263
317
  currentVersion: localCatalogVersion,
264
318
  targetVersion
265
319
  });
320
+ if (!compactLog) {
321
+ console.log(`[diaomao-update] updated ${packageName} from ${localCatalogVersion} to ${targetVersion} (source: ${resolvedTarget.source})`);
322
+ }
266
323
  continue;
267
324
  }
268
325
  const decision = compareVersionSpecs(currentSpecifier, targetVersion);
@@ -300,6 +357,9 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
300
357
  currentVersion: currentSpecifier,
301
358
  targetVersion
302
359
  });
360
+ if (!compactLog) {
361
+ console.log(`[diaomao-update] updated ${packageName} from ${currentSpecifier} to ${targetVersion} (source: ${resolvedTarget.source})`);
362
+ }
303
363
  }
304
364
  if (!matched) {
305
365
  skipRows.push({
@@ -328,6 +388,13 @@ async function diaomaoUpdate(config, cwd = typeof process !== 'undefined' ? proc
328
388
  console.log('');
329
389
  console.log(`Updated ${updatedRows.length} package version(s).`);
330
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
+ }
331
398
  return 0;
332
399
  }
333
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.1",
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
  ],