Skip to content

Commit 1903c03

Browse files
committed
feat(apps/prebuild-cli): create new CLI tool for generating prebuild templates
1 parent 0c3b215 commit 1903c03

Some content is hidden

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

48 files changed

+948
-86
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ Thumbs.db
4040

4141
.nx/cache
4242
.nx/workspace-data
43+
44+
.tmp

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache
5+
/.nx/workspace-data

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.verdaccio/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# path to a directory with all packages
2+
storage: ../tmp/local-registry/storage
3+
4+
# a list of other known repositories we can talk to
5+
uplinks:
6+
npmjs:
7+
url: https://registry.npmjs.org/
8+
maxage: 60m
9+
10+
packages:
11+
'**':
12+
# give all users (including non-authenticated users) full access
13+
# because it is a local registry
14+
access: $all
15+
publish: $all
16+
unpublish: $all
17+
18+
# if package is not available locally, proxy requests to npm registry
19+
proxy: npmjs
20+
21+
# log settings
22+
log:
23+
type: stdout
24+
format: pretty
25+
level: warn
26+
27+
publish:
28+
allow_offline: true # set offline to true to allow publish offline

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"recommendations": [
3-
43
"nrwl.angular-console",
5-
"esbenp.prettier-vscode"
4+
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint",
6+
"firsttris.vscode-jest-runner"
67
]
78
}

README.md

Lines changed: 8 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,12 @@
1-
# Source
1+
# react-native-contrib/source
22

3-
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
3+
Monorepo for all React Native contributions.
44

5-
✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨.
5+
## Prebuild
66

