Skip to content
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
55 changes: 4 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,8 @@ on:
- main
- 'v*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

- name: Setup node
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: lts/*
cache: pnpm

- run: pnpm install
- run: pnpm run lint
- run: pnpm run typecheck

ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20, 22, 24]
fail-fast: false
permissions: {}

steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

- name: Set node version to ${{ matrix.node }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: ${{ matrix.node }}
cache: pnpm

- name: Install
run: pnpm install

- name: Build
run: pnpm run build

- name: Test
run: pnpm run test
jobs:
unit-test:
uses: sxzz/workflows/.github/workflows/unit-test.yml@v1
90 changes: 43 additions & 47 deletions docs/.vitepress/data/gen-files.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Repository } from './repository.data'
import type { Repository } from './repository.data.ts'
import { writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { env } from 'node:process'
import { fileURLToPath } from 'node:url'
import { consola } from 'consola'
import { $fetch } from 'ofetch'
import { repositoryMeta } from './meta'
import { repositoryMeta } from './meta.ts'
import 'dotenv/config'

const GITHUB_TOKEN = env.GITHUB_TOKEN
Expand Down Expand Up @@ -35,6 +35,47 @@ query repositoryQuery($owner: String!, $name: String!, $readme: String!) {
}
}`

if (!GITHUB_TOKEN) {
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
process.exit(1)
}

const fetchs = repositoryMeta.map((repository) => {
return fetchRepo({
name: repository.name,
owner: repository.owner,
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
})
})

Promise.allSettled(fetchs).then((res) => {
const repoMeta = res?.map((item) => {
if (item.status === 'fulfilled') {
return {
name: item.value?.name,
stargazers: item.value?.stargazers,
owner: item.value?.owner,
description: item.value?.description,
url: item.value?.url,
isTemplate: item.value?.isTemplate,
primaryLanguage: item.value?.primaryLanguage,
forkCount: item.value?.forkCount,
}
}

return null
})?.filter(item => item && item.name)

writeFileSync(
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
JSON.stringify(repoMeta, null, 2),
)
consola.success('[repository.json] generate success!')
consola.success('All files generate done!')
}).catch((error) => {
consola.error(error)
})

async function fetchRepo(meta: {
owner: string
name: string
Expand Down Expand Up @@ -88,48 +129,3 @@ outline: deep
consola.error(`[${name}.md]: generate failed: ${error}`)
}
}

function main() {
if (!GITHUB_TOKEN) {
consola.error('GITHUB_TOKEN is missing, please refer to https://github.com/unjs/unplugin/blob/main/docs/README.md#development')
return false
}

const fetchs = repositoryMeta.map((repository) => {
return fetchRepo({
name: repository.name,
owner: repository.owner,
readme: repository.defaultBranch ? `${repository.defaultBranch}:README.md` : 'main:README.md',
})
})

Promise.allSettled(fetchs).then((res) => {
const repoMeta = res?.map((item) => {
if (item.status === 'fulfilled') {
return {
name: item.value?.name,
stargazers: item.value?.stargazers,
owner: item.value?.owner,
description: item.value?.description,
url: item.value?.url,
isTemplate: item.value?.isTemplate,
primaryLanguage: item.value?.primaryLanguage,
forkCount: item.value?.forkCount,
}
}

return null
})?.filter(item => item && item.name)

writeFileSync(
join(dirname(fileURLToPath(import.meta.url)), './repository.json'),
JSON.stringify(repoMeta, null, 2),
)
consola.success('[repository.json] generate success!')
consola.success('All files generate done!')
}).catch((error) => {
consola.error(error)
})
}

main()
3 changes: 1 addition & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": ">=18.19.0"
},
"scripts": {
"gen-files": "tsx ./.vitepress/data/gen-files.ts",
"gen-files": "node ./.vitepress/data/gen-files.ts",
"dev": "vitepress dev --open",
"build": "pnpm gen-files && vitepress build",
"lint": "case-police '**/*.md'",
Expand All @@ -21,7 +21,6 @@
"markdown-it": "catalog:docs",
"markdown-it-github-alerts": "catalog:docs",
"ofetch": "catalog:docs",
"tsx": "catalog:docs",
"unocss": "catalog:docs",
"unplugin": "workspace:*",
"unplugin-icons": "catalog:docs",
Expand Down
54 changes: 25 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
},
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.cjs",
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.cjs"
".": "./dist/index.mjs",
"./rspack/loaders/load": "./dist/rspack/loaders/load.mjs",
"./rspack/loaders/transform": "./dist/rspack/loaders/transform.mjs",
"./webpack/loaders/load": "./dist/webpack/loaders/load.mjs",
"./webpack/loaders/transform": "./dist/webpack/loaders/transform.mjs",
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"files": [
"dist"
],
"engines": {
"node": ">=18.12.0"
"node": "^20.19.0 || >=22.12.0"
},
"scripts": {
"build": "tsdown",
Expand All @@ -39,7 +39,7 @@
"docs:gen-files": "pnpm -C docs run gen-files",
"prepublishOnly": "nr build",
"release": "bumpp",
"test": "nr test:build && vitest run --pool=forks",
"test": "nr test:build && vitest run",
"test:build": "jiti scripts/buildFixtures.ts"
},
"dependencies": {
Expand All @@ -51,42 +51,38 @@
"devDependencies": {
"@antfu/eslint-config": "catalog:",
"@antfu/ni": "catalog:",
"@farmfe/cli": "catalog:",
"@farmfe/core": "catalog:",
"@rspack/cli": "catalog:",
"@rspack/core": "catalog:",
"@types/fs-extra": "catalog:",
"@farmfe/cli": "catalog:test",
"@farmfe/core": "catalog:peer",
"@rspack/cli": "catalog:test",
"@rspack/core": "catalog:peer",
"@types/node": "catalog:",
"@types/picomatch": "catalog:",
"ansis": "catalog:",
"bumpp": "catalog:",
"esbuild": "catalog:",
"esbuild-plugin-copy": "catalog:",
"eslint": "catalog:",
"eslint-plugin-format": "catalog:",
"fast-glob": "catalog:",
"fs-extra": "catalog:",
"jiti": "catalog:",
"jiti": "catalog:default",
"lint-staged": "catalog:",
"magic-string": "catalog:",
"rolldown": "catalog:",
"rollup": "catalog:",
"magic-string": "catalog:test",
"rolldown": "catalog:peer",
"rollup": "catalog:peer",
"simple-git-hooks": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:",
"unloader": "catalog:",
"unloader": "catalog:peer",
"unplugin": "workspace:*",
"unplugin-unused": "catalog:",
"vite": "catalog:",
"vitest": "catalog:",
"webpack": "catalog:",
"webpack-cli": "catalog:"
"vite": "catalog:peer",
"vitest": "catalog:test",
"webpack": "catalog:peer",
"webpack-cli": "catalog:test"
},
"resolutions": {
"esbuild": "catalog:"
},
"simple-git-hooks": {
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && pnpm exec lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
Expand Down
Loading
Loading