tailjng 0.1.4 → 0.1.5

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.
@@ -1,188 +1,188 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { COLORS } = require('./colors');
4
- const { writeFileSafe } = require('./project-utils');
5
-
6
- const COLORS_SOURCE_REL = 'src/lib/components/colors-config';
7
- const COLORS_FILES = ['colors.config.ts', 'colors.safelist.css', 'README.md'];
8
-
9
- function getProjectColorsDir(appRoot) {
10
- return path.join(appRoot, 'src', 'app', 'tailjng', 'colors');
11
- }
12
-
13
- function resolveTailjngPackageRoot(workspaceRoot) {
14
- const fromNodeModules = path.join(workspaceRoot, 'node_modules', 'tailjng', COLORS_SOURCE_REL);
15
- if (fs.existsSync(fromNodeModules)) {
16
- return path.join(workspaceRoot, 'node_modules', 'tailjng');
17
- }
18
-
19
- const fromMonorepo = path.join(workspaceRoot, 'projects', 'tailjng', COLORS_SOURCE_REL);
20
- if (fs.existsSync(fromMonorepo)) {
21
- return path.join(workspaceRoot, 'projects', 'tailjng');
22
- }
23
-
24
- return null;
25
- }
26
-
27
- function getColorsSafelistImportLine(workspaceRoot, styleEntry, appProject) {
28
- const appRoot = path.join(workspaceRoot, appProject.root || '');
29
- const colorsSafelist = path.join(getProjectColorsDir(appRoot), 'colors.safelist.css');
30
-
31
- let stylePath;
32
- if (path.isAbsolute(styleEntry)) {
33
- stylePath = styleEntry;
34
- } else if (styleEntry.startsWith('projects/')) {
35
- stylePath = path.join(workspaceRoot, styleEntry);
36
- } else {
37
- stylePath = path.join(appRoot, styleEntry);
38
- }
39
-
40
- const targetSafelist = fs.existsSync(colorsSafelist)
41
- ? colorsSafelist
42
- : path.join(workspaceRoot, 'node_modules', 'tailjng', 'src', 'colors.safelist.css');
43
-
44
- let rel = path.relative(path.dirname(stylePath), targetSafelist).split(path.sep).join('/');
45
- if (!rel.startsWith('.')) rel = `./${rel}`;
46
- return `@import "${rel}";`;
47
- }
48
-
49
- function ensureProjectColorsConfig(workspaceRoot, appRoot, overwrite = false) {
50
- const packageRoot = resolveTailjngPackageRoot(workspaceRoot);
51
- if (!packageRoot) {
52
- console.log(`${COLORS.yellow}[tailjng CLI] WARNING: tailjng package not found — skip colors config copy${COLORS.reset}`);
53
- return { created: 0, skipped: 0, colorsDir: getProjectColorsDir(appRoot) };
54
- }
55
-
56
- const sourceDir = path.join(packageRoot, COLORS_SOURCE_REL);
57
- const colorsDir = getProjectColorsDir(appRoot);
58
- let created = 0;
59
- let skipped = 0;
60
-
61
- for (const file of COLORS_FILES) {
62
- const src = path.join(sourceDir, file);
63
- const dest = path.join(colorsDir, file);
64
- if (!fs.existsSync(src)) continue;
65
-
66
- const content = fs.readFileSync(src, 'utf8');
67
- if (writeFileSafe(dest, content, overwrite)) {
68
- created += 1;
69
- console.log(`${COLORS.green}✔ Created ${path.relative(workspaceRoot, dest)}${COLORS.reset}`);
70
- } else {
71
- skipped += 1;
72
- console.log(`${COLORS.dim}↷ Skipped (exists) ${path.relative(workspaceRoot, dest)}${COLORS.reset}`);
73
- }
74
- }
75
-
76
- return { created, skipped, colorsDir };
77
- }
78
-
79
- function ensureColorsSafelistImport(styleFilePath, importLine) {
80
- if (!fs.existsSync(styleFilePath)) return { changed: false };
81
-
82
- let content = fs.readFileSync(styleFilePath, 'utf8');
83
- const projectImport = /tailjng\/colors\/colors\.safelist\.css/;
84
- const npmImport = /node_modules\/tailjng\/src\/colors\.safelist\.css/;
85
- const anySafelistImport = /@import\s+"[^"]*colors\.safelist\.css";?/;
86
-
87
- if (projectImport.test(content)) {
88
- return { changed: false };
89
- }
90
-
91
- if (npmImport.test(content) && projectImport.test(importLine)) {
92
- content = content.replace(anySafelistImport, importLine);
93
- fs.writeFileSync(styleFilePath, content, 'utf8');
94
- return { changed: true, migrated: true };
95
- }
96
-
97
- if (content.includes('colors.safelist.css')) {
98
- return { changed: false };
99
- }
100
-
101
- const tailwindMatch = content.match(/@(?:import|use)\s+"tailwindcss";?/);
102
- if (tailwindMatch) {
103
- const insertAt = tailwindMatch.index + tailwindMatch[0].length;
104
- content = `${content.slice(0, insertAt)}\n${importLine}\n${content.slice(insertAt)}`;
105
- } else {
106
- content = `${importLine}\n${content}`;
107
- }
108
-
109
- fs.writeFileSync(styleFilePath, content, 'utf8');
110
- return { changed: true };
111
- }
112
-
113
- function patchTailjngProvidersColors(providersPath) {
114
- if (!fs.existsSync(providersPath)) return { changed: false };
115
-
116
- let content = fs.readFileSync(providersPath, 'utf8');
117
- if (content.includes('tailjngColorsProvider') || content.includes('../tailjng/colors/colors.config')) {
118
- return { changed: false };
119
- }
120
-
121
- const lines = content.split('\n');
122
- let lastImport = -1;
123
- for (let i = 0; i < lines.length; i += 1) {
124
- if (lines[i].startsWith('import ')) lastImport = i;
125
- }
126
-
127
- const importLine = "import { tailjngColorsProvider } from '../tailjng/colors/colors.config';";
128
- if (lastImport === -1) {
129
- content = `${importLine}\n${content}`;
130
- } else {
131
- lines.splice(lastImport + 1, 0, importLine);
132
- content = lines.join('\n');
133
- }
134
-
135
- if (content.includes('export const tailjngProviders = [')) {
136
- content = content.replace(
137
- /export const tailjngProviders = \[/,
138
- 'export const tailjngProviders = [\n tailjngColorsProvider,',
139
- );
140
- }
141
-
142
- fs.writeFileSync(providersPath, content, 'utf8');
143
- return { changed: true };
144
- }
145
-
146
- function patchAppConfigColors(appConfigPath, srcRoot) {
147
- const providersPath = path.join(srcRoot, 'app', 'config', 'tailjng.providers.ts');
148
- if (fs.existsSync(providersPath)) {
149
- return patchTailjngProvidersColors(providersPath);
150
- }
151
-
152
- if (!fs.existsSync(appConfigPath)) return { changed: false };
153
-
154
- let content = fs.readFileSync(appConfigPath, 'utf8');
155
- if (content.includes('tailjngColorsProvider') || content.includes('./tailjng/colors/colors.config')) {
156
- return { changed: false };
157
- }
158
-
159
- const lines = content.split('\n');
160
- let lastImport = -1;
161
- for (let i = 0; i < lines.length; i += 1) {
162
- if (lines[i].startsWith('import ')) lastImport = i;
163
- }
164
-
165
- const importLine = "import { tailjngColorsProvider } from './tailjng/colors/colors.config';";
166
- if (lastImport === -1) {
167
- content = `${importLine}\n${content}`;
168
- } else {
169
- lines.splice(lastImport + 1, 0, importLine);
170
- content = lines.join('\n');
171
- }
172
-
173
- if (content.includes('providers: [')) {
174
- content = content.replace(/providers:\s*\[/, 'providers: [\n tailjngColorsProvider,');
175
- }
176
-
177
- fs.writeFileSync(appConfigPath, content, 'utf8');
178
- return { changed: true };
179
- }
180
-
181
- module.exports = {
182
- getProjectColorsDir,
183
- getColorsSafelistImportLine,
184
- ensureProjectColorsConfig,
185
- ensureColorsSafelistImport,
186
- patchAppConfigColors,
187
- COLORS_FILES,
188
- };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { COLORS } = require('./colors');
4
+ const { writeFileSafe } = require('./project-utils');
5
+
6
+ const COLORS_SOURCE_REL = 'src/lib/components/colors-config';
7
+ const COLORS_FILES = ['colors.config.ts', 'colors.safelist.css', 'README.md'];
8
+
9
+ function getProjectColorsDir(appRoot) {
10
+ return path.join(appRoot, 'src', 'app', 'tailjng', 'colors');
11
+ }
12
+
13
+ function resolveTailjngPackageRoot(workspaceRoot) {
14
+ const fromNodeModules = path.join(workspaceRoot, 'node_modules', 'tailjng', COLORS_SOURCE_REL);
15
+ if (fs.existsSync(fromNodeModules)) {
16
+ return path.join(workspaceRoot, 'node_modules', 'tailjng');
17
+ }
18
+
19
+ const fromMonorepo = path.join(workspaceRoot, 'projects', 'tailjng', COLORS_SOURCE_REL);
20
+ if (fs.existsSync(fromMonorepo)) {
21
+ return path.join(workspaceRoot, 'projects', 'tailjng');
22
+ }
23
+
24
+ return null;
25
+ }
26
+
27
+ function getColorsSafelistImportLine(workspaceRoot, styleEntry, appProject) {
28
+ const appRoot = path.join(workspaceRoot, appProject.root || '');
29
+ const colorsSafelist = path.join(getProjectColorsDir(appRoot), 'colors.safelist.css');
30
+
31
+ let stylePath;
32
+ if (path.isAbsolute(styleEntry)) {
33
+ stylePath = styleEntry;
34
+ } else if (styleEntry.startsWith('projects/')) {
35
+ stylePath = path.join(workspaceRoot, styleEntry);
36
+ } else {
37
+ stylePath = path.join(appRoot, styleEntry);
38
+ }
39
+
40
+ const targetSafelist = fs.existsSync(colorsSafelist)
41
+ ? colorsSafelist
42
+ : path.join(workspaceRoot, 'node_modules', 'tailjng', 'src', 'colors.safelist.css');
43
+
44
+ let rel = path.relative(path.dirname(stylePath), targetSafelist).split(path.sep).join('/');
45
+ if (!rel.startsWith('.')) rel = `./${rel}`;
46
+ return `@import "${rel}";`;
47
+ }
48
+
49
+ function ensureProjectColorsConfig(workspaceRoot, appRoot, overwrite = false) {
50
+ const packageRoot = resolveTailjngPackageRoot(workspaceRoot);
51
+ if (!packageRoot) {
52
+ console.log(`${COLORS.yellow}[tailjng CLI] WARNING: tailjng package not found — skip colors config copy${COLORS.reset}`);
53
+ return { created: 0, skipped: 0, colorsDir: getProjectColorsDir(appRoot) };
54
+ }
55
+
56
+ const sourceDir = path.join(packageRoot, COLORS_SOURCE_REL);
57
+ const colorsDir = getProjectColorsDir(appRoot);
58
+ let created = 0;
59
+ let skipped = 0;
60
+
61
+ for (const file of COLORS_FILES) {
62
+ const src = path.join(sourceDir, file);
63
+ const dest = path.join(colorsDir, file);
64
+ if (!fs.existsSync(src)) continue;
65
+
66
+ const content = fs.readFileSync(src, 'utf8');
67
+ if (writeFileSafe(dest, content, overwrite)) {
68
+ created += 1;
69
+ console.log(`${COLORS.green}✔ Created ${path.relative(workspaceRoot, dest)}${COLORS.reset}`);
70
+ } else {
71
+ skipped += 1;
72
+ console.log(`${COLORS.dim}↷ Skipped (exists) ${path.relative(workspaceRoot, dest)}${COLORS.reset}`);
73
+ }
74
+ }
75
+
76
+ return { created, skipped, colorsDir };
77
+ }
78
+
79
+ function ensureColorsSafelistImport(styleFilePath, importLine) {
80
+ if (!fs.existsSync(styleFilePath)) return { changed: false };
81
+
82
+ let content = fs.readFileSync(styleFilePath, 'utf8');
83
+ const projectImport = /tailjng\/colors\/colors\.safelist\.css/;
84
+ const npmImport = /node_modules\/tailjng\/src\/colors\.safelist\.css/;
85
+ const anySafelistImport = /@import\s+"[^"]*colors\.safelist\.css";?/;
86
+
87
+ if (projectImport.test(content)) {
88
+ return { changed: false };
89
+ }
90
+
91
+ if (npmImport.test(content) && projectImport.test(importLine)) {
92
+ content = content.replace(anySafelistImport, importLine);
93
+ fs.writeFileSync(styleFilePath, content, 'utf8');
94
+ return { changed: true, migrated: true };
95
+ }
96
+
97
+ if (content.includes('colors.safelist.css')) {
98
+ return { changed: false };
99
+ }
100
+
101
+ const tailwindMatch = content.match(/@(?:import|use)\s+"tailwindcss";?/);
102
+ if (tailwindMatch) {
103
+ const insertAt = tailwindMatch.index + tailwindMatch[0].length;
104
+ content = `${content.slice(0, insertAt)}\n${importLine}\n${content.slice(insertAt)}`;
105
+ } else {
106
+ content = `${importLine}\n${content}`;
107
+ }
108
+
109
+ fs.writeFileSync(styleFilePath, content, 'utf8');
110
+ return { changed: true };
111
+ }
112
+
113
+ function patchTailjngProvidersColors(providersPath) {
114
+ if (!fs.existsSync(providersPath)) return { changed: false };
115
+
116
+ let content = fs.readFileSync(providersPath, 'utf8');
117
+ if (content.includes('tailjngColorsProvider') || content.includes('../tailjng/colors/colors.config')) {
118
+ return { changed: false };
119
+ }
120
+
121
+ const lines = content.split('\n');
122
+ let lastImport = -1;
123
+ for (let i = 0; i < lines.length; i += 1) {
124
+ if (lines[i].startsWith('import ')) lastImport = i;
125
+ }
126
+
127
+ const importLine = "import { tailjngColorsProvider } from '../tailjng/colors/colors.config';";
128
+ if (lastImport === -1) {
129
+ content = `${importLine}\n${content}`;
130
+ } else {
131
+ lines.splice(lastImport + 1, 0, importLine);
132
+ content = lines.join('\n');
133
+ }
134
+
135
+ if (content.includes('export const tailjngProviders = [')) {
136
+ content = content.replace(
137
+ /export const tailjngProviders = \[/,
138
+ 'export const tailjngProviders = [\n tailjngColorsProvider,',
139
+ );
140
+ }
141
+
142
+ fs.writeFileSync(providersPath, content, 'utf8');
143
+ return { changed: true };
144
+ }
145
+
146
+ function patchAppConfigColors(appConfigPath, srcRoot) {
147
+ const providersPath = path.join(srcRoot, 'app', 'config', 'tailjng.providers.ts');
148
+ if (fs.existsSync(providersPath)) {
149
+ return patchTailjngProvidersColors(providersPath);
150
+ }
151
+
152
+ if (!fs.existsSync(appConfigPath)) return { changed: false };
153
+
154
+ let content = fs.readFileSync(appConfigPath, 'utf8');
155
+ if (content.includes('tailjngColorsProvider') || content.includes('./tailjng/colors/colors.config')) {
156
+ return { changed: false };
157
+ }
158
+
159
+ const lines = content.split('\n');
160
+ let lastImport = -1;
161
+ for (let i = 0; i < lines.length; i += 1) {
162
+ if (lines[i].startsWith('import ')) lastImport = i;
163
+ }
164
+
165
+ const importLine = "import { tailjngColorsProvider } from './tailjng/colors/colors.config';";
166
+ if (lastImport === -1) {
167
+ content = `${importLine}\n${content}`;
168
+ } else {
169
+ lines.splice(lastImport + 1, 0, importLine);
170
+ content = lines.join('\n');
171
+ }
172
+
173
+ if (content.includes('providers: [')) {
174
+ content = content.replace(/providers:\s*\[/, 'providers: [\n tailjngColorsProvider,');
175
+ }
176
+
177
+ fs.writeFileSync(appConfigPath, content, 'utf8');
178
+ return { changed: true };
179
+ }
180
+
181
+ module.exports = {
182
+ getProjectColorsDir,
183
+ getColorsSafelistImportLine,
184
+ ensureProjectColorsConfig,
185
+ ensureColorsSafelistImport,
186
+ patchAppConfigColors,
187
+ COLORS_FILES,
188
+ };
@@ -1,39 +1,37 @@
1
- const { execSync } = require('child_process');
2
- const { COLORS } = require('./colors');
3
-
4
- const RUNTIME_PACKAGES = {
5
- 'lucide-angular': '^0.525.0',
6
- '@ng-icons/lucide': '>=32.0.0',
7
- 'date-fns': '^4.1.0',
8
- 'exceljs': '^4.4.0',
9
- 'xlsx': '^0.18.5',
10
- 'file-saver': '^2.0.5',
11
- };
12
-
13
- const DEV_PACKAGES = {
14
- tailwindcss: '^4.0.9',
15
- '@tailwindcss/postcss': '^4.0.9',
16
- postcss: '^8.5.3',
17
- autoprefixer: '^10.4.20',
18
- };
19
-
20
- function installPackages(workspaceRoot, packages, isDev = false) {
21
- const entries = Object.entries(packages);
22
- if (entries.length === 0) return;
23
-
24
- const spec = entries.map(([name, version]) => `${name}@${version}`).join(' ');
25
- const flag = isDev ? '--save-dev' : '--save';
26
- console.log(`${COLORS.blue}[tailjng CLI] Installing ${isDev ? 'dev ' : ''}dependencies...${COLORS.reset}`);
27
-
28
- execSync(`npm install ${flag} --legacy-peer-deps ${spec}`.replace(/\s+/g, ' ').trim(), {
29
- cwd: workspaceRoot,
30
- stdio: 'inherit',
31
- shell: true,
32
- });
33
- }
34
-
35
- module.exports = {
36
- RUNTIME_PACKAGES,
37
- DEV_PACKAGES,
38
- installPackages,
39
- };
1
+ const { execSync } = require('child_process');
2
+ const { COLORS } = require('./colors');
3
+
4
+ const RUNTIME_PACKAGES = {
5
+ 'lucide-angular': '^0.577.0',
6
+ 'date-fns': '^4.1.0',
7
+ 'exceljs': '^4.4.0',
8
+ 'file-saver': '^2.0.5',
9
+ };
10
+
11
+ const DEV_PACKAGES = {
12
+ tailwindcss: '^4.0.9',
13
+ '@tailwindcss/postcss': '^4.0.9',
14
+ postcss: '^8.5.3',
15
+ autoprefixer: '^10.4.20',
16
+ };
17
+
18
+ function installPackages(workspaceRoot, packages, isDev = false) {
19
+ const entries = Object.entries(packages);
20
+ if (entries.length === 0) return;
21
+
22
+ const spec = entries.map(([name, version]) => `${name}@${version}`).join(' ');
23
+ const flag = isDev ? '--save-dev' : '--save';
24
+ console.log(`${COLORS.blue}[tailjng CLI] Installing ${isDev ? 'dev ' : ''}dependencies...${COLORS.reset}`);
25
+
26
+ execSync(`npm install ${flag} --legacy-peer-deps ${spec}`.replace(/\s+/g, ' ').trim(), {
27
+ cwd: workspaceRoot,
28
+ stdio: 'inherit',
29
+ shell: true,
30
+ });
31
+ }
32
+
33
+ module.exports = {
34
+ RUNTIME_PACKAGES,
35
+ DEV_PACKAGES,
36
+ installPackages,
37
+ };