shipthis 0.1.11 → 0.1.12

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 (115) hide show
  1. package/npm-shrinkwrap.json +2 -2
  2. package/oclif.manifest.json +1 -83
  3. package/package.json +1 -1
  4. package/dist/AppleBundleIdDetails-C0XqjxKJ.js +0 -72
  5. package/dist/AppleBundleIdDetails-CjP5y0cj.js +0 -74
  6. package/dist/AppleBundleIdDetails-CztWY_mT.js +0 -73
  7. package/dist/AppleBundleIdDetails-DKeSAte9.js +0 -73
  8. package/dist/AppleBundleIdDetails-Df30MPFC.js +0 -73
  9. package/dist/AppleBundleIdDetails-Dxo99Sgu.js +0 -72
  10. package/dist/Command-1YAl_0zS.js +0 -204
  11. package/dist/Command-Cl-JfhTy.js +0 -203
  12. package/dist/Command-D6rWEZRM.js +0 -204
  13. package/dist/Command-Dn0P_KOV.js +0 -205
  14. package/dist/Command-DxmQn3XT.js +0 -204
  15. package/dist/Command-YJJp90ru.js +0 -204
  16. package/dist/CommandGame--SAa3wEL.js +0 -8
  17. package/dist/CommandGame-CZUx_VQu.js +0 -8
  18. package/dist/CommandGame-DspVLTPZ.js +0 -8
  19. package/dist/CommandGame-cPaTk1wh.js +0 -8
  20. package/dist/CommandGame-k04mHiDl.js +0 -8
  21. package/dist/CommandGame-pI9VXKxi.js +0 -8
  22. package/dist/CreateKeystore-BnNdeDUa.js +0 -57
  23. package/dist/CreateKeystore-BqJdpvsI.js +0 -56
  24. package/dist/CreateKeystore-Cf-nsK_M.js +0 -56
  25. package/dist/CreateKeystore-D8uTRamD.js +0 -56
  26. package/dist/CreateKeystore-Dm0KVh85.js +0 -56
  27. package/dist/CreateKeystore-g1z6DsU5.js +0 -56
  28. package/dist/JobProgress-CPkWVSlH.js +0 -108
  29. package/dist/JobProgress-Dk0UoNah.js +0 -108
  30. package/dist/JobProgress-biiLhigg.js +0 -109
  31. package/dist/JobProgress-jmGAzvxS.js +0 -108
  32. package/dist/JobStatusTable-BA_q-kgE.js +0 -75
  33. package/dist/JobStatusTable-ByW0bN6c.js +0 -75
  34. package/dist/JobStatusTable-CgaTS7jS.js +0 -75
  35. package/dist/JobStatusTable-q4atKzhu.js +0 -75
  36. package/dist/ProjectCredentialsTable-BIWBAXCh.js +0 -37
  37. package/dist/ProjectCredentialsTable-Ch8022rs.js +0 -37
  38. package/dist/ProjectCredentialsTable-DRMK_SNw.js +0 -37
  39. package/dist/ProjectCredentialsTable-DfkpvTf8.js +0 -37
  40. package/dist/UserCredentialsTable-CeJS3_hd.js +0 -82
  41. package/dist/UserCredentialsTable-DMh8Wpy7.js +0 -82
  42. package/dist/UserCredentialsTable-DgHZJSHG.js +0 -82
  43. package/dist/UserCredentialsTable-ysmM5dlV.js +0 -82
  44. package/dist/baseAppleCommand-1isaFxCQ.js +0 -10
  45. package/dist/baseAppleCommand-B3WQtlx-.js +0 -10
  46. package/dist/baseAppleCommand-D-G4h8zQ.js +0 -10
  47. package/dist/baseAppleCommand-DpasCbje.js +0 -10
  48. package/dist/baseGameAndroidCommand-B-CFhPnE.js +0 -43
  49. package/dist/baseGameAndroidCommand-B3LRG701.js +0 -43
  50. package/dist/baseGameAndroidCommand-C9BuS2Sr.js +0 -43
  51. package/dist/baseGameAndroidCommand-DD0H8iy-.js +0 -43
  52. package/dist/commands/game/android/wizard.js +0 -509
  53. package/dist/export-BDxGDZdh.js +0 -36
  54. package/dist/export-B_F6vXIK.js +0 -36
  55. package/dist/export-BiLHgSJ9.js +0 -36
  56. package/dist/export-C_lu1FD9.js +0 -36
  57. package/dist/import-7T3J63j2.js +0 -38
  58. package/dist/import-Brg3zYmT.js +0 -38
  59. package/dist/import-BrlJuE2Z.js +0 -38
  60. package/dist/import-CxNikF1c.js +0 -38
  61. package/dist/import-DPbg8WvS.js +0 -38
  62. package/dist/index-B5XHQfs2.js +0 -122
  63. package/dist/index-B6V7vGOj.js +0 -136
  64. package/dist/index-BDFKyTPb.js +0 -24
  65. package/dist/index-BL-1G60K.js +0 -135
  66. package/dist/index-BQRxiyqn.js +0 -693
  67. package/dist/index-BQnkBr1Q.js +0 -136
  68. package/dist/index-BX9h2vPV.js +0 -123
  69. package/dist/index-BjGSEqP5.js +0 -135
  70. package/dist/index-BuZmCvZh.js +0 -24
  71. package/dist/index-Bv3x8c78.js +0 -693
  72. package/dist/index-ByOvCs4O.js +0 -122
  73. package/dist/index-BzffuqPa.js +0 -24
  74. package/dist/index-C9734Cj2.js +0 -693
  75. package/dist/index-CKYExssR.js +0 -136
  76. package/dist/index-CgBgZUkL.js +0 -144
  77. package/dist/index-DBrQda8r.js +0 -122
  78. package/dist/index-DE2Hvx2o.js +0 -122
  79. package/dist/index-DdABTtYO.js +0 -693
  80. package/dist/index-DgbQBx6x.js +0 -122
  81. package/dist/index-DxHPjZav.js +0 -136
  82. package/dist/index-X__XH_Fd.js +0 -144
  83. package/dist/index-m4HTrJ5J.js +0 -135
  84. package/dist/index-wyPoxiTc.js +0 -136
  85. package/dist/upload-CMo3hUhl.js +0 -60
  86. package/dist/upload-Cx71802W.js +0 -60
  87. package/dist/upload-DvAE1vDq.js +0 -60
  88. package/dist/upload-LXRr4pMa.js +0 -60
  89. package/dist/useAndroidServiceAccountTestResult-BDc7XpKE.js +0 -52
  90. package/dist/useAndroidServiceAccountTestResult-B_ekRewZ.js +0 -52
  91. package/dist/useAndroidServiceAccountTestResult-D_30xIJA.js +0 -52
  92. package/dist/useAndroidServiceAccountTestResult-InDf5WSl.js +0 -52
  93. package/dist/useAppleApp-CApC0-4Q.js +0 -32
  94. package/dist/useAppleApp-CETIcsJS.js +0 -32
  95. package/dist/useAppleApp-DgE0wEaq.js +0 -32
  96. package/dist/useAppleApp-DnSjUfSs.js +0 -32
  97. package/dist/useAppleBundleId-BNI8swhC.js +0 -64
  98. package/dist/useAppleBundleId-DtLODy3p.js +0 -64
  99. package/dist/useAppleBundleId-SmzY6rkm.js +0 -64
  100. package/dist/useAppleBundleId-gPBzJwQg.js +0 -64
  101. package/dist/useJobWatching-BIG6fnTN.js +0 -45
  102. package/dist/useJobWatching-BcBJ5dy1.js +0 -43
  103. package/dist/useJobWatching-Bz1e6xOv.js +0 -43
  104. package/dist/useJobWatching-Cp-CYd90.js +0 -45
  105. package/dist/useJobWatching-D-YzSlK8.js +0 -45
  106. package/dist/useJobWatching-P5oC7mNB.js +0 -45
  107. package/dist/useProjectCredentials-B5ZmpIxL.js +0 -54
  108. package/dist/useProjectCredentials-BRffcsO3.js +0 -54
  109. package/dist/useProjectCredentials-CKngz2rd.js +0 -54
  110. package/dist/useProjectCredentials-EapDge1I.js +0 -54
  111. package/dist/useWebSocket-Bep1zAVG.js +0 -36
  112. package/dist/useWebSocket-D8PojLtx.js +0 -36
  113. package/dist/useWebSocket-DoImIdTy.js +0 -36
  114. package/dist/useWebSocket-rBLiZsKb.js +0 -36
  115. package/dist/wizard-ChPegnMW.js +0 -133
