UNPKG

shipthis

Version:

ShipThis manages building and uploading your Godot games to the App Store and Google Play.

99 lines (96 loc) 3.06 kB
import { jsx } from 'react/jsx-runtime'; import { Flags } from '@oclif/core'; import { render } from 'ink'; import { v4 } from 'uuid'; import { V as createAPIKey, c as getShortDate } from '../../baseCommand-CTn3KGH3.js'; import { B as BaseAuthenticatedCommand, g as getShortUUID, a as getRenderedMarkdown } from '../../baseGameCommand-8VL7xe-O.js'; import 'node:fs'; import 'node:path'; import 'chalk'; import 'ink-spinner'; import 'react'; import '@tanstack/react-query'; import 'axios'; import 'luxon'; import 'fast-glob'; import 'yazl'; import 'socket.io-client'; import 'fullscreen-ink'; import 'string-length'; import 'strip-ansi'; import 'open'; import '@inkjs/ui'; import 'qrcode'; import { R as RunWithSpinner } from '../../RunWithSpinner-DucRnFp6.js'; import { C as Command } from '../../Command-Cj6F5B5a.js'; import 'crypto-js'; import '@expo/apple-utils/build/index.js'; import 'node:crypto'; import 'node:readline'; import 'node:url'; import 'readline-sync'; import 'isomorphic-git'; import 'deepmerge'; import 'ini'; import 'fs'; import 'path'; import 'marked'; import 'marked-terminal'; class ApiKeyCreate extends BaseAuthenticatedCommand { static args = {}; static description = "Create a new API key for your ShipThis account."; static examples = [ "<%= config.bin %> <%= command.id %> --durationDays 30", "<%= config.bin %> <%= command.id %> --name ci-key --durationDays 90", "<%= config.bin %> <%= command.id %> --name ci-key-headless --durationDays 365 --quiet" ]; static flags = { durationDays: Flags.integer({ char: "d", default: 365, description: "duration of the API key in days" }), name: Flags.string({ char: "n", description: "name to apply to the API key (if not provided, a random name will be generated)" }), quiet: Flags.boolean({ char: "q", default: false, description: "Outputs just the secret value" }) }; async run() { const { durationDays, name } = this.flags; const createKey = async () => { const apiKeyName = name ? name : `api-key-${getShortUUID(v4())}`; const apiKeyWithSecret = await createAPIKey({ durationDays, name: apiKeyName }); const successMessage = getRenderedMarkdown({ filename: "apikey-create.md.ejs", templateVars: { keyExpiry: getShortDate(apiKeyWithSecret.expiresAt), keyId: getShortUUID(apiKeyWithSecret.id), keyName: apiKeyWithSecret.name, keySecret: apiKeyWithSecret.secret } }); if (this.flags.quiet) { this.log(apiKeyWithSecret.secret); return; } this.log(successMessage); }; if (this.flags.quiet) return await createKey(); render( /* @__PURE__ */ jsx(Command, { command: this, children: /* @__PURE__ */ jsx( RunWithSpinner, { executeMethod: createKey, msgInProgress: "Creating ShipThis API key...", onComplete: () => process.exit(0) } ) }) ); } } export { ApiKeyCreate as default };