@volcengine/tls-observer-claude-code-install 0.0.2 → 0.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @volcengine/tls-observer-claude-code-install
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 兼容 windows 发布
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 包同步更新
14
+
3
15
  ## 0.0.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,12 +1,105 @@
1
- import { execFile, execFileSync, spawn } from "node:child_process";
1
+ import { execFileSync } from "node:child_process";
2
2
  import { homedir, tmpdir } from "node:os";
3
3
  import { pathToFileURL } from "node:url";
4
- import { promisify } from "node:util";
5
4
  import promises from "node:readline/promises";
6
5
  import { randomInt } from "node:crypto";
6
+ import * as __rspack_external_cross_spawn_96b24ecb from "cross-spawn";
7
7
  import * as __rspack_external_node_fs_promises_153e37e0 from "node:fs/promises";
8
8
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
9
- const execFileAsync = promisify(execFile);
9
+ var __webpack_modules__ = {};
10
+ var __webpack_module_cache__ = {};
11
+ function __webpack_require__(moduleId) {
12
+ var cachedModule = __webpack_module_cache__[moduleId];
13
+ if (void 0 !== cachedModule) return cachedModule.exports;
14
+ var module = __webpack_module_cache__[moduleId] = {
15
+ exports: {}
16
+ };
17
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
18
+ return module.exports;
19
+ }
20
+ __webpack_require__.m = __webpack_modules__;
21
+ (()=>{
22
+ __webpack_require__.add = function(modules) {
23
+ Object.assign(__webpack_require__.m, modules);
24
+ };
25
+ })();
26
+ __webpack_require__.add({
27
+ "cross-spawn" (module) {
28
+ module.exports = __rspack_external_cross_spawn_96b24ecb;
29
+ },
30
+ "../tls-observer-shared/src/cross-platform-spawn.cjs" (__unused_rspack_module, exports, __webpack_require__) {
31
+ const crossSpawnModule = __webpack_require__("cross-spawn");
32
+ const crossSpawn = crossSpawnModule.default ?? crossSpawnModule;
33
+ const DEFAULT_MAX_BUFFER = 1048576;
34
+ function outputTooLargeError(command, maxBuffer) {
35
+ const error = new Error(`${command} output exceeded ${maxBuffer} bytes`);
36
+ error.code = 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
37
+ return error;
38
+ }
39
+ async function runCommand(command, args, options = {}) {
40
+ return new Promise((resolve, reject)=>{
41
+ const child = crossSpawn(command, args, {
42
+ cwd: options.cwd,
43
+ env: options.env,
44
+ stdio: 'inherit' === options.stdio ? 'inherit' : [
45
+ 'ignore',
46
+ 'pipe',
47
+ 'pipe'
48
+ ],
49
+ windowsHide: true
50
+ });
51
+ const maxBuffer = options.maxBuffer ?? DEFAULT_MAX_BUFFER;
52
+ let stdout = '';
53
+ let stderr = '';
54
+ let outputBytes = 0;
55
+ let settled = false;
56
+ let timer;
57
+ const finish = (error)=>{
58
+ if (settled) return;
59
+ settled = true;
60
+ if (timer) clearTimeout(timer);
61
+ if (error) {
62
+ error.stdout ??= stdout;
63
+ error.stderr ??= stderr;
64
+ reject(error);
65
+ } else resolve({
66
+ stdout,
67
+ stderr
68
+ });
69
+ };
70
+ const appendOutput = (target, chunk)=>{
71
+ const text = String(chunk);
72
+ outputBytes += Buffer.byteLength(text);
73
+ if (outputBytes > maxBuffer) {
74
+ child.kill();
75
+ finish(outputTooLargeError(command, maxBuffer));
76
+ return;
77
+ }
78
+ if ('stdout' === target) stdout += text;
79
+ else stderr += text;
80
+ };
81
+ child.stdout?.on('data', (chunk)=>appendOutput('stdout', chunk));
82
+ child.stderr?.on('data', (chunk)=>appendOutput('stderr', chunk));
83
+ child.once('error', finish);
84
+ child.once('close', (code, signal)=>{
85
+ if (0 === code) return void finish();
86
+ const detail = signal ? `signal ${signal}` : `code ${code}`;
87
+ const error = new Error(`${command} exited with ${detail}`);
88
+ error.code = code;
89
+ finish(error);
90
+ });
91
+ if (options.timeoutMs && options.timeoutMs > 0) timer = setTimeout(()=>{
92
+ child.kill();
93
+ const error = new Error(`${command} timed out after ${options.timeoutMs}ms`);
94
+ error.code = 'ETIMEDOUT';
95
+ finish(error);
96
+ }, options.timeoutMs);
97
+ });
98
+ }
99
+ exports.d = runCommand;
100
+ }
101
+ });
102
+ const cross_platform_spawn = __webpack_require__("../tls-observer-shared/src/cross-platform-spawn.cjs");
10
103
  const PLUGIN_NAME = 'tls-observer-claude-code';
