Skip to content

Commit 50adc57

Browse files
committed
Initial commit
0 parents  commit 50adc57

14 files changed

+9035
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn.lock linguist-generated

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: weekly
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Check patches compatibility
2+
on: push
3+
jobs:
4+
build:
5+
runs-on: shopify-ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
8+
9+
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
10+
with:
11+
node-version: 16
12+
cache: "yarn"
13+
14+
- name: Installing dependencies
15+
run: yarn install --frozen-lockfile
16+
- name: Applying patches
17+
run: yarn patch-package --error-on-fail --error-on-warn

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
build
3+
.DS_Store
4+
npm-debug.log
5+
yarn-error.log
6+
.eslintcache
7+
*.tsbuildinfo

.npmignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
!templates/**/.gitignore
2+
3+
/.eslintignore
4+
/.eslintrc.js
5+
/.gitattributes
6+
/.github
7+
/.nvmrc
8+
/.prettierignore
9+
/.prettierrc.json
10+
/babel.config.js
11+
/jest.config.js
12+
/shipit.production.yml
13+
/src
14+
/tsconfig.eslint.json
15+
/tsconfig.json
16+
17+
18+
.DS_Store
19+
.eslintcache
20+
*.tsbuildinfo
21+
npm-debug.log
22+
yarn-error.log
23+
yarn.lock
24+
README_INTERNAL.md

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Shopify Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## This repo is deprecated
2+
3+
shop-minis-runtime was moved to the monorepo in https://github.com/shopify/shop-client/
4+
This repository is no longer used and maintained.
5+
6+
# shop-minis-runtime
7+
8+
shop-minis-runtime is responsible for guaranteeing that the context of Minis in development matches the context provided by Shop in production.
9+
10+
## Dependencies
11+
12+
Dependencies are provided by Shop itself during production runtime, however, that's not the case when the Mini is executed in a remote setup during development. In those cases, shop-minis-runtime will be the source of truth for which dependencies are available (and which versions they have).
13+
14+
## React context values
15+
16+
React context values are also missing when the Mini is executed in development mode. shop-minis-runtime will expose provider components that mimic the production environment of Shop.
17+
18+
## Metro config
19+
20+
To use the metro config exposed in this package you can use this example `metro.config.js` file:
21+
22+
```js
23+
// metro.config.js
24+
const { getMinisMetroConfig } = require("@shopify/shop-minis-runtime/metro-config");
25+
26+
module.exports = getMinisMetroConfig();
27+
```
28+
29+
## Babel preset
30+
31+
To use the babel preset exposed in this package you can use this example `babel.config.js` file:
32+
33+
```js
34+
// babel.config.js
35+
module.exports = {
36+
presets: ["@shopify/shop-minis-runtime/babel-preset"],
37+
};
38+
```

README_INTERNAL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# shop-minis-runtime
2+
3+
For now, this package just lists the dependencies that we share with partners and is responsible for making sure that the version we provide matches the version of that dependency used by Shop.
4+
5+
## Development
6+
7+
#### Installing dependencies
8+
9+
Use `yarn`, don't create or commit an npm `package-lock.json`. `yarn.lock` is the source of truth.
10+
11+
## Creating a new release
12+
13+
1. Check out and pull the latest `main` branch.
14+
2. Run `yarn version --patch`.
15+
3. Push both the version bump commit and the tag `git push origin main --follow-tags`
16+
4. In [shipit](https://shipit.shopify.io/shopify/shop-minis-runtime/production), find the commit corresponding to the new release and deploy it.
17+
5. After the deploy succeeds, the new version should be published in the [npm public registry](https://www.npmjs.com/package/@shopify/shop-minis-runtime) and ready to be used.
18+
19+
## TODO
20+
21+
- Migrate React provider components from the minis SDK to this package
22+
- Automate synchronization of dependency versions between this package and Shop
23+
- Nice to have: move patch-package related stuff here instead of having it in the minis templates
24+
- Move to a monorepo with other minis related packages

babel-preset.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = () => ({
2+
presets: [["module:metro-react-native-babel-preset", { useTransformReactJSXExperimental: true }]],
3+
plugins: [
4+
[
5+
"@babel/plugin-transform-react-jsx",
6+
{
7+
runtime: "automatic",
8+
},
9+
],
10+
["@babel/plugin-transform-named-capturing-groups-regex"],
11+
["import-graphql"],
12+
["react-native-reanimated/plugin"],
13+
],
14+
});

metro-config.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const path = require("path");
2+
const { getDefaultConfig } = require("metro-config");
3+
4+
module.exports.getMinisMetroConfig = async function getMinisMetroConfig() {
5+
const {
6+
resolver: { sourceExts, assetExts },
7+
} = await getDefaultConfig();
8+
9+
return {
10+
server: {
11+
port: 8082,
12+
},
13+
transformer: {
14+
getTransformOptions: async () => ({
15+
transform: {
16+
experimentalImportSupport: false,
17+
inlineRequires: true,
18+
},
19+
}),
20+
babelTransformerPath: require.resolve("react-native-svg-transformer"),
21+
},
22+
resolver: {
23+
assetExts: assetExts.filter((ext) => ext !== "svg"),
24+
sourceExts: [...sourceExts, "svg"],
25+
platforms: ["ios", "android"],
26+
resolveRequest: (context, moduleName, platform) => {
27+
// use a custom path instead of a relative import to load the mini manifest
28+
if (moduleName === "minis:manifest") {
29+
const manifestPath = path.join(process.cwd(), "src", "manifest.json");
30+
try {
31+
return {
32+
filePath: require.resolve(manifestPath),
33+
type: "sourceFile",
34+
};
35+
} catch (err) {
36+
// This shouldn't really happen, the CLI would explode before actually launching metro.
37+
console.warn(`Your manifest file could not be found in path ${manifestPath}`);
38+
return { type: "empty" };
39+
}
40+
}
41+
42+
// Chain to the standard Metro resolver for modules other than the manifest.
43+
return context.resolveRequest(context, moduleName, platform);
44+
},
45+
},
46+
};
47+
};

0 commit comments

Comments
 (0)