shipthis 0.1.25 → 0.1.26

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 (84) hide show
  1. package/dist/AppleBundleIdDetails-mPUG2R4N.js +76 -0
  2. package/dist/Command-B3AmRt2w.js +28 -0
  3. package/dist/CommandGame-BCMzP9pc.js +9 -0
  4. package/dist/Create-CsJxpzUs.js +59 -0
  5. package/dist/Import-v0M_ygyF.js +110 -0
  6. package/dist/JobProgress-9uvq8IBn.js +121 -0
  7. package/dist/JobStatusTable-Bf7J9WXe.js +191 -0
  8. package/dist/NextSteps-CK9zHOCt.js +18 -0
  9. package/dist/ProgressSpinner-6pw1T8Iw.js +16 -0
  10. package/dist/ProjectCredentialsTable-CTkP1mvy.js +37 -0
  11. package/dist/RunWithSpinner-BVXNWGD3.js +27 -0
  12. package/dist/StatusTable-Dm5St4g-.js +33 -0
  13. package/dist/Table-CvM6pccN.js +101 -0
  14. package/dist/Title-BCQtayg6.js +6 -0
  15. package/dist/UserCredentialsTable-DhtM_iTG.js +82 -0
  16. package/dist/baseAppleCommand-IGl6KTvv.js +10 -0
  17. package/dist/baseGameAndroidCommand-DFn4zMvq.js +43 -0
  18. package/dist/commands/apple/apiKey/create.js +103 -0
  19. package/dist/commands/apple/apiKey/export.js +81 -0
  20. package/dist/commands/apple/apiKey/import.js +85 -0
  21. package/dist/commands/apple/apiKey/status.js +122 -0
  22. package/dist/commands/apple/certificate/create.js +133 -0
  23. package/dist/commands/apple/certificate/export.js +81 -0
  24. package/dist/commands/apple/certificate/import.js +85 -0
  25. package/dist/commands/apple/certificate/status.js +130 -0
  26. package/dist/commands/apple/login.js +76 -0
  27. package/dist/commands/apple/status.js +79 -0
  28. package/dist/commands/dashboard.js +38 -0
  29. package/dist/commands/game/android/apiKey/connect.js +74 -0
  30. package/dist/commands/game/android/apiKey/create.js +74 -0
  31. package/dist/commands/game/android/apiKey/export.js +84 -0
  32. package/dist/commands/game/android/apiKey/import.js +93 -0
  33. package/dist/commands/game/android/apiKey/invite.js +81 -0
  34. package/dist/commands/game/android/apiKey/status.js +87 -0
  35. package/dist/commands/game/android/keyStore/create.js +69 -0
  36. package/dist/commands/game/android/keyStore/export.js +83 -0
  37. package/dist/commands/game/android/keyStore/import.js +112 -0
  38. package/dist/commands/game/android/keyStore/status.js +70 -0
  39. package/dist/commands/game/android/status.js +84 -0
  40. package/dist/commands/game/build/download.js +80 -0
  41. package/dist/commands/game/build/list.js +94 -0
  42. package/dist/commands/game/create.js +67 -0
  43. package/dist/commands/game/details.js +113 -0
  44. package/dist/commands/game/export.js +58 -0
  45. package/dist/commands/game/ios/app/addTester.js +124 -0
  46. package/dist/commands/game/ios/app/create.js +117 -0
  47. package/dist/commands/game/ios/app/status.js +66 -0
  48. package/dist/commands/game/ios/app/sync.js +95 -0
  49. package/dist/commands/game/ios/profile/create.js +129 -0
  50. package/dist/commands/game/ios/profile/export.js +83 -0
  51. package/dist/commands/game/ios/profile/import.js +92 -0
  52. package/dist/commands/game/ios/profile/status.js +139 -0
  53. package/dist/commands/game/ios/status.js +92 -0
  54. package/dist/commands/game/ios/wizard.js +153 -0
  55. package/dist/commands/game/job/list.js +91 -0
  56. package/dist/commands/game/job/status.js +91 -0
  57. package/dist/commands/game/list.js +83 -0
  58. package/dist/commands/game/ship.js +216 -0
  59. package/dist/commands/game/status.js +114 -0
  60. package/dist/commands/game/wizard.js +686 -0
  61. package/dist/commands/internal/fastlane.js +74 -0
  62. package/dist/commands/internal/readme.js +937 -0
  63. package/dist/commands/login.js +92 -0
  64. package/dist/commands/status.js +76 -0
  65. package/dist/export-CVs_xoDN.js +36 -0
  66. package/dist/git-DREGq-jc.js +32 -0
  67. package/dist/import-Ch5O7xfN.js +47 -0
  68. package/dist/index-BB00V5oF.js +136 -0
  69. package/dist/index-BD1WLuFJ.js +125 -0
  70. package/dist/index-CIa2EDQ6.js +24 -0
  71. package/dist/index-CboPN9aq.js +138 -0
  72. package/dist/index-DkNQs11R.js +711 -0
  73. package/dist/index-nnzhQ3nY.js +209 -0
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.js +1 -0
  76. package/dist/upload-CRE2nVdd.js +60 -0
  77. package/dist/useAndroidServiceAccountTestResult-DcYDam-p.js +52 -0
  78. package/dist/useAppleApp-B16WbUxJ.js +32 -0
  79. package/dist/useAppleBundleId-DobPATan.js +64 -0
  80. package/dist/useJobWatching--BvVn7xS.js +45 -0
  81. package/dist/useProjectCredentials-Btnr7WK3.js +54 -0
  82. package/dist/useWebSocket-ByuNoqRw.js +36 -0
  83. package/dist/utils/help.js +14 -0
  84. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { Box, Text } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
