Skip to content

Commit

Permalink
chore: update registry (#151)
Browse files Browse the repository at this point in the history
* fix: missing dependencies after import

* fix: demo component paths incorrect with subfolder
  • Loading branch information
zernonia authored Nov 6, 2023
1 parent 3e74fe7 commit cd3c767
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = {
'no-invalid-character': 'off',
'import/first': 'off',
'@stylistic/js/no-tabs': 'off',
'n/prefer-global/process': 'off',
},
}
6 changes: 2 additions & 4 deletions apps/www/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ for (const style of styles) {
name: "${item.name}",
type: "${item.type}",
registryDependencies: ${JSON.stringify(item.registryDependencies)},
component: () => import("../src/lib/registry/${style.name}/${type}/${
item.name
}.vue").then((m) => m.default),
component: () => import("${resolveFiles[0]}").then((m) => m.default),
files: [${resolveFiles.map(file => `"${file}"`)}],
},`
}
Expand Down Expand Up @@ -375,7 +373,7 @@ export const THEME_STYLES_WITH_VARIABLES = `
--ring: <%- colors.dark["ring"] %>;
}`

const themeCSS = []
const themeCSS: Array<string> = []
for (const theme of themes) {
themeCSS.push(
template(THEME_STYLES_WITH_VARIABLES)({
Expand Down
13 changes: 11 additions & 2 deletions apps/www/src/lib/registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import type { Registry } from '../../lib/registry'

const DEPENDENCIES = new Map<string, string[]>([
['radix-vue', []],
['@vueuse/core', []],
['v-calendar', []],
['@tanstack/vue-table', []],
['vee-validate', ['@vee-validate/zod', 'zod']],
])
// Some dependencies latest tag were not compatible with Vue3.
const DEPENDENCIES_WITH_TAGS = new Map<string, string>([
['v-calendar', 'v-calendar@next'],
])
const REGISTRY_DEPENDENCY = '@/'

type ArrayItem<T> = T extends Array<infer X> ? X : never
Expand Down Expand Up @@ -62,7 +67,7 @@ async function crawlExample(rootPath: string) {

if (dirent.isFile()) {
const [name] = dirent.name.split('.vue')
const file_path = join('example', dirent.name)
const file_path = join('example', dirent.path.split('/example')[1], dirent.name)
const { dependencies, registryDependencies }
= await getDependencies(join(dirent.path, dirent.name))

Expand Down Expand Up @@ -139,8 +144,12 @@ async function getDependencies(filename: string) {
Object.values(compiled.imports!).forEach((value) => {
const source = value.source
const peerDeps = DEPENDENCIES.get(source)
const taggedDeps = DEPENDENCIES_WITH_TAGS.get(source)
if (peerDeps !== undefined) {
dependencies.add(source)
if (taggedDeps !== undefined)
dependencies.add(taggedDeps)
else
dependencies.add(source)
peerDeps.forEach(dep => dependencies.add(dep))
}

Expand Down
11 changes: 8 additions & 3 deletions apps/www/src/public/registry/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"
Expand Down Expand Up @@ -302,7 +303,9 @@
},
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down Expand Up @@ -590,7 +593,9 @@
},
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down
3 changes: 2 additions & 1 deletion apps/www/src/public/registry/styles/default/calendar.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"
Expand Down
4 changes: 3 additions & 1 deletion apps/www/src/public/registry/styles/default/input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down
4 changes: 3 additions & 1 deletion apps/www/src/public/registry/styles/default/textarea.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down
3 changes: 2 additions & 1 deletion apps/www/src/public/registry/styles/new-york/calendar.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"
Expand Down
4 changes: 3 additions & 1 deletion apps/www/src/public/registry/styles/new-york/input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down
4 changes: 3 additions & 1 deletion apps/www/src/public/registry/styles/new-york/textarea.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
Expand Down
11 changes: 6 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"display": "Default",
"compilerOptions": {
"composite": false,
"module": "ESNext",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
"skipLibCheck": true
},
"exclude": ["node_modules"]
}

0 comments on commit cd3c767

Please sign in to comment.