Skip to content

Commit

Permalink
refactor: monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
niuiic committed Nov 3, 2023
1 parent 82d2eb1 commit 4d58523
Show file tree
Hide file tree
Showing 362 changed files with 26,001 additions and 1,900 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

35 changes: 0 additions & 35 deletions .eslintrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ dist
docs/.vitepress/dist
docs/.vitepress/cache
docs/api

# build
.turbo
23 changes: 0 additions & 23 deletions .prettierrc.cjs

This file was deleted.

23 changes: 23 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"rangeStart": 0,
"rangeEnd": 999999,
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": false,
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto",
"plugins": ["prettier-plugin-organize-imports"]
}
20 changes: 0 additions & 20 deletions jest.config.cjs

This file was deleted.

60 changes: 28 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"name": "@niuiic/flow",
"name": "fx-flow",
"version": "0.3.11",
"description": "A functional library for TypeScript/JavaScript",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsc",
"build": "turbo build",
"package": "rollup -c rollup.config.mjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"release": "pnpm package && release-it",
"call": "tsx cli",
Expand All @@ -24,46 +22,44 @@
"docs:build": "typedoc && pnpm call cleanDoc && vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"packageManager": "pnpm",
"author": "niuiic",
"homepage": "https://flow.niuiic.com",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/niuiic/flow.git"
},
"keywords": [
"functional programming",
"stream programming",
"lazy evaluation",
"concurrency"
],
"keywords": ["functional programming", "stream programming", "lazy evaluation", "concurrency"],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.2",
"@types/jest": "^29.5.3",
"@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.47.0",
"jest": "^29.6.2",
"lefthook": "^1.4.8",
"prettier": "^3.0.1",
"@farmfe/cli": "^0.5.8",
"@farmfe/core": "^0.13.19",
"@farmfe/js-plugin-dts": "^0.2.0",
"@rollup/plugin-typescript": "^11.1.5",
"@types/jest": "^29.5.7",
"@types/node": "^20.8.10",
"eslint": "^8.52.0",
"jest": "^29.7.0",
"lefthook": "^1.5.2",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"release-it": "^16.1.5",
"rollup": "^3.28.0",
"rollup-plugin-dts": "^5.3.1",
"release-it": "^16.2.1",
"rollup": "^4.2.0",
"rollup-plugin-dts": "^6.1.0",
"ts-jest": "^29.1.1",
"tslib": "^2.6.1",
"tsx": "^3.12.7",
"typedoc": "0.24.8",
"typedoc-plugin-markdown": "4.0.0-next.18",
"typedoc-plugin-missing-exports": "^2.0.1",
"typedoc-plugin-replace-text": "^3.1.0",
"typedoc-vitepress-theme": "1.0.0-next.2",
"typescript": "^5.1.6",
"vitepress": "1.0.0-rc.4"
"tslib": "^2.6.2",
"tsx": "^3.14.0",
"turbo": "^1.10.16",
"typedoc": "0.25.3",
"typedoc-plugin-markdown": "4.0.0-next.25",
"typedoc-plugin-missing-exports": "^2.1.0",
"typedoc-plugin-replace-text": "^3.2.0",
"typedoc-vitepress-theme": "1.0.0-next.3",
"typescript": "^5.2.2",
"vitepress": "1.0.0-rc.24"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["custom"]
}
42 changes: 42 additions & 0 deletions packages/core/farm.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { UserConfig } from '@farmfe/core'
import dts from '@farmfe/js-plugin-dts'
import { builtinModules } from 'node:module'
import path from 'node:path'

const config: UserConfig = {
compilation: {
input: {
index: 'src/index.ts'
},
output: {
path: 'dist',
entryFilename: '[entryName].js',
targetEnv: 'node',
format: 'esm'
},
resolve: {
alias: {
'@/': path.join(process.cwd(), 'src')
}
},
external: [...builtinModules.map((x) => `^${x}$`), ...builtinModules.map((x) => `^node:${x}$`)],
partialBundling: {
enforceResources: [
{
name: 'index.js',
test: ['.+']
}
]
},
minify: false,
sourcemap: false,
presetEnv: false
},
plugins: [
dts({
tsConfigPath: './tsconfig.json'
})
]
}

