dsh-code-server-app 0.1.40 → 0.1.41
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.en.md +74 -58
- package/README.md +65 -50
- package/lib/index.js +12 -1
- package/lib/native.js +50 -2
- package/package.json +1 -1
- package/vendor/VENDOR.json +1 -1
package/README.en.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
> - Microsoft **open-source** extensions (Python, TypeScript debugger, ESLint, …) are mirrored on Open VSX and install normally by search;
|
|
11
11
|
> - **If you need a proprietary Microsoft extension**: download the `.vsix` from the Marketplace page and install it manually with `code-server --install-extension <file>` (or drop it into `--extensions-dir`).
|
|
12
12
|
|
|
13
|
-
A static profile plugin (npm package with host + client bundle) that ships [code-server](https://github.com/coder/code-server) as a **platform-
|
|
13
|
+
A static profile plugin (npm package with host + client bundle) that ships [code-server](https://github.com/coder/code-server) as a **platform-independent dependency package** (a pack-time artifact at `vendor/code-server` → `@jinsiyu/dshcs-code-server`, with no install scripts and no postinstall); its binaries (argon2 plus 16 native modules) come from `@jinsiyu/dshcs-*-win32-<arch>` platform packages selected automatically per architecture by the platform aggregator. VS Code's inner dependencies and the prebuilt native modules are **all installed by the package manager together with the plugin** — no global npm install, no `bin` configuration, no profile config changes, no second install command.
|
|
14
14
|
|
|
15
15
|
## UI carrier (chosen by the DSH version, feature-detected at runtime)
|
|
16
16
|
|
|
@@ -59,21 +59,29 @@ cd C:\Users\User\Desktop\dsh-code-server-app
|
|
|
59
59
|
pnpm install # dev deps (esbuild + motion); allowBuilds is explicit → no postinstall runs
|
|
60
60
|
pnpm run build:client # src/factory.js → lib/client.js (not committed; must be built first)
|
|
61
61
|
pnpm run vendor:check # optional: show the bundled code-server version vs npm latest
|
|
62
|
-
pnpm run vendor:code-server
|
|
63
|
-
pnpm run repack:
|
|
64
|
-
|
|
65
|
-
pnpm
|
|
66
|
-
|
|
67
|
-
npm publish dsh-code-server-app-<version>.tgz --access public # ⑥ publish the plugin itself (same verified tarball)
|
|
62
|
+
pnpm run vendor:code-server # ① produce vendor/code-server (the upstream tree)
|
|
63
|
+
pnpm run repack:build -- --target win32-arm64,win32-x64 --pack # ② one script builds every sub-package
|
|
64
|
+
pnpm run publish:repacks # ③ publish every @jinsiyu/* sub-package
|
|
65
|
+
pnpm pack # ④ → dsh-code-server-app-<version>.tgz (~107KB)
|
|
66
|
+
npm publish dsh-code-server-app-<version>.tgz --access public # ⑤ publish the plugin itself (same verified tarball)
|
|
68
67
|
```
|
|
69
68
|
|
|
69
|
+
`repack:build` (`scripts/vendor-repacks.mjs`) is the **single script that produces every sub-package**:
|
|
70
|
+
|
|
71
|
+
| Sub-package | Content | os/cpu |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `@jinsiyu/dshcs-code-server@<code-server version>` | the code-server tree (`out/` + `lib/vscode` + its 136 runtime deps), **no machine-specific binary** | platform-independent |
|
|
74
|
+
| `@jinsiyu/dshcs-argon2-win32-arm64` / `-x64` | the argon2 module plus its compiled `.node` for that architecture (arm64 0xaa64 / x64 0x8664) | win32-<arch> |
|
|
75
|
+
| `@jinsiyu/dshcs-<name>[-win32-<arch>]` ×24 | the VS Code inner packages that need building (node-pty / @vscode/sqlite3 / kerberos / koffi / ssh2 / …) | gated when platform-specific |
|
|
76
|
+
| `@jinsiyu/dsh-code-server-runtime-win32-<arch>` | platform aggregator: its `dependencies` map those 16 natives **plus argon2** back to their original names via `npm:` aliases | win32-<arch> |
|
|
77
|
+
|
|
70
78
|
| Goal | Command |
|
|
71
79
|
|---|---|
|
|
72
|
-
| **Build the latest code-server from npm** | `pnpm run vendor:latest` (= `--force`): snapshots `code-server@latest` into `vendor/code-server`; afterwards you **must** re-run `repack:
|
|
80
|
+
| **Build the latest code-server from npm** | `pnpm run vendor:latest` (= `--force`): snapshots `code-server@latest` into `vendor/code-server`; afterwards you **must** re-run `repack:build` and republish every sub-package |
|
|
73
81
|
| **Pin a version** | `pnpm run vendor:code-server -- --version 4.136.2` |
|
|
74
82
|
| **Snapshot from an existing tree** | `pnpm run vendor:code-server -- --from <code-server dir>` (seconds) |
|
|
75
|
-
| **Rebuild
|
|
76
|
-
| **Rebuild
|
|
83
|
+
| **Rebuild every sub-package** | `pnpm run repack:build -- --target win32-arm64,win32-x64 --pack` (without `--from` it npm-installs and compiles the source tree itself — slow) |
|
|
84
|
+
| **Rebuild only the code-server/argon2 packages** | `node scripts/vendor-repacks.mjs --reuse --target win32-arm64,win32-x64 --pack` (reuses the natives already in `repack/build`, no source-tree analysis) |
|
|
77
85
|
| **Publish sub-packages** | `pnpm run publish:repacks` (`--dry-run` to preview; `--only <substr>` to filter; `--otp <code>` / `--limit N` for 2FA) |
|
|
78
86
|
| **Publish the plugin itself** | `npm publish dsh-code-server-app-<version>.tgz --access public` (publishes the exact tarball that was verified; no re-packing) |
|
|
79
87
|
| **Just report versions** | `pnpm run vendor:check` |
|
|
@@ -87,28 +95,28 @@ npm publish dsh-code-server-app-<version>.tgz --access public # ⑥ publish th
|
|
|
87
95
|
|
|
88
96
|
```powershell
|
|
89
97
|
# no postinstall in the package → no pnpm approve-builds / allowBuilds; one command installs everything
|
|
90
|
-
dsh plugin --profile web add dsh-code-server-app@0.1.
|
|
98
|
+
dsh plugin --profile web add dsh-code-server-app@0.1.40
|
|
91
99
|
# a local tarball works the same way:
|
|
92
|
-
dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-server-app-0.1.
|
|
100
|
+
dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-server-app-0.1.40.tgz
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
Ready to use immediately — **no second step, no "Install environment", no install-guide modal**.
|
|
96
|
-
Since 0.1.
|
|
104
|
+
Since 0.1.40 the main package is only **~107KB** (the plugin's own code); everything else is dependencies:
|
|
97
105
|
|
|
98
|
-
- **the code-server tree** (`lib/vscode` 196.9MB + its own 136 runtime dependencies)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`<profile>\node_modules\@jinsiyu\dshcs-code-server-win32-arm64\code-server`;
|
|
106
|
+
- **the code-server tree** (`lib/vscode` 196.9MB + its own 136 runtime dependencies) is a **platform-independent
|
|
107
|
+
package** `@jinsiyu/dshcs-code-server@<code-server version>` declared in the plugin's `dependencies`; it runs from
|
|
108
|
+
`<profile>\node_modules\@jinsiyu\dshcs-code-server\code-server`;
|
|
102
109
|
- the **pure-JS part** of VS Code's inner dependencies (35 packages: xterm / katex / typescript / ws / tar …) is
|
|
103
110
|
declared in the plugin's `dependencies` and installed by pnpm into the profile's `node_modules` (hoisted);
|
|
104
|
-
- the **
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
`@jinsiyu/dsh-code-server-runtime-<
|
|
111
|
+
- the **binary part** comes entirely from `@jinsiyu/dshcs-*` platform packages (one per platform, `os`/`cpu` gated):
|
|
112
|
+
`@jinsiyu/dshcs-argon2-win32-<arch>` and 16 native packages, mapped back to their **original names**
|
|
113
|
+
(`argon2` / `node-pty` / `@vscode/sqlite3` / …) by the **platform aggregator**
|
|
114
|
+
`@jinsiyu/dsh-code-server-runtime-win32-<arch>` using `npm:` aliases; the aggregators sit in the plugin's
|
|
115
|
+
`optionalDependencies`, so pnpm auto-selects the right platform;
|
|
108
116
|
- consequently the dependency graph contains **no package with pre/install/postinstall or a `binding.gyp`** →
|
|
109
117
|
no profile `allowBuilds`, no build script ever runs, and **the user machine needs no C++ toolchain**;
|
|
110
|
-
- **upgrading the plugin no longer re-downloads code-server**: the
|
|
111
|
-
code-server version change pulls those ~
|
|
118
|
+
- **upgrading the plugin no longer re-downloads code-server**: the tree package is cached by version, so only a
|
|
119
|
+
code-server version change pulls those ~60MB again (the argon2 platform package is only ~1.5MB).
|
|
112
120
|
|
|
113
121
|
### Install mechanism (why it is built this way)
|
|
114
122
|
|
|
@@ -122,34 +130,41 @@ Since 0.1.37 the main package is only **~105KB** (the plugin's own code); everyt
|
|
|
122
130
|
user agents, so it always fails under pnpm) → supply the argon2 native binary (no Windows prebuild exists;
|
|
123
131
|
compile with `node-gyp-build`, or reuse an existing `argon2.node` via `DSHCS_ARGON2_BINARY`) → strip leftover
|
|
124
132
|
install scripts → snapshot to `vendor/code-server/`;
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
`
|
|
130
|
-
- **
|
|
133
|
+
- the same script then builds the **platform-independent tree package**: the tree lives in an inner `code-server/`
|
|
134
|
+
directory (npm/pnpm packing **always excludes the package root's `node_modules`**; a subdirectory covered by
|
|
135
|
+
`files` is included), the package declares **no `dependencies`** (those 136 packages are already files inside
|
|
136
|
+
`code-server/node_modules`; declaring them would make pnpm install a second copy) and its
|
|
137
|
+
`node_modules/argon2` is removed entirely;
|
|
138
|
+
- **argon2** becomes two platform packages (`@jinsiyu/dshcs-argon2-win32-arm64` / `-x64`) built with the very same
|
|
139
|
+
rules as the other natives (delete `scripts`/`files`/`binding.gyp`, delete `prebuilds/` so both always load
|
|
140
|
+
`build/Release`), each compiled with `node-gyp rebuild --arch=<arch>` and PE-checked (0xaa64 / 0x8664);
|
|
141
|
+
- **packages that need compiling** are repacked into `@jinsiyu/dshcs-*`:
|
|
131
142
|
copy the already-compiled package directory → **delete `scripts` / `files` / `binding.gyp` / `.hooks` /
|
|
132
143
|
`.npmignore`** (keeping the compiled `.node` and every runtime file) → rewrite dependencies that belong to the
|
|
133
144
|
same set to `npm:` aliases → platform-specific ones get an `os`/`cpu` pair and a `-<platform>-<arch>` suffix;
|
|
134
|
-
- **the platform aggregator** maps those repacks back to their original names (e.g.
|
|
135
|
-
`"node-pty": "npm:@jinsiyu/dshcs-node-pty@1.2.0-beta.15"`
|
|
136
|
-
The aggregator itself is `os`/`cpu` gated,
|
|
137
|
-
`optionalDependencies` → one command picks the right one
|
|
145
|
+
- **the platform aggregator** maps those repacks and argon2 back to their original names (e.g.
|
|
146
|
+
`"node-pty": "npm:@jinsiyu/dshcs-node-pty@1.2.0-beta.15"`, `"argon2": "npm:@jinsiyu/dshcs-argon2-win32-arm64@0.44.0"`),
|
|
147
|
+
so code-server's and VS Code's `require(...)` calls need no change. The aggregator itself is `os`/`cpu` gated,
|
|
148
|
+
and the plugin declares both win32-arm64 and win32-x64 in `optionalDependencies` → one command picks the right one;
|
|
138
149
|
- **resolution path**: the host resolves the runtime root with
|
|
139
|
-
`require.resolve('@jinsiyu/dshcs-code-server
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
>
|
|
150
|
-
>
|
|
151
|
-
|
|
152
|
-
> package
|
|
150
|
+
`require.resolve('@jinsiyu/dshcs-code-server/package.json')` (then the inner `code-server/` directory) and
|
|
151
|
+
launches `code-server/out/node/entry.js`; inner dependencies resolve upward from there
|
|
152
|
+
(`code-server/node_modules` → the package's `node_modules` → `<profile>/node_modules`).
|
|
153
|
+
- **pnpm's nesting gotcha and the safety net**: `os`/`cpu`-gated packages are often installed **nested inside the
|
|
154
|
+
aggregator** (e.g. `<profile>/node_modules/@jinsiyu/dsh-code-server-runtime-win32-arm64/node_modules/argon2`),
|
|
155
|
+
i.e. neither at the profile root nor inside the code-server tree → the host adds that directory to the child
|
|
156
|
+
process's **`NODE_PATH`**, and the environment check resolves against both anchors
|
|
157
|
+
(code-server root + aggregator directory) — see `lib/native.js`.
|
|
158
|
+
|
|
159
|
+
> **Size note**: the plugin tarball is **~107KB**; `@jinsiyu/dshcs-code-server` is **~60.5MB** (242MB unpacked);
|
|
160
|
+
> each argon2 platform package is **~1.5MB**; the 16 native packages add ~250MB. A full install downloads
|
|
161
|
+
> roughly 315MB. Neither `vendor/` nor `repack/` is tracked by git (see `.gitignore`).
|
|
162
|
+
|
|
163
|
+
> **Upgrading from ≤ 0.1.39**: code-server moved from a platform-specific sub-package to **one
|
|
164
|
+
> platform-independent package plus two argon2 platform packages**, and every binary is now produced by the single
|
|
165
|
+
> repack script. The upgrade command is unchanged
|
|
166
|
+
> (`dsh plugin --profile web add dsh-code-server-app@<version>`); the old `dshcs-code-server-win32-*`
|
|
167
|
+
> sub-packages are removed by pnpm.
|
|
153
168
|
|
|
154
169
|
> **Upgrading from ≤ 0.1.35**: the old install root `<profile>\.code-server-app` (with ~1.4GB of inner
|
|
155
170
|
> dependencies) and the "Install environment" step are gone. The new version detects the old root and logs that it
|
|
@@ -157,9 +172,9 @@ Since 0.1.37 the main package is only **~105KB** (the plugin's own code); everyt
|
|
|
157
172
|
> `dsh-code-server-app: false` entries in the profile's `pnpm-workspace.yaml` can be removed too (no build
|
|
158
173
|
> approval is needed any more).
|
|
159
174
|
|
|
160
|
-
> **Uninstall**: `dsh plugin --profile web remove dsh-code-server-app` is enough; the
|
|
161
|
-
>
|
|
162
|
-
> `dsh plugin --profile web remove @jinsiyu/dshcs-code-server
|
|
175
|
+
> **Uninstall**: `dsh plugin --profile web remove dsh-code-server-app` is enough; the tree package, argon2 and the
|
|
176
|
+
> natives are separate dependencies, so to remove everything run e.g.
|
|
177
|
+
> `dsh plugin --profile web remove @jinsiyu/dshcs-code-server` (or `pnpm remove` inside the profile);
|
|
163
178
|
> if an old install root is still around, delete `<profile>\.code-server-app` manually.
|
|
164
179
|
|
|
165
180
|
> After install/dependency changes, **restart `dsh web`** (the static plugin row and host probe paths load at startup).
|
|
@@ -214,18 +229,19 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app
|
|
|
214
229
|
**latest** version; or use `pnpm run vendor:code-server -- --version 4.136.2` / `DSHCS_CODE_SERVER_VERSION`.
|
|
215
230
|
With an existing `vendor/code-server`, a plain `pnpm pack` never upgrades (it is a no-op).
|
|
216
231
|
- **Check first**: `pnpm run vendor:check` prints the bundled version / npm latest.
|
|
217
|
-
- **A version bump
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
232
|
+
- **A version bump means rebuilding and republishing the sub-packages** (all with the same script):
|
|
233
|
+
1. `pnpm run repack:build -- --target win32-arm64,win32-x64 --pack` → the new tree package
|
|
234
|
+
(`@jinsiyu/dshcs-code-server@<new version>`), the new argon2 platform packages and the natives rebuilt
|
|
235
|
+
against the new inner dependencies (the script also rewrites the plugin's pure-JS `dependencies` and both
|
|
236
|
+
aggregator versions);
|
|
237
|
+
2. `pnpm run publish:repacks` → publish; then bump the plugin version → `pnpm pack` → publish the plugin.
|
|
223
238
|
- **No runtime auto-upgrade anymore**: nothing fetches latest at startup; the version is fully determined by the bundled artifact.
|
|
224
239
|
- Bundled locally right now: `code-server@4.136.2` (with Code 1.136.1).
|
|
225
240
|
|
|
226
241
|
### Compatibility with the old install locations
|
|
227
242
|
|
|
228
|
-
Host probe order: `@jinsiyu/dshcs-code-server
|
|
243
|
+
Host probe order: `@jinsiyu/dshcs-code-server/code-server` (**the real layout since 0.1.40**) >
|
|
244
|
+
`@jinsiyu/dshcs-code-server-<platform>-<arch>/code-server` (the 0.1.37 platform sub-packages) >
|
|
229
245
|
the in-package `vendor/code-server` (0.1.36 and earlier / development) > the old install root
|
|
230
246
|
`<profile>\.code-server-app\node_modules\code-server` (0.1.35 and earlier) > plugin-internal
|
|
231
247
|
`node_modules/code-server` (development) > PATH/config `bin`. The old root is only mentioned in a startup log
|
|
@@ -254,7 +270,7 @@ package manager, and the card only reports the result.
|
|
|
254
270
|
|
|
255
271
|
| Key | Default | Description |
|
|
256
272
|
|---|---|---|
|
|
257
|
-
| `bin` | `code-server` (placeholder) | Launch priority: explicit `bin` in config > the
|
|
273
|
+
| `bin` | `code-server` (placeholder) | Launch priority: explicit `bin` in config > the tree package `@jinsiyu/dshcs-code-server/code-server/out/node/entry.js` > the old platform sub-packages `@jinsiyu/dshcs-code-server-<platform>-<arch>` > the in-package `vendor/code-server` > the old install root `.code-server-app` > plugin-internal `node_modules` > `code-server` on PATH. None present → startup error with troubleshooting hints |
|
|
258
274
|
| `host` | `127.0.0.1` | Bind address; `auth: none` only allows loopback (localhost/127.0.0.1/::1) |
|
|
259
275
|
| `port` | `8090` | Port; on conflict startup fails with diagnostics (no automatic port change) |
|
|
260
276
|
| `auth` | `none` | `none` \| `password`; non-loopback host automatically requires password |
|
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
> - **需要微软专有扩展时**:从 Marketplace 网页下载 `.vsix`,用 `code-server --install-extension <文件>`(或放入 `--extensions-dir`)手动安装,即可在插件列表使用。
|
|
12
12
|
|
|
13
13
|
静态 profile 插件(npm 包形态,host + client bundle),把 [code-server](https://github.com/coder/code-server)
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
**作为平台无关的依赖包随插件安装**(打包期产物 `vendor/code-server` → `@jinsiyu/dshcs-code-server`,无安装脚本、无 postinstall),
|
|
15
|
+
二进制部分(argon2 + 16 个原生模块)由 `@jinsiyu/dshcs-*-win32-<架构>` 平台包经聚合包按架构自动选中;
|
|
16
16
|
VS Code 内部依赖与预编译原生模块**全部由包管理器随插件一起装好** —— 无需全局 npm 安装、无需配置 `bin`、
|
|
17
17
|
无需改 profile 配置、无需第二条安装命令。
|
|
18
18
|
|
|
@@ -68,21 +68,29 @@ cd C:\Users\User\Desktop\dsh-code-server-app
|
|
|
68
68
|
pnpm install # 开发依赖(esbuild + motion);allowBuilds 已显式声明 → 不执行任何 postinstall
|
|
69
69
|
pnpm run build:client # src/factory.js → lib/client.js(不入库,必须先构建)
|
|
70
70
|
pnpm run vendor:check # 可选:查看内置 code-server 版本 vs npm 最新版
|
|
71
|
-
pnpm run vendor:code-server # ① 生成 vendor/code-server(code-server
|
|
72
|
-
pnpm run repack:
|
|
73
|
-
|
|
74
|
-
pnpm
|
|
75
|
-
|
|
76
|
-
npm publish dsh-code-server-app-<version>.tgz --access public # ⑥ 发布插件本体(同一次验证的 tarball)
|
|
71
|
+
pnpm run vendor:code-server # ① 生成 vendor/code-server(上游 code-server 树)
|
|
72
|
+
pnpm run repack:build -- --target win32-arm64,win32-x64 --pack # ② 统一脚本产出全部子包(见下表)
|
|
73
|
+
pnpm run publish:repacks # ③ 发布全部 @jinsiyu/* 子包(需 npm 登录)
|
|
74
|
+
pnpm pack # ④ → dsh-code-server-app-<version>.tgz(约 107KB)
|
|
75
|
+
npm publish dsh-code-server-app-<version>.tgz --access public # ⑤ 发布插件本体(同一次验证的 tarball)
|
|
77
76
|
```
|
|
78
77
|
|
|
78
|
+
`repack:build`(`scripts/vendor-repacks.mjs`)是**唯一的子包产出脚本**,一次生成:
|
|
79
|
+
|
|
80
|
+
| 子包 | 内容 | os/cpu |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `@jinsiyu/dshcs-code-server@<code-server 版本>` | code-server 树(`out/` + `lib/vscode` + 自带 136 个运行时依赖),**不含任何本机二进制** | 平台无关 |
|
|
83
|
+
| `@jinsiyu/dshcs-argon2-win32-arm64` / `-x64` | argon2 模块 + 该架构编译好的 `.node`(arm64 0xaa64 / x64 0x8664) | win32-<arch> |
|
|
84
|
+
| `@jinsiyu/dshcs-<名字>[-win32-<arch>]` ×24 | VS Code 内部依赖里需要构建的原生包(node-pty / @vscode/sqlite3 / kerberos / koffi / ssh2 / …) | 平台专属带 os/cpu |
|
|
85
|
+
| `@jinsiyu/dsh-code-server-runtime-win32-<arch>` | 平台聚合包:`dependencies` 用 `npm:` 别名把上面 16 个原生包 + **argon2** 装回原始名字 | win32-<arch> |
|
|
86
|
+
|
|
79
87
|
| 目标 | 命令 |
|
|
80
88
|
|---|---|
|
|
81
|
-
| **打 npm 最新版 code-server** | `pnpm run vendor:latest`(= `--force`):从 registry 取 `code-server@latest` 快照到 `vendor/code-server`;之后**必须**重跑 `repack:
|
|
89
|
+
| **打 npm 最新版 code-server** | `pnpm run vendor:latest`(= `--force`):从 registry 取 `code-server@latest` 快照到 `vendor/code-server`;之后**必须**重跑 `repack:build` 并重发全部子包 |
|
|
82
90
|
| **指定版本** | `pnpm run vendor:code-server -- --version 4.136.2` |
|
|
83
91
|
| **从已装好的树快照** | `pnpm run vendor:code-server -- --from <code-server 目录>`(秒级) |
|
|
84
|
-
|
|
|
85
|
-
|
|
|
92
|
+
| **完整重打子包** | `pnpm run repack:build -- --target win32-arm64,win32-x64 --pack`(不给 `--from` 会自动 npm install 解包 + 编译,耗时) |
|
|
93
|
+
| **只重打 code-server/argon2 包** | `node scripts/vendor-repacks.mjs --reuse --target win32-arm64,win32-x64 --pack`(复用 `repack/build` 里已有的原生包,不重新分析源树) |
|
|
86
94
|
| **发布子包** | `pnpm run publish:repacks`(`--dry-run` 预览;`--only <子串>` 过滤;`--otp <code>` / `--limit N` 应对 2FA) |
|
|
87
95
|
| **发布插件本体** | `npm publish dsh-code-server-app-<version>.tgz --access public`(发布**已验证过的那份 tarball**,不会重新打包) |
|
|
88
96
|
| **只报告版本** | `pnpm run vendor:check` |
|
|
@@ -95,27 +103,27 @@ npm publish dsh-code-server-app-<version>.tgz --access public # ⑥ 发布插
|
|
|
95
103
|
|
|
96
104
|
```powershell
|
|
97
105
|
# 包内无 postinstall → 无需 pnpm approve-builds / allowBuilds;一条命令装完
|
|
98
|
-
dsh plugin --profile web add dsh-code-server-app@0.1.
|
|
106
|
+
dsh plugin --profile web add dsh-code-server-app@0.1.40
|
|
99
107
|
# 本地 tarball 同理:
|
|
100
|
-
dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-server-app-0.1.
|
|
108
|
+
dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-server-app-0.1.40.tgz
|
|
101
109
|
```
|
|
102
110
|
|
|
103
|
-
装完即用,**没有第二步、没有「安装环境」、不弹安装指引**。0.1.
|
|
111
|
+
装完即用,**没有第二步、没有「安装环境」、不弹安装指引**。0.1.40 起主包只有 **~107KB**(插件自身代码),
|
|
104
112
|
其余全部是依赖:
|
|
105
113
|
|
|
106
|
-
- **code-server 本体**(含 `lib/vscode` 196.9MB + 它自带的 136 个运行时依赖)
|
|
107
|
-
`@jinsiyu/dshcs-code-server
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- VS Code 内部依赖里**纯 JS 的部分**(35 个:xterm / katex / typescript / ws / tar …)写在插件
|
|
114
|
+
- **code-server 本体**(含 `lib/vscode` 196.9MB + 它自带的 136 个运行时依赖)是**一个平台无关的包**
|
|
115
|
+
`@jinsiyu/dshcs-code-server@<code-server 版本>`,写进插件 `dependencies`,运行根在
|
|
116
|
+
`<profile>\node_modules\@jinsiyu\dshcs-code-server\code-server`;
|
|
117
|
+
- VS Code 内部依赖里**纯 JS 的部分**(35 个:xterm / katex / typescript / ws / tar …)也写在插件
|
|
111
118
|
`dependencies`,由 pnpm 装到 profile 的 `node_modules`(hoisted);
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
- **二进制部分**全部由 `@jinsiyu/dshcs-*` 平台包提供(每个平台各一份,os/cpu 限定):
|
|
120
|
+
`@jinsiyu/dshcs-argon2-win32-<arch>` 与 16 个原生包,经**平台聚合包**
|
|
121
|
+
`@jinsiyu/dsh-code-server-runtime-win32-<arch>` 用 `npm:` 别名装回**原始名字**
|
|
122
|
+
(`argon2` / `node-pty` / `@vscode/sqlite3` / …),聚合包挂在插件 `optionalDependencies` → pnpm 按架构自动选;
|
|
115
123
|
- 因此依赖图里**没有任何带 pre/install/postinstall 或 binding.gyp 的包** →
|
|
116
124
|
不需要 profile 的 `allowBuilds`、不执行任何构建、**使用者机器不需要 C++ 工具链**;
|
|
117
|
-
- **升级插件不再重下 code-server
|
|
118
|
-
只有 code-server 版本变化时才重新下载那 ~
|
|
125
|
+
- **升级插件不再重下 code-server**:本体包版本按 code-server 版本缓存,pnpm 直接复用;
|
|
126
|
+
只有 code-server 版本变化时才重新下载那 ~60MB,argon2 平台包只有 ~1.5MB。
|
|
119
127
|
|
|
120
128
|
### 安装机制(为什么这样设计)
|
|
121
129
|
|
|
@@ -127,38 +135,44 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-
|
|
|
127
135
|
`sh ./postinstall.sh`:Windows 无 sh,且它只认 npm/yarn 的 user-agent)拿到树 → 补齐 argon2 native
|
|
128
136
|
(win32-arm64 上游无预编译;可复用本机已有 `argon2.node`,见 `DSHCS_ARGON2_BINARY`)→
|
|
129
137
|
剥掉残留安装脚本 → 快照到 `vendor/code-server/`;
|
|
130
|
-
-
|
|
138
|
+
- 随后同一脚本把 `vendor/code-server` 打成**平台无关的本体包**:树放在包内子目录 `code-server/`
|
|
131
139
|
(npm/pnpm 打包**永远排除包根目录的 node_modules**,放在被 `files` 覆盖的子目录里才会随包发布),
|
|
132
|
-
|
|
133
|
-
写成 dependencies 会让 pnpm 再装一份)
|
|
134
|
-
-
|
|
140
|
+
包**不写 `dependencies`**(那 136 个依赖已经作为文件打包在 `code-server/node_modules` 里,
|
|
141
|
+
写成 dependencies 会让 pnpm 再装一份),并把 `node_modules/argon2` 整个删掉;
|
|
142
|
+
- **argon2** 单独打成两个平台包(`@jinsiyu/dshcs-argon2-win32-arm64` / `-x64`):与其它原生包同一套规则
|
|
143
|
+
(删 `scripts`/`files`/`binding.gyp`,删 `prebuilds/` 统一走 `build/Release`),各自用
|
|
144
|
+
`node-gyp rebuild --arch=<arch>` 现编并校验 PE machine(0xaa64 / 0x8664);
|
|
145
|
+
- **需要编译的包**同样由该脚本重打包成 `@jinsiyu/dshcs-*`:
|
|
135
146
|
复制已编译的包目录 → **删除 `scripts` / `files` / `binding.gyp` / `.hooks` / `.npmignore`**
|
|
136
147
|
(保留编译好的 `.node` 与全部运行时文件)→ 依赖里的同集包改成 `npm:` 别名 → 平台专属的加
|
|
137
148
|
`os`/`cpu` 与 `-<platform>-<arch>` 后缀;
|
|
138
|
-
-
|
|
139
|
-
|
|
149
|
+
- **平台聚合包**把重打包包与 argon2 按原始名字装回去(如 `"node-pty": "npm:@jinsiyu/dshcs-node-pty@1.2.0-beta.15"`、
|
|
150
|
+
`"argon2": "npm:@jinsiyu/dshcs-argon2-win32-arm64@0.44.0"`),于是 code-server 与 VS Code 的
|
|
151
|
+
`require('argon2')` / `require('node-pty')` 都不用改;聚合包本身 `os`/`cpu` 限定,
|
|
140
152
|
插件 `optionalDependencies` 同时声明 win32-arm64 与 win32-x64 两份 → 一条命令自动选对;
|
|
141
|
-
- **解析路径**:host 用 `require.resolve('@jinsiyu/dshcs-code-server
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
- **解析路径**:host 用 `require.resolve('@jinsiyu/dshcs-code-server/package.json')` 找到运行根
|
|
154
|
+
(包内子目录 `code-server/`),入口 `code-server/out/node/entry.js`;VS Code 内部依赖从该运行根向上查找
|
|
155
|
+
(`code-server/node_modules` → 包 `node_modules` → `<profile>/node_modules`)。
|
|
156
|
+
- **pnpm 的嵌套陷阱与兜底**:`os`/`cpu` 限定的包 pnpm 往往**嵌套装在聚合包自己的 `node_modules` 下**
|
|
157
|
+
(如 `<profile>/node_modules/@jinsiyu/dsh-code-server-runtime-win32-arm64/node_modules/argon2`),
|
|
158
|
+
既不在 profile 根也不在 code-server 树里 → host 在启动 code-server 时把该目录加进 **`NODE_PATH`**,
|
|
159
|
+
环境检测也按「code-server 运行根 + 聚合包目录」两个锚点解析(`lib/native.js`)。
|
|
160
|
+
|
|
161
|
+
> **体积提示**:插件 tarball 约 **107KB**;`@jinsiyu/dshcs-code-server` 约 **60.5MB**(解包 ~242MB);
|
|
162
|
+
> 两个 argon2 平台包各约 **1.5MB**;16 个原生包合计约 250MB。全部合计安装下载约 315MB。
|
|
149
163
|
> `vendor/` 与 `repack/` 都不入 git(见 `.gitignore`)。
|
|
150
164
|
|
|
151
|
-
> **从 ≤ 0.1.
|
|
152
|
-
>
|
|
153
|
-
>
|
|
165
|
+
> **从 ≤ 0.1.39 升级**:code-server 从「平台专属子包」改成「**一个平台无关本体包 + 两个 argon2 平台包**」,
|
|
166
|
+
> 二进制部分全部并入统一的原生包脚本管理;升级命令不变(一条
|
|
167
|
+
> `dsh plugin --profile web add dsh-code-server-app@<版本>`),旧的 `dshcs-code-server-win32-*` 子包会被 pnpm 清掉。
|
|
154
168
|
|
|
155
169
|
> **从 ≤ 0.1.35 升级**:旧版的安装根 `<profile>\.code-server-app`(含约 1.4GB 内部依赖)与
|
|
156
170
|
> 「安装环境」步骤都不再需要 —— 新版本会检测到它并打一条日志提示可安全删除:
|
|
157
171
|
> `Remove-Item -Recurse -Force <profile>\.code-server-app`。profile 的 `pnpm-workspace.yaml` 里
|
|
158
172
|
> 若还留着 `dsh-code-server-app: false` 之类的旧条目,也可以删掉(新版不再需要任何构建许可)。
|
|
159
173
|
|
|
160
|
-
> **卸载**:`dsh plugin --profile web remove dsh-code-server-app`
|
|
161
|
-
> 是独立依赖,若要彻底清干净可再 `dsh plugin --profile web remove @jinsiyu/dshcs-code-server
|
|
174
|
+
> **卸载**:`dsh plugin --profile web remove dsh-code-server-app` 即可;本体包、argon2 与原生包
|
|
175
|
+
> 是独立依赖,若要彻底清干净可再 `dsh plugin --profile web remove @jinsiyu/dshcs-code-server`
|
|
162
176
|
> (或直接在 profile 里 `pnpm remove`);若还残留旧安装根,再手动删除 `<profile>\.code-server-app`。
|
|
163
177
|
|
|
164
178
|
> 安装/依赖变化后请**重启 `dsh web`**(静态插件行与 host 探测路径在启动时加载)。
|
|
@@ -211,17 +225,18 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app
|
|
|
211
225
|
也可 `pnpm run vendor:code-server -- --version 4.136.2` 或设 `DSHCS_CODE_SERVER_VERSION`。
|
|
212
226
|
已有 `vendor/code-server` 时,不带 `--force`/`--version` 不会升级(日常 `pnpm pack` 是 no-op)。
|
|
213
227
|
- **先查再升**:`pnpm run vendor:check` 打印「内置版本 / npm latest」。
|
|
214
|
-
-
|
|
215
|
-
1. `pnpm run repack:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
- **换版本后重新出子包并发布**(全部由同一个脚本):
|
|
229
|
+
1. `pnpm run repack:build -- --target win32-arm64,win32-x64 --pack` → 新的本体包
|
|
230
|
+
(`@jinsiyu/dshcs-code-server@<新版本>`)、新的 argon2 平台包、以及按新内部依赖重建的原生包
|
|
231
|
+
(脚本会把新的「纯 JS 直装集」写进插件 `dependencies`、更新两个聚合包版本);
|
|
232
|
+
2. `pnpm run publish:repacks` → 发布;然后 bump 插件版本 → `pnpm pack` → 发布插件。
|
|
219
233
|
- **不再有运行期自动升级**:不会在启动时联网取 latest;版本完全由内置产物决定。
|
|
220
234
|
- 本机当前内置:`code-server@4.136.2`(with Code 1.136.1)。
|
|
221
235
|
|
|
222
236
|
### 兼容旧安装位
|
|
223
237
|
|
|
224
|
-
host 探测顺序:`@jinsiyu/dshcs-code-server
|
|
238
|
+
host 探测顺序:`@jinsiyu/dshcs-code-server/code-server`(**0.1.40+ 正式布局**)>
|
|
239
|
+
`@jinsiyu/dshcs-code-server-<平台>-<架构>/code-server`(0.1.37 平台专属子包)> 插件包内
|
|
225
240
|
`vendor/code-server`(0.1.36 及更早 / 开发期)> 旧版安装根
|
|
226
241
|
`<profile>\.code-server-app\node_modules\code-server`(兼容 0.1.35 及更早)> 插件包内
|
|
227
242
|
`node_modules/code-server`(开发期)> PATH/配置 `bin`。旧安装根只在启动日志里提示可删除,不再被写入。
|
|
@@ -248,7 +263,7 @@ host 探测顺序:`@jinsiyu/dshcs-code-server-<平台>-<架构>/code-server`(**0
|
|
|
248
263
|
|
|
249
264
|
| 键 | 默认 | 说明 |
|
|
250
265
|
|---|---|---|
|
|
251
|
-
| `bin` | `code-server`(占位) | 启动优先级:本配置显式 `bin` >
|
|
266
|
+
| `bin` | `code-server`(占位) | 启动优先级:本配置显式 `bin` > 本体包 `@jinsiyu/dshcs-code-server/code-server/out/node/entry.js` > 旧平台子包 `@jinsiyu/dshcs-code-server-<平台>-<架构>` > 包内 `vendor/code-server` > 旧安装根 `.code-server-app` > 插件包内 `node_modules` > PATH 中的 `code-server`。都不存在时启动报错并给出排查提示 |
|
|
252
267
|
| `host` | `127.0.0.1` | 绑定地址;`auth: none` 仅允许回环(localhost/127.0.0.1/::1) |
|
|
253
268
|
| `port` | `8090` | 端口;被占用时启动失败并给出诊断(不自动换端口) |
|
|
254
269
|
| `auth` | `none` | `none` \| `password`;非回环 host 自动要求 password |
|
package/lib/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
vendoredVersion,
|
|
49
49
|
vendorReady,
|
|
50
50
|
} from './vendor.js';
|
|
51
|
-
import { aliasNodePathDirs, resolveNativeDir, resolveRuntime, runtimePackageName, verifyNatives } from './native.js';
|
|
51
|
+
import { aliasNodePathDirs, ensureAliasLinks, resolveNativeDir, resolveRuntime, runtimePackageName, verifyNatives } from './native.js';
|
|
52
52
|
|
|
53
53
|
// schemastery 由 DSH 部署自带(官方核心依赖),仿 auto-open-web 的解析策略:
|
|
54
54
|
// 常规 import 优先,不可用时回退到全局 npm 布局的 DSH 部署副本。
|
|
@@ -645,6 +645,8 @@ export async function apply(ctx, config) {
|
|
|
645
645
|
|
|
646
646
|
let proc;
|
|
647
647
|
try {
|
|
648
|
+
// 启动前再自愈一次别名链接(插件重装/树被替换后可能丢失;幂等且只做存在性检查)
|
|
649
|
+
ensureAliasLinks();
|
|
648
650
|
const isCmd = launch.kind === 'bin' && win32() && /\.cmd$/i.test(launch.command);
|
|
649
651
|
const command = launch.kind === 'node' ? process.execPath : launch.command;
|
|
650
652
|
const spawnArgs = launch.kind === 'node' ? [launch.script, ...args] : args;
|
|
@@ -878,6 +880,15 @@ export async function apply(ctx, config) {
|
|
|
878
880
|
}
|
|
879
881
|
|
|
880
882
|
state.env = envCheck();
|
|
883
|
+
// pnpm 会把 os/cpu 限定的原生包嵌套装在聚合包下,而 VS Code 的 server-main.js 用 ESM import
|
|
884
|
+
// (不认 NODE_PATH)→ 在 code-server 树里补齐别名 junction,否则页面会 500。
|
|
885
|
+
const aliases = ensureAliasLinks();
|
|
886
|
+
if (aliases.created.length > 0) {
|
|
887
|
+
console.log(`[code-server] 已补齐 ${aliases.created.length} 个别名链接: ${aliases.created.join(', ')}`);
|
|
888
|
+
}
|
|
889
|
+
if (aliases.failed.length > 0) {
|
|
890
|
+
console.warn(`[code-server] 别名链接创建失败: ${aliases.failed.join('; ')}`);
|
|
891
|
+
}
|
|
881
892
|
if (!vendorReady()) {
|
|
882
893
|
console.warn(`[code-server] 找不到 code-server 运行树:平台子包 ${codeServerPackageName()} 未安装,`
|
|
883
894
|
+ '且包内 vendor/code-server 不存在(开发期请先 `npm run vendor:code-server`)');
|
package/lib/native.js
CHANGED
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
//
|
|
11
11
|
// 本模块只做两件事:
|
|
12
12
|
// 1. 找到本平台聚合包(以及它的依赖清单 = 期望可解析的原生模块名);
|
|
13
|
-
// 2. 从 code-server 运行位置出发校验这些模块是否真的能 require
|
|
13
|
+
// 2. 从 code-server 运行位置出发校验这些模块是否真的能 require 到;
|
|
14
|
+
// 3. 必要时在 code-server 树里补齐别名 junction(ESM import 不认 NODE_PATH,只能靠目录链)。
|
|
14
15
|
import { createRequire } from 'node:module';
|
|
15
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { existsSync, readFileSync, mkdirSync, symlinkSync } from 'node:fs';
|
|
16
17
|
import { dirname, join } from 'node:path';
|
|
17
18
|
import { PACKAGE_ROOT, codeServerRoot, profileRootOf } from './vendor.js';
|
|
18
19
|
|
|
@@ -114,3 +115,50 @@ export function verifyNatives(modules) {
|
|
|
114
115
|
}
|
|
115
116
|
return { resolved, missing };
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
/** 某个模块能否**只靠 code-server 运行根**(含其祖先 node_modules)解析。 */
|
|
120
|
+
function resolvesFromRoot(root, name) {
|
|
121
|
+
try {
|
|
122
|
+
const from = createRequire(join(root, 'package.json'));
|
|
123
|
+
for (const spec of [`${name}/package.json`, name]) {
|
|
124
|
+
try {
|
|
125
|
+
from.resolve(spec);
|
|
126
|
+
return true;
|
|
127
|
+
} catch { /* 试下一个 */ }
|
|
128
|
+
}
|
|
129
|
+
} catch { /* 忽略 */ }
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** 确保聚合包带回的别名模块能被 **code-server 树**解析。
|
|
134
|
+
*
|
|
135
|
+
* 为什么必须做:pnpm 会把带 `os`/`cpu` 限定的包**嵌套装在聚合包自己的 node_modules 下**
|
|
136
|
+
* (如 `<profile>/node_modules/@<scope>/dsh-code-server-runtime-win32-arm64/node_modules/@vscode/windows-registry`),
|
|
137
|
+
* 而 VS Code 的 `lib/vscode/out/server-main.js` 用 **ESM `import`** 加载这些包 —— ESM 不认
|
|
138
|
+
* `NODE_PATH`(那是 CJS 的兜底),只认目录链。所以这里在 `<codeServerRoot>/node_modules` 下
|
|
139
|
+
* 为每个「从树里解析不到」的别名补一个 junction,指向聚合包内的真实目录。
|
|
140
|
+
* 幂等、可重复调用;插件重装后由下次激活/启动自愈。
|
|
141
|
+
* @returns {{created:string[], failed:string[]}} */
|
|
142
|
+
export function ensureAliasLinks() {
|
|
143
|
+
const runtime = resolveRuntime();
|
|
144
|
+
const csRoot = codeServerRoot();
|
|
145
|
+
if (runtime === null || csRoot === null) return { created: [], failed: [] };
|
|
146
|
+
const linkRoot = join(csRoot, 'node_modules');
|
|
147
|
+
const created = [];
|
|
148
|
+
const failed = [];
|
|
149
|
+
for (const alias of runtime.modules) {
|
|
150
|
+
if (resolvesFromRoot(csRoot, alias)) continue; // 目录链已能看到(profile 根或树内),无需补
|
|
151
|
+
const target = resolveNativeDir(alias);
|
|
152
|
+
if (target === null) continue; // 该平台包没装上 → 交给 envCheck 报缺
|
|
153
|
+
const link = join(linkRoot, alias);
|
|
154
|
+
try {
|
|
155
|
+
if (existsSync(link)) continue;
|
|
156
|
+
mkdirSync(dirname(link), { recursive: true });
|
|
157
|
+
symlinkSync(target, link, process.platform === 'win32' ? 'junction' : 'dir');
|
|
158
|
+
created.push(alias);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
failed.push(`${alias}: ${error && error.message ? error.message : String(error)}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { created, failed };
|
|
164
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-code-server-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "Integrate code-server (VS Code in the browser) into DSH Web and Desktop: right-sidebar tab (DSH >= 0.1.5-alpha.1) with a floating-ball fallback for older hosts, over the Connection /api channel (ctx.connection.fetch; no webServer dependency) with host-side process lifecycle.",
|
|
5
5
|
"homepage": "https://github.com/jinsiyu/dsh-code-server-app",
|
|
6
6
|
"repository": {
|