Skip to content

Commit 408a735

Browse files
fix(core): 全局 setup 的工作区优先于 repo 检测
Mode B 用户在开发仓库目录下运行 media 时,优先使用 ~/.media-manager/config.json,避免误解析到 clone 目录。版本 bump 至 0.1.1。 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 50b2ccf commit 408a735

13 files changed

Lines changed: 51 additions & 32 deletions

File tree

.media-manager/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1,
3+
"layout": "v1",
4+
"createdAt": "2026-05-31T01:59:57.013Z"
5+
}

docs/workspace.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Clone 仓库后,**repo 根目录** 即 workspace(存在 `.media-manager/repo
3232
## 解析优先级
3333

3434
1. `--workspace` / `MEDIA_WORKSPACE`
35-
2. 向上查找 `.media-manager/config.json`
36-
3. repo marker(Mode A)
37-
4. `~/.media-manager/config.json`
35+
2. `~/.media-manager/config.json`(Mode B:`media setup` 写入的全局工作区)
36+
3. 从当前目录向上查找 `.media-manager/config.json`
37+
4. repo marker(Mode A:clone 仓库根目录)

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dsmlll/media-manager-cli",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"bin": {
66
"media": "./dist/main.js"
@@ -16,8 +16,8 @@
1616
"postinstall": "node scripts/postinstall.mjs"
1717
},
1818
"dependencies": {
19-
"@dsmlll/media-manager-core": "0.1.0",
20-
"@dsmlll/media-manager-runtime": "0.1.0"
19+
"@dsmlll/media-manager-core": "0.1.1",
20+
"@dsmlll/media-manager-runtime": "0.1.1"
2121
},
2222
"devDependencies": {
2323
"@types/node": "^24.6.0",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dsmlll/media-manager-core",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

packages/core/src/workspace.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ export function resolveWorkspace(options: ResolveWorkspaceOptions = {}): string
127127
return path.resolve(process.env.MEDIA_WORKSPACE);
128128
}
129129

130+
const globalConfig = readGlobalConfig();
131+
if (globalConfig?.workspace) {
132+
return path.resolve(globalConfig.workspace);
133+
}
134+
130135
const fromCwd = findWorkspaceConfigUpwards(cwd);
131136
if (fromCwd) return fromCwd;
132137

133138
const repoRoot = findRepoRoot(cwd);
134139
if (repoRoot) return repoRoot;
135140

136-
const globalConfig = readGlobalConfig();
137-
if (globalConfig?.workspace) {
138-
return path.resolve(globalConfig.workspace);
139-
}
140-
141141
throw new Error(
142142
"MediaManager workspace is not configured. Run `media setup` or set MEDIA_WORKSPACE."
143143
);

packages/core/tests/workspace.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,25 @@ function testFindRepoRoot() {
4848
assert.equal(findRepoRoot(repo), path.resolve(repo));
4949
}
5050

51+
function testGlobalConfigOverridesRepoCwd() {
52+
const globalWs = path.join(tmpRoot, "global-ws");
53+
setupWorkspace(globalWs);
54+
const fakeRepoCwd = path.join(tmpRoot, "fake-repo-cwd");
55+
fs.mkdirSync(path.join(fakeRepoCwd, ".media-manager"), { recursive: true });
56+
fs.writeFileSync(
57+
path.join(fakeRepoCwd, ".media-manager", "config.json"),
58+
JSON.stringify({ version: 1, layout: "v1", createdAt: new Date().toISOString() })
59+
);
60+
fs.writeFileSync(path.join(fakeRepoCwd, ".media-manager", "repo-marker.json"), "{}");
61+
assert.equal(resolveWorkspace({ cwd: fakeRepoCwd }), path.resolve(globalWs));
62+
}
63+
5164
function run() {
5265
testResolveWorkspaceFromExplicit();
5366
testSetupWorkspace();
5467
testDefaultWorkspacePath();
5568
testFindRepoRoot();
69+
testGlobalConfigOverridesRepoCwd();
5670
console.log("core tests passed");
5771
}
5872

packages/platform-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dsmlll/media-manager-platform-common",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

packages/runtime/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dsmlll/media-manager-runtime",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
@@ -19,8 +19,8 @@
1919
"postinstall": "node scripts/install-skill-deps.mjs"
2020
},
2121
"dependencies": {
22-
"@dsmlll/media-manager-core": "0.1.0",
23-
"@dsmlll/media-manager-platform-common": "0.1.0"
22+
"@dsmlll/media-manager-core": "0.1.1",
23+
"@dsmlll/media-manager-platform-common": "0.1.1"
2424
},
2525
"devDependencies": {
2626
"@types/node": "^24.6.0",

skills/csdn-publish-and-data/scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"typescript": "^5.9.2"
1717
},
1818
"dependencies": {
19-
"@dsmlll/media-manager-platform-common": "0.1.0",
19+
"@dsmlll/media-manager-platform-common": "0.1.1",
2020
"gray-matter": "^4.0.3",
2121
"playwright": "^1.58.2"
2222
}

0 commit comments

Comments
 (0)