@gxp-dev/tools 2.0.71 → 2.0.72

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/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # GxP Dev Tools
2
2
 
3
- A development toolkit for creating plugins for the GxP kiosk platform. Provides CLI tools, project scaffolding, an interactive TUI, and a development environment that emulates the GxP platform.
3
+ A development toolkit for building plugins for the GxP kiosk platform. Ships a CLI, an interactive TUI, a platform emulator for local dev, a JSON-config linter, and a Model Context Protocol (MCP) server that gives AI coding assistants 29 specialized tools across API specs, config editing, documentation search, and test scaffolding.
4
4
 
5
5
  ## Installation
6
6
 
7
- ### Global (Recommended)
7
+ ### Global (recommended)
8
8
 
9
9
  ```bash
10
10
  npm install -g @gxp-dev/tools
11
11
  ```
12
12
 
13
- ### Project-Level
13
+ ### Project-level
14
14
 
15
15
  ```bash
16
16
  npm install --save-dev @gxp-dev/tools
@@ -19,30 +19,26 @@ npm install --save-dev @gxp-dev/tools
19
19
  ### Updating
20
20
 
21
21
  ```bash
22
- # Global
23
- npm update -g @gxp-dev/tools
24
-
25
- # Project-level
26
- npm update @gxp-dev/tools
22
+ npm update -g @gxp-dev/tools # global
23
+ npm update @gxp-dev/tools # project-level
27
24
  ```
28
25
 
29
- After updating, run `gxdev init` in existing projects to sync dependencies and config files.
26
+ After updating, run `gxdev init` in existing projects to sync required dependencies, scripts, and config files.
30
27
 
31
28
  ## Quick Start
32
29
 
33
- ### New Project
30
+ ### New project
34
31
 
35
32
  ```bash
36
33
  gxdev init my-plugin
37
34
  cd my-plugin
35
+ npm install
38
36
  npm run dev-http
39
37
  ```
40
38
 
41
- Your plugin is running at `http://localhost:3060`. Press `Ctrl+Shift+D` to open the in-browser Dev Tools.
42
-
43
- ### Existing Project
39
+ Open `http://localhost:3060`. Press `Ctrl+Shift+D` for the in-browser Dev Tools (Store Inspector, Layout Switcher, Socket Simulator, Mock Data Editor).
44
40
 
45
- If you already have a Vue/Vite project:
41
+ ### Adding to an existing project
46
42
 
47
43
  ```bash
48
44
  cd my-existing-project
@@ -51,102 +47,133 @@ npm install
51
47
  npm run dev-http
52
48
  ```
53
49
 
54
- When run in a directory with an existing `package.json` (no name argument), `gxdev init` will:
50
+ When run in a directory with an existing `package.json` and no name argument, `gxdev init`:
55
51
 
56
- - Add missing required dependencies and devDependencies
57
- - Update mismatched dependency versions
58
- - Add missing npm scripts (`dev`, `build`, `dev-http`, etc.)
59
- - Back up your existing `vite.config.js` to `vite.config.js.backup`
60
- - Copy config files (`app-manifest.json`, `.env.example`, store setup, AI agent configs)
52
+ - Adds missing required dependencies and devDependencies (Vue, Pinia, Vite, ESLint, Prettier, Vitest, Vue Test Utils, toolkit itself).
53
+ - Sets `"type": "module"` if the field is missing (preserves an explicit `"commonjs"`).
54
+ - Adds missing npm scripts (`dev`, `build`, `test`, `lint`, `format`, `prepare`, socket/assets/datastore helpers).
55
+ - Copies bundle files: `app-manifest.json`, `configuration.json`, `app-instructions.md`, `vite.extend.js`, `eslint.config.js`, `.prettierrc`, `.githooks/pre-commit`, `.env.example`, store setup, AI agent configs.
56
+ - Creates `src/public/` for static assets (served by Vite at `/src/public/*`).
61
57
 
62
- It will **not** overwrite your source files (`src/`, `theme-layouts/`, etc.).
58
+ It does **not** overwrite your source files (`src/`, `theme-layouts/`, etc.).
63
59
 
