humanbehavior-js 0.5.50 → 0.5.51
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 +1 -1
- package/packages/wizard/dist/cli/ai-auto-install.js +34 -14
- package/packages/wizard/dist/cli/ai-auto-install.js.map +1 -1
- package/packages/wizard/dist/cli/auto-install.d.ts.map +1 -1
- package/packages/wizard/dist/cli/auto-install.js +45 -23
- package/packages/wizard/dist/cli/auto-install.js.map +1 -1
- package/packages/wizard/dist/core/install-wizard.d.ts.map +1 -1
- package/packages/wizard/dist/index.js +1 -1
- package/packages/wizard/dist/index.js.map +1 -1
- package/packages/wizard/dist/index.mjs +1 -1
- package/packages/wizard/dist/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -340,13 +340,26 @@ class AutoInstallationWizard {
|
|
|
340
340
|
*/
|
|
341
341
|
async generateNextJSModifications() {
|
|
342
342
|
const modifications = [];
|
|
343
|
-
// Check for App Router
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
|
|
343
|
+
// Check for App Router - try both with and without src directory
|
|
344
|
+
const appLayoutFileWithSrc = path.join(this.projectRoot, 'src', 'app', 'layout.tsx');
|
|
345
|
+
const appLayoutFile = path.join(this.projectRoot, 'app', 'layout.tsx');
|
|
346
|
+
const pagesLayoutFileWithSrc = path.join(this.projectRoot, 'src', 'pages', '_app.tsx');
|
|
347
|
+
const pagesLayoutFile = path.join(this.projectRoot, 'pages', '_app.tsx');
|
|
348
|
+
// Determine which layout file exists and set paths accordingly
|
|
349
|
+
let actualAppLayoutFile = null;
|
|
350
|
+
let providersFilePath = null;
|
|
351
|
+
if (fs.existsSync(appLayoutFileWithSrc)) {
|
|
352
|
+
actualAppLayoutFile = appLayoutFileWithSrc;
|
|
353
|
+
providersFilePath = path.join(this.projectRoot, 'src', 'app', 'providers.tsx');
|
|
354
|
+
}
|
|
355
|
+
else if (fs.existsSync(appLayoutFile)) {
|
|
356
|
+
actualAppLayoutFile = appLayoutFile;
|
|
357
|
+
providersFilePath = path.join(this.projectRoot, 'app', 'providers.tsx');
|
|
358
|
+
}
|
|
359
|
+
if (actualAppLayoutFile) {
|
|
347
360
|
// Create providers.tsx file for App Router
|
|
348
361
|
modifications.push({
|
|
349
|
-
filePath:
|
|
362
|
+
filePath: providersFilePath,
|
|
350
363
|
action: 'create',
|
|
351
364
|
content: `'use client';
|
|
352
365
|
|
|
@@ -362,19 +375,26 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
362
375
|
description: 'Created providers.tsx file for Next.js App Router'
|
|
363
376
|
});
|
|
364
377
|
// Modify layout.tsx to use the provider
|
|
365
|
-
const content = fs.readFileSync(
|
|
378
|
+
const content = fs.readFileSync(actualAppLayoutFile, 'utf8');
|
|
366
379
|
const modifiedContent = this.injectNextJSAppRouter(content);
|
|
367
380
|
modifications.push({
|
|
368
|
-
filePath:
|
|
381
|
+
filePath: actualAppLayoutFile,
|
|
369
382
|
action: 'modify',
|
|
370
383
|
content: modifiedContent,
|
|
371
384
|
description: 'Added Providers wrapper to Next.js App Router layout'
|
|
372
385
|
});
|
|
373
386
|
}
|
|
374
|
-
else if (fs.existsSync(pagesLayoutFile)) {
|
|
387
|
+
else if (fs.existsSync(pagesLayoutFileWithSrc) || fs.existsSync(pagesLayoutFile)) {
|
|
388
|
+
const actualPagesLayoutFile = fs.existsSync(pagesLayoutFileWithSrc) ? pagesLayoutFileWithSrc : pagesLayoutFile;
|
|
389
|
+
const providersPath = fs.existsSync(pagesLayoutFileWithSrc)
|
|
390
|
+
? path.join(this.projectRoot, 'src', 'components', 'providers.tsx')
|
|
391
|
+
: path.join(this.projectRoot, 'components', 'providers.tsx');
|
|
392
|
+
const importPath = fs.existsSync(pagesLayoutFileWithSrc)
|
|
393
|
+
? '../components/providers'
|
|
394
|
+
: './components/providers';
|
|
375
395
|
// Create providers.tsx file for Pages Router
|
|
376
396
|
modifications.push({
|
|
377
|
-
filePath:
|
|
397
|
+
filePath: providersPath,
|
|
378
398
|
action: 'create',
|
|
379
399
|
content: `'use client';
|
|
380
400
|
|
|
@@ -390,10 +410,10 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
390
410
|
description: 'Created providers.tsx file for Pages Router'
|
|
391
411
|
});
|
|
392
412
|
// Modify _app.tsx to use the provider
|
|
393
|
-
const content = fs.readFileSync(
|
|
394
|
-
const modifiedContent = this.injectNextJSPagesRouter(content);
|
|
413
|
+
const content = fs.readFileSync(actualPagesLayoutFile, 'utf8');
|
|
414
|
+
const modifiedContent = this.injectNextJSPagesRouter(content, importPath);
|
|
395
415
|
modifications.push({
|
|
396
|
-
filePath:
|
|
416
|
+
filePath: actualPagesLayoutFile,
|
|
397
417
|
action: 'modify',
|
|
398
418
|
content: modifiedContent,
|
|
399
419
|
description: 'Added Providers wrapper to Next.js Pages Router'
|
|
@@ -978,11 +998,11 @@ export const onClientEntry = () => {
|
|
|
978
998
|
});
|
|
979
999
|
return modifiedContent;
|
|
980
1000
|
}
|
|
981
|
-
injectNextJSPagesRouter(content) {
|
|
1001
|
+
injectNextJSPagesRouter(content, importPath = '../components/providers') {
|
|
982
1002
|
if (content.includes('Providers')) {
|
|
983
1003
|
return content;
|
|
984
1004
|
}
|
|
985
|
-
const importStatement = `import { Providers } from '
|
|
1005
|
+
const importStatement = `import { Providers } from '${importPath}';`;
|
|
986
1006
|
return content.replace(/function MyApp/, `${importStatement}\n\nfunction MyApp`).replace(/return \(([\s\S]*?)\);/, `return (
|
|
987
1007
|
<Providers>
|
|
988
1008
|
$1
|