shipthis 0.0.1

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.
Files changed (67) hide show
  1. package/README.md +894 -0
  2. package/bin/alias.sh +10 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +7 -0
  5. package/bin/dev.tsc.js +15 -0
  6. package/bin/loader.js +20 -0
  7. package/bin/run.cmd +3 -0
  8. package/bin/run.js +5 -0
  9. package/bin/run.tsc.js +15 -0
  10. package/dist/App-DFPMSEZF.js +21 -0
  11. package/dist/AppleBundleIdDetails-CuhAbVEp.js +61 -0
  12. package/dist/NextSteps-CK9zHOCt.js +18 -0
  13. package/dist/RunWithSpinner-BVXNWGD3.js +27 -0
  14. package/dist/StatusTable-CxuX_R1D.js +38 -0
  15. package/dist/Table-CvM6pccN.js +101 -0
  16. package/dist/Title-BCQtayg6.js +6 -0
  17. package/dist/UserCredentialsTable-DHeRI4h6.js +76 -0
  18. package/dist/baseAppleCommand-BXUu-026.js +10 -0
  19. package/dist/baseGameCommand-xrD2WDDN.js +599 -0
  20. package/dist/cacheKeys-CShA-ZjE.js +9 -0
  21. package/dist/commands/apple/apiKey/create.js +88 -0
  22. package/dist/commands/apple/apiKey/export.js +66 -0
  23. package/dist/commands/apple/apiKey/import.js +70 -0
  24. package/dist/commands/apple/apiKey/status.js +108 -0
  25. package/dist/commands/apple/certificate/create.js +118 -0
  26. package/dist/commands/apple/certificate/export.js +66 -0
  27. package/dist/commands/apple/certificate/import.js +70 -0
  28. package/dist/commands/apple/certificate/status.js +116 -0
  29. package/dist/commands/apple/login.js +74 -0
  30. package/dist/commands/apple/status.js +50 -0
  31. package/dist/commands/dashboard.js +32 -0
  32. package/dist/commands/game/build/download.js +78 -0
  33. package/dist/commands/game/build/list.js +83 -0
  34. package/dist/commands/game/create.js +59 -0
  35. package/dist/commands/game/details.js +89 -0
  36. package/dist/commands/game/export.js +52 -0
  37. package/dist/commands/game/ios/app/addTester.js +111 -0
  38. package/dist/commands/game/ios/app/create.js +104 -0
  39. package/dist/commands/game/ios/app/status.js +52 -0
  40. package/dist/commands/game/ios/app/sync.js +81 -0
  41. package/dist/commands/game/ios/profile/create.js +110 -0
  42. package/dist/commands/game/ios/profile/export.js +68 -0
  43. package/dist/commands/game/ios/profile/import.js +77 -0
  44. package/dist/commands/game/ios/profile/status.js +183 -0
  45. package/dist/commands/game/ios/status.js +79 -0
  46. package/dist/commands/game/job/list.js +80 -0
  47. package/dist/commands/game/job/status.js +297 -0
  48. package/dist/commands/game/list.js +69 -0
  49. package/dist/commands/game/ship.js +67 -0
  50. package/dist/commands/game/status.js +76 -0
  51. package/dist/commands/game/wizard.js +124 -0
  52. package/dist/commands/login.js +63 -0
  53. package/dist/commands/status.js +80 -0
  54. package/dist/export-CujqsTR_.js +36 -0
  55. package/dist/git-DREGq-jc.js +32 -0
  56. package/dist/import-Q-KO61ll.js +38 -0
  57. package/dist/index-DKsVctbw.js +125 -0
  58. package/dist/index.d.ts +1 -0
  59. package/dist/index.js +1 -0
  60. package/dist/run.js +3 -0
  61. package/dist/upload-CUlWmNbS.js +60 -0
  62. package/dist/useAppleApp-BmwYu7qG.js +32 -0
  63. package/dist/useAppleBundleId-DCJnfNWr.js +64 -0
  64. package/dist/useBuilds-Dh_PWwCf.js +41 -0
  65. package/dist/useJob-CCkqCMvF.js +34 -0
  66. package/oclif.manifest.json +1510 -0
  67. package/package.json +167 -0
