Skip to content

Commit c2f70ab

Browse files
committed
refactor(general): 💡 update to v5
1 parent 8cf64f1 commit c2f70ab

File tree

175 files changed

+12616
-16113
lines changed

Some content is hidden

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

175 files changed

+12616
-16113
lines changed

.editorconfig

-13
This file was deleted.

.eslintrc.base.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nx/javascript"],
32+
"rules": {}
33+
}
34+
]
35+
}

.eslintrc.json

+22-28
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
{
2-
"root": true,
3-
"ignorePatterns": ["**/*"],
4-
"plugins": ["@nx"],
2+
"ignorePatterns": ["!**/*"],
53
"overrides": [
64
{
7-
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
5+
"files": ["*.ts"],
6+
"extends": [
7+
"plugin:@nx/angular",
8+
"plugin:@angular-eslint/template/process-inline-templates"
9+
],
810
"rules": {
9-
"@nx/enforce-module-boundaries": [
11+
"@angular-eslint/directive-selector": [
1012
"error",
1113
{
12-
"enforceBuildableLibDependency": true,
13-
"allow": [],
14-
"depConstraints": [
15-
{
16-
"sourceTag": "*",
17-
"onlyDependOnLibsWithTags": ["*"]
18-
}
19-
]
14+
"type": "attribute",
15+
"prefix": "query",
16+
"style": "camelCase"
17+
}
18+
],
19+
"@angular-eslint/component-selector": [
20+
"error",
21+
{
22+
"type": "element",
23+
"prefix": "query",
24+
"style": "kebab-case"
2025
}
2126
]
2227
}
2328
},
2429
{
25-
"files": ["*.ts", "*.tsx"],
26-
"extends": ["plugin:@nx/typescript"],
27-
"rules": {}
28-
},
29-
{
30-
"files": ["*.js", "*.jsx"],
31-
"extends": ["plugin:@nx/javascript"],
32-
"rules": {}
33-
},
34-
{
35-
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36-
"env": {
37-
"jest": true
38-
},
30+
"files": ["*.html"],
31+
"extends": ["plugin:@nx/angular-template"],
3932
"rules": {}
4033
}
41-
]
34+
],
35+
"extends": ["./.eslintrc.base.json"]
4236
}

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
cache: 'npm'
3030

3131
- name: Install dependencies
32-
run: npm i --legacy-peer-deps
32+
run: npm i
3333

3434
- name: Run Build
3535
run: npm run build:all
3636

37-
- name: Run unit tests
37+
- name: Run tests
3838
run: npm run test:all

.github/workflows/gh-pages.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Playground to GitHub Pages
1+
name: Deploy playground to GitHub pages
22
on:
33
push:
44
branches:
@@ -17,26 +17,22 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: actions/setup-node@v3
20-
# this action has a built-in functionality for caching and restoring dependencies
21-
# https://github.com/actions/setup-node#caching-global-packages-data
2220
with:
2321
node-version: 16
2422
cache: 'npm'
2523
- name: Install and Build
2624
run: |
27-
npm ci --legacy-peer-deps
25+
npm i
2826
npx nx build playground -- --base-href /query/
2927
- name: Duplicated index.html
30-
# https://angular.io/guide/deployment#deploy-to-github-pages
31-
# To prevent 404 errors for application routes when refreshing the page
3228
run: |
3329
cp dist/packages/playground/index.html dist/packages/playground/404.html
3430
- name: Setup Pages
3531
uses: actions/configure-pages@v2
3632
- name: Upload artifact
3733
uses: actions/upload-pages-artifact@v1
3834
with:
39-
path: './dist/packages/playground'
35+
path: './dist/packages/query-playground'
4036
- name: Deploy to GitHub Pages
4137
id: deployment
4238
uses: actions/deploy-pages@v1

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
# compiled output
4-
/dist
5-
/tmp
4+
dist
5+
tmp
66
/out-tsc
77

88
# dependencies
@@ -38,5 +38,5 @@ testem.log
3838
.DS_Store
3939
Thumbs.db
4040

41+
.nx/cache
4142
.angular
42-
.nx

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/dist
44
/coverage
55
.angular
6+
.nx

.vscode/extensions.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"nrwl.angular-console",
44
"esbenp.prettier-vscode",
55
"firsttris.vscode-jest-runner",
6+
"ms-playwright.playwright",
67
"dbaeumer.vscode-eslint"
78
]
89
}

README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,18 @@ export class TodosPageComponent {
377377
};
378378
})
379379
);
380-
380+
381381
// Map the result `data` of multiple queries
382-
combineLatest([
383-
this.todosService.getTodos(),
384-
this.todosService.getTodos(),
385-
]).pipe(
386-
mapResultsData(([todos, todos2]) => {
387-
return {
388-
todos: todos.data.todos.filter(predicate),
389-
todos2: todos2.data.todos.filter(predicate),
390-
};
391-
})
392-
).subscribe(console.log); // { isLoading: boolean, isSuccess: boolean, isError: boolean, error: unknown, data: { todos: [], todos2: [] } }
382+
combineLatest([this.todosService.getTodos(), this.todosService.getTodos()])
383+
.pipe(
384+
mapResultsData(([todos, todos2]) => {
385+
return {
386+
todos: todos.data.todos.filter(predicate),
387+
todos2: todos2.data.todos.filter(predicate),
388+
};
389+
})
390+
)
391+
.subscribe(console.log); // { isLoading: boolean, isSuccess: boolean, isError: boolean, error: unknown, data: { todos: [], todos2: [] } }
393392

