@chatcode/chatcode-cli-test 1.0.9 → 1.0.10

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.9",
3
+ "version": "1.0.10",
4
4
  "description": "ChatCode CLI command-line coding assistant.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -20,11 +20,18 @@
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",
23
28
  "prepublishOnly": "bun run build"
24
29
  },
25
30
  "files": [
31
+ "bin/",
26
32
  "dist/cli.js",
27
33
  "dist/vendor/",
34
+ "scripts/npm-preinstall.mjs",
28
35
  "README.md"
29
36
  ],
30
37
  "publishConfig": {
@@ -108,8 +115,15 @@
108
115
  "modifiers-napi": "file:./shims/modifiers-napi",
109
116
  "url-handler-napi": "file:./shims/url-handler-napi"
110
117
  },
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
+ },
111
125
  "bin": {
112
- "chatcode-cli": "./dist/cli.js",
113
- "cco": "./dist/cli.js"
126
+ "chatcode-cli": "bin/cli.js",
127
+ "cco": "bin/cli.js"
114
128
  }
115
129
  }
@@ -0,0 +1,117 @@
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
+ }