Skip to content

Commit

Permalink
refactor: simplify structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 21, 2024
1 parent 22fb749 commit 4761a1d
Show file tree
Hide file tree
Showing 53 changed files with 26 additions and 42 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
3 changes: 3 additions & 0 deletions app/.unjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../docs/.docs/.nuxt/tsconfig.json"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fileURLToPath } from 'node:url'
import { defineNuxtModule } from 'nuxt/kit'
import type { ModuleOptions as ContentOptions } from '@nuxt/content'
import type { DocsConfig } from '../../../../../schema/config'
import type { DocsConfig } from '../../../schema/config'

export default defineNuxtModule({
async setup(_, nuxt) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion layers/core/app/pages/index.vue → app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { DocsConfig } from '../../schema'
import type { DocsConfig } from '../../schema/config'
type LandingConfig = NonNullable<DocsConfig['landing']>
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions app/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../docs/.docs/.nuxt/tsconfig.server.json"
}
File renamed without changes.
3 changes: 3 additions & 0 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../docs/.docs/.nuxt/tsconfig.json"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions bin/cli.mjs

This file was deleted.

7 changes: 0 additions & 7 deletions layers/core/cli/cli.mjs → cli/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { defineCommand, runMain } from 'citty'
import { setupDocs } from './setup.mjs'
// import type { SetupDocsOptions } from './setup.mjs'

// export interface DocsCLIOptions {
// name?: string
// description?: string
// setup?: SetupDocsOptions
// }

export function createCLI(opts) {
const sharedArgs = {
Expand Down
6 changes: 3 additions & 3 deletions layers/unjs/cli/main.mjs → cli/main.mjs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

import { fileURLToPath } from 'node:url'
import { createCLI } from '../../core/cli/cli.mjs'
import { createCLI } from './cli.mjs'

const appDir = fileURLToPath(new URL('../app', import.meta.url))

const cli = createCLI({
name: 'undocs',
description: 'UnJS Docs Tool',
setup: {
extends: [appDir],
defaults: {
github: 'unjs',
themeColor: '#ECDC5A',
Expand Down
13 changes: 3 additions & 10 deletions layers/core/cli/setup.mjs → cli/setup.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { fileURLToPath } from 'node:url'
import { resolve } from 'node:path'
// import type { NuxtConfig } from 'nuxt/schema'
import { getColors } from 'theme-colors'
import { loadConfig } from 'c12'
// import type { DocsConfig } from '../../../schema/config'

const appDir = fileURLToPath(new URL('../app', import.meta.url))
const pkgDir = fileURLToPath(new URL('../../..', import.meta.url))
const appDirUnjs = fileURLToPath(new URL('../app/.unjs', import.meta.url))

// export interface SetupDocsOptions {
// defaults?: DocsConfig
// dev?: boolean
// extends?: string[]
// }
const pkgDir = fileURLToPath(new URL('..', import.meta.url))

export async function setupDocs(docsDir, opts = {}) {
// Try to load docs config
Expand All @@ -30,8 +24,7 @@ export async function setupDocs(docsDir, opts = {}) {
const nuxtConfig = {
rootDir: resolve(docsDir, '.docs'),
srcDir: resolve(docsDir, '.docs'),

extends: [...(opts.extends || []), appDir, '@nuxt/ui-pro'],
extends: [...(opts.extends || []), appDirUnjs, appDir, '@nuxt/ui-pro'],
modulesDir: [resolve(pkgDir, 'node_modules'), resolve(docsDir, 'node_modules')],
build: {
transpile: [appDir],
Expand Down
3 changes: 0 additions & 3 deletions layers/core/app/server/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions layers/core/app/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions layers/unjs/app/tsconfig.json

This file was deleted.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"undocs": "./bin/cli.mjs"
},
"files": [
"bin",
"layers",
"!layers/**/node_modules",
"!layers/**/tsconfig.json",
"schema"
"app",
"cli",
"schema",
"!app/**/node_modules",
"!app/**/tsconfig.json"
],
"scripts": {
"build": "true",
Expand All @@ -22,12 +22,12 @@
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c layers",
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c -w layers",
"prepack": "bun run build",
"profile:0x": "bunx 0x -o bin/cli.mjs dev docs",
"profile:0x": "bunx 0x -o cli/main.mjs dev docs",
"profile:0x-kernel": "bun run profile:0x --kernel-tracing",
"profile:cpu": "rm -rf .profile && node --cpu-prof --diagnostic-dir ../../../.profile bin/cli.mjs dev docs",
"profile:cpu": "rm -rf .profile && node --cpu-prof --diagnostic-dir ../.profile bin/cli.mjs dev docs",
"release": "bun run lint && changelogen --release && npm publish && git push --follow-tags",
"template:dev": "bun run undocs dev template",
"undocs": "./bin/cli.mjs"
"undocs": "./cli/main.mjs"
},
"dependencies": {
"@nuxt/content": "^2.12.0",
Expand Down Expand Up @@ -67,4 +67,4 @@
"vue-tsc": "^1.8.27"
},
"packageManager": "bun@1.0.26"
}
}

0 comments on commit 4761a1d

Please sign in to comment.