7-
[Learn more about this workspace setup and its capabilities](https://nx.dev/getting-started/intro#learn-nx?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!
8-
9-
## Finish your CI setup
10-
11-
[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/aX2fVBwgYa)
12-
13-
14-
## Run tasks
15-
16-
To run tasks with Nx use:
17-
18-
```sh
19-
npx nx <target> <project-name>
20-
```
21-
22-
For example:
23-
24-
```sh
25-
npx nx build myproject
26-
```
27-
28-
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
29-
30-
[More about running tasks in the docs &raquo;](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
31-
32-
## Add new projects
33-
34-
While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature.
35-
36-
To install a new plugin you can use the `nx add` command. Here's an example of adding the React plugin:
37-
```sh
38-
npx nx add @nx/react
7+
```bash
8+
# Build the prebuild-cli
9+
nx build prebuild-cli
10+
# Run the prebuild-cli
11+
bun dist/apps/prebuild-cli/main.js -f expo -p macos
3912
```
40-
41-
Use the plugin's generator to create new projects. For example, to create a new React app or library:
42-
43-
```sh
44-
# Generate an app
45-
npx nx g @nx/react:app demo
46-
47-
# Generate a library
48-
npx nx g @nx/react:lib some-lib
49-
```
50-
51-
You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx list <plugin-name>` to learn about more specific capabilities of a particular plugin. Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to browse plugins and generators in your IDE.
52-
53-
[Learn more about Nx plugins &raquo;](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | [Browse the plugin registry &raquo;](https://nx.dev/plugin-registry?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
54-
55-
56-
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
57-
58-
## Install Nx Console
59-
60-
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
61-
62-
[Install Nx Console &raquo;](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
63-
64-
## Useful links
65-
66-
Learn more:
67-
68-
- [Learn more about this workspace setup](https://nx.dev/getting-started/intro#learn-nx?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects)
69-
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
70-
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
71-
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
72-
73-
And join the Nx community:
74-
- [Discord](https://go.nx.dev/community)
75-
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
76-
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
77-
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const baseConfig = require('../../eslint.config.js');
2+
3+
module.exports = [...baseConfig];

apps/prebuild-cli-e2e/jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default {
2+
displayName: 'prebuild-cli-e2e',
3+
preset: '../../jest.preset.js',
4+
setupFiles: ['<rootDir>/src/test-setup.ts'],
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': [
8+
'ts-jest',
9+
{
10+
tsconfig: '<rootDir>/tsconfig.spec.json',
11+
},
12+
],
13+
},
14+
moduleFileExtensions: ['ts', 'js', 'html'],
15+
coverageDirectory: '../../coverage/prebuild-cli-e2e',
16+
};

apps/prebuild-cli-e2e/project.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "prebuild-cli-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"implicitDependencies": ["prebuild-cli"],
6+
"targets": {
7+
"e2e": {
8+
"executor": "@nx/jest:jest",
9+
"outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"],
10+
"options": {
11+
"jestConfig": "apps/prebuild-cli-e2e/jest.config.ts",
12+
"passWithNoTests": true
13+
},
14+
"dependsOn": ["prebuild-cli:build"]
15+
}
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { execSync } from 'child_process';
2+
import { join } from 'path';
3+
4+
describe('CLI tests', () => {
5+
it('should print a message', () => {
6+
const cliPath = join(process.cwd(), 'dist/apps/prebuild-cli');
7+
8+
const output = execSync(`node ${cliPath}`).toString();
9+
10+
expect(output).toMatch(/Hello World/);
11+
});
12+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//

apps/prebuild-cli-e2e/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.spec.json"
8+
}
9+
],
10+
"compilerOptions": {
11+
"esModuleInterop": true
12+
}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../..//dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": ["jest.config.ts", "src/**/*.ts"]
9+
}

apps/prebuild-cli/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const baseConfig = require('../../eslint.config.js');
2+
3+
module.exports = [...baseConfig];

apps/prebuild-cli/jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
displayName: 'prebuild-cli',
3+
preset: '../../jest.preset.js',
4+
testEnvironment: 'node',
5+
transform: {
6+
'^.+\\.[tj]s$': '@swc/jest',
7+
},
8+
moduleFileExtensions: ['ts', 'js', 'html'],
9+
coverageDirectory: '../../coverage/apps/prebuild-cli',
10+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import {AppRegistry} from 'react-native-macos';
6+
import App from './App';
7+
import { expo } from './app.json';
8+
9+
AppRegistry.registerComponent(expo.name, () => App);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
2+
require File.join(File.dirname(`node --print "require.resolve('react-native-macos/package.json')"`), "scripts/react_native_pods")
3+
4+
require 'json'
5+
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
6+
7+
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
8+
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']
9+
10+
platform :macos, podfile_properties['macos.deploymentTarget'] || '11.0'
11+
install! 'cocoapods',
12+
:deterministic_uuids => false
13+
14+
prepare_react_native_project!
15+
16+
target 'HelloWorld-macOS' do
17+
use_expo_modules!
18+
19+
if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
20+
config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
21+
else
22+
config_command = [
23+
'node',
24+
'--no-warnings',
25+
'--eval',
26+
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
27+
'react-native-config',
28+
'--json',
29+
'--platform',
30+
'ios'
31+
]
32+
end
33+
34+
config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
35+
config = use_native_modules!(config_command)
36+
37+
use_react_native!(
38+
:path => '../node_modules/react-native-macos',
39+
:hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
40+
# An absolute path to your application root.
41+
:app_path => "#{Pod::Config.instance.installation_root}/..",
42+
:privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
43+
)
44+
45+
post_install do |installer|
46+
react_native_post_install(
47+
installer,
48+
config[:reactNativePath],
49+
:mac_catalyst_enabled => false,
50+
:ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
51+
)
52+
end
53+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"expo.jsEngine": "hermes",
3+
"EX_DEV_CLIENT_NETWORK_INSPECTOR": "true",
4+
"newArchEnabled": "false"
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Learn more https://docs.expo.io/guides/customizing-metro
2+
const { getDefaultConfig } = require('expo/metro-config');
3+
4+
/** @type {import('expo/metro-config').MetroConfig} */
5+
const config = getDefaultConfig(__dirname);
6+
7+
module.exports = config;

apps/prebuild-cli/project.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"name": "prebuild-cli",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/prebuild-cli/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "nx:run-commands",
10+
"options": {
11+
"commands": [
12+
"nx run prebuild-cli:build-ts",
13+
"nx run prebuild-cli:build-overlays"
14+
],
15+
"parallel": false
16+
}
17+
},
18+
"build-ts": {
19+
"executor": "@nx/esbuild:esbuild",
20+
"outputs": ["{options.outputPath}"],
21+
"defaultConfiguration": "production",
22+
"options": {
23+
"platform": "node",
24+
"outputPath": "dist/apps/prebuild-cli",
25+
"format": ["cjs"],
26+
"bundle": false,
27+
"main": "apps/prebuild-cli/src/main.ts",
28+
"tsConfig": "apps/prebuild-cli/tsconfig.app.json",
29+
"assets": [
30+
"apps/prebuild-cli/src/assets",
31+
"apps/prebuild-cli/overlays"
32+
],
33+
"generatePackageJson": true,
34+
"esbuildOptions": {
35+
"sourcemap": true,
36+
"outExtension": {
37+
".js": ".js"
38+
}
39+
}
40+
},
41+
"configurations": {
42+
"development": {},
43+
"production": {
44+
"esbuildOptions": {
45+
"sourcemap": false,
46+
"outExtension": {
47+
".js": ".js"
48+
}
49+
}
50+
}
51+
}
52+
},
53+
"build-overlays": {
54+
"executor": "nx:run-commands",
55+
"options": {
56+
"command": "cp -R apps/prebuild-cli/overlays dist/apps/prebuild-cli"
57+
}
58+
},
59+
"serve": {
60+
"executor": "@nx/js:node",
61+
"defaultConfiguration": "development",
62+
"dependsOn": ["build"],
63+
"options": {
64+
"buildTarget": "prebuild-cli:build",
65+
"runBuildTargetDependencies": false
66+
},
67+
"configurations": {
68+
"development": {
69+
"buildTarget": "prebuild-cli:build:development"
70+
},
71+
"production": {
72+
"buildTarget": "prebuild-cli:build:production"
73+
}
74+
}
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)