Skip to content

Commit

Permalink
Merge pull request #75 from PxTools/feature/PXWEB2-130-data-access-st…
Browse files Browse the repository at this point in the history
…ructure

Feature/pxweb2 130 data access structure
  • Loading branch information
MikaelNordberg authored Mar 18, 2024
2 parents b1276fc + cc74733 commit 152e9be
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 0 deletions.
Empty file.
30 changes: 30 additions & 0 deletions libs/pxweb2-api-client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}
11 changes: 11 additions & 0 deletions libs/pxweb2-api-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# pxweb2-api-client

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

## Building

Run `nx build pxweb2-api-client` to build the library.

## Running unit tests

Run `nx test pxweb2-api-client` to execute the unit tests via [Vitest](https://vitest.dev/).
8 changes: 8 additions & 0 deletions libs/pxweb2-api-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@pxweb2/pxweb2-api-client",
"version": "0.0.1",
"dependencies": {},
"main": "./index.js",
"module": "./index.mjs",
"typings": "./index.d.ts"
}
35 changes: 35 additions & 0 deletions libs/pxweb2-api-client/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "pxweb2-api-client",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pxweb2-api-client/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/libs/pxweb2-api-client"
},
"configurations": {
"development": {
"mode": "development"
},
"production": {
"mode": "production"
}
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../../coverage/libs/pxweb2-api-client"
}
},
"lint": {
"executor": "@nx/eslint:lint"
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/pxweb2-api-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/pxweb2-api-client';
7 changes: 7 additions & 0 deletions libs/pxweb2-api-client/src/lib/pxweb2-api-client.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { pxweb2ApiClient } from './pxweb2-api-client';

describe('pxweb2ApiClient', () => {
it('should work', () => {
expect(pxweb2ApiClient()).toEqual('pxweb2-api-client');
});
});
3 changes: 3 additions & 0 deletions libs/pxweb2-api-client/src/lib/pxweb2-api-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function pxweb2ApiClient(): string {
return 'pxweb2-api-client';
}
22 changes: 22 additions & 0 deletions libs/pxweb2-api-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions libs/pxweb2-api-client/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node", "vite/client"]
},
"include": ["src/**/*.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
26 changes: 26 additions & 0 deletions libs/pxweb2-api-client/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
62 changes: 62 additions & 0 deletions libs/pxweb2-api-client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import * as path from 'path';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/libs/pxweb2-api-client',

plugins: [
nxViteTsPaths(),
dts({
entryRoot: 'src',
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true,
}),
],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
outDir: '../../dist/libs/pxweb2-api-client',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: 'src/index.ts',
name: 'pxweb2-api-client',
fileName: 'index',
// Change this to the formats you want to support.
// Don't forget to update your package.json as well.
formats: ['es', 'cjs'],
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: [],
},
},

test: {
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],

reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/pxweb2-api-client',
provider: 'v8',
},
},
});
Empty file.
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
},
"@nx/vite:build": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"namedInputs": {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@pxweb2/pxweb2-api-client": ["libs/pxweb2-api-client/src/index.ts"],
"@pxweb2/pxweb2-ui": ["libs/pxweb2-ui/src/index.ts"]
}
},
Expand Down

0 comments on commit 152e9be

Please sign in to comment.