shipthis
Version:
ShipThis manages building and uploading your Godot games to the App Store and Google Play.
785 lines (772 loc) • 27.7 kB
JavaScript
import * as fs from 'node:fs';
import fs__default from 'node:fs';
import axios from 'axios';
import CryptoJS from 'crypto-js';
import { v4 } from 'uuid';
import { DateTime } from 'luxon';
import path from 'node:path';
import { Command, Flags } from '@oclif/core';
import * as expo from '@expo/apple-utils/build/index.js';
import 'node:crypto';
import 'node:readline';
import 'node:url';
import 'readline-sync';
import 'isomorphic-git';
import merge from 'deepmerge';
import { parse } from 'ini';
import { QueryClient } from '@tanstack/react-query';
import 'react';
import 'fast-glob';
import 'yazl';
import 'socket.io-client';
import 'fullscreen-ink';
import 'ink';
const AUTH_ENV_VAR_NAME = "SHIPTHIS_TOKEN";
const DOMAIN_ENV_VAR_NAME = "SHIPTHIS_DOMAIN";
const DEFAULT_SHIPPED_FILES_GLOBS = ["**/*"];
const DEFAULT_IGNORED_FILES_GLOBS = [
".git",
".gitignore",
"shipthis.json",
"shipthis-*.zip",
".godot/**",
".nomedia",
".import/**",
"export.cfg",
"export_credentials.cfg",
"*.translation",
".mono/**",
"data_*/**",
"mono_crash.*.json"
];
const PRIMARY_DOMAIN = "shipth.is";
function getUrlsForDomain(domain) {
const isPublic = domain.includes(PRIMARY_DOMAIN);
const apiDomain = (isPublic ? `api.` : "") + domain;
const wsDomain = (isPublic ? `ws.` : "") + domain;
return {
api: `https://${apiDomain}/api/1.0.0`,
web: `https://${domain}/`,
ws: `wss://${wsDomain}`
};
}
const DOMAIN = process.env[DOMAIN_ENV_VAR_NAME] || PRIMARY_DOMAIN;
const BACKEND_URLS = getUrlsForDomain(DOMAIN);
const API_URL = BACKEND_URLS.api;
const WS_URL = BACKEND_URLS.ws;
const WEB_URL = BACKEND_URLS.web;
const DEFAULT_LOCALE = "en-US";
function castObjectDates(apiObject, keys = ["createdAt", "updatedAt"]) {
if (!apiObject) return apiObject;
const datesOnly = Object.keys(apiObject).filter((k) => keys.includes(k)).reduce((a, c) => {
if (!apiObject[c]) return a;
a[c] = DateTime.fromISO(apiObject[c]);
return a;
}, {});
return {
...apiObject,
...datesOnly
};
}
function castArrayObjectDates(apiArray, keys = ["createdAt", "updatedAt"]) {
return apiArray.map((apiObject) => castObjectDates(apiObject, keys));
}
function castJobDates(jobObject) {
if (jobObject.build) return castObjectDates({ ...jobObject, build: castObjectDates(jobObject.build) });
return castObjectDates(jobObject);
}
function getDateLocale() {
const fallback = Intl.DateTimeFormat().resolvedOptions().locale.replaceAll("_", "-") || DEFAULT_LOCALE;
try {
const { env } = process;
const fullLocale = env.LC_TIME || env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES;
const shortLocale = fullLocale?.split(".")[0].replaceAll("_", "-");
const finalLocal = shortLocale || fallback;
const _ = DateTime.now().toLocaleString(DateTime.DATE_SHORT, { locale: finalLocal });
return finalLocal;
} catch {
return fallback;
}
}
function getShortDate(inputDate) {
const locale = getDateLocale();
return inputDate.toLocaleString(DateTime.DATE_SHORT, { locale });
}
function getShortDateTime(inputDate, extraFormatOpts = {}) {
const locale = getDateLocale();
const formatOpts = { ...DateTime.DATETIME_SHORT, ...extraFormatOpts };
return inputDate.toLocaleString(formatOpts, { locale });
}
function getShortTime(inputDate, extraFormatOpts = { fractionalSecondDigits: 3 }) {
const locale = getDateLocale();
const formatOpts = { ...DateTime.TIME_24_WITH_SECONDS, ...extraFormatOpts };
return inputDate.toLocaleString(formatOpts, { locale });
}
function getShortTimeDelta(start, end) {
return end.diff(start).rescale().set({ milliseconds: 0 }).shiftTo("minutes", "seconds").toHuman({
listStyle: "short",
unitDisplay: "short"
});
}
let currentAuthToken;
function setAuthToken(token) {
currentAuthToken = token;
}
function getAuthToken() {
return currentAuthToken;
}
function getAuthedHeaders() {
return {
Authorization: `Bearer ${currentAuthToken}`
};
}
async function createProject(props) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/projects`, props, opt);
return castObjectDates(data);
}
async function getProject(projectId) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/projects/${projectId}`, opt);
return castObjectDates(data);
}
async function getProjects(params) {
const headers = getAuthedHeaders();
const opt = { headers, params };
const { data: rawData } = await axios.get(`${API_URL}/projects`, opt);
const data = castArrayObjectDates(rawData.data);
return {
data,
pageCount: rawData.pageCount
};
}
async function updateProject(projectId, edits) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.put(`${API_URL}/projects/${projectId}`, edits, opt);
return castObjectDates(data);
}
async function getProjectPlatformProgress(projectId, platform) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/projects/${projectId}/${platform}/progress`, opt);
return data;
}
async function getNewUploadTicket(projectId) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/upload/${projectId}/url`, {}, opt);
return data;
}
async function startJobsFromUpload(uploadTicketId, startOptions) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/upload/start/${uploadTicketId}`, startOptions, opt);
return castArrayObjectDates(data);
}
async function getProjectJobs(projectId, params) {
const headers = getAuthedHeaders();
const opt = { headers, params };
const { data: rawData } = await axios.get(`${API_URL}/projects/${projectId}/jobs`, opt);
const data = castArrayObjectDates(rawData.data);
return {
data,
pageCount: rawData.pageCount
};
}
async function getJob(jobId, projectId) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/projects/${projectId}/jobs/${jobId}`, opt);
return castJobDates(data);
}
async function getSingleUseUrl(destination) {
const headers = await getAuthedHeaders();
const { data } = await axios.post(`${API_URL}/me/otp`, {}, { headers });
const queryString = Object.entries({ ...data, destination }).map(([key, value]) => `${key}=${encodeURIComponent(`${value}`)}`).join("&");
const url = `${WEB_URL}exchange/?${queryString}`;
return url;
}
async function getShortAuthRequiredUrl(destination) {
const { email } = await getSelf();
const key = v4();
const salt = "Na (s) + 1/2 Cl\u2082 (g) \u2192 NaCl (s)";
const fullKey = `${key}${salt}`;
const token = CryptoJS.AES.encrypt(email, fullKey).toString();
const params = {
destination,
key,
token
};
const queryString = Object.entries(params).map(([key2, value]) => `${key2}=${encodeURIComponent(`${value}`)}`).join("&");
const url = `${WEB_URL}login/?${queryString}`;
const headers = await getAuthedHeaders();
const { data } = await axios.post(
`${API_URL}/me/shorten`,
{
url
},
{ headers }
);
return data.url;
}
async function getBuild(projectId, buildId) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/projects/${projectId}/builds/${buildId}`, opt);
return castObjectDates(data);
}
async function getSelf() {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/me`, opt);
return castObjectDates(data);
}
async function acceptTerms() {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/me/acceptTerms`, {}, opt);
return castObjectDates(data);
}
async function getGoogleAuthUrl(projectId) {
const headers = getAuthedHeaders();
const opt = { headers };
const web = encodeURIComponent(new URL("/google/redirect/", WEB_URL).href);
const url = `${API_URL}/projects/${projectId}/credentials/android/key/connect`;
const { data } = await axios.get(`${url}?redirectUri=${web}`, opt);
const response = data;
return await getShortAuthRequiredUrl(response.url);
}
async function disconnectGoogle() {
const headers = getAuthedHeaders();
const opt = { headers };
await axios.delete(`${API_URL}/me/google/connect`, opt);
}
async function getGoogleStatus() {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.get(`${API_URL}/me/google/status`, opt);
return castObjectDates(data, ["orgCreatedAt"]);
}
async function enforcePolicy() {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/me/google/policy`, null, opt);
return castObjectDates(data, ["orgCreatedAt"]);
}
async function revokePolicy() {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.delete(`${API_URL}/me/google/policy`, opt);
return castObjectDates(data, ["orgCreatedAt"]);
}
async function inviteServiceAccount(projectId, developerId) {
try {
const headers = getAuthedHeaders();
const { data } = await axios.post(
`${API_URL}/projects/${projectId}/credentials/android/key/invite/`,
{ developerId },
{
headers
}
);
return data;
} catch (error) {
console.error("inviteServiceAccount Error", error);
throw error;
}
}
async function downloadBuildById(projectId, buildId, fileName) {
const build = await getBuild(projectId, buildId);
const { url } = build;
const writer = fs.createWriteStream(fileName);
const response = await axios({
method: "GET",
responseType: "stream",
url
});
response.data.pipe(writer);
return new Promise((resolve, reject) => {
writer.on("finish", resolve);
writer.on("error", reject);
});
}
const APIKEYS_DATE_FIELDS = ["createdAt", "updatedAt", "expiresAt", "lastUsedAt", "revokedAt"];
async function getAPIKeys(params) {
const headers = getAuthedHeaders();
const opt = { headers, params };
const { data: rawData } = await axios.get(`${API_URL}/me/keys`, opt);
const data = castArrayObjectDates(rawData.data, APIKEYS_DATE_FIELDS);
return {
data,
pageCount: rawData.pageCount
};
}
async function createAPIKey(createProps) {
const headers = getAuthedHeaders();
const opt = { headers };
const { data } = await axios.post(`${API_URL}/me/keys`, createProps, opt);
return castObjectDates(data, APIKEYS_DATE_FIELDS);
}
async function revokeAPIKey(apiKeyId) {
const headers = getAuthedHeaders();
const opt = { headers };
await axios.delete(`${API_URL}/me/keys/${apiKeyId}`, opt);
}
const defaultExport = expo.default;
const {
ApiKey,
ApiKeyType,
App,
Auth,
BetaGroup,
BundleId,
CapabilityType,
CapabilityTypeOption,
Certificate,
CertificateType,
Profile,
ProfileType,
Session,
UserRole
} = defaultExport;
var Platform = /* @__PURE__ */ ((Platform2) => {
Platform2["ANDROID"] = "ANDROID";
Platform2["IOS"] = "IOS";
return Platform2;
})(Platform || {});
var GameEngine = /* @__PURE__ */ ((GameEngine2) => {
GameEngine2["GODOT"] = "godot";
return GameEngine2;
})(GameEngine || {});
var JobStatus = /* @__PURE__ */ ((JobStatus2) => {
JobStatus2["COMPLETED"] = "COMPLETED";
JobStatus2["FAILED"] = "FAILED";
JobStatus2["PENDING"] = "PENDING";
JobStatus2["PROCESSING"] = "PROCESSING";
return JobStatus2;
})(JobStatus || {});
var JobStage = /* @__PURE__ */ ((JobStage2) => {
JobStage2["BUILD"] = "BUILD";
JobStage2["CONFIGURE"] = "CONFIGURE";
JobStage2["EXPORT"] = "EXPORT";
JobStage2["PUBLISH"] = "PUBLISH";
JobStage2["SETUP"] = "SETUP";
return JobStage2;
})(JobStage || {});
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
LogLevel2["ERROR"] = "ERROR";
LogLevel2["INFO"] = "INFO";
LogLevel2["WARN"] = "WARN";
return LogLevel2;
})(LogLevel || {});
var CredentialsType = /* @__PURE__ */ ((CredentialsType2) => {
CredentialsType2["CERTIFICATE"] = "CERTIFICATE";
CredentialsType2["KEY"] = "KEY";
return CredentialsType2;
})(CredentialsType || {});
var BuildType = /* @__PURE__ */ ((BuildType2) => {
BuildType2["AAB"] = "AAB";
BuildType2["APK"] = "APK";
BuildType2["IPA"] = "IPA";
return BuildType2;
})(BuildType || {});
function isCWDGodotGame() {
const cwd = process.cwd();
const godotProject = path.join(cwd, "project.godot");
return fs__default.existsSync(godotProject);
}
const GODOT_CAPABILITIES = [
// TODO: how about capabilities from godot extensions
{ key: "capabilities/access_wifi", name: "Access WiFi", type: CapabilityType.ACCESS_WIFI },
{ key: "capabilities/push_notifications", name: "Push Notifications", type: CapabilityType.PUSH_NOTIFICATIONS }
];
function getGodotProjectCapabilities(platform) {
const exportPresets = getGodotExportPresets(platform);
const { options } = exportPresets;
const capabilities = [];
for (const capability of GODOT_CAPABILITIES) {
if (!(capability.key in options)) continue;
if (`${options[capability.key]}`.toLocaleLowerCase() === "true") capabilities.push(capability.type);
}
return capabilities;
}
function getGodotProjectConfig() {
const cwd = process.cwd();
const projectGodotPath = path.join(cwd, "project.godot");
const projectGodotContent = fs__default.readFileSync(projectGodotPath, "utf8");
return parse(projectGodotContent);
}
function getGodotProjectName() {
try {
const projectGodotConfig = getGodotProjectConfig();
return projectGodotConfig.application["config/name"];
} catch {
return null;
}
}
function getGodotAppleBundleIdentifier() {
try {
const preset = getGodotExportPresets(Platform.IOS);
return preset.options["application/bundle_identifier"];
} catch (error) {
console.log(error);
return null;
}
}
function getGodotAndroidPackageName() {
try {
const preset = getGodotExportPresets(Platform.ANDROID);
return preset.options["package/unique_name"];
} catch (error) {
console.log(error);
return null;
}
}
function getGodotVersion() {
const projectGodotConfig = getGodotProjectConfig();
if ("config/features" in projectGodotConfig.application) {
const features = projectGodotConfig.application["config/features"];
const match = features.match(/"(\d+\.\d+)"/);
if (!match) throw new Error("Couldn't find Godot version in project.godot");
return match[1];
}
return "3.6";
}
function getGodotExportPresets(platform) {
const { warn } = console;
let presetConfig = platform === Platform.IOS ? getBaseExportPresets_iOS() : getBaseExportPresets_Android();
const cwd = process.cwd();
const filename = "export_presets.cfg";
const exportPresetsPath = path.join(cwd, filename);
const isFound = fs__default.existsSync(exportPresetsPath);
if (isFound) {
const exportPresetsContent = fs__default.readFileSync(exportPresetsPath, "utf8");
const exportPresetsIni = parse(exportPresetsContent);
const presetIndexes = Object.keys(exportPresetsIni.preset || {});
const presetIndex = presetIndexes.find((index) => {
const current = exportPresetsIni.preset[index];
return `${current.name}`.toUpperCase() === platform;
});
if (presetIndex) {
presetConfig = merge(presetConfig, exportPresetsIni.preset[presetIndex]);
} else {
warn(`Preset ${platform} not found in ${filename} - will use defaults`);
}
} else {
warn(`${filename} not found at ${exportPresetsPath}`);
}
return presetConfig;
}
function getBaseExportPresets_iOS() {
return {
custom_features: "",
dedicated_server: false,
encrypt_directory: false,
encrypt_pck: false,
encryption_exclude_filters: "",
encryption_include_filters: "",
exclude_filter: "",
export_filter: "all_resources",
export_path: "output",
include_filter: "",
name: "iOS",
options: {
"application/export_project_only": true,
"application/icon_interpolation": "4",
"application/launch_screens_interpolation": "4",
"application/short_version": "1.0.0",
// default version number
"application/signature": "",
"architectures/arm64": true,
"capabilities/access_wifi": false,
"capabilities/push_notifications": false,
"custom_template/debug": "",
"custom_template/release": "",
"icons/app_store_1024x1024": "",
"icons/ipad_76x76": "",
"icons/ipad_152x152": "",
"icons/ipad_167x167": "",
"icons/iphone_120x120": "",
"icons/iphone_180x180": "",
"icons/notification_40x40": "",
"icons/notification_60x60": "",
"icons/settings_58x58": "",
"icons/settings_87x87": "",
"icons/spotlight_40x40": "",
"icons/spotlight_80x80": "",
"landscape_launch_screens/ipad_1024x768": "",
"landscape_launch_screens/ipad_2048x1536": "",
"landscape_launch_screens/iphone_2208x1242": "",
"landscape_launch_screens/iphone_2436x1125": "",
"portrait_launch_screens/ipad_768x1024": "",
"portrait_launch_screens/ipad_1536x2048": "",
"portrait_launch_screens/iphone_640x960": "",
"portrait_launch_screens/iphone_640x1136": "",
"portrait_launch_screens/iphone_750x1334": "",
"portrait_launch_screens/iphone_1125x2436": "",
"portrait_launch_screens/iphone_1242x2208": "",
"privacy/camera_usage_description": "",
"privacy/camera_usage_description_localized": "{}",
"privacy/microphone_usage_description": "",
"privacy/microphone_usage_description_localized": "{}",
"privacy/photolibrary_usage_description": "",
"privacy/photolibrary_usage_description_localized": "{}",
"storyboard/custom_bg_color": "Color(0, 0, 0, 1)",
"storyboard/custom_image@2x": "",
"storyboard/custom_image@3x": "",
"storyboard/image_scale_mode": "0",
"storyboard/use_custom_bg_color": false,
"storyboard/use_launch_screen_storyboard": true,
"user_data/accessible_from_files_app": false,
"user_data/accessible_from_itunes_sharing": false
},
platform: "iOS",
runnable: true
};
}
function getBaseExportPresets_Android() {
return {
name: "Android",
// TODO
options: {
// TODO
},
platform: "Android"
};
}
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 50
}
}
});
class BaseCommand extends Command {
// define flags that can be inherited by any command that extends BaseCommand
static baseFlags = {};
// add the --json flag
static enableJsonFlag = false;
args;
flags;
async catch(err) {
return super.catch(err);
}
// Used in baseGameCommand and the other commands that need to ensure that the CWD is a Godot project
ensureWeAreInAProjectDir() {
if (!isCWDGodotGame()) {
this.error("No Godot project detected. Please run this from a godot project directory.", { exit: 1 });
}
if (!this.hasProjectConfig()) {
this.error(
'No ShipThis config found. Please run `shipthis game create --name "Space Invaders"` to create a game.',
{ exit: 1 }
);
}
}
ensureWeHaveAppleCookies() {
if (!this.hasAuthConfigFile()) {
this.error("You must be authenticated with Apple in to use this command. Please run shipthis apple login", {
exit: 1
});
}
}
async finally(_) {
return super.finally(_);
}
// Used in the apple commands to get the cookies from the auth file
async getAppleCookies() {
const authConfig = await this.getAuthConfig();
if (!authConfig.appleCookies) return null;
return authConfig.appleCookies;
}
// Returns the current auth config - prefers to use the env var
async getAuthConfig() {
const envVarValue = process.env[AUTH_ENV_VAR_NAME];
if (!envVarValue) return await this.getAuthConfigFromFile();
setAuthToken(envVarValue);
const self = await getSelf();
const selfWithJwt = {
...self,
jwt: envVarValue
};
return {
shipThisUser: selfWithJwt
};
}
// Loads the auth config from the file system
async getAuthConfigFromFile() {
const baseConfig = {};
const configPath = this.getAuthConfigPath();
if (!fs__default.existsSync(configPath)) return baseConfig;
const raw = await fs__default.promises.readFile(configPath, "utf8");
const parsed = JSON.parse(raw);
if (parsed.shipThisUser) {
setAuthToken(parsed.shipThisUser.jwt);
}
return {
...baseConfig,
...parsed
};
}
// This is used to expose the flags to the Android Wizard
getDetailsFlagsValues() {
const keys = Object.keys(DetailsFlags);
const values = {};
for (const key of keys) {
if (this.flags[key]) values[key] = this.flags[key];
}
return values;
}
// Exposing it to the react components using the CommandContext
getFlags() {
return this.flags;
}
getGameId() {
const { flags } = this;
if (flags.gameId) return flags.gameId;
const { project } = this.getProjectConfigSafe();
if (!project) return null;
return project.id;
}
async getProjectConfig() {
if (!this.hasProjectConfig()) throw new Error("No project config found");
return this.getProjectConfigSafe();
}
getProjectConfigSafe() {
if (!this.hasProjectConfig()) return {};
const configPath = this.getProjectConfigPath();
const raw = fs__default.readFileSync(configPath, "utf8");
return JSON.parse(raw);
}
hasAuthConfigFile() {
const configPath = this.getAuthConfigPath();
return fs__default.existsSync(configPath);
}
hasProjectConfig() {
const configPath = this.getProjectConfigPath();
return fs__default.existsSync(configPath);
}
// Tests the apple cookies
async hasValidAppleAuthState() {
try {
await this.refreshAppleAuthState();
return true;
} catch {
return false;
}
}
async init() {
process.on("SIGINT", () => process.exit(0));
process.on("SIGTERM", () => process.exit(0));
await super.init();
const { args, flags } = await this.parse({
args: this.ctor.args,
baseFlags: super.ctor.baseFlags,
enableJsonFlag: this.ctor.enableJsonFlag,
flags: this.ctor.flags,
strict: this.ctor.strict
});
this.flags = flags;
this.args = args;
await this.getAuthConfig();
}
async isAuthenticated() {
const authConfig = await this.getAuthConfig();
return Boolean(authConfig.shipThisUser?.jwt);
}
async refreshAppleAuthState() {
const cookies = await this.getAppleCookies();
const rerunMessage = "Please run shipthis apple login to authenticate with Apple.";
if (!cookies) throw new Error(`No Apple cookies found. ${rerunMessage}`);
const authState = await Auth.loginWithCookiesAsync(
{
cookies
},
{}
);
if (!authState) throw new Error(`Failed to refresh Apple auth state. ${rerunMessage}`);
return authState;
}
async setAppleCookies(cookies) {
const authConfig = await this.getAuthConfig();
await this.setAuthConfig({ ...authConfig, appleCookies: cookies });
}
// This is called after login to persist the JWT and user details
async setAuthConfig(config) {
const configPath = this.getAuthConfigPath();
await fs__default.promises.writeFile(configPath, JSON.stringify(config, null, 2));
}
async setProjectConfig(config) {
const configPath = this.getProjectConfigPath();
await fs__default.promises.writeFile(configPath, JSON.stringify(config, null, 2));
}
async updateProjectConfig(update) {
const config = await this.getProjectConfig();
await this.setProjectConfig({ ...config, ...update });
}
// Returns the values of the flags in DetailsFlags
getAuthConfigPath() {
return path.join(this.config.home, ".shipthis.auth.json");
}
getProjectConfigPath() {
return path.join(process.cwd(), "shipthis.json");
}
}
class BaseAuthenticatedCommand extends BaseCommand {
static flags = {};
async init() {
await super.init();
if (!this.isAuthenticated()) {
this.error("No auth config found. Please run `shipthis login` to authenticate.", { exit: 1 });
}
const self = await getSelf();
const accepted = Boolean(self.details?.hasAcceptedTerms);
if (!accepted) {
this.error("You must accept the terms and conditions. Please run `shipthis login --force` to re-authenticate", {
exit: 1
});
}
}
}
class BaseGameCommand extends BaseAuthenticatedCommand {
static flags = {
...BaseAuthenticatedCommand.flags,
gameId: Flags.string({ char: "g", description: "The ID of the game" })
};
async getGame() {
try {
const gameId = await this.getGameId();
if (!gameId) this.error("No game ID found.");
return await getProject(gameId);
} catch (error) {
if (error?.response?.status === 404) {
this.error("Game not found - please check you have access");
} else throw error;
}
}
async updateGame(update) {
const project = await this.getGame();
const projectUpdate = {
...project,
...update
};
const updatedProject = await updateProject(project.id, projectUpdate);
await this.updateProjectConfig({ project: updatedProject });
return updatedProject;
}
}
const DetailsFlags = {
androidPackageName: Flags.string({ char: "a", description: "Set the Android package name" }),
buildNumber: Flags.integer({ char: "b", description: "Set the build number" }),
gameEngine: Flags.string({ char: "e", description: "Set the game engine" }),
gameEngineVersion: Flags.string({ char: "v", description: "Set the game engine version" }),
gcpProjectId: Flags.string({ char: "g", description: "Set the GCP project ID" }),
gcpServiceAccountId: Flags.string({ char: "c", description: "Set the GCP service account ID" }),
iosBundleId: Flags.string({ char: "i", description: "Set the iOS bundle ID" }),
name: Flags.string({ char: "n", description: "The name of the game" }),
semanticVersion: Flags.string({ char: "s", description: "Set the semantic version" })
};
export { revokeAPIKey as $, ApiKey as A, BaseAuthenticatedCommand as B, CredentialsType as C, DetailsFlags as D, getProject as E, getProjectPlatformProgress as F, GODOT_CAPABILITIES as G, downloadBuildById as H, castArrayObjectDates as I, JobStatus as J, queryClient as K, JobStage as L, LogLevel as M, WS_URL as N, getAuthToken as O, Platform as P, getGoogleStatus as Q, getGodotAndroidPackageName as R, enforcePolicy as S, revokePolicy as T, UserRole as U, inviteServiceAccount as V, WEB_URL as W, disconnectGoogle as X, BaseCommand as Y, getAPIKeys as Z, createAPIKey as _, ApiKeyType as a, getSingleUseUrl as a0, setAuthToken as a1, acceptTerms as a2, Auth as a3, getNewUploadTicket as a4, startJobsFromUpload as a5, getShortAuthRequiredUrl as a6, castObjectDates as a7, getGoogleAuthUrl as a8, castJobDates as a9, getShortTime as aa, getShortDateTime as ab, getShortTimeDelta as ac, BuildType as ad, updateProject as ae, getShortDate as b, BaseGameCommand as c, getGodotAppleBundleIdentifier as d, BundleId as e, App as f, getProjects as g, CapabilityTypeOption as h, BetaGroup as i, isCWDGodotGame as j, Certificate as k, CertificateType as l, Profile as m, ProfileType as n, API_URL as o, getAuthedHeaders as p, getGodotProjectCapabilities as q, CapabilityType as r, GameEngine as s, getGodotVersion as t, createProject as u, DEFAULT_SHIPPED_FILES_GLOBS as v, DEFAULT_IGNORED_FILES_GLOBS as w, getGodotProjectName as x, getProjectJobs as y, getJob as z };