Skip to content

Commit

Permalink
refactor: tidy package manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 17, 2023
1 parent 2ca81a3 commit e339535
Show file tree
Hide file tree
Showing 50 changed files with 667 additions and 346 deletions.
26 changes: 26 additions & 0 deletions .changeset/many-rice-exist.md
@@ -0,0 +1,26 @@
---
'@vue-macros/reactivity-transform': patch
'@vue-macros/define-props-refs': patch
'@vue-macros/setup-component': patch
'unplugin-vue-define-options': patch
'@vue-macros/named-template': patch
'@vue-macros/better-define': patch
'@vue-macros/define-render': patch
'@vue-macros/define-model': patch
'@vue-macros/define-props': patch
'@vue-macros/define-slots': patch
'@vue-macros/export-props': patch
'@vue-macros/hoist-static': patch
'@vue-macros/short-vmodel': patch
'@vue-macros/setup-block': patch
'@vue-macros/short-emits': patch
'@vue-macros/setup-sfc': patch
'@vue-macros/devtools': patch
'@vue-macros/common': patch
'unplugin-vue-macros': patch
'@vue-macros/volar': patch
'@vue-macros/nuxt': patch
'@vue-macros/api': patch
---

tidy package manifests
87 changes: 87 additions & 0 deletions monoman.config.ts
@@ -0,0 +1,87 @@
import path from 'node:path'
import { defineConfig } from 'monoman'

function getPkgName(filepath: string) {
const relative = path.relative(process.cwd(), filepath)
const [, pkgName] = relative.split(path.sep)
return pkgName
}