@@ -1,204 +0,0 @@
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, j as getPlatformName, s as scriptDir } from './index-B6V7vGOj.js';
7
- import { c as cacheKeys, u as useAndroidServiceAccountTestResult, K as KeyTestStatus, a as KeyTestError } from './useAndroidServiceAccountTestResult-D_30xIJA.js';
8
- import { P as Platform, a5 as getShortDateTime, p as getAuthedHeaders, q as API_URL, J as castArrayObjectDates, K as JobStatus, a6 as getShortTimeDelta, a4 as getJob, H as getProject, a1 as getShortAuthRequiredUrl, a7 as queryClient, Z as WEB_URL } from './index-BQRxiyqn.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, GameContext as a, useBuilds as b, getBuildSummary as c, CommandContext as d, CreateGooglePlayGame as e, getJobSummary as g, queryBuilds as q, useJob as u };
@@ -1,203 +0,0 @@
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, j as getPlatformName, s as scriptDir } from './index-B6V7vGOj.js';
7
- import { c as cacheKeys, u as useAndroidServiceAccountTestResult, K as KeyTestStatus, a as KeyTestError } from './useAndroidServiceAccountTestResult-D_30xIJA.js';
8
- import { P as Platform, a5 as getShortDateTime, p as getAuthedHeaders, q as API_URL, J as castArrayObjectDates, K as JobStatus, a6 as getShortTimeDelta, a4 as getJob, H as getProject, a1 as getShortAuthRequiredUrl, a7 as queryClient, Z as WEB_URL } from './index-BQRxiyqn.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 root = path.dirname(process.argv[1]);
138
- const Markdown = ({ filename, templateVars, ...options }) => {
139
- setOptions({ renderer: new TerminalRenderer(options) });
140
- const mdPath = path.join(root, "..", "assets", "markdown", filename);
141
- const mdTemplate = fs__default.readFileSync(mdPath, "utf8").trim();
142
- const markdown = !templateVars ? mdTemplate : mdTemplate.replace(/\${(.*?)}/g, (_, key) => templateVars[key.trim()] || "");
143
- return /* @__PURE__ */ jsx(Text, { children: parse(markdown).trim() });
144
- };
145
-
146
- scriptDir(import.meta);
147
- const getIsAppFound = (result) => {
148
- const isFound = result?.status === KeyTestStatus.SUCCESS || result?.status === KeyTestStatus.ERROR && result?.error === KeyTestError.NOT_INVITED;
149
- return isFound;
150
- };
151
- const CreateGooglePlayGame = (props) => {
152
- const { gameId } = useContext(GameContext);
153
- return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(Create, { gameId, ...props }) });
154
- };
155
- const Create = ({ onComplete, onError, gameId, ...boxProps }) => {
156
- const { data: result, isFetching } = useAndroidServiceAccountTestResult({ projectId: gameId });
157
- const { data: builds } = useBuilds({ projectId: gameId, pageNumber: 0 });
158
- const previousIsFound = useRef(false);
159
- useEffect(() => {
160
- const isFound = getIsAppFound(result);
161
- if (previousIsFound.current === false && isFound) {
162
- onComplete();
163
- }
164
- previousIsFound.current = isFound;
165
- }, [result]);
166
- useInput(async (input) => {
167
- if (!gameId) return;
168
- switch (input) {
169
- case "r":
170
- queryClient.invalidateQueries({
171
- queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
172
- });
173
- break;
174
- case "d":
175
- const dashUrl = await getShortAuthRequiredUrl(`/games/${getShortUUID(gameId)}/builds`);
176
- await open(dashUrl);
177
- }
178
- if (input !== "r") return;
179
- queryClient.invalidateQueries({
180
- queryKey: cacheKeys.androidKeyTestResult({ projectId: gameId })
181
- });
182
- });
183
- const initialBuild = builds?.data.find((build) => build.platform === Platform.ANDROID);
184
- const downloadCmd = initialBuild ? `${getBuildSummary(initialBuild).cmd}` : "";
185
- const templateVars = {
186
- downloadCmd,
187
- dashboardURL: new URL(`/games/${getShortUUID(gameId)}/builds`, WEB_URL).toString()
188
- };
189
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
190
- /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
191
- /* @__PURE__ */ jsx(Text, { bold: true, children: isFetching ? "Checking..." : "ShipThis has not detected your game in Google Play. Press R to test again." }),
192
- isFetching && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
193
- ] }),
194
- /* @__PURE__ */ jsx(Markdown, { filename: "create-google-play-game.md", templateVars })
195
- ] }) });
196
- };
197
-
198
- const Command = ({ children, command }) => {
199
- const width = Math.min(160, process.stdout.columns || 80);
200
- return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommandProvider, { command, children: /* @__PURE__ */ jsx(Box, { width, flexDirection: "column", children }) }) });
201
- };
202
-
203
- export { Command as C, GameProvider as G, Markdown as M, GameContext as a, useBuilds as b, getBuildSummary as c, CommandContext as d, CreateGooglePlayGame as e, getJobSummary as g, queryBuilds as q, useJob as u };
@@ -1,204 +0,0 @@
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 };