@mxfb/cli 1.0.2 → 1.0.3

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/mxfb/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{existsSync as r,readdirSync as c}from"node:fs";import{readFile as l}from"node:fs/promises";import t from"node:path";import i from"node:process";import{fileURLToPath as m}from"node:url";import{Command as g}from"commander";import{styles as n}from"@design-edito/tools/agnostic/misc/logs/styles/index.js";var e=t.join(t.dirname(m(import.meta.url)),"..");function f(){try{return c(e).filter(o=>r(t.join(e,o,"index.js"))).sort()}catch{return[]}}var p=[t.join(e,"package.json"),t.join(e,"..","package.json")];async function d(){for(let o of p)try{let a=await l(o,{encoding:"utf-8"});return JSON.parse(a)}catch{continue}return null}var s=new g().name("mxfb").description("The @mxfb command line tools: what this package installs, and which version is here.");s.command("list").description("every command this package installs").action(async()=>{let o=f();if(console.log(""),console.log(n.title("Commands.")),o.length===0){console.log(n.warning("None found.")),console.log(n.light(e)),console.log("");return}o.forEach(a=>console.log(n.important(a))),console.log("")});s.command("version").description("the installed version of this package").action(async()=>{let o=await d();console.log(""),console.log(n.title("Version.")),o===null&&(console.log(n.error("No package.json next to the commands.")),console.log(n.light(e)),console.log(""),i.exit(1)),console.log(`${n.important(o.name??"@mxfb/cli")} ${o.version??"unknown"}`),console.log("")});i.argv.length<=2&&s.help();await s.parseAsync();
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/mxfb/index.ts"],
4
+ "sourcesContent": ["import { existsSync, readdirSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { Command } from 'commander'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\n\ntype PackageManifest = {\n name?: string\n version?: string\n}\n\n// A built command sits at <package>/<command>/index.js, so its siblings are the other\n// commands and the manifest is one level up.\nconst PACKAGE_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..')\n\nfunction listCommandNames (): string[] {\n try {\n return readdirSync(PACKAGE_DIR)\n .filter(name => existsSync(path.join(PACKAGE_DIR, name, 'index.js')))\n .sort()\n }\n catch { return [] }\n}\n\n// Published, the manifest sits next to the commands; in this repo it is one level further\n// up, since build/package.json is only written at publish time.\nconst MANIFEST_PATHS = [\n path.join(PACKAGE_DIR, 'package.json'),\n path.join(PACKAGE_DIR, '..', 'package.json')\n]\n\nasync function readManifest (): Promise<PackageManifest | null> {\n for (const manifestPath of MANIFEST_PATHS) {\n try {\n const raw = await readFile(manifestPath, { encoding: 'utf-8' })\n return JSON.parse(raw) as PackageManifest\n }\n catch { continue }\n }\n return null\n}\n\nconst program = new Command()\n .name('mxfb')\n .description('The @mxfb command line tools: what this package installs, and which version is here.')\n\nprogram\n .command('list')\n .description('every command this package installs')\n .action(async () => {\n const names = listCommandNames()\n console.log('')\n console.log(styles.title('Commands.'))\n if (names.length === 0) {\n console.log(styles.warning('None found.'))\n console.log(styles.light(PACKAGE_DIR))\n console.log('')\n return\n }\n names.forEach(name => console.log(styles.important(name)))\n console.log('')\n })\n\nprogram\n .command('version')\n .description('the installed version of this package')\n .action(async () => {\n const manifest = await readManifest()\n console.log('')\n console.log(styles.title('Version.'))\n if (manifest === null) {\n console.log(styles.error('No package.json next to the commands.'))\n console.log(styles.light(PACKAGE_DIR))\n console.log('')\n process.exit(1)\n }\n console.log(`${styles.important(manifest.name ?? '@mxfb/cli')} ${manifest.version ?? 'unknown'}`)\n console.log('')\n })\n\nif (process.argv.length <= 2) program.help()\nawait program.parseAsync()\n"],
5
+ "mappings": "AAAA,OAAS,cAAAA,EAAY,eAAAC,MAAmB,UACxC,OAAS,YAAAC,MAAgB,mBACzB,OAAOC,MAAU,YACjB,OAAOC,MAAa,eACpB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,WAAAC,MAAe,YACx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AU,CAAC,EAChCU,IAAa,OACf,QAAQ,IAAIV,EAAO,MAAM,uCAAuC,CAAC,EACjE,QAAQ,IAAIA,EAAO,MAAMC,CAAW,CAAC,EACrC,QAAQ,IAAI,EAAE,EACdJ,EAAQ,KAAK,CAAC,GAEhB,QAAQ,IAAI,GAAGG,EAAO,UAAUU,EAAS,MAAQ,WAAW,CAAC,IAAIA,EAAS,SAAW,SAAS,EAAE,EAChG,QAAQ,IAAI,EAAE,CAChB,CAAC,EAECb,EAAQ,KAAK,QAAU,GAAGW,EAAQ,KAAK,EAC3C,MAAMA,EAAQ,WAAW",
6
+ "names": ["existsSync", "readdirSync", "readFile", "path", "process", "fileURLToPath", "Command", "styles", "PACKAGE_DIR", "listCommandNames", "name", "MANIFEST_PATHS", "readManifest", "manifestPath", "raw", "program", "names", "manifest"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxfb/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -12,6 +12,7 @@
12
12
  "main": "index.js",
13
13
  "module": "index.js",
14
14
  "bin": {
15
+ "mxfb": "./mxfb/index.js",
15
16
  "scrape-tumblr": "./scrape-tumblr/index.js"
16
17
  },
17
18
  "dependencies": {