create-agentuity 2.0.1 → 2.0.3
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.js +42 -14
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
3
4
|
import { createRequire } from 'node:module';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
4
6
|
|
|
5
7
|
const require = createRequire(import.meta.url);
|
|
6
8
|
const pkg = require('./package.json');
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Derive the @agentuity/cli version specifier from the create-agentuity version.
|
|
12
|
+
*
|
|
13
|
+
* Since create-agentuity and @agentuity/cli are published in lockstep with
|
|
14
|
+
* identical version numbers, we use the exact version to ensure compatibility.
|
|
15
|
+
*
|
|
16
|
+
* This matters when users pin a specific version, e.g.:
|
|
17
|
+
* bun create agentuity@^1.0.0 → should use @agentuity/cli@1.0.x, not @latest
|
|
18
|
+
* bun create agentuity@2.0.0 → should use @agentuity/cli@2.0.0
|
|
19
|
+
* bun create agentuity → uses @latest create-agentuity, gets @latest CLI
|
|
20
|
+
*
|
|
21
|
+
* Prerelease versions use their dist-tag instead:
|
|
22
|
+
* - Beta versions (-beta.) → @beta
|
|
23
|
+
* - Other prereleases (-alpha., -rc., etc.) → @next
|
|
24
|
+
*
|
|
25
|
+
* @param {string} version - The create-agentuity package version
|
|
26
|
+
* @returns {string} Version specifier for @agentuity/cli (e.g. "2.0.2", "beta", "next")
|
|
27
|
+
*/
|
|
28
|
+
export function getCliVersionSpecifier(version) {
|
|
14
29
|
// Check for beta prerelease first
|
|
15
30
|
if (/-beta\./.test(version)) {
|
|
16
31
|
return 'beta';
|
|
@@ -19,19 +34,32 @@ export function getDistTag(version) {
|
|
|
19
34
|
if (/-([a-zA-Z]+)/.test(version)) {
|
|
20
35
|
return 'next';
|
|
21
36
|
}
|
|
22
|
-
|
|
37
|
+
// Stable versions: use the exact version to ensure major version compatibility
|
|
38
|
+
return version;
|
|
23
39
|
}
|
|
24
40
|
|
|
25
|
-
// Only run when executed directly, not when imported for testing
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
// Only run when executed directly, not when imported for testing.
|
|
42
|
+
// When bunx runs this script, it creates a symlink (e.g. ~/.bun/bin/create-agentuity)
|
|
43
|
+
// pointing to the real file. process.argv[1] is the symlink path while import.meta.url
|
|
44
|
+
// resolves to the real path, so we must resolve symlinks before comparing.
|
|
45
|
+
function checkIsMain() {
|
|
46
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
47
|
+
if (typeof Bun !== 'undefined') {
|
|
48
|
+
return Bun.main === scriptPath;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return realpathSync(process.argv[1]) === scriptPath;
|
|
52
|
+
} catch {
|
|
53
|
+
return process.argv[1] === scriptPath;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isMain = checkIsMain();
|
|
30
58
|
|
|
31
59
|
if (isMain) {
|
|
32
|
-
const
|
|
60
|
+
const cliVersion = getCliVersionSpecifier(pkg.version);
|
|
33
61
|
const args = process.argv.slice(2);
|
|
34
|
-
const result = spawnSync('bunx', [`@agentuity/cli@${
|
|
62
|
+
const result = spawnSync('bunx', [`@agentuity/cli@${cliVersion}`, 'create', ...args], {
|
|
35
63
|
stdio: 'inherit',
|
|
36
64
|
});
|
|
37
65
|
process.exit(result.status || 0);
|