shipthis 0.1.9 → 0.1.11

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 (134) hide show
  1. package/assets/markdown/create-or-import-keystore.md +7 -0
  2. package/dist/AppleBundleIdDetails-CjP5y0cj.js +74 -0
  3. package/dist/AppleBundleIdDetails-CztWY_mT.js +73 -0
  4. package/dist/AppleBundleIdDetails-DKeSAte9.js +73 -0
  5. package/dist/AppleBundleIdDetails-DymjrhOZ.js +73 -0
  6. package/dist/Command-BiB9MqbJ.js +204 -0
  7. package/dist/Command-D6rWEZRM.js +204 -0
  8. package/dist/Command-Dn0P_KOV.js +205 -0
  9. package/dist/Command-YJJp90ru.js +204 -0
  10. package/dist/CommandGame-C1oTlfdb.js +8 -0
  11. package/dist/CommandGame-cPaTk1wh.js +8 -0
  12. package/dist/CommandGame-k04mHiDl.js +8 -0
  13. package/dist/CommandGame-pI9VXKxi.js +8 -0
  14. package/dist/Create-DIaSKUpl.js +56 -0
  15. package/dist/CreateKeystore-BnNdeDUa.js +57 -0
  16. package/dist/CreateKeystore-Cf-nsK_M.js +56 -0
  17. package/dist/CreateKeystore-g1z6DsU5.js +56 -0
  18. package/dist/Import-BIOsf8AA.js +107 -0
  19. package/dist/JobProgress-CPkWVSlH.js +108 -0
  20. package/dist/JobProgress-W0QQR49T.js +108 -0
  21. package/dist/JobProgress-biiLhigg.js +109 -0
  22. package/dist/JobProgress-jmGAzvxS.js +108 -0
  23. package/dist/JobStatusTable-BA_q-kgE.js +75 -0
  24. package/dist/JobStatusTable-ByW0bN6c.js +75 -0
  25. package/dist/JobStatusTable-CgaTS7jS.js +75 -0
  26. package/dist/JobStatusTable-DqoppRro.js +75 -0
  27. package/dist/ProjectCredentialsTable-8kXt7sTS.js +37 -0
  28. package/dist/ProjectCredentialsTable-DRMK_SNw.js +37 -0
  29. package/dist/ProjectCredentialsTable-DfkpvTf8.js +37 -0
  30. package/dist/UserCredentialsTable-DMh8Wpy7.js +82 -0
  31. package/dist/UserCredentialsTable-DgHZJSHG.js +82 -0
  32. package/dist/UserCredentialsTable-TflQvTEP.js +82 -0
  33. package/dist/baseAppleCommand-1isaFxCQ.js +10 -0
  34. package/dist/baseAppleCommand-B9wyIqdL.js +10 -0
  35. package/dist/baseAppleCommand-DpasCbje.js +10 -0
  36. package/dist/baseGameAndroidCommand-6vsMpE7a.js +43 -0
  37. package/dist/baseGameAndroidCommand-B3LRG701.js +43 -0
  38. package/dist/baseGameAndroidCommand-C9BuS2Sr.js +43 -0
  39. package/dist/commands/apple/apiKey/create.js +10 -10
  40. package/dist/commands/apple/apiKey/export.js +8 -8
  41. package/dist/commands/apple/apiKey/import.js +8 -8
  42. package/dist/commands/apple/apiKey/status.js +7 -7
  43. package/dist/commands/apple/certificate/create.js +10 -10
  44. package/dist/commands/apple/certificate/export.js +8 -8
  45. package/dist/commands/apple/certificate/import.js +8 -8
  46. package/dist/commands/apple/certificate/status.js +7 -7
  47. package/dist/commands/apple/login.js +2 -2
  48. package/dist/commands/apple/status.js +6 -6
  49. package/dist/commands/dashboard.js +1 -1
  50. package/dist/commands/game/android/apiKey/connect.js +11 -11
  51. package/dist/commands/game/android/apiKey/create.js +13 -13
  52. package/dist/commands/game/android/apiKey/export.js +9 -9
  53. package/dist/commands/game/android/apiKey/import.js +9 -9
  54. package/dist/commands/game/android/apiKey/invite.js +4 -4
  55. package/dist/commands/game/android/apiKey/status.js +9 -9
  56. package/dist/commands/game/android/keyStore/create.js +12 -12
  57. package/dist/commands/game/android/keyStore/export.js +8 -8
  58. package/dist/commands/game/android/keyStore/import.js +49 -29
  59. package/dist/commands/game/android/keyStore/status.js +8 -8
  60. package/dist/commands/game/android/status.js +7 -7
  61. package/dist/commands/game/build/download.js +7 -7
  62. package/dist/commands/game/build/list.js +7 -7
  63. package/dist/commands/game/create.js +2 -2
  64. package/dist/commands/game/details.js +22 -8
  65. package/dist/commands/game/export.js +1 -1
  66. package/dist/commands/game/ios/app/addTester.js +6 -6
  67. package/dist/commands/game/ios/app/create.js +5 -5
  68. package/dist/commands/game/ios/app/status.js +9 -9
  69. package/dist/commands/game/ios/app/sync.js +7 -7
  70. package/dist/commands/game/ios/profile/create.js +10 -10
  71. package/dist/commands/game/ios/profile/export.js +8 -8
  72. package/dist/commands/game/ios/profile/import.js +8 -8
  73. package/dist/commands/game/ios/profile/status.js +8 -8
  74. package/dist/commands/game/ios/status.js +10 -10
  75. package/dist/commands/game/ios/wizard.js +2 -2
  76. package/dist/commands/game/job/list.js +7 -7
  77. package/dist/commands/game/job/status.js +11 -11
  78. package/dist/commands/game/list.js +7 -7
  79. package/dist/commands/game/ship.js +11 -11
  80. package/dist/commands/game/status.js +7 -7
  81. package/dist/commands/game/wizard.js +590 -35
  82. package/dist/commands/internal/fastlane.js +1 -1
  83. package/dist/commands/internal/readme.js +255 -770
  84. package/dist/commands/login.js +2 -2
  85. package/dist/commands/status.js +6 -6
  86. package/dist/export-B_F6vXIK.js +36 -0
  87. package/dist/export-C_lu1FD9.js +36 -0
  88. package/dist/export-rS9o87LD.js +36 -0
  89. package/dist/import-7T3J63j2.js +38 -0
  90. package/dist/import-Brg3zYmT.js +38 -0
  91. package/dist/import-DPbg8WvS.js +38 -0
  92. package/dist/import-v54PM_Qg.js +47 -0
  93. package/dist/index-BB7X1Pqp.js +695 -0
  94. package/dist/index-BQnkBr1Q.js +136 -0
  95. package/dist/index-BX9h2vPV.js +123 -0
  96. package/dist/index-BjGSEqP5.js +135 -0
  97. package/dist/index-Bv3x8c78.js +693 -0
  98. package/dist/index-ByOvCs4O.js +122 -0
  99. package/dist/index-BzffuqPa.js +24 -0
  100. package/dist/index-C9734Cj2.js +693 -0
  101. package/dist/index-CKYExssR.js +136 -0
  102. package/dist/index-Cz_KLwWf.js +136 -0
  103. package/dist/index-D6BH5UAM.js +135 -0
  104. package/dist/index-DOgF4dFK.js +24 -0
  105. package/dist/index-DgbQBx6x.js +122 -0
  106. package/dist/index-DxHPjZav.js +136 -0
  107. package/dist/index-m4HTrJ5J.js +135 -0
  108. package/dist/index-o9Y-84Rj.js +122 -0
  109. package/dist/upload-2naN75Zu.js +60 -0
  110. package/dist/upload-Cx71802W.js +60 -0
  111. package/dist/upload-DvAE1vDq.js +60 -0
  112. package/dist/useAndroidServiceAccountTestResult-BDc7XpKE.js +52 -0
  113. package/dist/useAndroidServiceAccountTestResult-B_ekRewZ.js +52 -0
  114. package/dist/useAndroidServiceAccountTestResult-Ce1x0Eh8.js +52 -0
  115. package/dist/useAppleApp-BEtLQa7n.js +32 -0
  116. package/dist/useAppleApp-CApC0-4Q.js +32 -0
  117. package/dist/useAppleApp-CETIcsJS.js +32 -0
  118. package/dist/useAppleBundleId-DXbMDRLd.js +64 -0
  119. package/dist/useAppleBundleId-SmzY6rkm.js +64 -0
  120. package/dist/useAppleBundleId-gPBzJwQg.js +64 -0
  121. package/dist/useJobWatching-BIG6fnTN.js +45 -0
  122. package/dist/useJobWatching-Cp-CYd90.js +45 -0
  123. package/dist/useJobWatching-D-YzSlK8.js +45 -0
  124. package/dist/useJobWatching-I_A3b36f.js +45 -0
  125. package/dist/useProjectCredentials-CKngz2rd.js +54 -0
  126. package/dist/useProjectCredentials-EapDge1I.js +54 -0
  127. package/dist/useProjectCredentials-vjedBbKl.js +54 -0
  128. package/dist/useWebSocket-Bep1zAVG.js +36 -0
  129. package/dist/useWebSocket-CBqsjHbt.js +36 -0
  130. package/dist/useWebSocket-rBLiZsKb.js +36 -0
  131. package/dist/wizard-ChPegnMW.js +133 -0
  132. package/npm-shrinkwrap.json +251 -223
  133. package/oclif.manifest.json +282 -223
  134. package/package.json +2 -4
