@ethlete/core 5.0.0-next.3 ā 5.0.0-next.31
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/CHANGELOG.md +304 -0
- package/README.md +30 -4
- package/fesm2022/ethlete-core.mjs +3944 -1102
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/generators/generators.json +9 -4
- package/generators/migrate-to-v5/color-naming.js +175 -0
- package/generators/migrate-to-v5/migration.js +6 -0
- package/generators/migrate-to-v5/schema.json +5 -0
- package/generators/{tailwind-4-theme ā tailwind-4-color-theme}/generator.js +191 -91
- package/generators/tailwind-4-color-theme/schema.json +44 -0
- package/generators/tailwind-4-surface-theme/generator.js +459 -0
- package/generators/tailwind-4-surface-theme/schema.json +48 -0
- package/package.json +13 -13
- package/types/ethlete-core.d.ts +1947 -999
- package/generators/tailwind-4-theme/schema.json +0 -32
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
"schema": "./migrate-to-v5/schema.json",
|
|
6
6
|
"description": "Migrate to v5"
|
|
7
7
|
},
|
|
8
|
-
"tailwind-4-theme": {
|
|
9
|
-
"factory": "./tailwind-4-theme/generator",
|
|
10
|
-
"schema": "./tailwind-4-theme/schema.json",
|
|
11
|
-
"description": "Generate theming for Tailwind CSS v4"
|
|
8
|
+
"tailwind-4-color-theme": {
|
|
9
|
+
"factory": "./tailwind-4-color-theme/generator",
|
|
10
|
+
"schema": "./tailwind-4-color-theme/schema.json",
|
|
11
|
+
"description": "Generate color theming for Tailwind CSS v4"
|
|
12
|
+
},
|
|
13
|
+
"tailwind-4-surface-theme": {
|
|
14
|
+
"factory": "./tailwind-4-surface-theme/generator",
|
|
15
|
+
"schema": "./tailwind-4-surface-theme/schema.json",
|
|
16
|
+
"description": "Generate surface theming for Tailwind CSS v4"
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { logger } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Symbol renames in TypeScript files (imports + usage).
|
|
4
|
+
*/
|
|
5
|
+
const TS_SYMBOL_RENAMES = {
|
|
6
|
+
ProvideThemeDirective: 'ProvideColorDirective',
|
|
7
|
+
THEME_PROVIDER: 'COLOR_PROVIDER',
|
|
8
|
+
ColorThemedDirective: 'ColoredDirective',
|
|
9
|
+
ColorThemedStylesComponent: 'ColoredStylesComponent',
|
|
10
|
+
SurfaceThemedDirective: 'SurfacedDirective',
|
|
11
|
+
SurfaceThemedStylesComponent: 'SurfacedStylesComponent',
|
|
12
|
+
injectThemesPrefix: 'injectColorThemesPrefix',
|
|
13
|
+
createCssThemeName: 'createCssColorThemeName',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* String replacements applied to HTML templates and inline templates.
|
|
17
|
+
*/
|
|
18
|
+
const TEMPLATE_REPLACEMENTS = [
|
|
19
|
+
['[etProvideTheme]', '[etProvideColor]'],
|
|
20
|
+
['etProvideTheme', 'etProvideColor'],
|
|
21
|
+
['[etProvideAltTheme]', '[etProvideAltColor]'],
|
|
22
|
+
['etProvideAltTheme', 'etProvideAltColor'],
|
|
23
|
+
['[etColorThemed]', '[etColored]'],
|
|
24
|
+
['etColorThemed', 'etColored'],
|
|
25
|
+
['[etSurfaceThemed]', '[etSurfaced]'],
|
|
26
|
+
['etSurfaceThemed', 'etSurfaced'],
|
|
27
|
+
['[theme]=', '[color]='],
|
|
28
|
+
['[altTheme]=', '[altColor]='],
|
|
29
|
+
['et-theme-alt--', 'et-color-alt--'],
|
|
30
|
+
['et-theme--', 'et-color--'],
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* CSS class name replacements.
|
|
34
|
+
*/
|
|
35
|
+
const CSS_REPLACEMENTS = [
|
|
36
|
+
['.et-color-themed', '.et-colored'],
|
|
37
|
+
['.et-surface-themed', '.et-surfaced'],
|
|
38
|
+
['.et-theme--', '.et-color--'],
|
|
39
|
+
['.et-theme-alt--', '.et-color-alt--'],
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Host directive input alias replacements in TypeScript files.
|
|
43
|
+
*/
|
|
44
|
+
const HOST_DIRECTIVE_REPLACEMENTS = [
|
|
45
|
+
["'etProvideTheme:theme'", "'etProvideColor:color'"],
|
|
46
|
+
["'etProvideAltTheme:altTheme'", "'etProvideAltColor:altColor'"],
|
|
47
|
+
["'etProvideTheme:color'", "'etProvideColor:color'"],
|
|
48
|
+
["'etProvideAltTheme:altColor'", "'etProvideAltColor:altColor'"],
|
|
49
|
+
['"etProvideTheme:theme"', '"etProvideColor:color"'],
|
|
50
|
+
['"etProvideAltTheme:altTheme"', '"etProvideAltColor:altColor"'],
|
|
51
|
+
['"etProvideTheme"', '"etProvideColor"'],
|
|
52
|
+
['"etProvideAltTheme"', '"etProvideAltColor"'],
|
|
53
|
+
];
|
|
54
|
+
export default async function migrateColorNaming(tree) {
|
|
55
|
+
logger.log('\nš Migrating theme ā color naming...\n');
|
|
56
|
+
const tsFiles = [];
|
|
57
|
+
const htmlFiles = [];
|
|
58
|
+
const cssFiles = [];
|
|
59
|
+
findFiles('.', tree, tsFiles, htmlFiles, cssFiles);
|
|
60
|
+
let filesModified = 0;
|
|
61
|
+
for (const filePath of tsFiles) {
|
|
62
|
+
const wasModified = migrateTypeScriptFile(tree, filePath);
|
|
63
|
+
if (wasModified) {
|
|
64
|
+
filesModified++;
|
|
65
|
+
logger.log(` ā ${filePath}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const filePath of htmlFiles) {
|
|
69
|
+
const wasModified = migrateTemplateFile(tree, filePath);
|
|
70
|
+
if (wasModified) {
|
|
71
|
+
filesModified++;
|
|
72
|
+
logger.log(` ā ${filePath}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const filePath of cssFiles) {
|
|
76
|
+
const wasModified = migrateCssFile(tree, filePath);
|
|
77
|
+
if (wasModified) {
|
|
78
|
+
filesModified++;
|
|
79
|
+
logger.log(` ā ${filePath}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (filesModified > 0) {
|
|
83
|
+
logger.log(`\nā
Successfully migrated color naming in ${filesModified} file(s)\n`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
logger.log('\nā¹ļø No files needed migration\n');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function findFiles(dir, tree, tsFiles, htmlFiles, cssFiles) {
|
|
90
|
+
const children = tree.children(dir);
|
|
91
|
+
for (const child of children) {
|
|
92
|
+
const path = dir === '.' ? child : `${dir}/${child}`;
|
|
93
|
+
if (tree.isFile(path)) {
|
|
94
|
+
if (path.includes('node_modules'))
|
|
95
|
+
continue;
|
|
96
|
+
if (path.endsWith('.ts') && !path.endsWith('.spec.ts')) {
|
|
97
|
+
tsFiles.push(path);
|
|
98
|
+
}
|
|
99
|
+
else if (path.endsWith('.html')) {
|
|
100
|
+
htmlFiles.push(path);
|
|
101
|
+
}
|
|
102
|
+
else if (path.endsWith('.css') || path.endsWith('.scss')) {
|
|
103
|
+
cssFiles.push(path);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
if (child === 'node_modules')
|
|
108
|
+
continue;
|
|
109
|
+
findFiles(path, tree, tsFiles, htmlFiles, cssFiles);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function migrateTypeScriptFile(tree, filePath) {
|
|
114
|
+
let content = tree.read(filePath, 'utf-8');
|
|
115
|
+
if (!content)
|
|
116
|
+
return false;
|
|
117
|
+
const original = content;
|
|
118
|
+
// Rename symbols
|
|
119
|
+
for (const [oldName, newName] of Object.entries(TS_SYMBOL_RENAMES)) {
|
|
120
|
+
content = replaceWholeWord(content, oldName, newName);
|
|
121
|
+
}
|
|
122
|
+
// Rename host directive input aliases
|
|
123
|
+
for (const [oldStr, newStr] of HOST_DIRECTIVE_REPLACEMENTS) {
|
|
124
|
+
content = content.replaceAll(oldStr, newStr);
|
|
125
|
+
}
|
|
126
|
+
// Handle inline templates in TypeScript files
|
|
127
|
+
for (const [oldStr, newStr] of TEMPLATE_REPLACEMENTS) {
|
|
128
|
+
content = content.replaceAll(oldStr, newStr);
|
|
129
|
+
}
|
|
130
|
+
// Handle CSS in TypeScript files
|
|
131
|
+
for (const [oldStr, newStr] of CSS_REPLACEMENTS) {
|
|
132
|
+
content = content.replaceAll(oldStr, newStr);
|
|
133
|
+
}
|
|
134
|
+
if (content !== original) {
|
|
135
|
+
tree.write(filePath, content);
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
function migrateTemplateFile(tree, filePath) {
|
|
141
|
+
let content = tree.read(filePath, 'utf-8');
|
|
142
|
+
if (!content)
|
|
143
|
+
return false;
|
|
144
|
+
const original = content;
|
|
145
|
+
for (const [oldStr, newStr] of TEMPLATE_REPLACEMENTS) {
|
|
146
|
+
content = content.replaceAll(oldStr, newStr);
|
|
147
|
+
}
|
|
148
|
+
if (content !== original) {
|
|
149
|
+
tree.write(filePath, content);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
function migrateCssFile(tree, filePath) {
|
|
155
|
+
let content = tree.read(filePath, 'utf-8');
|
|
156
|
+
if (!content)
|
|
157
|
+
return false;
|
|
158
|
+
const original = content;
|
|
159
|
+
for (const [oldStr, newStr] of CSS_REPLACEMENTS) {
|
|
160
|
+
content = content.replaceAll(oldStr, newStr);
|
|
161
|
+
}
|
|
162
|
+
if (content !== original) {
|
|
163
|
+
tree.write(filePath, content);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
function replaceWholeWord(content, oldWord, newWord) {
|
|
169
|
+
const regex = new RegExp(`\\b${escapeRegex(oldWord)}\\b`, 'g');
|
|
170
|
+
return content.replace(regex, newWord);
|
|
171
|
+
}
|
|
172
|
+
function escapeRegex(str) {
|
|
173
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=color-naming.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatFiles } from '@nx/devkit';
|
|
2
|
+
import migrateColorNaming from './color-naming.js';
|
|
2
3
|
import migrateCreateProvider from './create-provider.js';
|
|
3
4
|
import migrateRouterStateService from './router-state-service.js';
|
|
4
5
|
import migrateViewportService from './viewport-service.js';
|
|
@@ -18,6 +19,11 @@ export default async function migrate(tree, schema) {
|
|
|
18
19
|
if (shouldMigrateRouterStateService) {
|
|
19
20
|
await migrateRouterStateService(tree);
|
|
20
21
|
}
|
|
22
|
+
const shouldMigrateColorNaming = schema.migrateColorNaming !== false;
|
|
23
|
+
if (shouldMigrateColorNaming) {
|
|
24
|
+
console.log(' ⢠Migrating theme ā color naming...');
|
|
25
|
+
await migrateColorNaming(tree);
|
|
26
|
+
}
|
|
21
27
|
if (!schema.skipFormat) {
|
|
22
28
|
console.log(' ⢠Formatting files...');
|
|
23
29
|
await formatFiles(tree);
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"type": "boolean",
|
|
24
24
|
"description": "Migrate router state service to v5",
|
|
25
25
|
"default": true
|
|
26
|
+
},
|
|
27
|
+
"migrateColorNaming": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Migrate theme naming to color naming (ProvideThemeDirective -> ProvideColorDirective, etc.)",
|
|
30
|
+
"default": true
|
|
26
31
|
}
|
|
27
32
|
},
|
|
28
33
|
"required": []
|