@jinshuju/cli 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @jinshuju/cli
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@jinshuju/cli)](https://www.npmjs.com/package/@jinshuju/cli)
4
+
3
5
  Command-line interface for the Jinshuju Open API v1.
4
6
 
5
7
  ## Install
package/dist/cli.d.ts CHANGED
@@ -11,6 +11,11 @@ export type CliRuntime = {
11
11
  /** How wide a table may be. Defaults to the terminal, or 120 through a pipe. */
12
12
  width?: number;
13
13
  };
14
- export declare const VERSION = "0.1.0";
14
+ /**
15
+ * Read from package.json, not restated here. A release bumps that file and
16
+ * nothing else, so a constant reports the previous version from the moment it
17
+ * is published — 0.1.1 shipped saying 0.1.0.
18
+ */
19
+ export declare const VERSION: string;
15
20
  export declare function terminalWidth(stream?: NodeJS.WriteStream): number;
16
21
  export declare function runCli(args?: string[], runtime?: CliRuntime): Promise<CliResult>;
package/dist/cli.js CHANGED
@@ -186,7 +186,21 @@ function localOptions(flags, stdin) {
186
186
  showSecret: Boolean(bound.show_secret)
187
187
  };
188
188
  }
189
- export const VERSION = '0.1.0';
189
+ /**
190
+ * Read from package.json, not restated here. A release bumps that file and
191
+ * nothing else, so a constant reports the previous version from the moment it
192
+ * is published — 0.1.1 shipped saying 0.1.0.
193
+ */
194
+ export const VERSION = readVersion();
195
+ function readVersion() {
196
+ try {
197
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
198
+ return pkg.version ?? 'unknown';
199
+ }
200
+ catch {
201
+ return 'unknown';
202
+ }
203
+ }
190
204
  function ok(stdout) {
191
205
  return { exitCode: 0, stdout: stdout.endsWith('\n') ? stdout : `${stdout}\n`, stderr: '' };
192
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {