@shopify/shop-minis-cli 0.0.35
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/README.md +8 -0
- package/build/commands/create-mini/index.d.ts +2 -0
- package/build/commands/create-mini/index.js +116 -0
- package/build/commands/create-mini/index.js.map +1 -0
- package/build/commands/create-mini/utils/template-app.d.ts +1 -0
- package/build/commands/create-mini/utils/template-app.js +44 -0
- package/build/commands/create-mini/utils/template-app.js.map +1 -0
- package/build/commands/dev/index.d.ts +6 -0
- package/build/commands/dev/index.js +31 -0
- package/build/commands/dev/index.js.map +1 -0
- package/build/commands/dev/utils/android.d.ts +16 -0
- package/build/commands/dev/utils/android.js +165 -0
- package/build/commands/dev/utils/android.js.map +1 -0
- package/build/commands/dev/utils/binaries.d.ts +83 -0
- package/build/commands/dev/utils/binaries.js +173 -0
- package/build/commands/dev/utils/binaries.js.map +1 -0
- package/build/commands/dev/utils/binaries.test.d.ts +1 -0
- package/build/commands/dev/utils/binaries.test.js +275 -0
- package/build/commands/dev/utils/binaries.test.js.map +1 -0
- package/build/commands/dev/utils/deeplink.d.ts +3 -0
- package/build/commands/dev/utils/deeplink.js +30 -0
- package/build/commands/dev/utils/deeplink.js.map +1 -0
- package/build/commands/dev/utils/interactive-terminal.d.ts +23 -0
- package/build/commands/dev/utils/interactive-terminal.js +252 -0
- package/build/commands/dev/utils/interactive-terminal.js.map +1 -0
- package/build/commands/dev/utils/metro/metro-config.d.ts +2 -0
- package/build/commands/dev/utils/metro/metro-config.js +31 -0
- package/build/commands/dev/utils/metro/metro-config.js.map +1 -0
- package/build/commands/dev/utils/metro/metro-reporter.d.ts +14 -0
- package/build/commands/dev/utils/metro/metro-reporter.js +34 -0
- package/build/commands/dev/utils/metro/metro-reporter.js.map +1 -0
- package/build/commands/dev/utils/metro/metro-server-middleware.d.ts +6 -0
- package/build/commands/dev/utils/metro/metro-server-middleware.js +45 -0
- package/build/commands/dev/utils/metro/metro-server-middleware.js.map +1 -0
- package/build/commands/dev/utils/metro/metro-server.d.ts +2 -0
- package/build/commands/dev/utils/metro/metro-server.js +24 -0
- package/build/commands/dev/utils/metro/metro-server.js.map +1 -0
- package/build/commands/dev/utils/minis-manifest.d.ts +1 -0
- package/build/commands/dev/utils/minis-manifest.js +24 -0
- package/build/commands/dev/utils/minis-manifest.js.map +1 -0
- package/build/commands/dev/utils/qr-code.d.ts +1 -0
- package/build/commands/dev/utils/qr-code.js +12 -0
- package/build/commands/dev/utils/qr-code.js.map +1 -0
- package/build/commands/dev/utils/simulator.d.ts +19 -0
- package/build/commands/dev/utils/simulator.js +89 -0
- package/build/commands/dev/utils/simulator.js.map +1 -0
- package/build/commands/dev/utils/with-retries.d.ts +4 -0
- package/build/commands/dev/utils/with-retries.js +28 -0
- package/build/commands/dev/utils/with-retries.js.map +1 -0
- package/build/commands/generate-graphql-types/index.d.ts +5 -0
- package/build/commands/generate-graphql-types/index.js +90 -0
- package/build/commands/generate-graphql-types/index.js.map +1 -0
- package/build/commands/utils/exec-async-child-process.d.ts +18 -0
- package/build/commands/utils/exec-async-child-process.js +48 -0
- package/build/commands/utils/exec-async-child-process.js.map +1 -0
- package/build/commands/utils/wrap-with-loading-indicator.d.ts +9 -0
- package/build/commands/utils/wrap-with-loading-indicator.js +23 -0
- package/build/commands/utils/wrap-with-loading-indicator.js.map +1 -0
- package/build/dev-panel/images/bottomsheet.png +0 -0
- package/build/dev-panel/images/checkmark.svg +3 -0
- package/build/dev-panel/images/chevron.svg +3 -0
- package/build/dev-panel/images/copy.svg +4 -0
- package/build/dev-panel/images/get-started.svg +3 -0
- package/build/dev-panel/images/how-to.svg +3 -0
- package/build/dev-panel/images/navigation.png +0 -0
- package/build/dev-panel/images/references.svg +3 -0
- package/build/dev-panel/images/shop-minis-logo-inverse.svg +5 -0
- package/build/dev-panel/images/shop-minis-logo.svg +5 -0
- package/build/dev-panel/images/stories.png +0 -0
- package/build/dev-panel/images/topics.svg +3 -0
- package/build/dev-panel/index.html +302 -0
- package/build/dev-panel/middleware.d.ts +4 -0
- package/build/dev-panel/middleware.js +11 -0
- package/build/dev-panel/middleware.js.map +1 -0
- package/build/dev-panel/middleware.ts +6 -0
- package/build/dev-panel/styles.css +507 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +26 -0
- package/build/index.js.map +1 -0
- package/package.json +83 -0
- package/templates/__template_blank/src/custom.d.ts +4 -0
- package/templates/__template_blank/src/index.tsx +9 -0
- package/templates/__template_blank/src/screens/HomeScreen.tsx +12 -0
- package/templates/__template_blank/src/types.ts +5 -0
- package/templates/__template_common/.eslintignore +1 -0
- package/templates/__template_common/.eslintrc.json +132 -0
- package/templates/__template_common/.prettierrc.json +8 -0
- package/templates/__template_common/babel.config.js +19 -0
- package/templates/__template_common/gitignore +3 -0
- package/templates/__template_common/index.tsx +43 -0
- package/templates/__template_common/metro.config.js +31 -0
- package/templates/__template_common/package.json +68 -0
- package/templates/__template_common/patches/react-native+0.68.5.patch +173 -0
- package/templates/__template_common/src/manifest.json +29 -0
- package/templates/__template_common/tsconfig.json +36 -0
- package/templates/__template_hello_world/src/assets/Modal-component-thumbnail.png +0 -0
- package/templates/__template_hello_world/src/assets/ProductCard-component-thumbnail.png +0 -0
- package/templates/__template_hello_world/src/assets/ProductLink-component-thumbnail.png +0 -0
- package/templates/__template_hello_world/src/assets/assets.d.ts +4 -0
- package/templates/__template_hello_world/src/assets/figma-logo.svg +14 -0
- package/templates/__template_hello_world/src/assets/shop-minis-logo.svg +7 -0
- package/templates/__template_hello_world/src/components/ButtonCTA.tsx +31 -0
- package/templates/__template_hello_world/src/components/ComponentLink.ts +70 -0
- package/templates/__template_hello_world/src/components/ComponentListItem.tsx +38 -0
- package/templates/__template_hello_world/src/components/FeaturedComponents.tsx +108 -0
- package/templates/__template_hello_world/src/components/Header.tsx +40 -0
- package/templates/__template_hello_world/src/data/Test.graphql +33 -0
- package/templates/__template_hello_world/src/data/Test.graphql.d.ts +114 -0
- package/templates/__template_hello_world/src/data/TestProducts.graphql +34 -0
- package/templates/__template_hello_world/src/data/TestProducts.graphql.d.ts +119 -0
- package/templates/__template_hello_world/src/index.tsx +9 -0
- package/templates/__template_hello_world/src/routes.tsx +107 -0
- package/templates/__template_hello_world/src/screens/AvatarScreen.tsx +95 -0
- package/templates/__template_hello_world/src/screens/BottomSheetScreen.tsx +711 -0
- package/templates/__template_hello_world/src/screens/ButtonsScreen.tsx +90 -0
- package/templates/__template_hello_world/src/screens/GridScreen.tsx +74 -0
- package/templates/__template_hello_world/src/screens/HomeScreen.tsx +70 -0
- package/templates/__template_hello_world/src/screens/IconsScreen.tsx +181 -0
- package/templates/__template_hello_world/src/screens/MediaScreen.tsx +130 -0
- package/templates/__template_hello_world/src/screens/ModalScreen.tsx +379 -0
- package/templates/__template_hello_world/src/screens/ProductCardGridScreen.tsx +68 -0
- package/templates/__template_hello_world/src/screens/ProductCardScreen.tsx +62 -0
- package/templates/__template_hello_world/src/screens/ProductLinkScreen.tsx +215 -0
- package/templates/__template_hello_world/src/screens/ProgressIndicatorScreen.tsx +77 -0
- package/templates/__template_hello_world/src/screens/QuantityPickerScreen.tsx +76 -0
- package/templates/__template_hello_world/src/screens/SpinnerScreen.tsx +63 -0
- package/templates/__template_hello_world/src/screens/TypographyScreen.tsx +274 -0
- package/templates/__template_hello_world/src/screens/WebViewScreen.tsx +42 -0
- package/templates/__template_hello_world/src/types.ts +25 -0
- package/templates/__template_snowboardz/src/assets/assets.d.ts +4 -0
- package/templates/__template_snowboardz/src/assets/circle-blue.svg +9 -0
- package/templates/__template_snowboardz/src/assets/circle-green.svg +9 -0
- package/templates/__template_snowboardz/src/assets/circle-purple.svg +9 -0
- package/templates/__template_snowboardz/src/assets/circle-rainbow.svg +34 -0
- package/templates/__template_snowboardz/src/assets/circle-red.svg +9 -0
- package/templates/__template_snowboardz/src/assets/circle-yellow.svg +9 -0
- package/templates/__template_snowboardz/src/assets/skill-level-icon-advanced.svg +3 -0
- package/templates/__template_snowboardz/src/assets/skill-level-icon-beginner.svg +3 -0
- package/templates/__template_snowboardz/src/assets/skill-level-icon-intermediate.svg +3 -0
- package/templates/__template_snowboardz/src/components/ColorButton.tsx +79 -0
- package/templates/__template_snowboardz/src/components/ColorPicker.tsx +40 -0
- package/templates/__template_snowboardz/src/components/EmptyResult.tsx +52 -0
- package/templates/__template_snowboardz/src/components/SkillLevelIcon.tsx +44 -0
- package/templates/__template_snowboardz/src/components/SkillLevelPicker.tsx +86 -0
- package/templates/__template_snowboardz/src/data/TestProducts.graphql +34 -0
- package/templates/__template_snowboardz/src/data/TestProducts.graphql.d.ts +108 -0
- package/templates/__template_snowboardz/src/hooks/useSnowboardData.tsx +37 -0
- package/templates/__template_snowboardz/src/index.tsx +9 -0
- package/templates/__template_snowboardz/src/routes.tsx +17 -0
- package/templates/__template_snowboardz/src/screens/HomeScreen.tsx +126 -0
- package/templates/__template_snowboardz/src/types.ts +12 -0
- package/templates/__template_snowboardz/src/utils.ts +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Shop Minis CLI
|
|
2
|
+
|
|
3
|
+
A CLI tool to create, run and publish Shop Minis.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
Use this CLI tool to create a new Shop Mini by running `npm init @shopify/shop-mini` or `yarn create @shopify/shop-mini`.
|
|
8
|
+
Follow the instructions in the console to run your mini.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadCommand = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
13
|
+
const exec_async_child_process_1 = require("../utils/exec-async-child-process");
|
|
14
|
+
const wrap_with_loading_indicator_1 = require("../utils/wrap-with-loading-indicator");
|
|
15
|
+
const template_app_1 = require("./utils/template-app");
|
|
16
|
+
function logSuccess(handle, useYarn, outputDir = '.') {
|
|
17
|
+
console.log(`\n \nShop Mini`, chalk_1.default.green.bold(`${handle}`), 'created. Next steps:\n');
|
|
18
|
+
const currentPath = `${process.cwd()}/`;
|
|
19
|
+
const cdAbsolutePath = path_1.default.resolve(outputDir, handle);
|
|
20
|
+
const cdPath = cdAbsolutePath.startsWith(currentPath)
|
|
21
|
+
? cdAbsolutePath.replace(currentPath, '')
|
|
22
|
+
: cdAbsolutePath;
|
|
23
|
+
console.log(chalk_1.default.cyan.bold(` cd ${cdPath}`));
|
|
24
|
+
console.log(chalk_1.default.dim(' Open your Shop Mini’s directory\n'));
|
|
25
|
+
console.log(chalk_1.default.cyan.bold(` ↪ ${useYarn ? 'yarn' : 'npm'} start`));
|
|
26
|
+
console.log(chalk_1.default.dim(' Run Shop Mini, and open it on an iOS or Android device.\n'));
|
|
27
|
+
console.log(chalk_1.default.cyan(' ↪ ') +
|
|
28
|
+
chalk_1.default.cyan.underline.bold('https://shop.app/minis/docs/'));
|
|
29
|
+
console.log(chalk_1.default.dim(' Shop Minis documentation.\n \n'));
|
|
30
|
+
}
|
|
31
|
+
async function promptUser(miniNameArg) {
|
|
32
|
+
const questions = [];
|
|
33
|
+
if (miniNameArg === undefined) {
|
|
34
|
+
questions.push({
|
|
35
|
+
type: 'text',
|
|
36
|
+
name: 'miniName',
|
|
37
|
+
message: `Give your Shop Mini a name. ${chalk_1.default.dim('You can change it later.\n')}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
questions.push({
|
|
41
|
+
type: 'select',
|
|
42
|
+
name: 'templateName',
|
|
43
|
+
message: 'Select a template',
|
|
44
|
+
choices: [
|
|
45
|
+
{
|
|
46
|
+
title: 'Snowdevil',
|
|
47
|
+
description: 'Example of a Shop Mini using prebuilt components',
|
|
48
|
+
value: 'snowboardz',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: 'Hello World',
|
|
52
|
+
description: 'Prebuilt components you can play around with',
|
|
53
|
+
value: 'hello_world',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'Blank',
|
|
57
|
+
value: 'blank',
|
|
58
|
+
description: 'A blank canvas so you can create from scratch',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
initial: 0,
|
|
62
|
+
});
|
|
63
|
+
const onCancel = () => {
|
|
64
|
+
console.log('\nShop Mini creation stopped at your request. Name not saved.\n');
|
|
65
|
+
process.exit(0);
|
|
66
|
+
};
|
|
67
|
+
const response = await prompts_1.default.prompt(questions, { onCancel });
|
|
68
|
+
return {
|
|
69
|
+
miniName: miniNameArg || response.miniName,
|
|
70
|
+
templateName: response.templateName,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function loadCommand(parentProgram) {
|
|
74
|
+
const command = new commander_1.Command()
|
|
75
|
+
.name('create')
|
|
76
|
+
.description('Create a new Shop Mini')
|
|
77
|
+
.argument('[mini name]', 'the name of your mini')
|
|
78
|
+
.option('--useYarn', 'Use yarn as package manager instead of npm')
|
|
79
|
+
.option('--output-dir [path]', 'Specify an output directory for the mini')
|
|
80
|
+
.action(async (miniNameArg, options = {}) => {
|
|
81
|
+
const outputDir = options.outputDir ?? '.';
|
|
82
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
83
|
+
console.error(`Unable to create a mini at the specified output dir of ${outputDir}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const { miniName, templateName } = await promptUser(miniNameArg);
|
|
88
|
+
const handle = lodash_1.default.kebabCase(miniName);
|
|
89
|
+
await (0, wrap_with_loading_indicator_1.wrapWithLoadingIndicator)((0, template_app_1.generateMiniFromTemplate)(miniName, handle, templateName, outputDir), {
|
|
90
|
+
loadingMessage: 'Fetching template...',
|
|
91
|
+
successMessage: 'Template fetched',
|
|
92
|
+
});
|
|
93
|
+
// Yarn is ignoring the `resolutions` when you install
|
|
94
|
+
// via `yarn create @shopify/shop-mini` so use `--ignore-engines` to work around the
|
|
95
|
+
// problem with `@apollo/federation`
|
|
96
|
+
// npm fails to install for a similar reason on node 15 but runs fine so we will
|
|
97
|
+
// use `--force` to get everything installed
|
|
98
|
+
const installCmd = options.useYarn
|
|
99
|
+
? 'yarn --ignore-engines'
|
|
100
|
+
: 'npm i --force';
|
|
101
|
+
await (0, exec_async_child_process_1.execAsync)({
|
|
102
|
+
cmd: `cd ${path_1.default.resolve(outputDir, handle)} && ${installCmd}`,
|
|
103
|
+
loadingMessage: 'Installing dependencies. This might take a minute...',
|
|
104
|
+
successMessage: 'Dependencies installed',
|
|
105
|
+
});
|
|
106
|
+
logSuccess(handle, options.useYarn, outputDir);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
console.error(err?.message || err);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
parentProgram.addCommand(command);
|
|
114
|
+
}
|
|
115
|
+
exports.loadCommand = loadCommand;
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/create-mini/index.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAEvB,yCAAiC;AACjC,sDAA6C;AAC7C,kDAAyB;AACzB,oDAAsB;AAEtB,gFAA2D;AAC3D,sFAA6E;AAE7E,uDAA6D;AAE7D,SAAS,UAAU,CAAC,MAAc,EAAE,OAAiB,EAAE,SAAS,GAAG,GAAG;IACpE,OAAO,CAAC,GAAG,CACT,gBAAgB,EAChB,eAAK,CAAC,KAAK,CAAC,IAAI,CA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;AACnC,CAAC;AAvDD,kCAuDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateMiniFromTemplate(name: string, handle: string, templateName: string, outputDir?: string): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateMiniFromTemplate = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const replace_in_file_1 = require("replace-in-file");
|
|
11
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
12
|
+
async function replaceStringsInTemplate(dir, stringsToReplace) {
|
|
13
|
+
for (const [replaceKey, replaceValue] of Object.entries(stringsToReplace)) {
|
|
14
|
+
const replaceOptions = {
|
|
15
|
+
files: [`${dir}/**/*.*`],
|
|
16
|
+
from: new RegExp(replaceKey, 'g'),
|
|
17
|
+
to: replaceValue,
|
|
18
|
+
optionsForFiles: {
|
|
19
|
+
ignore: ['**/node_modules/**'],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
await (0, replace_in_file_1.replaceInFile)(replaceOptions);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function generateMiniFromTemplate(name, handle, templateName, outputDir = '.') {
|
|
26
|
+
const tmpDir = await fs_extra_1.default.mkdtemp(path_1.default.join(os_1.default.tmpdir(), `${handle}-`));
|
|
27
|
+
const miniTemplateDir = await path_1.default.join(__dirname, '../../../../templates', `__template_${templateName}`);
|
|
28
|
+
const miniDestinationDir = path_1.default.resolve(process.cwd(), outputDir, handle);
|
|
29
|
+
const CLIVersion = require('../../../../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
30
|
+
const stringsToReplace = {
|
|
31
|
+
__MINI_APP_NAME__: name,
|
|
32
|
+
__MINI_APP_HANDLE_PASCAL_CASE__: lodash_1.default.startCase(handle).replace(/ /g, ''),
|
|
33
|
+
__MINI_APP_HANDLE_KEBAB_CASE__: handle,
|
|
34
|
+
__SHOP_MINIS_CLI_VERSION__: CLIVersion,
|
|
35
|
+
};
|
|
36
|
+
const commonTemplateFilesDir = await path_1.default.join(__dirname, '../../../../templates', '__template_common');
|
|
37
|
+
await fs_extra_1.default.copy(commonTemplateFilesDir, tmpDir);
|
|
38
|
+
await fs_extra_1.default.copy(miniTemplateDir, tmpDir);
|
|
39
|
+
await fs_extra_1.default.move(path_1.default.join(tmpDir, 'gitignore'), path_1.default.join(tmpDir, '.gitignore'));
|
|
40
|
+
await replaceStringsInTemplate(tmpDir, stringsToReplace);
|
|
41
|
+
await fs_extra_1.default.copy(tmpDir, miniDestinationDir);
|
|
42
|
+
}
|
|
43
|
+
exports.generateMiniFromTemplate = generateMiniFromTemplate;
|
|
44
|
+
//# sourceMappingURL=template-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-app.js","sourceRoot":"","sources":["../../../../src/commands/create-mini/utils/template-app.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,4CAAmB;AAEnB,wDAAyB;AACzB,qDAA6C;AAC7C,oDAAsB;AAEtB,KAAK,UAAU,wBAAwB,CACrC,GAAW,EACX,gBAAwC;IAExC,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;QACzE,MAAM,cAAc,GAAG;YACrB,KAAK,EAAE,CAAC,GAAG,GAAG,SAAS,CAAC;YACxB,IAAI,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;YACjC,EAAE,EAAE,YAAY;YAChB,eAAe,EAAE;gBACf,MAAM,EAAE,CAAC,oBAAoB,CAAC;aAC/B;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AM,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACxD,MAAM,kBAAE,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;AAC3C,CAAC;AAjCD,4DAiCC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const internal_ip_1 = require("internal-ip");
|
|
10
|
+
const interactive_terminal_1 = require("./utils/interactive-terminal");
|
|
11
|
+
const metro_server_1 = require("./utils/metro/metro-server");
|
|
12
|
+
const minis_manifest_1 = require("./utils/minis-manifest");
|
|
13
|
+
async function loadCommand(parentProgram) {
|
|
14
|
+
const ip = await (0, internal_ip_1.v4)();
|
|
15
|
+
const command = new commander_1.Command()
|
|
16
|
+
.name('dev')
|
|
17
|
+
.version('2.0.0')
|
|
18
|
+
.description('Start a local dev server for the mini app')
|
|
19
|
+
.option('--reset-cache', 'reset the dev server cache')
|
|
20
|
+
.option('--host <host>', "packager's host", ip)
|
|
21
|
+
.action(async (options) => {
|
|
22
|
+
await (0, metro_server_1.runMetro)(options);
|
|
23
|
+
const miniHandle = (0, minis_manifest_1.getMiniManifest)().handle;
|
|
24
|
+
console.log('Local development environment for', chalk_1.default.green(miniHandle), 'is running...');
|
|
25
|
+
const interactiveTerminal = new interactive_terminal_1.InteractiveTerminal(options);
|
|
26
|
+
interactiveTerminal.start();
|
|
27
|
+
});
|
|
28
|
+
parentProgram.addCommand(command);
|
|
29
|
+
}
|
|
30
|
+
exports.loadCommand = loadCommand;
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dev/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAiC;AACjC,kDAAyB;AACzB,6CAAsC;AAEtC,uEAAgE;AAChE,6DAAmD;AACnD,2DAAsD;AAO/C,KAAK,UAAU,WAAW,CAAC,aAAsB;IACtD,MAAM,EAAE,GAAG,MAAM,IAAA,gBAAI,GAAE,CAAA;IAEvB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE;SAC1B,IAAI,CAAC,KAAK,CAAC;SACX,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,2CAA2C,CAAC;SACxD,MAAM,CAAC,eAAe,EAAE,4BAA4B,CAAC;SACrD,MAAM,CAAC,eAAe,EAAE,iBAAiB,EAAE,EAAE,CAAC;SAC9C,MAAM,CAAC,KAAK,EAAE,OAA0B,EAAE,EAAE;QAC3C,MAAM,IAAA,uBAAQ,EAAC,OAAO,CAAC,CAAA;QAEvB,MAAM,UAAU,GAAG,IAAA,gCAAe,GAAE,CAAC,MAAM,CAAA;QAC3C,OAAO,CAAC,GAAG,CACT,mCAAmC,EACnC,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,EACvB,eAAe,CAChB,CAAA;QAED,MAAM,mBAAmB,GAAG,IAAI,0CAAmB,CAAC,OAAO,CAAC,CAAA;QAC5D,mBAAmB,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEJ,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACnC,CAAC;AAxBD,kCAwBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface androidDevice {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly description: string;
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly isBooted: boolean;
|
|
6
|
+
readonly isAuthorized: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function getDevices(): Promise<androidDevice[]>;
|
|
9
|
+
export declare function getEmulators(): Promise<androidDevice[]>;
|
|
10
|
+
export declare function androidHomeExists(): boolean;
|
|
11
|
+
export declare function promptForAndroidDevices(): Promise<androidDevice | null>;
|
|
12
|
+
export declare function maybeLaunchEmulator(emulatorName: string): Promise<string | null>;
|
|
13
|
+
export declare function installShopInEmulator(emulatorId: string, version: string): Promise<void>;
|
|
14
|
+
export declare function getInstalledShopVersion(emulatorId: string): Promise<string | null | undefined>;
|
|
15
|
+
export declare function connectDevelopmentServer(emulatorId: string): Promise<void>;
|
|
16
|
+
export declare function deeplinkToEmulator(emulatorId: string, deeplink: string): Promise<void>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deeplinkToEmulator = exports.connectDevelopmentServer = exports.getInstalledShopVersion = exports.installShopInEmulator = exports.maybeLaunchEmulator = exports.promptForAndroidDevices = exports.androidHomeExists = exports.getEmulators = exports.getDevices = void 0;
|
|
7
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
11
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
12
|
+
const exec_async_child_process_1 = require("../../utils/exec-async-child-process");
|
|
13
|
+
const with_retries_1 = require("./with-retries");
|
|
14
|
+
const binaries_1 = require("./binaries");
|
|
15
|
+
const DEFAULT_ANDROID_HOME_MACOS = `${process.env.HOME}/Library/Android/sdk`;
|
|
16
|
+
function whichAndroidHome() {
|
|
17
|
+
if (process.env.ANDROID_HOME) {
|
|
18
|
+
return process.env.ANDROID_HOME;
|
|
19
|
+
}
|
|
20
|
+
if (fs_1.default.existsSync(DEFAULT_ANDROID_HOME_MACOS)) {
|
|
21
|
+
return DEFAULT_ANDROID_HOME_MACOS;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function whichEmulator() {
|
|
26
|
+
return `${whichAndroidHome()}/emulator/emulator`;
|
|
27
|
+
}
|
|
28
|
+
function whichAdb() {
|
|
29
|
+
return `${whichAndroidHome()}/platform-tools/adb`;
|
|
30
|
+
}
|
|
31
|
+
async function getDevices() {
|
|
32
|
+
const { stdout: devicesList } = await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} devices -l`);
|
|
33
|
+
return devicesList
|
|
34
|
+
.slice(1)
|
|
35
|
+
.filter(name => !name.includes('emulator'))
|
|
36
|
+
.map(name => ({
|
|
37
|
+
name: name.split(' ')[0],
|
|
38
|
+
description: `${name.split(' ')[0]} (device)`,
|
|
39
|
+
type: 'device',
|
|
40
|
+
isBooted: true,
|
|
41
|
+
isAuthorized: true,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
exports.getDevices = getDevices;
|
|
45
|
+
async function getEmulators() {
|
|
46
|
+
const { stdout: devicesList } = await (0, exec_async_child_process_1.execAsync)(`${whichEmulator()} -list-avds`);
|
|
47
|
+
return devicesList.map(name => ({
|
|
48
|
+
name,
|
|
49
|
+
description: `${name} (emulator)`,
|
|
50
|
+
type: 'emulator',
|
|
51
|
+
isBooted: false,
|
|
52
|
+
isAuthorized: true,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
exports.getEmulators = getEmulators;
|
|
56
|
+
function androidHomeExists() {
|
|
57
|
+
return Boolean(whichAndroidHome());
|
|
58
|
+
}
|
|
59
|
+
exports.androidHomeExists = androidHomeExists;
|
|
60
|
+
async function promptForAndroidDevices() {
|
|
61
|
+
const devices = await getDevices();
|
|
62
|
+
const emulators = await getEmulators();
|
|
63
|
+
const androidDevices = devices.concat(emulators);
|
|
64
|
+
if (!androidDevices.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const { value } = await (0, prompts_1.default)({
|
|
68
|
+
type: 'autocomplete',
|
|
69
|
+
name: 'value',
|
|
70
|
+
limit: 11,
|
|
71
|
+
message: 'Select a device',
|
|
72
|
+
choices: androidDevices.map(item => {
|
|
73
|
+
return {
|
|
74
|
+
title: item.description,
|
|
75
|
+
value: item,
|
|
76
|
+
};
|
|
77
|
+
}),
|
|
78
|
+
suggest: (input, choices) => {
|
|
79
|
+
const regex = new RegExp(input, 'i');
|
|
80
|
+
return choices.filter((choice) => regex.test(choice.title));
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
exports.promptForAndroidDevices = promptForAndroidDevices;
|
|
86
|
+
async function maybeLaunchEmulator(emulatorName) {
|
|
87
|
+
let emulatorId = await getIdForEmulatorWithName(emulatorName); // if emulatorId is defined the emulator is already running
|
|
88
|
+
if (!emulatorId) {
|
|
89
|
+
emulatorId = await doLaunchEmulator(emulatorName);
|
|
90
|
+
}
|
|
91
|
+
if (emulatorId) {
|
|
92
|
+
await waitForEmulatorToBoot(emulatorId);
|
|
93
|
+
}
|
|
94
|
+
return emulatorId;
|
|
95
|
+
}
|
|
96
|
+
exports.maybeLaunchEmulator = maybeLaunchEmulator;
|
|
97
|
+
async function installShopInEmulator(emulatorId, version) {
|
|
98
|
+
const fileName = (0, binaries_1.versionToBinaryFileName)(version, 'android');
|
|
99
|
+
const binaryPath = path_1.default.join(binaries_1.BINARIES_PATH, fileName);
|
|
100
|
+
await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} install -r "${binaryPath}"`);
|
|
101
|
+
}
|
|
102
|
+
exports.installShopInEmulator = installShopInEmulator;
|
|
103
|
+
async function getInstalledShopVersion(emulatorId) {
|
|
104
|
+
try {
|
|
105
|
+
const { stdout } = await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} shell dumpsys package com.shopify.arrive.internal | grep versionName`);
|
|
106
|
+
// stdout: ["versionName=2.86.0"]
|
|
107
|
+
return lodash_1.default.last(stdout?.[0]?.split('='));
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.getInstalledShopVersion = getInstalledShopVersion;
|
|
114
|
+
async function connectDevelopmentServer(emulatorId) {
|
|
115
|
+
await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} reverse tcp:8082 tcp:8082`);
|
|
116
|
+
}
|
|
117
|
+
exports.connectDevelopmentServer = connectDevelopmentServer;
|
|
118
|
+
async function deeplinkToEmulator(emulatorId, deeplink) {
|
|
119
|
+
await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} shell am start -a android.intent.action.VIEW -d ${deeplink}`);
|
|
120
|
+
}
|
|
121
|
+
exports.deeplinkToEmulator = deeplinkToEmulator;
|
|
122
|
+
async function getNameForEmulatorWithId(emulatorId) {
|
|
123
|
+
const { stdout } = await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} emu avd name`);
|
|
124
|
+
return stdout[0];
|
|
125
|
+
}
|
|
126
|
+
async function getIdForEmulatorWithName(emulatorName) {
|
|
127
|
+
const { stdout } = await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} devices`);
|
|
128
|
+
const emulatorIds = stdout.filter(result => result.startsWith('emulator-'));
|
|
129
|
+
for (const emulatorId of emulatorIds) {
|
|
130
|
+
const name = await getNameForEmulatorWithId(emulatorId);
|
|
131
|
+
if (name === emulatorName) {
|
|
132
|
+
return emulatorId;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
async function waitForEmulatorToBoot(emulatorId, timeout = 60 * 2 * 1000 // 2 minutes
|
|
138
|
+
) {
|
|
139
|
+
await (0, exec_async_child_process_1.execAsync)(`${whichAdb()} -s ${emulatorId} wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'`, { timeout });
|
|
140
|
+
}
|
|
141
|
+
function doLaunchEmulator(emulatorName) {
|
|
142
|
+
const emulatorProcess = child_process_1.default.spawn(whichEmulator(), [`@${emulatorName}`], {
|
|
143
|
+
stdio: 'ignore',
|
|
144
|
+
detached: true,
|
|
145
|
+
});
|
|
146
|
+
emulatorProcess.unref();
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
(0, with_retries_1.withRetries)(() => getIdForEmulatorWithName(emulatorName))
|
|
149
|
+
.then(resolve)
|
|
150
|
+
.catch(reject)
|
|
151
|
+
.finally(() => {
|
|
152
|
+
emulatorProcess.removeAllListeners();
|
|
153
|
+
})
|
|
154
|
+
.catch(() => { });
|
|
155
|
+
emulatorProcess.on('error', ({ message }) => {
|
|
156
|
+
reject(new Error(message));
|
|
157
|
+
emulatorProcess.removeAllListeners();
|
|
158
|
+
});
|
|
159
|
+
emulatorProcess.on('exit', () => {
|
|
160
|
+
reject(new Error('Emulator closed before booting up'));
|
|
161
|
+
emulatorProcess.removeAllListeners();
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"android.js","sourceRoot":"","sources":["../../../../src/commands/dev/utils/android.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAyC;AACzC,gDAAuB;AACvB,4CAAmB;AAEnB,oDAAsB;AACtB,sDAA6B;AAE7B,mFAA8D;AAE9D,iDAA0C;AAC1C,yCAAiE;AAEjE,MAAM,0BAA0B,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,sBAAsB,CAAA;AAU5E,SAAS,gBAAgB;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;KAChC;IAED,IAAI,YAAE,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE;QAC7C,OAAO,0BAA0B,CAAA;KACl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,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAAC,OAAO,EAAC,EAAE,EAAE;YACxC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;YAC1B,eAAe,CAAC,kBAAkB,EAAE,CAAA;QACtC,CAAC,CAAC,CAAA;QAEF,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YAC9B,MAAM,CAAC,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAA;YACtD,eAAe,CAAC,kBAAkB,EAAE,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare const BINARIES_PATH: string;
|
|
2
|
+
type Platform = 'ios' | 'android';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the file extension used for each platform.
|
|
5
|
+
* android: .apk
|
|
6
|
+
* ios: .zip (we intentionally compress .app files before uploading them to the cloud storage)
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBinaryFileExtensionForPlatform(platform: Platform): ".zip" | ".apk";
|
|
9
|
+
/**
|
|
10
|
+
* @example
|
|
11
|
+
* platform android
|
|
12
|
+
* version 2.76.0
|
|
13
|
+
* returns "2-76-0.apk"
|
|
14
|
+
*
|
|
15
|
+
* platform ios
|
|
16
|
+
* version 2.55.0+4
|
|
17
|
+
* returns "2-55-0+4.zip"
|
|
18
|
+
*/
|
|
19
|
+
export declare function versionToBinaryFileName(version: string, platform: Platform): string;
|
|
20
|
+
/**
|
|
21
|
+
* @example
|
|
22
|
+
* binaryFileName "2-76-0.apk"
|
|
23
|
+
* returns "2.76.0"
|
|
24
|
+
*
|
|
25
|
+
* binaryFileName "2-16-0+3.zip"
|
|
26
|
+
* returns "2.16.0+3"
|
|
27
|
+
*/
|
|
28
|
+
export declare function binaryFileNameToVersion(binaryFileName: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* @example
|
|
31
|
+
* 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"]
|
|
32
|
+
* returns "2.77.0+1"
|
|
33
|
+
*/
|
|
34
|
+
export declare function getLatestVersionFromFilesList(filenames: string[]): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a boolean indicating if the binary for the given version and platform is already downloaded in the system
|
|
37
|
+
*/
|
|
38
|
+
export declare function isVersionAvailableLocally(platform: Platform, version: string): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the biggest version in the downloads folder for the given platform.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getLatestDownloadedVersion(platform: Platform): Promise<string | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the latest version that's present in the remote storage of binaries
|
|
45
|
+
* TODO: this won't handle a bucket that has more than 50 files.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getLatestRemoteVersion(platform: Platform): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Downloads a binary from the remote storage
|
|
50
|
+
* @returns Promise that resolves to the downloaded version
|
|
51
|
+
*/
|
|
52
|
+
export declare function downloadBinary(platform: Platform, { onProgress, version, }?: {
|
|
53
|
+
/**
|
|
54
|
+
* Download progress callback
|
|
55
|
+
*/
|
|
56
|
+
onProgress?: (progress: number) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Version to download. Defaults to latest version available
|
|
59
|
+
*/
|
|
60
|
+
version?: string;
|
|
61
|
+
}): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Compares the current version against the latest available version.
|
|
64
|
+
*
|
|
65
|
+
* Does nothing if the current version is already the latest.
|
|
66
|
+
* Otherwise prompts the user to download the new version.
|
|
67
|
+
*/
|
|
68
|
+
export declare function maybePromptBinaryUpgrade(platform: Platform, { currentVersion, onProgress, onDownloadStart, }?: {
|
|
69
|
+
/**
|
|
70
|
+
* The version that's currently being used.
|
|
71
|
+
* Defaults to the bigger version in the downloads folder.
|
|
72
|
+
*/
|
|
73
|
+
currentVersion?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Download progress callback
|
|
76
|
+
*/
|
|
77
|
+
onProgress?: (progress: number) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Callback executed if the user agrees to update, before starting the download.
|
|
80
|
+
*/
|
|
81
|
+
onDownloadStart?: (version: string) => void;
|
|
82
|
+
}): Promise<string | null>;
|
|
83
|
+
export {};
|