64
60
  ## CLI Commands
65
61
 
66
- | Command | Description |
67
- | -------------------------- | ------------------------------------------------------ |
68
- | `gxdev` | Launch interactive TUI |
69
- | `gxdev init [name]` | Create a new project or update an existing one |
70
- | `gxdev dev` | Start development server (HTTPS + TUI) |
71
- | `gxdev dev --no-https` | Start with HTTP only |
72
- | `gxdev dev --with-socket` | Start with Socket.IO server |
73
- | `gxdev dev --chrome` | Start and launch Chrome with extension |
74
- | `gxdev dev --firefox` | Start and launch Firefox with extension |
75
- | `gxdev build` | Build plugin for production |
76
- | `gxdev setup-ssl` | Generate SSL certificates for HTTPS development |
77
- | `gxdev publish <file>` | Copy runtime files to your project for customization |
78
- | `gxdev datastore <action>` | Manage GxP datastore (list, add, scan-strings, config) |
79
- | `gxdev socket <action>` | Simulate socket events (list, send) |
80
- | `gxdev assets <action>` | Manage development assets (list, init, generate) |
81
- | `gxdev add-dependency` | Add API dependency via interactive wizard |
82
- | `gxdev extract-config` | Extract GxP config from source files |
83
- | `gxdev ext:chrome` | Launch Chrome with browser extension |
84
- | `gxdev ext:firefox` | Launch Firefox with browser extension |
85
- | `gxdev ext:build` | Build browser extensions for distribution |
62
+ | Command | Description |
63
+ | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
+ | `gxdev` | Launch the interactive TUI |
65
+ | `gxdev init [name]` | Create a new project or update an existing one |
66
+ | `gxdev dev` | Start the dev server (HTTPS + Vite + Socket.IO) |
67
+ | `gxdev dev --no-https` | HTTP only |
68
+ | `gxdev dev --no-socket` | Skip the Socket.IO server |
69
+ | `gxdev dev --with-mock` | Enable the local Mock API (routes under `/api/*`) |
70
+ | `gxdev dev --chrome` | Start dev + launch Chrome with the inspector extension |
71
+ | `gxdev dev --firefox` | Start dev + launch Firefox with the inspector extension |
72
+ | `gxdev build` | Build the plugin for production → `dist/<name>.gxpapp` |
73
+ | `gxdev lint [files..]` | Validate `configuration.json` / `app-manifest.json` against the templating schema. `--all` lints every known config file in the project. `--json` emits machine-readable results. |
74
+ | `gxdev extract-config` | Scan `src/` for GxP directives and store calls; merge findings into `app-manifest.json` |
75
+ | `gxdev add-dependency` | Build an API dependency entry via interactive wizard |
76
+ | `gxdev setup-ssl` | Generate local SSL certificates via mkcert |
77
+ | `gxdev publish <file>` | Copy a runtime file (`main.js`, `index.html`, `server.cjs`, `gxpPortalConfigStore.js`) into the project for customization. For Vite config changes, use `vite.extend.js` at the project root instead. |
78
+ | `gxdev datastore <action>` | Manage the GxP datastore (`list`, `add`, `scan-strings`, `config`) |
79
+ | `gxdev socket <action>` | Simulate socket events (`list`, `send`) |
80
+ | `gxdev assets <action>` | Manage dev assets (`list`, `init`, `generate`) |
81
+ | `gxdev ext:chrome` / `ext:firefox` | Launch the browser inspector extension |
82
+ | `gxdev ext:build` | Build the browser extensions for distribution |
86
83
 
87
84
  ## Features
88
85
 
