@getmaito/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
@@ -22,6 +22,12 @@ Run commands:
22
22
  maito posts list
23
23
  ```
24
24
 
25
+ Show the installed version:
26
+
27
+ ```sh
28
+ maito version
29
+ ```
30
+
25
31
  ## Auth
26
32
 
27
33
  Sign in for full CLI access:
package/dist/index.js CHANGED
@@ -13693,7 +13693,8 @@ var AutoPlugConfigSchema = exports_external.object({
13693
13693
  kind: AutoPlugKindSchema,
13694
13694
  destination: AutoPlugDestinationSchema.default("first_comment"),
13695
13695
  messageTemplate: exports_external.string().trim().min(1).max(1000),
13696
- ctaLinkId: exports_external.string().min(1).optional()
13696
+ ctaLinkId: exports_external.string().min(1).optional(),
13697
+ issueId: exports_external.string().min(1).optional()
13697
13698
  });
13698
13699
  // ../contracts/src/billing.ts
13699
13700
  var BillingPlanSchema = exports_external.enum([
@@ -17293,15 +17294,23 @@ function getConfigDir() {
17293
17294
  }
17294
17295
  return process.env.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), ".config");
17295
17296
  }
17296
- function parseJsonResponse(response, label) {
17297
- return response.json().catch(() => {
17298
- throw new Error(`Failed to parse ${label} response.`);
17299
- }).then((payload) => {
17300
- if (!response.ok) {
17301
- throw new Error(formatOAuthError(label, payload, response.status));
17297
+ async function parseJsonResponse(response, label) {
17298
+ const text = await response.text();
17299
+ let payload;
17300
+ if (text.trim()) {
17301
+ try {
17302
+ payload = JSON.parse(text);
17303
+ } catch {
17304
+ if (!response.ok) {
17305
+ throw new Error(formatOAuthError(label, text, response.status));
17306
+ }
17307
+ throw new Error(`Failed to parse ${label} response.`);
17302
17308
  }
17303
- return payload;
17304
- });
17309
+ }
17310
+ if (!response.ok) {
17311
+ throw new Error(formatOAuthError(label, payload, response.status));
17312
+ }
17313
+ return payload;
17305
17314
  }
17306
17315
  function formatOAuthError(label, payload, status) {
17307
17316
  if (payload && typeof payload === "object") {
@@ -17318,6 +17327,9 @@ function formatOAuthError(label, payload, status) {
17318
17327
  return `${label} failed: ${message}`;
17319
17328
  }
17320
17329
  }
17330
+ if (typeof payload === "string" && payload.trim()) {
17331
+ return `${label} failed with status ${status}: ${payload.trim()}`;
17332
+ }
17321
17333
  return `${label} failed with status ${status}.`;
17322
17334
  }
17323
17335
  function requireString(value, fieldName) {
@@ -17437,6 +17449,12 @@ async function maybePrintUpdateNotice(input) {
17437
17449
  console.error(`Update available: ${PACKAGE_NAME} ${CURRENT_VERSION} -> ${latestVersion}`);
17438
17450
  console.error(`Run: npm update -g ${PACKAGE_NAME}`);
17439
17451
  }
17452
+ function getCliPackageInfo() {
17453
+ return {
17454
+ name: PACKAGE_NAME,
17455
+ version: CURRENT_VERSION
17456
+ };
17457
+ }
17440
17458
  function isDisabled() {
17441
17459
  const value = process.env.MAITO_CLI_DISABLE_UPDATE_CHECK?.trim().toLowerCase();
17442
17460
  return value === "1" || value === "true" || value === "yes";
@@ -17517,6 +17535,10 @@ async function main() {
17517
17535
  const { positionals, flags } = parseArgs(process.argv.slice(2));
17518
17536
  const json2 = readBooleanFlag(flags, "json");
17519
17537
  const baseUrl = resolveApiBaseUrl(readStringFlag(flags, "base-url") ?? process.env.MAITO_BASE_URL);
17538
+ if (positionals[0] === "version" || readBooleanFlag(flags, "version")) {
17539
+ printVersion({ json: json2 });
17540
+ return;
17541
+ }
17520
17542
  if (positionals.length === 0 || positionals[0] === "help" || readBooleanFlag(flags, "help")) {
17521
17543
  printUsage();
17522
17544
  return;
@@ -17981,6 +18003,10 @@ function parseArgs(argv) {
17981
18003
  if (!value) {
17982
18004
  continue;
17983
18005
  }
18006
+ if (value === "-v") {
18007
+ flags.version = true;
18008
+ continue;
18009
+ }
17984
18010
  if (!value.startsWith("--")) {
17985
18011
  positionals.push(value);
17986
18012
  continue;
@@ -18013,6 +18039,17 @@ function normalizeOutputKey(positionals) {
18013
18039
  const root = normalizeRoot(positionals[0]);
18014
18040
  return [root, positionals[1]].filter(Boolean).join(".");
18015
18041
  }
18042
+ function printVersion(input) {
18043
+ const packageInfo = getCliPackageInfo();
18044
+ if (input.json) {
18045
+ printJson({
18046
+ command: "maito",
18047
+ ...packageInfo
18048
+ });
18049
+ return;
18050
+ }
18051
+ console.log(`maito ${packageInfo.version}`);
18052
+ }
18016
18053
  function requireAction(context, index, command) {
18017
18054
  const action = context.positionals[index];
18018
18055
  if (!action) {
@@ -18209,6 +18246,8 @@ function parseJson(value, label) {
18209
18246
  }
18210
18247
  function printUsage() {
18211
18248
  console.log(`Usage:
18249
+ maito version [--json]
18250
+ maito --version
18212
18251
  maito login [--base-url <url>] [--oauth-client-id <id>] [--json]
18213
18252
  maito logout [--base-url <url>] [--json]
18214
18253
  maito auth status [--base-url <url>] [--json]
@@ -1,4 +1,8 @@
1
1
  export declare function maybePrintUpdateNotice(input: {
2
2
  json: boolean;
3
3
  }): Promise<void>;
4
+ export declare function getCliPackageInfo(): {
5
+ name: string;
6
+ version: string;
7
+ };
4
8
  //# sourceMappingURL=update-check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AA4BA,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,iBA8BpE"}
1
+ {"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AA4BA,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,iBA8BpE;AAED,wBAAgB,iBAAiB;;;EAKhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getmaito/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "maito": "dist/index.js"