@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.8 → 0.4.0-alpha.81
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/LICENSE +21 -0
- package/README.md +11 -20
- package/dist/index.js +270 -85
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
- package/templates/pro/_app.tsx +14 -4
- package/templates/pro/prebuild.js +56 -79
- package/templates/pro/scripts/pro-content-plugin.js +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Per Aspera LLC. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary and confidential property of Per Aspera LLC ("Company").
|
|
7
|
+
|
|
8
|
+
RESTRICTIONS: You may not use, copy, modify, merge, publish, distribute,
|
|
9
|
+
sublicense, sell, or otherwise exploit this Software or any portion thereof
|
|
10
|
+
without the express prior written consent of the Company.
|
|
11
|
+
|
|
12
|
+
GOVERNMENT USE: Use, duplication, or disclosure by the U.S. Government is
|
|
13
|
+
subject to restrictions as set forth in FAR 52.227-19 (Commercial Computer
|
|
14
|
+
Software - Restricted Rights) and DFARS 252.227-7013 (Rights in Technical
|
|
15
|
+
Data and Computer Software), as applicable.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED. IN NO EVENT SHALL THE COMPANY BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
19
|
+
OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
For licensing inquiries: legal@peraspera.com
|
package/README.md
CHANGED
|
@@ -21,10 +21,14 @@ to automatically wire up Pro features:
|
|
|
21
21
|
## Quick Start
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
# Works — project created in $cwd/my-app
|
|
25
|
+
pnpx @stackwright-pro/launch-stackwright-pro --name my-app -y
|
|
25
26
|
# Dependencies install automatically (~7s)
|
|
26
27
|
cd my-app
|
|
27
|
-
|
|
28
|
+
npx @stackwright-pro/raft # Start the otter raft
|
|
29
|
+
|
|
30
|
+
# Equivalent explicit form
|
|
31
|
+
pnpx @stackwright-pro/launch-stackwright-pro my-app --name my-app -y
|
|
28
32
|
```
|
|
29
33
|
|
|
30
34
|
### With an OpenAPI Spec
|
|
@@ -72,7 +76,7 @@ Options:
|
|
|
72
76
|
--force Overwrite existing directory
|
|
73
77
|
--skip-otters Skip otter raft setup
|
|
74
78
|
-y, --yes Skip prompts, use defaults
|
|
75
|
-
--spec <
|
|
79
|
+
--spec <paths...> Paths to OpenAPI specs (can be specified multiple times)
|
|
76
80
|
--spec-name <name> Name for the API integration (default: derived from filename)
|
|
77
81
|
-V, --version Output the version number
|
|
78
82
|
-h, --help Display help
|
|
@@ -120,24 +124,11 @@ for architecture details, auth deep-dives, and deployment guides.
|
|
|
120
124
|
|
|
121
125
|
## Starting the Otter Raft
|
|
122
126
|
|
|
123
|
-
The otter raft runs in two modes:
|
|
124
|
-
|
|
125
|
-
### Interactive Mode (Default)
|
|
126
|
-
|
|
127
127
|
```bash
|
|
128
|
-
|
|
128
|
+
cd my-app
|
|
129
|
+
npx @stackwright-pro/raft
|
|
129
130
|
```
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- Asks questions about your project via TUI
|
|
134
|
-
- Coordinates specialist otters (brand, theme, api, auth, page)
|
|
135
|
-
- Uses certificate pinning to ensure only approved otters are invoked
|
|
136
|
-
|
|
137
|
-
### Phases Mode (Debugging)
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
python -m stackwright_pro.raft.cli_adapter foreman --phases
|
|
141
|
-
```
|
|
132
|
+
The raft verifies otter integrity, loads project context from `.stackwright/init-context.json`, and spawns code-puppy in foreman mode. Tell the foreman about your specs in natural language — it coordinates the API, auth, data, and page otters to build your app.
|
|
142
133
|
|
|
143
|
-
|
|
134
|
+
All state lives in `.stackwright/` — you can interrupt and resume at any time.
|
package/dist/index.js
CHANGED
|
@@ -31,9 +31,9 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "@stackwright-pro/launch-stackwright-pro",
|
|
34
|
-
version: "0.4.0-alpha.
|
|
34
|
+
version: "0.4.0-alpha.74",
|
|
35
35
|
description: "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
|
|
36
|
-
license: "
|
|
36
|
+
license: "SEE LICENSE IN LICENSE",
|
|
37
37
|
publishConfig: {
|
|
38
38
|
access: "public"
|
|
39
39
|
},
|
|
@@ -57,27 +57,33 @@ var require_package = __commonJS({
|
|
|
57
57
|
"launch-stackwright-pro": "dist/index.js"
|
|
58
58
|
},
|
|
59
59
|
scripts: {
|
|
60
|
-
build: "tsup",
|
|
60
|
+
build: "node ../../scripts/sync-versions.mjs && tsup",
|
|
61
|
+
"sync-versions": "node ../../scripts/sync-versions.mjs",
|
|
61
62
|
dev: "tsup --watch",
|
|
62
63
|
test: "vitest run",
|
|
63
64
|
"test:coverage": "vitest run --coverage"
|
|
64
65
|
},
|
|
65
66
|
dependencies: {
|
|
67
|
+
"@stackwright-pro/auth": "workspace:*",
|
|
68
|
+
"@stackwright-pro/auth-nextjs": "workspace:*",
|
|
69
|
+
"@stackwright-pro/mcp": "workspace:*",
|
|
70
|
+
"@stackwright-pro/openapi": "workspace:*",
|
|
71
|
+
"@stackwright-pro/otters": "workspace:*",
|
|
66
72
|
"@stackwright-pro/scaffold-hooks": "latest",
|
|
67
|
-
"@stackwright/cli": "^0.
|
|
68
|
-
"@stackwright/scaffold-core": "^0.1
|
|
73
|
+
"@stackwright/cli": "^0.8.6",
|
|
74
|
+
"@stackwright/scaffold-core": "^0.3.1",
|
|
69
75
|
chalk: "^5.6.2",
|
|
70
|
-
commander: "^
|
|
71
|
-
"fs-extra": "^11.3",
|
|
76
|
+
commander: "^15.0.0",
|
|
77
|
+
"fs-extra": "^11.3.5",
|
|
72
78
|
"js-yaml": "^4.1.0"
|
|
73
79
|
},
|
|
74
80
|
devDependencies: {
|
|
75
81
|
"@types/fs-extra": "^11.0",
|
|
76
82
|
"@types/js-yaml": "^4.0.9",
|
|
77
|
-
"@types/node": "
|
|
78
|
-
typescript: "
|
|
79
|
-
tsup: "
|
|
80
|
-
vitest: "
|
|
83
|
+
"@types/node": "catalog:",
|
|
84
|
+
typescript: "catalog:",
|
|
85
|
+
tsup: "catalog:",
|
|
86
|
+
vitest: "catalog:"
|
|
81
87
|
}
|
|
82
88
|
};
|
|
83
89
|
}
|
|
@@ -85,43 +91,97 @@ var require_package = __commonJS({
|
|
|
85
91
|
|
|
86
92
|
// src/index.ts
|
|
87
93
|
var import_commander = require("commander");
|
|
88
|
-
var
|
|
94
|
+
var import_path2 = __toESM(require("path"));
|
|
89
95
|
var import_os = __toESM(require("os"));
|
|
90
|
-
var
|
|
96
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
91
97
|
var import_chalk = __toESM(require("chalk"));
|
|
92
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
93
98
|
var import_child_process = require("child_process");
|
|
94
99
|
var import_cli = require("@stackwright/cli");
|
|
95
100
|
var import_scaffold_core = require("@stackwright/scaffold-core");
|
|
96
101
|
var import_scaffold_hooks = require("@stackwright-pro/scaffold-hooks");
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
|
|
103
|
+
// src/scaffold.ts
|
|
104
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
105
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
106
|
+
var import_path = __toESM(require("path"));
|
|
107
|
+
|
|
108
|
+
// src/generated/workspace-versions.ts
|
|
109
|
+
var PRO_VERSIONS = {
|
|
110
|
+
"@stackwright-pro/auth": "0.2.0-alpha.7",
|
|
111
|
+
"@stackwright-pro/auth-nextjs": "0.2.0-alpha.9",
|
|
112
|
+
"@stackwright-pro/display-components": "0.2.0-alpha.7",
|
|
113
|
+
"@stackwright-pro/mcp": "0.2.0-alpha.42",
|
|
114
|
+
"@stackwright-pro/openapi": "0.3.0-alpha.18",
|
|
115
|
+
"@stackwright-pro/otters": "1.0.0-alpha.36",
|
|
116
|
+
"@stackwright-pro/pulse": "0.3.0-alpha.10",
|
|
117
|
+
"@stackwright-pro/workflow": "0.1.0-alpha.11",
|
|
118
|
+
"@stackwright-pro/workflow-components": "0.1.0-alpha.13"
|
|
119
|
+
};
|
|
120
|
+
var OSS_VERSIONS = {
|
|
121
|
+
"@stackwright/build-scripts": "^0.7.0",
|
|
122
|
+
"@stackwright/core": "^0.8.2",
|
|
123
|
+
"@stackwright/icons": "^0.5.2",
|
|
124
|
+
"@stackwright/mcp": "^0.4.5",
|
|
125
|
+
"@stackwright/nextjs": "^0.5.3",
|
|
126
|
+
"@stackwright/otters": "^0.2.0",
|
|
127
|
+
"@stackwright/ui-shadcn": "^0.1.0"
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/scaffold.ts
|
|
131
|
+
async function addProDepsToPackageJson(targetDir) {
|
|
132
|
+
const pkgPath = import_path.default.join(targetDir, "package.json");
|
|
133
|
+
const content = await import_fs_extra.default.readFile(pkgPath, "utf-8");
|
|
134
|
+
const pkg = JSON.parse(content);
|
|
135
|
+
const dependencies = typeof pkg.dependencies === "object" && pkg.dependencies !== null ? { ...pkg.dependencies } : {};
|
|
136
|
+
const devDependencies = typeof pkg.devDependencies === "object" && pkg.devDependencies !== null ? { ...pkg.devDependencies } : {};
|
|
137
|
+
const scripts = typeof pkg.scripts === "object" && pkg.scripts !== null ? { ...pkg.scripts } : {};
|
|
138
|
+
for (const [pkgName, pinnedVersion] of Object.entries(OSS_VERSIONS)) {
|
|
139
|
+
if (pkgName in dependencies) {
|
|
140
|
+
dependencies[pkgName] = pinnedVersion;
|
|
141
|
+
}
|
|
142
|
+
if (pkgName in devDependencies) {
|
|
143
|
+
devDependencies[pkgName] = pinnedVersion;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
Object.assign(dependencies, {
|
|
147
|
+
"@stackwright-pro/display-components": PRO_VERSIONS["@stackwright-pro/display-components"],
|
|
148
|
+
"@stackwright-pro/mcp": PRO_VERSIONS["@stackwright-pro/mcp"],
|
|
149
|
+
"@stackwright-pro/otters": PRO_VERSIONS["@stackwright-pro/otters"],
|
|
150
|
+
"@stackwright-pro/openapi": PRO_VERSIONS["@stackwright-pro/openapi"],
|
|
151
|
+
"@stackwright-pro/auth": PRO_VERSIONS["@stackwright-pro/auth"],
|
|
152
|
+
"@stackwright-pro/auth-nextjs": PRO_VERSIONS["@stackwright-pro/auth-nextjs"],
|
|
153
|
+
"@stackwright-pro/pulse": PRO_VERSIONS["@stackwright-pro/pulse"],
|
|
154
|
+
"@stackwright-pro/workflow-components": PRO_VERSIONS["@stackwright-pro/workflow-components"],
|
|
155
|
+
"@stackwright-pro/workflow": PRO_VERSIONS["@stackwright-pro/workflow"],
|
|
156
|
+
"@stackwright/build-scripts": OSS_VERSIONS["@stackwright/build-scripts"],
|
|
157
|
+
zod: "^4.0.0"
|
|
158
|
+
});
|
|
159
|
+
Object.assign(devDependencies, {
|
|
160
|
+
"@stoplight/prism-cli": "^5.14.2"
|
|
161
|
+
});
|
|
162
|
+
Object.assign(scripts, {
|
|
163
|
+
"dev:admin": "MOCK_USER=admin next dev",
|
|
164
|
+
"dev:analyst": "MOCK_USER=analyst next dev",
|
|
165
|
+
"dev:viewer": "MOCK_USER=viewer next dev",
|
|
166
|
+
prebuild: "node scripts/prebuild.js",
|
|
167
|
+
predev: "node scripts/prebuild.js"
|
|
168
|
+
});
|
|
169
|
+
pkg.dependencies = dependencies;
|
|
170
|
+
pkg.devDependencies = devDependencies;
|
|
171
|
+
pkg.scripts = scripts;
|
|
172
|
+
await import_fs_extra.default.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
102
173
|
}
|
|
103
174
|
async function addAuthToStackwrightYml(targetDir) {
|
|
104
175
|
const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
|
|
105
176
|
const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
|
|
106
|
-
const config = import_js_yaml.default.load(content);
|
|
107
|
-
config.auth = {
|
|
108
|
-
type: "pki",
|
|
109
|
-
profile: "dod_cac",
|
|
110
|
-
source: "gateway_headers",
|
|
111
|
-
roles: [
|
|
112
|
-
{ name: "ADMIN", permissions: ["*"] },
|
|
113
|
-
{ name: "ANALYST", permissions: ["data:read", "data:write"] },
|
|
114
|
-
{ name: "VIEWER", permissions: ["data:read"] }
|
|
115
|
-
],
|
|
116
|
-
protected_routes: [{ path: "/*", roles: ["VIEWER", "ANALYST", "ADMIN"] }],
|
|
117
|
-
public_routes: ["/", "/getting-started"]
|
|
118
|
-
};
|
|
177
|
+
const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
|
|
178
|
+
config.auth = {};
|
|
119
179
|
await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
|
|
120
180
|
}
|
|
121
181
|
async function addIntegrationToStackwrightYml(targetDir, specName, specFilename, mockUrl) {
|
|
122
182
|
const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
|
|
123
183
|
const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
|
|
124
|
-
const config = import_js_yaml.default.load(content);
|
|
184
|
+
const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
|
|
125
185
|
const integration = {
|
|
126
186
|
type: "openapi",
|
|
127
187
|
name: specName,
|
|
@@ -131,20 +191,71 @@ async function addIntegrationToStackwrightYml(targetDir, specName, specFilename,
|
|
|
131
191
|
if (mockUrl) {
|
|
132
192
|
integration.mockUrl = mockUrl;
|
|
133
193
|
}
|
|
134
|
-
config.integrations = [
|
|
194
|
+
config.integrations = [
|
|
195
|
+
...Array.isArray(config.integrations) ? config.integrations : [],
|
|
196
|
+
integration
|
|
197
|
+
];
|
|
135
198
|
await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
|
|
136
199
|
}
|
|
137
|
-
async function
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
200
|
+
async function scaffoldWorkspaceConfig(targetDir) {
|
|
201
|
+
const workspaceDir = import_path.default.join(targetDir, ".code-puppy");
|
|
202
|
+
await import_fs_extra.default.ensureDir(workspaceDir);
|
|
203
|
+
const workspaceStats = await import_fs_extra.default.lstat(workspaceDir);
|
|
204
|
+
if (workspaceStats.isSymbolicLink()) {
|
|
205
|
+
throw new Error(".code-puppy/ is a symlink \u2014 refusing to write. Check for tampering.");
|
|
206
|
+
}
|
|
207
|
+
const agentsDir = import_path.default.join(workspaceDir, "agents");
|
|
208
|
+
await import_fs_extra.default.ensureDir(agentsDir);
|
|
209
|
+
if (await import_fs_extra.default.pathExists(agentsDir)) {
|
|
210
|
+
const agentsStats = await import_fs_extra.default.lstat(agentsDir);
|
|
211
|
+
if (agentsStats.isSymbolicLink()) {
|
|
212
|
+
throw new Error(".code-puppy/agents is a symlink \u2014 refusing to write. Check for tampering.");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const configPath = import_path.default.join(workspaceDir, "config.json");
|
|
216
|
+
let existingConfig = {};
|
|
217
|
+
if (import_fs_extra.default.existsSync(configPath)) {
|
|
218
|
+
try {
|
|
219
|
+
existingConfig = JSON.parse(await import_fs_extra.default.readFile(configPath, "utf-8"));
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (await import_fs_extra.default.pathExists(configPath)) {
|
|
224
|
+
const configStats = await import_fs_extra.default.lstat(configPath);
|
|
225
|
+
if (configStats.isSymbolicLink()) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
".code-puppy/config.json is a symlink \u2014 refusing to write. Check for tampering."
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
await import_fs_extra.default.writeFile(
|
|
232
|
+
configPath,
|
|
233
|
+
JSON.stringify({ ...existingConfig, projectOnly: true }, null, 2) + "\n",
|
|
234
|
+
"utf-8"
|
|
235
|
+
);
|
|
236
|
+
const mcpServersPath = import_path.default.join(workspaceDir, "mcp_servers.json");
|
|
237
|
+
if (await import_fs_extra.default.pathExists(mcpServersPath)) {
|
|
238
|
+
const mcpStats = await import_fs_extra.default.lstat(mcpServersPath);
|
|
239
|
+
if (mcpStats.isSymbolicLink()) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
".code-puppy/mcp_servers.json is a symlink \u2014 refusing to write. Check for tampering."
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!import_fs_extra.default.existsSync(mcpServersPath)) {
|
|
246
|
+
const mcpConfig = {
|
|
247
|
+
mcp_servers: {
|
|
248
|
+
"stackwright-pro-mcp": {
|
|
249
|
+
type: "stdio",
|
|
250
|
+
command: "pnpm",
|
|
251
|
+
args: ["exec", "stackwright-pro-mcp"],
|
|
252
|
+
enabled: true,
|
|
253
|
+
cwd: "${PROJECT_ROOT}"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
await import_fs_extra.default.writeFile(mcpServersPath, JSON.stringify(mcpConfig, null, 2) + "\n", "utf-8");
|
|
141
258
|
}
|
|
142
|
-
const specFilename = import_path.default.basename(resolvedSpec);
|
|
143
|
-
const derivedName = specName || import_path.default.basename(specFilename, import_path.default.extname(specFilename));
|
|
144
|
-
const specsDir = import_path.default.join(targetDir, "specs");
|
|
145
|
-
await import_fs_extra.default.ensureDir(specsDir);
|
|
146
|
-
await import_fs_extra.default.copy(resolvedSpec, import_path.default.join(specsDir, specFilename));
|
|
147
|
-
return { specFilename, derivedName };
|
|
148
259
|
}
|
|
149
260
|
function generateReadme(options) {
|
|
150
261
|
const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;
|
|
@@ -167,7 +278,7 @@ export const EquipmentSchema = z.object({
|
|
|
167
278
|
export type Equipment = z.infer<typeof EquipmentSchema>;
|
|
168
279
|
|
|
169
280
|
// src/generated/${specName}/client.ts
|
|
170
|
-
export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
|
|
281
|
+
export class ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client {
|
|
171
282
|
async getEquipment(id: string): Promise<Equipment> {
|
|
172
283
|
// Auto-wired with auth, validation, error handling
|
|
173
284
|
}
|
|
@@ -180,10 +291,10 @@ export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
|
|
|
180
291
|
3. You import and use it:
|
|
181
292
|
|
|
182
293
|
\`\`\`typescript
|
|
183
|
-
import { ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client } from '@/generated/${specName}/client';
|
|
294
|
+
import { ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client } from '@/generated/${specName}/client';
|
|
184
295
|
import type { Equipment } from '@/generated/${specName}/types';
|
|
185
296
|
|
|
186
|
-
const client = new ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client();
|
|
297
|
+
const client = new ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client();
|
|
187
298
|
const gear: Equipment = await client.getEquipment('123');
|
|
188
299
|
\`\`\`
|
|
189
300
|
|
|
@@ -219,12 +330,10 @@ Your project includes **SIX specialized AI agents** in \`node_modules/@stackwrig
|
|
|
219
330
|
**Start the otter raft:**
|
|
220
331
|
|
|
221
332
|
\`\`\`bash
|
|
222
|
-
|
|
333
|
+
npx @stackwright-pro/raft
|
|
223
334
|
\`\`\`
|
|
224
335
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
The raft is a Python state machine with a Rich terminal UI \u2014 it asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All user interaction happens in the terminal; code-puppy is called as a one-shot subprocess for creative tasks only.
|
|
336
|
+
The raft verifies otter integrity, writes project context, and spawns code-puppy in foreman mode. The foreman asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All state lives in \`.stackwright/\` \u2014 interrupt and resume anytime.
|
|
228
337
|
|
|
229
338
|
**Example session prompt:**
|
|
230
339
|
|
|
@@ -402,11 +511,33 @@ ${aiAgentsSection}## \u{1F4DA} Learn More
|
|
|
402
511
|
**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.
|
|
403
512
|
`;
|
|
404
513
|
}
|
|
514
|
+
|
|
515
|
+
// src/index.ts
|
|
516
|
+
(0, import_scaffold_hooks.registerProScaffoldHooks)();
|
|
517
|
+
var { version } = require_package();
|
|
518
|
+
async function copyProTemplate(templateName, destPath) {
|
|
519
|
+
const src = import_path2.default.resolve(__dirname, "..", "templates", "pro", templateName);
|
|
520
|
+
await import_fs_extra2.default.copy(src, destPath);
|
|
521
|
+
}
|
|
522
|
+
async function handleSpec(targetDir, specPath, specName) {
|
|
523
|
+
const resolvedSpec = import_path2.default.resolve(specPath);
|
|
524
|
+
if (!import_fs_extra2.default.existsSync(resolvedSpec)) {
|
|
525
|
+
throw new Error(`Spec file not found: ${resolvedSpec}`);
|
|
526
|
+
}
|
|
527
|
+
const specFilename = import_path2.default.basename(resolvedSpec);
|
|
528
|
+
const derivedName = specName || import_path2.default.basename(specFilename, import_path2.default.extname(specFilename));
|
|
529
|
+
const specsDir = import_path2.default.join(targetDir, "specs");
|
|
530
|
+
await import_fs_extra2.default.ensureDir(specsDir);
|
|
531
|
+
await import_fs_extra2.default.copy(resolvedSpec, import_path2.default.join(specsDir, specFilename));
|
|
532
|
+
return { specFilename, derivedName };
|
|
533
|
+
}
|
|
405
534
|
async function launch(targetDir, options) {
|
|
406
|
-
const dirName =
|
|
535
|
+
const dirName = import_path2.default.basename(targetDir);
|
|
407
536
|
console.log(import_chalk.default.cyan.bold("\n\u{1F6A2} Launching Stackwright Pro...\n"));
|
|
408
537
|
const scaffoldOpts = {
|
|
409
538
|
name: options.name || dirName,
|
|
539
|
+
standalone: true,
|
|
540
|
+
// prevents `workspace:*` refs when CLI runs inside the Pro monorepo
|
|
410
541
|
...options.title !== void 0 && { title: options.title },
|
|
411
542
|
...options.theme !== void 0 && { theme: options.theme },
|
|
412
543
|
...options.force !== void 0 && { force: options.force },
|
|
@@ -414,13 +545,41 @@ async function launch(targetDir, options) {
|
|
|
414
545
|
};
|
|
415
546
|
await (0, import_cli.scaffold)(targetDir, scaffoldOpts);
|
|
416
547
|
console.log(import_chalk.default.green("\u2705 Base project scaffolded (hooks added Pro deps + MCP config)"));
|
|
548
|
+
await addProDepsToPackageJson(targetDir);
|
|
549
|
+
console.log(import_chalk.default.green("\u{1F9A6} Pro packages added to package.json"));
|
|
550
|
+
const verifyPkg = JSON.parse(
|
|
551
|
+
await import_fs_extra2.default.readFile(import_path2.default.join(targetDir, "package.json"), "utf-8")
|
|
552
|
+
);
|
|
553
|
+
const proDepCount = Object.keys(
|
|
554
|
+
typeof verifyPkg.dependencies === "object" && verifyPkg.dependencies !== null ? verifyPkg.dependencies : {}
|
|
555
|
+
).filter((k) => k.startsWith("@stackwright-pro")).length;
|
|
556
|
+
console.log(import_chalk.default.dim(` \u2192 package.json verified: ${proDepCount} @stackwright-pro/* deps ready`));
|
|
417
557
|
console.log(import_chalk.default.cyan("\n\u{1F4E6} Installing dependencies (this takes a moment)..."));
|
|
418
558
|
if (!options.skipInstall) {
|
|
419
559
|
try {
|
|
420
|
-
(0, import_child_process.execSync)("pnpm install", {
|
|
560
|
+
(0, import_child_process.execSync)("pnpm install --ignore-workspace", {
|
|
561
|
+
cwd: targetDir,
|
|
562
|
+
stdio: "inherit",
|
|
563
|
+
timeout: 12e4
|
|
564
|
+
});
|
|
421
565
|
console.log(import_chalk.default.green("\u2705 Dependencies installed"));
|
|
422
|
-
} catch {
|
|
423
|
-
|
|
566
|
+
} catch (err) {
|
|
567
|
+
const isTimeout = err instanceof Error && (err.message.includes("ETIMEDOUT") || err.message.includes("timeout"));
|
|
568
|
+
console.error(
|
|
569
|
+
import_chalk.default.red("\n\u274C pnpm install failed. Auth and Pro packages are NOT installed.")
|
|
570
|
+
);
|
|
571
|
+
console.error(
|
|
572
|
+
import_chalk.default.red(" Your project is in an incomplete state \u2014 do NOT run or deploy it.")
|
|
573
|
+
);
|
|
574
|
+
if (isTimeout) {
|
|
575
|
+
console.error(
|
|
576
|
+
import_chalk.default.yellow(" The install timed out (>2 min). Check your network connection.")
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
console.error(
|
|
580
|
+
import_chalk.default.yellow(` Fix the error above, then run: pnpm install --ignore-workspace`)
|
|
581
|
+
);
|
|
582
|
+
process.exit(1);
|
|
424
583
|
}
|
|
425
584
|
} else {
|
|
426
585
|
console.log(import_chalk.default.dim("\u2139\uFE0F Skipping install (--skip-install). Run: pnpm install"));
|
|
@@ -428,33 +587,39 @@ async function launch(targetDir, options) {
|
|
|
428
587
|
const dependencyMode = "standalone";
|
|
429
588
|
await (0, import_scaffold_core.runScaffoldHooks)("postInstall", {
|
|
430
589
|
targetDir,
|
|
431
|
-
projectName: options.name ||
|
|
432
|
-
siteTitle: options.title || options.name ||
|
|
590
|
+
projectName: options.name || import_path2.default.basename(targetDir),
|
|
591
|
+
siteTitle: options.title || options.name || import_path2.default.basename(targetDir),
|
|
433
592
|
themeId: options.theme || "corporate",
|
|
434
593
|
packageJson: {},
|
|
435
594
|
dependencyMode
|
|
436
595
|
});
|
|
437
|
-
await copyProTemplate("_app.tsx",
|
|
438
|
-
await copyProTemplate("content.yml",
|
|
439
|
-
await copyProTemplate("next.config.js",
|
|
440
|
-
await
|
|
441
|
-
await copyProTemplate("mock-auth.ts",
|
|
442
|
-
await copyProTemplate("yaml.d.ts",
|
|
443
|
-
await
|
|
444
|
-
await copyProTemplate("prebuild.js",
|
|
596
|
+
await copyProTemplate("_app.tsx", import_path2.default.join(targetDir, "pages", "_app.tsx"));
|
|
597
|
+
await copyProTemplate("content.yml", import_path2.default.join(targetDir, "pages", "content.yml"));
|
|
598
|
+
await copyProTemplate("next.config.js", import_path2.default.join(targetDir, "next.config.js"));
|
|
599
|
+
await import_fs_extra2.default.ensureDir(import_path2.default.join(targetDir, "lib"));
|
|
600
|
+
await copyProTemplate("mock-auth.ts", import_path2.default.join(targetDir, "lib", "mock-auth.ts"));
|
|
601
|
+
await copyProTemplate("yaml.d.ts", import_path2.default.join(targetDir, "yaml.d.ts"));
|
|
602
|
+
await import_fs_extra2.default.ensureDir(import_path2.default.join(targetDir, "scripts"));
|
|
603
|
+
await copyProTemplate("prebuild.js", import_path2.default.join(targetDir, "scripts", "prebuild.js"));
|
|
604
|
+
await copyProTemplate(
|
|
605
|
+
"scripts/pro-content-plugin.js",
|
|
606
|
+
import_path2.default.join(targetDir, "scripts", "pro-content-plugin.js")
|
|
607
|
+
);
|
|
445
608
|
console.log(import_chalk.default.green("\u{1F510} Auth integration added (RBAC with 3 roles)"));
|
|
446
609
|
await addAuthToStackwrightYml(targetDir);
|
|
447
610
|
let specInfo = null;
|
|
448
611
|
const MOCK_URL = "http://localhost:4010";
|
|
449
|
-
if (options.spec) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
612
|
+
if (options.spec && options.spec.length > 0) {
|
|
613
|
+
for (const specPath of options.spec) {
|
|
614
|
+
specInfo = await handleSpec(targetDir, specPath, options.specName);
|
|
615
|
+
await addIntegrationToStackwrightYml(
|
|
616
|
+
targetDir,
|
|
617
|
+
specInfo.derivedName,
|
|
618
|
+
specInfo.specFilename,
|
|
619
|
+
options.mock ? MOCK_URL : void 0
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
console.log(import_chalk.default.green(`\u{1F4E1} ${options.spec.length} OpenAPI integration(s) wired up`));
|
|
458
623
|
if (options.mock) {
|
|
459
624
|
console.log(import_chalk.default.green("\u{1F3AD} Prism mock server configured"));
|
|
460
625
|
}
|
|
@@ -464,9 +629,9 @@ async function launch(targetDir, options) {
|
|
|
464
629
|
"\u26A0\uFE0F No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec."
|
|
465
630
|
)
|
|
466
631
|
);
|
|
467
|
-
const specsDir =
|
|
468
|
-
await
|
|
469
|
-
await copyProTemplate("petstore.yaml",
|
|
632
|
+
const specsDir = import_path2.default.join(targetDir, "specs");
|
|
633
|
+
await import_fs_extra2.default.ensureDir(specsDir);
|
|
634
|
+
await copyProTemplate("petstore.yaml", import_path2.default.join(specsDir, "petstore.yaml"));
|
|
470
635
|
specInfo = { specFilename: "petstore.yaml", derivedName: "petstore" };
|
|
471
636
|
await addIntegrationToStackwrightYml(
|
|
472
637
|
targetDir,
|
|
@@ -485,13 +650,33 @@ async function launch(targetDir, options) {
|
|
|
485
650
|
hasOtters: !options.skipOtters,
|
|
486
651
|
hasMock: !!options.mock
|
|
487
652
|
});
|
|
488
|
-
await
|
|
653
|
+
await import_fs_extra2.default.writeFile(import_path2.default.join(targetDir, "README.md"), readmeContent);
|
|
489
654
|
console.log(import_chalk.default.green("\u{1F4C4} README.md created"));
|
|
490
|
-
const
|
|
655
|
+
const initContext = {
|
|
656
|
+
projectRoot: targetDir,
|
|
657
|
+
projectName: options.name || dirName,
|
|
658
|
+
generatedBy: "launch-stackwright-pro",
|
|
659
|
+
version: "1.0"
|
|
660
|
+
};
|
|
661
|
+
if (specInfo) {
|
|
662
|
+
initContext.specPath = `specs/${specInfo.specFilename}`;
|
|
663
|
+
initContext.specName = specInfo.derivedName;
|
|
664
|
+
}
|
|
665
|
+
initContext.theme = options.theme || "corporate";
|
|
666
|
+
const stackwrightDir = import_path2.default.join(targetDir, ".stackwright");
|
|
667
|
+
await import_fs_extra2.default.ensureDir(stackwrightDir);
|
|
668
|
+
await import_fs_extra2.default.writeFile(
|
|
669
|
+
import_path2.default.join(stackwrightDir, "init-context.json"),
|
|
670
|
+
JSON.stringify(initContext, null, 2) + "\n",
|
|
671
|
+
"utf-8"
|
|
672
|
+
);
|
|
673
|
+
await scaffoldWorkspaceConfig(targetDir);
|
|
674
|
+
console.log(import_chalk.default.green("\u{1F43E} .code-puppy/ workspace scaffolded (projectOnly: true)"));
|
|
675
|
+
const relDir = import_path2.default.relative(process.cwd(), targetDir) || ".";
|
|
491
676
|
console.log(import_chalk.default.cyan.bold("\n\u{1F389} All set! Here's what to do next:\n"));
|
|
492
677
|
console.log(import_chalk.default.white(` 1. cd ${relDir}`));
|
|
493
|
-
console.log(import_chalk.default.white(" 2.
|
|
494
|
-
console.log(import_chalk.default.dim(" (
|
|
678
|
+
console.log(import_chalk.default.white(" 2. npx @stackwright-pro/raft"));
|
|
679
|
+
console.log(import_chalk.default.dim(" (use --verbose for troubleshooting)"));
|
|
495
680
|
if (specInfo) {
|
|
496
681
|
console.log(import_chalk.default.cyan(`
|
|
497
682
|
\u{1F4E1} Your API spec was copied to specs/${specInfo.specFilename}`));
|
|
@@ -509,8 +694,8 @@ async function launch(targetDir, options) {
|
|
|
509
694
|
async function main() {
|
|
510
695
|
const program = new import_commander.Command();
|
|
511
696
|
program.name("launch-stackwright-pro").description("\u{1F6A2} Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft").version(version).argument("[directory]", "Project directory", ".").option("--name <name>", "Project name (used in package.json)").option("--title <title>", "Site title shown in the app bar and browser tab").option("--theme <themeId>", "Theme ID (e.g., corporate, creative, minimal)").option("--force", "Launch even if the target directory is not empty").option("--skip-otters", "Skip copying otter raft configs").option("-y, --yes", "Skip all prompts, use defaults").option("--mock", "Configure Prism mock server for API development (runs on port 4010)").option(
|
|
512
|
-
"--spec <
|
|
513
|
-
"
|
|
697
|
+
"--spec <paths...>",
|
|
698
|
+
"Paths to OpenAPI specs (YAML or JSON) \u2014 copies into project and wires up integrations (can be specified multiple times)"
|
|
514
699
|
).option(
|
|
515
700
|
"--spec-name <name>",
|
|
516
701
|
"Name for the API integration (default: derived from spec filename)"
|
|
@@ -519,8 +704,8 @@ async function main() {
|
|
|
519
704
|
"Skip automatic pnpm install (useful in CI or when using a different package manager)"
|
|
520
705
|
).action(async (directory, options) => {
|
|
521
706
|
const homeDir = import_os.default.homedir();
|
|
522
|
-
const targetDir =
|
|
523
|
-
if (!targetDir.startsWith(homeDir +
|
|
707
|
+
const targetDir = directory !== "." ? import_path2.default.resolve(process.cwd(), directory) : options.name ? import_path2.default.resolve(process.cwd(), options.name) : process.cwd();
|
|
708
|
+
if (!targetDir.startsWith(homeDir + import_path2.default.sep) && targetDir !== homeDir) {
|
|
524
709
|
console.warn(import_chalk.default.yellow(`\u26A0\uFE0F Scaffolding outside your home directory: ${targetDir}`));
|
|
525
710
|
}
|
|
526
711
|
await launch(targetDir, options);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@stackwright-pro/launch-stackwright-pro\",\n \"version\": \"0.4.0-alpha.7\",\n \"description\": \"Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Per-Aspera-LLC/stackwright-pro\"\n },\n \"keywords\": [\n \"stackwright\",\n \"stackwright-pro\",\n \"scaffolding\",\n \"openapi\",\n \"government\",\n \"hackathon\"\n ],\n \"files\": [\n \"dist\",\n \"templates\"\n ],\n \"bin\": {\n \"launch-stackwright-pro\": \"dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@stackwright-pro/scaffold-hooks\": \"latest\",\n \"@stackwright/cli\": \"^0.7.0\",\n \"@stackwright/scaffold-core\": \"^0.1.0\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^14.0.3\",\n \"fs-extra\": \"^11.3\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.0\",\n \"typescript\": \"^5.0\",\n \"tsup\": \"^8.5\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","import { Command } from 'commander';\nimport path from 'path';\nimport os from 'os';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport yaml from 'js-yaml';\nimport { execSync } from 'child_process';\n\nimport { scaffold, ScaffoldOptions } from '@stackwright/cli';\nimport { runScaffoldHooks } from '@stackwright/scaffold-core';\nimport { registerProScaffoldHooks } from '@stackwright-pro/scaffold-hooks';\n// Register Pro hooks (adds deps, MCP config, etc.)\n// Must be called before scaffold() to ensure hooks run in the CLI's scaffold-core context\nregisterProScaffoldHooks();\n\nconst { version } = require('../package.json') as { version: string };\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface LaunchProOptions {\n name?: string;\n title?: string;\n theme?: string;\n force?: boolean;\n skipOtters?: boolean;\n skipInstall?: boolean;\n yes?: boolean;\n spec?: string;\n specName?: string;\n mock?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Template copying (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function copyProTemplate(templateName: string, destPath: string): Promise<void> {\n const src = path.resolve(__dirname, '..', 'templates', 'pro', templateName);\n await fs.copy(src, destPath);\n}\n\n// ---------------------------------------------------------------------------\n// Auth config (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function addAuthToStackwrightYml(targetDir: string): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content) as Record<string, unknown>;\n\n config.auth = {\n type: 'pki',\n profile: 'dod_cac',\n source: 'gateway_headers',\n roles: [\n { name: 'ADMIN', permissions: ['*'] },\n { name: 'ANALYST', permissions: ['data:read', 'data:write'] },\n { name: 'VIEWER', permissions: ['data:read'] },\n ],\n protected_routes: [{ path: '/*', roles: ['VIEWER', 'ANALYST', 'ADMIN'] }],\n public_routes: ['/', '/getting-started'],\n };\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\nasync function addIntegrationToStackwrightYml(\n targetDir: string,\n specName: string,\n specFilename: string,\n mockUrl?: string\n): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content) as Record<string, unknown>;\n\n const integration: Record<string, unknown> = {\n type: 'openapi',\n name: specName,\n spec: `./specs/${specFilename}`,\n collections: [],\n };\n\n if (mockUrl) {\n integration.mockUrl = mockUrl;\n }\n\n config.integrations = [integration];\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n// ---------------------------------------------------------------------------\n// Spec handling (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function handleSpec(\n targetDir: string,\n specPath: string,\n specName?: string\n): Promise<{ specFilename: string; derivedName: string }> {\n const resolvedSpec = path.resolve(specPath);\n\n if (!fs.existsSync(resolvedSpec)) {\n throw new Error(`Spec file not found: ${resolvedSpec}`);\n }\n\n const specFilename = path.basename(resolvedSpec);\n const derivedName = specName || path.basename(specFilename, path.extname(specFilename));\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await fs.copy(resolvedSpec, path.join(specsDir, specFilename));\n\n return { specFilename, derivedName };\n}\n\n// ---------------------------------------------------------------------------\n// README generator (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nfunction generateReadme(options: {\n projectName: string;\n hasSpec: boolean;\n specName?: string;\n specFilename?: string;\n hasOtters: boolean;\n hasMock: boolean;\n}): string {\n const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;\n\n // Build API Integration section if spec is present\n const apiIntegrationSection = hasSpec\n ? `## 📡 API Integration\n\nYour OpenAPI spec was copied to \\`specs/${specFilename}\\` and wired up in \\`stackwright.yml\\`.\n\n**What gets generated:**\n\n\\`\\`\\`typescript\n// src/generated/${specName}/schemas.ts\nexport const EquipmentSchema = z.object({\n id: z.string(),\n name: z.string(),\n status: z.enum(['operational', 'maintenance', 'retired']),\n // ... Zod validation for runtime safety\n});\n\n// src/generated/${specName}/types.ts\nexport type Equipment = z.infer<typeof EquipmentSchema>;\n\n// src/generated/${specName}/client.ts\nexport class ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client {\n async getEquipment(id: string): Promise<Equipment> {\n // Auto-wired with auth, validation, error handling\n }\n}\n\\`\\`\\`\n\n**How it works:**\n1. The \\`predev\\` script in \\`package.json\\` runs \\`prebuild.js\\` before every \\`pnpm dev\\`\n2. Prebuild reads your spec and generates type-safe code\n3. You import and use it:\n\n\\`\\`\\`typescript\nimport { ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client } from '@/generated/${specName}/client';\nimport type { Equipment } from '@/generated/${specName}/types';\n\nconst client = new ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client();\nconst gear: Equipment = await client.getEquipment('123');\n\\`\\`\\`\n\nNo manual typing. No drift. No runtime surprises.\n\n`\n : '';\n\n // Build mock server section if enabled\n const mockSection = hasMock\n ? `## 🎭 Mock Server\n\nPrism mock server is configured to serve your API at **http://localhost:4010**.\n\n\\`\\`\\`bash\npnpm dev:mock # Starts Prism + Next.js together\n\\`\\`\\`\n\nThis starts:\n1. Prism mock server on port 4010 (serves your OpenAPI spec)\n2. Next.js dev server on port 3000\n\nThe generated API client is automatically configured to use the mock server.\n\n`\n : '';\n\n // Build AI Agents section if otters are present\n const aiAgentsSection = hasOtters\n ? `## 🦦 AI Agents (The Otter Raft)\n\nYour project includes **SIX specialized AI agents** in \\`node_modules/@stackwright-pro/otters/\\`:\n\n- \\`stackwright-pro-foreman-otter\\` - Master coordinator that orchestrates all specialist otters\n- \\`stackwright-pro-api-otter\\` - Discovers entities from OpenAPI specs\n- \\`stackwright-pro-auth-otter\\` - Configures CAC/OIDC auth, RBAC rules, and audit middleware\n- \\`stackwright-pro-data-otter\\` - Configures endpoint filters & ISR revalidation\n- \\`stackwright-pro-page-otter\\` - Generates pages auto-wired with data, theme, and auth\n- \\`stackwright-pro-dashboard-otter\\` - Builds live data dashboards\n\n**Start the otter raft:**\n\n\\`\\`\\`bash\nuvx stackwright-pro-raft\n\\`\\`\\`\n\n> **Local dev (before PyPI publish):** \\`python -m stackwright_pro.raft.cli_adapter foreman\\`\n\nThe raft is a Python state machine with a Rich terminal UI — it asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All user interaction happens in the terminal; code-puppy is called as a one-shot subprocess for creative tasks only.\n\n**Example session prompt:**\n\n\"Build me a logistics dashboard from our OpenAPI spec. Connect to /equipment and /supplies endpoints.\"\n\n`\n : '';\n\n return `# ${projectName}\n\nA Stackwright Pro application with role-based auth, OpenAPI integration, and intelligent AI agents.\n\n## 🚀 Quick Start\n\n\\`\\`\\`bash\n# Start development server\npnpm dev\n\n# Open your browser\nopen http://localhost:3000\n\\`\\`\\`\n\n## 👥 Role-Based Development\n\nStackwright Pro includes **mock authentication** for local development with three pre-configured roles:\n\n\\`\\`\\`bash\npnpm dev:admin # Full permissions (*)\npnpm dev:analyst # Read & write data\npnpm dev:viewer # Read-only access\n\\`\\`\\`\n\n**How it works:**\n- Each script sets the \\`MOCK_USER\\` environment variable\n- \\`lib/mock-auth.ts\\` intercepts requests and injects the appropriate user context\n- Your pages & API routes respect the RBAC rules in \\`stackwright.yml\\`\n- No backend required for testing auth flows! 🎉\n\n**Pro tip:** Test your UI for all three roles to ensure proper permissions enforcement.\n\n${mockSection}## 📁 Project Structure\n\n\\`\\`\\`\n.\n├── pages/\n│ ├── _app.tsx # Pro version with AuthProvider + shadcn\n│ ├── index.tsx # Home page (auto-generated by Stackwright)\n│ ├── about/\n│ │ └── content.yml # Page content in YAML\n│ └── ...\n├── lib/\n│ └── mock-auth.ts # Dev-only auth mocking (no backend needed)\n├── scripts/\n│ └── prebuild.js # Auto-generates code from OpenAPI specs\n├── specs/ # OpenAPI spec files (if --spec was used)\n├── src/\n│ └── generated/ # Auto-generated types & clients\n│ └── {specName}/\n│ ├── schemas.ts # Zod schemas for runtime validation\n│ ├── types.ts # TypeScript types\n│ ├── client.ts # API client with auth\n│ └── provider.ts # CollectionProvider for Stackwright\n├── .stackwright/\n│ └── otters/ # AI agent configs (4 specialized otters)\n├── stackwright.yml # Theme, auth, API integrations\n└── package.json\n\\`\\`\\`\n\n**Key Files:**\n- \\`pages/_app.tsx\\` - Wraps your app with \\`AuthProvider\\` for RBAC\n- \\`stackwright.yml\\` - Single source of truth for theme, auth roles, and API wiring\n- \\`lib/mock-auth.ts\\` - Mocks CAC/PIV headers locally so you can test auth flows\n- \\`scripts/prebuild.js\\` - Runs before dev/build to generate types from your OpenAPI spec\n\n## 📄 Adding Pages\n\nStackwright uses **YAML for content**, so you never touch JSX unless you want to.\n\n**Example:** Create \\`pages/about/content.yml\\`:\n\n\\`\\`\\`yaml\ntitle: About Us\ndescription: Learn more about our mission\n\nsections:\n - type: main\n heading: Who We Are\n body: |\n We build mission-critical logistics systems for the Marine Corps.\n\n - type: feature_list\n title: Our Capabilities\n features:\n - icon: Security\n title: Zero Trust\n description: PKI-based auth with CAC/PIV\n - icon: Api\n title: Real-time Data\n description: OpenAPI-backed, Zod-validated\n\\`\\`\\`\n\nThat's it. Navigate to \\`/about\\` and it just works. No routing config, no React components.\n\n${apiIntegrationSection}## 🎨 Customizing Theme\n\nEdit \\`stackwright.yml\\` to change colors, fonts, spacing — applies everywhere instantly.\n\n\\`\\`\\`yaml\ntheme:\n id: my-theme\n name: My Custom Theme\n colors:\n primary: \"#C41E3A\" # Marine Corps red\n background: \"#FFFFFF\"\n text: \"#1A1A1A\"\n accent: \"#FFD700\" # Gold\n typography:\n fontFamily: \"'Inter', sans-serif\"\n h1Size: \"2.5rem\"\n spacing:\n unit: 8\n\\`\\`\\`\n\nNo CSS files. No theme provider boilerplate. Just YAML. Stackwright handles the rest.\n\n## 🔐 Auth Configuration\n\nStackwright Pro comes with **3 pre-configured roles** in \\`stackwright.yml\\`:\n\n\\`\\`\\`yaml\nauth:\n roles:\n - name: ADMIN\n permissions: ['*'] # Full access\n - name: ANALYST \n permissions: ['data:read', 'data:write'] # Read/write data\n - name: VIEWER\n permissions: ['data:read'] # Read-only\n\\`\\`\\`\n\n**Gate content in your YAML:**\n\n\\`\\`\\`yaml\nsections:\n - type: button\n label: Delete Equipment\n action: /api/equipment/delete\n auth:\n required_roles: [ADMIN]\n fallback: hide # Options: hide, disable, show_message\n\\`\\`\\`\n\nOnly admins see the button. Analysts and viewers? Button doesn't exist in the DOM.\n\n**Route protection:**\n\n\\`\\`\\`yaml\nauth:\n protected_routes:\n - path: /admin/*\n roles: [ADMIN]\n - path: /equipment/* \n roles: [ANALYST, ADMIN]\n public_routes:\n - /\n - /about\n\\`\\`\\`\n\nNo middleware to write. No useAuth hooks to remember. RBAC is declarative.\n\n${aiAgentsSection}## 📚 Learn More\n\n- **Stackwright Docs:** [https://stackwright.dev](https://stackwright.dev)\n- **OSS Repo:** [https://github.com/Per-Aspera-LLC/stackwright](https://github.com/Per-Aspera-LLC/stackwright)\n- **Pro Repo:** [https://github.com/Per-Aspera-LLC/stackwright-pro](https://github.com/Per-Aspera-LLC/stackwright-pro)\n\n**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.\n`;\n}\n\n// ---------------------------------------------------------------------------\n// Main launch flow\n// ---------------------------------------------------------------------------\n\nasync function launch(targetDir: string, options: LaunchProOptions): Promise<void> {\n const dirName = path.basename(targetDir);\n\n console.log(chalk.cyan.bold('\\n🚢 Launching Stackwright Pro...\\n'));\n\n // ------------------------------------------------------------------\n // 1. Scaffold base OSS project via @stackwright/cli\n // Hooks auto-handle: Pro deps, MCP config, role-based scripts\n // ------------------------------------------------------------------\n\n const scaffoldOpts: ScaffoldOptions = {\n name: options.name || dirName,\n ...(options.title !== undefined && { title: options.title }),\n ...(options.theme !== undefined && { theme: options.theme }),\n ...(options.force !== undefined && { force: options.force }),\n ...(options.yes !== undefined && { noInteractive: options.yes }),\n };\n\n await scaffold(targetDir, scaffoldOpts);\n console.log(chalk.green('✅ Base project scaffolded (hooks added Pro deps + MCP config)'));\n\n // ------------------------------------------------------------------\n // 1b. Run pnpm install — citizen devs shouldn't need to know this step exists\n // ------------------------------------------------------------------\n\n console.log(chalk.cyan('\\n📦 Installing dependencies (this takes a moment)...'));\n if (!options.skipInstall) {\n try {\n execSync('pnpm install', { cwd: targetDir, stdio: 'inherit', timeout: 120_000 });\n console.log(chalk.green('✅ Dependencies installed'));\n } catch {\n console.warn(chalk.yellow('⚠️ pnpm install failed — run it manually: pnpm install'));\n }\n } else {\n console.log(chalk.dim('ℹ️ Skipping install (--skip-install). Run: pnpm install'));\n }\n\n // Fire postInstall hooks now that install has run\n const dependencyMode: 'workspace' | 'standalone' = 'standalone';\n await runScaffoldHooks('postInstall', {\n targetDir,\n projectName: options.name || path.basename(targetDir),\n siteTitle: options.title || options.name || path.basename(targetDir),\n themeId: options.theme || 'corporate',\n packageJson: {},\n dependencyMode,\n });\n\n // ------------------------------------------------------------------\n // 2. Copy Pro templates (hooks can't handle these)\n // ------------------------------------------------------------------\n\n // Replace _app.tsx with Pro version (AuthProvider, shadcn, etc.)\n await copyProTemplate('_app.tsx', path.join(targetDir, 'pages', '_app.tsx'));\n\n // Add root content.yml for the home page\n await copyProTemplate('content.yml', path.join(targetDir, 'pages', 'content.yml'));\n\n // Replace next.config.js with Pro version (transpile pro pkgs)\n await copyProTemplate('next.config.js', path.join(targetDir, 'next.config.js'));\n\n // Add lib/mock-auth.ts\n await fs.ensureDir(path.join(targetDir, 'lib'));\n await copyProTemplate('mock-auth.ts', path.join(targetDir, 'lib', 'mock-auth.ts'));\n\n // Add yaml.d.ts for TypeScript support\n await copyProTemplate('yaml.d.ts', path.join(targetDir, 'yaml.d.ts'));\n\n // Add scripts/prebuild.js\n await fs.ensureDir(path.join(targetDir, 'scripts'));\n await copyProTemplate('prebuild.js', path.join(targetDir, 'scripts', 'prebuild.js'));\n\n console.log(chalk.green('🔐 Auth integration added (RBAC with 3 roles)'));\n\n // ------------------------------------------------------------------\n // 3. Add auth section to stackwright.yml\n // ------------------------------------------------------------------\n\n await addAuthToStackwrightYml(targetDir);\n\n // ------------------------------------------------------------------\n // 4. Handle --spec if provided\n // ------------------------------------------------------------------\n\n let specInfo: { specFilename: string; derivedName: string } | null = null;\n const MOCK_URL = 'http://localhost:4010';\n\n if (options.spec) {\n specInfo = await handleSpec(targetDir, options.spec, options.specName);\n\n // Pass mockUrl if --mock flag is set\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n options.mock ? MOCK_URL : undefined\n );\n console.log(chalk.green('📡 OpenAPI integration wired up'));\n\n if (options.mock) {\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n } else if (options.mock) {\n // --mock without --spec: use sample Petstore spec for demo\n console.log(\n chalk.yellow(\n '⚠️ No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec.'\n )\n );\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await copyProTemplate('petstore.yaml', path.join(specsDir, 'petstore.yaml'));\n\n specInfo = { specFilename: 'petstore.yaml', derivedName: 'petstore' };\n\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n MOCK_URL\n );\n console.log(chalk.green('📡 Sample Petstore spec wired up'));\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n\n // ------------------------------------------------------------------\n // 5. Generate README\n // ------------------------------------------------------------------\n\n const readmeContent = generateReadme({\n projectName: options.name || dirName,\n hasSpec: !!specInfo,\n ...(specInfo?.derivedName !== undefined && { specName: specInfo.derivedName }),\n ...(specInfo?.specFilename !== undefined && { specFilename: specInfo.specFilename }),\n hasOtters: !options.skipOtters,\n hasMock: !!options.mock,\n });\n\n await fs.writeFile(path.join(targetDir, 'README.md'), readmeContent);\n console.log(chalk.green('📄 README.md created'));\n\n // ------------------------------------------------------------------\n // 6. Print next steps\n // ------------------------------------------------------------------\n\n const relDir = path.relative(process.cwd(), targetDir) || '.';\n\n console.log(chalk.cyan.bold(\"\\n🎉 All set! Here's what to do next:\\n\"));\n console.log(chalk.white(` 1. cd ${relDir}`));\n console.log(chalk.white(' 2. uvx stackwright-pro-raft'));\n console.log(chalk.dim(' (local dev: python -m stackwright_pro.raft.cli_adapter foreman)'));\n\n if (specInfo) {\n console.log(chalk.cyan(`\\n📡 Your API spec was copied to specs/${specInfo.specFilename}`));\n console.log(chalk.dim(' The prebuild will generate types & client on first `pnpm dev`.'));\n }\n\n if (options.mock) {\n console.log(chalk.cyan('\\n🎭 Run with mock server:'));\n console.log(chalk.white(' pnpm dev:mock # Starts Prism + Next.js'));\n }\n\n if (!options.skipOtters) {\n console.log(chalk.cyan.bold('\\n🦦 The otter raft is ready to build your site!'));\n console.log(chalk.dim(' Run the command above to get started.\\n'));\n }\n}\n\n// ---------------------------------------------------------------------------\n// CLI definition\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n const program = new Command();\n\n program\n .name('launch-stackwright-pro')\n .description('🚢 Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft')\n .version(version)\n .argument('[directory]', 'Project directory', '.')\n .option('--name <name>', 'Project name (used in package.json)')\n .option('--title <title>', 'Site title shown in the app bar and browser tab')\n .option('--theme <themeId>', 'Theme ID (e.g., corporate, creative, minimal)')\n .option('--force', 'Launch even if the target directory is not empty')\n .option('--skip-otters', 'Skip copying otter raft configs')\n .option('-y, --yes', 'Skip all prompts, use defaults')\n .option('--mock', 'Configure Prism mock server for API development (runs on port 4010)')\n .option(\n '--spec <path>',\n 'Path to an OpenAPI spec (YAML or JSON) — copies into project and wires up integration'\n )\n .option(\n '--spec-name <name>',\n 'Name for the API integration (default: derived from spec filename)'\n )\n .option(\n '--skip-install',\n 'Skip automatic pnpm install (useful in CI or when using a different package manager)'\n )\n .action(async (directory: string, options: LaunchProOptions) => {\n const homeDir = os.homedir();\n const targetDir = path.resolve(directory);\n\n // Warn (don't block) when scaffolding outside home dir — unusual for a user-facing CLI\n if (!targetDir.startsWith(homeDir + path.sep) && targetDir !== homeDir) {\n console.warn(chalk.yellow(`⚠️ Scaffolding outside your home directory: ${targetDir}`));\n }\n\n await launch(targetDir, options);\n });\n\n await program.parseAsync(process.argv);\n}\n\nmain().catch((err: unknown) => {\n console.error(chalk.red('\\n❌ Launch failed:'), err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,SAAW;AAAA,MACX,eAAiB;AAAA,QACf,QAAU;AAAA,MACZ;AAAA,MACA,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,MACA,KAAO;AAAA,QACL,0BAA0B;AAAA,MAC5B;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,iBAAiB;AAAA,MACnB;AAAA,MACA,cAAgB;AAAA,QACd,mCAAmC;AAAA,QACnC,oBAAoB;AAAA,QACpB,8BAA8B;AAAA,QAC9B,OAAS;AAAA,QACT,WAAa;AAAA,QACb,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA,iBAAmB;AAAA,QACjB,mBAAmB;AAAA,QACnB,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,YAAc;A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,UAAM,YAAY,YAAAJ,QAAK,QAAQ,SAAS;AAGxC,QAAI,CAAC,UAAU,WAAW,UAAU,YAAAA,QAAK,GAAG,KAAK,cAAc,SAAS;AACtE,cAAQ,KAAK,aAAAG,QAAM,OAAO,0DAAgD,SAAS,EAAE,CAAC;AAAA,IACxF;AAEA,UAAM,OAAO,WAAW,OAAO;AAAA,EACjC,CAAC;AAEH,QAAM,QAAQ,WAAW,QAAQ,IAAI;AACvC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,aAAAA,QAAM,IAAI,yBAAoB,GAAG,GAAG;AAClD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["exports","module","path","fs","yaml","chalk","os"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/index.ts","../src/scaffold.ts","../src/generated/workspace-versions.ts"],"sourcesContent":["{\n \"name\": \"@stackwright-pro/launch-stackwright-pro\",\n \"version\": \"0.4.0-alpha.74\",\n \"description\": \"Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Per-Aspera-LLC/stackwright-pro\"\n },\n \"keywords\": [\n \"stackwright\",\n \"stackwright-pro\",\n \"scaffolding\",\n \"openapi\",\n \"government\",\n \"hackathon\"\n ],\n \"files\": [\n \"dist\",\n \"templates\"\n ],\n \"bin\": {\n \"launch-stackwright-pro\": \"dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"node ../../scripts/sync-versions.mjs && tsup\",\n \"sync-versions\": \"node ../../scripts/sync-versions.mjs\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@stackwright-pro/auth\": \"workspace:*\",\n \"@stackwright-pro/auth-nextjs\": \"workspace:*\",\n \"@stackwright-pro/mcp\": \"workspace:*\",\n \"@stackwright-pro/openapi\": \"workspace:*\",\n \"@stackwright-pro/otters\": \"workspace:*\",\n \"@stackwright-pro/scaffold-hooks\": \"latest\",\n \"@stackwright/cli\": \"^0.8.6\",\n \"@stackwright/scaffold-core\": \"^0.3.1\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^15.0.0\",\n \"fs-extra\": \"^11.3.5\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"catalog:\",\n \"typescript\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import { Command } from 'commander';\nimport path from 'path';\nimport os from 'os';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport { execSync } from 'child_process';\n\nimport { scaffold, ScaffoldOptions } from '@stackwright/cli';\nimport { runScaffoldHooks } from '@stackwright/scaffold-core';\nimport { registerProScaffoldHooks } from '@stackwright-pro/scaffold-hooks';\nimport {\n addProDepsToPackageJson,\n addAuthToStackwrightYml,\n scaffoldWorkspaceConfig,\n addIntegrationToStackwrightYml,\n generateReadme,\n} from './scaffold.js';\n// Register Pro hooks (adds deps, MCP config, etc.)\n// Must be called before scaffold() to ensure hooks run in the CLI's scaffold-core context\nregisterProScaffoldHooks();\n\nconst { version } = require('../package.json') as { version: string };\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface LaunchProOptions {\n name?: string;\n title?: string;\n theme?: string;\n force?: boolean;\n skipOtters?: boolean;\n skipInstall?: boolean;\n yes?: boolean;\n spec?: string[];\n specName?: string;\n mock?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Template copying (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function copyProTemplate(templateName: string, destPath: string): Promise<void> {\n const src = path.resolve(__dirname, '..', 'templates', 'pro', templateName);\n await fs.copy(src, destPath);\n}\n\n// ---------------------------------------------------------------------------\n// Spec handling (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function handleSpec(\n targetDir: string,\n specPath: string,\n specName?: string\n): Promise<{ specFilename: string; derivedName: string }> {\n const resolvedSpec = path.resolve(specPath);\n\n if (!fs.existsSync(resolvedSpec)) {\n throw new Error(`Spec file not found: ${resolvedSpec}`);\n }\n\n const specFilename = path.basename(resolvedSpec);\n const derivedName = specName || path.basename(specFilename, path.extname(specFilename));\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await fs.copy(resolvedSpec, path.join(specsDir, specFilename));\n\n return { specFilename, derivedName };\n}\n\n// ---------------------------------------------------------------------------\n// Main launch flow\n// ---------------------------------------------------------------------------\n\nasync function launch(targetDir: string, options: LaunchProOptions): Promise<void> {\n const dirName = path.basename(targetDir);\n\n console.log(chalk.cyan.bold('\\n🚢 Launching Stackwright Pro...\\n'));\n\n // ------------------------------------------------------------------\n // 1. Scaffold base OSS project via @stackwright/cli\n // Hooks auto-handle: Pro deps, MCP config, role-based scripts\n // ------------------------------------------------------------------\n\n const scaffoldOpts: ScaffoldOptions = {\n name: options.name || dirName,\n standalone: true, // prevents `workspace:*` refs when CLI runs inside the Pro monorepo\n ...(options.title !== undefined && { title: options.title }),\n ...(options.theme !== undefined && { theme: options.theme }),\n ...(options.force !== undefined && { force: options.force }),\n ...(options.yes !== undefined && { noInteractive: options.yes }),\n };\n\n await scaffold(targetDir, scaffoldOpts);\n console.log(chalk.green('✅ Base project scaffolded (hooks added Pro deps + MCP config)'));\n\n // ------------------------------------------------------------------\n // 1b. Run pnpm install — citizen devs shouldn't need to know this step exists\n // ------------------------------------------------------------------\n\n // Patch Pro packages directly into package.json before install.\n // This bypasses the scaffold hooks system (which has a known version-resolution\n // issue) and guarantees pro deps land regardless of hook execution order.\n await addProDepsToPackageJson(targetDir);\n console.log(chalk.green('🦦 Pro packages added to package.json'));\n\n // Verify package.json has Pro deps before installing\n const verifyPkg = JSON.parse(\n await fs.readFile(path.join(targetDir, 'package.json'), 'utf-8')\n ) as Record<string, unknown>;\n const proDepCount = Object.keys(\n typeof verifyPkg.dependencies === 'object' && verifyPkg.dependencies !== null\n ? (verifyPkg.dependencies as Record<string, string>)\n : {}\n ).filter((k) => k.startsWith('@stackwright-pro')).length;\n console.log(chalk.dim(` → package.json verified: ${proDepCount} @stackwright-pro/* deps ready`));\n\n console.log(chalk.cyan('\\n📦 Installing dependencies (this takes a moment)...'));\n if (!options.skipInstall) {\n try {\n execSync('pnpm install --ignore-workspace', {\n cwd: targetDir,\n stdio: 'inherit',\n timeout: 120_000,\n });\n console.log(chalk.green('✅ Dependencies installed'));\n } catch (err: unknown) {\n const isTimeout =\n err instanceof Error &&\n (err.message.includes('ETIMEDOUT') || err.message.includes('timeout'));\n console.error(\n chalk.red('\\n❌ pnpm install failed. Auth and Pro packages are NOT installed.')\n );\n console.error(\n chalk.red(' Your project is in an incomplete state — do NOT run or deploy it.')\n );\n if (isTimeout) {\n console.error(\n chalk.yellow(' The install timed out (>2 min). Check your network connection.')\n );\n }\n console.error(\n chalk.yellow(` Fix the error above, then run: pnpm install --ignore-workspace`)\n );\n process.exit(1);\n }\n } else {\n console.log(chalk.dim('ℹ️ Skipping install (--skip-install). Run: pnpm install'));\n }\n\n // Fire postInstall hooks now that install has run\n const dependencyMode: 'workspace' | 'standalone' = 'standalone';\n await runScaffoldHooks('postInstall', {\n targetDir,\n projectName: options.name || path.basename(targetDir),\n siteTitle: options.title || options.name || path.basename(targetDir),\n themeId: options.theme || 'corporate',\n packageJson: {},\n dependencyMode,\n });\n\n // ------------------------------------------------------------------\n // 2. Copy Pro templates (hooks can't handle these)\n // ------------------------------------------------------------------\n\n // Replace _app.tsx with Pro version (AuthProvider, shadcn, etc.)\n await copyProTemplate('_app.tsx', path.join(targetDir, 'pages', '_app.tsx'));\n\n // Add root content.yml for the home page\n await copyProTemplate('content.yml', path.join(targetDir, 'pages', 'content.yml'));\n\n // Replace next.config.js with Pro version (transpile pro pkgs)\n await copyProTemplate('next.config.js', path.join(targetDir, 'next.config.js'));\n\n // Add lib/mock-auth.ts\n await fs.ensureDir(path.join(targetDir, 'lib'));\n await copyProTemplate('mock-auth.ts', path.join(targetDir, 'lib', 'mock-auth.ts'));\n\n // Add yaml.d.ts for TypeScript support\n await copyProTemplate('yaml.d.ts', path.join(targetDir, 'yaml.d.ts'));\n\n // Add scripts/prebuild.js + scripts/pro-content-plugin.js\n await fs.ensureDir(path.join(targetDir, 'scripts'));\n await copyProTemplate('prebuild.js', path.join(targetDir, 'scripts', 'prebuild.js'));\n await copyProTemplate(\n 'scripts/pro-content-plugin.js',\n path.join(targetDir, 'scripts', 'pro-content-plugin.js')\n );\n\n console.log(chalk.green('🔐 Auth integration added (RBAC with 3 roles)'));\n\n // ------------------------------------------------------------------\n // 3. Add auth section to stackwright.yml\n // ------------------------------------------------------------------\n\n await addAuthToStackwrightYml(targetDir);\n\n // ------------------------------------------------------------------\n // 4. Handle --spec if provided\n // ------------------------------------------------------------------\n\n let specInfo: { specFilename: string; derivedName: string } | null = null;\n const MOCK_URL = 'http://localhost:4010';\n\n if (options.spec && options.spec.length > 0) {\n for (const specPath of options.spec) {\n specInfo = await handleSpec(targetDir, specPath, options.specName);\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n options.mock ? MOCK_URL : undefined\n );\n }\n console.log(chalk.green(`📡 ${options.spec.length} OpenAPI integration(s) wired up`));\n if (options.mock) {\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n } else if (options.mock) {\n // --mock without --spec: use sample Petstore spec for demo\n console.log(\n chalk.yellow(\n '⚠️ No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec.'\n )\n );\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await copyProTemplate('petstore.yaml', path.join(specsDir, 'petstore.yaml'));\n\n specInfo = { specFilename: 'petstore.yaml', derivedName: 'petstore' };\n\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n MOCK_URL\n );\n console.log(chalk.green('📡 Sample Petstore spec wired up'));\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n\n // ------------------------------------------------------------------\n // 5. Generate README\n // ------------------------------------------------------------------\n\n const readmeContent = generateReadme({\n projectName: options.name || dirName,\n hasSpec: !!specInfo,\n ...(specInfo?.derivedName !== undefined && { specName: specInfo.derivedName }),\n ...(specInfo?.specFilename !== undefined && { specFilename: specInfo.specFilename }),\n hasOtters: !options.skipOtters,\n hasMock: !!options.mock,\n });\n\n await fs.writeFile(path.join(targetDir, 'README.md'), readmeContent);\n console.log(chalk.green('📄 README.md created'));\n\n // ------------------------------------------------------------------\n // 5b. Write init-context.json for raft launcher\n // ------------------------------------------------------------------\n\n const initContext: Record<string, unknown> = {\n projectRoot: targetDir,\n projectName: options.name || dirName,\n generatedBy: 'launch-stackwright-pro',\n version: '1.0',\n };\n\n if (specInfo) {\n initContext.specPath = `specs/${specInfo.specFilename}`;\n initContext.specName = specInfo.derivedName;\n }\n\n initContext.theme = options.theme || 'corporate';\n\n const stackwrightDir = path.join(targetDir, '.stackwright');\n await fs.ensureDir(stackwrightDir);\n await fs.writeFile(\n path.join(stackwrightDir, 'init-context.json'),\n JSON.stringify(initContext, null, 2) + '\\n',\n 'utf-8'\n );\n\n // ------------------------------------------------------------------\n // 5c. Scaffold .code-puppy/ workspace directory\n // Creates config.json (projectOnly: true), mcp_servers.json,\n // and agents/ dir. raft-puppy discovers this via walk-up from cwd\n // on first startup — no CLI flags needed.\n // ------------------------------------------------------------------\n\n await scaffoldWorkspaceConfig(targetDir);\n console.log(chalk.green('🐾 .code-puppy/ workspace scaffolded (projectOnly: true)'));\n\n // ------------------------------------------------------------------\n // 6. Print next steps\n // ------------------------------------------------------------------\n\n const relDir = path.relative(process.cwd(), targetDir) || '.';\n\n console.log(chalk.cyan.bold(\"\\n🎉 All set! Here's what to do next:\\n\"));\n console.log(chalk.white(` 1. cd ${relDir}`));\n console.log(chalk.white(' 2. npx @stackwright-pro/raft'));\n console.log(chalk.dim(' (use --verbose for troubleshooting)'));\n\n if (specInfo) {\n console.log(chalk.cyan(`\\n📡 Your API spec was copied to specs/${specInfo.specFilename}`));\n console.log(chalk.dim(' The prebuild will generate types & client on first `pnpm dev`.'));\n }\n\n if (options.mock) {\n console.log(chalk.cyan('\\n🎭 Run with mock server:'));\n console.log(chalk.white(' pnpm dev:mock # Starts Prism + Next.js'));\n }\n\n if (!options.skipOtters) {\n console.log(chalk.cyan.bold('\\n🦦 The otter raft is ready to build your site!'));\n console.log(chalk.dim(' Run the command above to get started.\\n'));\n }\n}\n\n// ---------------------------------------------------------------------------\n// CLI definition\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n const program = new Command();\n\n program\n .name('launch-stackwright-pro')\n .description('🚢 Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft')\n .version(version)\n .argument('[directory]', 'Project directory', '.')\n .option('--name <name>', 'Project name (used in package.json)')\n .option('--title <title>', 'Site title shown in the app bar and browser tab')\n .option('--theme <themeId>', 'Theme ID (e.g., corporate, creative, minimal)')\n .option('--force', 'Launch even if the target directory is not empty')\n .option('--skip-otters', 'Skip copying otter raft configs')\n .option('-y, --yes', 'Skip all prompts, use defaults')\n .option('--mock', 'Configure Prism mock server for API development (runs on port 4010)')\n .option(\n '--spec <paths...>',\n 'Paths to OpenAPI specs (YAML or JSON) — copies into project and wires up integrations (can be specified multiple times)'\n )\n .option(\n '--spec-name <name>',\n 'Name for the API integration (default: derived from spec filename)'\n )\n .option(\n '--skip-install',\n 'Skip automatic pnpm install (useful in CI or when using a different package manager)'\n )\n .action(async (directory: string, options: LaunchProOptions) => {\n const homeDir = os.homedir();\n const targetDir =\n directory !== '.'\n ? path.resolve(process.cwd(), directory)\n : options.name\n ? path.resolve(process.cwd(), options.name)\n : process.cwd(); // last resort — same as old behaviour, only hit if neither arg nor --name\n\n // Warn (don't block) when scaffolding outside home dir — unusual for a user-facing CLI\n if (!targetDir.startsWith(homeDir + path.sep) && targetDir !== homeDir) {\n console.warn(chalk.yellow(`⚠️ Scaffolding outside your home directory: ${targetDir}`));\n }\n\n await launch(targetDir, options);\n });\n\n await program.parseAsync(process.argv);\n}\n\nmain().catch((err: unknown) => {\n console.error(chalk.red('\\n❌ Launch failed:'), err);\n process.exit(1);\n});\n","/**\n * scaffold.ts — Pro-specific scaffold mutation helpers\n *\n * Extracted from src/index.ts so these pure filesystem transforms can be\n * imported and tested independently (no __dirname, no fs.copy, no chalk).\n *\n * Every function here:\n * - Accepts a targetDir and operates on real files\n * - Is async/await throughout\n * - Has no side effects beyond writing to targetDir\n * - Is fully unit-testable with a real temp filesystem\n */\n\nimport fs from 'fs-extra';\nimport yaml from 'js-yaml';\nimport path from 'path';\nimport { PRO_VERSIONS, OSS_VERSIONS } from './generated/workspace-versions.js';\n\n// ---------------------------------------------------------------------------\n// Package.json mutations\n// ---------------------------------------------------------------------------\n\n/**\n * Inject Pro runtime dependencies and scripts into an existing package.json.\n * Enforces OSS version floors and adds Pro-specific dev scripts (prebuild/predev).\n * Safe to call multiple times — idempotent for dep keys.\n */\nexport async function addProDepsToPackageJson(targetDir: string): Promise<void> {\n const pkgPath = path.join(targetDir, 'package.json');\n const content = await fs.readFile(pkgPath, 'utf-8');\n const pkg = JSON.parse(content) as Record<string, unknown>;\n\n const dependencies: Record<string, string> =\n typeof pkg.dependencies === 'object' && pkg.dependencies !== null\n ? { ...(pkg.dependencies as Record<string, string>) }\n : {};\n const devDependencies: Record<string, string> =\n typeof pkg.devDependencies === 'object' && pkg.devDependencies !== null\n ? { ...(pkg.devDependencies as Record<string, string>) }\n : {};\n const scripts: Record<string, string> =\n typeof pkg.scripts === 'object' && pkg.scripts !== null\n ? { ...(pkg.scripts as Record<string, string>) }\n : {};\n\n // Enforce OSS version floors — replace workspace:* refs AND upgrade any stale version\n // pinned by the OSS scaffold template to our tested minimum.\n // OSS_VERSIONS = \"minimum tested versions\" — we always want them to win.\n for (const [pkgName, pinnedVersion] of Object.entries(OSS_VERSIONS)) {\n if (pkgName in dependencies) {\n dependencies[pkgName] = pinnedVersion;\n }\n if (pkgName in devDependencies) {\n devDependencies[pkgName] = pinnedVersion;\n }\n }\n\n // Pro runtime dependencies — exact versions from workspace at build time\n Object.assign(dependencies, {\n '@stackwright-pro/display-components': PRO_VERSIONS['@stackwright-pro/display-components'],\n '@stackwright-pro/mcp': PRO_VERSIONS['@stackwright-pro/mcp'],\n '@stackwright-pro/otters': PRO_VERSIONS['@stackwright-pro/otters'],\n '@stackwright-pro/openapi': PRO_VERSIONS['@stackwright-pro/openapi'],\n '@stackwright-pro/auth': PRO_VERSIONS['@stackwright-pro/auth'],\n '@stackwright-pro/auth-nextjs': PRO_VERSIONS['@stackwright-pro/auth-nextjs'],\n '@stackwright-pro/pulse': PRO_VERSIONS['@stackwright-pro/pulse'],\n '@stackwright-pro/workflow-components': PRO_VERSIONS['@stackwright-pro/workflow-components'],\n '@stackwright-pro/workflow': PRO_VERSIONS['@stackwright-pro/workflow'],\n '@stackwright/build-scripts': OSS_VERSIONS['@stackwright/build-scripts'],\n zod: '^4.0.0',\n });\n\n // Pro dev dependencies\n Object.assign(devDependencies, {\n '@stoplight/prism-cli': '^5.14.2',\n });\n\n // Role-based dev scripts\n Object.assign(scripts, {\n 'dev:admin': 'MOCK_USER=admin next dev',\n 'dev:analyst': 'MOCK_USER=analyst next dev',\n 'dev:viewer': 'MOCK_USER=viewer next dev',\n prebuild: 'node scripts/prebuild.js',\n predev: 'node scripts/prebuild.js',\n });\n\n pkg.dependencies = dependencies;\n pkg.devDependencies = devDependencies;\n pkg.scripts = scripts;\n\n await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\\n', 'utf-8');\n}\n\n// ---------------------------------------------------------------------------\n// stackwright.yml mutations\n// ---------------------------------------------------------------------------\n\n/**\n * Add an empty `auth:` key to an existing stackwright.yml.\n * The auth key is the hook point for Pro RBAC configuration.\n */\nexport async function addAuthToStackwrightYml(targetDir: string): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content, { schema: yaml.CORE_SCHEMA }) as Record<string, unknown>;\n\n config.auth = {};\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n/**\n * Append an OpenAPI integration entry to the `integrations:` array in stackwright.yml.\n * Creates the array if it does not exist. Safe to call multiple times for different specs.\n */\nexport async function addIntegrationToStackwrightYml(\n targetDir: string,\n specName: string,\n specFilename: string,\n mockUrl?: string\n): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content, { schema: yaml.CORE_SCHEMA }) as Record<string, unknown>;\n\n const integration: Record<string, unknown> = {\n type: 'openapi',\n name: specName,\n spec: `./specs/${specFilename}`,\n collections: [],\n };\n\n if (mockUrl) {\n integration.mockUrl = mockUrl;\n }\n\n config.integrations = [\n ...(Array.isArray(config.integrations) ? config.integrations : []),\n integration,\n ];\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n// ---------------------------------------------------------------------------\n// .code-puppy/ workspace config scaffolding\n// ---------------------------------------------------------------------------\n\n/**\n * Create (or idempotently update) the .code-puppy/ workspace directory.\n *\n * Creates:\n * - .code-puppy/config.json { projectOnly: true } (merges with existing)\n * - .code-puppy/mcp_servers.json stackwright-pro-mcp stdio server entry\n * - .code-puppy/agents/ empty directory for future agent configs\n *\n * Symlink guard: refuses to write if any of the managed paths is a symlink,\n * consistent with raft/src/lib.ts ensureWorkspaceConfig.\n */\nexport async function scaffoldWorkspaceConfig(targetDir: string): Promise<void> {\n const workspaceDir = path.join(targetDir, '.code-puppy');\n await fs.ensureDir(workspaceDir);\n // Symlink guard — consistent with raft/src/lib.ts ensureWorkspaceConfig\n const workspaceStats = await fs.lstat(workspaceDir);\n if (workspaceStats.isSymbolicLink()) {\n throw new Error('.code-puppy/ is a symlink — refusing to write. Check for tampering.');\n }\n\n const agentsDir = path.join(workspaceDir, 'agents');\n await fs.ensureDir(agentsDir);\n if (await fs.pathExists(agentsDir)) {\n const agentsStats = await fs.lstat(agentsDir);\n if (agentsStats.isSymbolicLink()) {\n throw new Error('.code-puppy/agents is a symlink — refusing to write. Check for tampering.');\n }\n }\n\n // config.json — projectOnly: true\n // Merge with existing so we don't clobber user customizations on re-scaffold\n const configPath = path.join(workspaceDir, 'config.json');\n let existingConfig: Record<string, unknown> = {};\n if (fs.existsSync(configPath)) {\n try {\n existingConfig = JSON.parse(await fs.readFile(configPath, 'utf-8')) as Record<\n string,\n unknown\n >;\n } catch {\n // Malformed — start fresh\n }\n }\n if (await fs.pathExists(configPath)) {\n const configStats = await fs.lstat(configPath);\n if (configStats.isSymbolicLink()) {\n throw new Error(\n '.code-puppy/config.json is a symlink — refusing to write. Check for tampering.'\n );\n }\n }\n await fs.writeFile(\n configPath,\n JSON.stringify({ ...existingConfig, projectOnly: true }, null, 2) + '\\n',\n 'utf-8'\n );\n\n // mcp_servers.json — pnpm-based stackwright-pro-mcp server\n // ${PROJECT_ROOT} is a literal — raft-puppy expands it at runtime to the\n // directory containing .code-puppy/ (walk-up discovery root).\n const mcpServersPath = path.join(workspaceDir, 'mcp_servers.json');\n if (await fs.pathExists(mcpServersPath)) {\n const mcpStats = await fs.lstat(mcpServersPath);\n if (mcpStats.isSymbolicLink()) {\n throw new Error(\n '.code-puppy/mcp_servers.json is a symlink — refusing to write. Check for tampering.'\n );\n }\n }\n if (!fs.existsSync(mcpServersPath)) {\n const mcpConfig = {\n mcp_servers: {\n 'stackwright-pro-mcp': {\n type: 'stdio',\n command: 'pnpm',\n args: ['exec', 'stackwright-pro-mcp'],\n enabled: true,\n cwd: '${PROJECT_ROOT}',\n },\n },\n };\n await fs.writeFile(mcpServersPath, JSON.stringify(mcpConfig, null, 2) + '\\n', 'utf-8');\n }\n}\n\n// ---------------------------------------------------------------------------\n// README generation\n// ---------------------------------------------------------------------------\n\nexport interface GenerateReadmeOptions {\n projectName: string;\n hasSpec: boolean;\n specName?: string;\n specFilename?: string;\n hasOtters: boolean;\n hasMock: boolean;\n}\n\n/**\n * Generate a project README.md with conditional sections based on which\n * Pro features are enabled (spec, mock server, otter raft).\n */\nexport function generateReadme(options: GenerateReadmeOptions): string {\n const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;\n\n // Build API Integration section if spec is present\n const apiIntegrationSection = hasSpec\n ? `## 📡 API Integration\\n\\nYour OpenAPI spec was copied to \\`specs/${specFilename}\\` and wired up in \\`stackwright.yml\\`.\\n\\n**What gets generated:**\\n\\n\\`\\`\\`typescript\\n// src/generated/${specName}/schemas.ts\\nexport const EquipmentSchema = z.object({\\n id: z.string(),\\n name: z.string(),\\n status: z.enum(['operational', 'maintenance', 'retired']),\\n // ... Zod validation for runtime safety\\n});\\n\\n// src/generated/${specName}/types.ts\\nexport type Equipment = z.infer<typeof EquipmentSchema>;\\n\\n// src/generated/${specName}/client.ts\\nexport class ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client {\\n async getEquipment(id: string): Promise<Equipment> {\\n // Auto-wired with auth, validation, error handling\\n }\\n}\\n\\`\\`\\`\\n\\n**How it works:**\\n1. The \\`predev\\` script in \\`package.json\\` runs \\`prebuild.js\\` before every \\`pnpm dev\\`\\n2. Prebuild reads your spec and generates type-safe code\\n3. You import and use it:\\n\\n\\`\\`\\`typescript\\nimport { ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client } from '@/generated/${specName}/client';\\nimport type { Equipment } from '@/generated/${specName}/types';\\n\\nconst client = new ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client();\\nconst gear: Equipment = await client.getEquipment('123');\\n\\`\\`\\`\\n\\nNo manual typing. No drift. No runtime surprises.\\n\\n`\n : '';\n\n // Build mock server section if enabled\n const mockSection = hasMock\n ? `## 🎭 Mock Server\\n\\nPrism mock server is configured to serve your API at **http://localhost:4010**.\\n\\n\\`\\`\\`bash\\npnpm dev:mock # Starts Prism + Next.js together\\n\\`\\`\\`\\n\\nThis starts:\\n1. Prism mock server on port 4010 (serves your OpenAPI spec)\\n2. Next.js dev server on port 3000\\n\\nThe generated API client is automatically configured to use the mock server.\\n\\n`\n : '';\n\n // Build AI Agents section if otters are present\n const aiAgentsSection = hasOtters\n ? `## 🦦 AI Agents (The Otter Raft)\\n\\nYour project includes **SIX specialized AI agents** in \\`node_modules/@stackwright-pro/otters/\\`:\\n\\n- \\`stackwright-pro-foreman-otter\\` - Master coordinator that orchestrates all specialist otters\\n- \\`stackwright-pro-api-otter\\` - Discovers entities from OpenAPI specs\\n- \\`stackwright-pro-auth-otter\\` - Configures CAC/OIDC auth, RBAC rules, and audit middleware\\n- \\`stackwright-pro-data-otter\\` - Configures endpoint filters & ISR revalidation\\n- \\`stackwright-pro-page-otter\\` - Generates pages auto-wired with data, theme, and auth\\n- \\`stackwright-pro-dashboard-otter\\` - Builds live data dashboards\\n\\n**Start the otter raft:**\\n\\n\\`\\`\\`bash\\nnpx @stackwright-pro/raft\\n\\`\\`\\`\\n\\nThe raft verifies otter integrity, writes project context, and spawns code-puppy in foreman mode. The foreman asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All state lives in \\`.stackwright/\\` — interrupt and resume anytime.\\n\\n**Example session prompt:**\\n\\n\"Build me a logistics dashboard from our OpenAPI spec. Connect to /equipment and /supplies endpoints.\"\\n\\n`\n : '';\n\n return `# ${projectName}\\n\\nA Stackwright Pro application with role-based auth, OpenAPI integration, and intelligent AI agents.\\n\\n## 🚀 Quick Start\\n\\n\\`\\`\\`bash\\n# Start development server\\npnpm dev\\n\\n# Open your browser\\nopen http://localhost:3000\\n\\`\\`\\`\\n\\n## 👥 Role-Based Development\\n\\nStackwright Pro includes **mock authentication** for local development with three pre-configured roles:\\n\\n\\`\\`\\`bash\\npnpm dev:admin # Full permissions (*)\\npnpm dev:analyst # Read & write data\\npnpm dev:viewer # Read-only access\\n\\`\\`\\`\\n\\n**How it works:**\\n- Each script sets the \\`MOCK_USER\\` environment variable\\n- \\`lib/mock-auth.ts\\` intercepts requests and injects the appropriate user context\\n- Your pages & API routes respect the RBAC rules in \\`stackwright.yml\\`\\n- No backend required for testing auth flows! 🎉\\n\\n**Pro tip:** Test your UI for all three roles to ensure proper permissions enforcement.\\n\\n${mockSection}## 📁 Project Structure\\n\\n\\`\\`\\`\\n.\\n├── pages/\\n│ ├── _app.tsx # Pro version with AuthProvider + shadcn\\n│ ├── index.tsx # Home page (auto-generated by Stackwright)\\n│ ├── about/\\n│ │ └── content.yml # Page content in YAML\\n│ └── ...\\n├── lib/\\n│ └── mock-auth.ts # Dev-only auth mocking (no backend needed)\\n├── scripts/\\n│ └── prebuild.js # Auto-generates code from OpenAPI specs\\n├── specs/ # OpenAPI spec files (if --spec was used)\\n├── src/\\n│ └── generated/ # Auto-generated types & clients\\n│ └── {specName}/\\n│ ├── schemas.ts # Zod schemas for runtime validation\\n│ ├── types.ts # TypeScript types\\n│ ├── client.ts # API client with auth\\n│ └── provider.ts # CollectionProvider for Stackwright\\n├── .stackwright/\\n│ └── otters/ # AI agent configs (4 specialized otters)\\n├── stackwright.yml # Theme, auth, API integrations\\n└── package.json\\n\\`\\`\\`\\n\\n**Key Files:**\\n- \\`pages/_app.tsx\\` - Wraps your app with \\`AuthProvider\\` for RBAC\\n- \\`stackwright.yml\\` - Single source of truth for theme, auth roles, and API wiring\\n- \\`lib/mock-auth.ts\\` - Mocks CAC/PIV headers locally so you can test auth flows\\n- \\`scripts/prebuild.js\\` - Runs before dev/build to generate types from your OpenAPI spec\\n\\n## 📄 Adding Pages\\n\\nStackwright uses **YAML for content**, so you never touch JSX unless you want to.\\n\\n**Example:** Create \\`pages/about/content.yml\\`:\\n\\n\\`\\`\\`yaml\\ntitle: About Us\\ndescription: Learn more about our mission\\n\\nsections:\\n - type: main\\n heading: Who We Are\\n body: |\\n We build mission-critical logistics systems for the Marine Corps.\\n\\n - type: feature_list\\n title: Our Capabilities\\n features:\\n - icon: Security\\n title: Zero Trust\\n description: PKI-based auth with CAC/PIV\\n - icon: Api\\n title: Real-time Data\\n description: OpenAPI-backed, Zod-validated\\n\\`\\`\\`\\n\\nThat's it. Navigate to \\`/about\\` and it just works. No routing config, no React components.\\n\\n${apiIntegrationSection}## 🎨 Customizing Theme\\n\\nEdit \\`stackwright.yml\\` to change colors, fonts, spacing — applies everywhere instantly.\\n\\n\\`\\`\\`yaml\\ntheme:\\n id: my-theme\\n name: My Custom Theme\\n colors:\\n primary: \"#C41E3A\" # Marine Corps red\\n background: \"#FFFFFF\"\\n text: \"#1A1A1A\"\\n accent: \"#FFD700\" # Gold\\n typography:\\n fontFamily: \"'Inter', sans-serif\"\\n h1Size: \"2.5rem\"\\n spacing:\\n unit: 8\\n\\`\\`\\`\\n\\nNo CSS files. No theme provider boilerplate. Just YAML. Stackwright handles the rest.\\n\\n## 🔐 Auth Configuration\\n\\nStackwright Pro comes with **3 pre-configured roles** in \\`stackwright.yml\\`:\\n\\n\\`\\`\\`yaml\\nauth:\\n roles:\\n - name: ADMIN\\n permissions: ['*'] # Full access\\n - name: ANALYST \\n permissions: ['data:read', 'data:write'] # Read/write data\\n - name: VIEWER\\n permissions: ['data:read'] # Read-only\\n\\`\\`\\`\\n\\n**Gate content in your YAML:**\\n\\n\\`\\`\\`yaml\\nsections:\\n - type: button\\n label: Delete Equipment\\n action: /api/equipment/delete\\n auth:\\n required_roles: [ADMIN]\\n fallback: hide # Options: hide, disable, show_message\\n\\`\\`\\`\\n\\nOnly admins see the button. Analysts and viewers? Button doesn't exist in the DOM.\\n\\n**Route protection:**\\n\\n\\`\\`\\`yaml\\nauth:\\n protected_routes:\\n - path: /admin/*\\n roles: [ADMIN]\\n - path: /equipment/* \\n roles: [ANALYST, ADMIN]\\n public_routes:\\n - /\\n - /about\\n\\`\\`\\`\\n\\nNo middleware to write. No useAuth hooks to remember. RBAC is declarative.\\n\\n${aiAgentsSection}## 📚 Learn More\\n\\n- **Stackwright Docs:** [https://stackwright.dev](https://stackwright.dev)\\n- **OSS Repo:** [https://github.com/Per-Aspera-LLC/stackwright](https://github.com/Per-Aspera-LLC/stackwright)\\n- **Pro Repo:** [https://github.com/Per-Aspera-LLC/stackwright-pro](https://github.com/Per-Aspera-LLC/stackwright-pro)\\n\\n**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.\\n`;\n}\n","// AUTO-GENERATED — do not edit manually.\n// Run `pnpm sync-versions` or `pnpm build` to regenerate.\n//\n// PRO_VERSIONS: exact versions of @stackwright-pro/* packages in this workspace.\n// OSS_VERSIONS: minimum tested versions of @stackwright/* OSS packages (caret range).\n\n/**\n * Exact versions of every @stackwright-pro/* package currently in the workspace.\n * Used by launch-stackwright-pro and scaffold-hooks to pin deps in scaffolded projects.\n * Updated automatically on every build — never edit this file by hand.\n */\nexport const PRO_VERSIONS = {\n '@stackwright-pro/auth': '0.2.0-alpha.7',\n '@stackwright-pro/auth-nextjs': '0.2.0-alpha.9',\n '@stackwright-pro/display-components': '0.2.0-alpha.7',\n '@stackwright-pro/mcp': '0.2.0-alpha.42',\n '@stackwright-pro/openapi': '0.3.0-alpha.18',\n '@stackwright-pro/otters': '1.0.0-alpha.36',\n '@stackwright-pro/pulse': '0.3.0-alpha.10',\n '@stackwright-pro/workflow': '0.1.0-alpha.11',\n '@stackwright-pro/workflow-components': '0.1.0-alpha.13',\n} as const satisfies Record<string, string>;\n\n/**\n * Minimum tested versions of @stackwright/* OSS packages.\n * Caret ranges anchored to the last version resolved in pnpm-lock.yaml.\n * Updated automatically on every build.\n */\nexport const OSS_VERSIONS = {\n '@stackwright/build-scripts': '^0.7.0',\n '@stackwright/core': '^0.8.2',\n '@stackwright/icons': '^0.5.2',\n '@stackwright/mcp': '^0.4.5',\n '@stackwright/nextjs': '^0.5.3',\n '@stackwright/otters': '^0.2.0',\n '@stackwright/ui-shadcn': '^0.1.0',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K,aAAAE,QAAM,OAAO,0DAAgD,SAAS,EAAE,CAAC;AAAA,IACxF;AAEA,UAAM,OAAO,WAAW,OAAO;AAAA,EACjC,CAAC;AAEH,QAAM,QAAQ,WAAW,QAAQ,IAAI;AACvC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,aAAAA,QAAM,IAAI,yBAAoB,GAAG,GAAG;AAClD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["exports","module","import_path","import_fs_extra","path","fs","yaml","path","fs","chalk","os"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackwright-pro/launch-stackwright-pro",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.81",
|
|
4
4
|
"description": "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -27,23 +27,29 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@stackwright-pro/scaffold-hooks": "latest",
|
|
30
|
-
"@stackwright/cli": "^0.
|
|
31
|
-
"@stackwright/scaffold-core": "^0.1
|
|
30
|
+
"@stackwright/cli": "^0.8.6",
|
|
31
|
+
"@stackwright/scaffold-core": "^0.3.1",
|
|
32
32
|
"chalk": "^5.6.2",
|
|
33
|
-
"commander": "^
|
|
34
|
-
"fs-extra": "^11.3",
|
|
35
|
-
"js-yaml": "^4.1.0"
|
|
33
|
+
"commander": "^15.0.0",
|
|
34
|
+
"fs-extra": "^11.3.5",
|
|
35
|
+
"js-yaml": "^4.1.0",
|
|
36
|
+
"@stackwright-pro/mcp": "0.2.0-alpha.49",
|
|
37
|
+
"@stackwright-pro/openapi": "0.3.0-alpha.23",
|
|
38
|
+
"@stackwright-pro/otters": "1.0.0-alpha.38",
|
|
39
|
+
"@stackwright-pro/auth": "0.2.0-alpha.11",
|
|
40
|
+
"@stackwright-pro/auth-nextjs": "0.2.0-alpha.13"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
38
43
|
"@types/fs-extra": "^11.0",
|
|
39
44
|
"@types/js-yaml": "^4.0.9",
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"typescript": "^
|
|
42
|
-
"tsup": "^8.5",
|
|
43
|
-
"vitest": "^4.
|
|
45
|
+
"@types/node": "^25.9.1",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"tsup": "^8.5.1",
|
|
48
|
+
"vitest": "^4.1.7"
|
|
44
49
|
},
|
|
45
50
|
"scripts": {
|
|
46
|
-
"build": "tsup",
|
|
51
|
+
"build": "node ../../scripts/sync-versions.mjs && tsup",
|
|
52
|
+
"sync-versions": "node ../../scripts/sync-versions.mjs",
|
|
47
53
|
"dev": "tsup --watch",
|
|
48
54
|
"test": "vitest run",
|
|
49
55
|
"test:coverage": "vitest run --coverage"
|
package/templates/pro/_app.tsx
CHANGED
|
@@ -6,7 +6,17 @@ import { registerDisplayComponents } from '@stackwright-pro/display-components';
|
|
|
6
6
|
import { registerPulseComponents } from '@stackwright-pro/pulse';
|
|
7
7
|
import { AuthProvider } from '@stackwright-pro/auth';
|
|
8
8
|
import '@stackwright/ui-shadcn/styles.css';
|
|
9
|
-
import
|
|
9
|
+
import authConfigRaw from '../src/auth-config.json'; // Generated at build time by prebuild.js
|
|
10
|
+
|
|
11
|
+
// auth-config.json is written from stackwright.yml `auth:` section — it may be
|
|
12
|
+
// sparse (e.g. `{}`) when roles haven't been configured yet, so we cast to the
|
|
13
|
+
// full shape and use || fallbacks below.
|
|
14
|
+
type AuthConfigShape = {
|
|
15
|
+
roles?: Array<{ name: string; permissions?: string[] }>;
|
|
16
|
+
protected_routes?: Array<{ path: string; roles: string[] }>;
|
|
17
|
+
public_routes?: string[];
|
|
18
|
+
};
|
|
19
|
+
const authConfig = authConfigRaw as AuthConfigShape;
|
|
10
20
|
|
|
11
21
|
// Register Stackwright components
|
|
12
22
|
registerNextJSComponents();
|
|
@@ -24,9 +34,9 @@ export default function App({ Component, pageProps }: AppProps) {
|
|
|
24
34
|
user={user}
|
|
25
35
|
session={session}
|
|
26
36
|
rbacConfig={{
|
|
27
|
-
roles: authConfig.roles
|
|
28
|
-
protected_routes: authConfig.protected_routes
|
|
29
|
-
public_routes: authConfig.public_routes
|
|
37
|
+
roles: authConfig.roles ?? [],
|
|
38
|
+
protected_routes: authConfig.protected_routes ?? [],
|
|
39
|
+
public_routes: authConfig.public_routes ?? [],
|
|
30
40
|
}}
|
|
31
41
|
>
|
|
32
42
|
<Component {...pageProps} />
|
|
@@ -1,105 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stackwright Pro prebuild script
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Uses runPrebuild() from @stackwright/build-scripts directly with the pro
|
|
5
|
+
* content plugin, enabling pro content types to pass schema validation
|
|
6
|
+
* alongside OSS content types.
|
|
7
|
+
*
|
|
8
|
+
* Also runs the OpenAPI plugin for API client generation and extracts
|
|
9
|
+
* auth config for client-side use.
|
|
10
|
+
*
|
|
11
|
+
* Requires @stackwright/build-scripts >= 0.7.0
|
|
7
12
|
*/
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
10
16
|
const fs = require('fs');
|
|
11
17
|
const path = require('path');
|
|
12
18
|
const yaml = require('js-yaml');
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Run stackwright-prebuild to generate _root.json, _site.json, etc.
|
|
17
|
-
*/
|
|
18
|
-
async function runStackwrightPrebuild(projectRoot) {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
// Use pnpm exec to ensure we use the correct package manager
|
|
21
|
-
const proc = spawn(process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', ['exec', 'stackwright-prebuild'], {
|
|
22
|
-
cwd: projectRoot,
|
|
23
|
-
stdio: 'inherit',
|
|
24
|
-
shell: true,
|
|
25
|
-
});
|
|
26
|
-
proc.on('close', (code) => {
|
|
27
|
-
if (code === 0) {
|
|
28
|
-
resolve();
|
|
29
|
-
} else {
|
|
30
|
-
reject(new Error(`stackwright-prebuild exited with code ${code}`));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
proc.on('error', reject);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
19
|
+
const { runPrebuild } = require('@stackwright/build-scripts');
|
|
20
|
+
const { createWorkflowPlugin } = require('@stackwright-pro/workflow');
|
|
21
|
+
const { proContentPlugin } = require('./pro-content-plugin');
|
|
36
22
|
|
|
37
23
|
/**
|
|
38
24
|
* Parse full stackwright.yml using js-yaml for complete config parsing
|
|
39
25
|
*/
|
|
40
26
|
function parseStackwrightYml(content) {
|
|
41
|
-
return yaml.load(content);
|
|
27
|
+
return yaml.load(content, { schema: yaml.CORE_SCHEMA });
|
|
42
28
|
}
|
|
43
29
|
|
|
44
30
|
async function main() {
|
|
45
|
-
|
|
46
|
-
const projectRoot = path.resolve(__dirname, '..');
|
|
47
|
-
|
|
48
|
-
const configPath = path.join(projectRoot, 'stackwright.yml');
|
|
49
|
-
if (!fs.existsSync(configPath)) {
|
|
50
|
-
console.log('No stackwright.yml found — skipping prebuild.');
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
31
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
53
32
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const fullConfig = parseStackwrightYml(configContent);
|
|
60
|
-
|
|
61
|
-
// Extract auth config and write as JSON for client-side use
|
|
62
|
-
if (fullConfig.auth) {
|
|
63
|
-
const authConfig = fullConfig.auth;
|
|
64
|
-
const srcDir = path.join(projectRoot, 'src');
|
|
65
|
-
|
|
66
|
-
if (!fs.existsSync(srcDir)) {
|
|
67
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
fs.writeFileSync(
|
|
71
|
-
path.join(srcDir, 'auth-config.json'),
|
|
72
|
-
JSON.stringify(authConfig, null, 2)
|
|
73
|
-
);
|
|
74
|
-
console.log('✓ Generated src/auth-config.json');
|
|
75
|
-
}
|
|
33
|
+
const configPath = path.join(projectRoot, 'stackwright.yml');
|
|
34
|
+
if (!fs.existsSync(configPath)) {
|
|
35
|
+
console.log('No stackwright.yml found — skipping prebuild.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
76
38
|
|
|
77
|
-
|
|
78
|
-
|
|
39
|
+
const configContent = fs.readFileSync(configPath, 'utf-8');
|
|
40
|
+
const fullConfig = parseStackwrightYml(configContent);
|
|
79
41
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
42
|
+
// Assemble plugins
|
|
43
|
+
const workflowPlugin = createWorkflowPlugin();
|
|
44
|
+
const plugins = [proContentPlugin, workflowPlugin];
|
|
85
45
|
|
|
86
|
-
|
|
46
|
+
const integrations = fullConfig.integrations || [];
|
|
47
|
+
if (integrations.length > 0) {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
49
|
+
const { createOpenAPIPlugin } = require('@stackwright-pro/openapi');
|
|
50
|
+
plugins.push(createOpenAPIPlugin());
|
|
51
|
+
console.log(` OpenAPI plugin: loaded (${integrations.length} integrations)`);
|
|
52
|
+
}
|
|
87
53
|
|
|
88
|
-
|
|
54
|
+
// Run prebuild with all plugins
|
|
55
|
+
console.log('Generating content files...');
|
|
56
|
+
await runPrebuild({
|
|
57
|
+
projectRoot,
|
|
58
|
+
plugins,
|
|
59
|
+
unknownContentTypes: 'warn', // log warnings for unknown types instead of failing build
|
|
60
|
+
});
|
|
89
61
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
62
|
+
// Extract auth config and write as JSON for client-side use
|
|
63
|
+
if (fullConfig.auth) {
|
|
64
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
65
|
+
if (!fs.existsSync(srcDir)) {
|
|
66
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
95
67
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.
|
|
101
|
-
process.exit(1);
|
|
68
|
+
fs.writeFileSync(
|
|
69
|
+
path.join(srcDir, 'auth-config.json'),
|
|
70
|
+
JSON.stringify(fullConfig.auth, null, 2)
|
|
71
|
+
);
|
|
72
|
+
console.log('✓ Generated src/auth-config.json');
|
|
102
73
|
}
|
|
74
|
+
|
|
75
|
+
console.log('✓ Prebuild complete!');
|
|
103
76
|
}
|
|
104
77
|
|
|
105
|
-
main()
|
|
78
|
+
main().catch((err) => {
|
|
79
|
+
console.error('Prebuild failed:', err.message);
|
|
80
|
+
console.error(err.stack);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// packages/launch-stackwright-pro/templates/pro/scripts/pro-content-plugin.js
|
|
2
|
+
//
|
|
3
|
+
// Pro content type plugin for @stackwright/build-scripts.
|
|
4
|
+
//
|
|
5
|
+
// CONFIRMED CASE B (@stackwright/build-scripts@0.5.0-alpha.0 / types@1.2.0-alpha.0):
|
|
6
|
+
// The currently shipped version of build-scripts does NOT read
|
|
7
|
+
// `contentItemSchemas` or `knownContentTypeKeys` from plugin objects.
|
|
8
|
+
// Those fields first appear in @stackwright/types@1.4.0+ and will be
|
|
9
|
+
// consumed by build-scripts@0.7.0 when that release ships.
|
|
10
|
+
//
|
|
11
|
+
// CURRENT BEHAVIOUR (pre-0.7.0):
|
|
12
|
+
// `unknownContentTypes: 'warn'` in prebuild.js already prevents hard failures
|
|
13
|
+
// for unrecognised content types. The `beforeBuild` stub below ensures this
|
|
14
|
+
// plugin is a syntactically valid, callable plugin (not silently ignored by
|
|
15
|
+
// the plugin runner) even though there is no side-effect to execute yet.
|
|
16
|
+
//
|
|
17
|
+
// TODO(@stackwright/build-scripts@0.7.0): Once 0.7.0 is the resolved floor,
|
|
18
|
+
// remove the `beforeBuild` stub — `contentItemSchemas` and
|
|
19
|
+
// `knownContentTypeKeys` will be consumed natively by the runtime and the
|
|
20
|
+
// plugin will suppress "unknown content type" warnings automatically.
|
|
21
|
+
|
|
22
|
+
'use strict';
|
|
23
|
+
|
|
24
|
+
const { z } = require('zod');
|
|
25
|
+
|
|
26
|
+
const PRO_CONTENT_TYPE_KEYS = [
|
|
27
|
+
// @stackwright-pro/display-components
|
|
28
|
+
'metric_card',
|
|
29
|
+
'status_badge',
|
|
30
|
+
'stat_bar',
|
|
31
|
+
'sparkline',
|
|
32
|
+
'activity_feed',
|
|
33
|
+
'dashboard_grid',
|
|
34
|
+
'data_table',
|
|
35
|
+
'json_viewer',
|
|
36
|
+
'action_bar',
|
|
37
|
+
'section',
|
|
38
|
+
'collection_listing',
|
|
39
|
+
// @stackwright-pro/pulse
|
|
40
|
+
'pulse_provider',
|
|
41
|
+
'metric_card_pulse',
|
|
42
|
+
'data_table_pulse',
|
|
43
|
+
'status_badge_pulse',
|
|
44
|
+
'stats_grid',
|
|
45
|
+
'alert_banner',
|
|
46
|
+
// @stackwright-pro/workflow-components
|
|
47
|
+
'workflow_mount',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const proContentPlugin = {
|
|
51
|
+
name: 'pro-content',
|
|
52
|
+
|
|
53
|
+
// --- Fields read by build-scripts@0.7.0+ (types@1.4.0+) ---
|
|
54
|
+
// Passthrough schemas — let each component handle its own prop validation
|
|
55
|
+
// at runtime. Registered here so the prebuild content-item validator
|
|
56
|
+
// accepts pro types without errors.
|
|
57
|
+
contentItemSchemas: PRO_CONTENT_TYPE_KEYS.map((type) =>
|
|
58
|
+
z.object({ type: z.literal(type) }).passthrough()
|
|
59
|
+
),
|
|
60
|
+
// String keys so the prebuild skips "unknown content type" warnings.
|
|
61
|
+
knownContentTypeKeys: PRO_CONTENT_TYPE_KEYS,
|
|
62
|
+
|
|
63
|
+
// --- Stub lifecycle hook (required for build-scripts@0.5.x / types@1.2.x) ---
|
|
64
|
+
// build-scripts@0.5.x only calls plugins that have beforeBuild or afterBuild.
|
|
65
|
+
// Without this stub the plugin object is accepted but never invoked, making
|
|
66
|
+
// the whole registration a silent no-op. The stub has no side-effects; its
|
|
67
|
+
// only purpose is to keep the plugin in the active lifecycle.
|
|
68
|
+
//
|
|
69
|
+
// Remove this stub when build-scripts@0.7.0 is the resolved floor (the
|
|
70
|
+
// 0.7.x runner calls plugins purely for their schema/key registration,
|
|
71
|
+
// not via beforeBuild/afterBuild).
|
|
72
|
+
beforeBuild: () => {},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports = { proContentPlugin };
|