89
- - **Platform Emulator** - PortalContainer.vue mimics the GxP platform environment
90
- - **Interactive TUI** - Terminal UI for managing dev services, logs, and slash commands
91
- - **Hot Module Replacement** - Instant updates during development
92
- - **Socket.IO Integration** - Test real-time features with simulated events
93
- - **SSL Support** - HTTPS development with auto-generated certificates
94
- - **Browser Extensions** - Chrome/Firefox DevTools panel for inspecting plugins
95
- - **Dev Tools Modal** - In-browser tools for inspecting state, switching layouts, and more (Ctrl+Shift+D)
96
- - **AI Scaffolding** - Generate starter code with Claude, Codex, or Gemini during init
97
- - **Mock API** - Local mock API server with OpenAPI spec integration
98
- - **Asset Generation** - Create placeholder images for development
86
+ - **Platform emulator** `PortalContainer.vue` mimics the live GxP environment so plugins render exactly like production.
87
+ - **Interactive TUI** terminal UI for managing dev services, streaming logs, and firing slash commands.
88
+ - **HMR + HTTPS** — Vite 8 dev server with mkcert-generated certs (or HTTP fallback).
89
+ - **GxP Strings Plugin** — `gxp-string` / `gxp-src` / `gxp-settings` / `gxp-state` directives pull live values from the datastore, editable in the in-browser Dev Tools.
90
+ - **Socket.IO integration** — real-time events with a local server; CLI `socket send` simulates events on demand.
91
+ - **Mock API** — OpenAPI-driven local mock (auto-loads platform specs, routes under `/api/*`).
92
+ - **Browser extensions** Chrome/Firefox DevTools panels for inspecting Vue component trees and GxP state.
93
+ - **Config linting** — AJV-based JSON Schema validation of `configuration.json` (form-builder definitions) and `app-manifest.json` (plugin metadata + defaults).
94
+ - **Pre-commit hook** — `.githooks/pre-commit` runs Prettier, ESLint, and the GxP linter on staged files; configured automatically via the `prepare` npm script.
95
+ - **Unit testing** — Vitest + `@vue/test-utils` wired out of the box; scaffolded tests via the MCP server.
96
+ - **MCP server** — 29 tools for AI coding assistants (see below).
97
+ - **AI scaffolding** — pre-wired configs for Claude Code, Codex, and Gemini during `init`.
98
+
99
+ ## MCP Server for AI assistants
100
+
101
+ The toolkit ships `gxp-api-server` (bin `@gxp-dev/tools/mcp/gxp-api-server.js`), an MCP server exposing 29 tools across five families. Point your AI assistant at it to get API-aware, schema-aware, test-aware help inside plugin projects:
102
+
103
+ | Family | Tools |
104
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
105
+ | **API spec** (6) | `get_openapi_spec`, `get_asyncapi_spec`, `search_api_endpoints`, `search_websocket_events`, `get_endpoint_details`, `get_api_environment` |
106
+ | **Extended API** (5) | `api_list_tags`, `api_list_operation_ids`, `api_get_operation_parameters`, `api_find_endpoints_by_schema`, `api_generate_dependency` |
107
+ | **Config editor** (13) | `config_validate`, `config_list_field_types`, `config_list_card_types`, `config_get_field_schema`, `config_list_cards`, `config_list_fields`, `config_add_field`, `config_move_field`, `config_remove_field`, `config_add_card`, `config_move_card`, `config_remove_card`, `config_extract_strings` |
108
+ | **Docs search** (3) | `docs_list_pages`, `docs_search`, `docs_get_page` — full-text across `docs.gxp.dev` via its sitemap |
109
+ | **Test helpers** (2) | `test_scaffold_component_test`, `test_api_route` |
110
+
111
+ Every config mutation is linter-guarded: invalid writes are refused unless `force: true`, so AI agents can't save broken state.
99
112
 
100
113
  ## Project Structure
101
114
 
102
- After `gxdev init`, your project contains:
115
+ After `gxdev init`:
103
116
 
