Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/build-templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Build all templates
on:
push:

jobs:
build-templates:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
type:
- module
- view
language:
- java-objc
- java-swift
- kotlin-objc
- kotlin-swift
- cpp
example:
- native
include:
- type: module
language: js
example: expo
- type: module
language: js
example: native
- type: module-legacy
language: java-objc
example: native
- type: module-turbo
language: java-objc
example: native
- type: module-mixed
language: java-objc
example: native

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3.4.1
with:
node-version: 16.x
cache: yarn

- name: Restore project yarn cache
id: root-yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

- name: Install dependencies
if: steps.root-yarn-cache.outputs.cache-hit != 'true'
run: |
yarn install --frozen-lockfile

- name: Build package
run: |
yarn workspace create-react-native-library prepare

- name: Create temporary working directory
run: |
mkdir ../tmp

- name: Create library
working-directory: ../tmp
run: |
../react-native-builder-bob/packages/create-react-native-library/bin/create-react-native-library react-native-test \
--slug react-native-test \
--description test \
--author-name test \
--author-email test@test \
--author-url https://test.test \
--repo-url https://test.test \
--type ${{ matrix.type }} \
--languages ${{ matrix.language }} \
--example ${{ matrix.example }}

- name: Cache dependencies of library
id: library-yarn-cache
uses: actions/cache@v3
with:
path: |
../tmp/react-native-test/node_modules
../tmp/example/node_modules
key: ${{ runner.os }}-library-yarn-${{ matrix.type }}-${{ matrix.language }}-${{ matrix.example}}-${{ hashFiles('yarn.lock') }}

- name: Install dependencies of library
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
working-directory: ../tmp/react-native-test
run: |
yarn install

- name: Lint library
working-directory: ../tmp/react-native-test
run: |
yarn lint

- name: Typecheck library
working-directory: ../tmp/react-native-test
run: |
yarn typescript

- name: Test library
working-directory: ../tmp/react-native-test
run: |
yarn test
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
name: Test monorepo
name: Check project
on:
pull_request:
branches:
- main
push:

jobs:
test-monorepo:
name: Test monorepo
check-project:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- name: Checkout
uses: actions/checkout@v3

- name: Install node
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.13.x
node-version: 16.x
cache: yarn

- name: Restore dependencies
- name: Restore yarn cache
id: yarn-cache
uses: actions/cache@v3
with:
path: '**/node_modules'
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Lint files
- name: Lint
run: yarn lint

- name: Build packages in the monorepo
- name: Build packages
run: yarn lerna run prepare

- name: Typecheck files
- name: Typecheck
run: yarn typescript
8 changes: 7 additions & 1 deletion packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ const args: Record<ArgName, yargs.Options> = {
},
'type': {
description: 'Type of library you want to develop',
choices: ['module', 'view'],
choices: [
'module-legacy',
'module-turbo',
'module-mixed',
'module',
'view',
],
},
'example': {
description: 'Type of example app',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const path = require('path');

module.exports = {
<% if (project.native) { -%>
module.exports = {<% if (project.native) { %>
dependencies: {
'<%- project.slug -%>': {
'<% project.slug -%>': {
root: path.join(__dirname, '..'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const LINKING_ERROR =
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

const <%- project.name -%> = NativeModules.<%- project.name -%>
? NativeModules.<%- project.name -%>
const <%- project.name -%> = NativeModules.<%- project.name %>
? NativeModules.<%- project.name %>
: new Proxy(
{},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const <%- project.name -%> = require('./Native<%- project.name -%>').default
const <%- project.name -%> = require('./Native<%- project.name -%>').default;

export function multiply(a: number, b: number): number {
return <%- project.name -%>.multiply(a, b);
Expand Down