@getmagical/cli 0.1.8 → 0.1.9

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
@@ -10,6 +10,7 @@ Magical CLI for the shared MCP operation surface.
10
10
  ## Usage
11
11
 
12
12
  ```bash
13
+ mgcl --version
13
14
  mgcl update
14
15
  mgcl auth login
15
16
  mgcl settings env base-url http://main.localhost:1355
package/dist/index.js CHANGED
@@ -2063,10 +2063,10 @@ function createMagicalApiClient({
2063
2063
  const resolveApiBaseUrl = typeof apiBaseUrl === "string" ? () => apiBaseUrl : apiBaseUrl;
2064
2064
  async function fetchJson({
2065
2065
  accessToken,
2066
- path: path5,
2066
+ path: path6,
2067
2067
  init
2068
2068
  }) {
2069
- const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path5}`;
2069
+ const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path6}`;
2070
2070
  const headers = new Headers(init?.headers);
2071
2071
  headers.set("authorization", `Bearer ${accessToken}`);
2072
2072
  const response = await fetchFn(url, {
@@ -3104,29 +3104,29 @@ function readInstalledPackageVersion({
3104
3104
  packageName,
3105
3105
  packageRootPath
3106
3106
  }) {
3107
- const packageManifestPath = path3.join(packageRootPath, "package.json");
3108
- if (!fs.existsSync(packageManifestPath)) {
3107
+ const packageManifestPath2 = path3.join(packageRootPath, "package.json");
3108
+ if (!fs.existsSync(packageManifestPath2)) {
3109
3109
  throw new CliError(
3110
- `Installed package metadata was not found at ${packageManifestPath}. Reinstall mgcl and try again.`
3110
+ `Installed package metadata was not found at ${packageManifestPath2}. Reinstall mgcl and try again.`
3111
3111
  );
3112
3112
  }
3113
- const packageManifestResult = safeJsonParse(
3114
- fs.readFileSync(packageManifestPath, "utf8")
3113
+ const packageManifestResult2 = safeJsonParse(
3114
+ fs.readFileSync(packageManifestPath2, "utf8")
3115
3115
  );
3116
- if (isErr(packageManifestResult)) {
3117
- throw new CliError(`Failed to parse ${packageManifestPath}.`, {
3118
- cause: packageManifestResult.error.cause
3116
+ if (isErr(packageManifestResult2)) {
3117
+ throw new CliError(`Failed to parse ${packageManifestPath2}.`, {
3118
+ cause: packageManifestResult2.error.cause
3119
3119
  });
3120
3120
  }
3121
- const packageManifest = packageManifestResult.value;
3121
+ const packageManifest = packageManifestResult2.value;
3122
3122
  if (packageManifest.name !== packageName) {
3123
3123
  throw new CliError(
3124
- `Expected installed package ${packageName} at ${packageManifestPath}. Reinstall mgcl and try again.`
3124
+ `Expected installed package ${packageName} at ${packageManifestPath2}. Reinstall mgcl and try again.`
3125
3125
  );
3126
3126
  }
3127
3127
  if (typeof packageManifest.version !== "string" || !packageManifest.version) {
3128
3128
  throw new CliError(
3129
- `Installed package version is missing from ${packageManifestPath}. Reinstall mgcl and try again.`
3129
+ `Installed package version is missing from ${packageManifestPath2}. Reinstall mgcl and try again.`
3130
3130
  );
3131
3131
  }
3132
3132
  return packageManifest.version;
@@ -3551,6 +3551,28 @@ function createFileStateStore(stateFilePath) {
3551
3551
  };
3552
3552
  }
3553
3553
 
3554
+ // src/version.ts
3555
+ import fs2 from "fs";
3556
+ import path5 from "path";
3557
+ import { fileURLToPath as fileURLToPath2 } from "url";
3558
+ var packageManifestPath = path5.resolve(
3559
+ path5.dirname(fileURLToPath2(import.meta.url)),
3560
+ "../package.json"
3561
+ );
3562
+ var packageManifestResult = safeJsonParse(
3563
+ fs2.readFileSync(packageManifestPath, "utf8")
3564
+ );
3565
+ if (isErr(packageManifestResult)) {
3566
+ throw new Error(`Failed to parse ${packageManifestPath}.`, {
3567
+ cause: packageManifestResult.error.cause
3568
+ });
3569
+ }
3570
+ var cliPackageVersion = packageManifestResult.value.version;
3571
+ if (typeof cliPackageVersion !== "string" || cliPackageVersion.length === 0) {
3572
+ throw new Error(`Expected a version in ${packageManifestPath}.`);
3573
+ }
3574
+ var CLI_VERSION = cliPackageVersion;
3575
+
3554
3576
  // src/workos-auth.ts
3555
3577
  import { z as z6 } from "zod";
3556
3578
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
@@ -4099,7 +4121,7 @@ function createDefaultDependencies() {
4099
4121
  function buildProgram(dependencies) {
4100
4122
  const program2 = configureCommandPresentation(
4101
4123
  new Command2().name("mgcl").description("Run Magical operations from the command line.")
4102
- ).addOption(new Option2("--json", "Render JSON output.")).addOption(
4124
+ ).addOption(new Option2("--json", "Render JSON output.")).version(CLI_VERSION, "--version", `Display mgcl version (${CLI_VERSION}).`).addOption(
4103
4125
  new Option2(
4104
4126
  "--update",
4105
4127
  "Update mgcl to the latest published npm release."