104
117
  ```
105
118
  my-plugin/
106
119
  ├── src/
107
- │ ├── Plugin.vue # Main plugin entry point
108
- │ ├── DemoPage.vue # Example component
120
+ │ ├── Plugin.vue # App entry point
121
+ │ ├── DemoPage.vue # Example component
122
+ │ ├── public/ # Static assets (served at /src/public/*)
109
123
  │ └── stores/
110
- │ └── index.js # Pinia store setup
111
- ├── theme-layouts/ # Layout components (Public, Private, System)
112
- ├── dev-assets/images/ # Development placeholder images
113
- ├── socket-events/ # Socket event templates
114
- ├── app-manifest.json # Plugin configuration (strings, settings, assets)
115
- ├── .env # Environment variables
124
+ │ └── index.js # Pinia store setup
125
+ ├── theme-layouts/ # System/Private/Public layouts
126
+ ├── dev-assets/images/ # Dev placeholder images
127
+ ├── socket-events/ # Socket event templates for simulation
128
+ ├── tests/ # Vitest test files (scaffolded as you go)
129
+ ├── scripts/ # Browser extension launch/pack scripts
130
+ ├── .githooks/pre-commit # Prettier + ESLint + gxdev lint on staged files
131
+ ├── app-manifest.json # Plugin metadata + default strings/settings/assets
132
+ ├── app-instructions.md # End-user onboarding doc (shown on install)
133
+ ├── configuration.json # Admin-panel config form definition
134
+ ├── vite.extend.js # Optional Vite config extension (aliases, plugins)
135
+ ├── eslint.config.js # ESLint flat config (JS + Vue)
136
+ ├── .prettierrc # Prettier config
116
137
  └── package.json
117
138
  ```
118
139
 
119
- The dev server automatically serves `index.html` and `main.js` from the toolkit runtime — no local copies needed.
140
+ The dev server serves `index.html` and `main.js` from the toolkit runtime — no local copies needed unless you opt in with `USE_LOCAL_INDEX` / `USE_LOCAL_MAIN`.
120
141
 
121
142
  ## Environment Variables
122
143
 
123
- Key variables (set in `.env`):
124
-
125
- | Variable | Default | Description |
126
- | ------------------- | ------------------ | ------------------------------------------------------------------------ |
127
- | `NODE_PORT` | `3060` | Development server port |
128
- | `SOCKET_IO_PORT` | `3061` | Socket.IO server port |
129
- | `COMPONENT_PATH` | `./src/Plugin.vue` | Main component path |
130
- | `USE_HTTPS` | `true` | Enable HTTPS |
131
- | `CERT_PATH` | | SSL certificate path |
132
- | `KEY_PATH` | | SSL private key path |
133
- | `USE_LOCAL_INDEX` | | Set to `true` to use a local `index.html` instead of the runtime version |
134
- | `USE_LOCAL_MAIN` | | Set to `true` to use a local `main.js` instead of the runtime version |
135
- | `SOCKET_IO_ENABLED` | `false` | Auto-start Socket.IO |
136
- | `API_ENV` | `mock` | API environment (mock, local, development, staging, production) |
137
-
138
- ## Runtime vs Template
139
-
140
- - **Runtime files** stay in `node_modules/` and are served automatically (`index.html`, `main.js`, store, dev tools, Vite config). Override `index.html`/`main.js` with `USE_LOCAL_INDEX`/`USE_LOCAL_MAIN` env vars. Use `gxdev publish` to copy other runtime files locally for customization.
144
+ Set in `.env` at the project root:
145
+
146
+ | Variable | Default | Description |
147
+ | ------------------------ | ------------------ | -------------------------------------------------------------------------------- |
148
+ | `NODE_PORT` | `3060` | Dev server port |
149
+ | `SOCKET_IO_PORT` | `3069` | Socket.IO server port |
150
+ | `COMPONENT_PATH` | `./src/Plugin.vue` | Main component path |
151
+ | `USE_HTTPS` | `true` | Enable HTTPS |
152
+ | `CERT_PATH` / `KEY_PATH` | | SSL cert/key paths (auto-set by `setup-ssl`) |
153
+ | `USE_LOCAL_INDEX` | | `true` to serve a local `index.html` instead of the runtime version |
154
+ | `USE_LOCAL_MAIN` | | `true` to serve a local `main.js` instead of the runtime version |
155
+ | `DISABLE_SOURCE_TRACKER` | | `true` to skip the source-tracking Vite plugin |
156
+ | `DISABLE_INSPECTOR` | | `true` to skip the component inspector plugin |
157
+ | `API_ENV` | `mock` | API environment (`mock`, `local`, `develop`, `testing`, `staging`, `production`) |
158
+ | `MOCK_API_ENABLED` | `false` | Mount the local mock API at `/api/*` |
159
+ | `ALLOWED_HOSTS` | | Comma-separated list of additional hostnames the dev server should accept |
160
+
161
+ ## Runtime vs. template
162
+
163
+ - **Runtime files** stay in `node_modules/@gxp-dev/tools/runtime/` and are used via imports or served by Vite at request time (`index.html`, `main.js`, store, dev tools, Vite config, inspector plugins). Override `index.html` / `main.js` with the `USE_LOCAL_*` env vars. Use `gxdev publish <file>` to copy other runtime files locally.
141
164
  - **Template files** are copied to your project during `gxdev init` and are fully yours to edit.
