@altafusion/fugue-devtools 0.6.3 → 0.6.4

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @altafusion/fugue-devtools
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 689e5a3: Tidy the Diagnostics section and list the site's `@altafusion/*` packages.
8
+
9
+ - Diagnostics is two `UCard`s like Studio Drafts: **Page** (the site: its `package.json` name and version and the commit it was built from, then url, viewport, theme, language, user agent, and a Copy Diagnostics button) and **Altafusion Packages**.
10
+ - The packages card reads each installed `@altafusion/*` package and its version from the site's `node_modules` at build time (into `runtimeConfig.public.fugueDevtools.packages`). When they all share one version it says so once ("All 10 packages are on version 0.6.3") and shows the names as badges; mixed versions are grouped. The copied diagnostics include the list.
11
+ - Removed the "Turn off dev tools" button from Diagnostics: the drawer header already has the turn-off control.
12
+ - @altafusion/fugue-ui@0.6.4
13
+
3
14
  ## 0.6.3
4
15
 
5
16
  ### Patch Changes
@@ -1,8 +1,10 @@
1
1
  <script setup lang="ts">
2
+ import { summarizePackageVersions } from '#devtools/utils/altafusionPackages'
3
+ import { formatAppInfo } from '#devtools/utils/appInfo'
4
+
2
5
  /** Built-in public section: safe for any visitor to see, and handy to paste into a bug report. */
3
6
  const route = useRoute()
4
7
  const colorMode = useColorMode()
5
- const api = useDevTools()
6
8
  const width = ref(window.innerWidth)
7
9
  const height = ref(window.innerHeight)
8
10
 
