Initial commit

This commit is contained in:
Zitao Xiong
2024-05-23 17:14:27 +08:00
commit 288f32ad52
20 changed files with 5670 additions and 0 deletions

1
.eslintignore Normal file
View File

@@ -0,0 +1 @@
node_modules

29
.eslintrc.json Normal file
View File

@@ -0,0 +1,29 @@
{
"root": true,
"ignorePatterns": ["!**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}

39
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
actions: read
contents: read
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 8
# Connect your workspace on nx.app and uncomment this to enable task distribution.
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested
# - run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build"
# Cache node_modules
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: nrwl/nx-set-shas@v4
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
# - run: pnpm exec nx-cloud record -- echo Hello World
- run: pnpm exec nx affected -t lint test build

41
.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
dist
tmp
/out-tsc
# dependencies
node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
.nx/cache

2
.npmrc Normal file
View File

@@ -0,0 +1,2 @@
strict-peer-dependencies=false
auto-install-peers=true

4
.prettierignore Normal file
View File

@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache

3
.prettierrc Normal file
View File

@@ -0,0 +1,3 @@
{
"singleQuote": true
}

3
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"recommendations": ["nrwl.angular-console", "esbenp.prettier-vscode"]
}

58
README.md Normal file
View File

@@ -0,0 +1,58 @@
# SuiDataSync
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
**This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)**
## Integrate with editors
Enhance your Nx experience by installing [Nx Console](https://nx.dev/nx-console) for your favorite editor. Nx Console
provides an interactive UI to view your projects, run tasks, generate code, and more! Available for VSCode, IntelliJ and
comes with a LSP for Vim users.
## Build the library
Run `npx nx build` to build the library. The build artifacts are stored in the output directory (i.e. `dist/`), ready to be published.
## Running tasks
To execute tasks with Nx use the following syntax:
```
npx nx <target> <project> <...options>
```
You can also run multiple targets:
```
npx nx run-many -t <target1> <target2>
```
..or add `-p` to filter specific projects
```
npx nx run-many -t <target1> <target2> -p <proj1> <proj2>
```
Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/features/run-tasks).
## Set up CI!
Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further.
- [Set up remote caching](https://nx.dev/features/share-your-cache)
- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution)
- [Learn more how to setup CI](https://nx.dev/recipes/ci)
## Explore the project graph
Run `npx nx graph` to show the graph of the workspace.
It will show tasks that you can run with Nx.
- [Learn more about Exploring the Project Graph](https://nx.dev/core-features/explore-graph)
## Connect with us!
- [Join the community](https://nx.dev/community)
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
- [Follow us on Twitter](https://twitter.com/nxdevtools)

34
nx.json Normal file
View File

@@ -0,0 +1,34 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.js",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json"
],
"sharedGlobals": []
},
"targetDefaults": {
"@nx/js:tsc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"@nx/vite:test": {
"cache": true,
"inputs": ["default", "^production"]
}
},
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
}
],
"nxCloudAccessToken": "OTM1NjljZGItOTgyYi00MDlhLTg0NjQtZjBjOWM4Njg3ODVlfHJlYWQtd3JpdGU="
}

41
package.json Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "@sui-data-sync/source",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "nx build",
"test": "nx test"
},
"dependencies": {
"tslib": "^2.3.0"
},
"devDependencies": {
"@nx/eslint": "19.0.6",
"@nx/eslint-plugin": "19.0.6",
"@nx/js": "19.0.6",
"@nx/vite": "19.0.6",
"@nx/web": "19.0.6",
"@nx/workspace": "19.0.6",
"@swc-node/register": "~1.8.0",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@types/node": "18.16.9",
"@typescript-eslint/eslint-plugin": "^7.3.0",
"@typescript-eslint/parser": "^7.3.0",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"eslint": "~8.57.0",
"eslint-config-prettier": "^9.0.0",
"nx": "19.0.6",
"prettier": "^2.6.2",
"typescript": "~5.4.2",
"vite": "~5.0.0",
"vitest": "^1.3.1"
},
"nx": {
"includedScripts": []
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}

5285
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

29
project.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "sui-data-sync",
"$schema": "node_modules/nx/schemas/project-schema.json",
"sourceRoot": "src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/sui-data-sync",
"main": "./src/index.ts",
"tsConfig": "./tsconfig.lib.json",
"assets": ["*.md"]
}
},
"lint": {
"command": "eslint ./src ./package.json"
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "coverage/sui-data-sync"
}
}
}
}

1
src/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './lib/sui-data-sync';

View File

@@ -0,0 +1,7 @@
import { suiDataSync } from './sui-data-sync';
describe('suiDataSync', () => {
it('should work', () => {
expect(suiDataSync()).toEqual('sui-data-sync');
});
});

3
src/lib/sui-data-sync.ts Normal file
View File

@@ -0,0 +1,3 @@
export function suiDataSync(): string {
return 'sui-data-sync';
}

30
tsconfig.json Normal file
View File

@@ -0,0 +1,30 @@
{
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "commonjs",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@sui-data-sync/source": ["src/index.ts"]
}
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

10
tsconfig.lib.json Normal file
View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}

26
tsconfig.spec.json Normal file
View File

@@ -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"
]
}

24
vite.config.ts Normal file
View File

@@ -0,0 +1,24 @@
import { defineConfig } from 'vite';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
export default defineConfig({
root: __dirname,
cacheDir: './node_modules/.vite/sui-data-sync',
plugins: [nxViteTsPaths()],
// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },
test: {
globals: true,
cache: { dir: './node_modules/.vitest/sui-data-sync' },
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: { reportsDirectory: './coverage/sui-data-sync', provider: 'v8' },
},
});