export default config
44 changes: 44 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "core",
"version": "0.3.11",
"description": "A functional library for TypeScript/JavaScript",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
"types": "dist/types/index.d.ts",
"files": ["dist"],
"engines": {
"node": ">=16"
},
"scripts": {
"build": "farm build",
"package": "rollup -c rollup.config.mjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"release": "pnpm package && release-it",
"call": "tsx cli",
"test": "jest",
"test:coverage": "jest --coverage",
"lint": "pnpm call lint",
"docs:dev": "vitepress dev docs",
"docs:build": "typedoc && pnpm call cleanDoc && vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"author": "niuiic",
"homepage": "https://flow.niuiic.com",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/niuiic/flow.git"
},
"keywords": ["functional programming", "stream programming", "lazy evaluation", "concurrency"],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"devDependencies": {
"@farmfe/cli": "^0.5.8",
"@farmfe/core": "^0.13.19",
"@farmfe/js-plugin-dts": "^0.2.0",
"eslint-config-custom": "workspace:*",
"tsconfig": "workspace:*"
}
}
7 changes: 4 additions & 3 deletions src/flow/andThen.ts → packages/core/src/flow/andThen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MaybePromise, ResultReturnValue } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result, err } from './result.js'
import type { MaybePromise, ResultReturnValue } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'
import { err } from './result'

/**
* Call `fn` if `result` is success.
Expand Down
6 changes: 3 additions & 3 deletions src/flow/anyway.ts → packages/core/src/flow/anyway.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MaybePromise, ResultReturnValue } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result } from './result.js'
import type { MaybePromise, ResultReturnValue } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'

/**
* Call `fn` anyway.
Expand Down
7 changes: 4 additions & 3 deletions src/flow/errThen.ts → packages/core/src/flow/errThen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MaybePromise } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result, err, ok } from './result.js'
import type { MaybePromise } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'
import { err, ok } from './result'

/**
* Call `fn` if `result` is failure.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MaybePromise, Modifier } from 'src/types/index.js'
import { FlowMissModifierException, isPromise } from 'src/utils.js'
import { Result, err, ok } from './result.js'
import type { MaybePromise, Modifier } from '@/types'
import { FlowMissModifierException, isPromise } from '@/utils'
import type { Result } from './result'
import { err, ok } from './result'

/**
* Call `fn` if `result` is failure, then exit flow.
Expand Down
7 changes: 4 additions & 3 deletions src/flow/flow.ts → packages/core/src/flow/flow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnyFunction, AnyObject, FlowReturnValue, FlowState, FnReturnValue, Modifier } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result, err } from './result.js'
import type { AnyFunction, AnyObject, FlowReturnValue, FlowState, FnReturnValue, Modifier } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'
import { err } from './result'

const toStr = (err: unknown) => JSON.stringify(err, Object.getOwnPropertyNames(err), 1)

Expand Down
7 changes: 4 additions & 3 deletions src/flow/ifThen.ts → packages/core/src/flow/ifThen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MaybePromise } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result, err, ok } from './result.js'
import type { MaybePromise } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'
import { err, ok } from './result'

type IfThenReturnValue<A, R> = R extends Promise<unknown> ? MaybePromise<Result<A>> : Result<A>

Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/flow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from './andThen'
export * from './anyway'
export * from './errThen'
export * from './errThenEnd'
export * from './flow'
export * from './ifThen'
export * from './inject'
export * from './inspect'
export * from './into'
export * from './log'
export * from './mapErr'
export * from './result'
export * from './useFlow'
6 changes: 3 additions & 3 deletions src/flow/inject.ts → packages/core/src/flow/inject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MaybePromise } from 'src/types/index.js'
import { isPromise } from 'src/utils.js'
import { Result } from './result.js'
import type { MaybePromise } from '@/types'
import { isPromise } from '@/utils'
import type { Result } from './result'

/**
* Inject a function to the progress without side effect.
Expand Down
Loading

0 comments on commit 4d58523

Please sign in to comment.