+ import './index-DkNQs11R.js';
5
+ import 'axios';
6
+ import '@tanstack/react-query';
7
+ import 'crypto';
8
+ import 'fs';
9
+ import 'readline-sync';
10
+ import 'node:readline';
11
+ import 'node:path';
12
+ import 'node:url';
13
+ import 'luxon';
14
+ import 'isomorphic-git';
15
+ import '@oclif/core';
16
+ import 'react';
17
+ import 'crypto-js';
18
+ import 'uuid';
19
+ import 'socket.io-client';
20
+ import { u as useAppleApp } from './useAppleApp-B16WbUxJ.js';
21
+ import 'fast-glob';
22
+ import 'yazl';
23
+ import '@inkjs/ui';
24
+ import './index-nnzhQ3nY.js';
25
+ import 'open';
26
+ import { T as Table } from './Table-CvM6pccN.js';
27
+ import { T as Title } from './Title-BCQtayg6.js';
28
+ import 'string-length';
29
+ import 'strip-ansi';
30
+ import 'marked';
31
+ import 'marked-terminal';
32
+ import 'path';
33
+ import 'qrcode';
34
+ import { u as useAppleBundleId } from './useAppleBundleId-DobPATan.js';
35
+
36
+ const AppleAppDetails = (props) => {
37
+ const { data, isLoading } = useAppleApp(props);
38
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
39
+ /* @__PURE__ */ jsx(Title, { children: "App Details (in the Apple Developer Portal)" }),
40
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
41
+ data && data.summary && /* @__PURE__ */ jsx(Table, { data: [data.summary] })
42
+ ] });
43
+ };
44
+
45
+ const AppleBundleIdDetails = (props) => {
46
+ const { data, isLoading } = useAppleBundleId(props);
47
+ const { bundleIdSummary, capabilitiesTable, shouldSyncCapabilities, capabilities } = data || {};
48
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
49
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
50
+ /* @__PURE__ */ jsx(Title, { children: "BundleId Details (in the Apple Developer Portal)" }),
51
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
52
+ bundleIdSummary && /* @__PURE__ */ jsx(Table, { data: [bundleIdSummary] })
53
+ ] }),
54
+ capabilities && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
55
+ /* @__PURE__ */ jsx(Title, { children: "Capabilities enabled in the BundleId" }),
56
+ /* @__PURE__ */ jsx(
57
+ Table,
58
+ {
59
+ data: capabilities.map((c) => {
60
+ return { capability: `${c}` };
61
+ })
62
+ }
63
+ )
64
+ ] }),
65
+ capabilitiesTable && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
66
+ /* @__PURE__ */ jsx(Title, { children: "BundleId Capability Check" }),
67
+ /* @__PURE__ */ jsx(Table, { data: capabilitiesTable })
68
+ ] }),
69
+ shouldSyncCapabilities && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
70
+ /* @__PURE__ */ jsx(Text, { bold: true, children: "The capabilities are out of sync with the Apple Developer Portal." }),
71
+ /* @__PURE__ */ jsx(Text, { bold: true, children: "Run shipthis game ios app sync" })
72
+ ] })
73
+ ] });
74
+ };
75
+
76
+ export { AppleAppDetails as A, AppleBundleIdDetails as a };
@@ -0,0 +1,28 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Box } from 'ink';
3
+ import { QueryClientProvider } from '@tanstack/react-query';
4
+ import { M as queryClient } from './index-DkNQs11R.js';
5
+ import 'axios';
6
+ import 'crypto';
7
+ import 'fs';
8
+ import 'readline-sync';
9
+ import 'node:readline';
10
+ import 'node:path';
11
+ import 'node:url';
12
+ import 'luxon';
13
+ import 'isomorphic-git';
14
+ import '@oclif/core';
15
+ import 'react';
16
+ import 'crypto-js';
17
+ import 'uuid';
18
+ import 'socket.io-client';
19
+ import 'fast-glob';
20
+ import 'yazl';
21
+ import { C as CommandProvider } from './index-nnzhQ3nY.js';
22
+
23
+ const Command = ({ children, command }) => {
24
+ const width = process.stdout.columns || 80;
25
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommandProvider, { command, children: /* @__PURE__ */ jsx(Box, { width, flexDirection: "column", children }) }) });
26
+ };
27
+
28
+ export { Command as C };
@@ -0,0 +1,9 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { G as GameProvider } from './index-nnzhQ3nY.js';
3
+ import { C as Command } from './Command-B3AmRt2w.js';
4
+
5
+ const CommandGame = ({ children, command }) => {
6
+ return /* @__PURE__ */ jsx(Command, { command, children: /* @__PURE__ */ jsx(GameProvider, { children }) });
7
+ };
8
+
9
+ export { CommandGame as C };
@@ -0,0 +1,59 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Box } from 'ink';
3
+ import axios from 'axios';
4
+ import { useContext } from 'react';
5
+ import { useQueryClient } from '@tanstack/react-query';
6
+ import { p as getAuthedHeaders, q as API_URL } from './index-DkNQs11R.js';
7
+ import { c as cacheKeys } from './useAndroidServiceAccountTestResult-DcYDam-p.js';
8
+ import { b as GameContext } from './index-nnzhQ3nY.js';
9
+ import 'ink-spinner';
10
+ import '@inkjs/ui';
11
+ import 'fs';
12
+ import 'uuid';
13
+ import 'yazl';
14
+ import 'crypto';
15
+ import 'readline-sync';
16
+ import 'node:readline';
17
+ import 'node:path';
18
+ import 'node:url';
19
+ import 'luxon';
20
+ import 'isomorphic-git';
21
+ import '@oclif/core';
22
+ import 'fast-glob';
23
+ import 'socket.io-client';
24
+ import 'open';
25
+ import 'marked';
26
+ import 'marked-terminal';
27
+ import 'path';
28
+ import 'qrcode';
29
+ import { R as RunWithSpinner } from './RunWithSpinner-BVXNWGD3.js';
30
+ import 'string-length';
31
+ import 'strip-ansi';
32
+
33
+ const CreateKeystore = ({ onComplete, onError, ...boxProps }) => {
34
+ const { gameId } = useContext(GameContext);
35
+ const queryClient = useQueryClient();
36
+ const handleCreate = async () => {
37
+ try {
38
+ if (!gameId) throw new Error("No game");
39
+ const headers = await getAuthedHeaders();
40
+ await axios.post(`${API_URL}/projects/${gameId}/credentials/android/certificate`, null, {
41
+ headers
42
+ });
43
+ queryClient.invalidateQueries({ queryKey: cacheKeys.projectCredentials({ projectId: gameId, pageNumber: 0 }) });
44
+ } catch (err) {
45
+ onError(err);
46
+ }
47
+ };
48
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", gap: 1, ...boxProps, children: gameId && /* @__PURE__ */ jsx(
49
+ RunWithSpinner,
50
+ {
51
+ executeMethod: handleCreate,
52
+ msgInProgress: "Creating Keystore...",
53
+ msgComplete: "Keystore created",
54
+ onComplete
55
+ }
56
+ ) });
57
+ };
58
+
59
+ export { CreateKeystore as C };
@@ -0,0 +1,110 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useContext, useState, useEffect } from 'react';
3
+ import { Box, Text } from 'ink';
4
+ import Spinner from 'ink-spinner';
5
+ import { b as GameContext } from './index-nnzhQ3nY.js';
6
+ import { M as queryClient, P as Platform, C as CredentialsType } from './index-DkNQs11R.js';
7
+ import 'axios';
8
+ import 'crypto-js';
9
+ import { v4 } from 'uuid';
10
+ import fs__default from 'fs';
11
+ import 'luxon';
12
+ import '@inkjs/ui';
13
+ import { useMutation } from '@tanstack/react-query';
14
+ import yazl from 'yazl';
15
+ import { c as cacheKeys } from './useAndroidServiceAccountTestResult-DcYDam-p.js';
16
+ import { i as importCredential } from './import-Ch5O7xfN.js';
17
+ import 'crypto';
18
+ import 'readline-sync';
19
+ import 'node:readline';
20
+ import 'node:path';
21
+ import 'node:url';
22
+ import 'isomorphic-git';
23
+ import '@oclif/core';
24
+ import 'fast-glob';
25
+ import 'socket.io-client';
26
+ import 'open';
27
+ import 'marked';
28
+ import 'marked-terminal';
29
+ import 'path';
30
+ import 'qrcode';
31
+ import 'string-length';
32
+ import 'strip-ansi';
33
+
34
+ async function importKeystore({ log = () => {
35
+ }, ...opt }) {
36
+ if (!opt.zipFilePath && !opt.jksFilePath) {
37
+ throw new Error("You must provide either a zipFilePath or a jksFilePath");
38
+ }
39
+ if (opt.zipFilePath && opt.jksFilePath) {
40
+ throw new Error("You cannot provide both a zipFilePath and a jksFilePath");
41
+ }
42
+ if (opt.jksFilePath && (!opt.keystorePassword || !opt.keyPassword)) {
43
+ throw new Error("You must provide both keystorePassword and keyPassword when importing a jks file");
44
+ }
45
+ const toDelete = [];
46
+ if (opt.jksFilePath) {
47
+ log("Creating zip file from jks file...");
48
+ const outputZipToFile = (zip, fileName) => new Promise((resolve) => {
49
+ const outputStream = fs__default.createWriteStream(fileName);
50
+ zip.outputStream.pipe(outputStream).on("close", () => resolve());
51
+ zip.end();
52
+ });
53
+ const zipFile = new yazl.ZipFile();
54
+ log("Adding keyStore.jks to zip file...");
55
+ zipFile.addFile(opt.jksFilePath, "keyStore.jks");
56
+ log("Adding password.txt and keyPassword.txt to zip file...");
57
+ zipFile.addBuffer(Buffer.from(`${opt.keystorePassword}`), "password.txt");
58
+ zipFile.addBuffer(Buffer.from(`${opt.keyPassword}`), "keyPassword.txt");
59
+ const tmpZipFile = `${process.cwd()}/shipthis-keyStore-${v4()}.zip`;
60
+ log(`Writing zip file: ${tmpZipFile}`);
61
+ await outputZipToFile(zipFile, tmpZipFile);
62
+ toDelete.push(tmpZipFile);
63
+ opt.zipFilePath = tmpZipFile;
64
+ }
65
+ log("Uploading and importing zip file...");
66
+ const keyStore = await importCredential({
67
+ projectId: opt.gameId,
68
+ zipPath: `${opt.zipFilePath}`,
69
+ type: CredentialsType.CERTIFICATE,
70
+ platform: Platform.ANDROID
71
+ });
72
+ log("Imported successfully");
73
+ toDelete.forEach((file) => {
74
+ log(`Deleting temporary file: ${file}`);
75
+ fs__default.unlinkSync(file);
76
+ });
77
+ return keyStore;
78
+ }
79
+ const useImportKeystore = () => {
80
+ return useMutation({
81
+ mutationFn: importKeystore,
82
+ onSuccess: async (data) => {
83
+ const projectId = data.projectId;
84
+ queryClient.invalidateQueries({
85
+ queryKey: cacheKeys.projectCredentials({ projectId, pageNumber: 0 })
86
+ });
87
+ }
88
+ });
89
+ };
90
+
91
+ const ImportKeystore = ({ onComplete, onError, importKeystoreProps }) => {
92
+ const { gameId } = useContext(GameContext);
93
+ const importMutation = useImportKeystore();
94
+ const [log, setLog] = useState(null);
95
+ useEffect(() => {
96
+ if (!gameId) return;
97
+ const importOpts = {
98
+ ...importKeystoreProps,
99
+ gameId,
100
+ log: setLog
101
+ };
102
+ importMutation.mutateAsync(importOpts).catch(onError).then(onComplete);
103
+ }, [gameId]);
104
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
105
+ /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
106
+ log && /* @__PURE__ */ jsx(Text, { children: log })
107
+ ] });
108
+ };
109
+
110
+ export { ImportKeystore as I };
@@ -0,0 +1,121 @@
1
+ import { v4 } from 'uuid';
2
+ import axios from 'axios';
3
+ import fg from 'fast-glob';
4
+ import fs__default from 'fs';
5
+ import yazl from 'yazl';
6
+ import { useMutation } from '@tanstack/react-query';
7
+ import { c as cacheKeys } from './useAndroidServiceAccountTestResult-DcYDam-p.js';
8
+ import { M as queryClient, x as DEFAULT_SHIPPED_FILES_GLOBS, w as DEFAULT_IGNORED_FILES_GLOBS, a1 as getNewUploadTicket, a2 as startJobsFromUpload, J as JobStatus } from './index-DkNQs11R.js';
9
+ import { e as getFileHash, f as getPlatformName } from './index-BB00V5oF.js';
10
+ import { g as getCWDGitInfo } from './git-DREGq-jc.js';
11
+ import { jsx, Fragment } from 'react/jsx-runtime';
12
+ import { useRef } from 'react';
13
+ import 'ink';
14
+ import './index-nnzhQ3nY.js';
15
+ import 'ink-spinner';
16
+ import 'crypto-js';
17
+ import 'luxon';
18
+ import '@inkjs/ui';
19
+ import 'open';
20
+ import 'marked';
21
+ import 'marked-terminal';
22
+ import 'path';
23
+ import { P as ProgressSpinner } from './ProgressSpinner-6pw1T8Iw.js';
24
+ import 'qrcode';
25
+ import 'string-length';
26
+ import 'strip-ansi';
27
+ import 'socket.io-client';
28
+ import { u as useJobWatching } from './useJobWatching--BvVn7xS.js';
29
+
30
+ async function ship({ command, log = () => {
31
+ } }) {
32
+ log("Fetching project config...");
33
+ const projectConfig = await command.getProjectConfig();
34
+ if (!projectConfig.project) throw new Error("No project found in project config");
35
+ log("Retrieving file globs...");
36
+ const shippedFilesGlobs = projectConfig.shippedFilesGlobs || DEFAULT_SHIPPED_FILES_GLOBS;
37
+ const ignoredFilesGlobs = projectConfig.ignoredFilesGlobs || DEFAULT_IGNORED_FILES_GLOBS;
38
+ log("Finding files to include in zip...");
39
+ const files = await fg(shippedFilesGlobs, { dot: true, ignore: ignoredFilesGlobs });
40
+ log(`Found ${files.length} files, adding to zip...`);
41
+ const zipFile = new yazl.ZipFile();
42
+ for (const file of files) {
43
+ zipFile.addFile(file, file);
44
+ }
45
+ const outputZipToFile = (zip, fileName) => new Promise((resolve) => {
46
+ const outputStream = fs__default.createWriteStream(fileName);
47
+ zip.outputStream.pipe(outputStream).on("close", () => resolve());
48
+ zip.end();
49
+ });
50
+ const tmpZipFile = `${process.cwd()}/shipthis-${v4()}.zip`;
51
+ log(`Creating zip file: ${tmpZipFile}`);
52
+ await outputZipToFile(zipFile, tmpZipFile);
53
+ log("Reading zip file buffer...");
54
+ const zipBuffer = fs__default.readFileSync(tmpZipFile);
55
+ const { size } = fs__default.statSync(tmpZipFile);
56
+ log("Requesting upload ticket...");
57
+ const uploadTicket = await getNewUploadTicket(projectConfig.project.id);
58
+ log("Uploading zip file...");
59
+ await axios.put(uploadTicket.url, zipBuffer, {
60
+ headers: {
61
+ "Content-length": size,
62
+ "Content-Type": "application/zip"
63
+ }
64
+ });
65
+ log("Fetching Git info...");
66
+ const gitInfo = await getCWDGitInfo();
67
+ log("Computing file hash...");
68
+ const zipFileMd5 = await getFileHash(tmpZipFile);
69
+ const uploadDetails = {
70
+ ...gitInfo,
71
+ zipFileMd5
72
+ };
73
+ log("Starting jobs from upload...");
74
+ const commandFlags = command.getFlags();
75
+ const startJobsOptions = {
76
+ ...uploadDetails,
77
+ skipPublish: commandFlags.skipPublish,
78
+ platform: commandFlags.platform?.toUpperCase()
79
+ };
80
+ const jobs = await startJobsFromUpload(uploadTicket.id, startJobsOptions);
81
+ log("Cleaning up temporary zip file...");
82
+ fs__default.unlinkSync(tmpZipFile);
83
+ log("Job submission complete.");
84
+ return jobs;
85
+ }
86
+ const useShip = () => {
87
+ return useMutation({
88
+ mutationFn: ship,
89
+ onSuccess: async (data) => {
90
+ queryClient.invalidateQueries({
91
+ queryKey: cacheKeys.jobs({ projectId: data[0].project.id, pageNumber: 0 })
92
+ });
93
+ }
94
+ });
95
+ };
96
+
97
+ const JobProgress = (props) => {
98
+ const prevJobStatus = useRef(props.job.status);
99
+ const handleJobUpdate = (job) => {
100
+ const completed = [JobStatus.COMPLETED, JobStatus.FAILED];
101
+ const wasRunning = !completed.includes(prevJobStatus.current);
102
+ if (completed.includes(job.status) && wasRunning) {
103
+ if (job.status === JobStatus.FAILED) {
104
+ props.onFailure(job);
105
+ } else {
106
+ props.onComplete(job);
107
+ }
108
+ }
109
+ prevJobStatus.current = job.status;
110
+ };
111
+ const { progress } = useJobWatching({
112
+ projectId: props.job.project.id,
113
+ jobId: props.job.id,
114
+ isWatching: true,
115
+ onJobUpdate: handleJobUpdate
116
+ });
117
+ const label = `${getPlatformName(props.job.type)} build progress...`;
118
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ProgressSpinner, { progress, label, spinnerType: "dots" }) });
119
+ };
120
+
121
+ export { JobProgress as J, useShip as u };
@@ -0,0 +1,191 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { measureElement, Box, Text } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
+ import { h as getStageColor, j as getMessageColor, c as getJobStatusColor } from './index-BB00V5oF.js';
5
+ import { useState, useEffect, useRef } from 'react';
6
+ import axios from 'axios';
7
+ import { useInfiniteQuery } from '@tanstack/react-query';
8
+ import { p as getAuthedHeaders, q as API_URL, L as castArrayObjectDates, H as castObjectDates, a5 as getShortTime, J as JobStatus } from './index-DkNQs11R.js';
9
+ import 'crypto-js';
10
+ import 'uuid';
11
+ import 'fs';
12
+ import { DateTime } from 'luxon';
13
+ import 'fast-glob';
14
+ import 'yazl';
15
+ import 'socket.io-client';
16
+ import 'crypto';
17
+ import 'readline-sync';
18
+ import 'node:readline';
19
+ import 'node:path';
20
+ import 'node:url';
21
+ import 'isomorphic-git';
22
+ import '@oclif/core';
23
+ import { c as cacheKeys } from './useAndroidServiceAccountTestResult-DcYDam-p.js';
24
+ import { u as useWebSocket } from './useWebSocket-ByuNoqRw.js';
25
+ import { T as Title } from './Title-BCQtayg6.js';
26
+ import stringLength from 'string-length';
27
+ import stripAnsi from 'strip-ansi';
28
+ import { a as getJobSummary } from './index-nnzhQ3nY.js';
29
+ import { u as useJobWatching } from './useJobWatching--BvVn7xS.js';
30
+ import { a as StatusRow, b as StatusRowLabel } from './StatusTable-Dm5St4g-.js';
31
+
32
+ function arrayToDictionary(array, key = "id") {
33
+ return array.reduce((a, i) => {
34
+ a[i[key]] = i;
35
+ return a;
36
+ }, {});
37
+ }
38
+ function dictionaryToArray(dictionary) {
39
+ return Object.keys(dictionary).map((key) => dictionary[key]);
40
+ }
41
+
42
+ async function queryJobLogs({
43
+ projectId,
44
+ jobId,
45
+ cursor,
46
+ pageSize = 10
47
+ }) {
48
+ try {
49
+ const headers = getAuthedHeaders();
50
+ const base = `${API_URL}/projects/${projectId}/jobs/${jobId}/logs/?pageSize=${pageSize}`;
51
+ const url = base + (cursor ? `&cursor=${cursor}` : "");
52
+ const response = await axios.get(url, { headers });
53
+ return {
54
+ ...response.data,
55
+ data: castArrayObjectDates(response.data.data, ["sentAt", "createdAt"])
56
+ };
57
+ } catch (error) {
58
+ console.warn("queryJobLogs Error", error);
59
+ throw error;
60
+ }
61
+ }
62
+ const useJobLogs = (props) => {
63
+ const queryResult = useInfiniteQuery({
64
+ queryKey: cacheKeys.jobLogs(props),
65
+ queryFn: async ({ pageParam }) => {
66
+ return queryJobLogs({
67
+ ...props,
68
+ cursor: pageParam
69
+ });
70
+ },
71
+ getNextPageParam: (lastPage) => lastPage.nextCursor,
72
+ initialPageParam: props.cursor
73
+ });
74
+ return queryResult;
75
+ };
76
+
77
+ function getSortedJobLogs(logs) {
78
+ return logs.sort((a, b) => a.sentAt.toMillis() - b.sentAt.toMillis());
79
+ }
80
+ function useJobLogTail(props) {
81
+ const [websocketLogs, setWebsocketLogs] = useState([]);
82
+ const listener = {
83
+ getPattern: () => `project.${props.projectId}:job.${props.jobId}:log`,
84
+ eventHandler: async (pattern, rawLogEntry) => {
85
+ setWebsocketLogs((prevLogs) => {
86
+ const logEntry = castObjectDates(rawLogEntry, ["sentAt", "createdAt"]);
87
+ return [...prevLogs, logEntry];
88
+ });
89
+ }
90
+ };
91
+ useWebSocket(props.isWatching ? [listener] : []);
92
+ const { isLoading, data: fetchedJobLogs } = useJobLogs({
93
+ projectId: props.projectId,
94
+ jobId: props.jobId,
95
+ pageSize: props.length
96
+ });
97
+ useEffect(() => {
98
+ setWebsocketLogs([]);
99
+ }, [props.jobId, props.projectId, props.length, props.isWatching, fetchedJobLogs]);
100
+ const firstPage = fetchedJobLogs ? fetchedJobLogs?.pages[0].data : [];
101
+ const allLogs = [...firstPage, ...websocketLogs];
102
+ const allLogsById = arrayToDictionary(allLogs);
103
+ const uniqueLogs = dictionaryToArray(allLogsById);
104
+ const data = getSortedJobLogs(uniqueLogs).slice(-props.length);
105
+ return {
106
+ isLoading,
107
+ data
108
+ };
109
+ }
110
+
111
+ const TruncatedText = ({ children, wrap, ...textPropsWithoutWrap }) => {
112
+ const ref = useRef();
113
+ const [width, setWidth] = useState(null);
114
+ useEffect(() => {
115
+ if (!ref.current) return;
116
+ const { width: measuredWidth } = measureElement(ref.current);
117
+ setWidth(measuredWidth);
118
+ }, []);
119
+ const getTruncated = (input) => {
120
+ const withoutCrlf = input.replaceAll(/[\r\n]/g, "");
121
+ if (width === null) return withoutCrlf;
122
+ const withoutAnsi = stripAnsi(withoutCrlf);
123
+ const textLength = stringLength(withoutAnsi);
124
+ return textLength > width ? withoutCrlf.substring(0, width) : withoutCrlf;
125
+ };
126
+ return /* @__PURE__ */ jsx(Box, { ref, children: /* @__PURE__ */ jsx(Text, { ...textPropsWithoutWrap, children: getTruncated(children) + "\x1B[0m" }) });
127
+ };
128
+
129
+ const JobLogTail = (props) => {
130
+ const { isLoading, data } = useJobLogTail(props);
131
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
132
+ /* @__PURE__ */ jsx(Title, { children: "Job Logs" }),
133
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
134
+ /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: data.map((log) => {
135
+ const stageColor = getStageColor(log.stage);
136
+ const messageColor = getMessageColor(log.level);
137
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", overflow: "hidden", height: 1, children: [
138
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: getShortTime(log.sentAt) }) }),
139
+ /* @__PURE__ */ jsx(Box, { marginLeft: 1, width: 9, justifyContent: "flex-start", children: /* @__PURE__ */ jsx(Text, { color: stageColor, children: log.stage }) }),
140
+ /* @__PURE__ */ jsx(Box, { marginLeft: 1, overflow: "hidden", height: 1, marginRight: 2, children: /* @__PURE__ */ jsx(TruncatedText, { color: messageColor, children: log.message }) })
141
+ ] }, log.id);
142
+ }) })
143
+ ] });
144
+ };
145
+
146
+ const JobStatusSpinner = ({ status, showSpinner }) => /* @__PURE__ */ jsxs(Fragment, { children: [
147
+ /* @__PURE__ */ jsx(Box, { width: JobStatus.PROCESSING.length, children: /* @__PURE__ */ jsx(Text, { color: getJobStatusColor(status), children: `${status}` }) }),
148
+ showSpinner && /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ /* @__PURE__ */ jsx(Text, { children: " " }),
150
+ /* @__PURE__ */ jsx(Spinner, { type: "dots" })
151
+ ] })
152
+ ] });
153
+ const JobStatusTable = ({ jobId, projectId, isWatching, onJobUpdate }) => {
154
+ const { data: job, stage, isLoading } = useJobWatching({ projectId, jobId, isWatching, onJobUpdate });
155
+ const [time, setTime] = useState(DateTime.now());
156
+ useEffect(() => {
157
+ if (!isWatching) return;
158
+ const interval = setInterval(() => setTime(DateTime.now()), 1e3);
159
+ return () => {
160
+ clearInterval(interval);
161
+ };
162
+ }, []);
163
+ const isJobInProgress = job && ![JobStatus.COMPLETED, JobStatus.FAILED].includes(job.status);
164
+ const summary = job ? getJobSummary(job, time) : null;
165
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "row", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
166
+ /* @__PURE__ */ jsx(Title, { children: "Job Details" }),
167
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
168
+ summary && job && /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
169
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [
170
+ /* @__PURE__ */ jsx(StatusRow, { label: "ID", value: summary.id }),
171
+ /* @__PURE__ */ jsx(StatusRow, { label: "Platform", value: summary.platform }),
172
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
173
+ /* @__PURE__ */ jsx(StatusRowLabel, { label: "Status" }),
174
+ /* @__PURE__ */ jsx(JobStatusSpinner, { status: job.status, showSpinner: isWatching && !!isJobInProgress })
175
+ ] }),
176
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
177
+ /* @__PURE__ */ jsx(StatusRowLabel, { label: "Stage" }),
178
+ stage && /* @__PURE__ */ jsx(Text, { color: getStageColor(stage), children: `${stage}` })
179
+ ] })
180
+ ] }),
181
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [
182
+ /* @__PURE__ */ jsx(StatusRow, { label: "Version", value: summary.version }),
183
+ /* @__PURE__ */ jsx(StatusRow, { label: "Git Info", value: summary.gitInfo }),
184
+ /* @__PURE__ */ jsx(StatusRow, { label: "Started At", value: summary.createdAt }),
185
+ /* @__PURE__ */ jsx(StatusRow, { label: "Runtime", value: summary.runtime })
186
+ ] })
187
+ ] })
188
+ ] }) });
189
+ };
190
+
191
+ export { JobStatusTable as J, JobLogTail as a };
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Box, Text } from 'ink';
3
+ import { T as Title } from './Title-BCQtayg6.js';
4
+
5
+ const ListWithTitle = ({ listItems, title }) => {
6
+ if (listItems.length === 0) return null;
7
+ const header = title.toUpperCase();
8
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
9
+ /* @__PURE__ */ jsx(Title, { children: header }),
10
+ /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginLeft: 2, children: listItems.map((listItem, index) => /* @__PURE__ */ jsx(Text, { children: listItem }, index)) })
11
+ ] });
12
+ };
13
+
14
+ const NextSteps = ({ steps }) => {
15
+ return /* @__PURE__ */ jsx(ListWithTitle, { listItems: steps, title: "Next Steps" });
16
+ };
17
+
18
+ export { NextSteps as N };
@@ -0,0 +1,16 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { ProgressBar } from '@inkjs/ui';
3
+ import { Box, Text } from 'ink';
4
+ import Spinner from 'ink-spinner';
5
+
6
+ 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: [
7
+ label && label != "" && /* @__PURE__ */ jsx(Text, { ...labelProps, children: label }),
8
+ /* @__PURE__ */ jsx(ProgressBar, { value: progress || 0 }),
9
+ /* @__PURE__ */ jsx(Box, { width: 4, children: /* @__PURE__ */ jsxs(Text, { children: [
10
+ Math.floor(progress || 0),
11
+ "%"
12
+ ] }) }),
13
+ /* @__PURE__ */ jsx(Spinner, { type: spinnerType })
14
+ ] }) }) });
15
+
16
+ export { ProgressSpinner as P };
@@ -0,0 +1,37 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Box, Text } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
+ import 'crypto';
5
+ import 'fs';
6
+ import 'readline-sync';
7
+ import 'node:readline';
8
+ import 'node:path';
9
+ import 'node:url';
10
+ import 'luxon';
11
+ import 'axios';
12
+ import 'isomorphic-git';
13
+ import './index-DkNQs11R.js';
14
+ import '@oclif/core';
15
+ import 'react';
16
+ import '@tanstack/react-query';
17
+ import 'crypto-js';
18
+ import 'uuid';
19
+ import { u as useProjectCredentials, g as getProjectCredentialSummary } from './useProjectCredentials-Btnr7WK3.js';
20
+ import 'fast-glob';
21
+ import 'yazl';
22
+ import 'socket.io-client';
23
+ import { T as Table } from './Table-CvM6pccN.js';
24
+ import { T as Title } from './Title-BCQtayg6.js';
25
+
26
+ const ProjectCredentialsTable = ({ credentialTypeName, queryProps, ...boxProps }) => {
27
+ const { isLoading, data } = useProjectCredentials(queryProps);
28
+ const hasActive = data?.data.some((credential) => credential.isActive);
29
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, ...boxProps, children: [
30
+ /* @__PURE__ */ jsx(Title, { children: `${credentialTypeName}s in your ShipThis account` }),
31
+ /* @__PURE__ */ jsx(Box, { marginLeft: 2, marginBottom: 1, flexDirection: "column", children: /* @__PURE__ */ jsx(Text, { children: hasActive ? `You have an active ${credentialTypeName} in your ShipThis account.` : `You DO NOT have an active ${credentialTypeName} which ShipThis can use.` }) }),
32
+ isLoading && /* @__PURE__ */ jsx(Spinner, { type: "dots" }),
33
+ data && data.data.length > 0 && /* @__PURE__ */ jsx(Table, { data: data.data.map(getProjectCredentialSummary) })
34
+ ] });
35
+ };
36
+
37
+ export { ProjectCredentialsTable as P };