shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
105 lines (102 loc) • 3.77 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { Flags } from '@oclif/core';
import { render } from 'ink';
import { g as getUserCredentials } from '../../../index-BW7z-5sB.js';
import { P as Platform, C as CredentialsType, A as ApiKey, U as UserRole, a as ApiKeyType } from '../../../baseCommand-CTn3KGH3.js';
import { B as BaseAppleCommand } from '../../../baseAppleCommand-Aq-Eaw_K.js';
import 'node:fs';
import 'axios';
import 'crypto-js';
import 'uuid';
import 'luxon';
import 'node:path';
import 'chalk';
import 'node:crypto';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import 'isomorphic-git';
import '@tanstack/react-query';
import 'react';
import 'fast-glob';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'ink-spinner';
import 'string-length';
import 'strip-ansi';
import 'open';
import '@inkjs/ui';
import '../../../baseGameCommand-8VL7xe-O.js';
import 'marked';
import 'marked-terminal';
import 'qrcode';
import { R as RunWithSpinner } from '../../../RunWithSpinner-DucRnFp6.js';
import { C as Command } from '../../../Command-Cj6F5B5a.js';
import { u as uploadUserCredentials } from '../../../upload-CHaDSvvi.js';
import '@expo/apple-utils/build/index.js';
import 'deepmerge';
import 'ini';
import 'fs';
import 'path';
class AppleApiKeyCreate extends BaseAppleCommand {
static args = {};
static description = "Creates an App Store Connect API Key in your Apple Developer account.\nSaves the private key in your ShipThis account.";
static examples = ["<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> --force"];
static flags = {
force: Flags.boolean({ char: "f" }),
quiet: Flags.boolean({ char: "q", description: "Avoid output except for interactions and errors" })
};
async run() {
const { flags } = this;
const { force } = flags;
const userCredentials = await getUserCredentials();
const userAppleApiKeyCredentials = userCredentials.filter(
(cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.KEY && cred.isActive
);
if (userAppleApiKeyCredentials.length > 0 && !force) {
this.error("An App Store Connect API already exists. Use --force to overwrite it.");
}
const authState = await this.refreshAppleAuthState();
const ctx = authState.context;
const createApiKey = async () => {
const userKey = await ApiKey.createAsync(ctx, {
allAppsVisible: true,
keyType: ApiKeyType.PUBLIC_API,
nickname: `ShipThis ${Math.floor(Date.now() / 1e3)}`,
roles: [UserRole.ADMIN]
});
const keyContent = await userKey.downloadAsync();
if (!keyContent) throw new Error("Failed to download key content");
const reloadedKey = await ApiKey.infoAsync(ctx, { id: userKey.id });
const key = {
issuer: `${reloadedKey.attributes.provider?.id}`,
keyId: userKey.id,
p8Content: keyContent,
serialNumber: userKey.id
};
await uploadUserCredentials({
contents: key,
platform: Platform.IOS,
serialNumber: key.serialNumber,
type: CredentialsType.KEY
});
};
const handleComplete = async () => {
await this.config.runCommand(`apple:apiKey:status`);
};
if (this.flags.quiet) return await createApiKey();
render(
/* @__PURE__ */ jsx(Command, { command: this, children: /* @__PURE__ */ jsx(
RunWithSpinner,
{
executeMethod: createApiKey,
msgComplete: `App Store Connect API created and saved to ShipThis`,
msgInProgress: `Creating App Store Connect API in the Apple Developer Portal...`,
onComplete: handleComplete
}
) })
);
}
}
export { AppleApiKeyCreate as default };