-
Notifications
You must be signed in to change notification settings - Fork 41
feat: expose Brownfield Gradle Plugin as node module #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4a176e0
ccc8ee2
7497ab3
f2e8fd2
997b629
fc1cd32
a8cdf09
c278b93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@callstack/react-native-brownfield': patch | ||
| --- | ||
|
|
||
| Expose the Brownfield Android Gradle Plugin source from the npm package for opt-in local patching. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [versions] | ||
| kotlinJvm = "2.0.21" | ||
| kotlinJvm = "2.2.21" | ||
| ktlint = "12.1.1" | ||
| detekt = "1.23.7" | ||
| agp = "8.5.2" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| pluginManagement { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| gradlePluginPortal() | ||
| } | ||
| } | ||
|
Comment on lines
+1
to
+7
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Why these changes are required?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without these, composite build can't resolve the plugin's dependencies. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /gradle-plugin/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * Copies the Brownfield Gradle plugin source from gradle-plugins/react/brownfield/ | ||
| * into packages/react-native-brownfield/gradle-plugin/brownfield/ so that the | ||
| * plugin source is included in the published npm package. | ||
| * | ||
| * This enables consumers to use the plugin as a composite build via includeBuild | ||
| * from node_modules instead of downloading it from Maven Central — useful for | ||
| * local patching or working with an unreleased version. | ||
| * | ||
| * Run with --clean to remove the copied output (e.g. after publishing or testing). | ||
| * | ||
| * Usage: | ||
| * node sync-gradle-plugin-source.js # copy | ||
| * node sync-gradle-plugin-source.js --clean # remove | ||
| */ | ||
| const fs = require('node:fs'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this file is copying the source of brownfield plugin to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
| const path = require('node:path'); | ||
|
|
||
| const packageRoot = path.resolve(__dirname, '..'); | ||
| const repoRoot = path.resolve(packageRoot, '..', '..'); | ||
|
|
||
| const sourceBrownfieldPath = path.join( | ||
| repoRoot, | ||
| 'gradle-plugins', | ||
| 'react', | ||
| 'brownfield' | ||
| ); | ||
|
|
||
| const targetRoot = path.join(packageRoot, 'gradle-plugin'); | ||
| const targetBrownfieldPath = path.join(targetRoot, 'brownfield'); | ||
|
|
||
| if (process.argv.includes('--clean')) { | ||
| // Remove the copied gradle-plugin directory from the package | ||
| fs.rmSync(targetRoot, { recursive: true, force: true }); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| // Always start from a clean slate to avoid stale files | ||
| fs.rmSync(targetRoot, { recursive: true, force: true }); | ||
|
|
||
| fs.cpSync(sourceBrownfieldPath, targetBrownfieldPath, { | ||
| recursive: true, | ||
| // Exclude Gradle build artefacts and local state that should not be shipped | ||
| filter(source) { | ||
| const relativePath = path.relative(sourceBrownfieldPath, source); | ||
| const parts = relativePath.split(path.sep); | ||
|
|
||
| return !parts.some((part) => | ||
| ['build', '.gradle', 'local.properties', '.kotlin', 'bin'].includes(part) | ||
| ); | ||
| }, | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.