@@ -0,0 +1,204 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { Text, useInput, Box } from 'ink';
3
+ import React, { useState, useEffect, useContext, useRef } from 'react';
4
+ import Spinner from 'ink-spinner';
5
+ import open from 'open';
6
+ import { g as getShortUUID, h as getPlatformName, s as scriptDir } from './index-Cz_KLwWf.js';
7
+ import { c as cacheKeys, u as useAndroidServiceAccountTestResult, K as KeyTestStatus, a as KeyTestError } from './useAndroidServiceAccountTestResult-Ce1x0Eh8.js';
8
+ import { p as getAuthedHeaders, q as API_URL, K as castArrayObjectDates, P as Platform, a6 as getShortDateTime, a5 as getJob, J as JobStatus, a7 as getShortTimeDelta, H as getProject, a2 as getShortAuthRequiredUrl, $ as queryClient, X as WEB_URL } from './index-BB7X1Pqp.js';
9
+ import '@inkjs/ui';
10
+ import axios from 'axios';
11
+ import { useQuery, QueryClientProvider } from '@tanstack/react-query';
12
+ import { setOptions, parse } from 'marked';
13
+ import fs__default from 'fs';
14
+ import TerminalRenderer from 'marked-terminal';
15
+ import path from 'path';
16
+ import 'qrcode';
17
+ import 'string-length';
18
+ import 'strip-ansi';
19
+ import 'luxon';
20
+ import 'uuid';
21
+ import 'fast-glob';
22
+ import 'yazl';
23
+ import 'socket.io-client';
24
+ import 'crypto';
25
+ import 'readline-sync';
26
+ import 'node:readline';
27
+ import 'node:path';
28
+ import 'node:url';
29
+ import 'crypto-js';
30
+ import 'isomorphic-git';
31
+ import '@oclif/core';
32
+
33
+ async function queryBuilds({ projectId, ...pageAndSortParams }) {
34
+ try {
35
+ const headers = getAuthedHeaders();
36
+ const url = `${API_URL}/projects/${projectId}/builds`;
37
+ const response = await axios.get(url, { headers, params: pageAndSortParams });
38
+ return {
39
+ ...response.data,
40
+ data: castArrayObjectDates(response.data.data)
41
+ };
42
+ } catch (error) {
43
+ console.warn("queryBuilds Error", error);
44
+ throw error;
45
+ }
46
+ }
47
+ function getBuildSummary(build) {
48
+ const filename = build.platform == Platform.IOS ? "output.ipa" : "output.aab";
49
+ return {
50
+ id: getShortUUID(build.id),
51
+ ...getJobDetailsSummary(build.jobDetails),
52
+ platform: getPlatformName(build.platform),
53
+ jobId: getShortUUID(build.jobId),
54
+ createdAt: getShortDateTime(build.createdAt),
55
+ cmd: `shipthis game build download ${getShortUUID(build.id)} ${filename}`
56
+ };
57
+ }
58
+ const useBuilds = (props) => {
59
+ const queryResult = useQuery({
60
+ queryKey: cacheKeys.builds(props),
61
+ queryFn: async () => queryBuilds(props)
62
+ });
63
+ return queryResult;
64
+ };
65
+
66
+ function getJobDetailsSummary(jobDetails) {
67
+ const semanticVersion = jobDetails?.semanticVersion || "N/A";
68
+ const buildNumber = jobDetails?.buildNumber || "N/A";
69
+ const gitCommit = jobDetails?.gitCommitHash ? getShortUUID(jobDetails?.gitCommitHash) : "N/A";
70
+ const gitBranch = jobDetails?.gitBranch || "N/A";
71
+ return {
72
+ version: `${semanticVersion} (${buildNumber})`,
73
+ gitInfo: `${gitCommit} (${gitBranch})`
74
+ };
75
+ }
76
+ function getJobSummary(job, timeNow) {
77
+ const inProgress = ![JobStatus.COMPLETED, JobStatus.FAILED].includes(job.status);
78
+ return {
79
+ id: getShortUUID(job.id),
80
+ ...getJobDetailsSummary(job.details),
81
+ platform: getPlatformName(job.type),
82
+ status: job.status,
83
+ createdAt: getShortDateTime(job.createdAt),
84
+ runtime: getShortTimeDelta(job.createdAt, inProgress ? timeNow : job.updatedAt)
85
+ };
86
+ }
87
+ const useJob = (props) => {
88
+ return useQuery({
89
+ queryKey: cacheKeys.job(props),
90
+ queryFn: () => getJob(props.jobId, props.projectId)
91
+ });
92
+ };
93
+
94
+ const CommandContext = React.createContext({
95
+ command: null,
96
+ setCommand: (command) => {
97
+ }
98
+ });
99
+ const CommandProvider = (props) => {
100
+ const [command, setCommand] = useState(props.command || null);
101
+ return /* @__PURE__ */ jsx(CommandContext.Provider, { value: { command, setCommand }, children: props.children });
102
+ };
103
+
104
+ const GameContext = React.createContext({
105
+ gameId: null,
106
+ game: null,
107
+ setGameId: (gameId) => {
108
+ }
109
+ });
110
+ const GameProvider = ({ children }) => {
111
+ const [gameId, setGameId] = useState(null);
112
+ const [game, setGame] = useState(null);
113
+ const { command } = React.useContext(CommandContext);
114
+ const handleLoad = async () => {
115
+ if (command) {
116
+ const commandGameId = await command.getGameId();
117
+ if (commandGameId) setGameId(commandGameId);
118
+ }
119
+ };
120
+ const handleGameIdChange = async () => {
121
+ if (!gameId) {
122
+ setGame(null);
123
+ return;
124
+ }
125
+ const game2 = await getProject(gameId);
126
+ setGame(game2);
127
+ };
128
+ useEffect(() => {
129
+ handleGameIdChange();
130
+ }, [gameId]);
131
+ useEffect(() => {
132
+ handleLoad();
133
+ }, [command]);
134
+ return /* @__PURE__ */ jsx(GameContext.Provider, { value: { gameId, game, setGameId }, children });
135
+ };
136
+
137
+ const entrypointPath = fs__default.realpathSync(process.argv[1]);
138
+ const root = path.dirname(entrypointPath);
139
+ const Markdown = ({ filename, templateVars, ...options }) => {
140
+ setOptions({ renderer: new TerminalRenderer(options) });
141
+ const mdPath = path.join(root, "..", "assets", "markdown", filename);
142
+ const mdTemplate = fs__default.readFileSync(mdPath, "utf8").trim();
143
+ const markdown = !templateVars ? mdTemplate : mdTemplate.replace(/\${(.*?)}/g, (_, key) => templateVars[key.trim()] || "");
144
+ return /* @__PURE__ */ jsx(Text, { children: parse(markdown).trim() });
145
+ };
146
+
147
+ scriptDir(import.meta);
148
+ const getIsAppFound = (result) => {
149
+ const isFound = result?.status === KeyTestStatus.SUCCESS || result?.status === KeyTestStatus.ERROR && result?.error === KeyTestError.NOT_INVITED;
150
+ return isFound;
151
+ };
152
+ const CreateGooglePlayGame = (props) => {
153
+ const { gameId } = useContext(GameContext);
154
+ return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(Create, { gameId, ...props }) });
155
+ };
156
+ const Create = ({ onComplete, onError, gameId, ...boxProps }) => {
157
+ const { data: result, isFetching } = useAndroidServiceAccountTestResult({ projectId: gameId });
158
+ const { data: builds } = useBuilds({ projectId: gameId, pageNumber: 0 });
159
+ const previousIsFound = useRef(false);
160
+ useEffect(() => {
161
+ const isFound = getIsAppFound(result);
162
+ if (previousIsFound.current === false && isFound) {
163
+ onComplete();
164
+ }
165
+ previousIsFound.current = isFound;
166
+ }, [result]);
167
+ useInput(async (input) => {
168
+ if (!gameId) return;
169
+ switch (input) {
170
+ case "r":
171
+ queryClient.invalidateQueries({
172
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
173
+ });
174
+ break;
175
+ case "d":
176
+ const dashUrl = await getShortAuthRequiredUrl(`/games/${getShortUUID(gameId)}/builds`);
177
+ await open(dashUrl);
178
+ }
179
+ if (input !== "r") return;
180
+ queryClient.invalidateQueries({
181
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
182
+ });
183
+ });
184
+ const initialBuild = builds?.data.find((build) => build.platform === Platform.ANDROID);
185
+ const downloadCmd = initialBuild ? `${getBuildSummary(initialBuild).cmd}` : "";
186
+ const templateVars = {
187
+ downloadCmd,
188
+ dashboardURL: new URL(`/games/${getShortUUID(gameId)}/builds`, WEB_URL).toString()
189
+ };
190
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
191
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
192
+ /* @__PURE__ */ jsx(Text, { bold: true, children: isFetching ? "Checking..." : "ShipThis has not detected your game in Google Play. Press R to test again." }),
193
+ isFetching && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
194
+ ] }),
195
+ /* @__PURE__ */ jsx(Markdown, { filename: "create-google-play-game.md", templateVars })
196
+ ] }) });
197
+ };
198
+
199
+ const Command = ({ children, command }) => {
200
+ const width = Math.min(160, process.stdout.columns || 80);
201
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommandProvider, { command, children: /* @__PURE__ */ jsx(Box, { width, flexDirection: "column", children }) }) });
202
+ };
203
+
204
+ export { Command as C, GameProvider as G, Markdown as M, getBuildSummary as a, GameContext as b, CommandContext as c, useBuilds as d, CreateGooglePlayGame as e, getJobSummary as g, queryBuilds as q, useJob as u };
@@ -0,0 +1,205 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { Text, useInput, Box } from 'ink';
3
+ import React, { useState, useEffect, useContext, useRef } from 'react';
4
+ import Spinner from 'ink-spinner';
5
+ import open from 'open';
6
+ import { g as getShortUUID, f as getPlatformName, s as scriptDir } from './index-DxHPjZav.js';
7
+ import { c as cacheKeys, u as useAndroidServiceAccountTestResult, K as KeyTestStatus, a as KeyTestError } from './useAndroidServiceAccountTestResult-B_ekRewZ.js';
8
+ import { o as getAuthedHeaders, p as API_URL, M as castArrayObjectDates, P as Platform, a6 as getShortDateTime, a5 as getJob, J as JobStatus, a7 as getShortTimeDelta, H as getProject, a2 as getShortAuthRequiredUrl, _ as queryClient, X as WEB_URL } from './index-C9734Cj2.js';
9
+ import '@inkjs/ui';
10
+ import axios from 'axios';
11
+ import { useQuery, QueryClientProvider } from '@tanstack/react-query';
12
+ import { setOptions, parse } from 'marked';
13
+ import fs__default from 'fs';
14
+ import TerminalRenderer from 'marked-terminal';
15
+ import path from 'path';
16
+ import 'qrcode';
17
+ import 'string-length';
18
+ import 'strip-ansi';
19
+ import 'luxon';
20
+ import 'uuid';
21
+ import 'fast-glob';
22
+ import 'yazl';
23
+ import 'socket.io-client';
24
+ import './wizard-ChPegnMW.js';
25
+ import 'crypto';
26
+ import 'readline-sync';
27
+ import 'node:readline';
28
+ import 'node:path';
29
+ import 'node:url';
30
+ import 'crypto-js';
31
+ import 'isomorphic-git';
32
+ import '@oclif/core';
33
+
34
+ async function queryBuilds({ projectId, ...pageAndSortParams }) {
35
+ try {
36
+ const headers = getAuthedHeaders();
37
+ const url = `${API_URL}/projects/${projectId}/builds`;
38
+ const response = await axios.get(url, { headers, params: pageAndSortParams });
39
+ return {
40
+ ...response.data,
41
+ data: castArrayObjectDates(response.data.data)
42
+ };
43
+ } catch (error) {
44
+ console.warn("queryBuilds Error", error);
45
+ throw error;
46
+ }
47
+ }
48
+ function getBuildSummary(build) {
49
+ const filename = build.platform == Platform.IOS ? "output.ipa" : "output.aab";
50
+ return {
51
+ id: getShortUUID(build.id),
52
+ ...getJobDetailsSummary(build.jobDetails),
53
+ platform: getPlatformName(build.platform),
54
+ jobId: getShortUUID(build.jobId),
55
+ createdAt: getShortDateTime(build.createdAt),
56
+ cmd: `shipthis game build download ${getShortUUID(build.id)} ${filename}`
57
+ };
58
+ }
59
+ const useBuilds = (props) => {
60
+ const queryResult = useQuery({
61
+ queryKey: cacheKeys.builds(props),
62
+ queryFn: async () => queryBuilds(props)
63
+ });
64
+ return queryResult;
65
+ };
66
+
67
+ function getJobDetailsSummary(jobDetails) {
68
+ const semanticVersion = jobDetails?.semanticVersion || "N/A";
69
+ const buildNumber = jobDetails?.buildNumber || "N/A";
70
+ const gitCommit = jobDetails?.gitCommitHash ? getShortUUID(jobDetails?.gitCommitHash) : "N/A";
71
+ const gitBranch = jobDetails?.gitBranch || "N/A";
72
+ return {
73
+ version: `${semanticVersion} (${buildNumber})`,
74
+ gitInfo: `${gitCommit} (${gitBranch})`
75
+ };
76
+ }
77
+ function getJobSummary(job, timeNow) {
78
+ const inProgress = ![JobStatus.COMPLETED, JobStatus.FAILED].includes(job.status);
79
+ return {
80
+ id: getShortUUID(job.id),
81
+ ...getJobDetailsSummary(job.details),
82
+ platform: getPlatformName(job.type),
83
+ status: job.status,
84
+ createdAt: getShortDateTime(job.createdAt),
85
+ runtime: getShortTimeDelta(job.createdAt, inProgress ? timeNow : job.updatedAt)
86
+ };
87
+ }
88
+ const useJob = (props) => {
89
+ return useQuery({
90
+ queryKey: cacheKeys.job(props),
91
+ queryFn: () => getJob(props.jobId, props.projectId)
92
+ });
93
+ };
94
+
95
+ const CommandContext = React.createContext({
96
+ command: null,
97
+ setCommand: (command) => {
98
+ }
99
+ });
100
+ const CommandProvider = (props) => {
101
+ const [command, setCommand] = useState(props.command || null);
102
+ return /* @__PURE__ */ jsx(CommandContext.Provider, { value: { command, setCommand }, children: props.children });
103
+ };
104
+
105
+ const GameContext = React.createContext({
106
+ gameId: null,
107
+ game: null,
108
+ setGameId: (gameId) => {
109
+ }
110
+ });
111
+ const GameProvider = ({ children }) => {
112
+ const [gameId, setGameId] = useState(null);
113
+ const [game, setGame] = useState(null);
114
+ const { command } = React.useContext(CommandContext);
115
+ const handleLoad = async () => {
116
+ if (command) {
117
+ const commandGameId = await command.getGameId();
118
+ if (commandGameId) setGameId(commandGameId);
119
+ }
120
+ };
121
+ const handleGameIdChange = async () => {
122
+ if (!gameId) {
123
+ setGame(null);
124
+ return;
125
+ }
126
+ const game2 = await getProject(gameId);
127
+ setGame(game2);
128
+ };
129
+ useEffect(() => {
130
+ handleGameIdChange();
131
+ }, [gameId]);
132
+ useEffect(() => {
133
+ handleLoad();
134
+ }, [command]);
135
+ return /* @__PURE__ */ jsx(GameContext.Provider, { value: { gameId, game, setGameId }, children });
136
+ };
137
+
138
+ const entrypointPath = fs__default.realpathSync(process.argv[1]);
139
+ const root = path.dirname(entrypointPath);
140
+ const Markdown = ({ filename, templateVars, ...options }) => {
141
+ setOptions({ renderer: new TerminalRenderer(options) });
142
+ const mdPath = path.join(root, "..", "assets", "markdown", filename);
143
+ const mdTemplate = fs__default.readFileSync(mdPath, "utf8").trim();
144
+ const markdown = !templateVars ? mdTemplate : mdTemplate.replace(/\${(.*?)}/g, (_, key) => templateVars[key.trim()] || "");
145
+ return /* @__PURE__ */ jsx(Text, { children: parse(markdown).trim() });
146
+ };
147
+
148
+ scriptDir(import.meta);
149
+ const getIsAppFound = (result) => {
150
+ const isFound = result?.status === KeyTestStatus.SUCCESS || result?.status === KeyTestStatus.ERROR && result?.error === KeyTestError.NOT_INVITED;
151
+ return isFound;
152
+ };
153
+ const CreateGooglePlayGame = (props) => {
154
+ const { gameId } = useContext(GameContext);
155
+ return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(Create, { gameId, ...props }) });
156
+ };
157
+ const Create = ({ onComplete, onError, gameId, ...boxProps }) => {
158
+ const { data: result, isFetching } = useAndroidServiceAccountTestResult({ projectId: gameId });
159
+ const { data: builds } = useBuilds({ projectId: gameId, pageNumber: 0 });
160
+ const previousIsFound = useRef(false);
161
+ useEffect(() => {
162
+ const isFound = getIsAppFound(result);
163
+ if (previousIsFound.current === false && isFound) {
164
+ onComplete();
165
+ }
166
+ previousIsFound.current = isFound;
167
+ }, [result]);
168
+ useInput(async (input) => {
169
+ if (!gameId) return;
170
+ switch (input) {
171
+ case "r":
172
+ queryClient.invalidateQueries({
173
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
174
+ });
175
+ break;
176
+ case "d":
177
+ const dashUrl = await getShortAuthRequiredUrl(`/games/${getShortUUID(gameId)}/builds`);
178
+ await open(dashUrl);
179
+ }
180
+ if (input !== "r") return;
181
+ queryClient.invalidateQueries({
182
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
183
+ });
184
+ });
185
+ const initialBuild = builds?.data.find((build) => build.platform === Platform.ANDROID);
186
+ const downloadCmd = initialBuild ? `${getBuildSummary(initialBuild).cmd}` : "";
187
+ const templateVars = {
188
+ downloadCmd,
189
+ dashboardURL: new URL(`/games/${getShortUUID(gameId)}/builds`, WEB_URL).toString()
190
+ };
191
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
192
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
193
+ /* @__PURE__ */ jsx(Text, { bold: true, children: isFetching ? "Checking..." : "ShipThis has not detected your game in Google Play. Press R to test again." }),
194
+ isFetching && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
195
+ ] }),
196
+ /* @__PURE__ */ jsx(Markdown, { filename: "create-google-play-game.md", templateVars })
197
+ ] }) });
198
+ };
199
+
200
+ const Command = ({ children, command }) => {
201
+ const width = Math.min(160, process.stdout.columns || 80);
202
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommandProvider, { command, children: /* @__PURE__ */ jsx(Box, { width, flexDirection: "column", children }) }) });
203
+ };
204
+
205
+ export { Command as C, GameProvider as G, Markdown as M, getBuildSummary as a, GameContext as b, CommandContext as c, useBuilds as d, CreateGooglePlayGame as e, getJobSummary as g, queryBuilds as q, useJob as u };
@@ -0,0 +1,204 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { Text, useInput, Box } from 'ink';
3
+ import React, { useState, useEffect, useContext, useRef } from 'react';
4
+ import Spinner from 'ink-spinner';
5
+ import open from 'open';
6
+ import { g as getShortUUID, h as getPlatformName, s as scriptDir } from './index-BQnkBr1Q.js';
7
+ import { c as cacheKeys, u as useAndroidServiceAccountTestResult, K as KeyTestStatus, a as KeyTestError } from './useAndroidServiceAccountTestResult-BDc7XpKE.js';
8
+ import { p as getAuthedHeaders, q as API_URL, K as castArrayObjectDates, P as Platform, a6 as getShortDateTime, a5 as getJob, J as JobStatus, a7 as getShortTimeDelta, H as getProject, a2 as getShortAuthRequiredUrl, $ as queryClient, X as WEB_URL } from './index-Bv3x8c78.js';
9
+ import '@inkjs/ui';
10
+ import axios from 'axios';
11
+ import { useQuery, QueryClientProvider } from '@tanstack/react-query';
12
+ import { setOptions, parse } from 'marked';
13
+ import fs__default from 'fs';
14
+ import TerminalRenderer from 'marked-terminal';
15
+ import path from 'path';
16
+ import 'qrcode';
17
+ import 'string-length';
18
+ import 'strip-ansi';
19
+ import 'luxon';
20
+ import 'uuid';
21
+ import 'fast-glob';
22
+ import 'yazl';
23
+ import 'socket.io-client';
24
+ import 'crypto';
25
+ import 'readline-sync';
26
+ import 'node:readline';
27
+ import 'node:path';
28
+ import 'node:url';
29
+ import 'crypto-js';
30
+ import 'isomorphic-git';
31
+ import '@oclif/core';
32
+
33
+ async function queryBuilds({ projectId, ...pageAndSortParams }) {
34
+ try {
35
+ const headers = getAuthedHeaders();
36
+ const url = `${API_URL}/projects/${projectId}/builds`;
37
+ const response = await axios.get(url, { headers, params: pageAndSortParams });
38
+ return {
39
+ ...response.data,
40
+ data: castArrayObjectDates(response.data.data)
41
+ };
42
+ } catch (error) {
43
+ console.warn("queryBuilds Error", error);
44
+ throw error;
45
+ }
46
+ }
47
+ function getBuildSummary(build) {
48
+ const filename = build.platform == Platform.IOS ? "output.ipa" : "output.aab";
49
+ return {
50
+ id: getShortUUID(build.id),
51
+ ...getJobDetailsSummary(build.jobDetails),
52
+ platform: getPlatformName(build.platform),
53
+ jobId: getShortUUID(build.jobId),
54
+ createdAt: getShortDateTime(build.createdAt),
55
+ cmd: `shipthis game build download ${getShortUUID(build.id)} ${filename}`
56
+ };
57
+ }
58
+ const useBuilds = (props) => {
59
+ const queryResult = useQuery({
60
+ queryKey: cacheKeys.builds(props),
61
+ queryFn: async () => queryBuilds(props)
62
+ });
63
+ return queryResult;
64
+ };
65
+
66
+ function getJobDetailsSummary(jobDetails) {
67
+ const semanticVersion = jobDetails?.semanticVersion || "N/A";
68
+ const buildNumber = jobDetails?.buildNumber || "N/A";
69
+ const gitCommit = jobDetails?.gitCommitHash ? getShortUUID(jobDetails?.gitCommitHash) : "N/A";
70
+ const gitBranch = jobDetails?.gitBranch || "N/A";
71
+ return {
72
+ version: `${semanticVersion} (${buildNumber})`,
73
+ gitInfo: `${gitCommit} (${gitBranch})`
74
+ };
75
+ }
76
+ function getJobSummary(job, timeNow) {
77
+ const inProgress = ![JobStatus.COMPLETED, JobStatus.FAILED].includes(job.status);
78
+ return {
79
+ id: getShortUUID(job.id),
80
+ ...getJobDetailsSummary(job.details),
81
+ platform: getPlatformName(job.type),
82
+ status: job.status,
83
+ createdAt: getShortDateTime(job.createdAt),
84
+ runtime: getShortTimeDelta(job.createdAt, inProgress ? timeNow : job.updatedAt)
85
+ };
86
+ }
87
+ const useJob = (props) => {
88
+ return useQuery({
89
+ queryKey: cacheKeys.job(props),
90
+ queryFn: () => getJob(props.jobId, props.projectId)
91
+ });
92
+ };
93
+
94
+ const CommandContext = React.createContext({
95
+ command: null,
96
+ setCommand: (command) => {
97
+ }
98
+ });
99
+ const CommandProvider = (props) => {
100
+ const [command, setCommand] = useState(props.command || null);
101
+ return /* @__PURE__ */ jsx(CommandContext.Provider, { value: { command, setCommand }, children: props.children });
102
+ };
103
+
104
+ const GameContext = React.createContext({
105
+ gameId: null,
106
+ game: null,
107
+ setGameId: (gameId) => {
108
+ }
109
+ });
110
+ const GameProvider = ({ children }) => {
111
+ const [gameId, setGameId] = useState(null);
112
+ const [game, setGame] = useState(null);
113
+ const { command } = React.useContext(CommandContext);
114
+ const handleLoad = async () => {
115
+ if (command) {
116
+ const commandGameId = await command.getGameId();
117
+ if (commandGameId) setGameId(commandGameId);
118
+ }
119
+ };
120
+ const handleGameIdChange = async () => {
121
+ if (!gameId) {
122
+ setGame(null);
123
+ return;
124
+ }
125
+ const game2 = await getProject(gameId);
126
+ setGame(game2);
127
+ };
128
+ useEffect(() => {
129
+ handleGameIdChange();
130
+ }, [gameId]);
131
+ useEffect(() => {
132
+ handleLoad();
133
+ }, [command]);
134
+ return /* @__PURE__ */ jsx(GameContext.Provider, { value: { gameId, game, setGameId }, children });
135
+ };
136
+
137
+ const entrypointPath = fs__default.realpathSync(process.argv[1]);
138
+ const root = path.dirname(entrypointPath);
139
+ const Markdown = ({ filename, templateVars, ...options }) => {
140
+ setOptions({ renderer: new TerminalRenderer(options) });
141
+ const mdPath = path.join(root, "..", "assets", "markdown", filename);
142
+ const mdTemplate = fs__default.readFileSync(mdPath, "utf8").trim();
143
+ const markdown = !templateVars ? mdTemplate : mdTemplate.replace(/\${(.*?)}/g, (_, key) => templateVars[key.trim()] || "");
144
+ return /* @__PURE__ */ jsx(Text, { children: parse(markdown).trim() });
145
+ };
146
+
147
+ scriptDir(import.meta);
148
+ const getIsAppFound = (result) => {
149
+ const isFound = result?.status === KeyTestStatus.SUCCESS || result?.status === KeyTestStatus.ERROR && result?.error === KeyTestError.NOT_INVITED;
150
+ return isFound;
151
+ };
152
+ const CreateGooglePlayGame = (props) => {
153
+ const { gameId } = useContext(GameContext);
154
+ return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(Create, { gameId, ...props }) });
155
+ };
156
+ const Create = ({ onComplete, onError, gameId, ...boxProps }) => {
157
+ const { data: result, isFetching } = useAndroidServiceAccountTestResult({ projectId: gameId });
158
+ const { data: builds } = useBuilds({ projectId: gameId, pageNumber: 0 });
159
+ const previousIsFound = useRef(false);
160
+ useEffect(() => {
161
+ const isFound = getIsAppFound(result);
162
+ if (previousIsFound.current === false && isFound) {
163
+ onComplete();
164
+ }
165
+ previousIsFound.current = isFound;
166
+ }, [result]);
167
+ useInput(async (input) => {
168
+ if (!gameId) return;
169
+ switch (input) {
170
+ case "r":
171
+ queryClient.invalidateQueries({
172
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
173
+ });
174
+ break;
175
+ case "d":
176
+ const dashUrl = await getShortAuthRequiredUrl(`/games/${getShortUUID(gameId)}/builds`);
177
+ await open(dashUrl);
178
+ }
179
+ if (input !== "r") return;
180
+ queryClient.invalidateQueries({
181
+ queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
182
+ });
183
+ });
184
+ const initialBuild = builds?.data.find((build) => build.platform === Platform.ANDROID);
185
+ const downloadCmd = initialBuild ? `${getBuildSummary(initialBuild).cmd}` : "";
186
+ const templateVars = {
187
+ downloadCmd,
188
+ dashboardURL: new URL(`/games/${getShortUUID(gameId)}/builds`, WEB_URL).toString()
189
+ };
190
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
191
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
192
+ /* @__PURE__ */ jsx(Text, { bold: true, children: isFetching ? "Checking..." : "ShipThis has not detected your game in Google Play. Press R to test again." }),
193
+ isFetching && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
194
+ ] }),
195
+ /* @__PURE__ */ jsx(Markdown, { filename: "create-google-play-game.md", templateVars })
196
+ ] }) });
197
+ };
198
+
199
+ const Command = ({ children, command }) => {
200
+ const width = Math.min(160, process.stdout.columns || 80);
201
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommandProvider, { command, children: /* @__PURE__ */ jsx(Box, { width, flexDirection: "column", children }) }) });
202
+ };
203
+
204
+ export { Command as C, GameProvider as G, Markdown as M, getBuildSummary as a, GameContext as b, CommandContext as c, useBuilds as d, CreateGooglePlayGame as e, getJobSummary as g, queryBuilds as q, useJob as u };
@@ -0,0 +1,8 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { C as Command, G as GameProvider } from './Command-BiB9MqbJ.js';
3
+
4
+ const CommandGame = ({ children, command }) => {
5
+ return /* @__PURE__ */ jsx(Command, { command, children: /* @__PURE__ */ jsx(GameProvider, { children }) });
6
+ };
7
+
8
+ export { CommandGame as C };
@@ -0,0 +1,8 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { C as Command, G as GameProvider } from './Command-D6rWEZRM.js';
3
+
4
+ const CommandGame = ({ children, command }) => {
5
+ return /* @__PURE__ */ jsx(Command, { command, children: /* @__PURE__ */ jsx(GameProvider, { children }) });
6
+ };
7
+
8
+ export { CommandGame as C };
@@ -0,0 +1,8 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { C as Command, G as GameProvider } from './Command-Dn0P_KOV.js';
3
+
4
+ const CommandGame = ({ children, command }) => {
5
+ return /* @__PURE__ */ jsx(Command, { command, children: /* @__PURE__ */ jsx(GameProvider, { children }) });
6
+ };
7
+
8
+ export { CommandGame as C };
@@ -0,0 +1,8 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { C as Command, G as GameProvider } from './Command-YJJp90ru.js';
3
+
4
+ const CommandGame = ({ children, command }) => {
5
+ return /* @__PURE__ */ jsx(Command, { command, children: /* @__PURE__ */ jsx(GameProvider, { children }) });
6
+ };
7
+
8
+ export { CommandGame as C };