165
+ - **`vite.extend.js`** at the project root is deep-merged into the runtime Vite config via `mergeConfig` — add aliases, plugins, and `define` keys without replacing the whole config.
142
166
 
143
167
  ## Documentation
144
168
 
145
- Full documentation is available at the [GxP Documentation site](https://docs.gramercytech.com/gx-devtools).
169
+ - **Full docs**: [docs.gxp.dev](https://docs.gxp.dev)
170
+ - **CLI reference**: `gxdev --help` or [docs.gxp.dev/gx-devtools/cli-reference](https://docs.gxp.dev/gx-devtools/cli-reference)
171
+ - **Getting started**: [docs.gxp.dev/gx-devtools/getting-started](https://docs.gxp.dev/gx-devtools/getting-started)
172
+ - **Platform templating system**: [docs.gxp.dev/platform/plugin-system](https://docs.gxp.dev/platform/plugin-system)
146
173
 
147
174
  ## Contributing
148
175
 
149
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, architecture details, and how to make changes to the toolkit itself.
176
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, architecture, and how to extend the toolkit itself.
150
177
 
151
178
  ## License
152
179
 
package/bin/lib/cli.js CHANGED
@@ -24,6 +24,7 @@ const {
24
24
  extensionInstallCommand,
25
25
  extractConfigCommand,
26
26
  addDependencyCommand,
27
+ lintCommand,
27
28
  } = require("./commands")
28
29
 
29
30
  // Load global configuration
@@ -301,6 +302,23 @@ yargs
301
302
  },
302
303
  extractConfigCommand,
303
304
  )
305
+ .command(
306
+ "lint [files..]",
307
+ "Lint GxP config JSON (configuration.json, app-manifest.json) against the templating schema",
308
+ {
309
+ all: {
310
+ describe: "Lint all known config files in the project root",
311
+ type: "boolean",
312
+ default: false,
313
+ },
314
+ json: {
315
+ describe: "Output results as JSON instead of terminal report",
316
+ type: "boolean",
317
+ default: false,
318
+ },
319
+ },
320
+ lintCommand,
321
+ )
304
322
  .command(
305
323
  "add-dependency",
306
324
  "Add an API dependency to app-manifest.json via interactive wizard",
@@ -20,6 +20,7 @@ const {
20
20
  } = require("./extensions")
21
21
  const { extractConfigCommand } = require("./extract-config")
22
22
  const { addDependencyCommand } = require("./add-dependency")
23
+ const { lintCommand } = require("./lint")
23
24
 
24
25
  module.exports = {
25
26
  initCommand,
@@ -36,4 +37,5 @@ module.exports = {
36
37
  extensionInstallCommand,
37
38
  extractConfigCommand,
38
39
  addDependencyCommand,
40
+ lintCommand,
39
41
  }
@@ -127,6 +127,22 @@ function copyBundleFiles(projectPath, paths, overwrite = false) {
127
127
  dest: "vite.extend.js",
128
128
  desc: "vite.extend.js (customize the Vite runtime config)",
129
129
  },
130
+ {
131
+ src: "eslint.config.js",
132
+ dest: "eslint.config.js",
133
+ desc: "eslint.config.js (flat config for JS/Vue)",
134
+ },
135
+ {
136
+ src: ".prettierrc",
137
+ dest: ".prettierrc",
138
+ desc: ".prettierrc (format config)",
139
+ },
140
+ {
141
+ src: "githooks/pre-commit",
142
+ dest: ".githooks/pre-commit",
143
+ desc: ".githooks/pre-commit (runs prettier + eslint + gxdev lint)",
144
+ mode: 0o755,
145
+ },
130
146
  { src: "env.example", dest: ".env.example", desc: ".env.example" },
131
147
  { src: "gitignore", dest: ".gitignore", desc: ".gitignore" },
132
148
  {
@@ -162,6 +178,13 @@ function copyBundleFiles(projectPath, paths, overwrite = false) {
162
178
  const srcPath = path.join(paths.templateDir, file.src)
163
179
  const destPath = path.join(projectPath, file.dest)
164
180
  safeCopyFile(srcPath, destPath, file.desc, overwrite)
181
+ if (file.mode && fs.existsSync(destPath)) {
182
+ try {
183
+ fs.chmodSync(destPath, file.mode)
184
+ } catch (_e) {
185
+ // Best-effort — Windows or restrictive FS may reject chmod.
186
+ }
187
+ }
165
188
  })
166
189
  }
167
190
  /**
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Lint Command
3
+ *
4
+ * Validates GxP config JSON (configuration.json, app-manifest.json) against
5
+ * schemas derived from the templating system docs.
6
+ */
7
+
8
+ const path = require("path")
9
+ const fs = require("fs")
10
+ const { lintFiles, detectSchema } = require("../lint")
11
+ const { formatReport } = require("../lint/formatter")
12
+ const { findProjectRoot } = require("../utils")
13
+
14
+ /**
15
+ * Targets for `--all` mode. Extendable as more lintable files emerge.
16
+ */
17
+ const DEFAULT_TARGETS = ["configuration.json", "app-manifest.json"]
18
+
19
+ function collectAllTargets(projectPath) {
20
+ return DEFAULT_TARGETS.map((name) => path.join(projectPath, name)).filter(
21
+ (p) => fs.existsSync(p),
22
+ )
23
+ }
24
+
25
+ async function lintCommand(argv) {
26
+ const projectPath = findProjectRoot()
27
+ const explicit = Array.isArray(argv.files) ? argv.files.filter(Boolean) : []
28
+
29
+ let files
30
+ let userSuppliedFiles = false
31
+ if (explicit.length > 0) {
32
+ // Resolve relative to the cwd the user ran from.
33
+ files = explicit.map((f) => path.resolve(process.cwd(), f))
34
+ userSuppliedFiles = true
35
+ } else {
36
+ // No files given: default to the well-known targets in the project root.
37
+ files = collectAllTargets(projectPath)
38
+ }
39
+
40
+ if (files.length === 0) {
41
+ console.log(
42
+ "No configuration.json or app-manifest.json found in project root.",
43
+ )
44
+ return
45
+ }
46
+
47
+ // Drop files we don't have a schema for, unless the user named them
48
+ // explicitly — in that case surface them as skipped in the report.
49
+ if (!userSuppliedFiles) {
50
+ files = files.filter((f) => detectSchema(f))
51
+ }
52
+
53
+ const { results, summary } = lintFiles(files)
54
+
55
+ if (argv.json) {
56
+ const out = {
57
+ summary,
58
+ results: results.map((r) => ({
59
+ file: r.file,
60
+ ok: r.ok,
61
+ skipped: r.skipped,
62
+ errors: r.errors,
63
+ })),
64
+ }
65
+ console.log(JSON.stringify(out, null, 2))
66
+ } else {
67
+ console.log(formatReport({ results, summary }, { cwd: projectPath }))
68
+ }
69
+
70
+ if (summary.filesWithErrors > 0) {
71
+ process.exit(1)
72
+ }
73
+ }
74
+
75
+ module.exports = {
76
+ lintCommand,
77
+ }
@@ -16,6 +16,12 @@ const REQUIRED_DEPENDENCIES = {
16
16
 
17
17
  const REQUIRED_DEV_DEPENDENCIES = {
18
18
  "@gxp-dev/tools": "^2.0.0",
19
+ eslint: "^10.2.1",
20
+ "eslint-plugin-vue": "^10.9.0",
21
+ globals: "^17.5.0",
22
+ prettier: "^3.8.3",
23
+ vitest: "^4.1.5",
24
+ "@vue/test-utils": "^2.4.6",
19
25
  }
20
26
 
21
27
  // Default scripts for package.json
@@ -24,6 +30,12 @@ const DEFAULT_SCRIPTS = {
24
30
  "dev-app": "gxdev dev",
25
31
  "dev-http": "gxdev dev --no-https",
26
32
  build: "gxdev build",
33
+ test: "vitest run",
34
+ "test:watch": "vitest",
35
+ lint: "gxdev lint --all",
36
+ "lint:js": "eslint .",
37
+ format: "prettier --write .",
38
+ prepare: "git config core.hooksPath .githooks || true",
27
39
  "setup-ssl": "gxdev setup-ssl",
28
40
  "socket:list": "gxdev socket list",
29
41
  "socket:send": "gxdev socket send",
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Terminal output formatter for GxP linter results.
3
+ *
4
+ * Uses raw ANSI codes (no extra dep). Auto-disables color when stdout is not
5
+ * a TTY or when NO_COLOR is set.
6
+ */
7
+
8
+ const path = require("path")
9
+
10
+ const USE_COLOR = process.stdout.isTTY && !process.env.NO_COLOR
11
+
12
+ function wrap(code) {
13
+ return (str) => (USE_COLOR ? `\x1b[${code}m${str}\x1b[0m` : String(str))
14
+ }
15
+
16
+ const red = wrap("31")
17
+ const green = wrap("32")
18
+ const yellow = wrap("33")
19
+ const blue = wrap("34")
20
+ const magenta = wrap("35")
21
+ const cyan = wrap("36")
22
+ const gray = wrap("90")
23
+ const bold = wrap("1")
24
+ const dim = wrap("2")
25
+
26
+ function formatResult(result, { cwd = process.cwd() } = {}) {
27
+ const lines = []
28
+ const rel = path.relative(cwd, result.file) || result.file
29
+
30
+ if (result.skipped) {
31
+ lines.push(gray(` ${rel} — skipped (${result.reason || "no schema"})`))
32
+ return lines.join("\n")
33
+ }
34
+
35
+ if (result.ok) {
36
+ lines.push(` ${green("✓")} ${rel}`)
37
+ return lines.join("\n")
38
+ }
39
+
40
+ lines.push(` ${red("✗")} ${bold(rel)}`)
41
+ for (const err of result.errors) {
42
+ const loc = gray(`${result.file}:${err.line}:${err.column}`)
43
+ const code = dim(`[${err.code}]`)
44
+ lines.push(` ${red("error")} ${code} ${err.message}`)
45
+ lines.push(` ${loc}`)
46
+ }
47
+ return lines.join("\n")
48
+ }
49
+
50
+ function formatReport({ results, summary }, opts = {}) {
51
+ const lines = []
52
+ lines.push(bold(cyan("\nGxP config lint")))
53
+ lines.push(
54
+ gray(` ${summary.totalFiles} file(s) scanned, ${summary.skipped} skipped`),
55
+ )
56
+ lines.push("")
57
+
58
+ for (const r of results) {
59
+ lines.push(formatResult(r, opts))
60
+ }
61
+
62
+ lines.push("")
63
+ if (summary.totalErrors === 0 && summary.filesWithErrors === 0) {
64
+ lines.push(green(bold("✓ No problems found.")))
65
+ } else {
66
+ lines.push(
67
+ red(
68
+ bold(
69
+ `✗ ${summary.totalErrors} error(s) in ${summary.filesWithErrors} file(s).`,
70
+ ),
71
+ ),
72
+ )
73
+ }
74
+ return lines.join("\n")
75
+ }
76
+
77
+ module.exports = {
78
+ formatResult,
79
+ formatReport,
80
+ colors: {
81
+ red,
82
+ green,
83
+ yellow,
84
+ blue,
85
+ magenta,
86
+ cyan,
87
+ gray,
88
+ bold,
89
+ dim,
90
+ },
91
+ }