@chimerai/cli 1.2.4 → 1.2.5
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":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAu6ED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,iBAyHtE"}
|
package/dist/commands/add.js
CHANGED
|
@@ -1175,6 +1175,19 @@ function transformSchemaForSqlite(schema) {
|
|
|
1175
1175
|
* Generic component addition function (PHASE 4 refactoring)
|
|
1176
1176
|
* Uses inline template generators — no fs.copy(), no dependency on templates/ folder
|
|
1177
1177
|
*/
|
|
1178
|
+
/**
|
|
1179
|
+
* Strips next-auth imports and session checks from a generated route file.
|
|
1180
|
+
* Used when the project does not have the 'auth' feature installed.
|
|
1181
|
+
*/
|
|
1182
|
+
function stripAuthFromRoute(content) {
|
|
1183
|
+
return content
|
|
1184
|
+
.replace(/^import \{ getServerSession \} from 'next-auth';\n/m, '')
|
|
1185
|
+
.replace(/^import \{ authOptions \} from '@\/lib\/auth';\n/m, '')
|
|
1186
|
+
.replace(/^ import \{ getServerSession \} from 'next-auth';\n/m, '')
|
|
1187
|
+
.replace(/^ import \{ authOptions \} from '@\/lib\/auth';\n/m, '')
|
|
1188
|
+
.replace(/\n const session = await getServerSession\(authOptions\);\n if \(!session\?\.user\?\.id\) \{\n return NextResponse\.json\(\{ error: 'Unauthorized' \}, \{ status: 401 \}\);\n \}\n/g, '\n')
|
|
1189
|
+
.replace(/,?\n\s*user_id: session\.user\.id,?/g, '');
|
|
1190
|
+
}
|
|
1178
1191
|
/**
|
|
1179
1192
|
* Checks if a given feature marker exists anywhere in the project's package.json
|
|
1180
1193
|
* or in a generated file (by scanning for the @chimerai marker convention).
|
|
@@ -1220,6 +1233,8 @@ async function addComponent(config, targetDir) {
|
|
|
1220
1233
|
}
|
|
1221
1234
|
}
|
|
1222
1235
|
const spinner = (0, ora_1.default)(`Adding ${config.displayName}...`).start();
|
|
1236
|
+
// Detect whether the project has auth installed (used to conditionally strip auth imports)
|
|
1237
|
+
const projectHasAuth = await hasFeature('auth', targetDir);
|
|
1223
1238
|
try {
|
|
1224
1239
|
// 1. Generate and write all required files
|
|
1225
1240
|
// Detect if project uses (app) route group for pages
|
|
@@ -1239,7 +1254,11 @@ async function addComponent(config, targetDir) {
|
|
|
1239
1254
|
// Ensure directory exists
|
|
1240
1255
|
await fs_extra_1.default.ensureDir(path_1.default.dirname(targetPath));
|
|
1241
1256
|
// Generate content from inline template and write
|
|
1242
|
-
|
|
1257
|
+
let content = file.generator();
|
|
1258
|
+
// Strip next-auth references from API routes when auth is not installed
|
|
1259
|
+
if (!projectHasAuth && target.startsWith('app/api/')) {
|
|
1260
|
+
content = stripAuthFromRoute(content);
|
|
1261
|
+
}
|
|
1243
1262
|
await fs_extra_1.default.writeFile(targetPath, content);
|
|
1244
1263
|
spinner.text = `Adding ${config.displayName}... (${file.target})`;
|
|
1245
1264
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/templates/chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAqI/C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAuLzC;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAwa/D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAwEnD;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,UAAQ,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/templates/chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAqI/C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAuLzC;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAwa/D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAwEnD;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,UAAQ,GAAG,MAAM,CAwb9D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAuQ5C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAwH1C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CA+O5C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CA+D9C;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAyGxD"}
|
package/dist/templates/chat.js
CHANGED
|
@@ -990,7 +990,8 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
|
|
990
990
|
}
|
|
991
991
|
}, [selectedModelId]);
|
|
992
992
|
|
|
993
|
-
${hasBilling
|
|
993
|
+
${hasBilling
|
|
994
|
+
? `// --- Fetch Credit Balance ---
|
|
994
995
|
const fetchCreditBalance = useCallback(async () => {
|
|
995
996
|
try {
|
|
996
997
|
const res = await fetch('/api/billing/credits');
|
|
@@ -1001,7 +1002,8 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
|
|
1001
1002
|
} catch {
|
|
1002
1003
|
// Credits endpoint may not exist — that's ok
|
|
1003
1004
|
}
|
|
1004
|
-
}, []);`
|
|
1005
|
+
}, []);`
|
|
1006
|
+
: ''}
|
|
1005
1007
|
|
|
1006
1008
|
// Load on mount
|
|
1007
1009
|
useEffect(() => {
|
package/package.json
CHANGED