tailjng 0.1.2 → 0.1.3

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.
@@ -25,6 +25,7 @@ const {
25
25
  hasTailwindSetup,
26
26
  getTailjngSafelistCssImport,
27
27
  ensureTailjngSafelistImport,
28
+ alignAngularAnimationsInPackageJson,
28
29
  resolveStyleFilePath,
29
30
  fileExists,
30
31
  } = require('../settings/project-utils');
@@ -96,12 +97,7 @@ function installPackages(workspaceRoot, packages, isDev = false) {
96
97
  });
97
98
  };
98
99
 
99
- try {
100
- run();
101
- } catch {
102
- console.log(`${COLORS.yellow}[tailjng CLI] Retrying with --legacy-peer-deps...${COLORS.reset}`);
103
- run('--legacy-peer-deps');
104
- }
100
+ run('--legacy-peer-deps');
105
101
  }
106
102
 
107
103
  function resolveTargetPath(workspaceRoot, appProject, relativePath, appRootRelative = false) {
@@ -180,12 +176,19 @@ async function runInitApp() {
180
176
  console.log(`${COLORS.yellow}Install it first: npm install tailjng${COLORS.reset}`);
181
177
  }
182
178
 
179
+ // Siempre alinear @angular/animations con la versión real de @angular/core del proyecto
180
+ const animationsAligned = alignAngularAnimationsInPackageJson(workspaceRoot);
181
+ if (animationsAligned.changed) {
182
+ console.log(`${COLORS.cyan}[tailjng CLI] Aligned @angular/animations → ${animationsAligned.version} (same as @angular/core)${COLORS.reset}`);
183
+ Object.assign(packageJson, readJson(packageJsonPath));
184
+ }
185
+
183
186
  if (installDeps) {
184
187
  if (tailwindReady) {
185
188
  console.log(`${COLORS.cyan}[tailjng CLI] Tailwind already configured — skipping Tailwind/PostCSS packages and .postcssrc.json${COLORS.reset}`);
186
189
  }
187
190
 
188
- const runtimePackages = resolveRuntimePackages(packageJson, RUNTIME_PACKAGES);
191
+ const runtimePackages = resolveRuntimePackages(packageJson, RUNTIME_PACKAGES, workspaceRoot);
189
192
  const devPackages = resolveDevPackages(packageJson, DEV_PACKAGES, tailwindReady);
190
193
  const missingRuntime = Object.fromEntries(getMissingPackages(packageJson, runtimePackages, workspaceRoot));
191
194
  const missingDev = Object.fromEntries(getMissingPackages(packageJson, devPackages, workspaceRoot));
@@ -244,15 +244,56 @@ function getMergedDependencies(packageJson) {
244
244
  return { ...packageJson.dependencies, ...packageJson.devDependencies };
245
245
  }
246
246
 
247
- /** Alinea @angular/animations con la línea de @angular/core del proyecto (evita ERESOLVE 19.2.0 vs 19.2.25). */
248
- function resolveRuntimePackages(packageJson, basePackages) {
247
+ function getInstalledPackageVersion(workspaceRoot, name) {
248
+ const pkgPath = path.join(workspaceRoot, 'node_modules', ...name.split('/'), 'package.json');
249
+ if (!fs.existsSync(pkgPath)) return null;
250
+ try {
251
+ return JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
252
+ } catch {
253
+ return null;
254
+ }
255
+ }
256
+
257
+ function resolveAngularAnimationsSpec(packageJson, workspaceRoot) {
258
+ const deps = getMergedDependencies(packageJson);
259
+ const coreInstalled = workspaceRoot ? getInstalledPackageVersion(workspaceRoot, '@angular/core') : null;
260
+ if (coreInstalled) return `^${coreInstalled}`;
261
+ if (deps['@angular/core']) return deps['@angular/core'];
262
+ return '^19.2.0';
263
+ }
264
+
265
+ /** Corrige @angular/animations para usar la misma versión que @angular/core del proyecto. */
266
+ function alignAngularAnimationsInPackageJson(workspaceRoot) {
267
+ const pkgPath = path.join(workspaceRoot, 'package.json');
268
+ if (!fs.existsSync(pkgPath)) return { changed: false };
269
+
270
+ const pkg = readJson(pkgPath);
271
+ const deps = pkg.dependencies || {};
272
+ const coreInstalled = getInstalledPackageVersion(workspaceRoot, '@angular/core');
273
+ const coreSpec = deps['@angular/core'];
274
+
275
+ // Preferir versión instalada (ej. 19.2.25); si no, la misma entrada que core en package.json
276
+ const aligned = coreInstalled ? `^${coreInstalled}` : coreSpec;
277
+ if (!aligned) return { changed: false };
278
+
279
+ if (!deps['@angular/animations']) return { changed: false };
280
+ if (deps['@angular/animations'] === aligned) return { changed: false };
281
+
282
+ deps['@angular/animations'] = aligned;
283
+ pkg.dependencies = deps;
284
+ writeJson(pkgPath, pkg);
285
+ return { changed: true, version: aligned };
286
+ }
287
+
288
+ /** Alinea @angular/animations con la versión instalada de @angular/core (evita ERESOLVE 19.2.0 vs 19.2.25). */
289
+ function resolveRuntimePackages(packageJson, basePackages, workspaceRoot = null) {
249
290
  const packages = { ...basePackages };
250
291
  const deps = getMergedDependencies(packageJson);
251
292
 
252
293
  if (deps['@angular/animations']) {
253
294
  delete packages['@angular/animations'];
254
- } else if (deps['@angular/core']) {
255
- packages['@angular/animations'] = deps['@angular/core'];
295
+ } else if (deps['@angular/core'] || (workspaceRoot && getInstalledPackageVersion(workspaceRoot, '@angular/core'))) {
296
+ packages['@angular/animations'] = resolveAngularAnimationsSpec(packageJson, workspaceRoot);
256
297
  }
257
298
 
258
299
  return packages;
@@ -327,6 +368,7 @@ module.exports = {
327
368
  getMergedDependencies,
328
369
  resolveRuntimePackages,
329
370
  resolveDevPackages,
371
+ alignAngularAnimationsInPackageJson,
330
372
  hasTailwindSetup,
331
373
  fileExists,
332
374
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailjng",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.2.0",
6
6
  "@angular/core": "^19.2.0",
Binary file
package/tailjng-0.1.2.tgz DELETED
Binary file