8000 internal: use workspaces by ThomasAribart · Pull Request #17 · ThomasAribart/onion.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

internal: use workspaces #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: ♻️ Checkout
uses: actions/checkout@v4

- name: 📌 Set shas
uses: nrwl/nx-set-shas@v4

- name: 🏗️ Set up pnpm
uses: pnpm/action-setup@v4.0.0

Expand All @@ -40,11 +43,11 @@ jobs:
- name: 🚚 Install dependencies
run: |
pnpm install --frozen-lockfile
pnpm add --save-dev typescript@${{ matrix.typescript }}
pnpm add --save-dev typescript@${{ matrix.typescript }} -w
shell: bash

- name: 🎯 Run tests
run: pnpm test
run: pnpm test-affected

release:
name: 🚀 Release
Expand All @@ -70,18 +73,19 @@ jobs:
- name: 🏗️ Build
run: pnpm build

- name: 🚀 Release (1/4)
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: 📌 Set packages versions
run: pnpm set-packages-versions ${{ github.event.release.tag_name }}

- name: 🚀 Release (2/4)
run: echo "RELEASE_NPM_TAG=${{ github.event.release.prerelease && 'alpha' || 'latest' }}" >> $GITHUB_ENV
- name: 🔄 Copy paste root README to @onion.js/core
run: cp README.md ./packages/core/README.md

- name: 🚀 Release (3/4)
run: pnpm version $RELEASE_VERSION --no-git-tag-version
- name: 🚀 Release (1/2)
run: echo "RELEASE_NPM_TAG=${{ github.event.release.prerelease && 'alpha' || 'latest' }}" >> $GITHUB_ENV

- name: 🚀 Release (4/4)
- name: 🚀 Release (2/2)
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.RELEASE_NPM_TAG }}
strategy: upgrade
package: ./packages/core/package.json
7 changes: 5 additions & 2 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: 📌 Set shas
uses: nrwl/nx-set-shas@v4

- name: 🏗️ Set up pnpm
uses: pnpm/action-setup@v4.0.0

Expand All @@ -52,8 +55,8 @@ jobs:
- name: 🚚 Install dependencies
run: |
pnpm install --frozen-lockfile
pnpm add --save-dev typescript@${{ matrix.typescript }}
pnpm add --save-dev typescript@${{ matrix.typescript }} -w
shell: bash

- name: 🎯 Run tests
run: pnpm test
run: pnpm test-affected
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ node_modules

# dist
dist