export default defineConfig([
{
include: ['packages/*/package.json'],
type: 'json',
write(data: Record<string, any>, { filepath }) {
const pkgName = getPkgName(filepath)

const descriptions: Record<string, string> = {
'define-options': 'Add defineOptions macro for Vue <script setup>.',
macros: 'Explore and extend more macros and syntax sugar to Vue.',
volar: 'Volar plugin for Vue Macros.',
devtools: 'Devtools plugin for Vue Macros.',
api: 'General API for Vue Macros.',
}
if (!data.private) {
data.description =
descriptions[pkgName] || `${pkgName} feature from Vue Macros.`
data.keywords = [
'vue-macros',
'macros',
'vue',
'sfc',
'setup',
'script-setup',
pkgName,
]
}
data.license = 'MIT'
if (pkgName === 'define-options') {
data.homepage =
'https://github.com/sxzz/unplugin-vue-macros/tree/main/packages/define-options#readme'
} else {
data.homepage = 'https://github.com/sxzz/unplugin-vue-macros#readme'
}

data.bugs = { url: 'https://github.com/sxzz/unplugin-vue-macros/issues' }
data.repository = {
type: 'git',
url: 'git+https://github.com/sxzz/unplugin-vue-macros.git',
directory: `packages/${pkgName}`,
}
data.author = '三咲智子 <sxzz@sxzz.moe>'
data.engines = { node: '>=14.19.0' }

if (Object.keys(data.dependencies).includes('unplugin')) {
const frameworks = ['vite', 'webpack', 'rollup', 'esbuild']
data.keywords.push('unplugin')
data.exports = {
'.': {
dev: './src/index.ts',
types: './dist/index.d.ts',
require: './dist/index.js',
import: './dist/index.mjs',
},
...Object.fromEntries(
frameworks.map((framework) => [
`./${framework}`,
{
dev: `./src/${framework}.ts`,
types: `./dist/${framework}.d.ts`,
require: `./dist/${framework}.js`,
import: `./dist/${framework}.mjs`,
},
])
),
'./*': ['./*', './*.d.ts'],
}
data.typesVersions = {
'<=4.9': {
'*': ['./dist/*', './*'],
},
}
}

return data
},
},
])
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -33,7 +33,7 @@
"@babel/types": "^7.20.7",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@sxzz/eslint-config": "^2.4.4",
"@sxzz/eslint-config": "^2.4.5",
"@types/node": "18.13.0",
"@vitest/coverage-c8": "^0.28.4",
"@vitest/ui": "^0.28.4",
Expand All @@ -45,6 +45,7 @@
"expect-type": "^0.15.0",
"fast-glob": "^3.2.12",
"hookable": "^5.4.2",
"monoman": "^0.1.0",
"npm-run-all": "^4.1.5",
"rollup-plugin-esbuild": "^5.0.0",
"tsup": "^6.6.0",
Expand Down
15 changes: 13 additions & 2 deletions packages/api/package.json
Expand Up @@ -2,14 +2,25 @@
"name": "@vue-macros/api",
"version": "0.4.2",
"packageManager": "pnpm@7.27.0",
"description": "General API for Vue Macros.",
"keywords": [
"vue-macros",
"macros",
"vue",
"sfc",
"setup",
"script-setup",
"api"
],
"license": "MIT",
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
"bugs": {
"url": "https://github.com/sxzz/unplugin-vue-macros/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git",
"directory": "packages/api"
},
"author": "三咲智子 <sxzz@sxzz.moe>",
"files": [
Expand All @@ -29,7 +40,7 @@
},
"scripts": {
"build": "tsup && tsx ../../scripts/postbuild.mts",
"dev": "DEV=1 tsup"
"dev": "DEV=true tsup"
},
"dependencies": {
"@babel/types": "^7.20.7",
Expand Down
4 changes: 1 addition & 3 deletions packages/api/tsup.config.ts
@@ -1,3 +1 @@
import cfg from '../common/tsup.config.js'

export default cfg
export { default } from '../../tsup.config.js'
27 changes: 20 additions & 7 deletions packages/better-define/package.json
Expand Up @@ -2,15 +2,16 @@
"name": "@vue-macros/better-define",
"version": "1.3.2",
"packageManager": "pnpm@7.27.0",
"description": "",
"description": "better-define feature from Vue Macros.",
"keywords": [
"unplugin",
"vue-macros",
"macros",
"vue",
"sfc",
"setup",
"macros",
"script-setup",
"better-define"
"better-define",
"unplugin"
],
"license": "MIT",
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
Expand All @@ -19,7 +20,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git",
"directory": "packages/better-define"
},
"author": "三咲智子 <sxzz@sxzz.moe>",
"files": [
Expand Down Expand Up @@ -59,11 +61,22 @@
"require": "./dist/esbuild.js",
"import": "./dist/esbuild.mjs"
},
"./*": "./*"
"./*": [
"./*",
"./*.d.ts"
]
},
"typesVersions": {
"<=4.9": {
"*": [
"./dist/*",
"./*"
]
}
},
"scripts": {
"build": "tsup && tsx ../../scripts/postbuild.mts",
"dev": "DEV=1 tsup"
"dev": "DEV=true tsup"
},
"dependencies": {
"@rollup/pluginutils": "^5.0.2",
Expand Down
4 changes: 1 addition & 3 deletions packages/better-define/tsup.config.ts
@@ -1,3 +1 @@
import cfg from '../common/tsup.config.js'

export default cfg
export { default } from '../../tsup.config.js'
15 changes: 13 additions & 2 deletions packages/common/package.json
Expand Up @@ -2,14 +2,25 @@
"name": "@vue-macros/common",
"version": "1.0.0",
"packageManager": "pnpm@7.27.0",
"description": "common feature from Vue Macros.",
"keywords": [
"vue-macros",
"macros",
"vue",
"sfc",
"setup",
"script-setup",
"common"
],
"license": "MIT",
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
"bugs": {
"url": "https://github.com/sxzz/unplugin-vue-macros/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git",
"directory": "packages/common"
},
"author": "三咲智子 <sxzz@sxzz.moe>",
"files": [
Expand All @@ -29,7 +40,7 @@
},
"scripts": {
"build": "tsup && tsx ../../scripts/postbuild.mts",
"dev": "DEV=1 tsup"
"dev": "DEV=true tsup"
},
"peerDependencies": {
"vue": "^2.7.0 || ^3.2.25"
Expand Down
45 changes: 1 addition & 44 deletions packages/common/tsup.config.ts
@@ -1,44 +1 @@
import { readFile } from 'node:fs/promises'
import { defineConfig } from 'tsup'

const rawRE = /[&?]raw(?:&|$)/

export default defineConfig({
entry: ['./src/*.ts'],
format: ['cjs', 'esm'],
target: 'node14',
splitting: true,
watch: !!process.env.DEV,
dts: process.env.DEV
? false
: {
compilerOptions: {
composite: false,
customConditions: ['dev'],
},
},
tsconfig: '../../tsconfig.lib.json',
clean: true,
define: {
'import.meta.DEV': JSON.stringify(!!process.env.DEV),
},
esbuildOptions: (options) => {
options.conditions = ['dev']
},
esbuildPlugins: [
{
name: 'raw-plugin',
setup(build) {
build.onLoad({ filter: /.*/ }, async ({ path, suffix }) => {
if (!rawRE.test(suffix)) return
// raw query, read file and return as string
return {
contents: `export default ${JSON.stringify(
await readFile(path, 'utf-8')
)}`,
}
})
},
},
],
})
export { default } from '../../tsup.config.js'
29 changes: 20 additions & 9 deletions packages/define-model/package.json
Expand Up @@ -2,15 +2,16 @@
"name": "@vue-macros/define-model",
"version": "1.3.1",
"packageManager": "pnpm@7.27.0",
"description": "",
"description": "define-model feature from Vue Macros.",
"keywords": [
"unplugin",
"vue-macros",
"macros",
"vue",
"sfc",
"setup",
"macros",
"script-setup",
"define-model"
"define-model",
"unplugin"
],
"license": "MIT",
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
Expand All @@ -19,7 +20,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git",
"directory": "packages/define-model"
},
"author": "三咲智子 <sxzz@sxzz.moe>",
"files": [
Expand Down Expand Up @@ -61,13 +63,22 @@
"require": "./dist/esbuild.js",
"import": "./dist/esbuild.mjs"
},
"./macros": "./macros.d.ts",
"./macros-global": "./macros-global.d.ts",
"./*": "./*"
"./*": [
"./*",
"./*.d.ts"
]
},
"typesVersions": {
"<=4.9": {
"*": [
"./dist/*",
"./*"
]
}
},
"scripts": {
"build": "tsup && tsx ../../scripts/postbuild.mts",
"dev": "DEV=1 tsup"
"dev": "DEV=true tsup"
},
"peerDependencies": {
"@vueuse/core": "^9.0.0"
Expand Down
4 changes: 1 addition & 3 deletions packages/define-model/tsup.config.ts
@@ -1,3 +1 @@
import cfg from '../common/tsup.config.js'

export default cfg
export { default } from '../../tsup.config.js'

0 comments on commit e339535

Please sign in to comment.