@nipe-solutions/flex-layout-codemod 2.0.0-beta.1 → 2.0.0-beta.2

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Minor Changes
6
+
7
+ - 89c6f92: Make migration planning the default, require `--write` to apply project changes, and publish schema-2 reports with explicit execution and application state.
8
+ - 77391e3: Launch the public documentation site and browser-only single-template migration playground, and point package metadata to the production documentation homepage.
9
+ - f058c0b: Add opt-in Tailwind conversion for the archived orientation breakpoints and project-configured print fallback behavior.
10
+ - 40e3719: Add an explicit native CSS target that updates templates and one owned companion stylesheet as a recoverable transaction.
11
+ - 029562c: Add opt-in migration of safe literal responsive image sources to native picture markup with atomic template validation and report-based review locations.
12
+ - 6f8ef7a: Convert literal Angular Flex-Layout Grid directives, including standard responsive aliases, when Tailwind compiler output and element ownership prove an exact migration.
13
+
14
+ ### Patch Changes
15
+
16
+ - 4715a71: Add an executable compatibility inventory and rewrite beta onboarding around safe previews, pinned team installation, exact support boundaries, and copyable CLI workflows.
17
+
3
18
  ## 2.0.0-beta.1
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -1,90 +1,161 @@
1
1
  # Angular Flex-Layout Codemod
2
2
 
3
- A safety-first codemod for migrating projects away from the archived Angular Flex-Layout library.
3
+ Version 2 remains a prerelease. This beta migrates supported Angular Flex-Layout template attributes to Tailwind CSS v4 utilities. It uses the Angular compiler and source-range edits, preserving unrelated template text, comments, interpolation, control flow, and line endings.
4
4
 
