-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
5,418 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Test (Ubuntu) | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on pull request events but only for the main branch | ||
pull_request: | ||
branches: [main] | ||
|
||
push: | ||
branches: [main] | ||
|
||
merge_group: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# ======== ut ======== | ||
ut-mac: | ||
# run ut in MacOS, as SWC cases will fail in Ubuntu CI | ||
runs-on: macos-14 | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 10 | ||
|
||
- name: Install Pnpm | ||
run: corepack enable | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
predicate-quantifier: 'every' | ||
filters: | | ||
changed: | ||
- "!**/*.md" | ||
- "!**/*.mdx" | ||
- name: Setup Node.js ${{ matrix.node-version }} | ||
if: steps.changes.outputs.changed == 'true' | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
if: steps.changes.outputs.changed == 'true' | ||
run: pnpm install | ||
|
||
- name: Unit Test | ||
if: steps.changes.outputs.changed == 'true' | ||
run: pnpm run test:unit | ||
|
||
# ======== e2e ======== | ||
e2e-ubuntu: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 10 | ||
|
||
- name: Install Pnpm | ||
run: corepack enable | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
predicate-quantifier: 'every' | ||
filters: | | ||
changed: | ||
- "!**/*.md" | ||
- "!**/*.mdx" | ||
- name: Setup Node.js ${{ matrix.node-version }} | ||
if: steps.changes.outputs.changed == 'true' | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
if: steps.changes.outputs.changed == 'true' | ||
run: pnpm install && cd ./e2e && pnpx playwright install | ||
|
||
- name: E2E Test | ||
if: steps.changes.outputs.changed == 'true' | ||
run: | | ||
pnpm run test:artifact | ||
pnpm run test:e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
registry = 'https://registry.npmjs.org/' | ||
strict-peer-dependencies=false | ||
hoist-patterns[]=[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v16.20.2 | ||
v18.20.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["biomejs.biome"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"search.useIgnoreFiles": true, | ||
"search.exclude": { | ||
"**/.git": true, | ||
"**/dist": true, | ||
"**/coverage": true, | ||
"**/compiled": true, | ||
"**/doc_build": true, | ||
"**/node_modules": true, | ||
"**/tsconfig.tsbuildinfo": true | ||
}, | ||
"files.exclude": { | ||
"**/.DS_Store": true | ||
}, | ||
"mdx.validate.validateFileLinks": "ignore", | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports.biome": "explicit" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json", | ||
"organizeImports": { | ||
"enabled": true, | ||
"include": [ | ||
"./**/*.js", | ||
"./**/*.jsx", | ||
"./**/*.ts", | ||
"./**/*.tsx", | ||
"./**/*.mjs", | ||
"./**/*.cjs" | ||
] | ||
}, | ||
"vcs": { | ||
"enabled": true, | ||
"defaultBranch": "main", | ||
"clientKind": "git", | ||
"useIgnoreFile": true | ||
}, | ||
"files": { | ||
"ignoreUnknown": true | ||
}, | ||
"formatter": { | ||
"indentStyle": "space" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"semicolons": "asNeeded" | ||
} | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"style": { | ||
"noNonNullAssertion": "off", | ||
"useFilenamingConvention": { | ||
"level": "error", | ||
"options": { | ||
"filenameCases": ["camelCase", "PascalCase", "export"] | ||
} | ||
} | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "off", | ||
"noConfusingVoidType": "off" | ||
}, | ||
"performance": { | ||
"noDelete": "off" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('todo', async () => { | ||
expect(1).toBe(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { build } from '@rslib/core' | ||
import { expect, test } from 'vitest' | ||
import { globContentJSON } from '#helper' | ||
|
||
test.fails('define', async () => { | ||
// @ts-expect-error follow conventional | ||
delete process.env.NODE_ENV | ||
|
||
const rslibConfig = { | ||
root: __dirname, | ||
entry: './js/src/index.js', | ||
outDir: 'dist', | ||
} | ||
|
||
const instance = await build(rslibConfig) | ||
const results = await globContentJSON(instance.context.distPath, { | ||
absolute: true, | ||
ignore: ['/**/*.map'], | ||
}) | ||
|
||
const entryJs = Object.keys(results).find((file) => file.endsWith('.js')) | ||
expect(results[entryJs!]).not.toContain('console.info(VERSION)') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.info(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@rslib/e2e", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"test": "playwright test" | ||
}, | ||
"imports": { | ||
"#helper": "./scripts/helper.ts" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "1.43.1", | ||
"@rslib/core": "workspace:*", | ||
"@rslib/tsconfig": "workspace:*", | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/node": "16.x", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.2.0", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
// Playwright test files with `.pw.` to distinguish from Vitest test files | ||
testMatch: /.*pw.(test|spec).(js|ts|mjs)/, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { platform } from 'node:os' | ||
import { join } from 'node:path' | ||
import fg, { | ||
type Options as GlobOptions, | ||
convertPathToPattern, | ||
} from 'fast-glob' | ||
import fse from 'fs-extra' | ||
|
||
export const getFiles = async (pattern: string) => {} | ||
|
||
// fast-glob only accepts posix path | ||
// https://github.com/mrmlnc/fast-glob#convertpathtopatternpath | ||
const convertPath = (path: string) => { | ||
if (platform() === 'win32') { | ||
return convertPathToPattern(path) | ||
} | ||
return path | ||
} | ||
|
||
export const globContentJSON = async (path: string, options?: GlobOptions) => { | ||
const files = await fg(convertPath(join(path, '**/*')), options) | ||
const ret: Record<string, string> = {} | ||
|
||
await Promise.all( | ||
files.map((file) => | ||
fse.readFile(file, 'utf-8').then((content) => { | ||
ret[file] = content | ||
}), | ||
), | ||
) | ||
|
||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import {} from '@rslib/core' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@rslib/tsconfig/base", | ||
"compilerOptions": { | ||
"noEmit": true | ||
}, | ||
"include": ["cases", "playwright.config.ts", "cases/**/*.test.ts", "scripts"], | ||
"exclude": ["**/node_modules", "**/.*/"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
{ | ||
"private": true, | ||
"name": "rslib-monorepo", | ||
"scripts": {}, | ||
"packageManager": "[email protected]", | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=16.18.1" | ||
}, | ||
"scripts": { | ||
"build": "pnpm -r --filter='./packages/*' run build", | ||
"prepare": "pnpm run build && simple-git-hooks", | ||
"test:unit": "vitest run --project unit", | ||
"test:artifact": "vitest run --project artifact", | ||
"test:e2e": "cd e2e && pnpm run test", | ||
"check-dependency-version": "check-dependency-version-consistency .", | ||
"lint": "biome check . --diagnostic-level=warn" | ||
}, | ||
"simple-git-hooks": { | ||
"pre-commit": "npx nano-staged" | ||
}, | ||
"nano-staged": { | ||
"*.{md,mdx,json,css,less,scss}": "prettier --write", | ||
"*.{js,jsx,ts,tsx,mjs,cjs}": [ | ||
"biome check --apply --formatter-enabled=false --linter-enabled=false", | ||
"prettier --write" | ||
] | ||
], | ||
"package.json": "pnpm run check-dependency-version" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.2.4", | ||
"@biomejs/biome": "^1.7.0", | ||
"@modern-js/module-tools": "^2.48.6", | ||
"check-dependency-version-consistency": "^4.1.0", | ||
"cross-env": "^7.0.3", | ||
"nano-staged": "^0.8.0", | ||
"simple-git-hooks": "^2.10.0" | ||
"prettier": "^3.2.4", | ||
"simple-git-hooks": "^2.10.0", | ||
"vitest": "^1.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env node | ||
|
||
async function main() { | ||
const { runCli } = require('../dist/cli') | ||
runCli() | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig, moduleTools } from '@modern-js/module-tools' | ||
|
||
export default defineConfig({ | ||
plugins: [moduleTools()], | ||
buildConfig: [ | ||
{ | ||
input: ['src'], | ||
buildType: 'bundleless', | ||
format: 'cjs', | ||
autoExtension: true, | ||
target: 'es2020', | ||
}, | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "@rslib/core", | ||
"type": "commonjs", | ||
"bin": { | ||
"rslib": "./bin/rslib.js" | ||
}, | ||
"main": "./dist/main.js", | ||
"types": "./dist/main.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/main.d.ts", | ||
"default": "./dist/main.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "modern build", | ||
"dev": "modern build --watch" | ||
}, | ||
"dependencies": { | ||
"@rsbuild/core": "0.6.2", | ||
"@rsbuild/shared": "0.6.2", | ||
"commander": "^12.0.0" | ||
}, | ||
"devDependencies": { | ||
"@rslib/tsconfig": "workspace:*", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
Oops, something went wrong.