diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml new file mode 100644 index 000000000..677548473 --- /dev/null +++ b/.github/workflows/build-templates.yml @@ -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 diff --git a/.github/workflows/test-monorepo.yml b/.github/workflows/check-project.yml similarity index 59% rename from .github/workflows/test-monorepo.yml rename to .github/workflows/check-project.yml index 96cb471cb..32500bd66 100644 --- a/.github/workflows/test-monorepo.yml +++ b/.github/workflows/check-project.yml @@ -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 diff --git a/packages/create-react-native-library/src/index.ts b/packages/create-react-native-library/src/index.ts index ef2848712..a5d3fe1d5 100644 --- a/packages/create-react-native-library/src/index.ts +++ b/packages/create-react-native-library/src/index.ts @@ -122,7 +122,13 @@ const args: Record = { }, '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', diff --git a/packages/create-react-native-library/templates/example/example/react-native.config.js b/packages/create-react-native-library/templates/example/example/react-native.config.js index de0224566..128e1521e 100644 --- a/packages/create-react-native-library/templates/example/example/react-native.config.js +++ b/packages/create-react-native-library/templates/example/example/react-native.config.js @@ -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, '..'), }, }, diff --git a/packages/create-react-native-library/templates/native-library-legacy/src/index.tsx b/packages/create-react-native-library/templates/native-library-legacy/src/index.tsx index 66834c908..651971c33 100644 --- a/packages/create-react-native-library/templates/native-library-legacy/src/index.tsx +++ b/packages/create-react-native-library/templates/native-library-legacy/src/index.tsx @@ -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( {}, { diff --git a/packages/create-react-native-library/templates/native-library-turbo/src/index.tsx b/packages/create-react-native-library/templates/native-library-turbo/src/index.tsx index 7672ac734..adc8b3076 100644 --- a/packages/create-react-native-library/templates/native-library-turbo/src/index.tsx +++ b/packages/create-react-native-library/templates/native-library-turbo/src/index.tsx @@ -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);