@chatcode/chatcode-cli-test 1.0.10 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatcode/chatcode-cli-test",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "ChatCode CLI command-line coding assistant.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -20,18 +20,11 @@
20
20
  "scan:public-surface": "bun run scripts/public-surface-scan.mjs --fail-on-match",
21
21
  "verify:public-surface": "bun run scripts/verify-public-surface-release.mjs",
22
22
  "build": "bun run scripts/build.mjs",
23
- "build:native": "bun run scripts/build.mjs --compile",
24
- "build:native:all": "bun run scripts/build.mjs --compile --all",
25
- "build:native:win": "bun run scripts/build.mjs --compile --targets=win32-x64",
26
- "build:native:pack": "node scripts/pack-native.mjs",
27
- "preinstall": "node ./scripts/npm-preinstall.mjs",
28
23
  "prepublishOnly": "bun run build"
29
24
  },
30
25
  "files": [
31
- "bin/",
32
26
  "dist/cli.js",
33
27
  "dist/vendor/",
34
- "scripts/npm-preinstall.mjs",
35
28
  "README.md"
36
29
  ],
37
30
  "publishConfig": {
@@ -115,15 +108,8 @@
115
108
  "modifiers-napi": "file:./shims/modifiers-napi",
116
109
  "url-handler-napi": "file:./shims/url-handler-napi"
117
110
  },
118
- "optionalDependencies": {
119
- "@chatcode/chatcode-cli-test-darwin-arm64": "1.0.10",
120
- "@chatcode/chatcode-cli-test-darwin-x64": "1.0.10",
121
- "@chatcode/chatcode-cli-test-linux-x64": "1.0.10",
122
- "@chatcode/chatcode-cli-test-linux-arm64": "1.0.10",
123
- "@chatcode/chatcode-cli-test-win32-x64": "1.0.10"
124
- },
125
111
  "bin": {
126
- "chatcode-cli": "bin/cli.js",
127
- "cco": "bin/cli.js"
112
+ "chatcode-cli": "./dist/cli.js",
113
+ "cco": "./dist/cli.js"
128
114
  }
129
115
  }
