Skip to content

Commit

Permalink
Merge branch 'create-slice-creators' into entity-methods-creator
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed Sep 1, 2024
2 parents e888b32 + b10f345 commit 45de908
Show file tree
Hide file tree
Showing 204 changed files with 15,585 additions and 7,650 deletions.
120 changes: 112 additions & 8 deletions .github/workflows/test-codegen.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: RTK-Query OpenAPI Codegen Tests
name: RTKQ OpenAPI Codegen
defaults:
run:
working-directory: ./packages/rtk-query-codegen-openapi
Expand All @@ -23,24 +23,128 @@ jobs:
codegen:
- 'packages/rtk-query-codegen-openapi/**'
- 'yarn.lock'
- '.github/workflows/test-codegen.yml'
build:
needs: changes
needs: [changes]
if: ${{ needs.changes.outputs.codegen == 'true' }}

runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/rtk-query-codegen-openapi

runs-on: ${{ matrix.os }}

name: 'Build artifact: ${{ matrix.os }} + Node ${{ matrix.node-version }}'

strategy:
matrix:
node-version: ['20.x']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn install

- name: Pack
run: yarn pack

- name: Upload artifact
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: package
path: ./packages/rtk-query-codegen-openapi/package.tgz

- name: Did we fail?
if: failure()
run: ls -lR

test:
needs: build
defaults:
run:
working-directory: ./packages/rtk-query-codegen-openapi
name: 'Test build artifact: ${{ matrix.os }} + Node ${{ matrix.node-version }}'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [20.x]
os: [ubuntu-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- run: yarn install
- run: yarn test
- name: Download artifact
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./packages/rtk-query-codegen-openapi
name: package

- name: Install dependencies
run: yarn install

- name: Install build artifact
run: yarn add ./package.tgz

- name: Remove path alias
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json

- name: Run tests
run: yarn test
env:
TEST_DIST: true

- name: Did we fail?
if: failure()
run: ls -R

are-the-types-wrong:
name: Check package definition with are-the-types-wrong

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20.x]
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install deps
run: yarn install

- name: Download artifact
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./packages/rtk-query-codegen-openapi
name: package

