itw-python-builder 0.1.30__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.30 → itw_python_builder-0.1.31}/PKG-INFO +1 -1
  2. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/ssr_tasks.py +43 -16
  3. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/PKG-INFO +1 -1
  4. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/pyproject.toml +1 -1
  5. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/LICENSE +0 -0
  6. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/README.md +0 -0
  7. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/.pylintrc +0 -0
  8. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/__init__.py +0 -0
  9. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/cli.py +0 -0
  10. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/tasks.py +0 -0
  11. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/templates/server.sitemap.snippet.ts +0 -0
  12. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/templates/sitemap.routes.ts +0 -0
  13. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/utils.py +0 -0
  14. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder/version.py +0 -0
  15. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/SOURCES.txt +0 -0
  16. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/dependency_links.txt +0 -0
  17. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/entry_points.txt +0 -0
  18. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/requires.txt +0 -0
  19. {itw_python_builder-0.1.30 → itw_python_builder-0.1.31}/itw_python_builder.egg-info/top_level.txt +0 -0
  20. {itw_python_builder-0.1.30 → 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.30
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
@@ -35,12 +35,7 @@ def _angular_major_version() -> int:
35
35
 
36
36
 
37
37
  def _angular_core_installed_version() -> str:
38
- """Return the exact installed @angular/core version from node_modules, or '' if not found.
39
-
40
- Used to pin `ng add @angular/ssr@<this>` so platform-server's strict peer-deps
41
- (which demand the same patch across all @angular/* packages) align with what's
42
- already installed — no need for --legacy-peer-deps or --force.
43
- """
38
+ """Return the exact installed @angular/core version from node_modules, or '' if not found."""
44
39
  pkg_path = os.path.join(os.getcwd(), 'node_modules', '@angular', 'core', 'package.json')
45
40
  if not os.path.isfile(pkg_path):
46
41
  return ''
@@ -48,6 +43,30 @@ def _angular_core_installed_version() -> str:
48
43
  return json.load(fp).get('version', '')
49
44
 
50
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
+
51
70
  TEMPLATES_DIR = Path(__file__).parent / 'templates'
52
71
 
53
72
  SITEMAP_IMPORT_LINE = "import {sitemapEntries} from './src/sitemap.routes';"
@@ -65,26 +84,34 @@ def _load_template(name: str) -> str:
65
84
 
66
85
 
67
86
  def _run_ng_add_ssr(ctx: Context) -> None:
68
- """Run `ng add @angular/ssr` pinned to the project's installed @angular/core patch.
87
+ """Pin SSR deps to the installed @angular/core version, then run `ng add @angular/ssr`.
69
88
 
70
- Angular's @angular/platform-server (pulled in by @angular/ssr) has strict
71
- peer-dependenciesevery patch version demands the exact same patch across
72
- all @angular/* packages. Without pinning, `ng add` grabs the latest patch and
73
- breaks any project not on that exact patch. Pinning to the installed core
74
- version aligns everything cleanly without bypassing npm's resolver.
89
+ Why: @angular/platform-server (pulled in by @angular/ssr) has strict per-patch
90
+ peer-depsplatform-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.
75
93
 
76
- Flags:
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`:
77
100
  - Angular 18 and earlier: no `--server-routing` flag (schematic rejects it).
78
- - Angular 19+: pass `--server-routing=false` to keep the classic setup,
79
- matching the layout itw expects (single `server` target, not the new
80
- server router).
101
+ - Angular 19+: pass `--server-routing=false` to keep the classic setup.
81
102
  """
82
103
  major = _angular_major_version()
83
104
  installed_core = _angular_core_installed_version()
105
+
84
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).')
85
111
  package_spec = f'@angular/ssr@{installed_core}'
86
112
  else:
87
113
  package_spec = '@angular/ssr'
114
+
88
115
  flags = '--skip-confirmation'
89
116
  if major >= 19:
90
117
  flags += ' --server-routing=false'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itw_python_builder
3
- Version: 0.1.30
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.30"
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"