diff --git a/app/src/cli/crossPlatformSpecs-cli.ts b/app/src/cli/crossPlatformSpecs-cli.ts index 4afdbaa..658f751 100644 --- a/app/src/cli/crossPlatformSpecs-cli.ts +++ b/app/src/cli/crossPlatformSpecs-cli.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import crossPlatformSpecs from "../crossPlatformSpecs.js" +import * as spec from "../crossPlatformSpecs.js" import { program } from "commander" import reqPackageJson, { reqPackagePath } from "req-package-json" import {promises as fs} from "fs" @@ -7,6 +7,7 @@ import * as path from "path" const config = reqPackageJson() import * as console from "./../lib/logger" + program .version(config.version) .description(config.description) @@ -14,12 +15,12 @@ program .option('-s, --silent', 'silence stdout') // .argument('', "description of required example") // .argument('[optional example]', "description of optional example") - .action((arg1, arg2, options) => { + .argument('[specific spec]', `Optionally provide a spec name of interest to only return that spec. Can be one of ["environment", "osName", "osVersion", "runtime", "runtimeVersion", "engine", "engineVersion", "cpuName", "cpuCores", "cpuArch", "memAvailable", "memFree"]. If omitted, a summery of all specs will be returned.`) + .action((spec, options) => { console.setVerbose(!options.silent) - // crossPlatformSpecs() - - + if (spec !== undefined) console.log(spec[spec]) + else console.log(spec.allSpecs()) }) .parse(process.argv) diff --git a/cjsIfyMod.mjs b/cjsIfyMod.mjs deleted file mode 100644 index 7a7da3b..0000000 --- a/cjsIfyMod.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import { rollup } from 'rollup'; -import commander from 'commander'; -import path from 'path'; -import fs from 'fs'; - -const { program } = commander; - -program - .argument("", "Input dir") - .action((dir) => { - for (const file of walkDir(dir).filter(file => file.endsWith(".js"))) { - rollup({ - input: file, - - - - } - }) - - -function walkDir(dir) { - if (!fs.statSync(dir).isDirectory()) return [dir] - const ls = [] - for (const file of fs.readdirSync(dir)) { - const filePath = path.join(dir, file); - if (fs.statSync(filePath).isDirectory()) { - ls.push(...walkDir(filePath)); - } else { - ls.push(filePath); - } - } -} diff --git a/package.json b/package.json index f36a2d8..bf52045 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Aggregation of functions to get system specs with a unified API for web and node.", "main": "./app/dist/esm/crossPlatformSpecs.mjs", "types": "./app/dist/esm/crossPlatformSpecs.d.ts", - "bin": "./app/dist/cjs/cli/crossPlatformSpecs-cli.js", + "bin": "./app/dist/esm/cli/crossPlatformSpecs-cli.mjs", "exports": { "node": { "import": "./app/dist/esm/crossPlatformSpecs.mjs",