@murongg/aah-cli 0.1.4 → 0.1.6
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/README.md +3 -0
- package/package.json +1 -1
- package/scripts/postinstall.mjs +46 -0
package/README.md
CHANGED
|
@@ -49,11 +49,14 @@ aah add --provider codex
|
|
|
49
49
|
aah list
|
|
50
50
|
aah current
|
|
51
51
|
aah refresh
|
|
52
|
+
aah upgrade
|
|
52
53
|
aah switch --provider codex user@example.com
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
`aah add --provider ...` starts the provider's login flow, stores the account in the managed account pool, and leaves the current active CLI account unchanged.
|
|
56
57
|
|
|
58
|
+
`aah upgrade` checks the latest `cli-vX.Y.Z` release, auto-detects how the CLI was installed, and upgrades in place when safe. On older installs that do not have install metadata yet, it may print a one-line manual upgrade command instead of upgrading directly.
|
|
59
|
+
|
|
57
60
|
Filter by provider:
|
|
58
61
|
|
|
59
62
|
```bash
|
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -32,6 +32,50 @@ export function releaseTagForVersion(version) {
|
|
|
32
32
|
return `cli-v${version}`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export function installMetadataPathForEnv(env = process.env, platform = process.platform) {
|
|
36
|
+
if (platform === "win32") {
|
|
37
|
+
const appData = env.APPDATA;
|
|
38
|
+
if (!appData) {
|
|
39
|
+
throw new Error("APPDATA is required on Windows");
|
|
40
|
+
}
|
|
41
|
+
return path.join(appData, "aah", "cli-install.json");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const home = env.HOME ?? os.homedir();
|
|
45
|
+
const configRoot = env.XDG_CONFIG_HOME ?? path.join(home, ".config");
|
|
46
|
+
return path.join(configRoot, "aah", "cli-install.json");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function detectPackageManagerFromEnv(env = process.env) {
|
|
50
|
+
const userAgent = env.npm_config_user_agent ?? "";
|
|
51
|
+
if (userAgent.startsWith("pnpm/")) {
|
|
52
|
+
return "pnpm";
|
|
53
|
+
}
|
|
54
|
+
if (userAgent.startsWith("yarn/")) {
|
|
55
|
+
return "yarn";
|
|
56
|
+
}
|
|
57
|
+
if (userAgent.startsWith("bun/")) {
|
|
58
|
+
return "bun";
|
|
59
|
+
}
|
|
60
|
+
return "npm";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function writeInstallMetadata(packageRoot, env = process.env, platform = process.platform) {
|
|
64
|
+
const metadataPath = installMetadataPathForEnv(env, platform);
|
|
65
|
+
const binaryPath = binaryPathForPackage(packageRoot, platform);
|
|
66
|
+
const metadata = {
|
|
67
|
+
schema_version: 1,
|
|
68
|
+
install_method: "package-manager",
|
|
69
|
+
package_manager: detectPackageManagerFromEnv(env),
|
|
70
|
+
package_name: "@murongg/aah-cli",
|
|
71
|
+
binary_path: binaryPath,
|
|
72
|
+
installed_at: new Date().toISOString(),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
fs.mkdirSync(path.dirname(metadataPath), { recursive: true });
|
|
76
|
+
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2));
|
|
77
|
+
}
|
|
78
|
+
|
|
35
79
|
function download(url, targetPath) {
|
|
36
80
|
return new Promise((resolve, reject) => {
|
|
37
81
|
https
|
|
@@ -80,6 +124,8 @@ async function main() {
|
|
|
80
124
|
if (process.platform !== "win32") {
|
|
81
125
|
fs.chmodSync(binaryPath, 0o755);
|
|
82
126
|
}
|
|
127
|
+
|
|
128
|
+
writeInstallMetadata(packageRoot);
|
|
83
129
|
}
|
|
84
130
|
|
|
85
131
|
if (process.argv[1] && import.meta.url === new URL(process.argv[1], "file:").href) {
|