rayprism 0.2.0 → 0.2.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/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
VALID_BRANCHES, BRANCH_META, BRANCHES_DIR, WORKSPACE_DIR_DESC,
|
|
16
16
|
DEFAULT_PROJECTS_DIR,
|
|
17
17
|
} from '../utils/constants.js';
|
|
18
|
-
import { ensureFramework,
|
|
18
|
+
import { ensureFramework, getVersion } from '../utils/template.js';
|
|
19
19
|
import { registerProject } from '../utils/registry.js';
|
|
20
20
|
|
|
21
21
|
// ─── Exported helper: link .agents/ .claude/ (merged mode) ──────────
|
|
@@ -185,7 +185,7 @@ export async function init(branch, projectName, opts = {}) {
|
|
|
185
185
|
log.err(`目录已存在: ${projectPath}`);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
const templateVer =
|
|
188
|
+
const templateVer = getVersion();
|
|
189
189
|
|
|
190
190
|
// Print banner
|
|
191
191
|
console.log('');
|
package/src/commands/list.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { VALID_BRANCHES, BRANCH_META, BRANCHES_DIR } from '../utils/constants.js';
|
|
8
|
-
import { ensureFramework,
|
|
8
|
+
import { ensureFramework, getVersion } from '../utils/template.js';
|
|
9
9
|
import { C } from '../utils/logger.js';
|
|
10
10
|
|
|
11
11
|
export async function list() {
|
|
@@ -18,7 +18,7 @@ export async function list() {
|
|
|
18
18
|
for (const b of VALID_BRANCHES) {
|
|
19
19
|
const branchDir = join(BRANCHES_DIR, b);
|
|
20
20
|
if (existsSync(branchDir)) {
|
|
21
|
-
const ver =
|
|
21
|
+
const ver = getVersion();
|
|
22
22
|
console.log(` ${C.green('●')} ${C.bold(b)} ${C.dim('v' + ver)} ${BRANCH_META[b].desc}`);
|
|
23
23
|
} else {
|
|
24
24
|
console.log(` ${C.yellow('○')} ${b} (分支目录未找到)`);
|
package/src/commands/status.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync, readFileSync, lstatSync, readdirSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { log, C } from '../utils/logger.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getVersion } from '../utils/template.js';
|
|
9
9
|
|
|
10
10
|
export async function status() {
|
|
11
11
|
const configPath = join(process.cwd(), '.rayprism.json');
|
|
@@ -26,10 +26,7 @@ export async function status() {
|
|
|
26
26
|
|
|
27
27
|
// Version comparison
|
|
28
28
|
const currentVer = config.template_version || '?';
|
|
29
|
-
let latestVer =
|
|
30
|
-
if (config.source && existsSync(join(config.source, 'VERSION'))) {
|
|
31
|
-
latestVer = readFileSync(join(config.source, 'VERSION'), 'utf8').trim();
|
|
32
|
-
}
|
|
29
|
+
let latestVer = getVersion();
|
|
33
30
|
|
|
34
31
|
console.log('');
|
|
35
32
|
if (currentVer === latestVer) {
|
package/src/commands/upgrade.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync, rmSync, symlinkSync, readdirSync, lstatSync, readlinkSync, mkdirSync } from 'node:fs';
|
|
6
6
|
import { join, basename } from 'node:path';
|
|
7
7
|
import { log, C } from '../utils/logger.js';
|
|
8
|
-
import { ensureFramework,
|
|
8
|
+
import { ensureFramework, getVersion } from '../utils/template.js';
|
|
9
9
|
import { BRANCHES_DIR } from '../utils/constants.js';
|
|
10
10
|
import { registerProject } from '../utils/registry.js';
|
|
11
11
|
import { linkHiddenDirs } from './init.js';
|
|
@@ -23,7 +23,7 @@ export async function upgrade() {
|
|
|
23
23
|
const branch = config.branch;
|
|
24
24
|
const branchDir = join(BRANCHES_DIR, branch);
|
|
25
25
|
const currentVer = config.template_version || '?';
|
|
26
|
-
const latestVer =
|
|
26
|
+
const latestVer = getVersion();
|
|
27
27
|
|
|
28
28
|
if (currentVer === latestVer) {
|
|
29
29
|
log.info(`模板已是最新版本: v${currentVer}`);
|
package/src/utils/template.js
CHANGED
|
@@ -10,6 +10,7 @@ import { join } from 'node:path';
|
|
|
10
10
|
import { pipeline } from 'node:stream/promises';
|
|
11
11
|
import { createGunzip } from 'node:zlib';
|
|
12
12
|
import { execSync } from 'node:child_process';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import { FRAMEWORK_DIR, BRANCHES_DIR, GITHUB_TARBALL, RAYPRISM_CACHE } from './constants.js';
|
|
14
15
|
import { log } from './logger.js';
|
|
15
16
|
|
|
@@ -67,12 +68,12 @@ export async function ensureFramework({ force = false } = {}) {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
* Get the
|
|
71
|
+
* Get the RayPrism version (single source of truth: package.json).
|
|
71
72
|
*/
|
|
72
|
-
export function
|
|
73
|
-
const
|
|
74
|
-
if (existsSync(
|
|
75
|
-
return readFileSync(
|
|
73
|
+
export function getVersion() {
|
|
74
|
+
const pkgPath = join(fileURLToPath(import.meta.url), '..', '..', '..', 'package.json');
|
|
75
|
+
if (existsSync(pkgPath)) {
|
|
76
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
|
|
76
77
|
}
|
|
77
78
|
return '0.0.0';
|
|
78
79
|
}
|