@altafusion/nuxt-base 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dev/nuxt-cli.mjs +57 -0
- package/dev/nuxt-dev.mjs +122 -0
- package/dev/nuxt-prepare.mjs +31 -0
- package/dev/open-browser.ts +118 -0
- package/dev/openChromiumWithoutReload.js +56 -0
- package/dev/ports.ts +97 -0
- package/dev/reuse-dev-browser.ts +29 -0
- package/eslint.config.mjs +16 -0
- package/index.ts +211 -0
- package/lib/nuxt-ui-theme.ts +130 -0
- package/modules/docus-typecheck.ts +156 -0
- package/modules.ts +49 -0
- package/nuxt.config.ts +47 -0
- package/package.json +69 -3
- package/tsconfig.template.json +11 -0
- package/typescript.ts +25 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @altafusion/nuxt-base
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- da3fca4: Remove dead links to the old documentation site from the package READMEs, and drop a site-specific entry from the `reset-fugue-content-site` helper.
|
|
8
|
+
- Updated dependencies [91aea5e]
|
|
9
|
+
- @altafusion/eslint-config@0.3.0
|
|
10
|
+
|
|
11
|
+
## 0.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 7767e60: Rebrand for the public release. In `@altafusion/shell`, `CODERMAR_BRANDS`, `CODERMAR_BRAND_THEME` and `utils/codermarBrandTheme` become `ALTAFUSION_*` and `utils/altafusionBrandTheme`, and the brand cookie key is now `altafusion:brand`. In `@altafusion/msw`, the `codermarMsw*` exports become `altafusionMsw*`. The site settings schema `$id` is now `https://altafusion.com/schemas/site-settings.json`. Package descriptions and docs no longer reference private sites.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [7767e60]
|
|
20
|
+
- @altafusion/eslint-config@0.2.0
|
|
21
|
+
|
|
22
|
+
## 0.1.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- @altafusion/eslint-config@0.1.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Altafusion
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @altafusion/nuxt-base
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Platform Nuxt layer — shared modules, TypeScript, runtime defaults, Vite/Nitro baseline. Product layers (Fugue, design-system) **extend** this; apps extend those layers.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
Layer `nuxt.config.ts` registers **`sharedModules`** from **`./modules`**, plus **`sharedModuleConfig`**, **`sharedTypeScriptConfig`**, **`sharedRuntimeConfig`**, and **`sharedDevtoolsConfig`**. No SPA-only opts (e.g. `experimental.appManifest`) — apps opt in locally.
|
|
8
|
+
|
|
9
|
+
## Exports
|
|
10
|
+
|
|
11
|
+
| Subpath | Role |
|
|
12
|
+
|---------|------|
|
|
13
|
+
| `.` | **`createAppConfig`**, **`baseNuxtConfig`**, shared module/runtime re-exports, Nuxt UI theme helpers |
|
|
14
|
+
| `./modules` | **`sharedModules`**, devtools/runtime/module config |
|
|
15
|
+
| `./typescript` | Shared TS compiler options |
|
|
16
|
+
| `./dev/ports` | Canonical HTTP dev ports, `devViteServerOptions`, `pinDevServerHmr` |
|
|
17
|
+
| `./dev/open-browser`, `./dev/reuse-dev-browser`, `./dev/nuxt-dev` | Dev server / browser utilities |
|
|
18
|
+
| `./ui-theme` | **`buildNuxtUIConfig`**, palette → Nuxt UI token helpers |
|
|
19
|
+
| `./tsconfig.template.json` | Package TS baseline |
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
**Extend the layer** (typical for packages):
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
export default defineNuxtConfig({
|
|
27
|
+
extends: ['@altafusion/nuxt-base'],
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Merge in an app** via **`createAppConfig`** (optional theme CSS, Nuxt UI tokens, dev browser reuse):
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { createAppConfig } from '@altafusion/nuxt-base'
|
|
35
|
+
|
|
36
|
+
export default createAppConfig(
|
|
37
|
+
{ /* app overrides */ },
|
|
38
|
+
{ theme: 'default', enableNuxtUI: true },
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
ESLint factories live in **`@altafusion/eslint-config`**, not here.
|
|
43
|
+
|
|
44
|
+
## Consumers
|
|
45
|
+
|
|
46
|
+
> **Local — do not copy-sync.** Repo wiring, ports, catalog keys, consuming apps, and docs-site links.
|
|
47
|
+
|
|
48
|
+
- **`createAppConfig({ theme, enableNuxtUI, … })`** — used by Altafusion product apps and **`templates/*`**. HMR stays on each app’s HTTP dev port via **`devViteServerOptions()`** / **`pinDevServerHmr`** inside **`createAppConfig`**; apps that do not use **`createAppConfig`** (e.g. a Docus site) set **`vite.server`** with **`devViteServerOptions()`** directly. Port **7003** is reserved for the first site copied from **`templates/fugue-content-site`**.
|
|
49
|
+
- **`devPorts`** / **`templateDevPorts`** — canonical HTTP ports for this monorepo (`developerDocs`, …); sites pass their own port to `nuxt-dev.mjs`.
|
|
50
|
+
- Downstream chain: **`@altafusion/fugue-nuxt-ui`** → Fugue family → **`@altafusion/shell`** / **`@altafusion/fugue-content`** on consumer apps.
|
package/dev/nuxt-cli.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Run the workspace-root `nuxt` binary with the given args.
|
|
4
|
+
*
|
|
5
|
+
* With `nodeLinker: hoisted`, package-local `node_modules/.bin/nuxt` shims can
|
|
6
|
+
* point at `<pkg>/node_modules/nuxt/...` which does not exist (Netlify
|
|
7
|
+
* `pnpm run build` → MODULE_NOT_FOUND). Walking up finds root
|
|
8
|
+
* `node_modules/nuxt/bin/nuxt.mjs`.
|
|
9
|
+
*
|
|
10
|
+
* Usage (from any workspace package two levels below root):
|
|
11
|
+
* "build": "node ../../packages-platform/nuxt-base/dev/nuxt-cli.mjs build"
|
|
12
|
+
* "postinstall": "node ../../packages-platform/nuxt-base/dev/nuxt-cli.mjs prepare"
|
|
13
|
+
*/
|
|
14
|
+
import { spawnSync } from 'node:child_process'
|
|
15
|
+
import { existsSync } from 'node:fs'
|
|
16
|
+
import { dirname, join } from 'node:path'
|
|
17
|
+
import process from 'node:process'
|
|
18
|
+
|
|
19
|
+
export function findNuxtBin(startDir = process.cwd()) {
|
|
20
|
+
let dir = startDir
|
|
21
|
+
while (true) {
|
|
22
|
+
const candidate = join(dir, 'node_modules', 'nuxt', 'bin', 'nuxt.mjs')
|
|
23
|
+
if (existsSync(candidate))
|
|
24
|
+
return candidate
|
|
25
|
+
const parent = dirname(dir)
|
|
26
|
+
if (parent === dir)
|
|
27
|
+
return null
|
|
28
|
+
dir = parent
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const args = process.argv.slice(2)
|
|
33
|
+
if (!args.length) {
|
|
34
|
+
console.error('[nuxt-cli] Usage: nuxt-cli.mjs <command> [...args]')
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const bin = findNuxtBin(process.cwd())
|
|
39
|
+
if (!bin) {
|
|
40
|
+
console.error(
|
|
41
|
+
`[nuxt-cli] Cannot find node_modules/nuxt/bin/nuxt.mjs from ${process.cwd()}`,
|
|
42
|
+
)
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const result = spawnSync(process.execPath, [bin, ...args], {
|
|
47
|
+
stdio: 'inherit',
|
|
48
|
+
cwd: process.cwd(),
|
|
49
|
+
env: process.env,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
if (result.error) {
|
|
53
|
+
console.error(`[nuxt-cli] ${result.error.message}`)
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
process.exit(result.status ?? 1)
|
package/dev/nuxt-dev.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process'
|
|
3
|
+
/**
|
|
4
|
+
* Run `nuxt dev` on the canonical 70xx port with env + CLI aligned.
|
|
5
|
+
* Usage: node @altafusion/nuxt-base/dev/nuxt-dev.mjs [devPortsKey] (or the `altafusion-nuxt-dev` bin)
|
|
6
|
+
*
|
|
7
|
+
* Keys must match `devPorts` in dev/ports.ts (see ports.test.ts). The key is optional when `SITE_DEV_PORT` or `PORT` is set,
|
|
8
|
+
* which is how a site outside this monorepo picks its port.
|
|
9
|
+
* fugue-content-site apps: optional `SITE_DEV_PORT` or `PORT` in cwd `.env` overrides the default.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
12
|
+
import os from 'node:os'
|
|
13
|
+
import { dirname, join } from 'node:path'
|
|
14
|
+
import process from 'node:process'
|
|
15
|
+
|
|
16
|
+
function findNuxtBin(startDir) {
|
|
17
|
+
let dir = startDir
|
|
18
|
+
while (true) {
|
|
19
|
+
const candidate = join(dir, 'node_modules', 'nuxt', 'bin', 'nuxt.mjs')
|
|
20
|
+
if (existsSync(candidate))
|
|
21
|
+
return candidate
|
|
22
|
+
const parent = dirname(dir)
|
|
23
|
+
if (parent === dir)
|
|
24
|
+
return null
|
|
25
|
+
dir = parent
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @type {Record<string, number>} — keep in sync with dev/ports.ts */
|
|
30
|
+
const devPorts = {
|
|
31
|
+
developerDocs: 7005,
|
|
32
|
+
pickup: 7006,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const key = process.argv[2]
|
|
36
|
+
// Sites outside this registry pass their port as the second argument: nuxt-dev.mjs <key> <port>
|
|
37
|
+
const defaultPort = devPorts[key] ?? (Number(process.argv[3]) || undefined)
|
|
38
|
+
|
|
39
|
+
function readDotEnvValue(name) {
|
|
40
|
+
try {
|
|
41
|
+
const line = readFileSync(join(process.cwd(), '.env'), 'utf8')
|
|
42
|
+
.split('\n')
|
|
43
|
+
.find(entry => entry.startsWith(`${name}=`) && !entry.trimStart().startsWith('#'))
|
|
44
|
+
if (!line)
|
|
45
|
+
return undefined
|
|
46
|
+
const raw = line.slice(name.length + 1).trim()
|
|
47
|
+
const quoted = (raw.startsWith('"') && raw.endsWith('"')) || (raw.startsWith('\'') && raw.endsWith('\''))
|
|
48
|
+
return quoted
|
|
49
|
+
? raw.slice(1, -1)
|
|
50
|
+
: raw
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const port = Number(process.env.SITE_DEV_PORT)
|
|
57
|
+
|| Number(process.env.PORT)
|
|
58
|
+
|| Number(readDotEnvValue('SITE_DEV_PORT'))
|
|
59
|
+
|| Number(readDotEnvValue('PORT'))
|
|
60
|
+
|| defaultPort
|
|
61
|
+
|
|
62
|
+
// A site outside this monorepo has no key in `devPorts`; it must set its own port.
|
|
63
|
+
if (!port) {
|
|
64
|
+
console.error(
|
|
65
|
+
`[nuxt-dev] No port for app key "${key ?? ''}". Set SITE_DEV_PORT or PORT (env or .env), or use a key from: ${Object.keys(devPorts).join(', ')}`,
|
|
66
|
+
)
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const portStr = String(port)
|
|
71
|
+
const env = {
|
|
72
|
+
...process.env,
|
|
73
|
+
PORT: portStr,
|
|
74
|
+
NUXT_PORT: portStr,
|
|
75
|
+
NITRO_PORT: portStr,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (key === 'developerDocs') {
|
|
79
|
+
// Bind after Nuxt config loads, so the default logo page is never served.
|
|
80
|
+
env.NUXT_DEV_EAGER_LISTEN = '0'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Nuxt 4.4+ puts vite-node IPC sockets under $TMPDIR/nuxt-vite-node-*/….sock (macOS max ~104 bytes).
|
|
84
|
+
// Default macOS TMPDIR (/var/folders/…) exceeds that → connect/listen EINVAL. Prefer /tmp when needed.
|
|
85
|
+
if (process.platform === 'darwin') {
|
|
86
|
+
const tmpdir = env.TMPDIR || os.tmpdir()
|
|
87
|
+
const sampleSocket = `${tmpdir}/nuxt-vite-node-XXXXXX/nuxt-vite-node-${process.pid}-${Date.now()}.sock`
|
|
88
|
+
if (sampleSocket.length >= 104) {
|
|
89
|
+
env.TMPDIR = '/tmp'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const nuxtBin = findNuxtBin(process.cwd())
|
|
94
|
+
if (!nuxtBin) {
|
|
95
|
+
console.error(`[nuxt-dev] Cannot find node_modules/nuxt/bin/nuxt.mjs from ${process.cwd()}`)
|
|
96
|
+
process.exit(1)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const child = spawn(
|
|
100
|
+
process.execPath,
|
|
101
|
+
[
|
|
102
|
+
nuxtBin,
|
|
103
|
+
'dev',
|
|
104
|
+
'--no-open',
|
|
105
|
+
'--host',
|
|
106
|
+
'localhost',
|
|
107
|
+
'--port',
|
|
108
|
+
portStr,
|
|
109
|
+
'--strictPort',
|
|
110
|
+
],
|
|
111
|
+
{
|
|
112
|
+
stdio: 'inherit',
|
|
113
|
+
env,
|
|
114
|
+
cwd: process.cwd(),
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
child.on('exit', (code, signal) => {
|
|
119
|
+
if (signal)
|
|
120
|
+
process.kill(process.pid, signal)
|
|
121
|
+
process.exit(code ?? 0)
|
|
122
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility wrapper — prefer `nuxt-cli.mjs prepare` in new scripts.
|
|
4
|
+
* @see ./nuxt-cli.mjs
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from 'node:child_process'
|
|
7
|
+
import { dirname, join } from 'node:path'
|
|
8
|
+
import process from 'node:process'
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
|
|
11
|
+
const cli = join(dirname(fileURLToPath(import.meta.url)), 'nuxt-cli.mjs')
|
|
12
|
+
const result = spawnSync(
|
|
13
|
+
process.execPath,
|
|
14
|
+
[
|
|
15
|
+
cli,
|
|
16
|
+
'prepare',
|
|
17
|
+
...process.argv.slice(2),
|
|
18
|
+
],
|
|
19
|
+
{
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
cwd: process.cwd(),
|
|
22
|
+
env: process.env,
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if (result.error) {
|
|
27
|
+
console.error(`[nuxt-prepare] ${result.error.message}`)
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
process.exit(result.status ?? 1)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open dev URL reusing an existing Chromium tab when possible (same behavior as Vite's server.open).
|
|
3
|
+
* Nuxt `dev --open` goes through listhen → macOS `open`, which always spawns a new tab.
|
|
4
|
+
*/
|
|
5
|
+
import { exec, execFile } from 'node:child_process'
|
|
6
|
+
import { dirname, join } from 'node:path'
|
|
7
|
+
import process from 'node:process'
|
|
8
|
+
import { fileURLToPath } from 'node:url'
|
|
9
|
+
import { promisify } from 'node:util'
|
|
10
|
+
|
|
11
|
+
const execAsync = promisify(exec)
|
|
12
|
+
const execFileAsync = promisify(execFile)
|
|
13
|
+
|
|
14
|
+
const openChromiumScriptDir = dirname(fileURLToPath(import.meta.url))
|
|
15
|
+
|
|
16
|
+
const supportedChromiumBrowsers = [
|
|
17
|
+
'Google Chrome Canary',
|
|
18
|
+
'Google Chrome Dev',
|
|
19
|
+
'Google Chrome Beta',
|
|
20
|
+
'Google Chrome',
|
|
21
|
+
'Microsoft Edge',
|
|
22
|
+
'Brave Browser',
|
|
23
|
+
'Vivaldi',
|
|
24
|
+
'Chromium',
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
const chromiumBrowserAliases: Record<string, string> = {
|
|
28
|
+
'chrome': 'Google Chrome',
|
|
29
|
+
'google chrome': 'Google Chrome',
|
|
30
|
+
'edge': 'Microsoft Edge',
|
|
31
|
+
'microsoft edge': 'Microsoft Edge',
|
|
32
|
+
'brave': 'Brave Browser',
|
|
33
|
+
'brave browser': 'Brave Browser',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** openChrome.js uses `tab.url().includes(lookupUrl)` — drop trailing slash so paths match. */
|
|
37
|
+
export function normalizeDevOpenUrl(url: string): string {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = new URL(url)
|
|
40
|
+
if (parsed.pathname.length > 1) {
|
|
41
|
+
parsed.pathname = parsed.pathname.replace(/\/$/, '')
|
|
42
|
+
} else if (!parsed.search && !parsed.hash) {
|
|
43
|
+
// Origin-only URLs (e.g. http://localhost:3000/) — drop trailing slash for tab reuse.
|
|
44
|
+
return parsed.href.replace(/\/$/, '')
|
|
45
|
+
}
|
|
46
|
+
return parsed.href
|
|
47
|
+
} catch {
|
|
48
|
+
return url.replace(/\/$/, '')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function resolveOpenedChromiumBrowser(
|
|
53
|
+
browser: string | undefined,
|
|
54
|
+
psStdout: string,
|
|
55
|
+
): string | undefined {
|
|
56
|
+
if (browser) {
|
|
57
|
+
const normalized = browser.toLowerCase().trim()
|
|
58
|
+
if (Object.hasOwn(chromiumBrowserAliases, normalized))
|
|
59
|
+
return chromiumBrowserAliases[normalized]
|
|
60
|
+
const match = supportedChromiumBrowsers.find(name => name.toLowerCase() === normalized)
|
|
61
|
+
// Explicit non-Chromium preference (e.g. Safari) — skip tab reuse, fall through to `open`.
|
|
62
|
+
return match
|
|
63
|
+
}
|
|
64
|
+
return supportedChromiumBrowsers.find(name => psStdout.includes(name))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let devBrowserOpenScheduledThisProcess = false
|
|
68
|
+
|
|
69
|
+
/** Skip repeat opens when Nuxt re-fires `listen` on dev restart (same Node process). */
|
|
70
|
+
export function scheduleOpenDevBrowserOnce(url: string, logPrefix = '[nuxt-base]'): void {
|
|
71
|
+
if (devBrowserOpenScheduledThisProcess)
|
|
72
|
+
return
|
|
73
|
+
devBrowserOpenScheduledThisProcess = true
|
|
74
|
+
void openDevBrowser(url).catch((err) => {
|
|
75
|
+
console.warn(`${logPrefix} Failed to open browser:`, err)
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function openDevBrowser(url: string): Promise<void> {
|
|
80
|
+
if (process.env.NUXT_DEV_OPEN === 'false')
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
const browser = process.env.BROWSER
|
|
84
|
+
if (browser?.toLowerCase() === 'none')
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
const lookupUrl = normalizeDevOpenUrl(url)
|
|
88
|
+
|
|
89
|
+
if (process.platform === 'darwin') {
|
|
90
|
+
try {
|
|
91
|
+
const psStdout = browser
|
|
92
|
+
? ''
|
|
93
|
+
: (await execAsync('ps cax')).stdout
|
|
94
|
+
const openedBrowser = resolveOpenedChromiumBrowser(browser, psStdout)
|
|
95
|
+
if (openedBrowser) {
|
|
96
|
+
await execFileAsync(
|
|
97
|
+
'osascript',
|
|
98
|
+
[
|
|
99
|
+
join(openChromiumScriptDir, 'openChromiumWithoutReload.js'),
|
|
100
|
+
lookupUrl,
|
|
101
|
+
openedBrowser,
|
|
102
|
+
],
|
|
103
|
+
)
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// fall through to generic open
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type OpenFn = (_target: string, _options?: { app?: { name: string } }) => Promise<unknown>
|
|
112
|
+
const { default: open } = await import('open') as { default: OpenFn }
|
|
113
|
+
await open(lookupUrl, browser
|
|
114
|
+
? {
|
|
115
|
+
app: { name: browser },
|
|
116
|
+
}
|
|
117
|
+
: undefined)
|
|
118
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Vite openChrome.js behavior without targetTab.reload().
|
|
3
|
+
* Nuxt re-fires `listen` on dev restart; reload would full-page refresh (not HMR).
|
|
4
|
+
*
|
|
5
|
+
* Based on Vite packages/vite/bin/openChrome.js (MIT).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/* global Application */
|
|
9
|
+
|
|
10
|
+
// osascript JXA invokes `run` with CLI args (see dev/open-browser.ts).
|
|
11
|
+
// eslint-disable-next-line no-unused-vars, unused-imports/no-unused-vars -- JXA entry point
|
|
12
|
+
function run(argv) {
|
|
13
|
+
const urlToOpen = argv[0]
|
|
14
|
+
const programName = argv[1] ?? 'Google Chrome'
|
|
15
|
+
|
|
16
|
+
const app = Application(programName)
|
|
17
|
+
|
|
18
|
+
if (app.windows.length === 0)
|
|
19
|
+
app.Window().make()
|
|
20
|
+
|
|
21
|
+
const found = lookupTabWithUrl(urlToOpen, app)
|
|
22
|
+
if (found) {
|
|
23
|
+
found.targetWindow.activeTabIndex = found.targetTabIndex
|
|
24
|
+
found.targetWindow.index = 1
|
|
25
|
+
app.activate()
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const emptyTabFound = lookupTabWithUrl('://newtab/', app)
|
|
30
|
+
if (emptyTabFound) {
|
|
31
|
+
emptyTabFound.targetWindow.activeTabIndex = emptyTabFound.targetTabIndex
|
|
32
|
+
emptyTabFound.targetTab.url = urlToOpen
|
|
33
|
+
app.activate()
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const firstWindow = app.windows[0]
|
|
38
|
+
firstWindow.tabs.push(app.Tab({ url: urlToOpen }))
|
|
39
|
+
app.activate()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function lookupTabWithUrl(lookupUrl, app) {
|
|
43
|
+
const windows = app.windows()
|
|
44
|
+
for (const window of windows) {
|
|
45
|
+
for (const [tabIndex, tab] of window.tabs().entries()) {
|
|
46
|
+
const tabUrl = tab.url()
|
|
47
|
+
if (tabUrl && tabUrl.includes(lookupUrl)) {
|
|
48
|
+
return {
|
|
49
|
+
targetTab: tab,
|
|
50
|
+
targetTabIndex: tabIndex + 1,
|
|
51
|
+
targetWindow: window,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dev/ports.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Canonical local dev HTTP ports — 70xx range so apps can run in parallel. */
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
|
|
4
|
+
// Port 7003 is reserved for the first site copied from templates/fugue-content-site (not assigned here).
|
|
5
|
+
export const devPorts = {
|
|
6
|
+
developerDocs: 7005,
|
|
7
|
+
pickup: 7006,
|
|
8
|
+
themePlayground: 7010,
|
|
9
|
+
} as const
|
|
10
|
+
|
|
11
|
+
/** Workspace starter templates — 80xx range, separate from {@link devPorts} apps. */
|
|
12
|
+
export const templateDevPorts = {
|
|
13
|
+
fugueContentSite: 8001,
|
|
14
|
+
docusSite: 8002,
|
|
15
|
+
} as const
|
|
16
|
+
|
|
17
|
+
export function devServerOptions(port: number) {
|
|
18
|
+
return {
|
|
19
|
+
port,
|
|
20
|
+
host: 'localhost',
|
|
21
|
+
strictPort: true,
|
|
22
|
+
url: `http://localhost:${port}`,
|
|
23
|
+
} as const
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Vite dev-server opts. The HTTP port stays on `devServer`.
|
|
28
|
+
* Nuxt attaches the HMR websocket to that same server — do not set
|
|
29
|
+
* `hmr.port` or `hmr.clientPort` to a different port.
|
|
30
|
+
*/
|
|
31
|
+
export function devViteServerOptions() {
|
|
32
|
+
return {
|
|
33
|
+
host: 'localhost',
|
|
34
|
+
strictPort: true,
|
|
35
|
+
hmr: { host: 'localhost' },
|
|
36
|
+
} as const
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Vite server opts for workspace templates — @see {@link devViteServerOptions}.
|
|
41
|
+
*/
|
|
42
|
+
export function templateViteServerOptions() {
|
|
43
|
+
return devViteServerOptions()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Drop a separate HMR port so the client uses the dev server Nuxt already
|
|
48
|
+
* attached the websocket to. Leaves `hmr: false` alone.
|
|
49
|
+
*/
|
|
50
|
+
export function pinDevServerHmr(server: { hmr?: Record<string, unknown> | boolean }) {
|
|
51
|
+
if (server.hmr === false)
|
|
52
|
+
return
|
|
53
|
+
const prev = typeof server.hmr === 'object' && server.hmr !== null
|
|
54
|
+
? server.hmr
|
|
55
|
+
: {}
|
|
56
|
+
const { port: _port, clientPort: _clientPort, ...rest } = prev
|
|
57
|
+
server.hmr = {
|
|
58
|
+
...rest,
|
|
59
|
+
host: 'localhost',
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Env vars so Nuxt/Vite resolve the same port as {@link devServerOptions}. */
|
|
64
|
+
export function devPortEnv(port: number): Record<string, string> {
|
|
65
|
+
const value = String(port)
|
|
66
|
+
return {
|
|
67
|
+
PORT: value,
|
|
68
|
+
NUXT_PORT: value,
|
|
69
|
+
NITRO_PORT: value,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Local HTTP port for Fugue Content consumer apps and templates.
|
|
75
|
+
* Each app `.env` sets `SITE_DEV_PORT` (or `PORT`); value differs per app, name stays generic.
|
|
76
|
+
*/
|
|
77
|
+
function parseDevPort(raw: string | undefined): number | undefined {
|
|
78
|
+
if (raw === undefined || raw.trim() === '')
|
|
79
|
+
return undefined
|
|
80
|
+
const trimmed = raw.trim()
|
|
81
|
+
if (!/^\d+$/.test(trimmed))
|
|
82
|
+
return undefined
|
|
83
|
+
const port = Number(trimmed)
|
|
84
|
+
if (port < 1 || port > 65535)
|
|
85
|
+
return undefined
|
|
86
|
+
return port
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function siteDevPort(fallback: number): number {
|
|
90
|
+
const fromSite = parseDevPort(process.env.SITE_DEV_PORT)
|
|
91
|
+
if (fromSite !== undefined)
|
|
92
|
+
return fromSite
|
|
93
|
+
const fromPort = parseDevPort(process.env.PORT)
|
|
94
|
+
if (fromPort !== undefined)
|
|
95
|
+
return fromPort
|
|
96
|
+
return fallback
|
|
97
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Nuxt } from 'nuxt/schema'
|
|
2
|
+
import { scheduleOpenDevBrowserOnce } from './open-browser'
|
|
3
|
+
|
|
4
|
+
const installedHookKey = Symbol.for('altafusion.reuseDevBrowserOnListen')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Prefer configured devServer.url — the listen hook can fire before the final port is reflected in listener.url.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveDevOpenUrl(nuxt: Nuxt, listener: { url: string }): string {
|
|
10
|
+
const fromConfig = nuxt.options.devServer?.url
|
|
11
|
+
if (typeof fromConfig === 'string' && fromConfig.length > 0)
|
|
12
|
+
return fromConfig
|
|
13
|
+
return listener.url
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Reuse the active Chromium tab (Vite-style) instead of Nuxt `--open` → listhen → macOS `open`. */
|
|
17
|
+
export function reuseDevBrowserOnListen(_options: unknown, nuxt: Nuxt) {
|
|
18
|
+
if (!nuxt.options.dev)
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
const options = nuxt.options as unknown as Record<PropertyKey, unknown>
|
|
22
|
+
if (options[installedHookKey])
|
|
23
|
+
return
|
|
24
|
+
options[installedHookKey] = true
|
|
25
|
+
|
|
26
|
+
nuxt.hook('listen', (_server, listener: { url: string }) => {
|
|
27
|
+
scheduleOpenDevBrowserOnce(resolveDevOpenUrl(nuxt, listener))
|
|
28
|
+
})
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { createPackageEslintConfig } from '@altafusion/eslint-config'
|
|
3
|
+
|
|
4
|
+
export default createPackageEslintConfig({
|
|
5
|
+
rules: {
|
|
6
|
+
'import/no-default-export': 'off',
|
|
7
|
+
'no-unused-vars': [
|
|
8
|
+
'error',
|
|
9
|
+
{
|
|
10
|
+
varsIgnorePattern: '^_',
|
|
11
|
+
argsIgnorePattern: '^_',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
'no-console': 'warn',
|
|
15
|
+
},
|
|
16
|
+
})
|
package/index.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Nuxt configuration for Altafusion packages
|
|
3
|
+
* Layer provides modules; this exports createAppConfig for app-specific overrides
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { NuxtConfig } from 'nuxt/schema'
|
|
7
|
+
import { defu } from 'defu'
|
|
8
|
+
import { mergeConfig } from 'vite'
|
|
9
|
+
import { pinDevServerHmr } from './dev/ports'
|
|
10
|
+
import { reuseDevBrowserOnListen } from './dev/reuse-dev-browser'
|
|
11
|
+
import { buildNuxtUIConfig } from './lib/nuxt-ui-theme'
|
|
12
|
+
import {
|
|
13
|
+
isNuxtDevtoolsEnabled,
|
|
14
|
+
sharedDevtoolsConfig,
|
|
15
|
+
sharedModuleConfig,
|
|
16
|
+
sharedRuntimeConfig,
|
|
17
|
+
} from './modules'
|
|
18
|
+
import { sharedTypeScriptConfig } from './typescript'
|
|
19
|
+
|
|
20
|
+
export { buildNuxtUIConfig, mirrorAppUiTheme, mirrorAppUiThemeFromPalette, nuxtUIOptionsFromPalette, siteConfigThemeFromPalette } from './lib/nuxt-ui-theme'
|
|
21
|
+
export type { NuxtUiSemanticColors, NuxtUiThemeInput, SitePalette } from './lib/nuxt-ui-theme'
|
|
22
|
+
export {
|
|
23
|
+
isNuxtDevtoolsEnabled,
|
|
24
|
+
sharedDevtoolsConfig,
|
|
25
|
+
sharedModuleConfig,
|
|
26
|
+
sharedModules,
|
|
27
|
+
sharedRuntimeConfig,
|
|
28
|
+
} from './modules'
|
|
29
|
+
export { sharedTSConfig, sharedTypeScriptConfig } from './typescript'
|
|
30
|
+
|
|
31
|
+
const STYLESHEET_EXT = /\.(?:css|scss|sass|less|styl(?:us)?)(?:[?#].*)?$/i
|
|
32
|
+
|
|
33
|
+
/** Resolve app-local or explicit theme CSS path for `createAppConfig({ theme })`. */
|
|
34
|
+
export function resolveThemeCss(theme: string): string {
|
|
35
|
+
if (theme.startsWith('~') || theme.startsWith('@') || theme.startsWith('.') || theme.includes('/')) {
|
|
36
|
+
return STYLESHEET_EXT.test(theme)
|
|
37
|
+
? theme
|
|
38
|
+
: `${theme}.css`
|
|
39
|
+
}
|
|
40
|
+
return `~/assets/css/themes/${theme}-theme.css`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Base Nuxt configuration (for createAppConfig merge)
|
|
45
|
+
* Modules come from the layer — do not duplicate here
|
|
46
|
+
*/
|
|
47
|
+
export const baseNuxtConfig = {
|
|
48
|
+
modules: [] as string[],
|
|
49
|
+
...sharedModuleConfig,
|
|
50
|
+
typescript: sharedTypeScriptConfig,
|
|
51
|
+
runtimeConfig: sharedRuntimeConfig,
|
|
52
|
+
devtools: sharedDevtoolsConfig,
|
|
53
|
+
compatibilityDate: '2026-05-22' as const,
|
|
54
|
+
css: [] as string[],
|
|
55
|
+
vite: {
|
|
56
|
+
define: { __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false' },
|
|
57
|
+
},
|
|
58
|
+
nitro: {
|
|
59
|
+
routeRules: {
|
|
60
|
+
'/sw.js': {
|
|
61
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
62
|
+
},
|
|
63
|
+
'/workbox-*.js': {
|
|
64
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create app-specific configuration by merging base with overrides
|
|
72
|
+
*/
|
|
73
|
+
export function createAppConfig(
|
|
74
|
+
overrides: Record<string, unknown> = {},
|
|
75
|
+
options: {
|
|
76
|
+
theme?: string
|
|
77
|
+
enableNuxtUI?: boolean
|
|
78
|
+
nuxtUIOptions?: Record<string, unknown>
|
|
79
|
+
additionalCSS?: string[]
|
|
80
|
+
/** Dark canvas when `data-theme="dark"` — `gray` (default) or `black`. */
|
|
81
|
+
darkCanvas?: 'gray' | 'black'
|
|
82
|
+
} = {},
|
|
83
|
+
): NuxtConfig {
|
|
84
|
+
const {
|
|
85
|
+
theme,
|
|
86
|
+
enableNuxtUI = false,
|
|
87
|
+
nuxtUIOptions = {},
|
|
88
|
+
additionalCSS = [],
|
|
89
|
+
darkCanvas = 'gray',
|
|
90
|
+
} = options
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
vite: viteOverride,
|
|
94
|
+
hooks: userHooksRaw,
|
|
95
|
+
nitro: nitroOverride,
|
|
96
|
+
devtools: devtoolsOverride,
|
|
97
|
+
ui: uiOverride,
|
|
98
|
+
...restOverrides
|
|
99
|
+
} = overrides
|
|
100
|
+
const userHooks = (userHooksRaw as Record<string, unknown> | undefined) ?? {}
|
|
101
|
+
const userViteExtendRaw = userHooks['vite:extendConfig']
|
|
102
|
+
// eslint-disable-next-line no-unused-vars -- `this` types the hook call context
|
|
103
|
+
type ViteExtendConfigHook = (this: unknown, _config: Record<string, unknown>, _context: unknown) => unknown
|
|
104
|
+
const userViteExtendHooks: ViteExtendConfigHook[] = []
|
|
105
|
+
if (typeof userViteExtendRaw === 'function') {
|
|
106
|
+
userViteExtendHooks.push(userViteExtendRaw as ViteExtendConfigHook)
|
|
107
|
+
} else if (Array.isArray(userViteExtendRaw)) {
|
|
108
|
+
for (const hook of userViteExtendRaw) {
|
|
109
|
+
if (typeof hook === 'function')
|
|
110
|
+
userViteExtendHooks.push(hook as ViteExtendConfigHook)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const { 'vite:extendConfig': _userViteExtendIgnored, ...restUserHooks } = userHooks
|
|
114
|
+
|
|
115
|
+
const mergedHooks: Record<string, unknown> = { ...restUserHooks }
|
|
116
|
+
mergedHooks['vite:extendConfig'] = async function (this: unknown, viteInlineConfig: Record<string, unknown>, context: unknown) {
|
|
117
|
+
for (const hook of userViteExtendHooks)
|
|
118
|
+
await hook.call(this, viteInlineConfig, context)
|
|
119
|
+
const server = (viteInlineConfig.server ??= {}) as {
|
|
120
|
+
hmr?: Record<string, unknown> | boolean
|
|
121
|
+
}
|
|
122
|
+
pinDevServerHmr(server)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const cssFiles = [
|
|
126
|
+
...(theme
|
|
127
|
+
? [
|
|
128
|
+
resolveThemeCss(theme),
|
|
129
|
+
]
|
|
130
|
+
: []),
|
|
131
|
+
...additionalCSS,
|
|
132
|
+
...((overrides.css as string[]) || []),
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
const overrideModules = (overrides.modules ?? []) as NonNullable<NuxtConfig['modules']>
|
|
136
|
+
const modules: NuxtConfig['modules'] = [
|
|
137
|
+
reuseDevBrowserOnListen,
|
|
138
|
+
...overrideModules,
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
const baseNitro = baseNuxtConfig.nitro ?? {}
|
|
142
|
+
const overrideNitro
|
|
143
|
+
= typeof nitroOverride === 'object' && nitroOverride !== null
|
|
144
|
+
? nitroOverride
|
|
145
|
+
: {}
|
|
146
|
+
const mergedNitro = {
|
|
147
|
+
...baseNitro,
|
|
148
|
+
...overrideNitro,
|
|
149
|
+
routeRules: {
|
|
150
|
+
...(baseNitro.routeRules ?? {}),
|
|
151
|
+
...((overrideNitro as { routeRules?: Record<string, unknown> }).routeRules ?? {}),
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const mergedUi = enableNuxtUI
|
|
156
|
+
? buildNuxtUIConfig({
|
|
157
|
+
primary: 'blue',
|
|
158
|
+
gray: 'slate',
|
|
159
|
+
...nuxtUIOptions,
|
|
160
|
+
...(typeof uiOverride === 'object' && uiOverride
|
|
161
|
+
? uiOverride
|
|
162
|
+
: {}),
|
|
163
|
+
})
|
|
164
|
+
: typeof uiOverride === 'object' && uiOverride
|
|
165
|
+
? uiOverride
|
|
166
|
+
: undefined
|
|
167
|
+
|
|
168
|
+
const hasExplicitDevtoolsEnabled = typeof devtoolsOverride === 'object'
|
|
169
|
+
&& devtoolsOverride !== null
|
|
170
|
+
&& 'enabled' in devtoolsOverride
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
// Nested defaults (e.g. eslint.config.stylistic) must survive app overrides.
|
|
174
|
+
...defu(restOverrides as Record<string, unknown>, baseNuxtConfig as Record<string, unknown>),
|
|
175
|
+
vite: mergeConfig(
|
|
176
|
+
baseNuxtConfig.vite,
|
|
177
|
+
(viteOverride ?? {}) as Record<string, unknown>,
|
|
178
|
+
),
|
|
179
|
+
nitro: mergedNitro,
|
|
180
|
+
css: cssFiles,
|
|
181
|
+
modules,
|
|
182
|
+
// Per-app Nuxt UI token overrides (@nuxt/ui module lives on @altafusion/fugue-nuxt-ui).
|
|
183
|
+
...(mergedUi !== undefined
|
|
184
|
+
? { ui: mergedUi }
|
|
185
|
+
: {}),
|
|
186
|
+
runtimeConfig: {
|
|
187
|
+
...baseNuxtConfig.runtimeConfig,
|
|
188
|
+
...(overrides.runtimeConfig as object),
|
|
189
|
+
public: {
|
|
190
|
+
...baseNuxtConfig.runtimeConfig.public,
|
|
191
|
+
theme: theme || 'default',
|
|
192
|
+
hasNuxtUI: enableNuxtUI,
|
|
193
|
+
darkCanvas,
|
|
194
|
+
...((overrides.runtimeConfig as { public?: object })?.public || {}),
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
hooks: mergedHooks,
|
|
198
|
+
// App-level — wins over layers that hardcode DevTools on (e.g. Docus).
|
|
199
|
+
// Explicit devtools boolean or enabled wins; otherwise NUXT_DEVTOOLS.
|
|
200
|
+
devtools: {
|
|
201
|
+
...(typeof devtoolsOverride === 'object' && devtoolsOverride
|
|
202
|
+
? devtoolsOverride
|
|
203
|
+
: {}),
|
|
204
|
+
enabled: typeof devtoolsOverride === 'boolean'
|
|
205
|
+
? devtoolsOverride
|
|
206
|
+
: hasExplicitDevtoolsEnabled
|
|
207
|
+
? Boolean((devtoolsOverride as { enabled: unknown }).enabled)
|
|
208
|
+
: isNuxtDevtoolsEnabled(),
|
|
209
|
+
},
|
|
210
|
+
} as NuxtConfig
|
|
211
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nuxt UI 4 theme config — maps legacy flat `primary` / `gray` to `ui.colors`.
|
|
3
|
+
*
|
|
4
|
+
* @nuxt/ui defaults `colors.primary` to `green`; flat keys on `ui` do not override it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Nuxt UI semantic color slots → Tailwind scale names. */
|
|
8
|
+
export interface NuxtUiSemanticColors {
|
|
9
|
+
primary?: string
|
|
10
|
+
secondary?: string
|
|
11
|
+
success?: string
|
|
12
|
+
info?: string
|
|
13
|
+
warning?: string
|
|
14
|
+
error?: string
|
|
15
|
+
neutral?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface NuxtUiThemeInput {
|
|
19
|
+
primary?: string
|
|
20
|
+
/** Legacy name — maps to Nuxt UI `colors.neutral`. */
|
|
21
|
+
gray?: string
|
|
22
|
+
colors?: NuxtUiSemanticColors
|
|
23
|
+
notifications?: { position?: string, [key: string]: unknown }
|
|
24
|
+
[key: string]: unknown
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Named palette — one object ties Nuxt UI semantic colors to app theme CSS.
|
|
29
|
+
* App-local first (`apps/<site>/palette.ts`); promote shared palettes when reused.
|
|
30
|
+
*/
|
|
31
|
+
export interface SitePalette {
|
|
32
|
+
id: string
|
|
33
|
+
/** App theme slug — loads `{theme}-theme.css` via createAppConfig */
|
|
34
|
+
theme: string
|
|
35
|
+
nuxtUI: {
|
|
36
|
+
colors: NuxtUiSemanticColors
|
|
37
|
+
notifications?: { position?: string, [key: string]: unknown }
|
|
38
|
+
}
|
|
39
|
+
/** Dark canvas personality when `data-theme="dark"` — `gray` (default) or `black`. */
|
|
40
|
+
darkCanvas?: 'gray' | 'black'
|
|
41
|
+
/** Brand & Surfaces token file (loaded via `{theme}-theme.css` @import chain) */
|
|
42
|
+
tokens?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const DEFAULT_SEMANTIC_COLORS: Required<NuxtUiSemanticColors> = {
|
|
46
|
+
primary: 'blue',
|
|
47
|
+
secondary: 'blue',
|
|
48
|
+
success: 'green',
|
|
49
|
+
info: 'blue',
|
|
50
|
+
warning: 'yellow',
|
|
51
|
+
error: 'red',
|
|
52
|
+
neutral: 'slate',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Build `ui` module config for `createAppConfig` / `nuxt.config`. */
|
|
56
|
+
export function buildNuxtUIConfig(options: NuxtUiThemeInput = {}) {
|
|
57
|
+
const {
|
|
58
|
+
primary,
|
|
59
|
+
gray,
|
|
60
|
+
colors: colorsOption,
|
|
61
|
+
notifications,
|
|
62
|
+
main,
|
|
63
|
+
...rest
|
|
64
|
+
} = options
|
|
65
|
+
|
|
66
|
+
const fromFlat: Record<string, string> = {}
|
|
67
|
+
if (primary !== undefined)
|
|
68
|
+
fromFlat.primary = primary
|
|
69
|
+
if (gray !== undefined)
|
|
70
|
+
fromFlat.neutral = gray
|
|
71
|
+
|
|
72
|
+
const colors = {
|
|
73
|
+
...DEFAULT_SEMANTIC_COLORS,
|
|
74
|
+
...fromFlat,
|
|
75
|
+
...(colorsOption ?? {}),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
colors,
|
|
80
|
+
notifications: {
|
|
81
|
+
position: 'top-0 bottom-auto',
|
|
82
|
+
...(notifications ?? {}),
|
|
83
|
+
},
|
|
84
|
+
...rest,
|
|
85
|
+
/**
|
|
86
|
+
* Override Nuxt UI `main` min-height (`calc(100vh-header)`). With a real
|
|
87
|
+
* header + footer sibling that always overflows the viewport by ~footer
|
|
88
|
+
* height. Apps can still override via `main` / `app.config`.
|
|
89
|
+
*/
|
|
90
|
+
main: {
|
|
91
|
+
base: 'flex-1 w-full min-h-0',
|
|
92
|
+
...(typeof main === 'object' && main
|
|
93
|
+
? main
|
|
94
|
+
: {}),
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Same shape for `app/app.config.ts` → keep in sync with `siteConfigTheme.nuxtUIOptions`. */
|
|
100
|
+
export function mirrorAppUiTheme(options: NuxtUiThemeInput = {}) {
|
|
101
|
+
return buildNuxtUIConfig(options)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Extract `nuxtUIOptions` for `siteConfigTheme` from a named palette. */
|
|
105
|
+
export function nuxtUIOptionsFromPalette(palette: SitePalette): NuxtUiThemeInput {
|
|
106
|
+
return {
|
|
107
|
+
colors: palette.nuxtUI.colors,
|
|
108
|
+
...(palette.nuxtUI.notifications
|
|
109
|
+
? { notifications: palette.nuxtUI.notifications }
|
|
110
|
+
: {}),
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Build `siteConfigTheme` for `defineFugueContentSite(..., siteConfigTheme)`. */
|
|
115
|
+
export function siteConfigThemeFromPalette(
|
|
116
|
+
palette: SitePalette,
|
|
117
|
+
extra: { enableNuxtUI?: boolean } = {},
|
|
118
|
+
) {
|
|
119
|
+
return {
|
|
120
|
+
theme: palette.theme,
|
|
121
|
+
enableNuxtUI: extra.enableNuxtUI ?? true,
|
|
122
|
+
nuxtUIOptions: nuxtUIOptionsFromPalette(palette),
|
|
123
|
+
darkCanvas: palette.darkCanvas ?? 'gray',
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Mirror palette Nuxt UI colors in `app/app.config.ts`. */
|
|
128
|
+
export function mirrorAppUiThemeFromPalette(palette: SitePalette) {
|
|
129
|
+
return buildNuxtUIConfig(nuxtUIOptionsFromPalette(palette))
|
|
130
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Nuxt } from 'nuxt/schema'
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import process from 'node:process'
|
|
5
|
+
import { defineNuxtModule } from '@nuxt/kit'
|
|
6
|
+
|
|
7
|
+
interface PrepareTypesRefs {
|
|
8
|
+
types?: string
|
|
9
|
+
path?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface TsConfigLike {
|
|
13
|
+
include?: string[]
|
|
14
|
+
exclude?: string[]
|
|
15
|
+
compilerOptions?: Record<string, unknown>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Docus vendor typecheck guards:
|
|
20
|
+
* - `@nuxt/kit` emits `/// <reference types="docus" />` for every `modules`/`_modules` package id.
|
|
21
|
+
* Docus has no `types` field, so that resolves to `main` (`nuxt.config.ts`) and breaks `vue-tsc -b`.
|
|
22
|
+
* - Drop those refs; layer `index.d.ts` path references still provide real Docus typings.
|
|
23
|
+
* - Strip `nuxt.config.*` from generated TS `include` lists so the config file is not pulled in via glob.
|
|
24
|
+
*/
|
|
25
|
+
const DOCUS_VENDOR_SOURCE_EXCLUDES = [
|
|
26
|
+
'**/node_modules/**/docus/app/**',
|
|
27
|
+
'**/node_modules/**/docus/modules/**',
|
|
28
|
+
'**/node_modules/**/docus/server/**',
|
|
29
|
+
] as const
|
|
30
|
+
|
|
31
|
+
function docusVendorPnpmExclude(pattern: (typeof DOCUS_VENDOR_SOURCE_EXCLUDES)[number]) {
|
|
32
|
+
return pattern.replace('**/node_modules/**/docus/', '**/node_modules/.pnpm/docus@*/node_modules/docus/')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Merged into generated `prepare:types` projects (npm + pnpm layouts). */
|
|
36
|
+
export const DOCUS_VENDOR_TYPECHECK_EXCLUDES = [
|
|
37
|
+
...DOCUS_VENDOR_SOURCE_EXCLUDES,
|
|
38
|
+
...DOCUS_VENDOR_SOURCE_EXCLUDES.map(docusVendorPnpmExclude),
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
export function isDocusVendorInclude(entry: string): boolean {
|
|
42
|
+
return entry.includes('/docus/nuxt.config')
|
|
43
|
+
|| entry.includes('/docus/app/')
|
|
44
|
+
|| entry.includes('/docus/modules/')
|
|
45
|
+
|| entry.includes('/docus/server/')
|
|
46
|
+
|| entry.includes('/node_modules/docus/')
|
|
47
|
+
|| entry.includes('/node_modules/.pnpm/docus@')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function stripDocusVendorIncludes(cfg: TsConfigLike | undefined): void {
|
|
51
|
+
if (cfg == null || !Array.isArray(cfg.include))
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
cfg.include = cfg.include.filter(
|
|
55
|
+
(entry: string) => typeof entry === 'string' && !isDocusVendorInclude(entry),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function mergeDocusVendorExcludes(cfg: TsConfigLike | undefined): void {
|
|
60
|
+
if (cfg == null)
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
cfg.exclude = [
|
|
64
|
+
...new Set([
|
|
65
|
+
...(cfg.exclude ?? []),
|
|
66
|
+
...DOCUS_VENDOR_TYPECHECK_EXCLUDES,
|
|
67
|
+
]),
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function stripDocusTypeRefs(refs: PrepareTypesRefs[] | undefined): void {
|
|
72
|
+
if (refs == null)
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
const kept = refs.filter(r => r.types !== 'docus')
|
|
76
|
+
refs.length = 0
|
|
77
|
+
refs.push(...kept)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isTsConfigLike(value: unknown): value is TsConfigLike {
|
|
81
|
+
return value != null
|
|
82
|
+
&& typeof value === 'object'
|
|
83
|
+
&& ('include' in value || 'exclude' in value || 'compilerOptions' in value)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function applyDocusVendorTypecheckGuards(payload: Record<string, unknown>): void {
|
|
87
|
+
for (const value of Object.values(payload)) {
|
|
88
|
+
if (isTsConfigLike(value)) {
|
|
89
|
+
stripDocusVendorIncludes(value)
|
|
90
|
+
mergeDocusVendorExcludes(value)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function omitDocusPackageConfigFromNodeTs(_options: unknown, nuxt: Nuxt) {
|
|
96
|
+
const patchTsConfigFile = (path: string) => {
|
|
97
|
+
if (!existsSync(path))
|
|
98
|
+
return
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const cfg = JSON.parse(readFileSync(path, 'utf8')) as TsConfigLike
|
|
102
|
+
stripDocusVendorIncludes(cfg)
|
|
103
|
+
mergeDocusVendorExcludes(cfg)
|
|
104
|
+
writeFileSync(path, `${JSON.stringify(cfg, null, 2)}\n`)
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.warn(`[docus-typecheck] Failed to patch ${path}:`, err)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const patchGeneratedTsConfigs = () => {
|
|
111
|
+
for (const name of [
|
|
112
|
+
'tsconfig.json',
|
|
113
|
+
'tsconfig.app.json',
|
|
114
|
+
'tsconfig.node.json',
|
|
115
|
+
'tsconfig.shared.json',
|
|
116
|
+
'tsconfig.server.json',
|
|
117
|
+
])
|
|
118
|
+
patchTsConfigFile(join(nuxt.options.buildDir, name))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
nuxt.hook('prepare:types', (payload) => {
|
|
122
|
+
const enableDevTsImports = (cfg: TsConfigLike | undefined) => {
|
|
123
|
+
if (cfg?.compilerOptions == null)
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
cfg.compilerOptions.allowImportingTsExtensions = true
|
|
127
|
+
cfg.compilerOptions.noEmit = true
|
|
128
|
+
}
|
|
129
|
+
enableDevTsImports(payload.nodeTsConfig)
|
|
130
|
+
|
|
131
|
+
applyDocusVendorTypecheckGuards(payload as Record<string, unknown>)
|
|
132
|
+
stripDocusTypeRefs(payload.references)
|
|
133
|
+
stripDocusTypeRefs(payload.nodeReferences)
|
|
134
|
+
stripDocusTypeRefs(payload.sharedReferences)
|
|
135
|
+
})
|
|
136
|
+
nuxt.hook('nitro:prepare:types', (payload) => {
|
|
137
|
+
applyDocusVendorTypecheckGuards(payload as Record<string, unknown>)
|
|
138
|
+
})
|
|
139
|
+
nuxt.hook('close', () => {
|
|
140
|
+
patchGeneratedTsConfigs()
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
process.once('beforeExit', () => {
|
|
144
|
+
patchGeneratedTsConfigs()
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default defineNuxtModule({
|
|
149
|
+
meta: {
|
|
150
|
+
name: '@altafusion/nuxt-base/docus-typecheck',
|
|
151
|
+
enforce: 'pre',
|
|
152
|
+
},
|
|
153
|
+
setup(_options, nuxt) {
|
|
154
|
+
omitDocusPackageConfigFromNodeTs(_options, nuxt)
|
|
155
|
+
},
|
|
156
|
+
})
|
package/modules.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Nuxt modules configuration
|
|
3
|
+
* Used by the layer and createAppConfig.
|
|
4
|
+
*
|
|
5
|
+
* ESLint stylistic defaults live in `sharedModuleConfig` below (sourced from `@altafusion/eslint-config`).
|
|
6
|
+
* The `@nuxt/eslint` module is registered on `@altafusion/fugue-nuxt-ui` / `@altafusion/fugue-theme`
|
|
7
|
+
* (not here): it only emits `.nuxt/eslint.config.mjs` for a consuming app when registered on a layer the app
|
|
8
|
+
* directly extends — merged modules from `extends: ['@altafusion/nuxt-base']` do not run that hook in the app root.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import process from 'node:process'
|
|
12
|
+
import { sharedStylisticDefaults } from '@altafusion/eslint-config/stylistic'
|
|
13
|
+
|
|
14
|
+
export const sharedModules: string[] = []
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Nuxt DevTools toggle via env (Nuxt has no built-in flag).
|
|
18
|
+
* - unset / empty → enabled (Nuxt 4 default)
|
|
19
|
+
* - `NUXT_DEVTOOLS=false|0|off|no` → disabled
|
|
20
|
+
* - any other value → enabled
|
|
21
|
+
*/
|
|
22
|
+
export function isNuxtDevtoolsEnabled(
|
|
23
|
+
raw: string | undefined = process.env.NUXT_DEVTOOLS,
|
|
24
|
+
): boolean {
|
|
25
|
+
if (raw === undefined || raw.trim() === '')
|
|
26
|
+
return true
|
|
27
|
+
return !['false', '0', 'off', 'no'].includes(raw.trim().toLowerCase())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Lazy — read at config merge time so `.env` / dotenv is already applied. */
|
|
31
|
+
export const sharedDevtoolsConfig = {
|
|
32
|
+
get enabled() {
|
|
33
|
+
return isNuxtDevtoolsEnabled()
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const sharedModuleConfig = {
|
|
38
|
+
eslint: {
|
|
39
|
+
config: {
|
|
40
|
+
stylistic: {
|
|
41
|
+
...sharedStylisticDefaults,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const sharedRuntimeConfig = {
|
|
48
|
+
public: {},
|
|
49
|
+
}
|
package/nuxt.config.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @altafusion/nuxt-base — Nuxt layer
|
|
3
|
+
*
|
|
4
|
+
* Base layer providing shared modules and config.
|
|
5
|
+
* fugue-theme extends this; product apps extend fugue-theme and shell.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { reuseDevBrowserOnListen } from './dev/reuse-dev-browser'
|
|
9
|
+
import { sharedDevtoolsConfig, sharedModuleConfig, sharedModules, sharedRuntimeConfig } from './modules'
|
|
10
|
+
import { sharedTypeScriptConfig } from './typescript'
|
|
11
|
+
|
|
12
|
+
export default defineNuxtConfig({
|
|
13
|
+
modules: [
|
|
14
|
+
...sharedModules,
|
|
15
|
+
reuseDevBrowserOnListen,
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
...sharedModuleConfig,
|
|
19
|
+
|
|
20
|
+
typescript: sharedTypeScriptConfig,
|
|
21
|
+
|
|
22
|
+
runtimeConfig: sharedRuntimeConfig,
|
|
23
|
+
|
|
24
|
+
// Env: `NUXT_DEVTOOLS=false` to disable (see `isNuxtDevtoolsEnabled` in modules.ts).
|
|
25
|
+
devtools: sharedDevtoolsConfig,
|
|
26
|
+
|
|
27
|
+
compatibilityDate: '2026-05-22',
|
|
28
|
+
|
|
29
|
+
css: [],
|
|
30
|
+
|
|
31
|
+
vite: {
|
|
32
|
+
define: {
|
|
33
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
nitro: {
|
|
38
|
+
routeRules: {
|
|
39
|
+
'/sw.js': {
|
|
40
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
41
|
+
},
|
|
42
|
+
'/workbox-*.js': {
|
|
43
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altafusion/nuxt-base",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "Base Nuxt layer and configuration for Altafusion packages",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/altafusion/fugue/tree/main/packages-platform/nuxt-base#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/altafusion/fugue/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/altafusion/fugue.git",
|
|
14
|
+
"directory": "packages-platform/nuxt-base"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./index.ts",
|
|
21
|
+
"./modules": "./modules.ts",
|
|
22
|
+
"./typescript": "./typescript.ts",
|
|
23
|
+
"./dev/open-browser": "./dev/open-browser.ts",
|
|
24
|
+
"./dev/ports": "./dev/ports.ts",
|
|
25
|
+
"./dev/reuse-dev-browser": "./dev/reuse-dev-browser.ts",
|
|
26
|
+
"./modules/docus-typecheck": "./modules/docus-typecheck.ts",
|
|
27
|
+
"./dev/nuxt-dev": "./dev/nuxt-dev.mjs",
|
|
28
|
+
"./ui-theme": "./lib/nuxt-ui-theme.ts",
|
|
29
|
+
"./tsconfig.template.json": "./tsconfig.template.json"
|
|
30
|
+
},
|
|
31
|
+
"main": "./index.ts",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"nuxt": ">=4.0.0",
|
|
34
|
+
"vite": ">=6.0.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@altafusion/eslint-config": "0.3.0",
|
|
38
|
+
"@nuxt/kit": "^4.6.4",
|
|
39
|
+
"defu": "^6.1.7",
|
|
40
|
+
"nuxt": "^4.6.4",
|
|
41
|
+
"open": "^11.0.4",
|
|
42
|
+
"vue": "^3.5.46",
|
|
43
|
+
"vue-router": "^5.5.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^26.6.6",
|
|
47
|
+
"eslint": "^10.15.0",
|
|
48
|
+
"typescript": "^6.0.3",
|
|
49
|
+
"vitest": "^5.1.1",
|
|
50
|
+
"vue-tsc": "^3.3.14"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"**",
|
|
54
|
+
"!**/*.test.ts",
|
|
55
|
+
"!**/.nuxt",
|
|
56
|
+
"!**/.output",
|
|
57
|
+
"!**/.data",
|
|
58
|
+
"!**/coverage",
|
|
59
|
+
"!**/node_modules",
|
|
60
|
+
"!dev/reset-fugue-content-site.mjs"
|
|
61
|
+
],
|
|
62
|
+
"bin": {
|
|
63
|
+
"altafusion-nuxt-cli": "./dev/nuxt-cli.mjs",
|
|
64
|
+
"altafusion-nuxt-dev": "./dev/nuxt-dev.mjs"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"clean": "rm -rf .output .nuxt node_modules/.cache dist",
|
|
68
|
+
"lint": "eslint .",
|
|
69
|
+
"lint:fix": "eslint . --fix",
|
|
70
|
+
"test": "pnpm --dir ../.. exec vitest run --project nuxt-base"
|
|
71
|
+
}
|
|
6
72
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"// Note": "Nuxt automatically generates comprehensive TypeScript config in .nuxt/",
|
|
3
|
+
"// Purpose": "This file exists for IDE/editor integration only",
|
|
4
|
+
"references": [
|
|
5
|
+
{ "path": "./.nuxt/tsconfig.app.json" },
|
|
6
|
+
{ "path": "./.nuxt/tsconfig.server.json" },
|
|
7
|
+
{ "path": "./.nuxt/tsconfig.shared.json" },
|
|
8
|
+
{ "path": "./.nuxt/tsconfig.node.json" }
|
|
9
|
+
],
|
|
10
|
+
"files": []
|
|
11
|
+
}
|
package/typescript.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TypeScript configuration for Nuxt apps
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const sharedTypeScriptConfig = {
|
|
6
|
+
typeCheck: false,
|
|
7
|
+
strict: true,
|
|
8
|
+
// Build-time files that sit next to `nuxt.config.ts` (the site config registry, its palette) run in Node and can import
|
|
9
|
+
// `node:*`. Nuxt's node project only lists `nuxt.config.*`, so without this the IDE types them with no Node types.
|
|
10
|
+
nodeTsConfig: {
|
|
11
|
+
include: ['../site.config.ts', '../palette.ts'],
|
|
12
|
+
compilerOptions: {
|
|
13
|
+
types: ['node'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const sharedTSConfig = {
|
|
19
|
+
compilerOptions: {
|
|
20
|
+
strict: true,
|
|
21
|
+
noUnusedLocals: true,
|
|
22
|
+
noUnusedParameters: true,
|
|
23
|
+
noImplicitReturns: true,
|
|
24
|
+
},
|
|
25
|
+
}
|