shipthis 0.1.11 → 0.1.13
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.
- package/assets/markdown/ship-failure.md +13 -0
- package/assets/markdown/ship-success.md +12 -0
- package/dist/{AppleBundleIdDetails-DymjrhOZ.js → AppleBundleIdDetails-DxWVnxa5.js} +4 -4
- package/dist/{Command-1YAl_0zS.js → Command-zfJ7qIJI.js} +8 -8
- package/dist/{CommandGame--SAa3wEL.js → CommandGame-DVsNreSF.js} +1 -1
- package/dist/{Create-DIaSKUpl.js → Create-DdF29mIS.js} +3 -3
- package/dist/{Import-BIOsf8AA.js → Import-D8ik724M.js} +4 -4
- package/dist/{JobProgress-biiLhigg.js → JobProgress-D1Pe4YJc.js} +10 -7
- package/dist/JobStatusTable-D-daiV-I.js +203 -0
- package/dist/{ProjectCredentialsTable-Ch8022rs.js → ProjectCredentialsTable-Ch2s5qF1.js} +2 -2
- package/dist/{UserCredentialsTable-CeJS3_hd.js → UserCredentialsTable-DzyAHhLB.js} +3 -3
- package/dist/{baseAppleCommand-1isaFxCQ.js → baseAppleCommand-BGXyWK-R.js} +1 -1
- package/dist/{baseGameAndroidCommand-6vsMpE7a.js → baseGameAndroidCommand-mdFhxanf.js} +2 -2
- package/dist/commands/apple/apiKey/create.js +7 -7
- package/dist/commands/apple/apiKey/export.js +6 -6
- package/dist/commands/apple/apiKey/import.js +6 -6
- package/dist/commands/apple/apiKey/status.js +5 -5
- package/dist/commands/apple/certificate/create.js +7 -7
- package/dist/commands/apple/certificate/export.js +6 -6
- package/dist/commands/apple/certificate/import.js +6 -6
- package/dist/commands/apple/certificate/status.js +5 -5
- package/dist/commands/apple/login.js +2 -2
- package/dist/commands/apple/status.js +4 -4
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/game/android/apiKey/connect.js +9 -9
- package/dist/commands/game/android/apiKey/create.js +10 -10
- package/dist/commands/game/android/apiKey/export.js +7 -7
- package/dist/commands/game/android/apiKey/import.js +9 -9
- package/dist/commands/game/android/apiKey/invite.js +4 -4
- package/dist/commands/game/android/apiKey/status.js +7 -7
- package/dist/commands/game/android/keyStore/create.js +8 -8
- package/dist/commands/game/android/keyStore/export.js +6 -6
- package/dist/commands/game/android/keyStore/import.js +9 -9
- package/dist/commands/game/android/keyStore/status.js +6 -6
- package/dist/commands/game/android/status.js +4 -4
- package/dist/commands/game/build/download.js +4 -4
- package/dist/commands/game/build/list.js +5 -5
- package/dist/commands/game/create.js +2 -2
- package/dist/commands/game/details.js +4 -4
- package/dist/commands/game/export.js +1 -1
- package/dist/commands/game/ios/app/addTester.js +5 -5
- package/dist/commands/game/ios/app/create.js +4 -4
- package/dist/commands/game/ios/app/status.js +7 -7
- package/dist/commands/game/ios/app/sync.js +5 -5
- package/dist/commands/game/ios/profile/create.js +7 -7
- package/dist/commands/game/ios/profile/export.js +6 -6
- package/dist/commands/game/ios/profile/import.js +6 -6
- package/dist/commands/game/ios/profile/status.js +6 -6
- package/dist/commands/game/ios/status.js +7 -7
- package/dist/commands/game/ios/wizard.js +2 -2
- package/dist/commands/game/job/list.js +4 -4
- package/dist/commands/game/job/status.js +17 -131
- package/dist/commands/game/list.js +4 -4
- package/dist/commands/game/ship.js +74 -19
- package/dist/commands/game/status.js +4 -4
- package/dist/commands/game/wizard.js +14 -14
- package/dist/commands/internal/fastlane.js +1 -1
- package/dist/commands/internal/readme.js +1 -1
- package/dist/commands/login.js +2 -2
- package/dist/commands/status.js +4 -4
- package/dist/{export-BDxGDZdh.js → export-Cin4rLWR.js} +1 -1
- package/dist/{import-v54PM_Qg.js → import-CXTv9E84.js} +1 -1
- package/dist/{index-BDFKyTPb.js → index-B4v66AKo.js} +1 -1
- package/dist/{index-ByOvCs4O.js → index-BVvcTBnj.js} +4 -4
- package/dist/{index-m4HTrJ5J.js → index-Cx_2qTdS.js} +7 -7
- package/dist/{index-BB7X1Pqp.js → index-Dhx6FAHt.js} +1 -1
- package/dist/{index-wyPoxiTc.js → index-Dj-chiHz.js} +2 -2
- package/dist/{upload-2naN75Zu.js → upload-DZCIfnwf.js} +1 -1
- package/dist/{useAndroidServiceAccountTestResult-BDc7XpKE.js → useAndroidServiceAccountTestResult-L4oozjag.js} +1 -1
- package/dist/{useAppleApp-DgE0wEaq.js → useAppleApp-DcSr-q-w.js} +1 -1
- package/dist/{useAppleBundleId-BNI8swhC.js → useAppleBundleId-BnJVPVIz.js} +1 -1
- package/dist/{useJobWatching-BIG6fnTN.js → useJobWatching-DS0qHqPA.js} +3 -3
- package/dist/{useProjectCredentials-B5ZmpIxL.js → useProjectCredentials-CI_AoXmH.js} +3 -3
- package/dist/{useWebSocket-Bep1zAVG.js → useWebSocket-ZEZvtpT_.js} +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/oclif.manifest.json +141 -223
- package/package.json +1 -1
- package/dist/AppleBundleIdDetails-C0XqjxKJ.js +0 -72
- package/dist/AppleBundleIdDetails-CjP5y0cj.js +0 -74
- package/dist/AppleBundleIdDetails-CztWY_mT.js +0 -73
- package/dist/AppleBundleIdDetails-DKeSAte9.js +0 -73
- package/dist/AppleBundleIdDetails-Df30MPFC.js +0 -73
- package/dist/AppleBundleIdDetails-Dxo99Sgu.js +0 -72
- package/dist/Command-BiB9MqbJ.js +0 -204
- package/dist/Command-Cl-JfhTy.js +0 -203
- package/dist/Command-D6rWEZRM.js +0 -204
- package/dist/Command-Dn0P_KOV.js +0 -205
- package/dist/Command-DxmQn3XT.js +0 -204
- package/dist/Command-YJJp90ru.js +0 -204
- package/dist/CommandGame-C1oTlfdb.js +0 -8
- package/dist/CommandGame-CZUx_VQu.js +0 -8
- package/dist/CommandGame-DspVLTPZ.js +0 -8
- package/dist/CommandGame-cPaTk1wh.js +0 -8
- package/dist/CommandGame-k04mHiDl.js +0 -8
- package/dist/CommandGame-pI9VXKxi.js +0 -8
- package/dist/CreateKeystore-BnNdeDUa.js +0 -57
- package/dist/CreateKeystore-BqJdpvsI.js +0 -56
- package/dist/CreateKeystore-Cf-nsK_M.js +0 -56
- package/dist/CreateKeystore-D8uTRamD.js +0 -56
- package/dist/CreateKeystore-Dm0KVh85.js +0 -56
- package/dist/CreateKeystore-g1z6DsU5.js +0 -56
- package/dist/JobProgress-CPkWVSlH.js +0 -108
- package/dist/JobProgress-Dk0UoNah.js +0 -108
- package/dist/JobProgress-W0QQR49T.js +0 -108
- package/dist/JobProgress-jmGAzvxS.js +0 -108
- package/dist/JobStatusTable-BA_q-kgE.js +0 -75
- package/dist/JobStatusTable-ByW0bN6c.js +0 -75
- package/dist/JobStatusTable-CgaTS7jS.js +0 -75
- package/dist/JobStatusTable-DqoppRro.js +0 -75
- package/dist/JobStatusTable-q4atKzhu.js +0 -75
- package/dist/ProjectCredentialsTable-8kXt7sTS.js +0 -37
- package/dist/ProjectCredentialsTable-BIWBAXCh.js +0 -37
- package/dist/ProjectCredentialsTable-DRMK_SNw.js +0 -37
- package/dist/ProjectCredentialsTable-DfkpvTf8.js +0 -37
- package/dist/UserCredentialsTable-DMh8Wpy7.js +0 -82
- package/dist/UserCredentialsTable-DgHZJSHG.js +0 -82
- package/dist/UserCredentialsTable-TflQvTEP.js +0 -82
- package/dist/UserCredentialsTable-ysmM5dlV.js +0 -82
- package/dist/baseAppleCommand-B3WQtlx-.js +0 -10
- package/dist/baseAppleCommand-B9wyIqdL.js +0 -10
- package/dist/baseAppleCommand-D-G4h8zQ.js +0 -10
- package/dist/baseAppleCommand-DpasCbje.js +0 -10
- package/dist/baseGameAndroidCommand-B-CFhPnE.js +0 -43
- package/dist/baseGameAndroidCommand-B3LRG701.js +0 -43
- package/dist/baseGameAndroidCommand-C9BuS2Sr.js +0 -43
- package/dist/baseGameAndroidCommand-DD0H8iy-.js +0 -43
- package/dist/commands/game/android/wizard.js +0 -509
- package/dist/export-B_F6vXIK.js +0 -36
- package/dist/export-BiLHgSJ9.js +0 -36
- package/dist/export-C_lu1FD9.js +0 -36
- package/dist/export-rS9o87LD.js +0 -36
- package/dist/import-7T3J63j2.js +0 -38
- package/dist/import-Brg3zYmT.js +0 -38
- package/dist/import-BrlJuE2Z.js +0 -38
- package/dist/import-CxNikF1c.js +0 -38
- package/dist/import-DPbg8WvS.js +0 -38
- package/dist/index-B5XHQfs2.js +0 -122
- package/dist/index-B6V7vGOj.js +0 -136
- package/dist/index-BL-1G60K.js +0 -135
- package/dist/index-BQRxiyqn.js +0 -693
- package/dist/index-BQnkBr1Q.js +0 -136
- package/dist/index-BX9h2vPV.js +0 -123
- package/dist/index-BjGSEqP5.js +0 -135
- package/dist/index-BuZmCvZh.js +0 -24
- package/dist/index-Bv3x8c78.js +0 -693
- package/dist/index-BzffuqPa.js +0 -24
- package/dist/index-C9734Cj2.js +0 -693
- package/dist/index-CKYExssR.js +0 -136
- package/dist/index-CgBgZUkL.js +0 -144
- package/dist/index-Cz_KLwWf.js +0 -136
- package/dist/index-D6BH5UAM.js +0 -135
- package/dist/index-DBrQda8r.js +0 -122
- package/dist/index-DE2Hvx2o.js +0 -122
- package/dist/index-DOgF4dFK.js +0 -24
- package/dist/index-DdABTtYO.js +0 -693
- package/dist/index-DgbQBx6x.js +0 -122
- package/dist/index-DxHPjZav.js +0 -136
- package/dist/index-X__XH_Fd.js +0 -144
- package/dist/index-o9Y-84Rj.js +0 -122
- package/dist/upload-CMo3hUhl.js +0 -60
- package/dist/upload-Cx71802W.js +0 -60
- package/dist/upload-DvAE1vDq.js +0 -60
- package/dist/upload-LXRr4pMa.js +0 -60
- package/dist/useAndroidServiceAccountTestResult-B_ekRewZ.js +0 -52
- package/dist/useAndroidServiceAccountTestResult-Ce1x0Eh8.js +0 -52
- package/dist/useAndroidServiceAccountTestResult-D_30xIJA.js +0 -52
- package/dist/useAndroidServiceAccountTestResult-InDf5WSl.js +0 -52
- package/dist/useAppleApp-BEtLQa7n.js +0 -32
- package/dist/useAppleApp-CApC0-4Q.js +0 -32
- package/dist/useAppleApp-CETIcsJS.js +0 -32
- package/dist/useAppleApp-DnSjUfSs.js +0 -32
- package/dist/useAppleBundleId-DXbMDRLd.js +0 -64
- package/dist/useAppleBundleId-DtLODy3p.js +0 -64
- package/dist/useAppleBundleId-SmzY6rkm.js +0 -64
- package/dist/useAppleBundleId-gPBzJwQg.js +0 -64
- package/dist/useJobWatching-BcBJ5dy1.js +0 -43
- package/dist/useJobWatching-Bz1e6xOv.js +0 -43
- package/dist/useJobWatching-Cp-CYd90.js +0 -45
- package/dist/useJobWatching-D-YzSlK8.js +0 -45
- package/dist/useJobWatching-I_A3b36f.js +0 -45
- package/dist/useJobWatching-P5oC7mNB.js +0 -45
- package/dist/useProjectCredentials-BRffcsO3.js +0 -54
- package/dist/useProjectCredentials-CKngz2rd.js +0 -54
- package/dist/useProjectCredentials-EapDge1I.js +0 -54
- package/dist/useProjectCredentials-vjedBbKl.js +0 -54
- package/dist/useWebSocket-CBqsjHbt.js +0 -36
- package/dist/useWebSocket-D8PojLtx.js +0 -36
- package/dist/useWebSocket-DoImIdTy.js +0 -36
- package/dist/useWebSocket-rBLiZsKb.js +0 -36
- package/dist/wizard-ChPegnMW.js +0 -133
package/dist/index-CKYExssR.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { useState, useRef, useEffect, useContext } from 'react';
|
|
4
|
-
import Spinner from 'ink-spinner';
|
|
5
|
-
import { b as GameContext } from './Command-Dn0P_KOV.js';
|
|
6
|
-
import { o as getAuthedHeaders, p as API_URL, F as castObjectDates, P as Platform, C as CredentialsType, Q as getGoogleStatus } from './index-C9734Cj2.js';
|
|
7
|
-
import axios from 'axios';
|
|
8
|
-
import 'crypto-js';
|
|
9
|
-
import 'uuid';
|
|
10
|
-
import 'luxon';
|
|
11
|
-
import 'fs';
|
|
12
|
-
import '@inkjs/ui';
|
|
13
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
14
|
-
import 'open';
|
|
15
|
-
import 'crypto';
|
|
16
|
-
import 'readline-sync';
|
|
17
|
-
import 'node:readline';
|
|
18
|
-
import 'node:path';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import { c as cacheKeys } from './useAndroidServiceAccountTestResult-B_ekRewZ.js';
|
|
21
|
-
import 'fast-glob';
|
|
22
|
-
import 'yazl';
|
|
23
|
-
import 'socket.io-client';
|
|
24
|
-
import 'isomorphic-git';
|
|
25
|
-
import '@oclif/core';
|
|
26
|
-
import { u as useWebSocket } from './useWebSocket-Bep1zAVG.js';
|
|
27
|
-
import { u as useProjectCredentials } from './useProjectCredentials-EapDge1I.js';
|
|
28
|
-
import { P as ProgressSpinner } from './ProgressSpinner-6pw1T8Iw.js';
|
|
29
|
-
import 'qrcode';
|
|
30
|
-
import 'string-length';
|
|
31
|
-
import 'strip-ansi';
|
|
32
|
-
import './wizard-ChPegnMW.js';
|
|
33
|
-
|
|
34
|
-
async function fetchStatus({ projectId }) {
|
|
35
|
-
try {
|
|
36
|
-
if (!projectId) throw new Error("projectId is required");
|
|
37
|
-
const headers = getAuthedHeaders();
|
|
38
|
-
const url = `${API_URL}/projects/${projectId}/credentials/android/key/status/`;
|
|
39
|
-
const response = await axios.get(url, { headers });
|
|
40
|
-
return castObjectDates(response.data);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.warn("fetchStatus Error", error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const useAndroidServiceAccountSetupStatus = (props) => {
|
|
47
|
-
return useQuery({
|
|
48
|
-
queryKey: cacheKeys.androidSetupStatus(props),
|
|
49
|
-
queryFn: () => fetchStatus(props),
|
|
50
|
-
// Status changes frequently, so we want to keep it fresh
|
|
51
|
-
refetchInterval: 1e3 * 5,
|
|
52
|
-
staleTime: 1e3 * 5
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const ERR_NOT_AUTHENTICATED = "You must be connected to Google to create a Service Account Key";
|
|
57
|
-
const useHasServiceAccountKey = (projectId) => {
|
|
58
|
-
const { data, isSuccess } = useProjectCredentials({ projectId, platform: Platform.ANDROID });
|
|
59
|
-
return isSuccess && data.data.some((cred) => cred.isActive && cred.platform === Platform.ANDROID && cred.type == CredentialsType.KEY);
|
|
60
|
-
};
|
|
61
|
-
const useAndroidServiceAccount = ({ projectId, onError, onComplete }) => {
|
|
62
|
-
const queryClient = useQueryClient();
|
|
63
|
-
const [isStarting, setIsStarting] = useState(false);
|
|
64
|
-
const hasServiceAccountKey = useHasServiceAccountKey(projectId);
|
|
65
|
-
const listener = {
|
|
66
|
-
getPattern: () => `project.${projectId}:android-setup-status`,
|
|
67
|
-
eventHandler: async (pattern, data) => {
|
|
68
|
-
const key = cacheKeys.androidSetupStatus({ projectId });
|
|
69
|
-
queryClient.setQueryData(key, () => data);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
useWebSocket([listener]);
|
|
73
|
-
const { data: setupStatus } = useAndroidServiceAccountSetupStatus({ projectId });
|
|
74
|
-
const prevSetupStatusRef = useRef("unknown");
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
if (["running", "queued"].includes(prevSetupStatusRef.current)) {
|
|
77
|
-
if (setupStatus?.status === "complete") onComplete();
|
|
78
|
-
if (setupStatus?.status === "error") onError(new Error(setupStatus.errorMessage));
|
|
79
|
-
}
|
|
80
|
-
prevSetupStatusRef.current = setupStatus?.status || "unknown";
|
|
81
|
-
}, [setupStatus]);
|
|
82
|
-
const handleStart = async () => {
|
|
83
|
-
try {
|
|
84
|
-
setIsStarting(true);
|
|
85
|
-
const currentStatus = await getGoogleStatus();
|
|
86
|
-
if (!currentStatus.isAuthenticated) throw new Error(ERR_NOT_AUTHENTICATED);
|
|
87
|
-
const headers = getAuthedHeaders();
|
|
88
|
-
const androidKeyApiBase = `${API_URL}/projects/${projectId}/credentials/android/key`;
|
|
89
|
-
const startUrl = `${androidKeyApiBase}/setup/`;
|
|
90
|
-
const { data: updatedStatus } = await axios.post(startUrl, {}, { headers });
|
|
91
|
-
queryClient.invalidateQueries({
|
|
92
|
-
queryKey: cacheKeys.projectCredentials({ projectId, pageNumber: 0 })
|
|
93
|
-
});
|
|
94
|
-
await queryClient.setQueryData(cacheKeys.androidSetupStatus({ projectId }), (_) => updatedStatus);
|
|
95
|
-
setIsStarting(false);
|
|
96
|
-
return true;
|
|
97
|
-
} catch (error) {
|
|
98
|
-
setIsStarting(false);
|
|
99
|
-
console.warn("useAndroidServiceAccount.handleStart Error", error);
|
|
100
|
-
onError(error);
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const isCreating = isStarting || setupStatus?.status === "queued" || setupStatus?.status === "running";
|
|
105
|
-
return {
|
|
106
|
-
handleStart,
|
|
107
|
-
setupStatus,
|
|
108
|
-
isCreating,
|
|
109
|
-
hasServiceAccountKey
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const CreateServiceAccountKey = (props) => {
|
|
114
|
-
const { gameId } = useContext(GameContext);
|
|
115
|
-
return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(CreateForGame, { gameId, ...props }) });
|
|
116
|
-
};
|
|
117
|
-
const CreateForGame = ({ onComplete, onError, gameId, ...boxProps }) => {
|
|
118
|
-
const [didStart, setDidStart] = useState(false);
|
|
119
|
-
const { handleStart, setupStatus, isCreating } = useAndroidServiceAccount({
|
|
120
|
-
projectId: gameId,
|
|
121
|
-
onError,
|
|
122
|
-
onComplete
|
|
123
|
-
});
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
handleStart().then(() => setDidStart(true));
|
|
126
|
-
}, [gameId]);
|
|
127
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
|
|
128
|
-
/* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
|
|
129
|
-
/* @__PURE__ */ jsx(Text, { children: "Creating a Service Account and API Key..." }),
|
|
130
|
-
isCreating && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
|
|
131
|
-
] }),
|
|
132
|
-
didStart && /* @__PURE__ */ jsx(ProgressSpinner, { progress: (setupStatus?.progress || 0) * 100, spinnerType: "dots" })
|
|
133
|
-
] }) });
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export { CreateServiceAccountKey as C };
|
package/dist/index-CgBgZUkL.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { useState, useRef, useEffect, useContext } from 'react';
|
|
4
|
-
import Spinner from 'ink-spinner';
|
|
5
|
-
import { a as GameContext } from './Command-Cl-JfhTy.js';
|
|
6
|
-
import { p as getAuthedHeaders, q as API_URL, O as castObjectDates, P as Platform, C as CredentialsType, S as getGoogleStatus } from './index-BQRxiyqn.js';
|
|
7
|
-
import axios from 'axios';
|
|
8
|
-
import 'crypto-js';
|
|
9
|
-
import 'uuid';
|
|
10
|
-
import 'luxon';
|
|
11
|
-
import 'fs';
|
|
12
|
-
import { ProgressBar } from '@inkjs/ui';
|
|
13
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
14
|
-
import 'open';
|
|
15
|
-
import 'crypto';
|
|
16
|
-
import 'readline-sync';
|
|
17
|
-
import 'node:readline';
|
|
18
|
-
import 'node:path';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import { c as cacheKeys } from './useAndroidServiceAccountTestResult-D_30xIJA.js';
|
|
21
|
-
import 'fast-glob';
|
|
22
|
-
import 'yazl';
|
|
23
|
-
import 'socket.io-client';
|
|
24
|
-
import 'isomorphic-git';
|
|
25
|
-
import '@oclif/core';
|
|
26
|
-
import { u as useWebSocket } from './useWebSocket-DoImIdTy.js';
|
|
27
|
-
import { u as useProjectCredentials } from './useProjectCredentials-B5ZmpIxL.js';
|
|
28
|
-
import 'qrcode';
|
|
29
|
-
import 'string-length';
|
|
30
|
-
import 'strip-ansi';
|
|
31
|
-
|
|
32
|
-
async function fetchStatus({ projectId }) {
|
|
33
|
-
try {
|
|
34
|
-
if (!projectId) throw new Error("projectId is required");
|
|
35
|
-
const headers = getAuthedHeaders();
|
|
36
|
-
const url = `${API_URL}/projects/${projectId}/credentials/android/key/status/`;
|
|
37
|
-
const response = await axios.get(url, { headers });
|
|
38
|
-
return castObjectDates(response.data);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.warn("fetchStatus Error", error);
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const useAndroidServiceAccountSetupStatus = (props) => {
|
|
45
|
-
return useQuery({
|
|
46
|
-
queryKey: cacheKeys.androidSetupStatus(props),
|
|
47
|
-
queryFn: () => fetchStatus(props),
|
|
48
|
-
// Status changes frequently, so we want to keep it fresh
|
|
49
|
-
refetchInterval: 1e3 * 5,
|
|
50
|
-
staleTime: 1e3 * 5
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const ERR_NOT_AUTHENTICATED = "You must be connected to Google to create a Service Account Key";
|
|
55
|
-
const useHasServiceAccountKey = (projectId) => {
|
|
56
|
-
const { data, isSuccess } = useProjectCredentials({ projectId, platform: Platform.ANDROID });
|
|
57
|
-
return isSuccess && data.data.some((cred) => cred.isActive && cred.platform === Platform.ANDROID && cred.type == CredentialsType.KEY);
|
|
58
|
-
};
|
|
59
|
-
const useAndroidServiceAccount = ({ projectId, onError, onComplete }) => {
|
|
60
|
-
const queryClient = useQueryClient();
|
|
61
|
-
const [isStarting, setIsStarting] = useState(false);
|
|
62
|
-
const hasServiceAccountKey = useHasServiceAccountKey(projectId);
|
|
63
|
-
const listener = {
|
|
64
|
-
getPattern: () => `project.${projectId}:android-setup-status`,
|
|
65
|
-
eventHandler: async (pattern, data) => {
|
|
66
|
-
const key = cacheKeys.androidSetupStatus({ projectId });
|
|
67
|
-
queryClient.setQueryData(key, () => data);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
useWebSocket([listener]);
|
|
71
|
-
const { data: setupStatus } = useAndroidServiceAccountSetupStatus({ projectId });
|
|
72
|
-
const prevSetupStatusRef = useRef("unknown");
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (["running", "queued"].includes(prevSetupStatusRef.current)) {
|
|
75
|
-
if (setupStatus?.status === "complete") onComplete();
|
|
76
|
-
if (setupStatus?.status === "error") onError(new Error(setupStatus.errorMessage));
|
|
77
|
-
}
|
|
78
|
-
prevSetupStatusRef.current = setupStatus?.status || "unknown";
|
|
79
|
-
}, [setupStatus]);
|
|
80
|
-
const handleStart = async () => {
|
|
81
|
-
try {
|
|
82
|
-
setIsStarting(true);
|
|
83
|
-
const currentStatus = await getGoogleStatus();
|
|
84
|
-
if (!currentStatus.isAuthenticated) throw new Error(ERR_NOT_AUTHENTICATED);
|
|
85
|
-
const headers = getAuthedHeaders();
|
|
86
|
-
const androidKeyApiBase = `${API_URL}/projects/${projectId}/credentials/android/key`;
|
|
87
|
-
const startUrl = `${androidKeyApiBase}/setup/`;
|
|
88
|
-
const { data: updatedStatus } = await axios.post(startUrl, {}, { headers });
|
|
89
|
-
queryClient.invalidateQueries({
|
|
90
|
-
queryKey: cacheKeys.projectCredentials({ projectId, pageNumber: 0 })
|
|
91
|
-
});
|
|
92
|
-
await queryClient.setQueryData(cacheKeys.androidSetupStatus({ projectId }), (_) => updatedStatus);
|
|
93
|
-
setIsStarting(false);
|
|
94
|
-
return true;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
setIsStarting(false);
|
|
97
|
-
console.warn("useAndroidServiceAccount.handleStart Error", error);
|
|
98
|
-
onError(error);
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const isCreating = isStarting || setupStatus?.status === "queued" || setupStatus?.status === "running";
|
|
103
|
-
return {
|
|
104
|
-
handleStart,
|
|
105
|
-
setupStatus,
|
|
106
|
-
isCreating,
|
|
107
|
-
hasServiceAccountKey
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const ProgressSpinner = ({ progress, label, spinnerType, labelProps, boxProps }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Box, { flexDirection: "column", gap: 1, ...boxProps, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
|
|
112
|
-
label && label != "" && /* @__PURE__ */ jsx(Text, { ...labelProps, children: label }),
|
|
113
|
-
/* @__PURE__ */ jsx(ProgressBar, { value: progress || 0 }),
|
|
114
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
115
|
-
Math.floor(progress || 0),
|
|
116
|
-
"%"
|
|
117
|
-
] }),
|
|
118
|
-
/* @__PURE__ */ jsx(Spinner, { type: spinnerType })
|
|
119
|
-
] }) }) });
|
|
120
|
-
|
|
121
|
-
const CreateServiceAccountKey = (props) => {
|
|
122
|
-
const { gameId } = useContext(GameContext);
|
|
123
|
-
return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(CreateForGame, { gameId, ...props }) });
|
|
124
|
-
};
|
|
125
|
-
const CreateForGame = ({ onComplete, onError, gameId, ...boxProps }) => {
|
|
126
|
-
const [didStart, setDidStart] = useState(false);
|
|
127
|
-
const { handleStart, setupStatus, isCreating } = useAndroidServiceAccount({
|
|
128
|
-
projectId: gameId,
|
|
129
|
-
onError,
|
|
130
|
-
onComplete
|
|
131
|
-
});
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
handleStart().then(() => setDidStart(true));
|
|
134
|
-
}, [gameId]);
|
|
135
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
|
|
136
|
-
/* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
|
|
137
|
-
/* @__PURE__ */ jsx(Text, { children: "Creating a Service Account and API Key..." }),
|
|
138
|
-
isCreating && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
|
|
139
|
-
] }),
|
|
140
|
-
didStart && /* @__PURE__ */ jsx(ProgressSpinner, { progress: (setupStatus?.progress || 0) * 100, spinnerType: "dots" })
|
|
141
|
-
] }) });
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export { CreateServiceAccountKey as C, ProgressSpinner as P };
|
package/dist/index-Cz_KLwWf.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import fs__default from 'fs';
|
|
3
|
-
import readlineSync from 'readline-sync';
|
|
4
|
-
import { promises } from 'node:readline';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { P as Platform, J as JobStatus, L as JobStage, M as LogLevel } from './index-BB7X1Pqp.js';
|
|
8
|
-
import 'react';
|
|
9
|
-
import 'axios';
|
|
10
|
-
import '@tanstack/react-query';
|
|
11
|
-
import 'luxon';
|
|
12
|
-
import 'isomorphic-git';
|
|
13
|
-
import '@oclif/core';
|
|
14
|
-
import 'crypto-js';
|
|
15
|
-
import 'uuid';
|
|
16
|
-
import 'fast-glob';
|
|
17
|
-
import 'yazl';
|
|
18
|
-
import 'socket.io-client';
|
|
19
|
-
|
|
20
|
-
function getShortUUID(originalUuid) {
|
|
21
|
-
return originalUuid.slice(0, 8);
|
|
22
|
-
}
|
|
23
|
-
function getStageColor(stage) {
|
|
24
|
-
switch (stage) {
|
|
25
|
-
case JobStage.SETUP:
|
|
26
|
-
return "#FFB3B3";
|
|
27
|
-
// pastel red
|
|
28
|
-
case JobStage.CONFIGURE:
|
|
29
|
-
return "#FFD9B3";
|
|
30
|
-
// pastel orange
|
|
31
|
-
case JobStage.EXPORT:
|
|
32
|
-
return "#FFFACD";
|
|
33
|
-
// pastel yellow
|
|
34
|
-
case JobStage.BUILD:
|
|
35
|
-
return "#B3FFB3";
|
|
36
|
-
// pastel green
|
|
37
|
-
case JobStage.PUBLISH:
|
|
38
|
-
return "#B3D9FF";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function getMessageColor(level) {
|
|
42
|
-
switch (level) {
|
|
43
|
-
case LogLevel.INFO:
|
|
44
|
-
return "white";
|
|
45
|
-
case LogLevel.WARN:
|
|
46
|
-
return "yellow";
|
|
47
|
-
case LogLevel.ERROR:
|
|
48
|
-
return "red";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function getJobStatusColor(status) {
|
|
52
|
-
switch (status) {
|
|
53
|
-
case JobStatus.PENDING:
|
|
54
|
-
return "yellow";
|
|
55
|
-
case JobStatus.PROCESSING:
|
|
56
|
-
return "blue";
|
|
57
|
-
case JobStatus.COMPLETED:
|
|
58
|
-
return "green";
|
|
59
|
-
case JobStatus.FAILED:
|
|
60
|
-
return "red";
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function getFileHash(filename) {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
const hash = crypto.createHash("sha256");
|
|
66
|
-
const rs = fs__default.createReadStream(filename);
|
|
67
|
-
rs.on("error", reject);
|
|
68
|
-
rs.on("data", (chunk) => hash.update(chunk));
|
|
69
|
-
rs.on("end", () => resolve(hash.digest("hex")));
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function isValidSemVer(versionString) {
|
|
73
|
-
const [semVer, major, minor, patch, prerelease, buildmetadata] = versionString.match(
|
|
74
|
-
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
75
|
-
) ?? [];
|
|
76
|
-
return !!semVer;
|
|
77
|
-
}
|
|
78
|
-
function makeHumanReadable(rawObject) {
|
|
79
|
-
const getLabel = (key) => {
|
|
80
|
-
const words = key.split(/(?=[A-Z])/);
|
|
81
|
-
return words.map((word) => word[0].toUpperCase() + word.slice(1)).join(" ").replaceAll(" ", " ");
|
|
82
|
-
};
|
|
83
|
-
const withLabels = Object.entries(rawObject).reduce((acc, [key, value]) => {
|
|
84
|
-
acc[getLabel(key)] = value;
|
|
85
|
-
return acc;
|
|
86
|
-
}, {});
|
|
87
|
-
return withLabels;
|
|
88
|
-
}
|
|
89
|
-
function getPlatformName(platform) {
|
|
90
|
-
switch (platform) {
|
|
91
|
-
case Platform.IOS:
|
|
92
|
-
return "iOS";
|
|
93
|
-
case Platform.ANDROID:
|
|
94
|
-
return "Android";
|
|
95
|
-
default:
|
|
96
|
-
throw new Error(`Unknown platform: ${platform}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function getMaskedInput(message) {
|
|
100
|
-
const password = readlineSync.question(message, {
|
|
101
|
-
hideEchoBack: true
|
|
102
|
-
// This will hide the input as the user types
|
|
103
|
-
});
|
|
104
|
-
return password;
|
|
105
|
-
}
|
|
106
|
-
async function getInput(message) {
|
|
107
|
-
const rl = promises.createInterface({
|
|
108
|
-
input: process.stdin,
|
|
109
|
-
output: process.stdout
|
|
110
|
-
});
|
|
111
|
-
const answer = await rl.question(message);
|
|
112
|
-
rl.close();
|
|
113
|
-
return answer;
|
|
114
|
-
}
|
|
115
|
-
function generatePackageName(gameName) {
|
|
116
|
-
let normalizedGameName = gameName.trim().toLowerCase();
|
|
117
|
-
normalizedGameName = normalizedGameName.replace(/[\s\-_]+/g, ".");
|
|
118
|
-
normalizedGameName = normalizedGameName.replace(/[^a-z0-9\.]/g, "");
|
|
119
|
-
normalizedGameName = normalizedGameName.replace(/\.+/g, ".");
|
|
120
|
-
normalizedGameName = normalizedGameName.replace(/^\./, "").replace(/\.$/, "");
|
|
121
|
-
if (/^[0-9]/.test(normalizedGameName)) {
|
|
122
|
-
normalizedGameName = "app." + normalizedGameName;
|
|
123
|
-
}
|
|
124
|
-
const prefix = "com.";
|
|
125
|
-
if (normalizedGameName === "") {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
return prefix + normalizedGameName;
|
|
129
|
-
}
|
|
130
|
-
function scriptDir(importMeta) {
|
|
131
|
-
const filename = fileURLToPath(importMeta.url);
|
|
132
|
-
const dirname = path.dirname(filename);
|
|
133
|
-
return dirname;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export { getInput as a, generatePackageName as b, getJobStatusColor as c, getStageColor as d, getMaskedInput as e, getFileHash as f, getShortUUID as g, getPlatformName as h, isValidSemVer as i, getMessageColor as j, makeHumanReadable as m, scriptDir as s };
|
package/dist/index-D6BH5UAM.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { useState, useRef, useEffect, useContext } from 'react';
|
|
4
|
-
import Spinner from 'ink-spinner';
|
|
5
|
-
import { b as GameContext } from './Command-BiB9MqbJ.js';
|
|
6
|
-
import { p as getAuthedHeaders, q as API_URL, F as castObjectDates, P as Platform, C as CredentialsType, Q as getGoogleStatus } from './index-BB7X1Pqp.js';
|
|
7
|
-
import axios from 'axios';
|
|
8
|
-
import 'crypto-js';
|
|
9
|
-
import 'uuid';
|
|
10
|
-
import 'luxon';
|
|
11
|
-
import 'fs';
|
|
12
|
-
import '@inkjs/ui';
|
|
13
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
14
|
-
import 'yazl';
|
|
15
|
-
import 'crypto';
|
|
16
|
-
import 'readline-sync';
|
|
17
|
-
import 'node:readline';
|
|
18
|
-
import 'node:path';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import { c as cacheKeys } from './useAndroidServiceAccountTestResult-Ce1x0Eh8.js';
|
|
21
|
-
import 'fast-glob';
|
|
22
|
-
import 'socket.io-client';
|
|
23
|
-
import 'isomorphic-git';
|
|
24
|
-
import '@oclif/core';
|
|
25
|
-
import { u as useWebSocket } from './useWebSocket-CBqsjHbt.js';
|
|
26
|
-
import { u as useProjectCredentials } from './useProjectCredentials-vjedBbKl.js';
|
|
27
|
-
import 'open';
|
|
28
|
-
import { P as ProgressSpinner } from './ProgressSpinner-6pw1T8Iw.js';
|
|
29
|
-
import 'qrcode';
|
|
30
|
-
import 'string-length';
|
|
31
|
-
import 'strip-ansi';
|
|
32
|
-
|
|
33
|
-
async function fetchStatus({ projectId }) {
|
|
34
|
-
try {
|
|
35
|
-
if (!projectId) throw new Error("projectId is required");
|
|
36
|
-
const headers = getAuthedHeaders();
|
|
37
|
-
const url = `${API_URL}/projects/${projectId}/credentials/android/key/status/`;
|
|
38
|
-
const response = await axios.get(url, { headers });
|
|
39
|
-
return castObjectDates(response.data);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.warn("fetchStatus Error", error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const useAndroidServiceAccountSetupStatus = (props) => {
|
|
46
|
-
return useQuery({
|
|
47
|
-
queryKey: cacheKeys.androidSetupStatus(props),
|
|
48
|
-
queryFn: () => fetchStatus(props),
|
|
49
|
-
// Status changes frequently, so we want to keep it fresh
|
|
50
|
-
refetchInterval: 1e3 * 5,
|
|
51
|
-
staleTime: 1e3 * 5
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const ERR_NOT_AUTHENTICATED = "You must be connected to Google to create a Service Account Key";
|
|
56
|
-
const useHasServiceAccountKey = (projectId) => {
|
|
57
|
-
const { data, isSuccess } = useProjectCredentials({ projectId, platform: Platform.ANDROID });
|
|
58
|
-
return isSuccess && data.data.some((cred) => cred.isActive && cred.platform === Platform.ANDROID && cred.type == CredentialsType.KEY);
|
|
59
|
-
};
|
|
60
|
-
const useAndroidServiceAccount = ({ projectId, onError, onComplete }) => {
|
|
61
|
-
const queryClient = useQueryClient();
|
|
62
|
-
const [isStarting, setIsStarting] = useState(false);
|
|
63
|
-
const hasServiceAccountKey = useHasServiceAccountKey(projectId);
|
|
64
|
-
const listener = {
|
|
65
|
-
getPattern: () => `project.${projectId}:android-setup-status`,
|
|
66
|
-
eventHandler: async (pattern, data) => {
|
|
67
|
-
const key = cacheKeys.androidSetupStatus({ projectId });
|
|
68
|
-
queryClient.setQueryData(key, () => data);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
useWebSocket([listener]);
|
|
72
|
-
const { data: setupStatus } = useAndroidServiceAccountSetupStatus({ projectId });
|
|
73
|
-
const prevSetupStatusRef = useRef("unknown");
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (["running", "queued"].includes(prevSetupStatusRef.current)) {
|
|
76
|
-
if (setupStatus?.status === "complete") onComplete();
|
|
77
|
-
if (setupStatus?.status === "error") onError(new Error(setupStatus.errorMessage));
|
|
78
|
-
}
|
|
79
|
-
prevSetupStatusRef.current = setupStatus?.status || "unknown";
|
|
80
|
-
}, [setupStatus]);
|
|
81
|
-
const handleStart = async () => {
|
|
82
|
-
try {
|
|
83
|
-
setIsStarting(true);
|
|
84
|
-
const currentStatus = await getGoogleStatus();
|
|
85
|
-
if (!currentStatus.isAuthenticated) throw new Error(ERR_NOT_AUTHENTICATED);
|
|
86
|
-
const headers = getAuthedHeaders();
|
|
87
|
-
const androidKeyApiBase = `${API_URL}/projects/${projectId}/credentials/android/key`;
|
|
88
|
-
const startUrl = `${androidKeyApiBase}/setup/`;
|
|
89
|
-
const { data: updatedStatus } = await axios.post(startUrl, {}, { headers });
|
|
90
|
-
queryClient.invalidateQueries({
|
|
91
|
-
queryKey: cacheKeys.projectCredentials({ projectId, pageNumber: 0 })
|
|
92
|
-
});
|
|
93
|
-
await queryClient.setQueryData(cacheKeys.androidSetupStatus({ projectId }), (_) => updatedStatus);
|
|
94
|
-
setIsStarting(false);
|
|
95
|
-
return true;
|
|
96
|
-
} catch (error) {
|
|
97
|
-
setIsStarting(false);
|
|
98
|
-
console.warn("useAndroidServiceAccount.handleStart Error", error);
|
|
99
|
-
onError(error);
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
const isCreating = isStarting || setupStatus?.status === "queued" || setupStatus?.status === "running";
|
|
104
|
-
return {
|
|
105
|
-
handleStart,
|
|
106
|
-
setupStatus,
|
|
107
|
-
isCreating,
|
|
108
|
-
hasServiceAccountKey
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const CreateServiceAccountKey = (props) => {
|
|
113
|
-
const { gameId } = useContext(GameContext);
|
|
114
|
-
return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(CreateForGame, { gameId, ...props }) });
|
|
115
|
-
};
|
|
116
|
-
const CreateForGame = ({ onComplete, onError, gameId, ...boxProps }) => {
|
|
117
|
-
const [didStart, setDidStart] = useState(false);
|
|
118
|
-
const { handleStart, setupStatus, isCreating } = useAndroidServiceAccount({
|
|
119
|
-
projectId: gameId,
|
|
120
|
-
onError,
|
|
121
|
-
onComplete
|
|
122
|
-
});
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
handleStart().then(() => setDidStart(true));
|
|
125
|
-
}, [gameId]);
|
|
126
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
|
|
127
|
-
/* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
|
|
128
|
-
/* @__PURE__ */ jsx(Text, { children: "Creating a Service Account and API Key..." }),
|
|
129
|
-
isCreating && /* @__PURE__ */ jsx(Spinner, { type: "dots" })
|
|
130
|
-
] }),
|
|
131
|
-
didStart && /* @__PURE__ */ jsx(ProgressSpinner, { progress: (setupStatus?.progress || 0) * 100, spinnerType: "dots" })
|
|
132
|
-
] }) });
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export { CreateServiceAccountKey as C };
|
package/dist/index-DBrQda8r.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Text, useInput, Box } from 'ink';
|
|
3
|
-
import open from 'open';
|
|
4
|
-
import { useState, useEffect, useContext } from 'react';
|
|
5
|
-
import { Q as getGoogleStatus, a2 as getShortAuthRequiredUrl, a3 as getGoogleAuthUrl, X as WEB_URL } from './index-DdABTtYO.js';
|
|
6
|
-
import 'crypto';
|
|
7
|
-
import 'fs';
|
|
8
|
-
import 'readline-sync';
|
|
9
|
-
import 'node:readline';
|
|
10
|
-
import 'node:path';
|
|
11
|
-
import 'node:url';
|
|
12
|
-
import 'axios';
|
|
13
|
-
import { useQuery } from '@tanstack/react-query';
|
|
14
|
-
import 'crypto-js';
|
|
15
|
-
import 'uuid';
|
|
16
|
-
import 'luxon';
|
|
17
|
-
import 'fast-glob';
|
|
18
|
-
import 'yazl';
|
|
19
|
-
import 'socket.io-client';
|
|
20
|
-
import { u as useWebSocket } from './useWebSocket-D8PojLtx.js';
|
|
21
|
-
import { c as cacheKeys } from './useAndroidServiceAccountTestResult-InDf5WSl.js';
|
|
22
|
-
import 'isomorphic-git';
|
|
23
|
-
import '@oclif/core';
|
|
24
|
-
import { b as GameContext, M as Markdown } from './Command-DxmQn3XT.js';
|
|
25
|
-
import 'ink-spinner';
|
|
26
|
-
import '@inkjs/ui';
|
|
27
|
-
import 'string-length';
|
|
28
|
-
import 'strip-ansi';
|
|
29
|
-
import qrcode from 'qrcode';
|
|
30
|
-
|
|
31
|
-
const useGoogleStatus = () => {
|
|
32
|
-
return useQuery({
|
|
33
|
-
queryKey: cacheKeys.googleStatus(),
|
|
34
|
-
queryFn: getGoogleStatus
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function useGoogleStatusWatching({
|
|
39
|
-
projectId,
|
|
40
|
-
isWatching,
|
|
41
|
-
onGoogleStatusUpdate
|
|
42
|
-
}) {
|
|
43
|
-
const [wsGoogleStatus, setWsGoogleStatus] = useState(null);
|
|
44
|
-
const listener = {
|
|
45
|
-
getPattern: () => `project.${projectId}:google-status`,
|
|
46
|
-
eventHandler: async (pattern, data2) => {
|
|
47
|
-
setWsGoogleStatus(data2);
|
|
48
|
-
if (onGoogleStatusUpdate) onGoogleStatusUpdate(data2);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
useWebSocket([listener] );
|
|
52
|
-
const { isLoading, data: googleStatus } = useGoogleStatus();
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
setWsGoogleStatus(null);
|
|
55
|
-
}, [projectId, isWatching, googleStatus]);
|
|
56
|
-
const fetchedGoogleStatus = googleStatus ? googleStatus : null;
|
|
57
|
-
const data = wsGoogleStatus ? wsGoogleStatus : fetchedGoogleStatus;
|
|
58
|
-
return {
|
|
59
|
-
isLoading,
|
|
60
|
-
data
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const QRCodeTerminal = ({ url }) => {
|
|
65
|
-
const [code, setCode] = useState(null);
|
|
66
|
-
const handleLoad = async () => {
|
|
67
|
-
const codeString = await qrcode.toString(url, { type: "terminal", errorCorrectionLevel: "L", small: true });
|
|
68
|
-
setCode(codeString);
|
|
69
|
-
};
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
handleLoad();
|
|
72
|
-
}, []);
|
|
73
|
-
return /* @__PURE__ */ jsx(Fragment, { children: code && /* @__PURE__ */ jsx(Text, { children: code }) });
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
async function getConnectUrl(gameId, helpPage) {
|
|
77
|
-
const helpPagePath = `/docs/android?gameId=${gameId}#2-connect-shipthis-with-google`;
|
|
78
|
-
const url = helpPage ? await getShortAuthRequiredUrl(helpPagePath) : await getGoogleAuthUrl(gameId);
|
|
79
|
-
return url;
|
|
80
|
-
}
|
|
81
|
-
const GoogleAuthQRCode = ({ gameId, helpPage }) => {
|
|
82
|
-
const [url, setUrl] = useState(null);
|
|
83
|
-
const handleLoad = async () => {
|
|
84
|
-
const url2 = await getConnectUrl(gameId, helpPage);
|
|
85
|
-
setUrl(url2);
|
|
86
|
-
};
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
handleLoad();
|
|
89
|
-
}, []);
|
|
90
|
-
return /* @__PURE__ */ jsx(Fragment, { children: url && /* @__PURE__ */ jsx(QRCodeTerminal, { url }) });
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const ConnectGoogle = (props) => {
|
|
94
|
-
const { gameId } = useContext(GameContext);
|
|
95
|
-
return /* @__PURE__ */ jsx(Fragment, { children: gameId && /* @__PURE__ */ jsx(ConnectForGame, { gameId, ...props }) });
|
|
96
|
-
};
|
|
97
|
-
const ConnectForGame = ({ onComplete, onError, helpPage, gameId, ...boxProps }) => {
|
|
98
|
-
useGoogleStatusWatching({
|
|
99
|
-
projectId: gameId,
|
|
100
|
-
isWatching: true,
|
|
101
|
-
onGoogleStatusUpdate: (status) => {
|
|
102
|
-
if (status.isAuthenticated) return onComplete();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
useInput(async (input) => {
|
|
106
|
-
if (!gameId) return;
|
|
107
|
-
if (input !== "d") return;
|
|
108
|
-
const url = await getConnectUrl(gameId, true);
|
|
109
|
-
await open(url);
|
|
110
|
-
});
|
|
111
|
-
const templateVars = {
|
|
112
|
-
privacyURL: new URL("/privacy", WEB_URL).toString()
|
|
113
|
-
};
|
|
114
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, ...boxProps, children: [
|
|
115
|
-
/* @__PURE__ */ jsx(Markdown, { filename: "privacy-notification.md", templateVars }),
|
|
116
|
-
/* @__PURE__ */ jsx(Text, { children: "Scan the QR code below to connect your Google account to ShipThis:" }),
|
|
117
|
-
gameId && /* @__PURE__ */ jsx(GoogleAuthQRCode, { gameId, helpPage: !!helpPage }),
|
|
118
|
-
/* @__PURE__ */ jsx(Text, { children: "Or press D to sign-in using your browser" })
|
|
119
|
-
] });
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export { ConnectGoogle as C };
|