@@ -14,7 +16,12 @@ function measure() {
14
16
  onMounted(() => window.addEventListener('resize', measure))
15
17
  onBeforeUnmount(() => window.removeEventListener('resize', measure))
16
18
 
19
+ const app = formatAppInfo(useRuntimeConfig().public.fugueDevtools.app)
20
+
17
21
  const rows = computed(() => ({
22
+ ...(app
23
+ ? { app }
24
+ : {}),
18
25
  url: route.fullPath,
19
26
  viewport: `${width.value}x${height.value}`,
20
27
  theme: colorMode.value,
@@ -22,45 +29,115 @@ const rows = computed(() => ({
22
29
  userAgent: navigator.userAgent,
23
30
  }))
24
31
 
32
+ const packages = useRuntimeConfig().public.fugueDevtools.packages ?? {}
33
+ const summary = summarizePackageVersions(packages)
34
+
25
35
  const copied = ref(false)
26
36
 
27
37
  async function copy() {
28
- await navigator.clipboard.writeText(JSON.stringify(rows.value, null, 2))
38
+ await navigator.clipboard.writeText(JSON.stringify({ ...rows.value, altafusion: packages }, null, 2))
29
39
  copied.value = true
30
40
  setTimeout(() => (copied.value = false), 1500)
31
41
  }
42
+
43
+ // A transparent card with the stronger `accented` border, so it reads on the drawer's solid background.
44
+ const cardUi = { root: 'bg-transparent ring-accented', header: 'px-3 py-2 sm:px-3', body: 'p-3 sm:p-3' }
32
45
  </script>
33
46
 
34
47
  <template>
35
- <div class="space-y-2 text-sm">
36
- <dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1">
37
- <template
38
- v-for="(value, key) in rows"
39
- :key="key"
40
- >
41
- <dt class="text-muted">
42
- {{ key }}
43
- </dt>
44
- <dd class="break-all font-mono text-xs">
45
- {{ value }}
46
- </dd>
48
+ <div class="grid w-full gap-4 text-sm sm:grid-cols-2">
49
+ <UCard :ui="cardUi">
50
+ <template #header>
51
+ <div class="flex items-center justify-between gap-2">
52
+ <span class="font-medium">Page</span>
53
+ <UButton
54
+ :label="copied ? 'Copied' : 'Copy Diagnostics'"
55
+ :icon="copied ? 'i-lucide-check' : 'i-lucide-copy'"
56
+ size="xs"
57
+ color="neutral"
58
+ variant="outline"
59
+ @click="copy"
60
+ />
61
+ </div>
47
62
  </template>
48
- </dl>
49
- <div class="flex gap-2">
50
- <UButton
51
- :label="copied ? 'Copied' : 'Copy diagnostics'"
52
- size="xs"
53
- color="neutral"
54
- variant="soft"
55
- @click="copy"
56
- />
57
- <UButton
58
- label="Turn off dev tools"
59
- size="xs"
60
- color="neutral"
61
- variant="ghost"
62
- @click="api.disable()"
63
+
64
+ <dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1">
65
+ <template
66
+ v-for="(value, key) in rows"
67
+ :key="key"
68
+ >
69
+ <dt class="text-muted">
70
+ {{ key }}
71
+ </dt>
72
+ <dd class="break-all font-mono text-xs">
73
+ {{ value }}
74
+ </dd>
75
+ </template>
76
+ </dl>
77
+ </UCard>
78
+
79
+ <UCard :ui="cardUi">
80
+ <template #header>
81
+ <div class="flex items-center justify-between gap-2">
82
+ <span class="font-medium">Altafusion Packages</span>
83
+ <UBadge
84
+ :label="`${summary.count} installed`"
85
+ size="sm"
86
+ color="neutral"
87
+ variant="subtle"
88
+ />
89
+ </div>
90
+ </template>
91
+
92
+ <UEmpty
93
+ v-if="!summary.count"
94
+ icon="i-lucide-package"
95
+ title="No Packages Found"
96
+ description="The site's @altafusion packages were not found at build time."
97
+ size="sm"
98
+ variant="naked"
63
99
  />
64
- </div>
100
+
101
+ <div
102
+ v-else
103
+ class="space-y-3"
104
+ >
105
+ <p
106
+ v-if="summary.uniform"
107
+ class="text-muted"
108
+ >
109
+ All {{ summary.count }} packages are on version
110
+ <UBadge
111
+ :label="summary.groups[0]!.version"
112
+ size="sm"
113
+ color="primary"
114
+ variant="subtle"
115
+ />
116
+ </p>
117
+
118
+ <div
119
+ v-for="group in summary.groups"
120
+ :key="group.version"
121
+ class="space-y-1"
122
+ >
123
+ <p
124
+ v-if="!summary.uniform"
125
+ class="font-mono text-xs"
126
+ >
127
+ {{ group.version }} ({{ group.names.length }})
128
+ </p>
129
+ <div class="flex flex-wrap gap-1">
130
+ <UBadge
131
+ v-for="name in group.names"
132
+ :key="name"
133
+ :label="name"
134
+ size="sm"
135
+ color="neutral"
136
+ variant="outline"
137
+ />
138
+ </div>
139
+ </div>
140
+ </div>
141
+ </UCard>
65
142
  </div>
66
143
  </template>
package/nuxt.config.ts CHANGED
@@ -7,7 +7,10 @@
7
7
 
8
8
  /// <reference path="./types/nuxt-fugue-devtools.d.ts" />
9
9
 
10
+ import type { Nuxt } from 'nuxt/schema'
10
11
  import { fileURLToPath } from 'node:url'
12
+ import { readAltafusionPackages } from './utils/readAltafusionPackages'
13
+ import { readAppInfo } from './utils/readAppInfo'
11
14
 
12
15
  const layerRoot = fileURLToPath(new URL('.', import.meta.url))
13
16
 
@@ -18,6 +21,22 @@ export default defineNuxtConfig({
18
21
  '#devtools': layerRoot,
19
22
  },
20
23
 
24
+ modules: [
25
+ // Reads the site's installed `@altafusion/*` packages and versions, and its own name, version and commit, for the Diagnostics section (once, at build time).
26
+ (_options: unknown, nuxt: Nuxt) => {
27
+ const current = nuxt.options.runtimeConfig.public.fugueDevtools
28
+ nuxt.options.runtimeConfig.public.fugueDevtools = {
29
+ ...current,
30
+ packages: readAltafusionPackages(nuxt.options.rootDir),
31
+ // What the site sets in its own `nuxt.config` (say, a release name) wins over what is read here.
32
+ app: {
33
+ ...readAppInfo(nuxt.options.rootDir),
34
+ ...current.app,
35
+ },
36
+ }
37
+ },
38
+ ],
39
+
21
40
  // Ship the type augmentations (`$fugueDevtools`, runtime config) to every site that extends this layer.
22
41
  hooks: {
23
42
  'prepare:types': ({ references }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@altafusion/fugue-devtools",
3
3
  "type": "module",
4
- "version": "0.6.3",
4
+ "version": "0.6.4",
5
5
  "description": "Generic non-modal dev tools drawer for Nuxt apps — Fugue family",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/altafusion/fugue/tree/main/packages-fugue/fugue-devtools#readme",
@@ -36,11 +36,11 @@
36
36
  "vue-router": "^5.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@altafusion/fugue-ui": "0.6.3"
39
+ "@altafusion/fugue-ui": "0.6.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@altafusion/eslint-config": "0.6.3",
43
- "@altafusion/nuxt-base": "0.6.3",
42
+ "@altafusion/eslint-config": "0.6.4",
43
+ "@altafusion/nuxt-base": "0.6.4",
44
44
  "@types/node": "^26.6.11",
45
45
  "eslint": "^10.15.0",
46
46
  "nuxt": "^4.7.0",
@@ -9,6 +9,10 @@ declare module 'nuxt/schema' {
9
9
  persistNamespace?: string
10
10
  persistKey?: string
11
11
  defaultPosition?: 'top' | 'right' | 'bottom' | 'left'
12
+ /** The site's installed `@altafusion/*` packages and versions, filled in at build time. */
13
+ packages?: Record<string, string>
14
+ /** The site's own name, version and build commit, filled in at build time; set a field in `nuxt.config` to override it. */
15
+ app?: import('../utils/appInfo').AppInfo
12
16
  }
13
17
  }
14
18
  }
@@ -0,0 +1,36 @@
1
+ /** One version and the `@altafusion/*` packages installed at it. */
2
+ export interface PackageVersionGroup {
3
+ version: string
4
+ names: string[]
5
+ }
6
+
7
+ export interface PackageVersionSummary {
8
+ count: number
9
+ /** Newest-first is not assumed: groups are ordered by how many packages share the version, then by version text. */
10
+ groups: PackageVersionGroup[]
11
+ /** True when every package is on the same version, so the UI can say it once. */
12
+ uniform: boolean
13
+ }
14
+
15
+ /** Groups `{ '@altafusion/shell': '0.6.3', ... }` by version, with short names (the scope dropped) sorted inside each group. */
16
+ export function summarizePackageVersions(packages: Record<string, string> = {}): PackageVersionSummary {
17
+ const byVersion = new Map<string, string[]>()
18
+ for (const [name, version] of Object.entries(packages)) {
19
+ const names = byVersion.get(version) ?? []
20
+ names.push(name.replace(/^@altafusion\//, ''))
21
+ byVersion.set(version, names)
22
+ }
23
+ const groups = [
24
+ ...byVersion.entries(),
25
+ ]
26
+ .map(([version, names]) => ({
27
+ version,
28
+ names: names.sort(),
29
+ }))
30
+ .sort((a, b) => b.names.length - a.names.length || b.version.localeCompare(a.version))
31
+ return {
32
+ count: Object.keys(packages).length,
33
+ groups,
34
+ uniform: groups.length === 1,
35
+ }
36
+ }
@@ -0,0 +1,18 @@
1
+ /** The site running the dev tools: its `package.json` name and version, and the commit it was built from. */
2
+ export interface AppInfo {
3
+ name?: string
4
+ version?: string
5
+ /** Full or short commit hash of the build (Netlify's `COMMIT_REF`, GitHub's `GITHUB_SHA`, else `git rev-parse HEAD`). */
6
+ commit?: string
7
+ }
8
+
9
+ /** `camilajessica 0.1.0 (9e5769e)`; any missing part is left out, and `undefined` when there is nothing to show. */
10
+ export function formatAppInfo(app?: AppInfo): string | undefined {
11
+ if (!app)
12
+ return undefined
13
+ const label = [app.name, app.version].filter(Boolean).join(' ')
14
+ const commit = app.commit
15
+ ? `(${app.commit.slice(0, 7)})`
16
+ : ''
17
+ return [label, commit].filter(Boolean).join(' ') || undefined
18
+ }
@@ -0,0 +1,27 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ /**
5
+ * Build-time only (it imports `node:fs`, so only `nuxt.config.ts` may import it): the `@altafusion/*` packages a site has
6
+ * installed, as `{ '@altafusion/shell': '0.6.3' }`, read from `<rootDir>/node_modules/@altafusion/*\/package.json`.
7
+ */
8
+ export function readAltafusionPackages(rootDir: string): Record<string, string> {
9
+ const scopeDir = join(rootDir, 'node_modules', '@altafusion')
10
+ if (!existsSync(scopeDir))
11
+ return {}
12
+
13
+ const packages: Record<string, string> = {}
14
+ for (const dir of readdirSync(scopeDir).sort()) {
15
+ const file = join(scopeDir, dir, 'package.json')
16
+ if (!existsSync(file))
17
+ continue
18
+ try {
19
+ const pkg = JSON.parse(readFileSync(file, 'utf8')) as { name?: string, version?: string }
20
+ if (pkg.name && pkg.version)
21
+ packages[pkg.name] = pkg.version
22
+ } catch {
23
+ // A package.json that cannot be read is skipped; the list is a convenience for bug reports.
24
+ }
25
+ }
26
+ return packages
27
+ }
@@ -0,0 +1,42 @@
1
+ import type { AppInfo } from './appInfo'
2
+ import { execFileSync } from 'node:child_process'
3
+ import { existsSync, readFileSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+ import process from 'node:process'
6
+
7
+ /** Asks git for the current commit; `undefined` when there is no git or no repository (a build from a tarball). */
8
+ function gitCommit(rootDir: string): string | undefined {
9
+ try {
10
+ return execFileSync('git', ['rev-parse', 'HEAD'], {
11
+ cwd: rootDir,
12
+ encoding: 'utf8',
13
+ stdio: ['ignore', 'pipe', 'ignore'],
14
+ }).trim() || undefined
15
+ } catch {
16
+ return undefined
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Build-time only (it imports `node:fs`, so only `nuxt.config.ts` may import it): the site's own name and version from its
22
+ * `package.json`, plus the commit it was built from. The version alone barely changes between deploys; the commit does.
23
+ */
24
+ export function readAppInfo(
25
+ rootDir: string,
26
+ env: Record<string, string | undefined> = process.env,
27
+ commitFromGit: (dir: string) => string | undefined = gitCommit,
28
+ ): AppInfo {
29
+ const file = join(rootDir, 'package.json')
30
+ let name: string | undefined
31
+ let version: string | undefined
32
+ if (existsSync(file)) {
33
+ try {
34
+ const pkg = JSON.parse(readFileSync(file, 'utf8')) as { name?: string, version?: string }
35
+ name = pkg.name
36
+ version = pkg.version
37
+ } catch {
38
+ // An unreadable package.json leaves the name and version out; the commit can still show.
39
+ }
40
+ }
41
+ return { name, version, commit: env.COMMIT_REF || env.GITHUB_SHA || commitFromGit(rootDir) }
42
+ }