shipthis 0.1.4 → 0.1.6

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 (132) hide show
  1. package/dist/AppleBundleIdDetails-Df30MPFC.js +73 -0
  2. package/dist/Command-DxmQn3XT.js +204 -0
  3. package/dist/CommandGame-DspVLTPZ.js +8 -0
  4. package/dist/CreateKeystore-D8uTRamD.js +56 -0
  5. package/dist/JobProgress-Dk0UoNah.js +108 -0
  6. package/dist/JobStatusTable-q4atKzhu.js +75 -0
  7. package/dist/ProgressSpinner-6pw1T8Iw.js +16 -0
  8. package/dist/ProjectCredentialsTable-BIWBAXCh.js +37 -0
  9. package/dist/UserCredentialsTable-CeJS3_hd.js +82 -0
  10. package/dist/baseAppleCommand-D-G4h8zQ.js +10 -0
  11. package/dist/baseGameAndroidCommand-DD0H8iy-.js +43 -0
  12. package/dist/commands/apple/apiKey/create.js +7 -7
  13. package/dist/commands/apple/apiKey/export.js +6 -6
  14. package/dist/commands/apple/apiKey/import.js +6 -6
  15. package/dist/commands/apple/apiKey/status.js +6 -6
  16. package/dist/commands/apple/certificate/create.js +7 -7
  17. package/dist/commands/apple/certificate/export.js +6 -6
  18. package/dist/commands/apple/certificate/import.js +6 -6
  19. package/dist/commands/apple/certificate/status.js +6 -6
  20. package/dist/commands/apple/login.js +2 -2
  21. package/dist/commands/apple/status.js +4 -4
  22. package/dist/commands/dashboard.js +1 -1
  23. package/dist/commands/game/android/apiKey/connect.js +8 -8
  24. package/dist/commands/game/android/apiKey/create.js +11 -10
  25. package/dist/commands/game/android/apiKey/export.js +7 -7
  26. package/dist/commands/game/android/apiKey/import.js +7 -7
  27. package/dist/commands/game/android/apiKey/invite.js +4 -4
  28. package/dist/commands/game/android/apiKey/status.js +7 -7
  29. package/dist/commands/game/android/keyStore/create.js +8 -8
  30. package/dist/commands/game/android/keyStore/export.js +6 -6
  31. package/dist/commands/game/android/keyStore/import.js +6 -6
  32. package/dist/commands/game/android/keyStore/status.js +6 -6
  33. package/dist/commands/game/android/status.js +4 -4
  34. package/dist/commands/game/android/wizard.js +18 -81
  35. package/dist/commands/game/build/download.js +4 -4
  36. package/dist/commands/game/build/list.js +5 -5
  37. package/dist/commands/game/create.js +2 -2
  38. package/dist/commands/game/details.js +4 -4
  39. package/dist/commands/game/export.js +1 -1
  40. package/dist/commands/game/ios/app/addTester.js +5 -5
  41. package/dist/commands/game/ios/app/create.js +4 -4
  42. package/dist/commands/game/ios/app/status.js +7 -7
  43. package/dist/commands/game/ios/app/sync.js +5 -5
  44. package/dist/commands/game/ios/profile/create.js +7 -7
  45. package/dist/commands/game/ios/profile/export.js +6 -6
  46. package/dist/commands/game/ios/profile/import.js +6 -6
  47. package/dist/commands/game/ios/profile/status.js +7 -7
  48. package/dist/commands/game/ios/status.js +7 -7
  49. package/dist/commands/game/ios/wizard.js +2 -2
  50. package/dist/commands/game/job/list.js +4 -4
  51. package/dist/commands/game/job/status.js +10 -59
  52. package/dist/commands/game/list.js +4 -4
  53. package/dist/commands/game/ship.js +73 -50
  54. package/dist/commands/game/status.js +4 -4
  55. package/dist/commands/game/wizard.js +1 -1
  56. package/dist/commands/internal/fastlane.js +1 -1
  57. package/dist/commands/internal/readme.js +3 -3
  58. package/dist/commands/login.js +2 -2
  59. package/dist/commands/status.js +4 -4
  60. package/dist/export-BDxGDZdh.js +36 -0
  61. package/dist/import-BrlJuE2Z.js +38 -0
  62. package/dist/index-BDFKyTPb.js +24 -0
  63. package/dist/index-BL-1G60K.js +135 -0
  64. package/dist/index-DBrQda8r.js +122 -0
  65. package/dist/index-DdABTtYO.js +693 -0
  66. package/dist/index-wyPoxiTc.js +136 -0
  67. package/dist/upload-LXRr4pMa.js +60 -0
  68. package/dist/useAndroidServiceAccountTestResult-InDf5WSl.js +52 -0
  69. package/dist/useAppleApp-DgE0wEaq.js +32 -0
  70. package/dist/useAppleBundleId-DtLODy3p.js +64 -0
  71. package/dist/useJobWatching-P5oC7mNB.js +45 -0
  72. package/dist/useProjectCredentials-BRffcsO3.js +54 -0
  73. package/dist/useWebSocket-D8PojLtx.js +36 -0
  74. package/docs/apple/apiKey/create.md +1 -1
  75. package/docs/apple/apiKey/export.md +1 -1
  76. package/docs/apple/apiKey/import.md +1 -1
  77. package/docs/apple/apiKey/status.md +1 -1
  78. package/docs/apple/apiKey.md +4 -4
  79. package/docs/apple/certificate/create.md +1 -1
  80. package/docs/apple/certificate/export.md +1 -1
  81. package/docs/apple/certificate/import.md +1 -1
  82. package/docs/apple/certificate/status.md +1 -1
  83. package/docs/apple/certificate.md +4 -4
  84. package/docs/apple/login.md +1 -1
  85. package/docs/apple/status.md +2 -1
  86. package/docs/dashboard.md +1 -1
  87. package/docs/game/android/apiKey/connect.md +1 -1
  88. package/docs/game/android/apiKey/create.md +1 -1
  89. package/docs/game/android/apiKey/export.md +1 -1
  90. package/docs/game/android/apiKey/import.md +1 -1
  91. package/docs/game/android/apiKey/invite.md +1 -1
  92. package/docs/game/android/apiKey/status.md +1 -1
  93. package/docs/game/android/apiKey.md +6 -6
  94. package/docs/game/android/keyStore/create.md +1 -1
  95. package/docs/game/android/keyStore/export.md +1 -1
  96. package/docs/game/android/keyStore/import.md +1 -1
  97. package/docs/game/android/keyStore/status.md +1 -1
  98. package/docs/game/android/keyStore.md +4 -4
  99. package/docs/game/android/status.md +1 -1
  100. package/docs/game/android/wizard.md +1 -1
  101. package/docs/game/android.md +12 -12
  102. package/docs/game/build/download.md +1 -1
  103. package/docs/game/build/list.md +1 -1
  104. package/docs/game/build.md +2 -2
  105. package/docs/game/create.md +1 -1
  106. package/docs/game/details.md +1 -1
  107. package/docs/game/export.md +1 -1
  108. package/docs/game/ios/app/addTester.md +1 -1
  109. package/docs/game/ios/app/create.md +1 -1
  110. package/docs/game/ios/app/status.md +1 -1
  111. package/docs/game/ios/app/sync.md +1 -1
  112. package/docs/game/ios/app.md +3 -3
  113. package/docs/game/ios/profile/create.md +1 -1
  114. package/docs/game/ios/profile/export.md +1 -1
  115. package/docs/game/ios/profile/import.md +1 -1
  116. package/docs/game/ios/profile/status.md +1 -1
  117. package/docs/game/ios/profile.md +4 -4
  118. package/docs/game/ios/status.md +1 -1
  119. package/docs/game/ios/wizard.md +1 -1
  120. package/docs/game/job/list.md +1 -1
  121. package/docs/game/job/status.md +1 -1
  122. package/docs/game/job.md +2 -2
  123. package/docs/game/list.md +1 -1
  124. package/docs/game/ship.md +1 -1
  125. package/docs/game/status.md +1 -1
  126. package/docs/game/wizard.md +1 -1
  127. package/docs/help.md +1 -1
  128. package/docs/login.md +1 -1
  129. package/docs/status.md +1 -1
  130. package/npm-shrinkwrap.json +2 -2
  131. package/oclif.manifest.json +122 -122
  132. package/package.json +1 -1
@@ -0,0 +1,135 @@
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-DxmQn3XT.js';
6
+ import { p as getAuthedHeaders, q as API_URL, M as castObjectDates, P as Platform, C as CredentialsType, Q as getGoogleStatus } from './index-DdABTtYO.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-InDf5WSl.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-D8PojLtx.js';
27
+ import { u as useProjectCredentials } from './useProjectCredentials-BRffcsO3.js';
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 };
@@ -0,0 +1,122 @@
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 };