@superdoc-dev/cli 0.2.0-next.102 → 0.2.0-next.103

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +87 -21
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -208,6 +208,7 @@ superdoc info ./contract.docx --pretty
208
208
  - `--session <id>`
209
209
  - `--timeout-ms <n>`
210
210
  - `--help`
211
+ - `--version`, `-v`
211
212
 
212
213
  ## Input payload flags
213
214
 
package/dist/index.js CHANGED
@@ -142,6 +142,7 @@ function parseGlobalArgs(argv) {
142
142
  let timeoutMs;
143
143
  let sessionId;
144
144
  let help = false;
145
+ let version2 = false;
145
146
  const rest = [];
146
147
  for (let index = 0;index < argv.length; index += 1) {
147
148
  const token = argv[index];
@@ -161,6 +162,10 @@ function parseGlobalArgs(argv) {
161
162
  help = true;
162
163
  continue;
163
164
  }
165
+ if (token === "--version" || token === "-v") {
166
+ version2 = true;
167
+ continue;
168
+ }
164
169
  if (token === "--session") {
165
170
  const next = argv[index + 1];
166
171
  if (!next) {
@@ -216,7 +221,8 @@ function parseGlobalArgs(argv) {
216
221
  output,
217
222
  timeoutMs,
218
223
  sessionId,
219
- help
224
+ help,
225
+ version: version2
220
226
  },
221
227
  rest
222
228
  };
@@ -389031,6 +389037,41 @@ var init_uninstall = __esm(() => {
389031
389037
  init_skill_targets();
389032
389038
  });
389033
389039
 
389040
+ // src/lib/version.ts
389041
+ import { readFileSync } from "node:fs";
389042
+ import { dirname as dirname3, resolve as resolve4 } from "node:path";
389043
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
389044
+ function resolveCliPackagePath() {
389045
+ const __filename3 = fileURLToPath3(import.meta.url);
389046
+ const __dirname3 = dirname3(__filename3);
389047
+ return resolve4(__dirname3, "../../package.json");
389048
+ }
389049
+ function parsePackageVersion(rawPackageJson) {
389050
+ try {
389051
+ const parsed = JSON.parse(rawPackageJson);
389052
+ if (typeof parsed.version === "string" && parsed.version.length > 0) {
389053
+ return parsed.version;
389054
+ }
389055
+ } catch {}
389056
+ return null;
389057
+ }
389058
+ function resolveCliPackageVersion() {
389059
+ if (cachedCliPackageVersion) {
389060
+ return cachedCliPackageVersion;
389061
+ }
389062
+ try {
389063
+ const packageJson = readFileSync(resolveCliPackagePath(), "utf8");
389064
+ const version4 = parsePackageVersion(packageJson);
389065
+ cachedCliPackageVersion = version4 ?? FALLBACK_CLI_PACKAGE_VERSION;
389066
+ return cachedCliPackageVersion;
389067
+ } catch {
389068
+ cachedCliPackageVersion = FALLBACK_CLI_PACKAGE_VERSION;
389069
+ return cachedCliPackageVersion;
389070
+ }
389071
+ }
389072
+ var FALLBACK_CLI_PACKAGE_VERSION = "0.0.0", cachedCliPackageVersion = null;
389073
+ var init_version2 = () => {};
389074
+
389034
389075
  // src/host/session-pool.ts
389035
389076
  function profileToFingerprint(profile) {
389036
389077
  return JSON.stringify({
@@ -389336,6 +389377,17 @@ async function invokeCliFromHost(rawParams, options2 = {}) {
389336
389377
  }
389337
389378
  };
389338
389379
  }
389380
+ if (invocation.versionText) {
389381
+ return {
389382
+ command: "version",
389383
+ data: {
389384
+ version: invocation.versionText
389385
+ },
389386
+ meta: {
389387
+ elapsedMs: invocation.elapsedMs
389388
+ }
389389
+ };
389390
+ }
389339
389391
  if (!invocation.execution) {
389340
389392
  throw new CliError("COMMAND_FAILED", "cli.invoke produced no command result.");
389341
389393
  }
@@ -389363,22 +389415,6 @@ __export(exports_server, {
389363
389415
  HostServer: () => HostServer
389364
389416
  });
389365
389417
  import { createInterface } from "node:readline";
389366
- import { readFileSync } from "node:fs";
389367
- import { dirname as dirname3, resolve as resolve4 } from "node:path";
389368
- import { fileURLToPath as fileURLToPath3 } from "node:url";
389369
- function resolveCliVersion() {
389370
- try {
389371
- const __filename3 = fileURLToPath3(import.meta.url);
389372
- const __dirname3 = dirname3(__filename3);
389373
- const packagePath = resolve4(__dirname3, "../../package.json");
389374
- const raw = readFileSync(packagePath, "utf8");
389375
- const parsed = JSON.parse(raw);
389376
- if (typeof parsed.version === "string" && parsed.version.length > 0) {
389377
- return parsed.version;
389378
- }
389379
- } catch {}
389380
- return "0.0.0";
389381
- }
389382
389418
  function parseHostCommandTokens(tokens) {
389383
389419
  let stdio = false;
389384
389420
  let help = false;
@@ -389488,7 +389524,7 @@ class HostServer {
389488
389524
  protocolVersion: HOST_PROTOCOL_VERSION,
389489
389525
  features: [...HOST_PROTOCOL_FEATURES],
389490
389526
  notifications: [...HOST_PROTOCOL_NOTIFICATIONS],
389491
- cliVersion: resolveCliVersion()
389527
+ cliVersion: resolveCliPackageVersion()
389492
389528
  }));
389493
389529
  }
389494
389530
  return;
@@ -389603,6 +389639,7 @@ var HOST_HELP = `Usage:
389603
389639
  var init_server = __esm(async () => {
389604
389640
  init_errors();
389605
389641
  init_guards();
389642
+ init_version2();
389606
389643
  init_contract2();
389607
389644
  init_session_pool();
389608
389645
  init_protocol();
@@ -389717,7 +389754,15 @@ function parseInvocation(argv) {
389717
389754
  return { globals, rest };
389718
389755
  }
389719
389756
  async function executeParsedInvocation(parsed, io, executionMode, sessionPool) {
389720
- if (parsed.globals.help || parsed.rest.length === 0) {
389757
+ if (parsed.globals.help) {
389758
+ return { helpText: HELP };
389759
+ }
389760
+ if (parsed.globals.version) {
389761
+ return {
389762
+ versionText: resolveCliPackageVersion()
389763
+ };
389764
+ }
389765
+ if (parsed.rest.length === 0) {
389721
389766
  return { helpText: HELP };
389722
389767
  }
389723
389768
  const { key: key3, args: args3 } = parseCommand(parsed.rest);
@@ -389764,6 +389809,7 @@ async function invokeCommand(argv, options2 = {}) {
389764
389809
  globals: parsed.globals,
389765
389810
  execution: output.execution,
389766
389811
  helpText: output.helpText,
389812
+ versionText: output.versionText,
389767
389813
  elapsedMs: io.now() - startedAt
389768
389814
  };
389769
389815
  }
@@ -389779,6 +389825,11 @@ async function run2(argv, ioOverrides, options2 = {}) {
389779
389825
  try {
389780
389826
  const parsed = parseInvocation(argv);
389781
389827
  outputMode = parsed.globals.output;
389828
+ if (parsed.globals.version && !parsed.globals.help) {
389829
+ io.stdout(`${resolveCliPackageVersion()}
389830
+ `);
389831
+ return 0;
389832
+ }
389782
389833
  if (parsed.rest[0] === "host") {
389783
389834
  const hostTokens = parsed.rest.slice(1);
389784
389835
  if (parsed.globals.help)
@@ -389805,8 +389856,13 @@ async function run2(argv, ioOverrides, options2 = {}) {
389805
389856
  io.stdout(output.helpText);
389806
389857
  return 0;
389807
389858
  }
389859
+ if (output.versionText) {
389860
+ io.stdout(`${output.versionText}
389861
+ `);
389862
+ return 0;
389863
+ }
389808
389864
  if (!output.execution) {
389809
- throw new CliError("COMMAND_FAILED", "Command produced no execution result and no help text.");
389865
+ throw new CliError("COMMAND_FAILED", "Command produced no execution result, help text, or version text.");
389810
389866
  }
389811
389867
  const elapsedMs = io.now() - startedAt;
389812
389868
  writeSuccess(io, outputMode, output.execution, elapsedMs);
@@ -389840,6 +389896,7 @@ var init_src2 = __esm(async () => {
389840
389896
  init_install();
389841
389897
  init_uninstall();
389842
389898
  init_context();
389899
+ init_version2();
389843
389900
  init_cli();
389844
389901
  HELP = [
389845
389902
  CLI_HELP,
@@ -389850,7 +389907,16 @@ var init_src2 = __esm(async () => {
389850
389907
  " superdoc read <file>",
389851
389908
  "",
389852
389909
  "Canonical machine call:",
389853
- ' superdoc call <operationId> [--input-json "{...}"|--input-file payload.json]'
389910
+ ' superdoc call <operationId> [--input-json "{...}"|--input-file payload.json]',
389911
+ "",
389912
+ "Global flags:",
389913
+ " --output <json|pretty>",
389914
+ " --json",
389915
+ " --pretty",
389916
+ " --session <id>",
389917
+ " --timeout-ms <n>",
389918
+ " --help, -h",
389919
+ " --version, -v"
389854
389920
  ].join(`
389855
389921
  `);
389856
389922
  MANUAL_COMMANDS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.102",
3
+ "version": "0.2.0-next.103",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -21,20 +21,20 @@
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
23
  "@superdoc/document-api": "0.0.1",
24
- "superdoc": "1.18.0",
25
24
  "@superdoc/pm-adapter": "0.0.0",
26
- "@superdoc/super-editor": "0.0.1"
25
+ "@superdoc/super-editor": "0.0.1",
26
+ "superdoc": "1.18.0"
27
27
  },
28
28
  "module": "src/index.ts",
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.102",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.102",
35
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.102",
36
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.102",
37
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.102"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.103",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.103",
35
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.103",
36
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.103",
37
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.103"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",