- name: Run are-the-types-wrong
run: yarn dlx @arethetypeswrong/cli@latest ./package.tgz --format table
66 changes: 62 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,26 @@ jobs:
- name: Install build artifact
run: yarn workspace @reduxjs/toolkit add $(pwd)/package.tgz

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts ./src/tests/*.* ./src/query/tests/*.*
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json

- name: Run tests, against dist
env:
TEST_DIST: true
run: yarn test

- name: Run type tests with `moduleResolution Bundler`
run: rm -rf dist && yarn tsc -p . --moduleResolution Bundler --module ESNext --noEmit false --declaration --emitDeclarationOnly --outDir dist --target ESNext && rm -rf dist

test-types:
name: Test Types with TypeScript ${{ matrix.ts }}
name: 'Test Types: TS ${{ matrix.ts }}'

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['20.x']
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3', '5.4']
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3', '5.4', '5.5']
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -134,9 +139,11 @@ jobs:
- name: Show installed RTK versions
run: yarn info @reduxjs/toolkit

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts ./src/tests/*.* ./src/query/tests/*.*
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json

- name: Test types
env:
TEST_DIST: true
run: |
yarn tsc --version
yarn type-tests
Expand Down Expand Up @@ -243,3 +250,54 @@ jobs:

- name: Run are-the-types-wrong
run: yarn attw ./package.tgz --format table --ignore-rules false-cjs

test-type-portability:
name: 'Test Type Portability: TS ${{ matrix.ts }} + Node ${{ matrix.node }}'
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['20.x']
ts: ['5.3', '5.4', '5.5', 'next']
example:
[
{ name: 'bundler', moduleResolution: 'Bundler' },
{ name: 'nodenext-cjs', moduleResolution: 'NodeNext' },
{ name: 'nodenext-esm', moduleResolution: 'NodeNext' },
]
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'

- name: Install deps
run: yarn install

- uses: actions/download-artifact@v4
with:
name: package
path: packages/toolkit

- name: Install build artifact
run: yarn workspace @examples-type-portability/${{ matrix.example.name }} add $(pwd)/package.tgz

- name: Install TypeScript ${{ matrix.ts }}
run: yarn workspace @examples-type-portability/${{ matrix.example.name }} add -D typescript@${{ matrix.ts }}

- name: Test type portability with `moduleResolution ${{ matrix.example.moduleResolution }}`
run: yarn workspace @examples-type-portability/${{ matrix.example.name }} run test

- name: Test type portability with `moduleResolution Node10`
run: yarn workspace @examples-type-portability/${{ matrix.example.name }} run test --module CommonJS --moduleResolution Node10 --preserveSymLinks --verbatimModuleSyntax false

- name: Test type portability with `moduleResolution Node10` and `type module` in `package.json`
if: matrix.example.name == 'nodenext-esm' || matrix.example.name == 'bundler'
run: |
npm --workspace=@examples-type-portability/${{ matrix.example.name }} pkg set type=module
yarn workspace @examples-type-portability/${{ matrix.example.name }} run test --module ESNext --moduleResolution Node10 --preserveSymLinks --verbatimModuleSyntax false
37 changes: 32 additions & 5 deletions .yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
diff --git a/package.json b/package.json
index b924e066ecfdb30917b9c1056b360834da357698..15e155bd84f9d16537ffe36f9a87debcb0ec3591 100644
--- a/package.json
+++ b/package.json
@@ -8,12 +8,15 @@
"type": "module",
"main": "dist/index.js",
"typings": "index.d.ts",
+ "types": "index.d.ts",
"exports": {
".": {
+ "types": "./index.d.ts",
"require": "./dist/index.js",
"default": "./src/index.js"
},
"./pure": {
+ "types": "./pure.d.ts",
"require": "./dist/pure.js",
"default": "./src/pure.js"
}
diff --git a/pure.d.ts b/pure.d.ts
index b13bb4eb87d0b316bb51bd6094b2353c6fc8527d..ee01cc9bd3233f5e67b050d48e22202b495a4a0a 100644
--- a/pure.d.ts
+++ b/pure.d.ts
@@ -1 +1 @@
-export * from './';
+export * from './index.js';
diff --git a/src/index.js b/src/index.js
index 90ff7fa3d7d4fa62dbbf638958ae4e28abd089a8..28434687b5163b7472e86bdb11bed69e0868e660 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,4 @@
-import { mockConsole, createConsole } from './pure';
+import { mockConsole, createConsole } from './pure.js';

// Keep an instance of the original console and export it
const originalConsole = global.console;
diff --git a/src/pure.js b/src/pure.js
Expand All @@ -15,7 +42,7 @@ index b00ea2abbaea833e336676aa46e7ced2d59d6d88..42b83ed83fa16cf2234571500fe09868
@@ -228,10 +228,11 @@ export function restore() {
global.console = global.originalConsole;
}

+/*
if (typeof expect === 'function' && typeof expect.extend === 'function') {
expect.extend({
Expand All @@ -24,13 +51,13 @@ index b00ea2abbaea833e336676aa46e7ced2d59d6d88..42b83ed83fa16cf2234571500fe09868
+ // Workaround for custom inline snapshot matchers
const error = new Error();
const stacks = error.stack.split('\n');

@@ -245,7 +246,6 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
error.stack = stacks.join('\n');

const context = Object.assign(this, { error });
- /* -------------------------------------------------------------- */

const testingConsoleInstance =
(received && received.testingConsole) || received;
@@ -270,3 +270,4 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
Expand Down
Loading

0 comments on commit 45de908

Please sign in to comment.