394393
// process error or success result directly
395394
this.todosService

packages/playground/.eslintrc.json renamed to devtools/.eslintrc.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["../../.eslintrc.json"],
2+
"extends": ["../.eslintrc.base.json"],
33
"ignorePatterns": ["!**/*"],
44
"overrides": [
55
{
@@ -13,15 +13,15 @@
1313
"error",
1414
{
1515
"type": "attribute",
16-
"prefix": "ngQuery",
16+
"prefix": "query",
1717
"style": "camelCase"
1818
}
1919
],
2020
"@angular-eslint/component-selector": [
2121
"error",
2222
{
2323
"type": "element",
24-
"prefix": "ng-query",
24+
"prefix": "query",
2525
"style": "kebab-case"
2626
}
2727
]
@@ -31,6 +31,13 @@
3131
"files": ["*.html"],
3232
"extends": ["plugin:@nx/angular-template"],
3333
"rules": {}
34+
},
35+
{
36+
"files": ["*.json"],
37+
"parser": "jsonc-eslint-parser",
38+
"rules": {
39+
"@nx/dependency-checks": "error"
40+
}
3441
}
3542
]
3643
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# ng-query
1+
# devtools
22

33
This library was generated with [Nx](https://nx.dev).
44

55
## Running unit tests
66

7-
Run `nx test ng-query` to execute the unit tests.
7+
Run `nx test devtools` to execute the unit tests.

packages/playground/jest.config.ts renamed to devtools/jest.config.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-disable */
22
export default {
3-
displayName: 'playground',
4-
preset: '../../jest.preset.js',
3+
displayName: 'devtools',
4+
preset: '../jest.preset.js',
55
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6-
globals: {},
7-
coverageDirectory: '../../coverage/packages/playground',
6+
coverageDirectory: '../coverage/devtools',
87
transform: {
98
'^.+\\.(ts|mjs|js|html)$': [
109
'jest-preset-angular',

devtools/ng-package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../dist/devtools",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

devtools/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@ngneat/query-devtools",
3+
"version": "0.0.1",
4+
"peerDependencies": {
5+
"@angular/core": "^16.2.0",
6+
"@tanstack/query-devtools": "5.4.2"
7+
},
8+
"dependencies": {
9+
"tslib": "^2.3.0"
10+
},
11+
"sideEffects": false
12+
}

devtools/project.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "devtools",
3+
"$schema": "../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "devtools/src",
5+
"prefix": "query",
6+
"tags": [],
7+
"projectType": "library",
8+
"targets": {
9+
"build": {
10+
"executor": "@nx/angular:package",
11+
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12+
"options": {
13+
"project": "devtools/ng-package.json"
14+
},
15+
"configurations": {
16+
"production": {
17+
"tsConfig": "devtools/tsconfig.lib.prod.json"
18+
},
19+
"development": {
20+
"tsConfig": "devtools/tsconfig.lib.json"
21+
}
22+
},
23+
"defaultConfiguration": "production"
24+
},
25+
"test": {
26+
"executor": "@nx/jest:jest",
27+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28+
"options": {
29+
"jestConfig": "devtools/jest.config.ts",
30+
"passWithNoTests": true
31+
},
32+
"configurations": {
33+
"ci": {
34+
"ci": true,
35+
"codeCoverage": true
36+
}
37+
}
38+
},
39+
"lint": {
40+
"executor": "@nx/eslint:lint",
41+
"outputs": ["{options.outputFile}"],
42+
"options": {
43+
"lintFilePatterns": [
44+
"devtools/**/*.ts",
45+
"devtools/**/*.html",
46+
"devtools/package.json"
47+
]
48+
}
49+
}
50+
}
51+
}

devtools/src/index.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
DestroyRef,
3+
ENVIRONMENT_INITIALIZER,
4+
inject,
5+
makeEnvironmentProviders,
6+
} from '@angular/core';
7+
import { TanstackQueryDevtoolsConfig } from '@tanstack/query-devtools';
8+
import { injectQueryClient } from '@ngneat/query';
9+
10+
export function provideQueryDevTools(
11+
devToolOptions: Partial<Omit<TanstackQueryDevtoolsConfig, 'client'>> = {}
12+
) {
13+
return makeEnvironmentProviders([
14+
{
15+
provide: ENVIRONMENT_INITIALIZER,
16+
multi: true,
17+
useValue() {
18+
const queryClient = injectQueryClient();
19+
const destroyRef = inject(DestroyRef);
20+
21+
import('./lib/devtools/devtools').then((m) => {
22+
m.queryDevtools({ queryClient, destroyRef, ...devToolOptions });
23+
});
24+
},
25+
},
26+
]);
27+
}

0 commit comments

Comments
 (0)