Skip to content

Commit 4aba928

Browse files
committed
feat: add support for generating JS libraries with Expo
1 parent 498d8b1 commit 4aba928

File tree

81 files changed

+159
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+159
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions

src/create.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import validateNpmPackage from 'validate-npm-package-name';
1010
import githubUsername from 'github-username';
1111
import pack from '../package.json';
1212

13-
const TEMPLATE = path.resolve(__dirname, '../templates/library');
1413
const BINARIES = /(gradlew|\.(jar|keystore|png|jpg|gif))$/;
15-
const CPP_FILES = path.resolve(__dirname, '../templates/cppLibrary');
14+
15+
const COMMON_FILES = path.resolve(__dirname, '../templates/common');
16+
const NATIVE_FILES = path.resolve(__dirname, '../templates/native-library');
17+
const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');
18+
const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');
1619

1720
export default async function create(argv: yargs.Arguments<any>) {
1821
const folder = path.join(process.cwd(), argv.name);
@@ -52,6 +55,7 @@ export default async function create(argv: yargs.Arguments<any>) {
5255
authorEmail,
5356
authorUrl,
5457
githubUrl: repo,
58+
useNative,
5559
useCpp,
5660
} = (await inquirer.prompt([
5761
{
@@ -120,11 +124,18 @@ export default async function create(argv: yargs.Arguments<any>) {
120124
},
121125
validate: input => /^https?:\/\//.test(input) || 'Must be a valid URL',
122126
},
127+
{
128+
type: 'confirm',
129+
name: 'useNative',
130+
message: 'Do you want to use Java or Objective-C code?',
131+
default: true,
132+
},
123133
{
124134
type: 'confirm',
125135
name: 'useCpp',
126136
message: 'Do you want to use C++ code?',
127137
default: false,
138+
when: response => response.useNative,
128139
},
129140
])) as {
130141
slug: string;
@@ -133,6 +144,7 @@ export default async function create(argv: yargs.Arguments<any>) {
133144
authorEmail: string;
134145
authorUrl: string;
135146
githubUrl: string;
147+
useNative: boolean;
136148
useCpp: boolean;
137149
};
138150

@@ -185,9 +197,15 @@ export default async function create(argv: yargs.Arguments<any>) {
185197
}
186198
};
187199

188-
await copyDir(TEMPLATE, folder);
200+
await copyDir(COMMON_FILES, folder);
201+
202+
if (useNative) {
203+
await copyDir(NATIVE_FILES, folder);
204+
} else {
205+
await copyDir(EXPO_FILES, folder);
206+
}
189207

190-
if (options.project.useCpp) {
208+
if (useCpp) {
191209
await copyDir(CPP_FILES, folder);
192210
}
193211

File renamed without changes.
File renamed without changes.

templates/library/$.gitignore renamed to templates/common/$.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ buck-out/
5353
android/app/libs
5454
android/keystores/debug.keystore
5555

56+
# Expo
57+
.expo/*
58+
5659
# generated by bob
5760
lib/

templates/library/$package.json renamed to templates/common/$package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"prepare": "bob build",
2121
"release": "release-it",
2222
"example": "yarn --cwd example",
23-
"pods": "cd example/ios && node -e \"process.exit(require('os').platform() === 'darwin')\" || pod install",
23+
"pods": "node -e \"process.exit(require('os').platform() !== 'darwin')\" && test -d example/ios && cd example/ios && pod install || printf ''",
2424
"bootstrap": "yarn example && yarn && yarn pods"
2525
},
2626
"keywords": [
@@ -38,22 +38,22 @@
3838
"devDependencies": {
3939
"@commitlint/config-conventional": "^8.3.4",
4040
"@react-native-community/bob": "^<%= bob.version %>",
41-
"@react-native-community/eslint-config": "^0.0.7",
42-
"@release-it/conventional-changelog": "^1.1.0",
43-
"@types/jest": "^25.1.2",
41+
"@react-native-community/eslint-config": "^1.1.0",
42+
"@release-it/conventional-changelog": "^1.1.4",
43+
"@types/jest": "^25.2.1",
4444
"@types/react": "^16.9.19",
45-
"@types/react-native": "0.61.10",
46-
"commitlint": "^8.3.4",
45+
"@types/react-native": "0.62.7",
46+
"commitlint": "^8.3.5",
4747
"eslint": "^6.8.0",
48-
"eslint-config-prettier": "^6.10.0",
49-
"eslint-plugin-prettier": "^3.1.2",
50-
"husky": "^4.0.1",
51-
"jest": "^25.1.0",
52-
"prettier": "^1.19.1",
48+
"eslint-config-prettier": "^6.11.0",
49+
"eslint-plugin-prettier": "^3.1.3",
50+
"husky": "^4.2.5",
51+
"jest": "^26.0.1",
52+
"prettier": "^2.0.5",
5353
"react": "~16.9.0",
5454
"react-native": "~0.61.5",
55-
"release-it": "^12.6.3",
56-
"typescript": "^3.7.5"
55+
"release-it": "^13.5.8",
56+
"typescript": "^3.8.3"
5757
},
5858
"peerDependencies": {
5959
"react": "*",
@@ -98,8 +98,8 @@
9898
},
9999
"release-it": {
100100
"git": {
101-
"commitMessage": "chore: release %s",
102-
"tagName": "v%s"
101+
"commitMessage": "chore: release ${version}",
102+
"tagName": "v${version}"
103103
},
104104
"npm": {
105105
"publish": true
File renamed without changes.

0 commit comments

Comments
 (0)