-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonoman.config.ts
More file actions
149 lines (137 loc) · 4.42 KB
/
monoman.config.ts
File metadata and controls
149 lines (137 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { readdir, readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'
import { camelCase } from 'change-case'
import { defineConfig } from 'monoman';
import {
// noDuplicatedDeps,
noDuplicatedPnpmLockfile,
} from 'monoman/presets'
import { docsLink, githubLink } from './macros/repo'
import type { PackageJson } from 'pkg-types'
/// keep-sorted
// const descriptions: Record<string, string> = {
// 'define-options': 'Add defineOptions macro for Vue <script setup>.',
// 'test-utils': 'Test utilities for Vue Macros.',
// api: 'General API for Vue Macros.',
// astro: 'Astro integration of Vue Macros.',
// config: 'Config API for Vue Macros.',
// devtools: 'Devtools plugin for Vue Macros.',
// macros: 'Explore more macros and syntax sugar to Vue.',
// volar: 'Volar plugin for Vue Macros.',
// }
function getPkgName(filePath: string) {
const relative = path.relative(import.meta.dirname, filePath)
const [ , pkgName ] = relative.split(path.sep)
return pkgName
}
let version: string | undefined
export default defineConfig([
{
include: [ 'packages/*/package.json' ],
type: 'json',
async contents(data: PackageJson, { filePath }) {
const pkgRoot = path.resolve(filePath, '..')
const pkgSrc = path.resolve(pkgRoot, 'src')
const pkgName = getPkgName(filePath)
data.type = 'module'
const hasRootDts = (await readdir(pkgRoot)).some((file) =>
file.endsWith('.d.ts'),
)
if (!data.private) {
data.version = version ||= data.version
data.description = `ixfx ${ camelCase(pkgName) }`
data.keywords = [
'ixfx',
'interactivity',
pkgName,
]
}
data.main = './dist/index.js'
data.license = 'MIT'
data.homepage = docsLink
data.bugs = { url: `${ githubLink }/issues` }
data.repository = {
type: 'git',
url: `git+${ githubLink }.git`,
directory: `packages/${ pkgName }`,
}
data.author = 'Clint Heyer <clint@thestaticvoid.net>'
data.engines = { node: '>=24.0.0' }
data.files = [ 'dist' ]
if (hasRootDts) data.files.push('*.d.ts')
data.files.sort()
// if (
// Object.keys(data.dependencies || {}).includes('unplugin') ||
// data?.meta?.plugin
// ) {
// data.keywords!.push('unplugin')
// // write unplugin entries
// const entries = [
// 'vite',
// 'webpack',
// 'rollup',
// 'esbuild',
// 'rspack',
// 'rolldown',
// ]
// Promise.all(
// entries.map((entry) =>
// writeFile(
// path.resolve(pkgSrc, `${ entry }.ts`),
// `import unplugin from '.'\n
// export default unplugin.${ entry } as typeof unplugin.${ entry }\n`,
// 'utf8',
// ),
// ),
// )
// }
data.publishConfig ||= {}
data.publishConfig.access = 'public'
// data.publishConfig.tag = 'next'
return data
},
},
{
include: [ 'packages/*/README.md' ],
exclude: [ 'packages/define-options/README.md' ],
type: 'text',
async contents(_, ctx) {
const pkgPath = path.resolve(path.dirname(ctx.filePath), 'package.json')
const pkg = JSON.parse(await readFile(pkgPath, 'utf8'))
const pkgName = pkg.name
return `# ${ pkgName } [](https://npmjs.com/package/${ pkgName })\n
Please refer to [README.md](${ githubLink }#readme)\n`
},
},
// ...noDuplicatedDeps({
// include: [
// 'package.json',
// 'packages/*/package.json'
// ],
// }),
// ...noDuplicatedDeps({
// include: [
// 'package.json',
// 'packages/*/package.json'
// ],
// ignores: [ 'vue' ],
// }),
// ...noDuplicatedPnpmLockfile({
// deps: [
// 'typescript',
// /vite(?!-(plugin-(vue-devtools|inspect)|hot-client))/,
// /vue\b(?!([/-]devtools))/,
// /twoslash/,
// /shiki/,
// /babel/,
// /esbuild/,
// /unocss/,
// /rolldown/,
// /oxc(?!-project\/types)/,
// ],
// }),
// ...noDuplicatedPnpmLockfile({
// deps: [ 'lru-cache', 'minimatch', 'debug', 'vite-plugin-vue-devtools' ],
// allowMajor: true,
// }),
])