minahil 0.1.13 → 0.1.15
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/schematics/ng-add/index.js +61 -0
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
5
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
6
|
+
function default_1(options) {
|
|
7
|
+
return (tree, context) => {
|
|
8
|
+
context.logger.info('🚀 Setting up Minahil library...');
|
|
9
|
+
// 1. Read user's Angular version from package.json
|
|
10
|
+
const angularCore = (0, dependencies_1.getPackageJsonDependency)(tree, '@angular/core');
|
|
11
|
+
if (!angularCore) {
|
|
12
|
+
throw new Error('❌ Cannot find @angular/core in package.json. Make sure this is an Angular project.');
|
|
13
|
+
}
|
|
14
|
+
// 2. Extract major version (e.g., "^19.0.0" -> "19" or "~18.2.0" -> "18")
|
|
15
|
+
const angularVersion = angularCore.version;
|
|
16
|
+
const majorVersionMatch = angularVersion.match(/(\d+)/);
|
|
17
|
+
if (!majorVersionMatch) {
|
|
18
|
+
throw new Error(`❌ Could not determine Angular version from ${angularVersion}`);
|
|
19
|
+
}
|
|
20
|
+
const majorVersion = parseInt(majorVersionMatch[0], 10);
|
|
21
|
+
// 3. Validate Angular version is in supported range (17-21)
|
|
22
|
+
if (majorVersion < 17 || majorVersion > 21) {
|
|
23
|
+
throw new Error(`❌ Minahil library supports Angular versions 17-21, but found Angular ${majorVersion}.\n` +
|
|
24
|
+
`Please upgrade or downgrade your Angular version.`);
|
|
25
|
+
}
|
|
26
|
+
context.logger.info(`✅ Detected Angular version: ${majorVersion}`);
|
|
27
|
+
// 4. Check if user already has CDK installed
|
|
28
|
+
const existingCdk = (0, dependencies_1.getPackageJsonDependency)(tree, '@angular/cdk');
|
|
29
|
+
if (existingCdk) {
|
|
30
|
+
const existingCdkMajor = existingCdk.version.match(/(\d+)/)?.[0];
|
|
31
|
+
// Check if existing CDK version matches Angular version
|
|
32
|
+
if (existingCdkMajor && parseInt(existingCdkMajor) === majorVersion) {
|
|
33
|
+
context.logger.info(`✅ Using existing @angular/cdk@${existingCdk.version}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
context.logger.warn(`⚠️ Found @angular/cdk@${existingCdk.version} but you have Angular ${majorVersion}.\n` +
|
|
37
|
+
` Consider updating CDK to match your Angular version: npm install @angular/cdk@^${majorVersion}.0.0`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Install matching CDK version
|
|
42
|
+
const cdkVersion = `^${majorVersion}.0.0`;
|
|
43
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, {
|
|
44
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
45
|
+
name: '@angular/cdk',
|
|
46
|
+
version: cdkVersion,
|
|
47
|
+
});
|
|
48
|
+
context.logger.info(`✅ Installing @angular/cdk@${cdkVersion} to match Angular ${majorVersion}`);
|
|
49
|
+
}
|
|
50
|
+
// 6. Schedule npm install
|
|
51
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
52
|
+
context.logger.info('');
|
|
53
|
+
context.logger.info('🎉 Minahil library has been successfully configured!');
|
|
54
|
+
context.logger.info('');
|
|
55
|
+
context.logger.info('📚 Next steps:');
|
|
56
|
+
context.logger.info(' 1. Import components from "minahil" in your modules or standalone components');
|
|
57
|
+
context.logger.info(' 2. Check the documentation for available components');
|
|
58
|
+
context.logger.info('');
|
|
59
|
+
return tree;
|
|
60
|
+
};
|
|
61
|
+
}
|