itw-python-builder 0.1.29__tar.gz → 0.1.31__tar.gz

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.
Files changed (20) hide show
  1. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/PKG-INFO +1 -1
  2. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/ssr_tasks.py +60 -6
  3. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/PKG-INFO +1 -1
  4. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/pyproject.toml +1 -1
  5. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/LICENSE +0 -0
  6. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/README.md +0 -0
  7. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/.pylintrc +0 -0
  8. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/__init__.py +0 -0
  9. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/cli.py +0 -0
  10. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/tasks.py +0 -0
  11. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/templates/server.sitemap.snippet.ts +0 -0
  12. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/templates/sitemap.routes.ts +0 -0
  13. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/utils.py +0 -0
  14. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder/version.py +0 -0
  15. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/SOURCES.txt +0 -0
  16. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/dependency_links.txt +0 -0
  17. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/entry_points.txt +0 -0
  18. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/requires.txt +0 -0
  19. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/top_level.txt +0 -0
  20. {itw_python_builder-0.1.29 → itw_python_builder-0.1.31}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itw_python_builder
3
- Version: 0.1.29
3
+ Version: 0.1.31
4
4
  Summary: Standardized Django deployment pipeline with Docker, testing, and SonarQube integration
5
5
  Author-email: IT-Works <contact@it-works.io>
6
6
  License: MIT
@@ -34,6 +34,39 @@ def _angular_major_version() -> int:
34
34
  return int(match.group(1)) if match else 0
35
35
 
36
36
 
37
+ def _angular_core_installed_version() -> str:
38
+ """Return the exact installed @angular/core version from node_modules, or '' if not found."""
39
+ pkg_path = os.path.join(os.getcwd(), 'node_modules', '@angular', 'core', 'package.json')
40
+ if not os.path.isfile(pkg_path):
41
+ return ''
42
+ with open(pkg_path, 'r', encoding='utf-8') as fp:
43
+ return json.load(fp).get('version', '')
44
+
45
+
46
+ def _pin_ssr_deps_in_package_json(target_version: str) -> list:
47
+ """Pin @angular/ssr and @angular/platform-server in package.json to exact target_version.
48
+
49
+ Returns the list of packages whose entries were changed (or added). Does NOT touch
50
+ other @angular/* packages — only the two that @angular/ssr's install touches and
51
+ which carry strict peer-dependencies. This prevents npm from re-resolving them to
52
+ a newer patch that wouldn't match the installed @angular/core.
53
+ """
54
+ pkg_path = os.path.join(os.getcwd(), 'package.json')
55
+ with open(pkg_path, 'r', encoding='utf-8') as fp:
56
+ data = json.load(fp)
57
+ deps = data.setdefault('dependencies', {})
58
+ changed = []
59
+ for pkg in ('@angular/ssr', '@angular/platform-server'):
60
+ if deps.get(pkg) != target_version:
61
+ deps[pkg] = target_version
62
+ changed.append(pkg)
63
+ if changed:
64
+ with open(pkg_path, 'w', encoding='utf-8') as fp:
65
+ json.dump(data, fp, indent=2)
66
+ fp.write('\n')
67
+ return changed
68
+
69
+
37
70
  TEMPLATES_DIR = Path(__file__).parent / 'templates'
38
71
 
39
72
  SITEMAP_IMPORT_LINE = "import {sitemapEntries} from './src/sitemap.routes';"
@@ -51,18 +84,39 @@ def _load_template(name: str) -> str:
51
84
 
52
85
 
53
86
  def _run_ng_add_ssr(ctx: Context) -> None:
54
- """Run `ng add @angular/ssr` with flags appropriate to the project's Angular version.
87
+ """Pin SSR deps to the installed @angular/core version, then run `ng add @angular/ssr`.
88
+
89
+ Why: @angular/platform-server (pulled in by @angular/ssr) has strict per-patch
90
+ peer-deps — platform-server@X.Y.Z demands @angular/core@X.Y.Z *exactly*. If
91
+ package.json declares platform-server as a range like ^X.Y.0, npm resolves to
92
+ the latest patch (often newer than the installed core), which breaks the install.
55
93
 
56
- Angular 18 and earlier: no `--server-routing` flag (schematic rejects it).
57
- Angular 19+: pass `--server-routing=false` to keep the classic setup, matching
58
- the layout itw expects (single `server` target, not the new server router).
94
+ The fix is to pin only the two new packages (@angular/ssr and @angular/platform-server)
95
+ in package.json to the exact patch that matches the installed @angular/core. This
96
+ leaves every other @angular/* package alone — no upgrades, no downgrades and
97
+ lets ng add → npm install resolve cleanly without --legacy-peer-deps or --force.
98
+
99
+ Flags on `ng add`:
100
+ - Angular 18 and earlier: no `--server-routing` flag (schematic rejects it).
101
+ - Angular 19+: pass `--server-routing=false` to keep the classic setup.
59
102
  """
60
103
  major = _angular_major_version()
104
+ installed_core = _angular_core_installed_version()
105
+
106
+ if installed_core:
107
+ changed = _pin_ssr_deps_in_package_json(installed_core)
108
+ if changed:
109
+ pkgs = ', '.join(changed)
110
+ print(f'[itw] Pinned {pkgs} to {installed_core} in package.json (matches installed @angular/core).')
111
+ package_spec = f'@angular/ssr@{installed_core}'
112
+ else:
113
+ package_spec = '@angular/ssr'
114
+
61
115
  flags = '--skip-confirmation'
62
116
  if major >= 19:
63
117
  flags += ' --server-routing=false'
64
- print(f'[itw] Running `ng add @angular/ssr` (Angular {major}, this may take a minute)...')
65
- ctx.run(f'npx ng add @angular/ssr {flags}')
118
+ print(f'[itw] Running `ng add {package_spec}` (Angular {major}, this may take a minute)...')
119
+ ctx.run(f'npx ng add {package_spec} {flags}')
66
120
 
67
121
 
68
122
  def _install_ngx_seo_helper(ctx: Context) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itw_python_builder
3
- Version: 0.1.29
3
+ Version: 0.1.31
4
4
  Summary: Standardized Django deployment pipeline with Docker, testing, and SonarQube integration
5
5
  Author-email: IT-Works <contact@it-works.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itw_python_builder"
7
- version = "0.1.29"
7
+ version = "0.1.31"
8
8
  description = "Standardized Django deployment pipeline with Docker, testing, and SonarQube integration"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"