11
104
  const PLUGIN_PACKAGE_NAME = '@volcengine/tls-observer-claude-code';
12
105
  const PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;
@@ -477,7 +570,6 @@ function pluginPackageSpec(options) {
477
570
  async function installPluginPackageToTemp(options) {
478
571
  const root = await __rspack_external_node_fs_promises_153e37e0.mkdtemp(__rspack_external_node_path_c5b9b54f.join(tmpdir(), 'tls-observer-claude-code-plugin-'));
479
572
  const packageSpec = pluginPackageSpec(options);
480
- const npm = 'win32' === process.platform ? 'npm.cmd' : 'npm';
481
573
  const args = [
482
574
  'install',
483
575
  '--prefix',
@@ -491,8 +583,8 @@ async function installPluginPackageToTemp(options) {
491
583
  packageSpec
492
584
  ];
493
585
  try {
494
- await execFileAsync(npm, args, {
495
- timeout: 120000
586
+ await (0, cross_platform_spawn.d)('npm', args, {
587
+ timeoutMs: 120000
496
588
  });
497
589
  } catch (error) {
498
590
  const detail = error && 'object' == typeof error && 'stderr' in error ? String(error.stderr || '') : error instanceof Error ? error.message : String(error);
@@ -552,30 +644,20 @@ async function installPlugin(options) {
552
644
  for (const entry of runtimeEntries)await __rspack_external_node_fs_promises_153e37e0.cp(__rspack_external_node_path_c5b9b54f.join(source, entry), __rspack_external_node_path_c5b9b54f.join(options.pluginTarget, entry), {
553
645
  recursive: true
554
646
  });
555
- const npm = 'win32' === process.platform ? 'npm.cmd' : 'npm';
556
647
  console.log('插件依赖安装中,请稍后...');
557
648
  try {
558
- await new Promise((resolve, reject)=>{
559
- const child = spawn(npm, [
560
- 'install',
561
- '--omit=dev',
562
- "--ignore-scripts",
563
- '--no-audit',
564
- '--no-fund'
565
- ], {
566
- cwd: options.pluginTarget,
567
- stdio: 'inherit'
568
- });
569
- const timer = setTimeout(()=>{
570
- child.kill();
571
- reject(new Error("npm install timed out after 120s"));
572
- }, 120000);
573
- child.on('exit', (code)=>{
574
- clearTimeout(timer);
575
- if (0 === code) resolve();
576
- else reject(new Error(`npm install exited with code ${code}`));
577
- });
578
- child.on('error', reject);
649
+ await (0, cross_platform_spawn.d)('npm', [
650
+ 'install',
651
+ '--omit=dev',
652
+ "--ignore-scripts",
653
+ '--no-audit',
654
+ '--no-fund',
655
+ '--registry',
656
+ options.registry
657
+ ], {
658
+ cwd: options.pluginTarget,
659
+ stdio: 'inherit',
660
+ timeoutMs: 120000
579
661
  });
580
662
  } catch (error) {
581
663
  const detail = error && 'object' == typeof error && 'stderr' in error ? String(error.stderr || '') : error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/tls-observer-claude-code-install",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "One-step installer for the TLS Observer Claude Code plugin.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,16 +19,17 @@
19
19
  "node": ">=18"
20
20
  },
21
21
  "dependencies": {
22
- "@volcengine/openapi": "^1.36.1"
22
+ "@volcengine/openapi": "^1.36.1",
23
+ "cross-spawn": "7.0.6"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@rslib/core": "^0.21.5",
26
- "@types/node": "^24.10.9",
27
+ "@types/node": "^25.9.3",
27
28
  "prettier": "^3.4.2",
28
- "typescript": "^6.0.3"
29
+ "typescript": "^6.0.3",
30
+ "@volcengine/tls-observer-shared": "0.0.1"
29
31
  },
30
32
  "publishConfig": {
31
- "registry": "https://registry.npmjs.org/",
32
33
  "access": "public"
33
34
  },
34
35
  "scripts": {
@@ -1,11 +1,11 @@
1
1
  import * as fs from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
- import { execFile, execFileSync, spawn } from 'node:child_process';
3
+ import { execFileSync } from 'node:child_process';
4
4
  import { homedir, tmpdir } from 'node:os';
5
5
  import { pathToFileURL } from 'node:url';
6
- import { promisify } from 'node:util';
7
6
  import readline from 'node:readline/promises';
8
7
  import { randomInt } from 'node:crypto';
8
+ import { runCommand } from '@volcengine/tls-observer-shared/cross-platform-spawn';
9
9
 
10
10
  type AnyRecord = Record<string, any>;
11
11
 
@@ -67,7 +67,6 @@ type PluginInstallResult = {
67
67
  version?: string;
68
68
  };
69
69
 
70
- const execFileAsync = promisify(execFile);
71
70
  const PLUGIN_NAME = 'tls-observer-claude-code';
72
71
  const PLUGIN_PACKAGE_NAME = '@volcengine/tls-observer-claude-code';
73
72
  const PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;
@@ -610,7 +609,6 @@ async function installPluginPackageToTemp(options: InstallOptions): Promise<{
610
609
  }> {
611
610
  const root = await fs.mkdtemp(path.join(tmpdir(), 'tls-observer-claude-code-plugin-'));
612
611
  const packageSpec = pluginPackageSpec(options);
613
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
614
612
  const args = [
615
613
  'install',
616
614
  '--prefix',
@@ -625,7 +623,7 @@ async function installPluginPackageToTemp(options: InstallOptions): Promise<{
625
623
  ];
626
624
 
627
625
  try {
628
- await execFileAsync(npm, args, { timeout: 120_000 });
626
+ await runCommand('npm', args, { timeoutMs: 120_000 });
629
627
  } catch (error) {
630
628
  const detail =
631
629
  error && typeof error === 'object' && 'stderr' in error
@@ -685,25 +683,25 @@ async function installPlugin(options: InstallOptions): Promise<PluginInstallResu
685
683
  for (const entry of runtimeEntries) {
686
684
  await fs.cp(path.join(source, entry), path.join(options.pluginTarget, entry), { recursive: true });
687
685
  }
688
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
689
686
  console.log('插件依赖安装中,请稍后...');
690
687
  try {
691
- await new Promise<void>((resolve, reject) => {
692
- const child = spawn(npm, ['install', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'], {
688
+ await runCommand(
689
+ 'npm',
690
+ [
691
+ 'install',
692
+ '--omit=dev',
693
+ '--ignore-scripts',
694
+ '--no-audit',
695
+ '--no-fund',
696
+ '--registry',
697
+ options.registry,
698
+ ],
699
+ {
693
700
  cwd: options.pluginTarget,
694
701
  stdio: 'inherit',
695
- });
696
- const timer = setTimeout(() => {
697
- child.kill();
698
- reject(new Error(`npm install timed out after 120s`));
699
- }, 120_000);
700
- child.on('exit', (code) => {
701
- clearTimeout(timer);
702
- if (code === 0) resolve();
703
- else reject(new Error(`npm install exited with code ${code}`));
704
- });
705
- child.on('error', reject);
706
- });
702
+ timeoutMs: 120_000,
703
+ },
704
+ );
707
705
  } catch (error) {
708
706
  const detail =
709
707
  error && typeof error === 'object' && 'stderr' in error