@able-autonomy/able 0.0.11 → 0.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.
Files changed (2) hide show
  1. package/able.ts +17 -5
  2. package/package.json +1 -1
package/able.ts CHANGED
@@ -103,12 +103,24 @@ if (command === 'config') {
103
103
  }
104
104
  // `bunx` keeps the copy it fetched first; asking for @latest once refreshes it. A host that pins Able runs its pin instead.
105
105
  if (command === 'upgrade') {
106
- const r = Bun.spawnSync(['bunx', '@able-autonomy/able@latest'], { stdout: 'ignore', stderr: 'ignore' })
107
- if (r.exitCode !== 0) fail('bunx @able-autonomy/able@latest failed')
108
- const { version } = await (await fetch('https://registry.npmjs.org/@able-autonomy/able/latest')).json()
109
- console.log(`able ${version} is the latest, and bunx now runs it`)
106
+ const { version: current } = await Bun.file(join(import.meta.dir, 'package.json')).json()
107
+ const { version: latest } = await (await fetch('https://registry.npmjs.org/@able-autonomy/able/latest')).json()
110
108
  const pinned = Bun.file('node_modules/@able-autonomy/able/package.json')
111
- if (await pinned.exists()) console.log(`this folder pins ${(await pinned.json()).version}: set @able-autonomy/able to ${version} in package.json, then bun install`)
109
+ if (await pinned.exists()) {
110
+ const pin = (await pinned.json()).version
111
+ console.log(
112
+ pin === latest
113
+ ? `Congrats! This folder already pins the latest able (v${latest})`
114
+ : `This folder pins able v${pin}; the latest is v${latest}. Set @able-autonomy/able to ${latest} in package.json, then bun install`,
115
+ )
116
+ process.exit(0)
117
+ }
118
+ if (Bun.semver.order(current, latest) >= 0) {
119
+ console.log(`Congrats! You're already on the latest version of able (which is v${current})`)
120
+ process.exit(0)
121
+ }
122
+ if (Bun.spawnSync(['bunx', '@able-autonomy/able@latest'], { stdout: 'ignore', stderr: 'ignore' }).exitCode !== 0) fail('bunx @able-autonomy/able@latest failed')
123
+ console.log(`Upgraded able v${current} → v${latest}`)
112
124
  process.exit(0)
113
125
  }
114
126
  const modules: Record<string, string> = { commit: './src/commit.ts', push: './src/push.ts', ws: './src/workspaces/index.ts' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@able-autonomy/able",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Able's command line and the config types a host's able.config.ts uses",
5
5
  "type": "module",
6
6
  "license": "MIT",