# nx-cache
nx-cache
33 changes: 33 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "@nrwl/workspace/presets/npm.json",
"npmScope": "onion.js",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": {
"cacheableOperations": ["package", "test"],
"cacheDirectory": "nx-cache"
}
}
},
"targetDependencies": {
"package": [
{
"target": "package",
"projects": "dependencies"
}
],
"test": [
{
"target": "package",
"projects": "dependencies"
}
]
},
"affected": {
"defaultBase": "main"
},
"implicitDependencies": {
"*": "*"
}
}
41 changes: 41 additions & 0 deletions onion-js.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"search.exclude": {
"**/coverage": true,
"**/node_modules": true,
"**/.serverless": true,
"**/build": true,
"**/bundles": true,
"**/dist": true,
"pnpm-lock.yaml": true
},
"[dotenv][ignore][properties][shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[html][javascript][json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"extensions": {
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"foxundermoon.shell-format",
"stylelint.vscode-stylelint",
"styled-components.vscode-styled-components"
]
},
"folders": [
{
"path": "packages/core",
"name": "🫀 Core"
},
{
"path": ".",
"name": "🧅 Root"
}
]
}
54 changes: 19 additions & 35 deletions 9E7A package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,52 @@
{
"name": "@onion.js/core",
"name": "@onion.js/onion.js",
"description": "Type-safe & ultra-lightweight library to declare and use high-order functions based on HotScript",
"license": "MIT",
"homepage": "https://github.com/ThomasAribart/onion-js",
"bugs": "https://github.com/ThomasAribart/onion-js/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/ThomasAribart/onion-js.git"
},
"bugs": {
"url": "https://github.com/ThomasAribart/onion-js/issues"
},
"keywords": [
"typescript",
"hotscript",
"high-order functions",
"middleware"
],
"license": "MIT",
"contributors": [
"ThomasAribart <thomasa@theodo.fr>"
],
"engines": {
"node": ">=14.0.0"
},
"files": [
"dist"
],
"exports": {
".": {
"require": "./dist/csj/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts"
}
},
"scripts": {
"build:cjs": "tsc -p tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"build:types": "tsc -p tsconfig.types.json && tsc-alias -p tsconfig.types.json",
"prebuild": "rm -rf dist",
"build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:types",
"test": "pnpm test-type && pnpm test-format && pnpm test-linter && pnpm test-unit",
"test-format": "prettier --check .",
"test-linter": "eslint --ext=js,ts .",
"test-type": "tsc --noEmit --emitDeclarationOnly false",
"test-unit": "vitest run --passWithNoTests",
"test-unit-watch": "vitest --passWithNoTests"
},
"dependencies": {
"hotscript": "^1.0.13"
"build": "nx run-many --target=build --all --parallel=4",
"graph": "nx dep-graph",
"package": "nx run-many --target=package --all --parallel=4",
"set-packages-versions": "ts-node scripts/setPackagesVersions",
"test": "nx run-many --target=test --all --parallel=4",
"test-affected": "nx affected --target=test --parallel=4"
},
"devDependencies": {
"@nrwl/tao": "^14.0.3",
"@nrwl/workspace": "^14.0.3",
"@types/node": "*",
"aws-sdk": "^2.1124.0",
"dependency-cruiser": "^11.7.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"nx": "^14.0.3",
"ts-node": "^10.9.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.12.4",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8.55.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"prettier": "^3.3.3",
"ts-toolbelt": "^9.6.0",
"tsc-alias": "^1.8.10",
"typescript": "^5.3.3",
"vite-tsconfig-paths": "^4.2.2",
"vitest": "1.6.0"
"typescript": "^5.3.3"
},
"packageManager": "pnpm@9.1.4"
}
58 changes: 58 additions & 0 deletions packages/core/package.json
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@onion.js/core",
"description": "Type-safe & ultra-lightweight library to declare and use high-order functions based on HotScript",
"homepage": "https://github.com/ThomasAribart/onion-js",
"repository": {
"type": "git",
"url": "git+https://github.com/ThomasAribart/onion-js.git"
},
"bugs": {
"url": "https://github.com/ThomasAribart/onion-js/issues"
},
"keywords": [
"typescript",
"hotscript",
"high-order functions",
"middleware"
],
"license": "MIT",
"contributors": [
"ThomasAribart <thomasa@theodo.fr>"
],
"engines": {
"node": ">=14.0.0"
},
"files": [
"dist"
],
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts"
}
},
"scripts": {
"build-cjs": "tsc -p tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json",
"build-esm": "tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"build-types": "tsc -p tsconfig.types.json && tsc-alias -p tsconfig.types.json",
"prebuild": "rimraf dist *.tsbuildinfo",
"build": "pnpm run build-cjs && pnpm run build-esm && pnpm run build-types",
"test": "pnpm test-type && pnpm test-format && pnpm test-linter && pnpm test-unit",
"test-format": "prettier --check . --ignore-path ../../.prettierignore",
"test-linter": "eslint --ext=js,ts .",
"test-type": "tsc --noEmit --emitDeclarationOnly false",
"test-unit": "vitest run --passWithNoTests",
"test-unit-watch": "vitest --passWithNoTests"
},
"dependencies": {
"hotscript": "^1.0.13"
},
"devDependencies": {
"rimraf": "^6.0.1",
"tsc-alias": "^1.8.10",
"vite-tsconfig-paths": "^4.2.2",
"vitest": "1.6.0"
},
"packageManager": "pnpm@9.1.4"
}
6 changes: 6 additions & 0 deletions packages/core/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "packages/core",
"projectType": "library",
"tags": [],
"implicitDependencies": []
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
51 changes: 25 additions & 26 deletions src/object.unit.test.ts → packages/core/src/object.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { F, O } from 'hotscript'
import type { A } from 'ts-toolbelt'
import type { B, Call, F, O } from 'hotscript'

import { Layer } from './layer'
import { Onion } from './onion'
Expand All @@ -24,10 +23,9 @@ describe('Onion', () => {
jsonStringifyProp('body')
)

const assertAfter: A.Equals<
typeof after,
{ headers: null; body: string }
> = 1
const assertAfter: Call<
B.Equals<typeof after, { headers: null; body: string }>
> = true
assertAfter

expect(after).toStrictEqual({
Expand All @@ -41,18 +39,19 @@ describe('Onion', () => {
jsonStringifyProp('body')
)

const assertBefore: A.Equals<
Parameters<(typeof onion)['from']>,
[{ headers: null; body: object }]
> = 1
const assertBefore: Call<
B.Equals<
Parameters<(typeof onion)['from']>,
[{ headers: null; body: object }]
>
> = true
assertBefore

const after = onion.from({ headers: null, body: { foo: 'bar' } })

const assertAfter: A.Equals<
typeof after,
{ headers: null; body: string }
> = 1
const assertAfter: Call<
B.Equals<typeof after, { headers: null; body: string }>
> = true
assertAfter

expect(after).toStrictEqual({
Expand All @@ -78,10 +77,9 @@ describe('Onion', () => {
const before = () => ({ headers: null, body: { foo: 'bar' } })
const after = Onion.wrap(before).with(jsonStringifyRespBody)

const assertAfter: A.Equals<
typeof after,
() => { headers: null; body: string }
> = 1
const assertAfter: Call<
B.Equals<typeof after, () => { headers: null; body: string }>
> = true
assertAfter

expect(after()).toStrictEqual({
Expand All @@ -95,18 +93,19 @@ describe('Onion', () => {
jsonStringifyRespBody
)

const assertBefore: A.Equals<
Parameters<(typeof onion)['from']>,
[() => { headers: null; body: unknown }]
> = 1
const assertBefore: Call<
B.Equals<
Parameters<(typeof onion)['from']>,
[() => { headers: null; body: unknown }]
>
> = true
assertBefore

const after = onion.from(() => ({ headers: null, body: { foo: 'bar' } }))

const assertAfter: A.Equals<
typeof after,
() => { headers: null; body: string }
> = 1
const assertAfter: Call<
B.Equals<typeof after, () => { headers: null; body: string }>
> = true
assertAfter

expect(after()).toStrictEqual({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading
0