@gxp-dev/tools 2.0.37 → 2.0.39

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,244 +1,151 @@
1
1
  # GxP Dev Tools
2
2
 
3
- A development devtools for creating plugins for the GxP kiosk platform. This package provides CLI tools, project scaffolding, and a development environment that emulates the GxP platform.
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.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### Global (Recommended)
8
+
7
9
  ```bash
8
10
  npm install -g @gxp-dev/tools
9
11
  ```
10
12
 
11
- Or use it as a dev dependency in your project:
13
+ ### Project-Level
12
14
 
13
15
  ```bash
14
16
  npm install --save-dev @gxp-dev/tools
15
17
  ```
16
18
 
19
+ ### Updating
20
+
21
+ ```bash
22
+ # Global
23
+ npm update -g @gxp-dev/tools
24
+
25
+ # Project-level
26
+ npm update @gxp-dev/tools
27
+ ```
28
+
29
+ After updating, run `gxdev init` in existing projects to sync dependencies and config files.
30
+
17
31
  ## Quick Start
18
32
 
19
- Create a new GxP plugin project:
33
+ ### New Project
20
34
 
21
35
  ```bash
22
36
  gxdev init my-plugin
23
37
  cd my-plugin
24
- git init
25
- npm run dev
38
+ npm run dev-http
39
+ ```
40
+
41
+ Your plugin is running at `http://localhost:3060`. Press `Ctrl+Shift+D` to open the in-browser Dev Tools.
42
+
43
+ ### Existing Project
44
+
45
+ If you already have a Vue/Vite project:
46
+
47
+ ```bash
48
+ cd my-existing-project
49
+ gxdev init
50
+ npm install
51
+ npm run dev-http
26
52
  ```
27
53
 
54
+ When run in a directory with an existing `package.json` (no name argument), `gxdev init` will:
55
+ - Add missing required dependencies and devDependencies
56
+ - Update mismatched dependency versions
57
+ - Add missing npm scripts (`dev`, `build`, `dev-http`, etc.)
58
+ - Back up your existing `vite.config.js` to `vite.config.js.backup`
59
+ - Copy config files (`app-manifest.json`, `.env.example`, store setup, AI agent configs)
60
+
61
+ It will **not** overwrite your source files (`src/`, `theme-layouts/`, etc.).
62
+
28
63
  ## CLI Commands
29
64
 
30
65
  | Command | Description |
31
66
  |---------|-------------|
67
+ | `gxdev` | Launch interactive TUI |
32
68
  | `gxdev init [name]` | Create a new project or update an existing one |
33
- | `gxdev dev` | Start development server with HTTPS and Socket.IO |
34
- | `gxdev dev --no-https` | Start development server with HTTP only |
69
+ | `gxdev dev` | Start development server (HTTPS + TUI) |
70
+ | `gxdev dev --no-https` | Start with HTTP only |
71
+ | `gxdev dev --with-socket` | Start with Socket.IO server |
72
+ | `gxdev dev --chrome` | Start and launch Chrome with extension |
73
+ | `gxdev dev --firefox` | Start and launch Firefox with extension |
35
74
  | `gxdev build` | Build plugin for production |
36
75
  | `gxdev setup-ssl` | Generate SSL certificates for HTTPS development |
37
76
  | `gxdev publish <file>` | Copy runtime files to your project for customization |
38
77
  | `gxdev datastore <action>` | Manage GxP datastore (list, add, scan-strings, config) |
39
78
  | `gxdev socket <action>` | Simulate socket events (list, send) |
40
79
  | `gxdev assets <action>` | Manage development assets (list, init, generate) |
41
- | `gxdev ext:firefox` | Launch Firefox with browser extension |
80
+ | `gxdev add-dependency` | Add API dependency via interactive wizard |
81
+ | `gxdev extract-config` | Extract GxP config from source files |
42
82
  | `gxdev ext:chrome` | Launch Chrome with browser extension |
