shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
160 lines (157 loc) • 5.14 kB
JavaScript
import { Flags } from '@oclif/core';
import chalk from 'chalk';
import { j as isCWDGodotGame, W as WEB_URL, P as Platform, C as CredentialsType, k as getProject } from '../../../baseCommand-CTn3KGH3.js';
import { B as BaseAuthenticatedCommand, a as getRenderedMarkdown } from '../../../baseGameCommand-8VL7xe-O.js';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import 'luxon';
import 'axios';
import 'isomorphic-git';
import '@tanstack/react-query';
import 'react';
import 'fast-glob';
import 'uuid';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'ink';
import 'react/jsx-runtime';
import 'ink-spinner';
import 'string-length';
import 'strip-ansi';
import 'open';
import '@inkjs/ui';
import 'qrcode';
import { g as getUserCredentials, a as getProjectCredentials } from '../../../index-BW7z-5sB.js';
import 'crypto-js';
import '@expo/apple-utils/build/index.js';
import 'deepmerge';
import 'ini';
import 'fs';
import 'path';
import 'marked';
import 'marked-terminal';
class GameIosWizard extends BaseAuthenticatedCommand {
static args = {};
static description = "Runs all the steps for iOS";
static examples = ["<%= config.bin %> <%= command.id %>"];
static flags = {
forceStep: Flags.string({
char: "f",
description: "Force a specific step to run."
})
};
async run() {
const { flags } = this;
if (!isCWDGodotGame()) {
this.error(
"No Godot project detected. Please run this from a Godot project directory with a project.godot file.",
{ exit: 1 }
);
}
const projectConfig = this.getProjectConfigSafe();
const game = projectConfig.project;
const isStepForced = (cmdName) => flags.forceStep?.includes(cmdName);
const logSkip = (cmdName) => this.log(chalk.blue(`[skip] shipthis ${cmdName.replaceAll(":", " ")}`));
const logRun = (cmdName, args) => this.log(chalk.green(`[run] shipthis ${cmdName.replaceAll(":", " ")} ${args.join(" ")}`));
const iosSteps = [
{
args: ["--quiet"],
command: "game:create",
shouldRun: async () => !game
},
{
args: ["--quiet"],
command: "apple:login",
shouldRun: async () => {
const isLoggedIn = await this.hasValidAppleAuthState();
return !isLoggedIn;
}
},
{
args: ["--quiet"],
command: "apple:apiKey:create",
async shouldRun() {
const userCredentials = await getUserCredentials();
const userAppleApiKeyCredentials = userCredentials.filter(
(cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.KEY
);
const hasKey = userAppleApiKeyCredentials.length > 0;
return !hasKey;
}
},
{
args: ["--quiet"],
command: "apple:certificate:create",
async shouldRun() {
const userCredentials = await getUserCredentials();
const userAppleDistCredentials = userCredentials.filter(
(cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE
);
const hasDistCert = userAppleDistCredentials.length > 0;
return !hasDistCert;
}
},
{
args: ["--quiet"],
command: "game:ios:app:create",
async shouldRun() {
if (!game) return true;
const project = await getProject(game.id);
const hasBundleIdSet = Boolean(project.details?.iosBundleId);
return !hasBundleIdSet;
}
},
{
args: ["--quiet"],
command: "game:ios:app:sync",
// Can always run this
shouldRun: async () => true
},
{
args: ["--quiet", "--self"],
command: "game:ios:app:addTester",
shouldRun: async () => true
},
{
args: ["--quiet"],
command: "game:ios:profile:create",
async shouldRun() {
if (!game) return true;
const projectCredentials = await getProjectCredentials(game.id);
const projectAppleProfileCredentials = projectCredentials.filter(
(cred) => cred.platform === Platform.IOS && cred.type === CredentialsType.CERTIFICATE
);
const hasProfile = projectAppleProfileCredentials.length > 0;
return !hasProfile;
}
}
];
for (const step of iosSteps) {
const { command } = step;
const willRun = isStepForced(command) || await step.shouldRun();
if (!willRun) {
logSkip(command);
continue;
}
const args = [...step.args, ...isStepForced(command) ? ["--force"] : []];
logRun(command, args);
await this.config.runCommand(command, args);
}
const successMessage = getRenderedMarkdown({
filename: "ios-success.md.ejs",
templateVars: {
androidSetupURL: new URL("/docs/android", WEB_URL).toString(),
docsURL: new URL("/docs", WEB_URL).toString()
}
});
this.log(`
${successMessage}
`);
}
}
export { GameIosWizard as default };