@chatcode/chatcode-cli-test 1.0.19 → 1.0.21
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/bin/cli.js +19 -3
- package/dist/cli.js +1439 -1439
- package/package.json +17 -12
package/bin/cli.js
CHANGED
|
@@ -11,15 +11,31 @@ const root = join(here, '..')
|
|
|
11
11
|
const args = process.argv.slice(2)
|
|
12
12
|
const platformKey = `${process.platform}-${process.arch}`
|
|
13
13
|
const executableName = process.platform === 'win32' ? 'chatcode-cli.exe' : 'chatcode-cli'
|
|
14
|
-
const
|
|
14
|
+
const mainPackage = JSON.parse(
|
|
15
15
|
readFileSync(join(root, 'package.json'), 'utf8'),
|
|
16
|
-
)
|
|
16
|
+
)
|
|
17
|
+
const mainPackageName = mainPackage.name
|
|
17
18
|
|
|
18
19
|
function resolveOptionalBinary() {
|
|
19
20
|
if (process.env.CHATCODE_CLI_FORCE_NODE === '1') return null
|
|
20
21
|
|
|
21
22
|
try {
|
|
22
|
-
|
|
23
|
+
const packageName = `${mainPackageName}-${platformKey}`
|
|
24
|
+
const executablePath = require.resolve(`${packageName}/${executableName}`)
|
|
25
|
+
const nativePackage = JSON.parse(
|
|
26
|
+
readFileSync(join(dirname(executablePath), 'package.json'), 'utf8'),
|
|
27
|
+
)
|
|
28
|
+
const versionMatches = nativePackage.version === mainPackage.version
|
|
29
|
+
const formatMatches =
|
|
30
|
+
nativePackage.chatcodeNativePackageFormat ===
|
|
31
|
+
mainPackage.chatcodeNativePackageFormat
|
|
32
|
+
if (!versionMatches || !formatMatches) {
|
|
33
|
+
console.warn(
|
|
34
|
+
`Ignoring ${packageName}@${nativePackage.version}: expected version ${mainPackage.version} and native package format ${mainPackage.chatcodeNativePackageFormat}. Using the bundled Node build instead.`,
|
|
35
|
+
)
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
return executablePath
|
|
23
39
|
} catch (_) {
|
|
24
40
|
return null
|
|
25
41
|
}
|