83
+ | `gxdev ext:firefox` | Launch Firefox with browser extension |
43
84
  | `gxdev ext:build` | Build browser extensions for distribution |
44
85
 
45
86
  ## Features
46
87
 
47
- - **Platform Emulator**: PortalContainer.vue mimics the GxP platform environment
48
- - **Hot Module Replacement**: Instant updates during development
49
- - **Socket.IO Integration**: Test real-time features with simulated events
50
- - **SSL Support**: HTTPS development with auto-generated certificates
51
- - **Browser Extensions**: Test plugins on live GxP pages
52
- - **Dev Tools Modal**: In-browser tools for inspecting state, switching layouts, and more
53
- - **Asset Generation**: Create placeholder images for development
54
-
55
- ---
88
+ - **Platform Emulator** - PortalContainer.vue mimics the GxP platform environment
89
+ - **Interactive TUI** - Terminal UI for managing dev services, logs, and slash commands
90
+ - **Hot Module Replacement** - Instant updates during development
91
+ - **Socket.IO Integration** - Test real-time features with simulated events
92
+ - **SSL Support** - HTTPS development with auto-generated certificates
93
+ - **Browser Extensions** - Chrome/Firefox DevTools panel for inspecting plugins
94
+ - **Dev Tools Modal** - In-browser tools for inspecting state, switching layouts, and more (Ctrl+Shift+D)
95
+ - **AI Scaffolding** - Generate starter code with Claude, Codex, or Gemini during init
96
+ - **Mock API** - Local mock API server with OpenAPI spec integration
97
+ - **Asset Generation** - Create placeholder images for development
56
98
 
57
- # DevTools Development Guide
99
+ ## Project Structure
58
100
 
59
- This section is for developers contributing to the devtools itself.
60
-
61
- ## Repository Structure
101
+ After `gxdev init`, your project contains:
62
102
 
63
103
  ```
64
- gx-devtools/
65
- ├── bin/ # CLI tool
66
- │ ├── gx-devtools.js # Entry point (delegates to lib/cli.js)
67
- └── lib/ # Modular CLI components
68
- │ ├── cli.js # Yargs command definitions
69
- │ ├── constants.js # Dependencies, scripts, ports
70
- │ ├── commands/ # Individual command modules
71
- │ │ ├── init.js # gxdev init
72
- │ │ ├── dev.js # gxdev dev
73
- │ │ ├── build.js # gxdev build
74
- │ │ ├── publish.js # gxdev publish
75
- │ │ ├── ssl.js # gxdev setup-ssl
76
- │ │ ├── datastore.js
77
- │ │ ├── socket.js
78
- │ │ ├── assets.js
79
- │ │ └── extensions.js
80
- │ └── utils/ # Shared utilities
81
- │ ├── paths.js # Path resolution
82
- │ ├── ssl.js # SSL certificate management
83
- │ ├── files.js # File operations
84
- │ └── prompts.js # User prompts
85
- ├── runtime/ # Files used from node_modules (NOT copied to projects)
86
- │ ├── PortalContainer.vue # Platform emulator (immutable for users)
87
- │ ├── server.js # Socket.IO development server
88
- │ ├── dev-tools/ # In-browser development tools
89
- │ │ ├── DevToolsModal.vue
90
- │ │ ├── StoreInspector.vue
91
- │ │ ├── LayoutSwitcher.vue
92
- │ │ ├── SocketSimulator.vue
93
- │ │ └── MockDataEditor.vue
104
+ my-plugin/
105
+ ├── src/
106
+ │ ├── Plugin.vue # Main plugin entry point
107
+ ├── DemoPage.vue # Example component
94
108
  │ └── stores/
95
- │ └── gxpPortalConfigStore.js # Core Pinia store
96
- ├── template/ # Files copied to new projects during init
97
- ├── src/
98
- │ │ ├── Plugin.vue # User's app entry point
99
- │ │ ├── DemoPage.vue # Example component
100
- │ │ └── stores/ # Store setup
101
- │ ├── theme-layouts/ # Layout templates
102
- │ ├── dev-assets/ # Placeholder images
103
- │ ├── main.js # Dev entry point
104
- │ ├── vite.config.js # Project build config
105
- │ └── ...
106
- ├── socket-events/ # Socket event templates for simulation
107
- ├── browser-extensions/ # Chrome and Firefox extensions
108
- │ ├── chrome/
109
- │ └── firefox/
110
- └── scripts/ # Build and launch scripts
109
+ │ └── index.js # Pinia store setup
110
+ ├── theme-layouts/ # Layout components (Public, Private, System)
111
+ ├── dev-assets/images/ # Development placeholder images
112
+ ├── socket-events/ # Socket event templates
113
+ ├── app-manifest.json # Plugin configuration (strings, settings, assets)
114
+ ├── .env # Environment variables
115
+ └── package.json
111
116
  ```
