create-react-native-module
Advanced tools
Comparing version 0.17.1 to 0.18.0
# Changelog | ||
### 0.18.0 | ||
* generate example with symlink by default, with multiple workarounds in example metro.config.js (#309) | ||
### 0.17.1 | ||
@@ -4,0 +8,0 @@ |
@@ -130,4 +130,7 @@ const emoji = require('node-emoji'); | ||
command: '--generate-example', | ||
description: 'Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally', | ||
description: 'Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally', | ||
}, { | ||
command: '--example-file-linkage', | ||
description: "DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js", | ||
}, { | ||
command: '--example-name [exampleName]', | ||
@@ -134,0 +137,0 @@ description: 'Name for the example project', |
@@ -82,2 +82,3 @@ // Node.js built-in: | ||
generateExample = DEFAULT_GENERATE_EXAMPLE, | ||
exampleFileLinkage = false, | ||
exampleName = DEFAULT_EXAMPLE_NAME, | ||
@@ -118,2 +119,3 @@ exampleReactNativeVersion = DEFAULT_EXAMPLE_REACT_NATIVE_VERSION, | ||
generateExample: ${generateExample} | ||
exampleFileLinkage: ${exampleFileLinkage} | ||
exampleName: ${exampleName} | ||
@@ -183,2 +185,3 @@ writeExamplePodfile: ${writeExamplePodfile} | ||
generateExample, | ||
exampleFileLinkage, | ||
exampleName, | ||
@@ -220,2 +223,3 @@ }; | ||
useAppleNetworking, | ||
exampleFileLinkage, | ||
exampleName, | ||
@@ -234,15 +238,25 @@ writeExamplePodfile, | ||
return new Promise((resolve, reject) => { | ||
// Add postinstall script to the example package.json | ||
console.info('Adding cleanup postinstall task to the example app'); | ||
// determine this path before the next steps: | ||
const pathExampleApp = `./${moduleName}/${exampleName}`; | ||
npmAddScriptSync(`${pathExampleApp}/package.json`, { | ||
key: 'postinstall', | ||
value: `node ../scripts/examples_postinstall.js` | ||
}, fs); | ||
// postinstall workaround script *only* needed in case | ||
// the DEPRECATED --example-file-linkage option | ||
// (exampleFileLinkage: true) is used | ||
// (not needed otherwise): | ||
if (exampleFileLinkage) { | ||
console.info('Adding the cleanup postinstall *workaround* task to the example app'); | ||
npmAddScriptSync(`${pathExampleApp}/package.json`, { | ||
key: 'postinstall', | ||
value: `node ../scripts/examples_postinstall.js` | ||
}, fs); | ||
} | ||
// Add and link the new library | ||
console.info('Linking the new module library to the example app'); | ||
const addLinkLibraryCommand = exampleFileLinkage | ||
? 'yarn add file:../' | ||
: 'yarn add link:../'; | ||
const addLinkLibraryOptions = { cwd: pathExampleApp, stdio: 'inherit' }; | ||
try { | ||
commandSync('yarn add file:../', addLinkLibraryOptions); | ||
commandSync(addLinkLibraryCommand, addLinkLibraryOptions); | ||
} catch (e) { | ||
@@ -249,0 +263,0 @@ console.error('Yarn failure for example, aborting'); |
{ | ||
"name": "create-react-native-module", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"description": "Tool to create a React Native library module or view module with a single command", | ||
@@ -5,0 +5,0 @@ "bin": "bin/cli.js", |
@@ -31,3 +31,3 @@ # create-react-native-module | ||
- Minimum React Native version: 0.60 (outdated), 0.61 (recommended) | ||
- generated example app with known issue with adding dependencies to the library root - see [issue #308](https://github.com/brodybits/create-react-native-module/issues/308) | ||
- generated example app with symlink by default, has known issue with adding dependencies to the library root - see [issue #308](https://github.com/brodybits/create-react-native-module/issues/308) | ||
- Platform fork support | ||
@@ -108,3 +108,4 @@ - tvOS platform fork | ||
--use-apple-networking [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code | ||
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally | ||
--example-file-linkage DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js | ||
--example-name <exampleName> Name for the example project (default: `example`) | ||
@@ -145,3 +146,4 @@ --example-react-native-version <version> React Native version for the generated example project (default: `react-native@latest`) | ||
view: Boolean, /* Generate the module as a very simple native view component (Default: false) */ | ||
generateExample: Boolean, /* Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally (Default: false) */ | ||
generateExample: Boolean, /* Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally (Default: false) */ | ||
exampleFileLinkage: Boolean, /* DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js (Default: false) */ | ||
exampleName: String, /* Name for the example project (Default: `example`) */ | ||
@@ -148,0 +150,0 @@ exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `react-native@latest`) */ |
module.exports = [{ | ||
name: () => 'scripts/examples_postinstall.js', | ||
// only needed in case of `exampleFileLinkage: true`: | ||
name: ({ exampleFileLinkage }) => | ||
exampleFileLinkage ? 'scripts/examples_postinstall.js' : undefined, | ||
content: ({ exampleName }) => | ||
@@ -117,2 +119,35 @@ `#!/usr/bin/env node | ||
}, { | ||
// metro.config.js workarounds needed in case of `exampleFileLinkage: false`: | ||
name: ({ exampleName, exampleFileLinkage }) => | ||
exampleFileLinkage ? undefined : `${exampleName}/metro.config.js`, | ||
content: ({ moduleName, exampleName }) => `// metro.config.js | ||
// | ||
// with multiple workarounds for this issue with symlinks: | ||
// https://github.com/facebook/metro/issues/1 | ||
// | ||
// with thanks to @johnryan (<https://github.com/johnryan>) | ||
// for the pointers to multiple workaround solutions here: | ||
// https://github.com/facebook/metro/issues/1#issuecomment-541642857 | ||
// | ||
// see also this discussion: | ||
// https://github.com/brodybits/create-react-native-module/issues/232 | ||
const path = require('path') | ||
module.exports = { | ||
// workaround for an issue with symlinks encountered starting with | ||
// metro@0.55 / React Native 0.61 | ||
// (not needed with React Native 0.60 / metro@0.54) | ||
resolver: { | ||
extraNodeModules: new Proxy( | ||
{}, | ||
{ get: (_, name) => path.resolve('.', 'node_modules', name) } | ||
) | ||
}, | ||
// quick workaround for another issue with symlinks | ||
watchFolders: ['.', '..'] | ||
} | ||
`, | ||
}, { | ||
name: ({ exampleName, writeExamplePodfile }) => | ||
@@ -119,0 +154,0 @@ writeExamplePodfile ? `${exampleName}/ios/Podfile` : undefined, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83420
1483
277