@filip.mazev/blocks 1.0.0 → 1.0.2
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
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@filip.mazev/blocks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"schematics": "./schematics/collection.json",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@angular/core": "^
|
|
6
|
+
"@angular/core": "^21.1.1",
|
|
7
7
|
"@filip.mazev/blocks-core": "latest",
|
|
8
8
|
"@filip.mazev/modal": "latest",
|
|
9
9
|
"@filip.mazev/toastr": "latest"
|
|
@@ -16,7 +16,10 @@ function addDependencies(tree, context) {
|
|
|
16
16
|
context.logger.warn('Could not find package.json. Skipping dependency injection.');
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const packageJsonBuffer = tree.read(packageJsonPath);
|
|
20
|
+
if (!packageJsonBuffer)
|
|
21
|
+
return;
|
|
22
|
+
const packageJson = JSON.parse(packageJsonBuffer.toString('utf-8'));
|
|
20
23
|
if (!packageJson.dependencies) {
|
|
21
24
|
packageJson.dependencies = {};
|
|
22
25
|
}
|
|
@@ -25,22 +28,52 @@ function addDependencies(tree, context) {
|
|
|
25
28
|
'@filip.mazev/modal',
|
|
26
29
|
'@filip.mazev/toastr'
|
|
27
30
|
];
|
|
31
|
+
let dependenciesAdded = false;
|
|
28
32
|
packages.forEach(pkg => {
|
|
29
33
|
if (!packageJson.dependencies[pkg]) {
|
|
30
34
|
packageJson.dependencies[pkg] = 'latest';
|
|
31
35
|
context.logger.info(`Added ${pkg} to dependencies.`);
|
|
36
|
+
dependenciesAdded = true;
|
|
32
37
|
}
|
|
33
38
|
});
|
|
34
|
-
|
|
39
|
+
if (dependenciesAdded) {
|
|
40
|
+
tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
function injectStyles(tree, context) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
const workspaceConfigPath = '/angular.json';
|
|
45
|
+
if (!tree.exists(workspaceConfigPath)) {
|
|
46
|
+
context.logger.warn('Could not find angular.json. Please configure the Blocks theme manually.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const workspaceConfigBuffer = tree.read(workspaceConfigPath);
|
|
50
|
+
if (!workspaceConfigBuffer)
|
|
51
|
+
return;
|
|
52
|
+
const workspaceConfig = JSON.parse(workspaceConfigBuffer.toString('utf-8'));
|
|
53
|
+
const projectName = workspaceConfig.defaultProject || Object.keys(workspaceConfig.projects)[0];
|
|
54
|
+
const project = workspaceConfig.projects[projectName];
|
|
55
|
+
if (!project) {
|
|
56
|
+
context.logger.warn('Could not find a valid project in angular.json.');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const buildOptions = project.architect?.build?.options;
|
|
60
|
+
if (!buildOptions || !buildOptions.styles) {
|
|
61
|
+
context.logger.warn(`Could not find styles configuration for project "${projectName}".`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let targetStylePath = '';
|
|
65
|
+
for (const style of buildOptions.styles) {
|
|
66
|
+
const styleString = typeof style === 'string' ? style : style.input;
|
|
67
|
+
if (styleString && (styleString.endsWith('.scss') || styleString.endsWith('.sass'))) {
|
|
68
|
+
targetStylePath = styleString;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!targetStylePath || !tree.exists(targetStylePath)) {
|
|
73
|
+
context.logger.warn('Could not locate a global .scss or .sass file. Please configure the Blocks theme manually.');
|
|
41
74
|
return;
|
|
42
75
|
}
|
|
43
|
-
const content = tree.read(
|
|
76
|
+
const content = tree.read(targetStylePath).toString('utf-8');
|
|
44
77
|
if (content.includes('@filip.mazev/blocks-core')) {
|
|
45
78
|
context.logger.info('Blocks SCSS configuration already exists. Skipping style injection.');
|
|
46
79
|
return;
|
|
@@ -58,6 +91,6 @@ function injectStyles(tree, context) {
|
|
|
58
91
|
}
|
|
59
92
|
}
|
|
60
93
|
`;
|
|
61
|
-
tree.overwrite(
|
|
62
|
-
context.logger.info(
|
|
94
|
+
tree.overwrite(targetStylePath, blocksThemeSnippet + '\n' + content);
|
|
95
|
+
context.logger.info(`Successfully injected Blocks theme configuration into ${targetStylePath}.`);
|
|
63
96
|
}
|