112
117
 
113
- ## Key Concepts
114
-
115
- ### Runtime vs Template
116
-
117
- - **`/runtime/`**: Files that stay in node_modules and are imported at runtime via the `@gx-runtime` Vite alias. Users cannot modify these files directly.
118
-
119
- - **`/template/`**: Files copied to user projects during `gxdev init`. Users can edit these files.
120
-
121
- ### Vite Aliases
122
-
123
- Projects use these aliases (defined in `template/vite.config.js`):
118
+ The dev server automatically serves `index.html` and `main.js` from the toolkit runtime — no local copies needed.
124
119
 
125
- - `@` → Project's `src/` directory
126
- - `@layouts` → Project's `theme-layouts/` directory
127
- - `@gx-runtime` → DevTools's `runtime/` directory (from node_modules)
120
+ ## Environment Variables
128
121
 
129
- ### PortalContainer.vue
122
+ Key variables (set in `.env`):
130
123
 
131
- The platform emulator that wraps user plugins during development. It:
132
- - Provides mock router, theme, and navigation
133
- - Injects props that the real platform provides
134
- - Includes the dev tools modal (Ctrl+Shift+D)
135
- - Lives in `/runtime/` so users can't accidentally modify it
136
-
137
- ## Setting Up for Development
138
-
139
- 1. **Clone the repository**:
140
- ```bash
141
- git clone https://github.com/GramercyTech/gx-devtools.git
142
- cd gx-devtools
143
- ```
144
-
145
- 2. **Install dependencies**:
146
- ```bash
147
- npm install
148
- ```
149
-
150
- 3. **Link for local testing**:
151
- ```bash
152
- npm link
153
- ```
154
-
155
- 4. **Create a test project**:
156
- ```bash
157
- mkdir /tmp/test-project
158
- cd /tmp/test-project
159
- gxdev init test-app
160
- cd test-app
161
-
162
- # Link to local devtools instead of published version
163
- rm -rf node_modules/@gxp-dev/tools
164
- mkdir -p node_modules/@gramercytech
165
- ln -s /path/to/gx-devtools node_modules/@gxp-dev/tools
166
-
167
- npm run dev-http
168
- ```
169
-
170
- ## Making Changes
171
-
172
- ### Adding a New CLI Command
173
-
174
- 1. Create a new file in `bin/lib/commands/`:
175
- ```javascript
176
- // bin/lib/commands/mycommand.js
177
- function myCommand(argv) {
178
- console.log("My command running!");
179
- }
180
- module.exports = { myCommand };
181
- ```
182
-
183
- 2. Export from `bin/lib/commands/index.js`
184
-
185
- 3. Register in `bin/lib/cli.js`:
186
- ```javascript
187
- .command('mycommand', 'Description', {}, myCommand)
188
- ```
189
-
190
- ### Modifying the Dev Tools Modal
191
-
192
- Dev tools components are in `/runtime/dev-tools/`. Changes here affect all projects using the devtools.
193
-
194
- ### Adding Template Files
195
-
196
- Add files to `/template/` and update `bin/lib/commands/init.js` to copy them during project creation.
197
-
198
- ## Testing
199
-
200
- ### Manual Testing
201
-
202
- ```bash
203
- # Test CLI help
204
- node bin/gx-devtools.js --help
205
-
206
- # Test init command
207
- cd /tmp && rm -rf test-project
208
- node /path/to/gx-devtools/bin/gx-devtools.js init test-project
209
-
210
- # Test dev server (after linking)
211
- cd test-project
212
- npm run dev-http
213
-
214
- # Test build
215
- npm run build
216
- ```
124
+ | Variable | Default | Description |
125
+ |----------|---------|-------------|
126
+ | `NODE_PORT` | `3060` | Development server port |
127
+ | `SOCKET_IO_PORT` | `3061` | Socket.IO server port |
128
+ | `COMPONENT_PATH` | `./src/Plugin.vue` | Main component path |
129
+ | `USE_HTTPS` | `true` | Enable HTTPS |
130
+ | `CERT_PATH` | | SSL certificate path |
131
+ | `KEY_PATH` | | SSL private key path |
132
+ | `USE_LOCAL_INDEX` | | Set to `true` to use a local `index.html` instead of the runtime version |
133
+ | `USE_LOCAL_MAIN` | | Set to `true` to use a local `main.js` instead of the runtime version |
134
+ | `SOCKET_IO_ENABLED` | `false` | Auto-start Socket.IO |
135
+ | `API_ENV` | `mock` | API environment (mock, local, development, staging, production) |
217
136
 
