@chimerai/cli 0.2.93 → 0.2.95

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.
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkDH,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAmED,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,iBAyI9E"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0DH,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAmED,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,iBAyI9E"}
@@ -61,8 +61,13 @@ function stripAuthFromGeneratedCode(code) {
61
61
  code = code.replace(/^import \{ getServerSession \} from 'next-auth';\n/m, '');
62
62
  code = code.replace(/^import \{ authOptions \} from '@\/lib\/auth';\n/m, '');
63
63
  code = code.replace(/^import \{ logAuditAction \} from '@\/lib\/audit';\n/m, '');
64
- // Remove inline session check blocks
64
+ // Remove inline session check blocks — 4-space indentation (provider/admin routes)
65
65
  code = code.replace(/\n {4}const session = await getServerSession\(authOptions\);\n {4}if \(!session\?\.user\) \{\n {6}return NextResponse\.json\(\{ error: 'Unauthorized' \}, \{ status: 401 \}\);\n {4}\}\n/g, '\n');
66
+ // Remove inline session check blocks — 2-space indentation (models/prompts routes)
67
+ code = code.replace(/\n {2}const session = await getServerSession\(authOptions\);\n {2}if \(!session\?\.user\) \{\n {4}return NextResponse\.json\(\{ error: 'Unauthorized' \}, \{ status: 401 \}\);\n {2}\}\n/g, '\n');
68
+ // Also catch orphaned getServerSession calls (import already removed but call remains)
69
+ code = code.replace(/^ {2}const session = await getServerSession\(authOptions\);\n/m, '');
70
+ code = code.replace(/^ {2}if \(!session\?\.user\) \{\n {4}return NextResponse\.json\(\{ error: 'Unauthorized' \}, \{ status: 401 \}\);\n {2}\}\n/m, '');
66
71
  // Replace session.user.id with local-dev fallback
67
72
  code = code.replace(/session\.user\.id/g, "'local-dev'");
68
73
  code = code.replace(/session\?\.user\?\.id/g, "'local-dev'");
@@ -983,6 +988,13 @@ async function copyFeatureFiles(targetDir, features) {
983
988
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'lib/auth'));
984
989
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'lib/auth/resolve-auth.ts'), resolveAuthStub);
985
990
  }
991
+ // Shared no-auth helper — used for all route generators below
992
+ const _withAuth = features.includes('auth');
993
+ const _strip = (code) => (_withAuth ? code : stripAuthFromGeneratedCode(code));
994
+ // useAppName hook — always generated (used by chat page, dashboard layout, etc.)
995
+ const useAppNameHook = templates.generateUseAppNameHook();
996
+ await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'lib'));
997
+ await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'lib/use-app-name.ts'), useAppNameHook);
986
998
  // ── Widget Infrastructure (embeddable chat for external apps) ──────
987
999
  // Rate limiter (supports both session and API-key tiers)
988
1000
  const rateLimiter = templates.generateRateLimiter();
@@ -995,10 +1007,10 @@ async function copyFeatureFiles(targetDir, features) {
995
1007
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'public/widget/loader.js'), widgetLoader);
996
1008
  // API-Key management routes
997
1009
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/v1/api-keys'));
998
- const apiKeysRoute = templates.generateApiKeysRoute();
1010
+ const apiKeysRoute = _strip(templates.generateApiKeysRoute());
999
1011
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/v1/api-keys/route.ts'), apiKeysRoute);
1000
1012
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/v1/api-keys/[id]'));
1001
- const apiKeyIdRoute = templates.generateApiKeyIdRoute();
1013
+ const apiKeyIdRoute = _strip(templates.generateApiKeyIdRoute());
1002
1014
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/v1/api-keys/[id]/route.ts'), apiKeyIdRoute);
1003
1015
  // API-Key management page (settings UI)
1004
1016
  if (features.includes('auth')) {
@@ -1009,9 +1021,6 @@ async function copyFeatureFiles(targetDir, features) {
1009
1021
  // Notify provider change utility
1010
1022
  const notifyLib = templates.generateNotifyProviderChangeLib();
1011
1023
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'lib/notify-provider-change.ts'), notifyLib);
1012
- // When auth is not enabled, strip next-auth imports/checks from provider routes
1013
- const _withAuth = features.includes('auth');
1014
- const _strip = (code) => (_withAuth ? code : stripAuthFromGeneratedCode(code));
1015
1024
  // Provider CRUD route — /api/providers
1016
1025
  const providerCrudRoute = _strip(templates.generateProviderCrudRoute());
1017
1026
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/providers'));
@@ -1102,10 +1111,6 @@ async function copyFeatureFiles(targetDir, features) {
1102
1111
  const appSettingsRoute = templates.generateAppSettingsRoute();
1103
1112
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/app-settings'));
1104
1113
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/app-settings/route.ts'), appSettingsRoute);
1105
- // useAppName client hook
1106
- const useAppNameHook = templates.generateUseAppNameHook();
1107
- await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'lib'));
1108
- await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'lib/use-app-name.ts'), useAppNameHook);
1109
1114
  // ── RBAC Permission utilities (required by admin API routes) ───
1110
1115
  const permissionsLib = `/**
1111
1116
  * Permission utility functions
@@ -1241,10 +1246,10 @@ async function getServerSessionWithPermissions() {
1241
1246
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/dashboard/prompts'));
1242
1247
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/dashboard/prompts/page.tsx'), promptsPage);
1243
1248
  // Prompts API routes
1244
- const promptsRoute = templates.generatePromptsRoute();
1249
+ const promptsRoute = _strip(templates.generatePromptsRoute());
1245
1250
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/prompts'));
1246
1251
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/prompts/route.ts'), promptsRoute);
1247
- const promptsIdRoute = templates.generatePromptsIdRoute();
1252
+ const promptsIdRoute = _strip(templates.generatePromptsIdRoute());
1248
1253
  await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/prompts/[id]'));
1249
1254
  await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/prompts/[id]/route.ts'), promptsIdRoute);
1250
1255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chimerai/cli",
3
- "version": "0.2.93",
3
+ "version": "0.2.95",
4
4
  "description": "CLI wizard for ChimerAI starter kit — scaffold auth, RBAC, AI chat, billing and more into any Next.js project",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {