amorphous-cli 0.3.0 → 0.3.1

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/index.mjs CHANGED
@@ -3,14 +3,21 @@ import { loadDotEnv } from './lib/config.mjs'
3
3
  import { runCommand } from './lib/commands.mjs'
4
4
  import { ensureLocalHttpsTrust } from './lib/tls.mjs'
5
5
  import { startUpdateCheck } from './lib/update-check.mjs'
6
+ import { CLI_VERSION, isVersionRequest } from './lib/version.mjs'
7
+
8
+ const argv = process.argv.slice(2)
9
+ if (isVersionRequest(argv)) {
10
+ console.log(CLI_VERSION)
11
+ process.exit(0)
12
+ }
6
13
 
7
14
  ensureLocalHttpsTrust()
8
15
  loadDotEnv()
9
16
 
10
- const update = startUpdateCheck({ argv: process.argv.slice(2) })
17
+ const update = startUpdateCheck({ argv })
11
18
 
12
19
  try {
13
- await runCommand(process.argv.slice(2))
20
+ await runCommand(argv)
14
21
  await update.finish()
15
22
  } catch (e) {
16
23
  console.error(e instanceof Error ? e.message : e)
package/lib/help.mjs CHANGED
@@ -31,6 +31,7 @@ export const ROOT_HELP = `Amorphous
31
31
  rename --name Rename
32
32
 
33
33
  Run amorphous-cli <command> --help for flags. Pass --json where you need machine output.
34
+ Run amorphous-cli --version to print the installed version.
34
35
  `
35
36
 
36
37
  export const COMMAND_HELP = {
package/lib/version.mjs CHANGED
@@ -1,3 +1,7 @@
1
1
  import { readFileSync } from 'node:fs'
2
2
 
3
3
  export const CLI_VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version
4
+
5
+ export function isVersionRequest(argv) {
6
+ return argv.length === 1 && (argv[0] === '--version' || argv[0] === '-v')
7
+ }
@@ -0,0 +1,21 @@
1
+ import assert from 'node:assert/strict'
2
+ import { execFileSync } from 'node:child_process'
3
+ import { fileURLToPath } from 'node:url'
4
+ import test from 'node:test'
5
+ import { isVersionRequest } from './version.mjs'
6
+
7
+ test('version is a standalone global CLI option', () => {
8
+ assert.equal(isVersionRequest(['--version']), true)
9
+ assert.equal(isVersionRequest(['-v']), true)
10
+ assert.equal(isVersionRequest(['list', '--version']), false)
11
+ assert.equal(isVersionRequest([]), false)
12
+ })
13
+
14
+ test('CLI prints its package version without running a command', () => {
15
+ const entry = fileURLToPath(new URL('../index.mjs', import.meta.url))
16
+ const output = execFileSync(process.execPath, [entry, '--version'], {
17
+ encoding: 'utf8',
18
+ env: { ...process.env, AMORPHOUS_NO_UPDATE_CHECK: '1' },
19
+ })
20
+ assert.equal(output.trim(), '0.3.1')
21
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amorphous-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "mcpName": "io.github.amorphous-one/amorphous",
5
5
  "description": "Make whatever you want, yourself, with your own agent, or with others.",
6
6
  "type": "module",