218
- ### Verifying Changes
137
+ ## Runtime vs Template
219
138
 
220
- 1. Create a fresh test project
221
- 2. Link the local devtools
222
- 3. Run `npm run dev-http` and verify the app loads
223
- 4. Run `npm run build` and check `dist/` output
224
- 5. Test dev tools with Ctrl+Shift+D
139
+ - **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.
140
+ - **Template files** are copied to your project during `gxdev init` and are fully yours to edit.
225
141
 
226
- ## Publishing
142
+ ## Documentation
227
143
 
228
- 1. Update version in `package.json`
229
- 2. Ensure all new directories are included (runtime/, template/, socket-events/)
230
- 3. Run `npm publish`
144
+ Full documentation is available at the [GxP Documentation site](https://docs.gramercytech.com/gx-devtools).
231
145
 
232
- ## Dependencies
146
+ ## Contributing
233
147
 
234
- The devtools uses:
235
- - **Vite** - Build tool and dev server
236
- - **Vue 3** - UI framework
237
- - **Pinia** - State management
238
- - **Socket.IO** - Real-time communication
239
- - **yargs** - CLI argument parsing
240
- - **shelljs** - Shell commands
241
- - **mkcert** - SSL certificate generation
148
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, architecture details, and how to make changes to the toolkit itself.
242
149
 
243
150
  ## License
244
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -205,6 +205,56 @@ export default defineConfig(({ mode }) => {
205
205
  },
206
206
  };
207
207
 
208
+ // Fallback plugin for missing @layouts files
209
+ // When a project doesn't have theme-layouts/, serve minimal fallbacks
210
+ // so PortalContainer.vue imports don't break
211
+ const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
212
+ const layoutFallbackPlugin = {
213
+ name: "gxp-layout-fallback",
214
+ resolveId(source) {
215
+ // Only handle @layouts/ imports
216
+ if (!source.startsWith("@layouts/")) return null;
217
+
218
+ const fileName = source.replace("@layouts/", "");
219
+ const localFile = path.resolve(layoutsDir, fileName);
220
+
221
+ // If the file exists locally, let Vite resolve it normally
222
+ if (fs.existsSync(localFile)) return null;
223
+
224
+ // Return a virtual module ID for the missing file
225
+ return `\0gxp-layout-fallback:${fileName}`;
226
+ },
227
+ load(id) {
228
+ if (!id.startsWith("\0gxp-layout-fallback:")) return null;
229
+
230
+ const fileName = id.replace("\0gxp-layout-fallback:", "");
231
+ console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
232
+
233
+ // CSS files get empty content
234
+ if (fileName.endsWith(".css")) {
235
+ return "/* GxP fallback: no local AdditionalStyling.css */";
236
+ }
237
+
238
+ // Vue layout components get a passthrough slot wrapper
239
+ if (fileName.endsWith(".vue")) {
240
+ return `
241
+ <template><slot /></template>
242
+ <script setup>
243
+ defineOptions({ inheritAttrs: false });
244
+ defineProps({
245
+ usrLang: { type: String, default: "" },
246
+ portalSettings: { type: Object, default: () => ({}) },
247
+ portalLanguage: { type: Object, default: () => ({}) },
248
+ portalNavigation: { type: Array, default: () => ([]) },
249
+ portalAssets: { type: Object, default: () => ({}) },
250
+ });
251
+ </script>`;
252
+ }
253
+
254
+ return "";
255
+ },
256
+ };
257
+
208
258
  // Determine if HTTPS is enabled
209
259
  const useHttps = getHttpsConfig(env) !== false;
210
260
 
@@ -237,6 +287,8 @@ export default defineConfig(({ mode }) => {
237
287
  },
238
288
  plugins: [
239
289
  runtimeFilesPlugin,
290
+ // Layout fallback must run before vue() to resolve missing @layouts/ imports
291
+ layoutFallbackPlugin,
240
292
  // Source tracker must run BEFORE vue() to transform templates before compilation
241
293
  gxpSourceTrackerPlugin(),
242
294
  vue(),
@@ -146,6 +146,42 @@ export default defineConfig(({ mode }) => {
146
146
  // Find the toolkit path for runtime imports
147
147
  const toolkitPath = findToolkitPath();
148
148
 
149
+ // Fallback plugin for missing @layouts files
150
+ const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
151
+ const layoutFallbackPlugin = {
152
+ name: "gxp-layout-fallback",
153
+ resolveId(source) {
154
+ if (!source.startsWith("@layouts/")) return null;
155
+ const fileName = source.replace("@layouts/", "");
156
+ const localFile = path.resolve(layoutsDir, fileName);
157
+ if (fs.existsSync(localFile)) return null;
158
+ return `\0gxp-layout-fallback:${fileName}`;
159
+ },
160
+ load(id) {
161
+ if (!id.startsWith("\0gxp-layout-fallback:")) return null;
162
+ const fileName = id.replace("\0gxp-layout-fallback:", "");
163
+ console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
164
+ if (fileName.endsWith(".css")) {
165
+ return "/* GxP fallback: no local AdditionalStyling.css */";
166
+ }
167
+ if (fileName.endsWith(".vue")) {
168
+ return `
169
+ <template><slot /></template>
170
+ <script setup>
171
+ defineOptions({ inheritAttrs: false });
172
+ defineProps({
173
+ usrLang: { type: String, default: "" },
174
+ portalSettings: { type: Object, default: () => ({}) },
175
+ portalLanguage: { type: Object, default: () => ({}) },
176
+ portalNavigation: { type: Array, default: () => ([]) },
177
+ portalAssets: { type: Object, default: () => ({}) },
178
+ });
179
+ </script>`;
180
+ }
181
+ return "";
182
+ },
183
+ };
184
+
149
185
  // Determine if HTTPS is enabled
150
186
  const useHttps = getHttpsConfig(env) !== false;
151
187
 
@@ -175,6 +211,8 @@ export default defineConfig(({ mode }) => {
175
211
  ),
176
212
  },
177
213
  plugins: [
214
+ // Layout fallback must run before vue() to resolve missing @layouts/ imports
215
+ layoutFallbackPlugin,
178
216
  // Source tracker must come before vue() to transform templates before compilation
179
217
  ...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
180
218
  vue(),