humanbehavior-js 0.4.19 → 0.4.20
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/dist/cjs/install-wizard.cjs +56 -10
- package/dist/cjs/install-wizard.cjs.map +1 -1
- package/dist/cjs/wizard/index.cjs +56 -10
- package/dist/cjs/wizard/index.cjs.map +1 -1
- package/dist/cli/ai-auto-install.js +56 -10
- package/dist/cli/ai-auto-install.js.map +1 -1
- package/dist/cli/auto-install.js +56 -10
- package/dist/cli/auto-install.js.map +1 -1
- package/dist/esm/install-wizard.js +56 -10
- package/dist/esm/install-wizard.js.map +1 -1
- package/dist/esm/wizard/index.js +56 -10
- package/dist/esm/wizard/index.js.map +1 -1
- package/package.json +1 -1
- package/src/wizard/core/install-wizard.ts +60 -10
|
@@ -698,8 +698,17 @@ export default defineNuxtPlugin(() => {
|
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
700
|
|
|
701
|
-
// Handle Angular environment
|
|
701
|
+
// Handle Angular environment files (proper Angular way)
|
|
702
702
|
const envFile = path.join(this.projectRoot, 'src', 'environments', 'environment.ts');
|
|
703
|
+
const envProdFile = path.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');
|
|
704
|
+
|
|
705
|
+
// Create environments directory if it doesn't exist
|
|
706
|
+
const envDir = path.dirname(envFile);
|
|
707
|
+
if (!fs.existsSync(envDir)) {
|
|
708
|
+
fs.mkdirSync(envDir, { recursive: true });
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// Create or update development environment
|
|
703
712
|
if (fs.existsSync(envFile)) {
|
|
704
713
|
const content = fs.readFileSync(envFile, 'utf8');
|
|
705
714
|
if (!content.includes('humanBehaviorApiKey')) {
|
|
@@ -707,20 +716,62 @@ export default defineNuxtPlugin(() => {
|
|
|
707
716
|
/export const environment = {([\s\S]*?)};/,
|
|
708
717
|
`export const environment = {
|
|
709
718
|
$1,
|
|
710
|
-
humanBehaviorApiKey:
|
|
719
|
+
humanBehaviorApiKey: '${this.apiKey}'
|
|
711
720
|
};`
|
|
712
721
|
);
|
|
713
722
|
modifications.push({
|
|
714
723
|
filePath: envFile,
|
|
715
724
|
action: 'modify',
|
|
716
725
|
content: modifiedContent,
|
|
717
|
-
description: 'Added API key to Angular environment'
|
|
726
|
+
description: 'Added API key to Angular development environment'
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
// Create new development environment file
|
|
731
|
+
modifications.push({
|
|
732
|
+
filePath: envFile,
|
|
733
|
+
action: 'create',
|
|
734
|
+
content: `export const environment = {
|
|
735
|
+
production: false,
|
|
736
|
+
humanBehaviorApiKey: '${this.apiKey}'
|
|
737
|
+
};`,
|
|
738
|
+
description: 'Created Angular development environment file'
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// Create or update production environment
|
|
743
|
+
if (fs.existsSync(envProdFile)) {
|
|
744
|
+
const content = fs.readFileSync(envProdFile, 'utf8');
|
|
745
|
+
if (!content.includes('humanBehaviorApiKey')) {
|
|
746
|
+
const modifiedContent = content.replace(
|
|
747
|
+
/export const environment = {([\s\S]*?)};/,
|
|
748
|
+
`export const environment = {
|
|
749
|
+
$1,
|
|
750
|
+
humanBehaviorApiKey: '${this.apiKey}'
|
|
751
|
+
};`
|
|
752
|
+
);
|
|
753
|
+
modifications.push({
|
|
754
|
+
filePath: envProdFile,
|
|
755
|
+
action: 'modify',
|
|
756
|
+
content: modifiedContent,
|
|
757
|
+
description: 'Added API key to Angular production environment'
|
|
718
758
|
});
|
|
719
759
|
}
|
|
760
|
+
} else {
|
|
761
|
+
// Create new production environment file
|
|
762
|
+
modifications.push({
|
|
763
|
+
filePath: envProdFile,
|
|
764
|
+
action: 'create',
|
|
765
|
+
content: `export const environment = {
|
|
766
|
+
production: true,
|
|
767
|
+
humanBehaviorApiKey: '${this.apiKey}'
|
|
768
|
+
};`,
|
|
769
|
+
description: 'Created Angular production environment file'
|
|
770
|
+
});
|
|
720
771
|
}
|
|
721
772
|
|
|
722
|
-
//
|
|
723
|
-
|
|
773
|
+
// For Angular, we don't need .env files since we use environment.ts
|
|
774
|
+
// The environment files are already created above
|
|
724
775
|
|
|
725
776
|
return modifications;
|
|
726
777
|
}
|
|
@@ -1255,11 +1306,12 @@ export default function App()`
|
|
|
1255
1306
|
}
|
|
1256
1307
|
|
|
1257
1308
|
const importStatement = `import { initializeHumanBehavior } from 'humanbehavior-js/angular';`;
|
|
1309
|
+
const environmentImport = `import { environment } from './environments/environment';`;
|
|
1258
1310
|
|
|
1259
|
-
// Add
|
|
1311
|
+
// Add imports at the top
|
|
1260
1312
|
let modifiedContent = content.replace(
|
|
1261
1313
|
/import.*from.*['"]@angular/,
|
|
1262
|
-
`${importStatement}\n$&`
|
|
1314
|
+
`${importStatement}\n${environmentImport}\n$&`
|
|
1263
1315
|
);
|
|
1264
1316
|
|
|
1265
1317
|
// Add initialization after bootstrapApplication
|
|
@@ -1269,9 +1321,7 @@ export default function App()`
|
|
|
1269
1321
|
|
|
1270
1322
|
// Initialize HumanBehavior SDK (client-side only)
|
|
1271
1323
|
if (typeof window !== 'undefined') {
|
|
1272
|
-
const tracker = initializeHumanBehavior(
|
|
1273
|
-
'${this.apiKey}'
|
|
1274
|
-
);
|
|
1324
|
+
const tracker = initializeHumanBehavior(environment.humanBehaviorApiKey);
|
|
1275
1325
|
}`
|
|
1276
1326
|
);
|
|
1277
1327
|
|