package/bin/cli.js DELETED
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from 'node:child_process'
3
- import { existsSync, readFileSync } from 'node:fs'
4
- import { createRequire } from 'node:module'
5
- import { dirname, join } from 'node:path'
6
- import { fileURLToPath } from 'node:url'
7
-
8
- const require = createRequire(import.meta.url)
9
- const here = dirname(fileURLToPath(import.meta.url))
10
- const root = join(here, '..')
11
- const args = process.argv.slice(2)
12
- const platformKey = `${process.platform}-${process.arch}`
13
- const executableName = process.platform === 'win32' ? 'chatcode-cli.exe' : 'chatcode-cli'
14
- const mainPackageName = JSON.parse(
15
- readFileSync(join(root, 'package.json'), 'utf8'),
16
- ).name
17
-
18
- function resolveOptionalBinary() {
19
- if (process.env.CHATCODE_CLI_FORCE_NODE === '1') return null
20
-
21
- try {
22
- return require.resolve(`${mainPackageName}-${platformKey}/${executableName}`)
23
- } catch (_) {
24
- return null
25
- }
26
- }
27
-
28
- function resolveLocalBinary() {
29
- if (process.env.CHATCODE_CLI_FORCE_NODE === '1') return null
30
-
31
- const localBinary = join(root, 'dist', 'native', platformKey, executableName)
32
- return existsSync(localBinary) ? localBinary : null
33
- }
34
-
35
- function run(command, commandArgs) {
36
- const result = spawnSync(command, commandArgs, {
37
- stdio: 'inherit',
38
- windowsHide: false,
39
- })
40
-
41
- if (result.error) return result.error
42
- if (result.signal) {
43
- process.kill(process.pid, result.signal)
44
- process.exit(1)
45
- }
46
- process.exit(result.status ?? 1)
47
- }
48
-
49
- const nativeBinary = resolveLocalBinary() ?? resolveOptionalBinary()
50
- if (nativeBinary) {
51
- const error = run(nativeBinary, args)
52
- if (error && error.code !== 'ENOENT') {
53
- console.error(`Failed to run native ChatCode CLI binary: ${error.message}`)
54
- process.exit(1)
55
- }
56
- }
57
-
58
- const fallbackCli = join(root, 'dist', 'cli.js')
59
- if (!existsSync(fallbackCli)) {
60
- console.error(
61
- `ChatCode CLI is not installed correctly: missing ${fallbackCli}`,
62
- )
63
- process.exit(1)
64
- }
65
-
66
- const error = run(process.execPath, [fallbackCli, ...args])
67
- if (error) {
68
- console.error(`Failed to run ChatCode CLI: ${error.message}`)
69
- process.exit(1)
70
- }
@@ -1,117 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- existsSync,
4
- lstatSync,
5
- readFileSync,
6
- readdirSync,
7
- readlinkSync,
8
- rmSync,
9
- } from 'node:fs'
10
- import { join } from 'node:path'
11
- import { pathToFileURL } from 'node:url'
12
-
13
- const COMMANDS = ['chatcode-cli', 'cco']
14
- const WINDOWS_SHIM_SUFFIXES = ['', '.cmd', '.ps1']
15
- const CHATCODE_PACKAGE_MARKERS = [
16
- '@chatcode/chatcode-cli',
17
- '@chatcode\\chatcode-cli',
18
- '@chatcode/chatcode-cli-test',
19
- '@chatcode\\chatcode-cli-test',
20
- 'node_modules/@chatcode/chatcode-cli',
21
- 'node_modules\\@chatcode\\chatcode-cli',
22
- 'node_modules/@chatcode/chatcode-cli-test',
23
- 'node_modules\\@chatcode\\chatcode-cli-test',
24
- ]
25
-
26
- function isGlobalNpmInstall(env = process.env) {
27
- return env.npm_config_global === 'true' || env.npm_config_global === '1'
28
- }
29
-
30
- function mentionsChatCodePackage(value) {
31
- return CHATCODE_PACKAGE_MARKERS.some(marker => value.includes(marker))
32
- }
33
-
34
- function fileMentionsChatCodePackage(file) {
35
- try {
36
- return mentionsChatCodePackage(readFileSync(file, 'utf8'))
37
- } catch (_) {
38
- return false
39
- }
40
- }
41
-
42
- function symlinkMentionsChatCodePackage(file) {
43
- try {
44
- return mentionsChatCodePackage(readlinkSync(file))
45
- } catch (_) {
46
- return false
47
- }
48
- }
49
-
50
- function directoryLooksRemovable(dir) {
51
- let entries
52
- try {
53
- entries = readdirSync(dir)
54
- } catch (_) {
55
- return false
56
- }
57
- if (entries.length === 0) return true
58
-
59
- const packageJson = join(dir, 'package.json')
60
- if (!existsSync(packageJson)) return false
61
-
62
- try {
63
- const pkg = JSON.parse(readFileSync(packageJson, 'utf8'))
64
- return (
65
- pkg.name === '@chatcode/chatcode-cli' ||
66
- pkg.name === '@chatcode/chatcode-cli-test'
67
- )
68
- } catch (_) {
69
- return false
70
- }
71
- }
72
-
73
- function shouldRemoveCandidate(candidate) {
74
- let stat
75
- try {
76
- stat = lstatSync(candidate)
77
- } catch (_) {
78
- return false
79
- }
80
-
81
- if (stat.isSymbolicLink()) return symlinkMentionsChatCodePackage(candidate)
82
- if (stat.isDirectory()) return directoryLooksRemovable(candidate)
83
- if (!stat.isFile()) return false
84
- return fileMentionsChatCodePackage(candidate)
85
- }
86
-
87
- export function cleanLegacyGlobalShims({
88
- prefix = process.env.npm_config_prefix,
89
- commands = COMMANDS,
90
- log = () => {},
91
- } = {}) {
92
- if (!prefix) return []
93
-
94
- const removed = []
95
- for (const command of commands) {
96
- for (const suffix of WINDOWS_SHIM_SUFFIXES) {
97
- const candidate = join(prefix, `${command}${suffix}`)
98
- if (!existsSync(candidate)) continue
99
- if (!shouldRemoveCandidate(candidate)) continue
100
-
101
- rmSync(candidate, { recursive: true, force: true })
102
- removed.push(candidate)
103
- log(`Removed stale ChatCode CLI npm shim: ${candidate}`)
104
- }
105
- }
106
- return removed
107
- }
108
-
109
- function main() {
110
- if (process.platform !== 'win32') return
111
- if (!isGlobalNpmInstall()) return
112
- cleanLegacyGlobalShims({ log: message => console.log(message) })
113
- }
114
-
115
- if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
116
- main()
117
- }