@karoy/dsh-wsl-desktop 0.1.1 → 0.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.
package/README.md CHANGED
@@ -68,17 +68,12 @@
68
68
 
69
69
  ## 发布
70
70
 
71
- 仓库的 `NPM_TOKEN` 是 **stage-only** 令牌,发布走「暂存 + 人工审批」:
71
+ 仓库的 `NPM_TOKEN` 具备直接发布权限:
72
72
 
73
73
  1. 改 `package.json` 的 `version`,提交并 push;
74
- 2. 在 GitHub 创建 **Release**(发布)→ `Stage npm release` 工作流先跑 CI,再执行
75
- `npm stage publish --access public`;
76
- 3. 工作流成功后会打印 `staged with id <uuid>`;维护者用 2FA 批准:
77
- `npm stage approve <uuid>`,或在 npmjs.com 的包页面批准;
78
- 4. 审批后验证:`npm view @karoy/dsh-wsl-desktop version`。
79
-
80
- 若要 CI 直接发布(不经暂存),把 `NPM_TOKEN` 换成具备
81
- 「Read and write (publish and stage)」权限的令牌,并把工作流改回 `npm publish`。
74
+ 2. 在 GitHub 创建 **Release**(发布)→ `Publish to npm` 工作流先跑 CI,再执行
75
+ `npm publish --access public`;
76
+ 3. 验证:`npm view @karoy/dsh-wsl-desktop version`(当前 `0.1.1`)。
82
77
  ## 回滚
83
78
 
84
79
  `/wsl-desktop-remove`,或关闭窗口后删除 `installDir` 与 `%APPDATA%\DeepSeek Harness WSL`。
@@ -4,7 +4,7 @@ import path from 'node:path'
4
4
  import { createRequire } from 'node:module'
5
5
  import { spawnSync } from 'node:child_process'
6
6
 
7
- const require$ = createRequire(path.join(os.homedir(), '.dsh', 'profiles', 'desktop', 'index.js'))
7
+ const require$ = createRequire(import.meta.url)
8
8
  const yaml = require$('yaml')
9
9
 
10
10
  /** Windows temp file path spoken in WSL terms (`C:\...` → `/mnt/c/...`). */
package/lib/setup.js CHANGED
@@ -13,10 +13,13 @@
13
13
  */
14
14
  import { spawnSync } from 'node:child_process'
15
15
  import fs from 'node:fs'
16
+ import { createRequire } from 'node:module'
16
17
  import os from 'node:os'
17
18
  import path from 'node:path'
18
19
  import { writeStamp } from './state.js'
19
20
 
21
+ const require$ = createRequire(import.meta.url)
22
+
20
23
  const MARKER = 'wsl-desktop patch'
21
24
  const HELPER_MARKER = 'wslDesktopRequire'
22
25
 
@@ -78,21 +81,27 @@ function copyInstall(sourceDir, installDir) {
78
81
  fs.rmSync(installDir, { recursive: true, force: true })
79
82
  }
80
83
  fs.mkdirSync(installDir, { recursive: true })
81
- const status = run('robocopy', [sourceDir, installDir, '/E', '/NFL', '/NDL', '/NJH', '/NP'])
84
+ // Skip what the copy does not need: app.asar (extracted straight from the
85
+ // installed app) and its unpacked payload (extractAll pulls those files from
86
+ // the source's app.asar.unpacked). Together they are ~450 MB of the ~1 GB
87
+ // install, and skipping the archive also avoids racing its rename (EBUSY).
88
+ const status = run('robocopy', [
89
+ sourceDir, installDir, '/E', '/NFL', '/NDL', '/NJH', '/NP',
90
+ '/XF', 'app.asar', '/XD', 'app.asar.unpacked',
91
+ ])
82
92
  if (status > 7) throw new Error('wsl-desktop: robocopy failed with ' + String(status))
83
93
  }
84
94
 
85
- function extractAsar(resourcesDir) {
86
- const asar = path.join(resourcesDir, 'app.asar')
95
+ function extractAsar(sourceDir, resourcesDir) {
96
+ const sourceAsar = path.join(sourceDir, 'resources', 'app.asar')
97
+ if (!fs.existsSync(sourceAsar)) throw new Error('wsl-desktop: source resources/app.asar is missing')
87
98
  const app = path.join(resourcesDir, 'app')
88
- const backup = path.join(resourcesDir, 'app.asar.orig')
89
- if (!fs.existsSync(asar)) {
90
- if (fs.existsSync(app) && fs.existsSync(backup)) return
91
- throw new Error('wsl-desktop: resources/app.asar is missing')
99
+ const mainPath = path.join(app, 'lib', 'main.js')
100
+ if (!fs.existsSync(mainPath)) {
101
+ fs.rmSync(app, { recursive: true, force: true })
102
+ require$('@electron/asar').extractAll(sourceAsar, app)
92
103
  }
93
- run('npx', ['-y', '@electron/asar', 'extract', 'app.asar', 'app'], { cwd: resourcesDir, shell: true, timeout: 900000 })
94
- if (!fs.existsSync(path.join(app, 'lib', 'main.js'))) throw new Error('wsl-desktop: asar extraction produced no app/lib/main.js')
95
- fs.renameSync(asar, backup)
104
+ if (!fs.existsSync(mainPath)) throw new Error('wsl-desktop: asar extraction produced no app/lib/main.js')
96
105
  }
97
106
 
98
107
  export function patchMain(mainPath, config) {
@@ -246,7 +255,7 @@ export function setup(pluginConfig = {}) {
246
255
 
247
256
  copyInstall(sourceDir, installDir)
248
257
  const resourcesDir = path.join(installDir, 'resources')
249
- extractAsar(resourcesDir)
258
+ extractAsar(sourceDir, resourcesDir)
250
259
  const mainPath = path.join(resourcesDir, 'app', 'lib', 'main.js')
251
260
  patchMain(mainPath, config)
252
261
  installHelper(resourcesDir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karoy/dsh-wsl-desktop",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Install and launch a DSH Desktop copy whose Electron shell proxies its Host connection to a DSH Host running inside WSL",
5
5
  "keywords": [
6
6
  "dsh",
@@ -59,5 +59,9 @@
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@deepseek-ai/cordis": "*"
62
+ },
63
+ "dependencies": {
64
+ "@electron/asar": "^4.0.1",
65
+ "yaml": "^2.8.1"
62
66
  }
63
67
  }