@shopify/shop-minis-cli 0.0.42 → 0.0.44
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/build/commands/cancel-submission/cancel-submission.js +3 -2
- package/build/commands/cancel-submission/cancel-submission.js.map +1 -1
- package/build/commands/check-submission/index.js +39 -6
- package/build/commands/check-submission/index.js.map +1 -1
- package/build/commands/check-submission/types.d.ts +1 -1
- package/build/commands/config.d.ts +5 -0
- package/build/commands/config.js +20 -0
- package/build/commands/config.js.map +1 -1
- package/build/commands/data/cancel-submission.d.ts +22 -0
- package/build/commands/data/cancel-submission.js +26 -0
- package/build/commands/data/cancel-submission.js.map +1 -0
- package/build/commands/data/client.d.ts +7 -0
- package/build/commands/data/client.js +8 -0
- package/build/commands/data/client.js.map +1 -0
- package/build/commands/data/create-submission.d.ts +20 -0
- package/build/commands/data/create-submission.js +27 -0
- package/build/commands/data/create-submission.js.map +1 -0
- package/build/commands/data/create-upload.d.ts +21 -0
- package/build/commands/data/create-upload.js +40 -0
- package/build/commands/data/create-upload.js.map +1 -0
- package/build/commands/data/get-submissions.d.ts +27 -0
- package/build/commands/data/get-submissions.js +33 -0
- package/build/commands/data/get-submissions.js.map +1 -0
- package/build/commands/dev/index.d.ts +2 -0
- package/build/commands/dev/index.js +8 -2
- package/build/commands/dev/index.js.map +1 -1
- package/build/commands/dev/utils/android.d.ts +6 -4
- package/build/commands/dev/utils/android.js +29 -29
- package/build/commands/dev/utils/android.js.map +1 -1
- package/build/commands/dev/utils/binaries.d.ts +2 -59
- package/build/commands/dev/utils/binaries.js +7 -84
- package/build/commands/dev/utils/binaries.js.map +1 -1
- package/build/commands/dev/utils/build-type.d.ts +2 -0
- package/build/commands/dev/utils/build-type.js +14 -0
- package/build/commands/dev/utils/build-type.js.map +1 -0
- package/build/commands/dev/utils/deeplink.d.ts +2 -2
- package/build/commands/dev/utils/deeplink.js +5 -5
- package/build/commands/dev/utils/deeplink.js.map +1 -1
- package/build/commands/dev/utils/interactive-terminal.d.ts +3 -1
- package/build/commands/dev/utils/interactive-terminal.js +37 -78
- package/build/commands/dev/utils/interactive-terminal.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-server.d.ts +1 -1
- package/build/commands/dev/utils/metro/metro-server.js +1 -1
- package/build/commands/dev/utils/metro/metro-server.js.map +1 -1
- package/build/commands/dev/utils/network.d.ts +8 -8
- package/build/commands/dev/utils/network.js +69 -23
- package/build/commands/dev/utils/network.js.map +1 -1
- package/build/commands/dev/utils/patch-package.d.ts +4 -0
- package/build/commands/dev/utils/patch-package.js +72 -0
- package/build/commands/dev/utils/patch-package.js.map +1 -0
- package/build/commands/dev/utils/platform.d.ts +18 -0
- package/build/commands/dev/utils/platform.js +41 -0
- package/build/commands/dev/utils/platform.js.map +1 -0
- package/build/commands/dev/utils/simulator.d.ts +5 -2
- package/build/commands/dev/utils/simulator.js +27 -13
- package/build/commands/dev/utils/simulator.js.map +1 -1
- package/build/commands/dev/utils/start-app.d.ts +23 -0
- package/build/commands/dev/utils/start-app.js +85 -0
- package/build/commands/dev/utils/start-app.js.map +1 -0
- package/build/commands/dev/utils/types.d.ts +24 -1
- package/build/commands/dev/utils/types.js +6 -1
- package/build/commands/dev/utils/types.js.map +1 -1
- package/build/commands/dev/utils/version.d.ts +64 -0
- package/build/commands/dev/utils/version.js +101 -0
- package/build/commands/dev/utils/version.js.map +1 -0
- package/build/commands/submit/errors.d.ts +1 -1
- package/build/commands/submit/errors.js +1 -1
- package/build/commands/submit/errors.js.map +1 -1
- package/build/commands/submit/submit.js +2 -1
- package/build/commands/submit/submit.js.map +1 -1
- package/build/commands/submit/tasks.d.ts +0 -1
- package/build/commands/submit/tasks.js +4 -48
- package/build/commands/submit/tasks.js.map +1 -1
- package/build/commands/types/autogenerated/shop-minis-admin-api/gql.d.ts +9 -9
- package/build/commands/types/autogenerated/shop-minis-admin-api/gql.js +2 -2
- package/build/commands/types/autogenerated/shop-minis-admin-api/gql.js.map +1 -1
- package/build/commands/types/autogenerated/shop-minis-admin-api/graphql.d.ts +301 -65
- package/build/commands/types/autogenerated/shop-minis-admin-api/graphql.js +155 -97
- package/build/commands/types/autogenerated/shop-minis-admin-api/graphql.js.map +1 -1
- package/build/commands/utils/common-tasks.d.ts +1 -0
- package/build/commands/utils/common-tasks.js +49 -0
- package/build/commands/utils/common-tasks.js.map +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/jest.config.ts +2 -2
- package/package.json +3 -1
- package/templates/__template_common/.eslintrc.js +29 -0
- package/templates/__template_common/index.tsx +0 -2
- package/templates/__template_common/package.json +4 -33
- package/templates/__template_common/patches/react-native+0.71.4.patch +78 -0
- package/templates/__template_common/src/manifest.json +1 -27
- package/templates/__template_hello_world/src/components/ComponentLink.ts +4 -0
- package/templates/__template_hello_world/src/components/ComponentListItem.tsx +1 -0
- package/templates/__template_hello_world/src/components/FeaturedComponents.tsx +2 -0
- package/templates/__template_hello_world/src/components/quiz/QuizSlide.tsx +6 -3
- package/templates/__template_hello_world/src/components/quiz/TextFieldSlide.tsx +88 -7
- package/templates/__template_hello_world/src/routes.tsx +6 -0
- package/templates/__template_hello_world/src/screens/AccordionScreen.tsx +73 -0
- package/templates/__template_hello_world/src/screens/InputScreen.tsx +4 -10
- package/templates/__template_hello_world/src/types.ts +1 -0
- package/templates/__template_hello_world/src/utils/mockQuizData.ts +19 -0
- package/build/commands/utils/graphql.d.ts +0 -92
- package/build/commands/utils/graphql.js +0 -123
- package/build/commands/utils/graphql.js.map +0 -1
- package/templates/__template_common/.eslintrc.json +0 -15
- package/templates/__template_common/patches/react-native+0.68.5.patch +0 -173
|
@@ -1,62 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Returns the file extension used for each platform.
|
|
4
|
-
* android: .apk
|
|
5
|
-
* ios: .zip (we intentionally compress .app files before uploading them to the cloud storage)
|
|
6
|
-
*/
|
|
7
|
-
export declare function getBinaryFileExtensionForPlatform(platform: Platform): ".zip" | ".apk";
|
|
8
|
-
/**
|
|
9
|
-
* @example
|
|
10
|
-
* platform android
|
|
11
|
-
* version 2.76.0
|
|
12
|
-
* returns "2-76-0.apk"
|
|
13
|
-
*
|
|
14
|
-
* platform ios
|
|
15
|
-
* version 2.55.0+4
|
|
16
|
-
* returns "2-55-0+4.zip"
|
|
17
|
-
*/
|
|
18
|
-
export declare function versionToBinaryFileName(version: string, platform: Platform): string;
|
|
19
|
-
/**
|
|
20
|
-
* @example
|
|
21
|
-
* binaryFileName "2-76-0.apk"
|
|
22
|
-
* returns "2.76.0"
|
|
23
|
-
*
|
|
24
|
-
* binaryFileName "2-16-0+3.zip"
|
|
25
|
-
* returns "2.16.0+3"
|
|
26
|
-
*/
|
|
27
|
-
export declare function binaryFileNameToVersion(binaryFileName: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* @example
|
|
30
|
-
* filenames ["2-76-0+3.apk", "2-76-0+3.zip", "2-77-0.apk", "2-77-0.zip", "2-77-0+1.apk", "2-77-0+1.zip"]
|
|
31
|
-
* returns "2.77.0+1"
|
|
32
|
-
*/
|
|
33
|
-
export declare function getLatestVersionFromFilesList(filenames: string[]): string | null;
|
|
1
|
+
import { BinaryMetadata } from './types.js';
|
|
34
2
|
/**
|
|
35
3
|
* Returns a boolean indicating if the binary for the given version and platform is already downloaded in the system
|
|
36
4
|
*/
|
|
37
|
-
export declare function isVersionAvailableLocally(
|
|
38
|
-
/**
|
|
39
|
-
* Gets the biggest version in the downloads folder for the given platform.
|
|
40
|
-
*/
|
|
41
|
-
export declare function getLatestDownloadedVersion(platform: Platform): Promise<string | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Compares the current version against the latest available version.
|
|
44
|
-
*
|
|
45
|
-
* Does nothing if the current version is already the latest.
|
|
46
|
-
* Otherwise prompts the user to download the new version.
|
|
47
|
-
*/
|
|
48
|
-
export declare function maybePromptBinaryUpgrade(platform: Platform, { currentVersion, onProgress, onDownloadStart, }?: {
|
|
49
|
-
/**
|
|
50
|
-
* The version that's currently being used.
|
|
51
|
-
* Defaults to the bigger version in the downloads folder.
|
|
52
|
-
*/
|
|
53
|
-
currentVersion?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Download progress callback
|
|
56
|
-
*/
|
|
57
|
-
onProgress?: (progress: number) => void;
|
|
58
|
-
/**
|
|
59
|
-
* Callback executed if the user agrees to update, before starting the download.
|
|
60
|
-
*/
|
|
61
|
-
onDownloadStart?: (version: string) => void;
|
|
62
|
-
}): Promise<string | null>;
|
|
5
|
+
export declare function isVersionAvailableLocally(version: BinaryMetadata): Promise<boolean>;
|
|
@@ -1,94 +1,17 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import { compareBuild as semverCompare, valid as isValidSemver } from 'semver';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
import prompts from 'prompts';
|
|
5
2
|
import { PATHS } from '../../config.js';
|
|
6
|
-
import {
|
|
7
|
-
/**
|
|
8
|
-
* Returns the file extension used for each platform.
|
|
9
|
-
* android: .apk
|
|
10
|
-
* ios: .zip (we intentionally compress .app files before uploading them to the cloud storage)
|
|
11
|
-
*/
|
|
12
|
-
export function getBinaryFileExtensionForPlatform(platform) {
|
|
13
|
-
return platform === 'ios' ? '.zip' : '.apk';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @example
|
|
17
|
-
* platform android
|
|
18
|
-
* version 2.76.0
|
|
19
|
-
* returns "2-76-0.apk"
|
|
20
|
-
*
|
|
21
|
-
* platform ios
|
|
22
|
-
* version 2.55.0+4
|
|
23
|
-
* returns "2-55-0+4.zip"
|
|
24
|
-
*/
|
|
25
|
-
export function versionToBinaryFileName(version, platform) {
|
|
26
|
-
return (version.replace(/\./g, '-') + getBinaryFileExtensionForPlatform(platform));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @example
|
|
30
|
-
* binaryFileName "2-76-0.apk"
|
|
31
|
-
* returns "2.76.0"
|
|
32
|
-
*
|
|
33
|
-
* binaryFileName "2-16-0+3.zip"
|
|
34
|
-
* returns "2.16.0+3"
|
|
35
|
-
*/
|
|
36
|
-
export function binaryFileNameToVersion(binaryFileName) {
|
|
37
|
-
return binaryFileName.split('.')[0].replace(/-/g, '.');
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @example
|
|
41
|
-
* filenames ["2-76-0+3.apk", "2-76-0+3.zip", "2-77-0.apk", "2-77-0.zip", "2-77-0+1.apk", "2-77-0+1.zip"]
|
|
42
|
-
* returns "2.77.0+1"
|
|
43
|
-
*/
|
|
44
|
-
export function getLatestVersionFromFilesList(filenames) {
|
|
45
|
-
const localVersions = _.uniq(filenames
|
|
46
|
-
.map(binaryFileNameToVersion)
|
|
47
|
-
.filter(version => isValidSemver(version)));
|
|
48
|
-
localVersions.sort(semverCompare);
|
|
49
|
-
const last = localVersions.slice(-1)[0];
|
|
50
|
-
return last ?? null;
|
|
51
|
-
}
|
|
3
|
+
import { metadataToBinaryFileName } from './version.js';
|
|
52
4
|
/**
|
|
53
5
|
* Returns a boolean indicating if the binary for the given version and platform is already downloaded in the system
|
|
54
6
|
*/
|
|
55
|
-
export async function isVersionAvailableLocally(
|
|
7
|
+
export async function isVersionAvailableLocally(version) {
|
|
56
8
|
const localBinariesList = await fs.readdir(PATHS.CACHE_DIR);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Gets the biggest version in the downloads folder for the given platform.
|
|
62
|
-
*/
|
|
63
|
-
export async function getLatestDownloadedVersion(platform) {
|
|
64
|
-
const localBinariesList = await fs.readdir(PATHS.CACHE_DIR);
|
|
65
|
-
const localBinariesForPlatform = localBinariesList.filter(name => name.endsWith(getBinaryFileExtensionForPlatform(platform)));
|
|
66
|
-
return getLatestVersionFromFilesList(localBinariesForPlatform);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Compares the current version against the latest available version.
|
|
70
|
-
*
|
|
71
|
-
* Does nothing if the current version is already the latest.
|
|
72
|
-
* Otherwise prompts the user to download the new version.
|
|
73
|
-
*/
|
|
74
|
-
export async function maybePromptBinaryUpgrade(platform, { currentVersion, onProgress, onDownloadStart, } = {}) {
|
|
75
|
-
const _currentVersion = currentVersion || (await getLatestDownloadedVersion(platform));
|
|
76
|
-
const latestVersion = await getLatestRemoteVersion(platform);
|
|
77
|
-
if (latestVersion === _currentVersion) {
|
|
78
|
-
// returns early if user is already on latest version
|
|
79
|
-
return null;
|
|
9
|
+
try {
|
|
10
|
+
const fileName = metadataToBinaryFileName(version);
|
|
11
|
+
return localBinariesList.includes(fileName);
|
|
80
12
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
initial: true,
|
|
84
|
-
name: 'shouldUpdate',
|
|
85
|
-
message: "There's a new version of Shop available. Do you want to upgrade?",
|
|
86
|
-
});
|
|
87
|
-
if (shouldUpdate) {
|
|
88
|
-
onDownloadStart?.(latestVersion);
|
|
89
|
-
await downloadBinary(platform, { version: latestVersion, onProgress });
|
|
90
|
-
return latestVersion;
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
91
15
|
}
|
|
92
|
-
return null;
|
|
93
16
|
}
|
|
94
17
|
//# sourceMappingURL=binaries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binaries.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/binaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"binaries.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/binaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAGrC,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAAuB;IACrE,MAAM,iBAAiB,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAC3D,IAAI;QACF,MAAM,QAAQ,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;QAElD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAC5C;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BuildType } from './types.js';
|
|
2
|
+
export function getBuildTypeForBinaryBuildType(type) {
|
|
3
|
+
switch (type) {
|
|
4
|
+
case 'release':
|
|
5
|
+
return BuildType.Release;
|
|
6
|
+
case 'nightly':
|
|
7
|
+
return BuildType.Nightly;
|
|
8
|
+
case 'snapshot':
|
|
9
|
+
return BuildType.Snapshot;
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`Invalid build type: ${type}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=build-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-type.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/build-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AAEpC,MAAM,UAAU,8BAA8B,CAAC,IAAY;IACzD,QAAQ,IAAI,EAAE;QACZ,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,OAAO,CAAA;QAC1B,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,OAAO,CAAA;QAC1B,KAAK,UAAU;YACb,OAAO,SAAS,CAAC,QAAQ,CAAA;QAC3B;YACE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAA;KACjD;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DevCommandOptions } from '../index.js';
|
|
2
|
-
export declare function getBundleUrl({ host }: DevCommandOptions):
|
|
3
|
-
export declare function getDeeplink(miniHandle: string, options: DevCommandOptions, universalLink?: boolean):
|
|
2
|
+
export declare function getBundleUrl({ host }: DevCommandOptions): string;
|
|
3
|
+
export declare function getDeeplink(miniHandle: string, options: DevCommandOptions, universalLink?: boolean): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
export
|
|
2
|
+
export function getBundleUrl({ host }) {
|
|
3
3
|
return `http://${host}:8082/index.bundle`;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
const bundleUrl =
|
|
5
|
+
function getDeeplinkParams(miniHandle, options) {
|
|
6
|
+
const bundleUrl = getBundleUrl(options);
|
|
7
7
|
const params = {
|
|
8
8
|
handle: miniHandle,
|
|
9
9
|
bundleUrl: encodeURIComponent(bundleUrl),
|
|
@@ -45,8 +45,8 @@ function getDevelopmentEntryPointParams() {
|
|
|
45
45
|
return '';
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
export
|
|
49
|
-
const deeplinkParams =
|
|
48
|
+
export function getDeeplink(miniHandle, options, universalLink = false) {
|
|
49
|
+
const deeplinkParams = getDeeplinkParams(miniHandle, options);
|
|
50
50
|
const developmentParams = getDevelopmentEntryPointParams();
|
|
51
51
|
if (universalLink) {
|
|
52
52
|
return `https://shop.app/mini/remote/${deeplinkParams}${developmentParams}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deeplink.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/deeplink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAIzC,MAAM,
|
|
1
|
+
{"version":3,"file":"deeplink.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/deeplink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAIzC,MAAM,UAAU,YAAY,CAAC,EAAC,IAAI,EAAoB;IACpD,OAAO,UAAU,IAAI,oBAAoB,CAAA;AAC3C,CAAC;AAED,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,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;KACxD;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,GAAG,EAAE,IAAI,KAAK,kBAAkB,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC9D,OAAO,CAAC,GAAG,CACT,gEAAgE,CACjE,CAAA;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;SAClB;QACD,sFAAsF;QACtF,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,UAAkB,EAClB,OAA0B,EAC1B,aAAa,GAAG,KAAK;IAErB,MAAM,cAAc,GAAG,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAC7D,MAAM,iBAAiB,GAAG,8BAA8B,EAAE,CAAA;IAE1D,IAAI,aAAa,EAAE;QACjB,OAAO,gCAAgC,cAAc,GAAG,iBAAiB,EAAE,CAAA;KAC5E;SAAM;QACL,OAAO,wBAAwB,cAAc,GAAG,iBAAiB,EAAE,CAAA;KACpE;AACH,CAAC"}
|
|
@@ -18,6 +18,8 @@ export declare class InteractiveTerminal {
|
|
|
18
18
|
loadingEnd(endState?: 'succeed' | 'fail' | 'warn' | 'info', logMessage?: string): void;
|
|
19
19
|
handleKeyPress: (key: string) => Promise<void>;
|
|
20
20
|
showSetupAndroidHomeInstructions(): Promise<void>;
|
|
21
|
-
startAndroidApp(deviceId: string): Promise<void>;
|
|
22
21
|
printDeeplinkQRCode(): Promise<void>;
|
|
22
|
+
private startApp;
|
|
23
|
+
private get deeplink();
|
|
24
|
+
private get loadingHandlers();
|
|
23
25
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import ora from 'ora';
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
import open from 'open';
|
|
4
|
-
import
|
|
3
|
+
import ora from 'ora';
|
|
5
4
|
import { DEV_PANEL_BASE_URL } from '../../../dev-panel/middleware.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { getMiniManifest } from '../../utils/minis-manifest.js';
|
|
6
|
+
import { androidHomeExists } from '../../config.js';
|
|
7
|
+
import { maybeLaunchEmulator, promptForAndroidDevices } from './android.js';
|
|
9
8
|
import { getBundleUrl, getDeeplink } from './deeplink.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { printQRCode } from './qr-code.js';
|
|
10
|
+
import { bootSimulator, promptForSimulator } from './simulator.js';
|
|
11
|
+
import { startApp } from './start-app.js';
|
|
12
|
+
import { Platform } from './platform.js';
|
|
12
13
|
const { stdin } = process;
|
|
13
14
|
function clearTerminal() {
|
|
14
15
|
process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
|
|
@@ -115,10 +116,10 @@ export class InteractiveTerminal {
|
|
|
115
116
|
this.loadingEnd('fail', `Couldn't launch emulator ${device.name}`);
|
|
116
117
|
break;
|
|
117
118
|
}
|
|
118
|
-
await this.
|
|
119
|
+
await this.startApp(Platform.Android, emulatorId);
|
|
119
120
|
}
|
|
120
121
|
else {
|
|
121
|
-
await this.
|
|
122
|
+
await this.startApp(Platform.Android, device.name);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
else {
|
|
@@ -135,37 +136,7 @@ export class InteractiveTerminal {
|
|
|
135
136
|
if (simulator) {
|
|
136
137
|
this.loadingStart('Launching simulator');
|
|
137
138
|
await bootSimulator(simulator.udid);
|
|
138
|
-
|
|
139
|
-
if (installedShopVersion) {
|
|
140
|
-
this.loadingEnd();
|
|
141
|
-
// We assume that the version being used in the simulator matches the biggest version in the downloads folder
|
|
142
|
-
// because version returned by the simulator does not include build numbers.
|
|
143
|
-
const upgradedVersion = await maybePromptBinaryUpgrade('ios', {
|
|
144
|
-
onDownloadStart: () => {
|
|
145
|
-
this.loadingStart('Downloading Shop (0%)');
|
|
146
|
-
},
|
|
147
|
-
onProgress: progress => {
|
|
148
|
-
this._loading.text = `Downloading Shop (${progress}%)`;
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
if (upgradedVersion) {
|
|
152
|
-
this.loadingStart('Installing Shop');
|
|
153
|
-
await installShopInSimulator(simulator.udid, upgradedVersion);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.loadingStart('Downloading Shop (0%)');
|
|
158
|
-
const downloadedVersion = await downloadBinary('ios', {
|
|
159
|
-
onProgress: progress => {
|
|
160
|
-
this._loading.text = `Downloading Shop (${progress}%)`;
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
this.loadingStart('Installing Shop\n ↪ You can skip onboarding, or log in with your existing Shop account (optional).');
|
|
164
|
-
await installShopInSimulator(simulator.udid, downloadedVersion);
|
|
165
|
-
}
|
|
166
|
-
this.loadingStart('Opening Shop');
|
|
167
|
-
await deeplinkToSimulator(simulator.udid, await getDeeplink(this.miniHandle, this.options));
|
|
168
|
-
this.loadingEnd();
|
|
139
|
+
await this.startApp(Platform.IOS, simulator.udid);
|
|
169
140
|
}
|
|
170
141
|
else {
|
|
171
142
|
console.log('\nNo simulator was selected\n');
|
|
@@ -178,10 +149,10 @@ export class InteractiveTerminal {
|
|
|
178
149
|
}
|
|
179
150
|
case 'd': {
|
|
180
151
|
// TODO: Should we send these as params? or should the dev panel website already know how to fetch them without the need of query params?
|
|
181
|
-
//
|
|
152
|
+
// Advantage would be that people could just type the base url in the browser whenever they want to open the dev panel. That's impossible with the query params being required
|
|
182
153
|
const paramsObj = {
|
|
183
|
-
bundleUrl:
|
|
184
|
-
deepLink:
|
|
154
|
+
bundleUrl: getBundleUrl(this.options),
|
|
155
|
+
deepLink: getDeeplink(this.miniHandle, this.options, true),
|
|
185
156
|
};
|
|
186
157
|
const searchParams = `?${new URLSearchParams(paramsObj).toString()}`;
|
|
187
158
|
open(`${DEV_PANEL_BASE_URL}${searchParams}`);
|
|
@@ -203,44 +174,32 @@ export class InteractiveTerminal {
|
|
|
203
174
|
console.log(`See ${chalk.blue.underline.bold('https://developer.android.com/studio/command-line/variables')}`);
|
|
204
175
|
await this.waitForAnyKeyAndPrintInstructions();
|
|
205
176
|
}
|
|
206
|
-
async startAndroidApp(deviceId) {
|
|
207
|
-
const installedShopVersion = await getInstalledShopVersionAndroid(deviceId);
|
|
208
|
-
if (installedShopVersion) {
|
|
209
|
-
this.loadingEnd();
|
|
210
|
-
// We assume that the version being used in the emulator matches the biggest version in the downloads folder
|
|
211
|
-
// because version returned by the emulator does not include build numbers.
|
|
212
|
-
const upgradedVersion = await maybePromptBinaryUpgrade('android', {
|
|
213
|
-
onDownloadStart: () => {
|
|
214
|
-
this.loadingStart('Downloading Shop (0%)');
|
|
215
|
-
},
|
|
216
|
-
onProgress: progress => {
|
|
217
|
-
this._loading.text = `Downloading Shop (${progress}%)`;
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
if (upgradedVersion) {
|
|
221
|
-
this.loadingStart('Installing Shop');
|
|
222
|
-
await installShopInEmulator(deviceId, upgradedVersion);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
this.loadingStart('Downloading Shop (0%)');
|
|
227
|
-
const downloadedVersion = await downloadBinary('android', {
|
|
228
|
-
onProgress: progress => {
|
|
229
|
-
this._loading.text = `Downloading Shop (${progress}%)`;
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
this.loadingStart('Installing Shop\n ↪ You can skip onboarding, or log in with your existing Shop account (optional).');
|
|
233
|
-
await installShopInEmulator(deviceId, downloadedVersion);
|
|
234
|
-
}
|
|
235
|
-
this.loadingStart('Opening Shop');
|
|
236
|
-
await connectDevelopmentServer(deviceId);
|
|
237
|
-
await deeplinkToEmulator(deviceId, await getDeeplink(this.miniHandle, this.options));
|
|
238
|
-
this.loadingEnd();
|
|
239
|
-
}
|
|
240
177
|
async printDeeplinkQRCode() {
|
|
241
178
|
console.log('\n');
|
|
242
|
-
await printQRCode(
|
|
179
|
+
await printQRCode(getDeeplink(this.miniHandle, this.options, true));
|
|
243
180
|
console.log('Scan the QR code to open Shop Mini on your device (requires the Shop app to be installed)\n');
|
|
244
181
|
}
|
|
182
|
+
async startApp(platform, deviceId) {
|
|
183
|
+
await startApp({
|
|
184
|
+
platform,
|
|
185
|
+
deviceId,
|
|
186
|
+
deeplink: this.deeplink,
|
|
187
|
+
type: this.options.buildType,
|
|
188
|
+
}, this.loadingHandlers);
|
|
189
|
+
}
|
|
190
|
+
get deeplink() {
|
|
191
|
+
return getDeeplink(this.miniHandle, this.options);
|
|
192
|
+
}
|
|
193
|
+
get loadingHandlers() {
|
|
194
|
+
return {
|
|
195
|
+
onLoadingStart: this.loadingStart.bind(this),
|
|
196
|
+
onLoadingEnd: this.loadingEnd.bind(this),
|
|
197
|
+
onLoadingUpdate: (text) => {
|
|
198
|
+
if (this._loading) {
|
|
199
|
+
this._loading.text = text;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
245
204
|
}
|
|
246
205
|
//# sourceMappingURL=interactive-terminal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-terminal.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/interactive-terminal.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"interactive-terminal.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/interactive-terminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,GAAU,MAAM,KAAK,CAAA;AAE5B,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAC,mBAAmB,EAAE,uBAAuB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AAA;QACjB,MAAM,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;QACnE,OAAO,CAAC,GAAG,CACT,6FAA6F,CAC9F,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAkB,EAAE,QAAgB;QACzD,MAAM,QAAQ,CACZ;YACE,QAAQ;YACR,QAAQ;YACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;SAC7B,EACD,IAAI,CAAC,eAAe,CACrB,CAAA;IACH,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACnD,CAAC;IAED,IAAY,eAAe;QACzB,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACxC,eAAe,EAAE,CAAC,IAAY,EAAE,EAAE;gBAChC,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACjB,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;iBAC1B;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DevCommandOptions } from '../../index.js';
|
|
2
|
-
export declare function runMetro(options?: DevCommandOptions): Promise<void>;
|
|
2
|
+
export declare function runMetro(options?: Pick<DevCommandOptions, 'host' | 'resetCache'>): Promise<void>;
|
|
@@ -7,7 +7,7 @@ export async function runMetro(options = DEFAULT_OPTIONS) {
|
|
|
7
7
|
const { host, ...metroOptions } = options;
|
|
8
8
|
const metroServerConfig = {
|
|
9
9
|
...(await getMetroConfig()),
|
|
10
|
-
metroOptions,
|
|
10
|
+
...metroOptions,
|
|
11
11
|
};
|
|
12
12
|
await Metro.runServer(metroServerConfig, { host });
|
|
13
13
|
if (host !== 'localhost') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro-server.js","sourceRoot":"","sources":["../../../../../src/commands/dev/utils/metro/metro-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"metro-server.js","sourceRoot":"","sources":["../../../../../src/commands/dev/utils/metro/metro-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAEhD,MAAM,eAAe,GAAG;IACtB,UAAU,EAAE,KAAK;CACT,CAAA;AAEV,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,UAA0D,eAAe;IAEzE,MAAM,EAAC,IAAI,EAAE,GAAG,YAAY,EAAC,GAAG,OAAO,CAAA;IACvC,MAAM,iBAAiB,GAAY;QACjC,GAAG,CAAC,MAAM,cAAc,EAAE,CAAC;QAC3B,GAAG,YAAY;KAChB,CAAA;IAED,MAAM,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAC,IAAI,EAAC,CAAC,CAAA;IAEhD,IAAI,IAAI,KAAK,WAAW,EAAE;QACxB,MAAM,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,CAAA;KAC9D;AACH,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Platform } from './
|
|
1
|
+
import { Platform } from './platform.js';
|
|
2
|
+
import { BinaryMetadata, BuildType } from './types.js';
|
|
3
|
+
export declare const CDN_ADDRESS = "http://34.160.57.53/";
|
|
4
|
+
export declare const GOOGLE_CLOUD_BUCKET_NAME = "minis_cli_app_builds";
|
|
5
|
+
export declare const metadataToBucketPath: (metadata: BinaryMetadata) => string;
|
|
2
6
|
/**
|
|
3
7
|
* Downloads a binary from the remote storage
|
|
4
8
|
* @returns Promise that resolves to the downloaded version
|
|
5
9
|
*/
|
|
6
|
-
export declare function downloadBinary(
|
|
10
|
+
export declare function downloadBinary(versionToDownload: BinaryMetadata, { onProgress, }?: {
|
|
7
11
|
/**
|
|
8
12
|
* Download progress callback
|
|
9
13
|
*/
|
|
10
14
|
onProgress?: (progress: number) => void;
|
|
11
|
-
|
|
12
|
-
* Version to download. Defaults to latest version available
|
|
13
|
-
*/
|
|
14
|
-
version?: string;
|
|
15
|
-
}): Promise<string>;
|
|
15
|
+
}): Promise<BinaryMetadata>;
|
|
16
16
|
/**
|
|
17
17
|
* Returns the latest version that's present in the remote storage of binaries
|
|
18
18
|
* TODO: this won't handle a bucket that has more than 50 files.
|
|
19
19
|
*/
|
|
20
|
-
export declare function getLatestRemoteVersion(platform: Platform): Promise<
|
|
20
|
+
export declare function getLatestRemoteVersion(platform: Platform, type: BuildType): Promise<BinaryMetadata | null>;
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
|
+
import { basename } from 'node:path';
|
|
2
3
|
import { Storage } from '@google-cloud/storage';
|
|
3
4
|
import fs from 'fs-extra';
|
|
5
|
+
import { compare, parse } from 'semver';
|
|
4
6
|
import { PATHS } from '../../config.js';
|
|
5
|
-
import {
|
|
7
|
+
import { isVersionAvailableLocally } from './binaries.js';
|
|
8
|
+
import { getLatestVersionFromFilesList, metadataToBinaryFileName, } from './version.js';
|
|
6
9
|
// TODO: set up domain and ssl certificate for cdn
|
|
7
|
-
// https://console.cloud.google.com/net-services/cdn/backendBucket/details/minis-
|
|
8
|
-
// https://console.cloud.google.com/storage/browser/
|
|
9
|
-
const CDN_ADDRESS = 'http://
|
|
10
|
-
const GOOGLE_CLOUD_BUCKET_NAME = '
|
|
10
|
+
// https://console.cloud.google.com/net-services/cdn/backendBucket/details/minis-app-builds-backend-bucket?project=arrive-167720
|
|
11
|
+
// https://console.cloud.google.com/storage/browser/minis_cli_app_builds
|
|
12
|
+
export const CDN_ADDRESS = 'http://34.160.57.53/';
|
|
13
|
+
export const GOOGLE_CLOUD_BUCKET_NAME = 'minis_cli_app_builds';
|
|
11
14
|
const bucket = new Storage().bucket(GOOGLE_CLOUD_BUCKET_NAME);
|
|
15
|
+
export const metadataToBucketPath = (metadata) => `${metadata.version}/${metadataToBinaryFileName(metadata)}`;
|
|
12
16
|
/**
|
|
13
17
|
* Downloads a binary from the remote storage
|
|
14
18
|
* @returns Promise that resolves to the downloaded version
|
|
15
19
|
*/
|
|
16
|
-
export async function downloadBinary(
|
|
17
|
-
const
|
|
18
|
-
const isVersionAlreadyDownloaded = await isVersionAvailableLocally(platform, versionToDownload);
|
|
20
|
+
export async function downloadBinary(versionToDownload, { onProgress, } = {}) {
|
|
21
|
+
const isVersionAlreadyDownloaded = await isVersionAvailableLocally(versionToDownload);
|
|
19
22
|
if (isVersionAlreadyDownloaded) {
|
|
20
23
|
onProgress?.(100);
|
|
21
24
|
return versionToDownload;
|
|
22
25
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const remoteFile = bucketResponse[0][0];
|
|
28
|
-
const fileSize = parseInt(remoteFile.metadata.size, 10);
|
|
26
|
+
const localFileName = metadataToBinaryFileName(versionToDownload);
|
|
27
|
+
const remoteBucketPath = metadataToBucketPath(versionToDownload);
|
|
28
|
+
const [metadata] = await bucket.file(remoteBucketPath).getMetadata();
|
|
29
|
+
const fileSize = parseInt(metadata.size, 10);
|
|
29
30
|
return new Promise((resolve, reject) => {
|
|
30
|
-
const writeStream = fs.createWriteStream(`${PATHS.CACHE_DIR}/${
|
|
31
|
+
const writeStream = fs.createWriteStream(`${PATHS.CACHE_DIR}/${localFileName}`);
|
|
31
32
|
const progressInterval = setInterval(() => {
|
|
32
33
|
const progress = Math.round((writeStream.bytesWritten / fileSize) * 100);
|
|
33
34
|
onProgress?.(progress);
|
|
34
35
|
}, 200);
|
|
35
|
-
http.get(`${CDN_ADDRESS}${
|
|
36
|
+
http.get(`${CDN_ADDRESS}${remoteBucketPath}`, cdnResponse => {
|
|
36
37
|
cdnResponse.pipe(writeStream);
|
|
37
38
|
writeStream.on('finish', () => {
|
|
38
39
|
writeStream.close();
|
|
@@ -51,12 +52,57 @@ export async function downloadBinary(platform, { onProgress, version, } = {}) {
|
|
|
51
52
|
* Returns the latest version that's present in the remote storage of binaries
|
|
52
53
|
* TODO: this won't handle a bucket that has more than 50 files.
|
|
53
54
|
*/
|
|
54
|
-
export async function getLatestRemoteVersion(platform) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
export async function getLatestRemoteVersion(platform, type) {
|
|
56
|
+
const versions = await getRemoteVersions();
|
|
57
|
+
// newest first
|
|
58
|
+
const sortedVersions = versions.sort(compare).reverse();
|
|
59
|
+
// iterate over versions, in case newest version(s) don't contain builds for the given platform/type
|
|
60
|
+
for (const version of sortedVersions) {
|
|
61
|
+
const prefix = `${version}/`;
|
|
62
|
+
const [filesMetadata] = await bucket.getFiles({
|
|
63
|
+
prefix,
|
|
64
|
+
});
|
|
65
|
+
const fileNames = filesMetadata
|
|
66
|
+
.map(file => file.name)
|
|
67
|
+
// extract filename from GCS bucket path
|
|
68
|
+
.map(path => basename(path));
|
|
69
|
+
const latestVersion = getLatestVersionFromFilesList(fileNames, platform, type);
|
|
70
|
+
if (latestVersion != null) {
|
|
71
|
+
return latestVersion;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns a list of all the versions that are present in the remote bucket,
|
|
78
|
+
* regardless of platform or build type
|
|
79
|
+
*/
|
|
80
|
+
async function getRemoteVersions() {
|
|
81
|
+
// GCS doesn't have a concept of 'folders', so we just list prefixes (which are the version numbers)
|
|
82
|
+
// and remove the trailing delimiter ('/')
|
|
83
|
+
let query = {
|
|
84
|
+
delimiter: '/',
|
|
85
|
+
// intentionally set to false to keep `apiResponse`
|
|
86
|
+
// see: https://github.com/googleapis/google-cloud-node/issues/2594
|
|
87
|
+
autoPaginate: false,
|
|
88
|
+
};
|
|
89
|
+
const prefixes = [];
|
|
90
|
+
// loop to handle pagination
|
|
91
|
+
do {
|
|
92
|
+
const [_files, nextQuery, apiResponse] = await bucket.getFiles(query);
|
|
93
|
+
const newPrefixes = apiResponse.prefixes ?? [];
|
|
94
|
+
prefixes.push(...newPrefixes);
|
|
95
|
+
query = nextQuery;
|
|
96
|
+
} while (query != null);
|
|
97
|
+
return (prefixes
|
|
98
|
+
// remove trailing delimiter
|
|
99
|
+
.map(prefix => prefix.replace(/\/$/, ''))
|
|
100
|
+
// validate that we only have 'x.y.z', not 'x.y.z-rc.1' or 'x.y.z+123'
|
|
101
|
+
.filter(prefix => {
|
|
102
|
+
const parsed = parse(prefix);
|
|
103
|
+
return (parsed != null &&
|
|
104
|
+
parsed.build.length === 0 &&
|
|
105
|
+
parsed.prerelease.length === 0);
|
|
106
|
+
}));
|
|
61
107
|
}
|
|
62
108
|
//# sourceMappingURL=network.js.map
|