5
- Version 2 remains a prerelease under active development. It does not claim production-ready conversion coverage. See the [compatibility reference](docs/compatibility.md) for the current directive-by-directive status and safety limitations.
5
+ Documentation and the single-template playground are available at [angular-flex-layout-codemod.nipesolutions.com](https://angular-flex-layout-codemod.nipesolutions.com). The playground previews Tailwind or native CSS output entirely in browser memory; your template is not sent to a server or persisted. Only the installed CLI performs project discovery, project validation, reporting, transactional writes, rollback, and multi-file work.
6
6
 
7
- Install a published v2 beta as a development dependency with `npm install --save-dev @nipe-solutions/flex-layout-codemod@beta`. Maintainers should follow the reviewed [release process](docs/architecture/release-process.md); merging a version pull request does not publish the package.
7
+ ## Why this exists
8
8
 
9
- ## Current scope
9
+ Angular Flex-Layout is archived. Replacing it safely requires more than substituting class names: responsive aliases, display restoration, existing classes, inline styles, and runtime bindings can change the result. This codemod converts only cases it can represent exactly and leaves the rest in place with diagnostics for review.
10
10
 
11
- The v2 engine parses templates with the Angular compiler and applies validated source-range edits. It preserves comments, control-flow syntax, interpolation, line endings, and all unrelated source text instead of serializing the template as generic HTML.
11
+ ## Compatibility at a glance
12
12
 
13
- The current prerelease converts documented static inputs and literal responsive inputs using the standard Angular Flex-Layout viewport aliases (`xs` through `xl`, `lt-*`, and `gt-*`) to exact Tailwind CSS v4 arbitrary media variants. For example, `fxLayout.sm="row"` becomes `[@media_screen_and_(min-width:_600px)_and_(max-width:_959.98px)]:flex-row` alongside the other layout utilities. Dynamic bindings, orientation, print, and custom breakpoints, unsupported directives, and responsive families with conflicting overlapping values remain unchanged with structured review results. Ambiguous behavior is never approximated silently.
13
+ Tailwind CSS v4 remains the default target. A native CSS target is available with `--target css --stylesheet <path>` for exactly eight Flex semantic families at base and the 13 standard viewport aliases. Grid, visibility, responsive class/style, orientation, print, and custom aliases remain preserved for CSS. Conversion is deliberately limited: dynamic bindings, ambiguous responsive precedence, unsafe class or style ownership, and unsupported directives are preserved for review.
14
14
 
15
- Literal responsive `ngClass.<alias>` and `ngStyle.<alias>` values use the same 13-alias boundary. Class values are split with Angular `NgClass`'s ECMAScript-whitespace rule and convert only when every token is in the compiler-proven built-in Tailwind CSS v4 surface, retains the host element as its CSS target, and can be emitted byte-for-byte for Tailwind's raw template scanner. Style declarations convert to arbitrary-property utilities only when Flex-Layout's quote removal, semicolon splitting, exact-key application order, Angular unit handling, CSS priority, fallback ownership, and responsive precedence can be represented exactly. Distinct exact ordinary keys that apply to the same CSS property, including `font-size` and `font-size.px`, are preserved because their result can depend on `NgStyle` activation history. Unsuffixed `ngClass` and `ngStyle` siblings are treated as replaceable fallback authorities rather than silently left as always-active values.
15
+ The complete directive-by-directive status, including grid, image, breakpoint, and class/style boundaries, is in [docs/compatibility.md](docs/compatibility.md). Treat that reference as the beta’s compatibility contract.
16
16
 
17
- ```html
18
- <!-- input -->
19
- <div ngClass.sm="flex items-center"></div>
20
- <div ngStyle.lt-md="font-size.px: 14; color: #334155"></div>
17
+ ## Quick start
21
18
 
22
- <!-- output -->
23
- <div
24
- class="[@media_screen_and_(min-width:_600px)_and_(max-width:_959.98px)]:flex [@media_screen_and_(min-width:_600px)_and_(max-width:_959.98px)]:items-center"
25
- ></div>
26
- <div
27
- class="[@media_screen_and_(max-width:_959.98px)]:[font-size:14px] [@media_screen_and_(max-width:_959.98px)]:[color:#334155]"
28
- ></div>
19
+ Evaluate the published beta without installing it. This safely previews the migration and does not write templates:
20
+
21
+ ```bash
22
+ npx @nipe-solutions/flex-layout-codemod@beta ./src
23
+ ```
24
+
25
+ Read the terminal summary and diagnostics before applying any migration. A clean Git worktree makes the resulting template diff easy to inspect.
26
+
27
+ ## Install for a team or CI
28
+
29
+ Install the beta as an exact development dependency. `--save-exact` records the prerelease resolved from the `beta` tag, so the package manifest and lockfile keep the team on that reviewed version:
30
+
31
+ ```bash
32
+ npm install --save-dev --save-exact @nipe-solutions/flex-layout-codemod@beta
29
33
  ```
30
34
 
31
- Application classes, project plugin utilities, custom-theme-dependent candidates such as `bg-brand-500`, unsafe style values, bindings, interpolation, and deprecated `class.<alias>` or `style.<alias>` selectors remain in place with review diagnostics. The current mode does not inspect project styles or Tailwind configuration and does not generate a companion stylesheet.
35
+ Use `npm ci` in CI to install the committed lockfile. The package exposes the `flex-layout-codemod` executable through the local npm binary path; no global installation is required.
32
36
 
33
- Existing literal classes use a broader conservative ownership check than generated-candidate admission. Compiler-modeled Tailwind utilities contribute every stable declaration they emit, including inferred arbitrary text sizes, directional border style/width pairs, and shadow color custom properties. A recognized pinned Tailwind utility whose complete property set is not modeled is treated as an unknown CSS authority and blocks an intersecting conversion instead of being silently ignored; ordinary application classes such as `card` remain additive.
37
+ ## Preview, review, and apply
38
+
39
+ Preview the local dependency and write a JSON report for review:
40
+
41
+ ```bash
42
+ npx flex-layout-codemod ./src --report ./reports/flex-layout.json
43
+ ```
44
+
45
+ The command plans and validates without changing project templates or stylesheets by default. `--report` is intentional reporting output: the report is an explicit side effect and is written atomically in both plan and write modes, even though a plan does not create template-output directories.
46
+
47
+ If any template has a parse error, no project changes are applied and terminal output labels the remaining edits as planned. In the default plan mode, `application` remains `{ "status": "skipped", "reason": "plan-only" }` even when parsing fails. When `--write` was requested, a parse error produces `{ "status": "skipped", "reason": "parse-errors" }`. Neither outcome presents proposed template or stylesheet actions as applied writes.
48
+
49
+ After reviewing the report and committing or branching your work, apply the migration in place:
50
+
51
+ ```bash
52
+ npx flex-layout-codemod ./src --target tailwind --write
53
+ ```
54
+
55
+ `--write` explicitly applies the validated plan. Without it, `--output` names only the proposed destination. With it, omitting `--output` applies changed templates in place; add `--output ./migrated-src` to apply them elsewhere. Review the Git diff before accepting the changes. If an in-place run is unwanted, inspect `git diff` before taking further action, then restore only the intended files deliberately through your normal Git workflow from a clean worktree or committed branch.
56
+
57
+ ### Native CSS companion stylesheet
58
+
59
+ Use the native CSS target when the documented Flex-only surface is appropriate:
60
+
61
+ ```bash
62
+ npx flex-layout-codemod ./src --target css --stylesheet ./src/flex-layout-migration.css --write
63
+ ```
34
64
 
35
- Literal `fxShow` and `fxHide` inputs are converted when the element's complete display behavior is provable. The conversion follows Angular Flex-Layout coercion: `fxShow="false"` hides, `fxHide="false"` shows, and other literal strings, including `"0"`, are truthy before `fxHide` inversion. Literal values use Angular-decoded text, so an entity-spelled value such as `fals&#101;` has the same semantics as `false`. Hiding uses `hidden`; a responsive shown state after base hiding restores only a display value proven by a converted `fxLayout` or one unambiguous base Tailwind display utility.
65
+ The migration updates templates and the one named companion stylesheet as a transaction. It owns only the marked `flex-layout-codemod` block, preserves handwritten CSS surrounding that block, retains unmatched owned rules because the stylesheet may serve templates outside the selected invocation, and keeps shared rules deduplicated across files. The current CLI has no complete-project pruning mode. On ordinary failures or handled interruption it rolls the changed templates and stylesheet back together.
66
+
67
+ The stylesheet path may use any filename accepted as a regular file. If it ends in `.html` and is inside a folder input, that exact selected path is excluded from template discovery so reruns remain byte-idempotent. Stylesheet, template, and JSON-report destinations must remain physically distinct; existing file identity and conservative case/Unicode-normalized aliases for missing paths are checked before application and again before report replacement.
68
+
69
+ No filesystem workflow can promise durable rollback after abrupt process termination, power loss, or a storage failure. If the command reports unconfirmed recovery, stop and inspect the listed paths, reconcile them with Git or a verified backup, then rerun only after the project is consistent.
70
+
71
+ ## Examples
72
+
73
+ This converted example is the same static layout and gap case exercised by the migration fixtures:
36
74
 
37
75
  ```html
38
76
  <!-- input -->
39
- <div fxLayout="column" fxShow="false" fxShow.sm></div>
77
+ <div fxLayout="column" fxLayoutGap="4"></div>
40
78
 
41
79
  <!-- output -->
42
- <div
43
- class="flex flex-col box-border hidden [@media_screen_and_(min-width:_600px)_and_(max-width:_959.98px)]:flex"
44
- ></div>
80
+ <div class="flex flex-col box-border gap-[4px]"></div>
45
81
  ```
46
82
 
47
- The complete visibility family is preserved when it contains a binding or interpolation, an orientation, print, or custom alias, conflicting overlapping states, an unverified restoration display, a partially overlapping responsive layout display without safe ownership, or an unsafe class/style interaction. A literal or bound style that can control `display` always blocks conversion. An unresolved responsive class or style authority also preserves related visibility output when it may control `display`. A bound class blocks a family that needs generated classes, but does not block an all-shown no-op whose attributes can simply be removed. See the [compatibility reference](docs/compatibility.md) and [visibility architecture](docs/architecture/visibility-semantics.md) for the exact boundary.
83
+ Literal Grid containers and children use compiler-verified arbitrary properties when no exact built-in utility exists:
48
84
 
49
- ## CLI workflow
85
+ ```html
86
+ <!-- input -->
87
+ <section gdColumns="12rem 1fr" gdGap="1rem"><div gdColumn="2"></div></section>
50
88
 
51
- Run the codemod for one Angular template or a directory:
89
+ <!-- output -->
90
+ <section class="grid [grid-template-columns:12rem_1fr] [grid-gap:1rem]"><div class="[grid-column:2]"></div></section>
91
+ ```
92
+
93
+ Orientation and print conversion require explicit source-configuration evidence. These flags assert settings you have already verified in the Angular application's Flex-Layout configuration; the codemod does not discover them:
52
94
 
53
95
  ```bash
54
- flex-layout-codemod ./src --target tailwind --output ./migrated-src
96
+ # Source uses addOrientationBps: true and printWithBreakpoints: ['md', 'handset']
97
+ npx flex-layout-codemod ./src --orientation-breakpoints --print-with-breakpoints md,handset --write
98
+
99
+ # Source explicitly uses printWithBreakpoints: []
100
+ npx flex-layout-codemod ./src --print-with-breakpoints none --write
55
101
  ```
56
102
 
57
- Preview the same migration plan without writing templates, while also creating a JSON report:
103
+ With orientation enabled, all nine archived aliases are available: `handset`, `handset.portrait`, `handset.landscape`, `tablet`, `tablet.portrait`, `tablet.landscape`, `web`, `web.portrait`, and `web.landscape`. Print conversion reproduces configured responsive fallback values, while an explicit `.print` value takes precedence.
104
+
105
+ Responsive image migration is a separate opt-in because introducing `<picture>` changes the image's parent and may affect CSS or test selectors. After reviewing that risk, enable literal standard-breakpoint sources with `--responsive-images`:
58
106
 
59
107
  ```bash
60
- flex-layout-codemod ./src --target tailwind --output ./migrated-src --dry-run --report ./reports/flex-layout.json
108
+ npx flex-layout-codemod ./src --responsive-images --report ./reports/flex-layout.json --write
109
+ ```
110
+
111
+ ```html
112
+ <!-- input -->
113
+ <img src="hero.png" src.lt-sm="hero-mobile.png" alt="Hero" />
114
+
115
+ <!-- output -->
116
+ <picture
117
+ ><source media="screen and (max-width: 599.98px)" srcset="hero-mobile.png" />
118
+ <img src="hero.png" alt="Hero"
119
+ /></picture>
61
120
  ```
62
121
 
63
- Only changed `.html` files are written during a real migration. For a single-file input, the planned output path must end in `.html` (case-insensitive); omitting `--output` keeps the default in-place behavior. For a folder input, `--output` remains a directory and each derived template output retains its `.html` path. `--dry-run` applies and validates edits in memory but does not write template output or create its missing parent directories. A requested `--report <path>` is an explicit reporting side effect and is still written atomically during a dry-run. The report path must be nonblank and end in `.json` (case-insensitive). Migratable inputs and planned template outputs exclusively use `.html`, so this structural rule prevents report collisions while allowing reports anywhere, including inside input or output trees. Invalid output and report paths are rejected before migration without creating output or report directories.
122
+ Only literal values using the 13 standard viewport aliases convert. Dynamic values, orientation, print, custom aliases, ambiguous URLs, structural directives on the image, and images already inside `<picture>` remain unchanged. Use the JSON report's file paths and source offsets to review every converted `imgSrc` occurrence and check selectors that assume the `<img>` has its former parent. Interactive file navigation is deferred to the CLI upgrade.
64
123
 
65
- Unresolved `review`, `unsupported`, or `invalid` results are strict by default. To preserve the same diagnostics and migration output while accepting unresolved work in automation, use:
124
+ This fixture is intentionally preserved because the value is a runtime Angular expression. The report records a `dynamic-binding` review diagnostic and the source remains unchanged:
66
125
 
67
- ```bash
68
- flex-layout-codemod ./src --dry-run --allow-unresolved
126
+ ```html
127
+ <div [fxFlex]="basis"></div>
69
128
  ```
70
129
 
71
- The CLI uses these exit codes:
130
+ ## Reports and exit codes
131
+
132
+ Reports use JSON schema version `2` and include required `mode` and `application` fields alongside per-file results, diagnostics, and a summary. `mode` records whether `plan` or `write` was requested. `application` records whether project changes were `applied` or were `skipped` because the run was plan-only or parsing failed. File `changed` values and stylesheet actions always describe proposed destination differences; consult `application` to determine whether those proposals reached the project.
72
133
 
73
- | Code | Meaning |
74
- | ---: | -------------------------------------------------------------------------------------- |
75
- | `0` | Migration completed with no unresolved results, or `--allow-unresolved` accepted them. |
76
- | `1` | Configuration, parsing, template I/O, report writing, or an internal invariant failed. |
77
- | `2` | Migration completed safely, but unresolved results remain in strict mode. |
134
+ Schema 2 removes the schema-1 `dryRun` field. Existing scripts that relied on implicit writes must add `--write`. Existing preview scripts must remove `--dry-run`, because planning is now the default and the obsolete option is rejected. Report consumers must replace `dryRun` checks with `mode` plus the required `application` state.
135
+
136
+ The default exit policy is strict:
137
+
138
+ | Code | Meaning |
139
+ | ---: | ---------------------------------------------------------------------------------------------------------- |
140
+ | `0` | Planning or application completed cleanly, or unresolved work was accepted with `--allow-unresolved`. |
141
+ | `1` | Configuration, parsing, project I/O, transaction, report writing, or an internal invariant failed. |
142
+ | `2` | Planning or application completed safely, but `review`, `unsupported`, or `invalid` results remain strict. |
143
+
144
+ For an informational CI report that accepts unresolved work while retaining every diagnostic, use:
145
+
146
+ ```bash
147
+ npx flex-layout-codemod ./src --report ./reports/flex-layout.json --allow-unresolved
148
+ ```
78
149
 
79
- JSON reports use schema version `1`. Report paths use forward slashes and are relative to the input root; a single-file input is represented by its basename, never an absolute checkout path. Files are path-sorted, results retain source order, and the summary is derived from those file results.
150
+ `--allow-unresolved` changes only the final exit code; it does not hide diagnostics or alter the migration output.
80
151
 
81
- Each non-parse report result represents one source directive occurrence. Measure responsive class and style adoption by counting `ngClass`, `ngStyle`, `class`, and `style` results by status in a representative migration report. This occurrence ratio is an inventory of the scanned templates, not a claim that the same percentage of an application or its runtime behavior was converted.
152
+ ## Known boundaries
82
153
 
83
- Use version control and review the generated diff before replacing application templates. Native CSS output remains outside the current scope.
154
+ Tailwind CSS v4 remains the default target. A native CSS target is available with `--target css --stylesheet <path>` for exactly eight Flex semantic families at base and the 13 standard viewport aliases. Grid, visibility, responsive class/style, orientation, print, and custom aliases remain preserved for CSS. Responsive `imgSrc` remains an independent opt-in native `<picture>` migration. See [docs/compatibility.md](docs/compatibility.md) for exact supported forms and diagnostic codes before planning a large migration.
84
155
 
85
- The TypeScript extension API changed in v2: mutable Cheerio converters were replaced by immutable `ConversionAdapter` plans and structured `ConversionResult` values. These prerelease APIs may continue to evolve before v2 is stable.
156
+ The CSS target does not inspect project styles, Tailwind configuration, Sass, or Less; it updates only its one owned companion block. Dynamic Angular bindings are not evaluated.
86
157
 
87
- ## Development
158
+ ## Contributing and support
88
159
 
89
160
  The repository requires Node.js 24 and npm 11.
90
161
 
@@ -93,7 +164,7 @@ npm ci
93
164
  npm run verify
94
165
  ```
95
166
 
96
- See [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. Security reports belong in [GitHub private vulnerability reporting](https://github.com/NIPE-Solutions/flex-layout-migrator/security/advisories/new); other support routes are documented in [docs/SUPPORT.md](docs/SUPPORT.md).
167
+ Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. Security reports belong in [GitHub private vulnerability reporting](https://github.com/NIPE-Solutions/flex-layout-migrator/security/advisories/new); other support routes are listed in [docs/SUPPORT.md](docs/SUPPORT.md). Maintainers should follow the reviewed [release process](docs/architecture/release-process.md).
97
168
 
98
169
  ## License
99
170