Browse Source

fixed startup infinite loop due to AO version checking ao-cli, now it gets from global npm package.json

main
deicidus 2 years ago
parent
commit
6a99b0053d
  1. 5
      README.md
  2. 20
      scripts/features/ao-cli.js

5
README.md

@ -23,6 +23,7 @@ These features work right now:
* Browse the [AO User Manual](https://git.coalitionofinvisiblecolleges.org/autonomousorganization/ao-manual) and automatically download and keep it updated * Browse the [AO User Manual](https://git.coalitionofinvisiblecolleges.org/autonomousorganization/ao-manual) and automatically download and keep it updated
* Interactive install wizard installs the AO for you * Interactive install wizard installs the AO for you
* Operate essential AO client features (view, create, and organize priorities) * Operate essential AO client features (view, create, and organize priorities)
* Easily monitor your AO server status and start/stop the service
* Easily view installed/running status of optional AO features (soon all features) * Easily view installed/running status of optional AO features (soon all features)
* Easily install/uninstall and turn on/off optional AO features * Easily install/uninstall and turn on/off optional AO features
* Manages your AO configuration (.env) file for you * Manages your AO configuration (.env) file for you
@ -32,8 +33,7 @@ These features work right now:
* Wraps the functionality of (some of) Zen's Alchemy suite of scripts (system configuration, AO installation) * Wraps the functionality of (some of) Zen's Alchemy suite of scripts (system configuration, AO installation)
* Add `ao` alias for `ao-cli` (under Features→ao-cli) * Add `ao` alias for `ao-cli` (under Features→ao-cli)
* Enchant your 'cd' command to narrate your travels through the UNIX filesystem (under Features→ao-cli) (less annoying than it sounds, easy to disable) * Enchant your 'cd' command to narrate your travels through the UNIX filesystem (under Features→ao-cli) (less annoying than it sounds, easy to disable)
* Easily monitor your AO server status and start/stop the service * Easily add your existing systemctl services to the Features list so you can start and stop them from the AO Features menu
* Easily add your existing systemctl services the Features list so you can start and stop them from the AO Features menu
## Upcoming Features ## Upcoming Features
@ -63,6 +63,7 @@ These features are planned and many are mocked up in the menus:
## Version History ## Version History
* 0.1.6 Fixed AO version number crash on startup
* 0.1.5 Added support for feature submodules and adding system services to AO's features menu * 0.1.5 Added support for feature submodules and adding system services to AO's features menu
* 0.1.4 Added fantasy hook feature to bring the AO MUD aesthetic into the terminal * 0.1.4 Added fantasy hook feature to bring the AO MUD aesthetic into the terminal
* 0.1.2 AO install wizard partway done, reorganized project repos, 'Check AO install' feature * 0.1.2 AO install wizard partway done, reorganized project repos, 'Check AO install' feature

20
scripts/features/ao-cli.js

@ -1,6 +1,7 @@
import { execSync } from 'child_process' import { execSync } from 'child_process'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
import path from 'path' import path from 'path'
import fs from 'fs'
import { loadJsonFile } from '../files.js' import { loadJsonFile } from '../files.js'
// Can't include .json files without adding an experimental node flag, but we can use this workaround to use require, which works, instead // Can't include .json files without adding an experimental node flag, but we can use this workaround to use require, which works, instead
@ -34,7 +35,24 @@ function installAoCli() {
} }
async function getAoCliVersion() { async function getAoCliVersion() {
return execSync('ao-cli --version').toString().replace(/\n$/, '') const npmGlobalPackagesPath = execSync('npm root -g').toString().replace(/\n/, '')
const aoGlobalPackagePath = path.join(npmGlobalPackagesPath, '@autonomousorganization/ao-cli/package.json')
let jsonFileContents
try {
const contents = fs.readFileSync(aoGlobalPackagePath)
jsonFileContents = JSON.parse(contents)
} catch(err) {
if(err.code === 'ENOENT') {
console.log('The global ao-cli package.json file does not exist.')
} else {
console.log('Unknown error loading global ao-cli package.json file, aborting.', err)
}
return null
}
if(!jsonFileContents.hasOwnProperty('version')) {
return null
}
return jsonFileContents.version
} }
// Updates the globally-installed version of this package, ao-cli, using npm // Updates the globally-installed version of this package, ao-cli, using npm

Loading…
Cancel
Save