Skip to content

Commit

Permalink
ci: add monoman check
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Aug 26, 2023
1 parent 7c1bc6a commit e77b26a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Format Check
run: nr format:check

- name: Monorepo Check
run: nr mono:check

test:
strategy:
matrix:
Expand Down
19 changes: 12 additions & 7 deletions monoman.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// @ts
import path from 'node:path'
import { readFile } from 'node:fs/promises'
import { existsSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'monoman'
import { type Options } from 'tsup'
import fg from 'fast-glob'

function getPkgName(filepath: string) {
const relative = path.relative(process.cwd(), filepath)
// @ts-expect-error
const dirname = path.dirname(fileURLToPath(new URL(import.meta.url)))

function getPkgName(filePath: string) {
const relative = path.relative(dirname, filePath)
const [, pkgName] = relative.split(path.sep)
return pkgName
}
Expand All @@ -15,10 +20,10 @@ export default defineConfig([
{
include: ['packages/*/package.json'],
type: 'json',
async write(data: Record<string, any>, { filepath }) {
const pkgRoot = path.resolve(filepath, '..')
async contents(data: Record<string, any>, { filePath }) {
const pkgRoot = path.resolve(filePath, '..')
const pkgSrc = path.resolve(pkgRoot, 'src')
const pkgName = getPkgName(filepath)
const pkgName = getPkgName(filePath)
const isESM = data.type === 'module'
const cjsPrefix = isESM ? 'c' : ''
const esmPrefix = isESM ? '' : 'm'
Expand Down Expand Up @@ -129,8 +134,8 @@ export default defineConfig([
include: ['packages/*/README.md'],
exclude: ['packages/define-options/README.md'],
type: 'text',
async write(_, ctx) {
const pkgPath = path.resolve(path.dirname(ctx.filepath), 'package.json')
async contents(_, ctx) {
const pkgPath = path.resolve(path.dirname(ctx.filePath), 'package.json')
const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'))
const pkgName = pkg.name

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"lint": "eslint --max-warnings 0 --cache .",
"format": "prettier --write --cache .",
"format:check": "prettier --check --cache .",
"mono:check": "monoman --check",
"publish": "pnpm build && changeset publish",
"typecheck": "run-p \"typecheck:*\"",
"typecheck:lib": "vue-tsc --noEmit -p tsconfig.lib.json",
Expand All @@ -47,7 +48,7 @@
"eslint-define-config": "^1.23.0",
"expect-type": "^0.16.0",
"fast-glob": "^3.3.1",
"monoman": "^0.2.0",
"monoman": "^0.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
Expand Down
18 changes: 13 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e77b26a

Please sign in to comment.