dsh-remote 0.8.50 → 0.8.51
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 +1 -0
- package/README.md +1 -0
- package/lib/index.js +76 -1
- package/node_modules/buildcheck/.eslintrc.js +5 -0
- package/node_modules/buildcheck/.github/workflows/ci.yml +88 -0
- package/node_modules/buildcheck/.github/workflows/lint.yml +27 -0
- package/node_modules/buildcheck/.npmignore +3 -0
- package/node_modules/buildcheck/LICENSE +19 -0
- package/node_modules/buildcheck/README.md +106 -0
- package/node_modules/buildcheck/deps/Find-VisualStudio.cs +250 -0
- package/node_modules/buildcheck/lib/findvs.js +361 -0
- package/node_modules/buildcheck/lib/index.js +738 -0
- package/node_modules/buildcheck/package.json +36 -0
- package/node_modules/buildcheck/test/test.js +8 -0
- package/node_modules/cpu-features/.eslintrc.js +5 -0
- package/node_modules/cpu-features/.github/workflows/ci.yml +74 -0
- package/node_modules/cpu-features/.github/workflows/lint.yml +27 -0
- package/node_modules/cpu-features/LICENSE +19 -0
- package/node_modules/cpu-features/README.md +59 -0
- package/node_modules/cpu-features/binding.gyp +16 -0
- package/node_modules/cpu-features/buildcheck.js +32 -0
- package/node_modules/cpu-features/deps/cpu_features/.clang-format +4 -0
- package/node_modules/cpu-features/deps/cpu_features/.dockerignore +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/Dockerfile +5 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/aarch64_linux_cmake.yml +30 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_freebsd_cmake.yml +22 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_bazel.yml +26 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_cmake.yml +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_macos_cmake.yml +43 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_windows_cmake.yml +25 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/arm_linux_cmake.yml +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/clang_format.yml +24 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/mips_linux_cmake.yml +30 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/power_linux_cmake.yml +29 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/riscv_linux_cmake.yml +28 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/s390x_linux_cmake.yml +27 -0
- package/node_modules/cpu-features/deps/cpu_features/.grenrc.yml +21 -0
- package/node_modules/cpu-features/deps/cpu_features/BUILD.bazel +329 -0
- package/node_modules/cpu-features/deps/cpu_features/CMakeLists.txt +261 -0
- package/node_modules/cpu-features/deps/cpu_features/CONTRIBUTING.md +23 -0
- package/node_modules/cpu-features/deps/cpu_features/LICENSE +230 -0
- package/node_modules/cpu-features/deps/cpu_features/README.md +272 -0
- package/node_modules/cpu-features/deps/cpu_features/WORKSPACE +19 -0
- package/node_modules/cpu-features/deps/cpu_features/bazel/ci/README.md +5 -0
- package/node_modules/cpu-features/deps/cpu_features/bazel/platforms.bzl +11 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesConfig.cmake.in +3 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesNdkCompatConfig.cmake.in +3 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/README.md +30 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/Makefile +252 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/README.md +40 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.dot +64 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.svg +312 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/generate_image.sh +7 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/amd64/Dockerfile +48 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/toolchain/Dockerfile +34 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/CMakeLists.txt +22 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/main.cpp +11 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/vagrant/freebsd/Vagrantfile +107 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/googletest.CMakeLists.txt.in +15 -0
- package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +105 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_cache_info.h +54 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_macros.h +384 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_aarch64.h +259 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h +121 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_mips.h +74 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_ppc.h +149 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_riscv.h +72 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_s390x.h +108 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_x86.h +288 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/bit_utils.h +40 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/cpuid_x86.h +37 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/filesystem.h +39 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/hwcaps.h +240 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/stack_line_reader.h +49 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/string_view.h +110 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/windows_utils.h +70 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/CMakeLists.txt +60 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/README.md +4 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.c +205 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.h +320 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/ndk-compat-test.c +12 -0
- package/node_modules/cpu-features/deps/cpu_features/patches/0001-Add-Apple-Silicon-Support.patch +456 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/generate_badges.d +165 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/make_release.sh +75 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/run_integration.sh +490 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/test_integration.sh +79 -0
- package/node_modules/cpu-features/deps/cpu_features/src/copy.inl +19 -0
- package/node_modules/cpu-features/deps/cpu_features/src/define_introspection.inl +86 -0
- package/node_modules/cpu-features/deps/cpu_features/src/define_introspection_and_hwcaps.inl +26 -0
- package/node_modules/cpu-features/deps/cpu_features/src/equals.inl +22 -0
- package/node_modules/cpu-features/deps/cpu_features/src/filesystem.c +62 -0
- package/node_modules/cpu-features/deps/cpu_features/src/hwcaps.c +169 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64__base_implementation.inl +88 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_linux_or_android.c +79 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.c +82 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_windows.c +138 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_arm_linux_or_android.c +212 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_mips_linux_or_android.c +93 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_ppc_linux.c +163 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_riscv_linux.c +111 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_s390x_linux.c +120 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86__base_implementation.inl +2055 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_freebsd.c +68 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_linux_or_android.c +58 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_macos.c +57 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_windows.c +58 -0
- package/node_modules/cpu-features/deps/cpu_features/src/stack_line_reader.c +132 -0
- package/node_modules/cpu-features/deps/cpu_features/src/string_view.c +192 -0
- package/node_modules/cpu-features/deps/cpu_features/src/utils/list_cpu_features.c +461 -0
- package/node_modules/cpu-features/deps/cpu_features/test/CMakeLists.txt +114 -0
- package/node_modules/cpu-features/deps/cpu_features/test/bit_utils_test.cc +53 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_aarch64_test.cc +396 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_arm_test.cc +384 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_mips_test.cc +176 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_ppc_test.cc +131 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_riscv_test.cc +180 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_s390x_test.cc +82 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_x86_test.cc +1729 -0
- package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.cc +103 -0
- package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.h +61 -0
- package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.cc +52 -0
- package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.h +31 -0
- package/node_modules/cpu-features/deps/cpu_features/test/stack_line_reader_test.cc +132 -0
- package/node_modules/cpu-features/deps/cpu_features/test/string_view_test.cc +202 -0
- package/node_modules/cpu-features/lib/index.js +5 -0
- package/node_modules/cpu-features/package.json +40 -0
- package/node_modules/cpu-features/src/binding.cc +151 -0
- package/node_modules/cpu-features/test/test.js +12 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -276,6 +276,7 @@ Deploying to a product profile is a separate, explicit action (`./sync.sh`) for
|
|
|
276
276
|
| `webInstallPrefix` | string | `''` | where an automatic deployment installs dsh; empty means `$HOME/.dsh-remote/dsh` (no system directory, no PATH change) |
|
|
277
277
|
| `webInstallVersion` | string | `0.1.5-rc.2` | dsh version an automatic deployment installs; the default is the first that can start the web surface on Linux |
|
|
278
278
|
| `webInstallRegistry` | string | `''` | npm registry for the install; **empty keeps the remote's own config**, so an internal mirror is never overridden |
|
|
279
|
+
| `localTools` | string | `bootstrap` | which `rw_*` tools a LOCAL session (cwd outside every remote mirror) sees (issue #63): `bootstrap` keeps only the configuration loop `rw_machines`/`rw_connect`/`rw_pick_workspace` (the other 19 refuse a local session with "this session is LOCAL", so exposing them just wastes schema budget); `none` hides all `rw_*` (remote setup happens via the settings page only); `all` restores the legacy full surface. REMOTE sessions (cwd inside a mirror) always see everything; an invalid value degrades to `bootstrap` |
|
|
279
280
|
|
|
280
281
|
> The authoritative list is the `Config` schema in `lib/index.js`; this table mirrors it.
|
|
281
282
|
|
package/README.md
CHANGED
|
@@ -258,6 +258,7 @@ scripts/dev-run.sh --status # 是否在运行
|
|
|
258
258
|
| `webInstallPrefix` | string | `''` | 自动部署装到远端的哪个目录;留空用 `$HOME/.dsh-remote/dsh`(不写系统目录、不改 PATH) |
|
|
259
259
|
| `webInstallVersion` | string | `0.1.5-rc.2` | 自动部署安装的 dsh 版本;默认值是第一个在 Linux 上能启动 web 的版本 |
|
|
260
260
|
| `webInstallRegistry` | string | `''` | 安装用的 npm 源;**留空沿用远端自己的配置**,不会覆盖内网镜像 |
|
|
261
|
+
| `localTools` | string | `bootstrap` | 本地 session(cwd 不在远程镜像里)暴露哪些 `rw_*` 工具(issue #63):`bootstrap`=只暴露配置闭环 `rw_machines`/`rw_connect`/`rw_pick_workspace`(其余 19 个在本地 session 必然报 "this session is LOCAL",暴露只是白占 schema);`none`=完全不暴露 `rw_*`(远程配置只能走设置页);`all`=旧的 full 暴露。远程 session(cwd 在镜像里)不受影响,始终全量;非法值按 `bootstrap` 处理 |
|
|
261
262
|
|
|
262
263
|
> 权威清单是 `lib/index.js` 里的 `Config` schema,本表与之一致。
|
|
263
264
|
|
package/lib/index.js
CHANGED
|
@@ -99,6 +99,35 @@ export function win32FolderPickScript() {
|
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/** The rw_* tools a LOCAL session keeps under `localTools: 'bootstrap'`
|
|
103
|
+
* (issue #63): exactly the configuration loop — list machines, connect, pick
|
|
104
|
+
* a workspace. Every other rw_* tool needs a mirror-bound session and refuses
|
|
105
|
+
* a local one with "this session is LOCAL", so keeping it visible only spends
|
|
106
|
+
* schema budget. Exported so the test suite pins the set against the real
|
|
107
|
+
* registrations. */
|
|
108
|
+
export const LOCAL_BOOTSTRAP_TOOLS = ['rw_machines', 'rw_connect', 'rw_pick_workspace']
|
|
109
|
+
|
|
110
|
+
/** Normalize the `localTools` config value (issue #63). Anything unrecognized
|
|
111
|
+
* degrades to the safe default 'bootstrap' rather than disabling the filter
|
|
112
|
+
* (a typo must not silently re-expose the dead surface the user asked to
|
|
113
|
+
* hide) — mirroring how an unknown value would otherwise be mistaken for
|
|
114
|
+
* 'all'. */
|
|
115
|
+
export function normalizeLocalTools(value) {
|
|
116
|
+
const v = String(value || '').trim().toLowerCase()
|
|
117
|
+
return v === 'none' || v === 'all' ? v : 'bootstrap'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** rw_pick_workspace's closing "what next" sentence (issue #63). In a LOCAL
|
|
121
|
+
* session `rw_sync` cannot run — the mirror path must be opened as a NEW
|
|
122
|
+
* session first, because tool routing keys on the session's cwd and picking
|
|
123
|
+
* a workspace does not change it. Only a mirror-bound (or caller-context-
|
|
124
|
+
* less) session can sync right away. */
|
|
125
|
+
export function pickWorkspaceNextStep(localSession) {
|
|
126
|
+
return localSession
|
|
127
|
+
? 'NOTE: this session is LOCAL — rw_sync and the other remote tools refuse to run here. Open a session whose workspace IS the local mirror path above, then run rw_sync there to download the remote files.'
|
|
128
|
+
: 'Run rw_sync to download its files into the local mirror.'
|
|
129
|
+
}
|
|
130
|
+
|
|
102
131
|
// Web and Desktop share the SSH tools; each optional UI transport is attached
|
|
103
132
|
// reactively below, so service startup order does not drop the JSON routes.
|
|
104
133
|
export const inject = ['tools', 'systemPrompt']
|
|
@@ -235,6 +264,16 @@ export const Config = z.object({
|
|
|
235
264
|
/** npm registry to install from. Empty uses the remote's own npm config, which
|
|
236
265
|
* is what an internal mirror needs to stay in effect. */
|
|
237
266
|
webInstallRegistry: z.string().default(''),
|
|
267
|
+
/** Which rw_* tools a LOCAL session (session cwd is NOT a remote-workspaces
|
|
268
|
+
* mirror) sees (issue #63): `bootstrap` (default) exposes only the
|
|
269
|
+
* configuration loop — rw_machines / rw_connect / rw_pick_workspace — since
|
|
270
|
+
* the other tools can never succeed there (they refuse with "this session
|
|
271
|
+
* is LOCAL") and exposing them only spends ~4k tokens of schema per request;
|
|
272
|
+
* `none` hides every rw_* tool (remote setup then happens via the settings
|
|
273
|
+
* page only); `all` keeps the legacy full surface. A REMOTE session (cwd
|
|
274
|
+
* inside a mirror) always sees all tools, and an invalid value falls back
|
|
275
|
+
* to `bootstrap`. (schemastery 3.18 has no .enum — validated in code.) */
|
|
276
|
+
localTools: z.string().default('bootstrap'),
|
|
238
277
|
})
|
|
239
278
|
|
|
240
279
|
// ── shell / path helpers (pure implementations in lib/paths.js) ───────────
|
|
@@ -1786,8 +1825,11 @@ export async function apply(ctx, config) {
|
|
|
1786
1825
|
if (!b.bound) persistWorkspace(p)
|
|
1787
1826
|
const local = ensureMirror(p, b.host, b.username, b.port, { alias: b.alias || "" })
|
|
1788
1827
|
startAutoPush(local)
|
|
1828
|
+
// The closing hint depends on where THIS session stands (issue #63):
|
|
1829
|
+
// in a LOCAL session "Run rw_sync" is a dead instruction — rw_sync
|
|
1830
|
+
// refuses a local session — so say the mirror must be OPENED first.
|
|
1789
1831
|
return {
|
|
1790
|
-
text: `Remote workspace set to ${shown} on ${b.username}@${b.host}.\nLocal mirror (native workspace path): ${local}\n\
|
|
1832
|
+
text: `Remote workspace set to ${shown} on ${b.username}@${b.host}.\nLocal mirror (native workspace path): ${local}\n\n${pickWorkspaceNextStep(b.local)}`,
|
|
1791
1833
|
}
|
|
1792
1834
|
},
|
|
1793
1835
|
}),
|
|
@@ -2535,6 +2577,39 @@ export async function apply(ctx, config) {
|
|
|
2535
2577
|
},
|
|
2536
2578
|
})
|
|
2537
2579
|
|
|
2580
|
+
// ── local-session tool visibility (issue #63) ────────────────────────────
|
|
2581
|
+
// All rw_* tools register globally (at registration time there is no session
|
|
2582
|
+
// to consult), but in a LOCAL session the operation tools can never succeed:
|
|
2583
|
+
// bindingFor() refuses them with "this session is LOCAL". Exposing them
|
|
2584
|
+
// anyway costs every local request a few thousand tokens of dead schema.
|
|
2585
|
+
// The `system-prompt/assemble` waterfall is where the final per-request tool
|
|
2586
|
+
// list passes with the calling agent attached, so the SAME cwd test the
|
|
2587
|
+
// prompt section above already performs can trim the list there. A session
|
|
2588
|
+
// whose cwd maps to a mirror keeps the full surface; anything else — a
|
|
2589
|
+
// plain local directory, or a mirror whose meta is missing/unparsable
|
|
2590
|
+
// (resolveMirror reports no binding; bindingFor refuses it as local too) —
|
|
2591
|
+
// is reduced per config.localTools. An assembly without agent/cwd is left
|
|
2592
|
+
// alone, matching bindingFor's "no caller context" semantics. `ctx.on` is
|
|
2593
|
+
// cordis-core, but guard like the other
|
|
2594
|
+
// optional surfaces: a minimal embedding (or a small test double) without
|
|
2595
|
+
// event support simply keeps the legacy full surface.
|
|
2596
|
+
if (typeof ctx.on === 'function') {
|
|
2597
|
+
ctx.on('system-prompt/assemble', async (_assembly, assembleContext, next) => {
|
|
2598
|
+
const assembled = await next()
|
|
2599
|
+
const mode = normalizeLocalTools(config.localTools)
|
|
2600
|
+
if (mode === 'all') return assembled
|
|
2601
|
+
const agent = assembleContext && assembleContext.agent
|
|
2602
|
+
const cwd = agent && agent.session && agent.session.header && agent.session.header.cwd
|
|
2603
|
+
if (!cwd) return assembled // no caller context → not definitively local
|
|
2604
|
+
const { remotePath, machine } = resolveMirrorForLocal(String(cwd))
|
|
2605
|
+
if (remotePath && machine) return assembled // remote session → full surface
|
|
2606
|
+
const tools = (assembled.tools || []).filter(
|
|
2607
|
+
(t) => !t.name || !t.name.startsWith('rw_') || (mode === 'bootstrap' && LOCAL_BOOTSTRAP_TOOLS.includes(t.name)),
|
|
2608
|
+
)
|
|
2609
|
+
return { ...assembled, tools }
|
|
2610
|
+
})
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2538
2613
|
// ── slash commands ─────────────────────────────────────────────────────────
|
|
2539
2614
|
const commands = ctx.get('commands')
|
|
2540
2615
|
if (commands !== undefined) {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
tests-linux:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
persist-credentials: false
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
- name: Check Node.js version
|
|
24
|
+
run: node -pe process.versions
|
|
25
|
+
- name: Install module
|
|
26
|
+
run: npm install
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: npm test
|
|
29
|
+
tests-macos-intel:
|
|
30
|
+
runs-on: macos-15-intel
|
|
31
|
+
strategy:
|
|
32
|
+
fail-fast: false
|
|
33
|
+
matrix:
|
|
34
|
+
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
with:
|
|
38
|
+
persist-credentials: false
|
|
39
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
40
|
+
uses: actions/setup-node@v4
|
|
41
|
+
with:
|
|
42
|
+
node-version: ${{ matrix.node-version }}
|
|
43
|
+
- name: Check Node.js version
|
|
44
|
+
run: node -pe process.versions
|
|
45
|
+
- name: Install module
|
|
46
|
+
run: npm install
|
|
47
|
+
- name: Run tests
|
|
48
|
+
run: npm test
|
|
49
|
+
tests-macos-arm:
|
|
50
|
+
runs-on: macos-latest
|
|
51
|
+
strategy:
|
|
52
|
+
fail-fast: false
|
|
53
|
+
matrix:
|
|
54
|
+
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
with:
|
|
58
|
+
persist-credentials: false
|
|
59
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
60
|
+
uses: actions/setup-node@v4
|
|
61
|
+
with:
|
|
62
|
+
node-version: ${{ matrix.node-version }}
|
|
63
|
+
- name: Check Node.js version
|
|
64
|
+
run: node -pe process.versions
|
|
65
|
+
- name: Install module
|
|
66
|
+
run: npm install
|
|
67
|
+
- name: Run tests
|
|
68
|
+
run: npm test
|
|
69
|
+
tests-windows-2022:
|
|
70
|
+
runs-on: windows-2022
|
|
71
|
+
strategy:
|
|
72
|
+
fail-fast: false
|
|
73
|
+
matrix:
|
|
74
|
+
node-version: [24.x]
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/checkout@v4
|
|
77
|
+
with:
|
|
78
|
+
persist-credentials: false
|
|
79
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
80
|
+
uses: actions/setup-node@v4
|
|
81
|
+
with:
|
|
82
|
+
node-version: ${{ matrix.node-version }}
|
|
83
|
+
- name: Check Node.js version
|
|
84
|
+
run: node -pe process.versions
|
|
85
|
+
- name: Install module
|
|
86
|
+
run: npm install
|
|
87
|
+
- name: Run tests
|
|
88
|
+
run: npm test
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
env:
|
|
9
|
+
NODE_VERSION: 22.x
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint-js:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
- name: Use Node.js ${{ env.NODE_VERSION }}
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ env.NODE_VERSION }}
|
|
22
|
+
- name: Check Node.js version
|
|
23
|
+
run: node -pe process.versions
|
|
24
|
+
- name: Install ESLint + ESLint configs/plugins
|
|
25
|
+
run: npm install --only=dev
|
|
26
|
+
- name: Lint files
|
|
27
|
+
run: npm run lint
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright Brian White. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
|
5
|
+
deal in the Software without restriction, including without limitation the
|
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
IN THE SOFTWARE.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
|
|
3
|
+
Build environment checking for [node.js](http://nodejs.org/).
|
|
4
|
+
|
|
5
|
+
This allows for autoconf-like functionality for node addons/build scripts.
|
|
6
|
+
|
|
7
|
+
**Note:** Obsolete and/or exotic build environments or platforms not supported
|
|
8
|
+
by node.js are not supported.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
* [node.js](http://nodejs.org/) -- v10.0.0 or newer
|
|
13
|
+
* Supported compilers:
|
|
14
|
+
* gcc
|
|
15
|
+
* clang
|
|
16
|
+
* MSVC 2013+ and Windows SDK 8.1+
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
npm install buildcheck
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Check if a C function exists
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
'use strict';
|
|
28
|
+
|
|
29
|
+
const BuildEnvironment = require('buildcheck');
|
|
30
|
+
|
|
31
|
+
const buildEnv = new BuildEnvironment();
|
|
32
|
+
|
|
33
|
+
console.log(buildEnv.checkFunction('c', 'preadv2'));
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Check if a C header is usable
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
'use strict';
|
|
40
|
+
|
|
41
|
+
const BuildEnvironment = require('buildcheck');
|
|
42
|
+
|
|
43
|
+
const buildEnv = new BuildEnvironment();
|
|
44
|
+
|
|
45
|
+
console.log(buildEnv.checkHeader('c', 'linux/io_uring.h'));
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Try to compile some C code
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
'use strict';
|
|
52
|
+
|
|
53
|
+
const BuildEnvironment = require('buildcheck');
|
|
54
|
+
|
|
55
|
+
const buildEnv = new BuildEnvironment();
|
|
56
|
+
|
|
57
|
+
// Should be a successful compile
|
|
58
|
+
console.log(buildEnv.tryCompile('c', 'int main() { return 0; }'));
|
|
59
|
+
|
|
60
|
+
// Should be a failed compile
|
|
61
|
+
console.log(buildEnv.tryCompile('c', 'int main() { return z; }'));
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API
|
|
65
|
+
|
|
66
|
+
### Exports
|
|
67
|
+
|
|
68
|
+
The exported value is `BuildEnvironment`, the main class for dealing with a build environment.
|
|
69
|
+
|
|
70
|
+
### BuildEnvironment
|
|
71
|
+
|
|
72
|
+
#### Methods
|
|
73
|
+
|
|
74
|
+
* **(constructor)**([< _object_ >config]) - Creates and returns a new BuildEnvironment instance. `config` may contain:
|
|
75
|
+
|
|
76
|
+
* **compilerC** - _string_ - C compiler command to use. *Note: this is ignored on Windows.* **Default:** `process.env.CC` or `'cc'`
|
|
77
|
+
|
|
78
|
+
* **compilerCXX** - _string_ - C++ compiler command to use. *Note: this is ignored on Windows.* **Default:** `process.env.CXX` or `'c++'`
|
|
79
|
+
|
|
80
|
+
* **msvs_version** - _mixed_ - A string or number containing the year of the Visual Studio compiler to use. *Note: this is for Windows only.* **Default:** newest version installed
|
|
81
|
+
|
|
82
|
+
* **checkDeclared**(< _string_ >lang, < _string_ >symbolName[, < _object_ >options]) - _boolean_ - Checks if a symbol `symbolName` is declared where `lang` is either `'c'` or `'c++'`. Returns `true` if symbol exists, `false` otherwise. `options` may contain:
|
|
83
|
+
|
|
84
|
+
* **headers** - _array_ - A list of headers to try when checking if the symbol is declared. `checkFunction()` will always first try without a library. If not supplied, a default list of common (platform-specific) headers will be used.
|
|
85
|
+
|
|
86
|
+
* **searchLibs** - _array_ - A list of library names (without the `'-l'` prefix) to try when checking if the symbol is declared. `checkDeclared()` will always first try without a library.
|
|
87
|
+
|
|
88
|
+
* **checkFunction**(< _string_ >lang, < _string_ >functionName[, < _object_ >options]) - _boolean_ - Checks if a function `functionName` exists and is linkable where `lang` is either `'c'` or `'c++'`. Returns `true` if function exists, `false` otherwise. `options` may contain:
|
|
89
|
+
|
|
90
|
+
* **searchLibs** - _array_ - A list of library names (without the `'-l'` prefix) to try when checking for this function. `checkFunction()` will always first try without a library.
|
|
91
|
+
|
|
92
|
+
* **checkFeature**(< _string_ >featureName) - _mixed_ - Executes a special test for a "feature" and returns the result. Supported values for `featureName`:
|
|
93
|
+
|
|
94
|
+
* `'strerror_r'` - Returns an object containing:
|
|
95
|
+
|
|
96
|
+
* `declared` - _boolean_ - Whether `strerror_r()` is declared
|
|
97
|
+
|
|
98
|
+
* `returnsCharPtr` - _boolean_ - If `strerror_r()` is declared, whether it returns `char*` (a GNU extension) or not.
|
|
99
|
+
|
|
100
|
+
* **checkHeader**(< _string_ >lang, < _string_ >headerName) - _boolean_ - Checks if the header `headerName` exists and is usable where `lang` is either `'c'` or `'c++'`. Returns `true` if the header exists and is usable, `false` otherwise.
|
|
101
|
+
|
|
102
|
+
* **defines**([< _string_ >lang[, < _boolean_ >rendered]]) - _array_ - Returns a list of features, functions, headers, and symbols known to be defined by this build environment instance. `lang` is either `'c'` or `'c++'` If `lang` is not set, defines for both `'c'` and `'c++'` will be returned. If `rendered` is `true` (defaults to `false`), autoconf-style defines (e.g. "HAVE_FOO=1") will be returned instead. Defines coming from features utilize base strings/names from autoconf for better compatibility.
|
|
103
|
+
|
|
104
|
+
* **libs**([< _string_ >lang]) - _array_ - Returns a list of (`'-l'`-prefixed) libraries known to be required for features and functions defined by this build environment instance. `lang` is either `'c'` or `'c++'` If `lang` is not set, defines for both `'c'` and `'c++'` will be returned.
|
|
105
|
+
|
|
106
|
+
* **tryCompile**(< _string_ >lang, < _string_ >code[, < _array_ >compilerParams]) - _mixed_ - Attempts to compile `code` where `lang` is either `'c'` or `'c++'`. `compilerParams` is an optional array of compiler/linker flags to include. Returns `true` on successful compilation, or an _Error_ instance with an `output` property containing the compiler error output.
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Copyright 2017 - Refael Ackermann
|
|
2
|
+
// Distributed under MIT style license
|
|
3
|
+
// See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
|
|
4
|
+
|
|
5
|
+
// Usage:
|
|
6
|
+
// powershell -ExecutionPolicy Unrestricted -Command "Add-Type -Path Find-VisualStudio.cs; [VisualStudioConfiguration.Main]::PrintJson()"
|
|
7
|
+
// This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
|
|
8
|
+
|
|
9
|
+
using System;
|
|
10
|
+
using System.Text;
|
|
11
|
+
using System.Runtime.InteropServices;
|
|
12
|
+
using System.Collections.Generic;
|
|
13
|
+
|
|
14
|
+
namespace VisualStudioConfiguration
|
|
15
|
+
{
|
|
16
|
+
[Flags]
|
|
17
|
+
public enum InstanceState : uint
|
|
18
|
+
{
|
|
19
|
+
None = 0,
|
|
20
|
+
Local = 1,
|
|
21
|
+
Registered = 2,
|
|
22
|
+
NoRebootRequired = 4,
|
|
23
|
+
NoErrors = 8,
|
|
24
|
+
Complete = 4294967295,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[Guid("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848")]
|
|
28
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
29
|
+
[ComImport]
|
|
30
|
+
public interface IEnumSetupInstances
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
void Next([MarshalAs(UnmanagedType.U4), In] int celt,
|
|
34
|
+
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface), Out] ISetupInstance[] rgelt,
|
|
35
|
+
[MarshalAs(UnmanagedType.U4)] out int pceltFetched);
|
|
36
|
+
|
|
37
|
+
void Skip([MarshalAs(UnmanagedType.U4), In] int celt);
|
|
38
|
+
|
|
39
|
+
void Reset();
|
|
40
|
+
|
|
41
|
+
[return: MarshalAs(UnmanagedType.Interface)]
|
|
42
|
+
IEnumSetupInstances Clone();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
|
|
46
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
47
|
+
[ComImport]
|
|
48
|
+
public interface ISetupConfiguration
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[Guid("26AAB78C-4A60-49D6-AF3B-3C35BC93365D")]
|
|
53
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
54
|
+
[ComImport]
|
|
55
|
+
public interface ISetupConfiguration2 : ISetupConfiguration
|
|
56
|
+
{
|
|
57
|
+
|
|
58
|
+
[return: MarshalAs(UnmanagedType.Interface)]
|
|
59
|
+
IEnumSetupInstances EnumInstances();
|
|
60
|
+
|
|
61
|
+
[return: MarshalAs(UnmanagedType.Interface)]
|
|
62
|
+
ISetupInstance GetInstanceForCurrentProcess();
|
|
63
|
+
|
|
64
|
+
[return: MarshalAs(UnmanagedType.Interface)]
|
|
65
|
+
ISetupInstance GetInstanceForPath([MarshalAs(UnmanagedType.LPWStr), In] string path);
|
|
66
|
+
|
|
67
|
+
[return: MarshalAs(UnmanagedType.Interface)]
|
|
68
|
+
IEnumSetupInstances EnumAllInstances();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[Guid("B41463C3-8866-43B5-BC33-2B0676F7F42E")]
|
|
72
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
73
|
+
[ComImport]
|
|
74
|
+
public interface ISetupInstance
|
|
75
|
+
{
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[Guid("89143C9A-05AF-49B0-B717-72E218A2185C")]
|
|
79
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
80
|
+
[ComImport]
|
|
81
|
+
public interface ISetupInstance2 : ISetupInstance
|
|
82
|
+
{
|
|
83
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
84
|
+
string GetInstanceId();
|
|
85
|
+
|
|
86
|
+
[return: MarshalAs(UnmanagedType.Struct)]
|
|
87
|
+
System.Runtime.InteropServices.ComTypes.FILETIME GetInstallDate();
|
|
88
|
+
|
|
89
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
90
|
+
string GetInstallationName();
|
|
91
|
+
|
|
92
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
93
|
+
string GetInstallationPath();
|
|
94
|
+
|
|
95
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
96
|
+
string GetInstallationVersion();
|
|
97
|
+
|
|
98
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
99
|
+
string GetDisplayName([MarshalAs(UnmanagedType.U4), In] int lcid);
|
|
100
|
+
|
|
101
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
102
|
+
string GetDescription([MarshalAs(UnmanagedType.U4), In] int lcid);
|
|
103
|
+
|
|
104
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
105
|
+
string ResolvePath([MarshalAs(UnmanagedType.LPWStr), In] string pwszRelativePath);
|
|
106
|
+
|
|
107
|
+
[return: MarshalAs(UnmanagedType.U4)]
|
|
108
|
+
InstanceState GetState();
|
|
109
|
+
|
|
110
|
+
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
|
|
111
|
+
ISetupPackageReference[] GetPackages();
|
|
112
|
+
|
|
113
|
+
ISetupPackageReference GetProduct();
|
|
114
|
+
|
|
115
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
116
|
+
string GetProductPath();
|
|
117
|
+
|
|
118
|
+
[return: MarshalAs(UnmanagedType.VariantBool)]
|
|
119
|
+
bool IsLaunchable();
|
|
120
|
+
|
|
121
|
+
[return: MarshalAs(UnmanagedType.VariantBool)]
|
|
122
|
+
bool IsComplete();
|
|
123
|
+
|
|
124
|
+
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
|
|
125
|
+
ISetupPropertyStore GetProperties();
|
|
126
|
+
|
|
127
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
128
|
+
string GetEnginePath();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[Guid("DA8D8A16-B2B6-4487-A2F1-594CCCCD6BF5")]
|
|
132
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
133
|
+
[ComImport]
|
|
134
|
+
public interface ISetupPackageReference
|
|
135
|
+
{
|
|
136
|
+
|
|
137
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
138
|
+
string GetId();
|
|
139
|
+
|
|
140
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
141
|
+
string GetVersion();
|
|
142
|
+
|
|
143
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
144
|
+
string GetChip();
|
|
145
|
+
|
|
146
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
147
|
+
string GetLanguage();
|
|
148
|
+
|
|
149
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
150
|
+
string GetBranch();
|
|
151
|
+
|
|
152
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
153
|
+
string GetType();
|
|
154
|
+
|
|
155
|
+
[return: MarshalAs(UnmanagedType.BStr)]
|
|
156
|
+
string GetUniqueId();
|
|
157
|
+
|
|
158
|
+
[return: MarshalAs(UnmanagedType.VariantBool)]
|
|
159
|
+
bool GetIsExtension();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[Guid("c601c175-a3be-44bc-91f6-4568d230fc83")]
|
|
163
|
+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
164
|
+
[ComImport]
|
|
165
|
+
public interface ISetupPropertyStore
|
|
166
|
+
{
|
|
167
|
+
|
|
168
|
+
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
|
|
169
|
+
string[] GetNames();
|
|
170
|
+
|
|
171
|
+
object GetValue([MarshalAs(UnmanagedType.LPWStr), In] string pwszName);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
|
|
175
|
+
[CoClass(typeof(SetupConfigurationClass))]
|
|
176
|
+
[ComImport]
|
|
177
|
+
public interface SetupConfiguration : ISetupConfiguration2, ISetupConfiguration
|
|
178
|
+
{
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D")]
|
|
182
|
+
[ClassInterface(ClassInterfaceType.None)]
|
|
183
|
+
[ComImport]
|
|
184
|
+
public class SetupConfigurationClass
|
|
185
|
+
{
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public static class Main
|
|
189
|
+
{
|
|
190
|
+
public static void PrintJson()
|
|
191
|
+
{
|
|
192
|
+
ISetupConfiguration query = new SetupConfiguration();
|
|
193
|
+
ISetupConfiguration2 query2 = (ISetupConfiguration2)query;
|
|
194
|
+
IEnumSetupInstances e = query2.EnumAllInstances();
|
|
195
|
+
|
|
196
|
+
int pceltFetched;
|
|
197
|
+
ISetupInstance2[] rgelt = new ISetupInstance2[1];
|
|
198
|
+
List<string> instances = new List<string>();
|
|
199
|
+
while (true)
|
|
200
|
+
{
|
|
201
|
+
e.Next(1, rgelt, out pceltFetched);
|
|
202
|
+
if (pceltFetched <= 0)
|
|
203
|
+
{
|
|
204
|
+
Console.WriteLine(String.Format("[{0}]", string.Join(",", instances.ToArray())));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
try
|
|
209
|
+
{
|
|
210
|
+
instances.Add(InstanceJson(rgelt[0]));
|
|
211
|
+
}
|
|
212
|
+
catch (COMException)
|
|
213
|
+
{
|
|
214
|
+
// Ignore instances that can't be queried.
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private static string JsonString(string s)
|
|
220
|
+
{
|
|
221
|
+
return "\"" + s.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private static string InstanceJson(ISetupInstance2 setupInstance2)
|
|
225
|
+
{
|
|
226
|
+
// Visual Studio component directory:
|
|
227
|
+
// https://docs.microsoft.com/en-us/visualstudio/install/workload-and-component-ids
|
|
228
|
+
|
|
229
|
+
StringBuilder json = new StringBuilder();
|
|
230
|
+
json.Append("{");
|
|
231
|
+
|
|
232
|
+
string path = JsonString(setupInstance2.GetInstallationPath());
|
|
233
|
+
json.Append(String.Format("\"path\":{0},", path));
|
|
234
|
+
|
|
235
|
+
string version = JsonString(setupInstance2.GetInstallationVersion());
|
|
236
|
+
json.Append(String.Format("\"version\":{0},", version));
|
|
237
|
+
|
|
238
|
+
List<string> packages = new List<string>();
|
|
239
|
+
foreach (ISetupPackageReference package in setupInstance2.GetPackages())
|
|
240
|
+
{
|
|
241
|
+
string id = JsonString(package.GetId());
|
|
242
|
+
packages.Add(id);
|
|
243
|
+
}
|
|
244
|
+
json.Append(String.Format("\"packages\":[{0}]", string.Join(",", packages.ToArray())));
|
|
245
|
+
|
|
246
|
+
json.Append("}");
|
|
247
|
+
return json.ToString();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|