@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.93 → 0.4.0-alpha.94

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackwright-pro/launch-stackwright-pro",
3
- "version": "0.4.0-alpha.93",
3
+ "version": "0.4.0-alpha.94",
4
4
  "description": "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -32,11 +32,11 @@
32
32
  "commander": "^15.0.0",
33
33
  "fs-extra": "^11.3.5",
34
34
  "js-yaml": "^4.2.0",
35
- "@stackwright-pro/auth-nextjs": "0.2.0-alpha.13",
36
35
  "@stackwright-pro/auth": "0.2.0-alpha.11",
36
+ "@stackwright-pro/auth-nextjs": "0.2.0-alpha.13",
37
+ "@stackwright-pro/mcp": "0.2.0-alpha.59",
37
38
  "@stackwright-pro/openapi": "0.3.0-alpha.23",
38
39
  "@stackwright-pro/otters": "1.0.0-alpha.43",
39
- "@stackwright-pro/mcp": "0.2.0-alpha.58",
40
40
  "@stackwright-pro/scaffold-hooks": "1.0.0-alpha.15"
41
41
  },
42
42
  "devDependencies": {
@@ -75,17 +75,64 @@ async function main() {
75
75
  unknownContentTypes: 'warn', // log warnings for unknown types instead of failing build
76
76
  });
77
77
 
78
- // Extract auth config and write as JSON for client-side use
79
- if (fullConfig.auth) {
78
+ // Extract auth config and write as JSON for client-side use.
79
+ // The auth otter writes to config/auth.yml (standalone RBAC config), while
80
+ // stackwright.yml may only have an empty `auth: {}` placeholder. Bridge
81
+ // both sources: prefer stackwright.yml if it has roles, otherwise merge
82
+ // from config/auth.yml so the client-side AuthProvider gets real RBAC data.
83
+ const authConfig = fullConfig.auth || {};
84
+ const authConfigPath = path.join(projectRoot, 'config', 'auth.yml');
85
+
86
+ if (
87
+ Object.keys(authConfig).length <= 0 ||
88
+ (!authConfig.roles && !authConfig.rbac)
89
+ ) {
90
+ // stackwright.yml auth: is empty or has no role data — try config/auth.yml
91
+ if (fs.existsSync(authConfigPath)) {
92
+ try {
93
+ const authYaml = fs.readFileSync(authConfigPath, 'utf-8');
94
+ const parsed = yaml.load(authYaml, { schema: yaml.CORE_SCHEMA });
95
+ if (parsed && typeof parsed === 'object') {
96
+ // Map config/auth.yml fields to the client-side schema
97
+ const rbac = parsed.rbac || {};
98
+ const roles = (rbac.roles || []).map((roleName) =>
99
+ typeof roleName === 'string'
100
+ ? { name: roleName, permissions: [] }
101
+ : roleName
102
+ );
103
+
104
+ const protectedRoutes = (parsed.protectedRoutes || []).map((route) =>
105
+ typeof route === 'string'
106
+ ? { path: route, roles: roles.map((r) => r.name) }
107
+ : route
108
+ );
109
+
110
+ Object.assign(authConfig, {
111
+ roles,
112
+ protected_routes: protectedRoutes,
113
+ public_routes: parsed.publicRoutes || ['/'],
114
+ method: parsed.method || 'none',
115
+ audit: parsed.audit || {},
116
+ });
117
+
118
+ console.log(' ℹ Bridged auth config from config/auth.yml → src/auth-config.json');
119
+ }
120
+ } catch (e) {
121
+ console.warn(' Could not parse config/auth.yml:', e.message);
122
+ }
123
+ }
124
+ }
125
+
126
+ if (Object.keys(authConfig).length > 0) {
80
127
  const srcDir = path.join(projectRoot, 'src');
81
128
  if (!fs.existsSync(srcDir)) {
82
129
  fs.mkdirSync(srcDir, { recursive: true });
83
130
  }
84
131
  fs.writeFileSync(
85
132
  path.join(srcDir, 'auth-config.json'),
86
- JSON.stringify(fullConfig.auth, null, 2)
133
+ JSON.stringify(authConfig, null, 2)
87
134
  );
88
- console.log(' Generated src/auth-config.json');
135
+ console.log(' Generated src/auth-config.json');
89
136
  }
90
137
 
91
138
  // Restore original stackwright.yml if we modified it during theme merge