@@ -0,0 +1,66 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Args, Flags } from '@oclif/core';
3
+ import { render } from 'ink';
4
+ import * as fs from 'fs';
5
+ import { B as BaseAuthenticatedCommand, g as getUserCredentials, P as Platform, C as CredentialsType } from '../../../baseGameCommand-xrD2WDDN.js';
6
+ import 'path';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import 'ink-spinner';
19
+ import 'string-length';
20
+ import 'strip-ansi';
21
+ import { R as RunWithSpinner } from '../../../RunWithSpinner-BVXNWGD3.js';
22
+ import { e as exportCredential } from '../../../export-CujqsTR_.js';
23
+ import 'ini';
24
+ import 'deepmerge';
25
+
26
+ class AppleApiKeyExport extends BaseAuthenticatedCommand {
27
+ static args = {
28
+ file: Args.string({ description: "Name of the ZIP file to create", required: true })
29
+ };
30
+ static description = "Saves the current App Store Connect API Key to a ZIP file";
31
+ static examples = ["<%= config.bin %> <%= command.id %> userApiKey.zip"];
32
+ static flags = {
33
+ force: Flags.boolean({ char: "f", description: "Overwrite the file if it already exists" })
34
+ };
35
+ async run() {
36
+ const { args, flags } = this;
37
+ const { file } = args;
38
+ const { force } = flags;
39
+ const zipAlreadyExists = fs.existsSync(file);
40
+ if (zipAlreadyExists && !force) {
41
+ this.error(`The file ${file} already exists. Use --force to overwrite it.`);
42
+ }
43
+ const userCredentials = await getUserCredentials();
44
+ const userAppleApiKeyCredentials = userCredentials.filter(
45
+ (cred) => cred.platform == Platform.IOS && cred.type == CredentialsType.KEY
46
+ );
47
+ if (userAppleApiKeyCredentials.length === 0) {
48
+ this.error("No App Store Connect API Key found which can be exported.");
49
+ }
50
+ const [key] = userAppleApiKeyCredentials;
51
+ const handleComplete = async () => process.exit(0);
52
+ render(
53
+ /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
54
+ RunWithSpinner,
55
+ {
56
+ msgInProgress: `Exporting App Store Connect API Key to ${file}...`,
57
+ msgComplete: `App Store Connect API Key exported to ${file}`,
58
+ executeMethod: () => exportCredential({ zipPath: file, credentialId: key.id }),
59
+ onComplete: handleComplete
60
+ }
61
+ ) })
62
+ );
63
+ }
64
+ }
65
+
66
+ export { AppleApiKeyExport as default };
@@ -0,0 +1,70 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Args, Flags } from '@oclif/core';
3
+ import { render } from 'ink';
4
+ import * as fs from 'fs';
5
+ import { B as BaseAuthenticatedCommand, g as getUserCredentials, P as Platform, C as CredentialsType } from '../../../baseGameCommand-xrD2WDDN.js';
6
+ import 'path';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import 'ink-spinner';
19
+ import 'string-length';
20
+ import 'strip-ansi';
21
+ import { R as RunWithSpinner } from '../../../RunWithSpinner-BVXNWGD3.js';
22
+ import { i as importCredential } from '../../../import-Q-KO61ll.js';
23
+ import 'ini';
24
+ import 'deepmerge';
25
+
26
+ class AppleApiKeyImport extends BaseAuthenticatedCommand {
27
+ static args = {
28
+ file: Args.string({
29
+ description: "Name of the ZIP file to import (must be in the same format as the export)",
30
+ required: true
31
+ })
32
+ };
33
+ static description = "Imports an App Store Connect API Key ZIP file into your ShipThis account";
34
+ static examples = ["<%= config.bin %> <%= command.id %> userApiKey.zip"];
35
+ static flags = {
36
+ force: Flags.boolean({ char: "f" })
37
+ };
38
+ async run() {
39
+ const { args, flags } = this;
40
+ const { file } = args;
41
+ const { force } = flags;
42
+ const zipFound = fs.existsSync(file);
43
+ if (!zipFound) {
44
+ this.error(`The file ${file} does not exist.`);
45
+ }
46
+ const userCredentials = await getUserCredentials();
47
+ const userAppleApiKeyCredentials = userCredentials.filter(
48
+ (cred) => cred.platform == Platform.IOS && cred.type == CredentialsType.KEY
49
+ );
50
+ if (userAppleApiKeyCredentials.length !== 0 && !force) {
51
+ this.error("An App Store Connect API Key already exists. Use --force to overwrite it.");
52
+ }
53
+ const handleComplete = async () => {
54
+ await this.config.runCommand(`apple:apiKey:status`, ["--noAppleAuth"]);
55
+ };
56
+ render(
57
+ /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
58
+ RunWithSpinner,
59
+ {
60
+ msgInProgress: `Importing App Store Connect API from ${file}...`,
61
+ msgComplete: `App Store Connect API imported from ${file}`,
62
+ executeMethod: () => importCredential({ zipPath: file, type: CredentialsType.KEY, platform: Platform.IOS }),
63
+ onComplete: handleComplete
64
+ }
65
+ ) })
66
+ );
67
+ }
68
+ }
69
+
70
+ export { AppleApiKeyImport as default };
@@ -0,0 +1,108 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { Flags } from '@oclif/core';
3
+ import { Box, Text, render } from 'ink';
4
+ import { f as getShortDate, A as ApiKey, P as Platform, C as CredentialsType, B as BaseAuthenticatedCommand } from '../../../baseGameCommand-xrD2WDDN.js';
5
+ import 'path';
6
+ import 'fs';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import { DateTime } from 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import { useQuery } from '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import Spinner from 'ink-spinner';
19
+ import { u as useUserCredentials, U as UserCredentialsTable } from '../../../UserCredentialsTable-DHeRI4h6.js';
20
+ import { T as Title } from '../../../Title-BCQtayg6.js';
21
+ import { T as Table } from '../../../Table-CvM6pccN.js';
22
+ import 'string-length';
23
+ import 'strip-ansi';
24
+ import { N as NextSteps } from '../../../NextSteps-CK9zHOCt.js';
25
+ import 'ini';
26
+ import 'deepmerge';
27
+ import '../../../cacheKeys-CShA-ZjE.js';
28
+ import '../../../index-DKsVctbw.js';
29
+
30
+ async function queryAppleApiKeys({ ctx }) {
31
+ const keys = await ApiKey.getAsync(ctx);
32
+ const activeKeys = keys.filter((key) => key.attributes.isActive);
33
+ return activeKeys;
34
+ }
35
+ const canAppleApiKeyBeUsed = (key, userCredentials) => {
36
+ if (!key.attributes.isActive) return false;
37
+ return userCredentials.some((cred) => cred.isActive && cred.serialNumber == key.id);
38
+ };
39
+ function getAppleApiKeySummary(key, userCredentials) {
40
+ return {
41
+ keyID: key.id,
42
+ name: key.attributes.nickname,
43
+ roles: key.attributes.roles?.join(", "),
44
+ lastUsed: getShortDate(DateTime.fromISO(key.attributes.lastUsed)),
45
+ canBeUsed: canAppleApiKeyBeUsed(key, userCredentials)
46
+ };
47
+ }
48
+ const useAppleApiKeys = (props) => {
49
+ const queryResult = useQuery({
50
+ queryKey: ["appleApiKeys"],
51
+ queryFn: () => queryAppleApiKeys(props)
52
+ });
53
+ return queryResult;
54
+ };
55
+
56
+ const AppleApiKeysTable = ({ ctx, ...boxProps }) => {
57
+ const { data: userCredentialsResponse } = useUserCredentials({ platform: Platform.IOS, type: CredentialsType.KEY });
58
+ const { data: keys, isLoading } = useAppleApiKeys({ ctx });
59
+ const hasUsable = keys && userCredentialsResponse && keys.some((key) => canAppleApiKeyBeUsed(key, userCredentialsResponse.data));
60
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, ...boxProps, children: [
61
+ /* @__PURE__ */ jsx(Title, { children: "App Store Connect API Keys in your Apple account" }),
62
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
63
+ keys && userCredentialsResponse && /* @__PURE__ */ jsxs(Fragment, { children: [
64
+ /* @__PURE__ */ jsxs(Box, { marginLeft: 2, marginBottom: 1, flexDirection: "column", children: [
65
+ /* @__PURE__ */ jsx(Text, { children: `You have ${keys.length} App Store Connect API Keys in your Apple account` }),
66
+ /* @__PURE__ */ jsx(Text, { children: `${hasUsable ? "One" : "None"} of these can be used by ShipThis` })
67
+ ] }),
68
+ /* @__PURE__ */ jsx(Table, { data: keys.map((key) => getAppleApiKeySummary(key, userCredentialsResponse.data)) }),
69
+ !hasUsable && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "You do not have a usable App Store Connect API Key. To ship an iOS game, you will need a usable App Store Connect API Key." }) })
70
+ ] })
71
+ ] });
72
+ };
73
+
74
+ class AppleApiKeyStatus extends BaseAuthenticatedCommand {
75
+ static args = {};
76
+ static description = "Displays the status of the App Store Connect API Keys in your Apple and ShipThis accounts. The API key is used to automatically publish your games to the App Store.";
77
+ static examples = [
78
+ "<%= config.bin %> <%= command.id %>",
79
+ "<%= config.bin %> <%= command.id %> --noAppleAuth"
80
+ ];
81
+ static flags = {
82
+ noAppleAuth: Flags.boolean({ char: "f" })
83
+ };
84
+ async run() {
85
+ const { flags } = this;
86
+ const showApple = !flags.noAppleAuth;
87
+ let ctx = null;
88
+ if (showApple) {
89
+ const authState = await this.refreshAppleAuthState();
90
+ ctx = authState.context;
91
+ }
92
+ render(
93
+ /* @__PURE__ */ jsxs(App, { children: [
94
+ /* @__PURE__ */ jsx(
95
+ UserCredentialsTable,
96
+ {
97
+ credentialTypeName: "App Store Connect API Key",
98
+ queryProps: { type: CredentialsType.KEY, platform: Platform.IOS }
99
+ }
100
+ ),
101
+ showApple && /* @__PURE__ */ jsx(AppleApiKeysTable, { ctx }),
102
+ /* @__PURE__ */ jsx(NextSteps, { steps: [] })
103
+ ] })
104
+ );
105
+ }
106
+ }
107
+
108
+ export { AppleApiKeyStatus as default };
@@ -0,0 +1,118 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Flags } from '@oclif/core';
3
+ import { render } from 'ink';
4
+ import 'path';
5
+ import 'fs';
6
+ import '@expo/apple-utils/build/index.js';
7
+ import 'axios';
8
+ import { q as Certificate, r as CertificateType, g as getUserCredentials, P as Platform, C as CredentialsType } from '../../../baseGameCommand-xrD2WDDN.js';
9
+ import 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { B as BaseAppleCommand } from '../../../baseAppleCommand-BXUu-026.js';
18
+ import { A as App } from '../../../App-DFPMSEZF.js';
19
+ import 'ink-spinner';
20
+ import 'string-length';
21
+ import 'strip-ansi';
22
+ import { R as RunWithSpinner } from '../../../RunWithSpinner-BVXNWGD3.js';
23
+ import forge from 'node-forge';
24
+ import { u as uploadUserCredentials } from '../../../upload-CUlWmNbS.js';
25
+ import 'ini';
26
+ import 'deepmerge';
27
+
28
+ function decodeCertificate(certificateContent) {
29
+ const decodedContent = forge.util.decode64(certificateContent);
30
+ const asn1 = forge.asn1.fromDer(decodedContent);
31
+ return forge.pki.certificateFromAsn1(asn1);
32
+ }
33
+ function encodePkcs12(pkcs12Asn1) {
34
+ const derBytes = forge.asn1.toDer(pkcs12Asn1).getBytes();
35
+ return forge.util.encode64(derBytes);
36
+ }
37
+ async function createCertificate(ctx, certificateType = CertificateType.IOS_DISTRIBUTION) {
38
+ const {
39
+ pem: csrPem,
40
+ keyPair: { privateKey }
41
+ } = await Certificate.createCertificateSigningRequestAsync();
42
+ const certificate = await Certificate.createAsync(ctx, {
43
+ csrContent: csrPem,
44
+ certificateType
45
+ });
46
+ return {
47
+ certificate,
48
+ privateKey,
49
+ privateKeyPem: forge.pki.privateKeyToPem(privateKey)
50
+ };
51
+ }
52
+ function exportCertificate(certificate, privateKey) {
53
+ const decodedCertificate = decodeCertificate(certificate.attributes.certificateContent);
54
+ const password = forge.util.encode64(forge.random.getBytesSync(16));
55
+ const pkcs12Asn1 = forge.pkcs12.toPkcs12Asn1(privateKey, [decodedCertificate], password, {
56
+ friendlyName: "key",
57
+ algorithm: "3des"
58
+ });
59
+ const encodedPkcs12 = encodePkcs12(pkcs12Asn1);
60
+ return {
61
+ certificateBase64: encodedPkcs12,
62
+ certificatePassword: password
63
+ };
64
+ }
65
+
66
+ class AppleCertificateCreate extends BaseAppleCommand {
67
+ static args = {};
68
+ static description = "Creates an iOS Distribution Certificate in your Apple Developer account and saves it with the private key to your ShipThis account";
69
+ static examples = ["<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> --force"];
70
+ static flags = {
71
+ force: Flags.boolean({ char: "f" }),
72
+ quiet: Flags.boolean({ char: "q", description: "Avoid output except for interactions and errors" })
73
+ };
74
+ async run() {
75
+ const { flags } = this;
76
+ const { force } = flags;
77
+ const userCredentials = await getUserCredentials();
78
+ const userAppleDistCredentials = userCredentials.filter(
79
+ (cred) => cred.platform == Platform.IOS && cred.type == CredentialsType.CERTIFICATE
80
+ );
81
+ if (userAppleDistCredentials.length !== 0 && !force) {
82
+ this.error("An Apple Distribution Certificate already exists. Use --force to overwrite it.");
83
+ }
84
+ const authState = await this.refreshAppleAuthState();
85
+ const ctx = authState.context;
86
+ const createCert = async () => {
87
+ const { certificate, privateKey } = await createCertificate(ctx);
88
+ const exported = exportCertificate(certificate, privateKey);
89
+ const serialNumber = certificate.attributes.serialNumber;
90
+ await uploadUserCredentials({
91
+ platform: Platform.IOS,
92
+ type: CredentialsType.CERTIFICATE,
93
+ contents: {
94
+ serialNumber,
95
+ ...exported
96
+ },
97
+ serialNumber
98
+ });
99
+ };
100
+ const handleComplete = async () => {
101
+ await this.config.runCommand(`apple:certificate:status`);
102
+ };
103
+ if (this.flags.quiet) return await createCert();
104
+ render(
105
+ /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
106
+ RunWithSpinner,
107
+ {
108
+ msgInProgress: `Creating certificate in the Apple Developer Portal...`,
109
+ msgComplete: `Certificate created and saved to ShipThis`,
110
+ executeMethod: createCert,
111
+ onComplete: handleComplete
112
+ }
113
+ ) })
114
+ );
115
+ }
116
+ }
117
+
118
+ export { AppleCertificateCreate as default };
@@ -0,0 +1,66 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Args, Flags } from '@oclif/core';
3
+ import { render } from 'ink';
4
+ import * as fs from 'fs';
5
+ import { B as BaseAuthenticatedCommand, g as getUserCredentials, P as Platform, C as CredentialsType } from '../../../baseGameCommand-xrD2WDDN.js';
6
+ import 'path';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import 'ink-spinner';
19
+ import 'string-length';
20
+ import 'strip-ansi';
21
+ import { R as RunWithSpinner } from '../../../RunWithSpinner-BVXNWGD3.js';
22
+ import { e as exportCredential } from '../../../export-CujqsTR_.js';
23
+ import 'ini';
24
+ import 'deepmerge';
25
+
26
+ class AppleCertificateExport extends BaseAuthenticatedCommand {
27
+ static args = {
28
+ file: Args.string({ description: "Name of the ZIP file to create", required: true })
29
+ };
30
+ static description = "Saves the current Apple Distribution Certificate to a ZIP file.";
31
+ static examples = ["<%= config.bin %> <%= command.id %> userCert.zip"];
32
+ static flags = {
33
+ force: Flags.boolean({ char: "f", description: "Overwrite the file if it already exists" })
34
+ };
35
+ async run() {
36
+ const { args, flags } = this;
37
+ const { file } = args;
38
+ const { force } = flags;
39
+ const zipAlreadyExists = fs.existsSync(file);
40
+ if (zipAlreadyExists && !force) {
41
+ this.error(`The file ${file} already exists. Use --force to overwrite it.`);
42
+ }
43
+ const userCredentials = await getUserCredentials();
44
+ const userAppleDistCredentials = userCredentials.filter(
45
+ (cred) => cred.platform == Platform.IOS && cred.type == CredentialsType.CERTIFICATE
46
+ );
47
+ if (userAppleDistCredentials.length === 0) {
48
+ this.error("No Apple Distribution Certificate found which can be exported.");
49
+ }
50
+ const [cert] = userAppleDistCredentials;
51
+ const handleComplete = async () => process.exit(0);
52
+ render(
53
+ /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
54
+ RunWithSpinner,
55
+ {
56
+ msgInProgress: `Exporting certificate to ${file}...`,
57
+ msgComplete: `Certificate exported to ${file}`,
58
+ executeMethod: () => exportCredential({ zipPath: file, credentialId: cert.id }),
59
+ onComplete: handleComplete
60
+ }
61
+ ) })
62
+ );
63
+ }
64
+ }
65
+
66
+ export { AppleCertificateExport as default };
@@ -0,0 +1,70 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Args, Flags } from '@oclif/core';
3
+ import { render } from 'ink';
4
+ import * as fs from 'fs';
5
+ import { B as BaseAuthenticatedCommand, g as getUserCredentials, P as Platform, C as CredentialsType } from '../../../baseGameCommand-xrD2WDDN.js';
6
+ import 'path';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import 'ink-spinner';
19
+ import 'string-length';
20
+ import 'strip-ansi';
21
+ import { R as RunWithSpinner } from '../../../RunWithSpinner-BVXNWGD3.js';
22
+ import { i as importCredential } from '../../../import-Q-KO61ll.js';
23
+ import 'ini';
24
+ import 'deepmerge';
25
+
26
+ class AppleCertificateImport extends BaseAuthenticatedCommand {
27
+ static args = {
28
+ file: Args.string({
29
+ description: "Name of the ZIP file to import (must be in the same format as the export)",
30
+ required: true
31
+ })
32
+ };
33
+ static description = "Imports an iOS Distribution Certificate to your ShipThis account";
34
+ static examples = ["<%= config.bin %> <%= command.id %> userCert.zip"];
35
+ static flags = {
36
+ force: Flags.boolean({ char: "f" })
37
+ };
38
+ async run() {
39
+ const { args, flags } = this;
40
+ const { file } = args;
41
+ const { force } = flags;
42
+ const zipFound = fs.existsSync(file);
43
+ if (!zipFound) {
44
+ this.error(`The file ${file} does not exist.`);
45
+ }
46
+ const userCredentials = await getUserCredentials();
47
+ const userAppleDistCredentials = userCredentials.filter(
48
+ (cred) => cred.platform == Platform.IOS && cred.type == CredentialsType.CERTIFICATE
49
+ );
50
+ if (userAppleDistCredentials.length !== 0 && !force) {
51
+ this.error("An Apple Distribution Certificate already exists. Use --force to overwrite it.");
52
+ }
53
+ const handleComplete = async () => {
54
+ await this.config.runCommand(`apple:certificate:status`, ["--noAppleAuth"]);
55
+ };
56
+ render(
57
+ /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(
58
+ RunWithSpinner,
59
+ {
60
+ msgInProgress: `Importing certificate from ${file}...`,
61
+ msgComplete: `Certificate imported from ${file}`,
62
+ executeMethod: () => importCredential({ zipPath: file, type: CredentialsType.CERTIFICATE, platform: Platform.IOS }),
63
+ onComplete: handleComplete
64
+ }
65
+ ) })
66
+ );
67
+ }
68
+ }
69
+
70
+ export { AppleCertificateImport as default };
@@ -0,0 +1,116 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { Flags } from '@oclif/core';
3
+ import { Box, Text, render } from 'ink';
4
+ import { f as getShortDate, q as Certificate, r as CertificateType, P as Platform, C as CredentialsType, B as BaseAuthenticatedCommand } from '../../../baseGameCommand-xrD2WDDN.js';
5
+ import 'path';
6
+ import 'fs';
7
+ import '@expo/apple-utils/build/index.js';
8
+ import 'axios';
9
+ import { DateTime } from 'luxon';
10
+ import 'crypto';
11
+ import 'readline-sync';
12
+ import 'node:readline';
13
+ import 'react';
14
+ import { useQuery } from '@tanstack/react-query';
15
+ import 'socket.io-client';
16
+ import 'isomorphic-git';
17
+ import { A as App } from '../../../App-DFPMSEZF.js';
18
+ import Spinner from 'ink-spinner';
19
+ import { g as getShortUUID } from '../../../index-DKsVctbw.js';
20
+ import { u as useUserCredentials, U as UserCredentialsTable } from '../../../UserCredentialsTable-DHeRI4h6.js';
21
+ import { T as Title } from '../../../Title-BCQtayg6.js';
22
+ import { T as Table } from '../../../Table-CvM6pccN.js';
23
+ import 'string-length';
24
+ import 'strip-ansi';
25
+ import { N as NextSteps } from '../../../NextSteps-CK9zHOCt.js';
26
+ import 'ini';
27
+ import 'deepmerge';
28
+ import '../../../cacheKeys-CShA-ZjE.js';
29
+
30
+ async function queryAppleCertificates({ ctx }) {
31
+ const appleCerts = await Certificate.getAsync(ctx, {
32
+ query: {
33
+ filter: {
34
+ certificateType: [CertificateType.DISTRIBUTION, CertificateType.IOS_DISTRIBUTION]
35
+ }
36
+ }
37
+ });
38
+ return appleCerts;
39
+ }
40
+ const canAppleCertificateBeUsed = (cert, userCredentials) => {
41
+ if (cert.attributes.status != "Issued") return false;
42
+ return userCredentials.some((cred) => cred.isActive && cred.serialNumber == cert.attributes.serialNumber);
43
+ };
44
+ function getAppleCertificateSummary(cert, userCredentials) {
45
+ return {
46
+ id: getShortUUID(cert.id),
47
+ name: cert.attributes.name,
48
+ serial: cert.attributes.serialNumber,
49
+ expires: getShortDate(DateTime.fromISO(cert.attributes.expirationDate)),
50
+ canBeUsed: canAppleCertificateBeUsed(cert, userCredentials)
51
+ };
52
+ }
53
+ const useAppleCertificates = (props) => {
54
+ const queryResult = useQuery({
55
+ queryKey: ["appleCertificates"],
56
+ queryFn: () => queryAppleCertificates(props)
57
+ });
58
+ return queryResult;
59
+ };
60
+
61
+ const AppleCertificatesTable = ({ ctx, ...boxProps }) => {
62
+ const { data: userCredentialsResponse } = useUserCredentials({
63
+ platform: Platform.IOS,
64
+ type: CredentialsType.CERTIFICATE
65
+ });
66
+ const { data: certs, isLoading } = useAppleCertificates({ ctx });
67
+ const hasUsable = certs && userCredentialsResponse && certs.some((cert) => canAppleCertificateBeUsed(cert, userCredentialsResponse.data));
68
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, ...boxProps, children: [
69
+ /* @__PURE__ */ jsx(Title, { children: "Distribution Certificates in your Apple account" }),
70
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
71
+ certs && userCredentialsResponse && /* @__PURE__ */ jsxs(Fragment, { children: [
72
+ /* @__PURE__ */ jsxs(Box, { marginLeft: 2, marginBottom: 1, flexDirection: "column", children: [
73
+ /* @__PURE__ */ jsx(Text, { children: `You have ${certs.length} Distribution Certificates in your Apple account` }),
74
+ /* @__PURE__ */ jsx(Text, { children: `${hasUsable ? "One" : "None"} of these can be used by ShipThis` })
75
+ ] }),
76
+ /* @__PURE__ */ jsx(Table, { data: certs.map((cert) => getAppleCertificateSummary(cert, userCredentialsResponse.data)) }),
77
+ !hasUsable && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "You do not have a usable Distribution Certificate. To ship an iOS game, you will need a usable Distribution Certificate." }) })
78
+ ] })
79
+ ] });
80
+ };
81
+
82
+ class AppleCertificateStatus extends BaseAuthenticatedCommand {
83
+ static args = {};
84
+ static description = "Displays the status of the iOS Distribution certificates in your Apple and ShipThis accounts. These are used to sign all of your iOS apps.";
85
+ static examples = [
86
+ "<%= config.bin %> <%= command.id %>",
87
+ "<%= config.bin %> <%= command.id %> --noAppleAuth"
88
+ ];
89
+ static flags = {
90
+ noAppleAuth: Flags.boolean({ char: "f" })
91
+ };
92
+ async run() {
93
+ const { flags } = this;
94
+ const showApple = !flags.noAppleAuth;
95
+ let ctx = null;
96
+ if (showApple) {
97
+ const authState = await this.refreshAppleAuthState();
98
+ ctx = authState.context;
99
+ }
100
+ render(
101
+ /* @__PURE__ */ jsxs(App, { children: [
102
+ /* @__PURE__ */ jsx(
103
+ UserCredentialsTable,
104
+ {
105
+ credentialTypeName: "Apple iOS Distribution Certificate",
106
+ queryProps: { type: CredentialsType.CERTIFICATE, platform: Platform.IOS }
107
+ }
108
+ ),
109
+ showApple && /* @__PURE__ */ jsx(AppleCertificatesTable, { ctx }),
110
+ /* @__PURE__ */ jsx(NextSteps, { steps: [] })
111
+ ] })
112
+ );
113
+ }
114
+ }
115
+
116
+ export { AppleCertificateStatus as default };