cabloy 5.1.55 → 5.1.57

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/.gitignore CHANGED
@@ -62,6 +62,7 @@ zova/.quasar
62
62
  **/.vitepress/cache
63
63
  **/.rollup.cache
64
64
  **/.temp-dynamic-*
65
+ /.cabloy-version
65
66
  vona/package.json
66
67
  zova/package.json
67
68
  vona/docker-compose.yml
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.57
4
+
5
+ ### Features
6
+
7
+ - Track the Cabloy version during initialization and upgrade.
8
+
9
+ ## 5.1.56
10
+
11
+ ### Features
12
+
13
+ - Update functionality.
14
+
3
15
  ## 5.1.55
4
16
 
5
17
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabloy",
3
- "version": "5.1.55",
3
+ "version": "5.1.57",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A Node.js fullstack framework",
6
6
  "keywords": [
package/scripts/init.ts CHANGED
@@ -19,6 +19,7 @@ const VONA_DIR = resolve(ROOT_DIR, 'vona');
19
19
  const ZOVA_DIR = resolve(ROOT_DIR, 'zova');
20
20
  const CABLOY_DOCS_DIR = resolve(ROOT_DIR, 'cabloy-docs');
21
21
  const PNPM_VERSION = '11.5.2';
22
+ const VERSION_MARKER_FILE = '.cabloy-version';
22
23
 
23
24
  // --- Helpers ---
24
25
 
@@ -70,6 +71,50 @@ function deleteGitkeepFiles(dir: string): void {
70
71
  }
71
72
  }
72
73
 
74
+ function isValidVersion(version: string): boolean {
75
+ return /^\d+\.\d+\.\d+$/.test(version);
76
+ }
77
+
78
+ function readPackageVersion(): string {
79
+ const filePath = resolve(ROOT_DIR, 'package.json');
80
+ const packageContent = JSON.parse(readFileSync(filePath, 'utf-8')) as { version?: string };
81
+ const version = packageContent.version?.trim();
82
+ if (!version || !isValidVersion(version)) {
83
+ throw new Error(`Invalid Cabloy version in package.json: ${version ?? '<missing>'}`);
84
+ }
85
+ return version;
86
+ }
87
+
88
+ function readVersionMarker(): string | undefined {
89
+ const filePath = resolve(ROOT_DIR, VERSION_MARKER_FILE);
90
+ if (!existsSync(filePath)) return undefined;
91
+ const version = readFileSync(filePath, 'utf-8').trim();
92
+ if (!version) return undefined;
93
+ if (!isValidVersion(version)) {
94
+ throw new Error(`Invalid Cabloy version marker: ${version}`);
95
+ }
96
+ return version;
97
+ }
98
+
99
+ function resolveVersionMarker(): string {
100
+ const versionFromEnv = process.env.CABLOY_VERSION?.trim();
101
+ if (versionFromEnv) {
102
+ if (!isValidVersion(versionFromEnv)) {
103
+ throw new Error(`Invalid CABLOY_VERSION: ${versionFromEnv}`);
104
+ }
105
+ return versionFromEnv;
106
+ }
107
+ return readVersionMarker() ?? readPackageVersion();
108
+ }
109
+
110
+ function writeVersionMarker(): void {
111
+ const version = resolveVersionMarker();
112
+ const filePath = resolve(ROOT_DIR, VERSION_MARKER_FILE);
113
+ writeFileSync(filePath, `${version}\n`);
114
+ // eslint-disable-next-line
115
+ console.log(`[init] Marked Cabloy version: ${version}`);
116
+ }
117
+
73
118
  // --- Step 0: Set APP_NAME in .env files ---
74
119
 
