Skip to content

Commit

Permalink
feat(apps): react-navigation example
Browse files Browse the repository at this point in the history
  • Loading branch information
crherman7 committed Jan 15, 2025
1 parent f20d7bc commit aab213c
Show file tree
Hide file tree
Showing 105 changed files with 3,313 additions and 10 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ yarn-error.log*
# Astro
.astro/

# Flagship Code
!**/coderc/build
apps/example/ios
apps/example/android

!**/plugin-native-navigation/__tests__/**/node_modules
!**/plugin-fsapp/__tests__/**/node_modules
!**/__tests__/**/node_modules
apps/**/ios
apps/**/android
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@brandingbrand/code-example",
"name": "@brandingbrand/code-example-app-router",
"version": "1.0.0",
"license": "MIT",
"private": true,
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions apps/example-react-navigation/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
7 changes: 7 additions & 0 deletions apps/example-react-navigation/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: "avoid",
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: "all",
};
1 change: 1 addition & 0 deletions apps/example-react-navigation/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions apps/example-react-navigation/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions apps/example-react-navigation/coderc/build/build.internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {defineBuild} from '@brandingbrand/code-cli-kit';
import type {CodePluginAsset} from '@brandingbrand/code-plugin-asset';
import type {CodePluginAppIcon} from '@brandingbrand/code-plugin-app-icon';
import type {CodePluginSplashScreen} from '@brandingbrand/code-plugin-splash-screen';

export default defineBuild<
CodePluginAsset & CodePluginAppIcon & CodePluginSplashScreen
>({
ios: {
bundleId: 'com.brandingbrand',
displayName: 'Branding Brand',
plist: {
urlScheme: {
scheme: 'app',
},
},
},
android: {
packageName: 'com.brandingbrand',
displayName: 'Branding Brand',
},
codePluginAsset: {
plugin: {
assetPath: ['./coderc/assets/fonts'],
},
},
codePluginAppIcon: {
plugin: {
appIconPath: './coderc/assets/app-icon',
iconInsets: 20,
},
},
codePluginSplashScreen: {
plugin: {
ios: {
type: 'generated',
generated: {
logoPath: './coderc/assets/splash-screen/logo.png',
backgroundColor: '#fff',
},
},
android: {
type: 'generated',
generated: {
logoPath: './coderc/assets/splash-screen/logo.png',
backgroundColor: '#fff',
},
},
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @jest-environment-options {"requireTemplate": true}
*/

/// <reference types="@brandingbrand/code-jest-config" />

import {fs, path} from '@brandingbrand/code-cli-kit';
import plugin from '../src';

describe('plugin', () => {
it('ios', async () => {
await plugin.ios?.({} as any, {} as any);

const pbxProj = await fs.readFile(path.ios.projectPbxProj, 'utf-8');

expect(pbxProj).toContain(
'${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh',
);
});

it('android', async () => {
await plugin.android?.({} as any, {} as any);

const appBuildGradle = await fs.readFile(
path.android.appBuildGradle,
'utf-8',
);
const settingsGradle = await fs.readFile(
path.project.resolve('android', 'settings.gradle'),
'utf-8',
);

expect(appBuildGradle).toContain('../../../node_modules');
expect(settingsGradle).toContain('../../../node_modules');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "plugin-monorepo",
"version": "0.0.0",
"license": "UNLICENSED",
"private": true,
"main": "src/index.ts",
"scripts": {
"lint": "eslint . --max-warnings 0",
"test": "jest"
},
"jest": {
"preset": "@brandingbrand/code-jest-config"
},
"types": "src/index.ts",
"devDependencies": {
"eslint": "^8.0.0",
"jest": "^29.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Defines a plugin for @brandingbrand/code-cli-kit.
* @module Plugin
*/

import {
definePlugin,
path,
string,
withUTF8,
} from '@brandingbrand/code-cli-kit';

/**
* Defines a plugin with functions for both iOS and Android platforms.
* @alias module:Plugin
* @param {Object} build - The build configuration object.
* @param {Object} options - The options object.
*/
export default definePlugin({
/**
* Function to be executed for iOS platform.
* @param {Object} _build - The build configuration object for iOS.
* @param {Object} _options - The options object for iOS.
* @returns {Promise<void>} A promise that resolves when the process completes.
*/
ios: async function (_build: object, _options: object): Promise<void> {
await withUTF8(path.ios.projectPbxProj, content => {
return string.replace(
content,
/(..\/)+?node_modules\/react-native/gm,
'${REACT_NATIVE_PATH}',
);
});
},

/**
* Function to be executed for Android platform.
* @param {Object} _build - The build configuration object for Android.
* @param {Object} _options - The options object for Android.
* @returns {Promise<void>} A promise that resolves when the process completes.
*/
android: async function (_build: object, _options: object): Promise<void> {
await withUTF8(
path.project.resolve('android', 'settings.gradle'),
content => {
return string.replace(
content,
/(..\/)+?(node_modules)/gm,
'../../../$2',
);
},
);

await withUTF8(path.android.appBuildGradle, content => {
content = string.replace(
content,
/(react\s+{\n(\s+))/gm,
'$1reactNativeDir = file("../../../../node_modules/react-native")\n$2',
);

content = string.replace(
content,
/(..\/)+?(node_modules\/@react-native-community)/gm,
'../../../../$2',
);

return content;
});
},
});
Loading

0 comments on commit aab213c

Please sign in to comment.