expo-module-scripts 2.0.0 → 2.1.0
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/CHANGELOG.md +29 -0
- package/README.md +10 -8
- package/bin/expo-module-configure +64 -4
- package/bin/expo-module-readme +2 -2
- package/package.json +14 -13
- package/templates/README.md +4 -4
- package/templates/scripts/with-node.sh +44 -0
- package/templates/tsconfig.json +1 -1
- package/tsconfig.base.json +1 -1
- package/tsconfig.plugin.json +4 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unpublished
|
|
4
|
+
|
|
5
|
+
### 🛠 Breaking changes
|
|
6
|
+
|
|
7
|
+
### 🎉 New features
|
|
8
|
+
|
|
9
|
+
### 🐛 Bug fixes
|
|
10
|
+
|
|
11
|
+
### 💡 Others
|
|
12
|
+
|
|
13
|
+
## 2.1.0 — 2022-08-04
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Add `templates/scripts/source-login-scripts.sh` vendoring tool for node binary resolution in Xcode build phases scripts. ([#15336](https://github.com/expo/expo/pull/15336) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Fixed `source-login-scripts.sh` error when `extendedglob` is enabled in zsh config. ([#17024](https://github.com/expo/expo/pull/17024) by [@kudo](https://github.com/kudo))
|
|
22
|
+
- Fixed `expo-module prepare` error if target packages contain temporary kotlin build files. ([#17023](https://github.com/expo/expo/pull/17023) by [@kudo](https://github.com/kudo))
|
|
23
|
+
- Improved support of nvm sourcing in iOS shell scripts. ([#17109](https://github.com/expo/expo/pull/17109) by [@liamronancb](https://github.com/liamronancb))
|
|
24
|
+
- Fixed `source-login-scripts.sh` ~/zlogin typo. ([#17622](https://github.com/expo/expo/pull/17622) by [@vrgimael](https://github.com/vrgimael))
|
|
25
|
+
- Deprecated the unreliable `source-login-scripts.sh` and sourcing the Node.js binary path from `.xcode.env` and `.xcode.env.local`. ([#18330](https://github.com/expo/expo/pull/18330) by [@kudo](https://github.com/kudo))
|
|
26
|
+
|
|
27
|
+
### 💡 Others
|
|
28
|
+
|
|
29
|
+
- Updated `@testing-library/react-hooks` to version `7.0.1`. ([#14552](https://github.com/expo/expo/pull/14552)) by [@Simek](https://github.com/Simek))
|
package/README.md
CHANGED
|
@@ -54,8 +54,8 @@ Add the following scripts to your `package.json` and run `yarn`
|
|
|
54
54
|
|
|
55
55
|
Running `yarn` will now run the `prepare` script, which generates any missing files:
|
|
56
56
|
|
|
57
|
-
- [`.eslintrc.js`](./templates/.eslintrc.js) ([docs](https://eslint.org/docs/user-guide/configuring)) this extends [`eslint-config-universe`](https://github.com/expo/expo/tree/
|
|
58
|
-
- Optionally you can customize Prettier too: [.prettierrc guide](https://github.com/expo/expo/tree/
|
|
57
|
+
- [`.eslintrc.js`](./templates/.eslintrc.js) ([docs](https://eslint.org/docs/user-guide/configuring)) this extends [`eslint-config-universe`](https://github.com/expo/expo/tree/main/packages/eslint-config-universe).
|
|
58
|
+
- Optionally you can customize Prettier too: [.prettierrc guide](https://github.com/expo/expo/tree/main/packages/eslint-config-universe#customizing-prettier).
|
|
59
59
|
- [`.npmignore`](./templates/.npmignore) ([docs](https://docs.npmjs.com/misc/developers)) currently only ignores the `babel.config.js` in your module. You might also want to also add tests and docs.
|
|
60
60
|
- Expo modules use `.npmignore` **instead of** the `files` field in the `package.json`.
|
|
61
61
|
- (Pro Tip) Test which files get packaged by running `npm pack`. If you see files that aren't crucial to running the module, you should add them to `.npmignore`.
|
|
@@ -65,11 +65,13 @@ Running `yarn` will now run the `prepare` script, which generates any missing fi
|
|
|
65
65
|
- Try and incorporate a table of contents (TOC).
|
|
66
66
|
- [`tsconfig.json`](./templates/tsconfig.json) ([docs](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)) extends [`tsconfig.base.json`](./tsconfig.base.json) this is important for ensuring all Unimodules use the same version of TypeScript.
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Besides, running `yarn prepare` script will also synchronize optional files from `expo-module-scripts` when the file is present and contains the `@generated` pattern:
|
|
69
|
+
|
|
70
|
+
- [`with-node.sh`](./templates/scripts/with-node.sh): An Xcode build phase script helper for Node.js binary resolution. It sources the project's **.xcode.env** and **.xcode.env.local** files, which may define an environment variable named `NODE_BINARY` to specify the file path of the Node.js binary to run.
|
|
69
71
|
|
|
70
72
|
### 🔌 Config Plugin
|
|
71
73
|
|
|
72
|
-
To create a [config plugin](https://github.com/expo/expo-cli/blob/
|
|
74
|
+
To create a [config plugin](https://github.com/expo/expo-cli/blob/main/packages/config-plugins/README.md) that automatically configures your native code, you have two options:
|
|
73
75
|
|
|
74
76
|
1. Create a `plugin` folder and write your plugin in TypeScript (recommended).
|
|
75
77
|
2. Create an `app.plugin.js` file in the project root and write the plugin in pure Node.js-compliant JavaScript.
|
|
@@ -91,7 +93,7 @@ The following files are required for a TypeScript plugin:
|
|
|
91
93
|
╰── src/index.ts ➡️ The TypeScript entry point for your plugin
|
|
92
94
|
```
|
|
93
95
|
|
|
94
|
-
Create
|
|
96
|
+
Create an `app.plugin.js` (the entry point for a config plugin):
|
|
95
97
|
|
|
96
98
|
```js
|
|
97
99
|
module.exports = require('./plugin/build');
|
|
@@ -142,14 +144,14 @@ Use the following scripts to interact with the plugin:
|
|
|
142
144
|
|
|
143
145
|
### 🤡 Jest
|
|
144
146
|
|
|
145
|
-
The Jest preset extends [`jest-expo`](https://github.com/expo/expo/tree/
|
|
147
|
+
The Jest preset extends [`jest-expo`](https://github.com/expo/expo/tree/main/packages/jest-expo) or [`jest-expo-enzyme`](https://github.com/expo/expo/tree/main/packages/jest-expo-enzyme) and adds proper TypeScript support and type declarations to the presets.
|
|
146
148
|
|
|
147
149
|
**For unit testing API-based modules:**
|
|
148
150
|
|
|
149
151
|
```json
|
|
150
152
|
{
|
|
151
153
|
"jest": {
|
|
152
|
-
"preset": "expo-module-scripts
|
|
154
|
+
"preset": "expo-module-scripts"
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
```
|
|
@@ -286,7 +288,7 @@ One of the rules enforced is restricting any imports from the `fbjs` library. As
|
|
|
286
288
|
Replacements for common `fbjs` uses-cases are listed below:
|
|
287
289
|
|
|
288
290
|
- `invariant`- replace with [`invariant`](https://www.npmjs.com/package/invariant)
|
|
289
|
-
- `ExecutionEnvironment`- replace with [`Platform` from `@unimodules/core`](https://github.com/expo/expo/blob/
|
|
291
|
+
- `ExecutionEnvironment`- replace with [`Platform` from `@unimodules/core`](https://github.com/expo/expo/blob/main/packages/%40unimodules/react-native-adapter/src/Platform.ts)
|
|
290
292
|
|
|
291
293
|
#### lint plugin
|
|
292
294
|
|
|
@@ -6,11 +6,71 @@ script_dir="$(dirname "$0")"
|
|
|
6
6
|
|
|
7
7
|
shopt -s dotglob
|
|
8
8
|
|
|
9
|
+
# an optional template file will be synced only if the target file is present in the file system,
|
|
10
|
+
# and its content contains the string `@generated`.
|
|
11
|
+
OPTIONAL_TEMPLATE_FILES=(
|
|
12
|
+
# add a relative file path from `templates/` for each new optional file
|
|
13
|
+
"scripts/with-node.sh"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# returns relative file paths inside a given directory without the leading "./".
|
|
17
|
+
# usage: get_relative_files "/path/to/dir"
|
|
18
|
+
get_relative_files() {
|
|
19
|
+
pushd $1 > /dev/null
|
|
20
|
+
local files=$(find . -type f | cut -c 3-)
|
|
21
|
+
popd > /dev/null
|
|
22
|
+
echo $files
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# syncs the source file if the target file is missing or the existing file contains `@generated`.
|
|
27
|
+
# usage: sync_file_if_missing "/path/source_path" "/path/target_path"
|
|
28
|
+
sync_file_if_missing() {
|
|
29
|
+
local source=$1
|
|
30
|
+
local target=$2
|
|
31
|
+
# echo "sync_file_if_missing $source -> $target"
|
|
32
|
+
if [ ! -f "$target" ] || grep --quiet "@generated" "$target"; then
|
|
33
|
+
rsync --checksum "$source" "$target"
|
|
34
|
+
fi
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# syncs the source file if the target file is present in the file system and its content contains `@generated`.
|
|
38
|
+
# usage: sync_file_if_present "/path/source_path" "/path/target_path"
|
|
39
|
+
sync_file_if_present() {
|
|
40
|
+
local source=$1
|
|
41
|
+
local target=$2
|
|
42
|
+
# echo "sync_file_if_present $source -> $target"
|
|
43
|
+
if [ -f "$target" ] && grep --quiet "@generated" "$target"; then
|
|
44
|
+
rsync --checksum "$source" "$target"
|
|
45
|
+
fi
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# check if a file is listed in `OPTIONAL_TEMPLATE_FILES`.
|
|
49
|
+
# usage: if is_optional_file "path/to/file"; then ... fi
|
|
50
|
+
is_optional_file() {
|
|
51
|
+
local file=$1
|
|
52
|
+
for optional_file in "${OPTIONAL_TEMPLATE_FILES[@]}"; do
|
|
53
|
+
if [ "$file" = "$optional_file" ]; then
|
|
54
|
+
true
|
|
55
|
+
return
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
false
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# script main starts from here
|
|
65
|
+
#
|
|
66
|
+
|
|
9
67
|
"$script_dir/expo-module-readme"
|
|
10
68
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if
|
|
14
|
-
|
|
69
|
+
template_files=$(get_relative_files "$script_dir/../templates")
|
|
70
|
+
for template_relative_file in $template_files; do
|
|
71
|
+
if is_optional_file "$template_relative_file"; then
|
|
72
|
+
sync_file_if_present "$script_dir/../templates/$template_relative_file" "$template_relative_file"
|
|
73
|
+
else
|
|
74
|
+
sync_file_if_missing "$script_dir/../templates/$template_relative_file" "$template_relative_file"
|
|
15
75
|
fi
|
|
16
76
|
done
|
package/bin/expo-module-readme
CHANGED
|
@@ -37,7 +37,7 @@ function removeOptionals(content) {
|
|
|
37
37
|
return content.replace(regexp, '');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const DEFAULT_HOMEPAGE = 'https://docs.expo.
|
|
40
|
+
const DEFAULT_HOMEPAGE = 'https://docs.expo.dev/versions/latest/';
|
|
41
41
|
|
|
42
42
|
function generateREADME() {
|
|
43
43
|
const template = path.join(__dirname, '..', 'templates', 'README.md');
|
|
@@ -92,7 +92,7 @@ function generateREADME() {
|
|
|
92
92
|
}
|
|
93
93
|
readme = replaceAll('docName', docName, readme);
|
|
94
94
|
if (isAndroid) {
|
|
95
|
-
const androidPackages = glob.sync('android/**/*Package.java');
|
|
95
|
+
const androidPackages = glob.sync('android/src/**/*Package.{java,kt}');
|
|
96
96
|
let androidPackage;
|
|
97
97
|
let androidPackagePath = 'expo.modules.yourModule.YourPackage';
|
|
98
98
|
let androidPackageName = 'YourPackage';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-module-scripts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A private package for various tasks for Expo module packages like compiling and testing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,22 +24,23 @@
|
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/expo/expo/issues"
|
|
26
26
|
},
|
|
27
|
-
"homepage": "https://github.com/expo/expo/tree/
|
|
27
|
+
"homepage": "https://github.com/expo/expo/tree/main/packages/expo-module-scripts#readme",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/cli": "^7.1.2",
|
|
30
30
|
"@expo/npm-proofread": "^1.0.1",
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@types/jest": "^
|
|
34
|
-
"babel-preset-expo": "~
|
|
31
|
+
"@testing-library/react-hooks": "^7.0.1",
|
|
32
|
+
"@tsconfig/node12": "^1.0.9",
|
|
33
|
+
"@types/jest": "^26.0.24",
|
|
34
|
+
"babel-preset-expo": "~9.2.0",
|
|
35
35
|
"commander": "^2.19.0",
|
|
36
|
-
"eslint-config-universe": "^
|
|
37
|
-
"find-yarn-workspace-root": "
|
|
38
|
-
"glob": "^7.1.
|
|
39
|
-
"jest-expo": "~
|
|
40
|
-
"jest-expo-enzyme": "^1.
|
|
36
|
+
"eslint-config-universe": "^11.0.0",
|
|
37
|
+
"find-yarn-workspace-root": "^2.0.0",
|
|
38
|
+
"glob": "^7.1.7",
|
|
39
|
+
"jest-expo": "~46.0.0",
|
|
40
|
+
"jest-expo-enzyme": "^1.2.3",
|
|
41
|
+
"jest-watch-typeahead": "0.6.4",
|
|
41
42
|
"ts-jest": "~26.3.0",
|
|
42
|
-
"typescript": "^4.
|
|
43
|
+
"typescript": "^4.3.5"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8074a07eb9b07884f66c88cd7001376a9c28ca96"
|
|
45
46
|
}
|
package/templates/README.md
CHANGED
|
@@ -5,17 +5,17 @@ ${description}
|
|
|
5
5
|
|
|
6
6
|
# API documentation
|
|
7
7
|
|
|
8
|
-
- [Documentation for the
|
|
9
|
-
- [Documentation for the latest stable release](https://docs.expo.
|
|
8
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/${docName}.md)
|
|
9
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/${docName}/)
|
|
10
10
|
|
|
11
11
|
<!--- end remove for interfaces --->
|
|
12
12
|
# Installation in managed Expo projects
|
|
13
13
|
|
|
14
|
-
For
|
|
14
|
+
For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
|
15
15
|
|
|
16
16
|
# Installation in bare React Native projects
|
|
17
17
|
|
|
18
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
18
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
19
19
|
|
|
20
20
|
### Add the package to your npm dependencies
|
|
21
21
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
# Copyright 2018-present 650 Industries. All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# @generated by expo-module-scripts
|
|
6
|
+
#
|
|
7
|
+
# USAGE:
|
|
8
|
+
# ./with-node.sh command
|
|
9
|
+
|
|
10
|
+
CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
11
|
+
|
|
12
|
+
# Start with a default
|
|
13
|
+
NODE_BINARY=$(command -v node)
|
|
14
|
+
export NODE_BINARY
|
|
15
|
+
|
|
16
|
+
# Override the default with the global environment
|
|
17
|
+
ENV_PATH="$PODS_ROOT/../.xcode.env"
|
|
18
|
+
if [[ -f "$ENV_PATH" ]]; then
|
|
19
|
+
source "$ENV_PATH"
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Override the global with the local environment
|
|
23
|
+
LOCAL_ENV_PATH="${ENV_PATH}.local"
|
|
24
|
+
if [[ -f "$LOCAL_ENV_PATH" ]]; then
|
|
25
|
+
source "$LOCAL_ENV_PATH"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [[ -n "$NODE_BINARY" && -x "$NODE_BINARY" ]]; then
|
|
29
|
+
echo "Node found at: ${NODE_BINARY}"
|
|
30
|
+
else
|
|
31
|
+
cat >&2 << EOF
|
|
32
|
+
[ERROR] Could not find "node" while running an Xcode build script. You need to specify the path to your Node.js executable by defining an environment variable named NODE_BINARY in your project's .xcode.env or .xcode.env.local file. You can set this up quickly by running:
|
|
33
|
+
|
|
34
|
+
echo "export NODE_BINARY=\$(command -v node)" >> .xcode.env
|
|
35
|
+
|
|
36
|
+
in the ios folder of your project.
|
|
37
|
+
EOF
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Execute argument, if present
|
|
42
|
+
if [[ "$#" -gt 0 ]]; then
|
|
43
|
+
"$NODE_BINARY" $@
|
|
44
|
+
fi
|
package/templates/tsconfig.json
CHANGED
package/tsconfig.base.json
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"jsx": "react",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"esModuleInterop": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
8
|
"types": ["jest", "jest-require"],
|
|
10
9
|
"typeRoots": [
|
|
11
10
|
"./ts-declarations",
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
],
|
|
14
13
|
"sourceMap": true,
|
|
15
14
|
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
16
|
"inlineSources": true,
|
|
17
17
|
"strictNullChecks": true,
|
|
18
18
|
"strictPropertyInitialization": true,
|
package/tsconfig.plugin.json
CHANGED