75
120
  function setAppName(): void {
@@ -245,5 +290,6 @@ initVona();
245
290
  initZova();
246
291
  initCabloyDocs();
247
292
  buildSsrCabloyBasicStartBatch();
293
+ writeVersionMarker();
248
294
  // eslint-disable-next-line
249
295
  console.log('[init] Done!');
@@ -1,5 +1,13 @@
1
1
  import { execSync } from 'node:child_process';
2
- import { cpSync, createWriteStream, existsSync, mkdirSync, rmSync, unlinkSync } from 'node:fs';
2
+ import {
3
+ cpSync,
4
+ createWriteStream,
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ rmSync,
9
+ unlinkSync,
10
+ } from 'node:fs';
3
11
  import { tmpdir } from 'node:os';
4
12
  import { dirname, join, resolve } from 'node:path';
5
13
  import { pipeline } from 'node:stream/promises';
@@ -11,6 +19,7 @@ const ROOT_DIR = resolve(__dirname, '..');
11
19
  const NPM_REGISTRY = 'https://registry.npmjs.org';
12
20
  const PACKAGE_NAME = 'cabloy';
13
21
  const TEMP_DIR = resolve(ROOT_DIR, 'node_modules/.cabloy-upgrade');
22
+ const VERSION_MARKER_FILE = '.cabloy-version';
14
23
 
15
24
  // --- Whitelist ---
16
25
 
@@ -78,13 +87,22 @@ const WHITELIST_FILES: string[] = [
78
87
  'zova/openapi.config.ts',
79
88
  ];
80
89
 
90
+ type LatestPackageInfo = {
91
+ version: string;
92
+ tarballUrl: string;
93
+ };
94
+
81
95
  // --- Helpers ---
82
96
 
83
97
  // oxlint-disable no-console
84
98
  const log = console.log; // eslint-disable-line no-console
85
99
 
86
- function exec(cmd: string): void {
87
- execSync(cmd, { stdio: 'inherit', cwd: ROOT_DIR });
100
+ function exec(cmd: string, env?: NodeJS.ProcessEnv): void {
101
+ execSync(cmd, {
102
+ stdio: 'inherit',
103
+ cwd: ROOT_DIR,
104
+ env: env ? { ...process.env, ...env } : process.env,
105
+ });
88
106
  }
89
107
 
90
108
  function shouldCopyPath(path: string): boolean {
@@ -95,6 +113,54 @@ function copyDirectory(src: string, dest: string): void {
95
113
  cpSync(src, dest, { recursive: true, filter: shouldCopyPath });
96
114
  }
97
115
 
116
+ function isValidVersion(version: string): boolean {
117
+ return /^\d+\.\d+\.\d+$/.test(version);
118
+ }
119
+
120
+ function parseVersion(version: string): [number, number, number] {
121
+ if (!isValidVersion(version)) {
122
+ throw new Error(`Invalid Cabloy version: ${version}`);
123
+ }
124
+ const [major, minor, patch] = version.split('.').map(item => Number.parseInt(item, 10));
125
+ return [major, minor, patch];
126
+ }
127
+
128
+ function compareVersions(left: string, right: string): number {
129
+ const leftParts = parseVersion(left);
130
+ const rightParts = parseVersion(right);
131
+ for (let i = 0; i < leftParts.length; i++) {
132
+ if (leftParts[i] > rightParts[i]) return 1;
133
+ if (leftParts[i] < rightParts[i]) return -1;
134
+ }
135
+ return 0;
136
+ }
137
+
138
+ function readVersionMarker(): string | undefined {
139
+ const filePath = resolve(ROOT_DIR, VERSION_MARKER_FILE);
140
+ if (!existsSync(filePath)) return undefined;
141
+ const version = readFileSync(filePath, 'utf-8').trim();
142
+ if (!version) {
143
+ throw new Error(`Invalid Cabloy version marker in ${VERSION_MARKER_FILE}: <empty>`);
144
+ }
145
+ if (!isValidVersion(version)) {
146
+ throw new Error(`Invalid Cabloy version marker in ${VERSION_MARKER_FILE}: ${version}`);
147
+ }
148
+ return version;
149
+ }
150
+
151
+ function readRequiredVersionMarker(expectedVersion: string): string {
152
+ const version = readVersionMarker();
153
+ if (!version) {
154
+ throw new Error(`Expected ${VERSION_MARKER_FILE} to be created after upgrade`);
155
+ }
156
+ if (version !== expectedVersion) {
157
+ throw new Error(
158
+ `Expected ${VERSION_MARKER_FILE} to be ${expectedVersion} after upgrade, received ${version}`,
159
+ );
160
+ }
161
+ return version;
162
+ }
163
+
98
164
  async function extractTarball(tarballPath: string, targetDir: string): Promise<void> {
99
165
  rmSync(targetDir, { recursive: true, force: true });
100
166
  mkdirSync(targetDir, { recursive: true });
@@ -120,14 +186,22 @@ function preflight(): void {
120
186
 
121
187
  // --- Step 2: Download & extract ---
122
188
 
123
- async function fetchLatestTarballUrl(): Promise<string> {
189
+ async function fetchLatestPackageInfo(): Promise<LatestPackageInfo> {
124
190
  const url = `${NPM_REGISTRY}/${PACKAGE_NAME}/latest`;
125
191
  const res = await fetch(url);
126
192
  if (!res.ok) {
127
193
  throw new Error(`Failed to fetch package info: ${res.status} ${res.statusText}`);
128
194
  }
129
- const data = (await res.json()) as { dist: { tarball: string } };
130
- return data.dist.tarball;
195
+ const data = (await res.json()) as { version?: string; dist?: { tarball?: string } };
196
+ const version = data.version?.trim();
197
+ const tarballUrl = data.dist?.tarball?.trim();
198
+ if (!version || !isValidVersion(version)) {
199
+ throw new Error(`Invalid latest Cabloy version from npm: ${version ?? '<missing>'}`);
200
+ }
201
+ if (!tarballUrl) {
202
+ throw new Error('Missing tarball URL in npm latest metadata');
203
+ }
204
+ return { version, tarballUrl };
131
205
  }
132
206
 
133
207
  async function downloadTarball(tarballUrl: string): Promise<string> {
@@ -145,8 +219,7 @@ async function downloadTarball(tarballUrl: string): Promise<string> {
145
219
  return tmpFile;
146
220
  }
147
221
 
148
- async function downloadAndExtract(): Promise<void> {
149
- const tarballUrl = await fetchLatestTarballUrl();
222
+ async function downloadAndExtract(tarballUrl: string): Promise<void> {
150
223
  const tarballPath = await downloadTarball(tarballUrl);
151
224
  try {
152
225
  await extractTarball(tarballPath, TEMP_DIR);
@@ -190,9 +263,12 @@ function selectiveOverwrite(dryRun?: boolean): void {
190
263
  // Delete directories
191
264
  for (const dir of BLACKLIST_DIRS) {
192
265
  const dest = resolve(ROOT_DIR, dir);
193
- if (existsSync(dest)) {
194
- rmSync(dest, { recursive: true, force: true });
266
+ if (!existsSync(dest)) continue;
267
+ if (dryRun) {
268
+ log(` [dry-run] Delete directory: ${dir}`);
269
+ continue;
195
270
  }
271
+ rmSync(dest, { recursive: true, force: true });
196
272
  }
197
273
 
198
274
  // Overwrite files
@@ -210,12 +286,12 @@ function selectiveOverwrite(dryRun?: boolean): void {
210
286
 
211
287
  // --- Step 4: Run init ---
212
288
 
213
- function runInit(dryRun?: boolean): void {
289
+ function runInit(dryRun: boolean, version: string): void {
214
290
  if (dryRun) {
215
291
  log(' [dry-run] Run: npm run init');
216
292
  return;
217
293
  }
218
- exec('npm run init');
294
+ exec('npm run init', { CABLOY_VERSION: version } as any);
219
295
  }
220
296
 
221
297
  // --- Step 5: Cleanup ---
@@ -240,25 +316,61 @@ async function main(): Promise<void> {
240
316
  // 1. Pre-flight
241
317
  preflight();
242
318
 
243
- // 2. Download & extract
244
- log('Downloading latest cabloy from npm registry...');
245
- await downloadAndExtract();
246
- log('Downloaded and extracted successfully!\n');
319
+ const latestPackageInfo = await fetchLatestPackageInfo();
320
+ const currentVersion = readVersionMarker();
321
+
322
+ if (currentVersion) {
323
+ log(`Current project Cabloy version: ${currentVersion}`);
324
+ } else {
325
+ log(
326
+ `Warning: Missing ${VERSION_MARKER_FILE}, continuing with upgrade for backward compatibility.`,
327
+ );
328
+ }
329
+ log(`Latest Cabloy version: ${latestPackageInfo.version}`);
330
+
331
+ if (currentVersion) {
332
+ const comparison = compareVersions(currentVersion, latestPackageInfo.version);
333
+ if (comparison === 0) {
334
+ log(`Cabloy is already up to date (current: ${currentVersion}). Skipping upgrade.`);
335
+ return;
336
+ }
337
+ if (comparison > 0) {
338
+ throw new Error(
339
+ `Project Cabloy version ${currentVersion} is newer than npm latest ${latestPackageInfo.version}. Aborting upgrade.`,
340
+ );
341
+ }
342
+ log(`Upgrading Cabloy from ${currentVersion} to ${latestPackageInfo.version}...\n`);
343
+ } else {
344
+ log(`Upgrading Cabloy to ${latestPackageInfo.version}...\n`);
345
+ }
247
346
 
248
- // 3. Selective overwrite
249
- log('Overwriting framework-owned files...');
250
- selectiveOverwrite(dryRun);
251
- log('');
347
+ try {
348
+ // 2. Download & extract
349
+ log('Downloading latest cabloy from npm registry...');
350
+ await downloadAndExtract(latestPackageInfo.tarballUrl);
351
+ log('Downloaded and extracted successfully!\n');
252
352
 
253
- // 4. Run init
254
- log('Running npm run init...');
255
- runInit(dryRun);
256
- log('');
353
+ // 3. Selective overwrite
354
+ log('Overwriting framework-owned files...');
355
+ selectiveOverwrite(dryRun);
356
+ log('');
257
357
 
258
- // 5. Cleanup
259
- cleanup(dryRun);
358
+ // 4. Run init
359
+ log('Running npm run init...');
360
+ runInit(dryRun, latestPackageInfo.version);
361
+ log('');
260
362
 
261
- log('Upgrade complete!');
363
+ if (dryRun) {
364
+ log(`[dry-run] Current Cabloy version would become: ${latestPackageInfo.version}`);
365
+ } else {
366
+ log(`Current Cabloy version: ${readRequiredVersionMarker(latestPackageInfo.version)}`);
367
+ }
368
+
369
+ log('Upgrade complete!');
370
+ } finally {
371
+ // 5. Cleanup
372
+ cleanup(dryRun);
373
+ }
262
374
  }
263
375
 
264
376
  main().catch(err => {
@@ -43,19 +43,6 @@ overrides:
43
43
  '@vue/shared': '3.5.36'
44
44
  zod: 'npm:@cabloy/zod@4.3.6'
45
45
 
46
- minimumReleaseAgeExclude:
47
- - '@cabloy/vue-runtime-core@3.5.57'
48
- - vue@3.5.38
49
- - zova-core@5.1.50
50
- - zova-jsx@1.1.56
51
- - zova-module-a-interceptor@5.1.23
52
- - zova-module-a-ssr@5.1.20
53
- - zova-module-a-style@5.1.26
54
- - zova-module-a-zod@5.1.24
55
- - zova-module-a-zova@5.1.62
56
- - zova-suite-a-zova@5.1.94
57
- - zova@5.1.95
58
-
59
46
  allowBuilds:
60
47
  '@swc/core': true
61
48
  '@zhennann/ejs': true
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-jsx",
3
- "version": "1.1.59",
3
+ "version": "1.1.60",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "Zova JSX",
6
6
  "keywords": [
@@ -50,7 +50,7 @@
50
50
  "@cabloy/word-utils": "^2.1.14",
51
51
  "typestyle": "^2.4.0",
52
52
  "vue": "^3.5.38",
53
- "zova-core": "^5.1.53"
53
+ "zova-core": "^5.1.54"
54
54
  },
55
55
  "devDependencies": {
56
56
  "clean-package": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova",
3
- "version": "5.1.98",
3
+ "version": "5.1.99",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -45,8 +45,8 @@
45
45
  "postpack": "clean-package restore"
46
46
  },
47
47
  "dependencies": {
48
- "zova-core": "^5.1.53",
49
- "zova-suite-a-zova": "^5.1.97"
48
+ "zova-core": "^5.1.54",
49
+ "zova-suite-a-zova": "^5.1.98"
50
50
  },
51
51
  "devDependencies": {
52
52
  "clean-package": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-core",
3
- "version": "5.1.53",
3
+ "version": "5.1.54",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -9,7 +9,7 @@ declare module 'vue' {
9
9
  };
10
10
  }
11
11
 
12
- export interface AllowedComponentProps {}
12
+ export interface AllowedComponentProps extends IComponentIntrinsicAttributes {}
13
13
  }
14
14
 
15
15
  export interface IComponentIntrinsicAttributes {
@@ -40,7 +40,7 @@ export interface IComponentIntrinsicAttributes {
40
40
  declare module 'vue/jsx-runtime' {
41
41
  namespace JSX {
42
42
  // need define class/style in IntrinsicAttributes
43
- export interface IntrinsicAttributes extends IComponentIntrinsicAttributes {}
43
+ export interface IntrinsicAttributes {}
44
44
  }
45
45
  }
46
46
 
@@ -52,10 +52,6 @@ overrides:
52
52
  vue-router: 'npm:@cabloy/vue-router@^4.4.16'
53
53
  zod: 'npm:@cabloy/zod@4.3.6'
54
54
 
55
- minimumReleaseAgeExclude:
56
- - '@cabloy/vue-runtime-core@3.5.57'
57
- - vue@3.5.38
58
-
59
55
  allowBuilds:
60
56
  '@parcel/watcher': true
61
57
  '@zhennann/ejs': true
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-zova",
3
- "version": "5.1.65",
3
+ "version": "5.1.66",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "keywords": [
@@ -43,7 +43,7 @@
43
43
  "@cabloy/word-utils": "^2.1.14",
44
44
  "defu": "^6.1.7",
45
45
  "luxon": "^3.7.2",
46
- "zova-jsx": "^1.1.59"
46
+ "zova-jsx": "^1.1.60"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@cabloy/cli": "^3.1.17",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-zova",
3
- "version": "5.1.97",
3
+ "version": "5.1.98",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "zova-module-a-style": "^5.1.29",
33
33
  "zova-module-a-table": "^5.1.30",
34
34
  "zova-module-a-zod": "^5.1.27",
35
- "zova-module-a-zova": "^5.1.65"
35
+ "zova-module-a-zova": "^5.1.66"
36
36
  },
37
37
  "title": "a-zova"
38
38
  }