Skip to content
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

feat(router): ENG-5727 router impl #2757

Merged
Merged
6 changes: 0 additions & 6 deletions apps/example/coderc/plugins/plugin-example/.eslintrc.js

This file was deleted.

11 changes: 0 additions & 11 deletions apps/example/coderc/plugins/plugin-example/__tests__/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions apps/example/coderc/plugins/plugin-example/tsconfig.json

This file was deleted.

36 changes: 36 additions & 0 deletions apps/example/coderc/plugins/plugin-monorepo/__tests__/index.ts
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
@@ -1,5 +1,5 @@
{
"name": "@brandingbrand/code-plugin-example",
"name": "plugin-monorepo",
"version": "0.0.0",
"license": "UNLICENSED",
"private": true,
Expand All @@ -13,8 +13,7 @@
},
"types": "src/index.ts",
"devDependencies": {
"eslint": "^8.56.0",
"jest": "^29.2.1",
"typescript": "4.8.4"
"eslint": "^8.0.0",
"jest": "^29.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
* @module Plugin
*/

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

/**
* Defines a plugin with functions for both iOS and Android platforms.
Expand All @@ -18,13 +23,48 @@ export default definePlugin({
* @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> {},
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> {},
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