Skip to content

feat: sbb-angular auto migration setup - #606

Open
DavideMininni-Fincons wants to merge 78 commits into
mainfrom
feat/angular-auto-migration
Open

DavideMininni-Fincons wants to merge 78 commits into
mainfrom
feat/angular-auto-migration

Conversation

@DavideMininni-Fincons

@DavideMininni-Fincons DavideMininni-Fincons commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Setup for the automatic migration from sbb-angular to lyne-angular.


The migration is executed launching ng generate @sbb-esta/lyne-angular:migrate-legacy;

  • the --project parameter can be used to migrate a specific project in a multi-project workspace;
  • the --module parameter can be used to launch a module specific migration.

The setup includes customizable rules for:

  • import path migration;
  • selector migration;
  • attribute migration and removal; it's also possible to add a default value for an attribute which is not present using defaultValue combined with replaceWith;
  • type migration (including the change in the import / export clause);
  • comment addition (eg: 'FIXME: this module does not exist anymore').

If a custom rule is needed, it can be simply added in the migration chain.
The configured theme is already available for specific theme-dependent migrations.

Check src/angular/schematics/migrate-legacy/README.md for technical details.


Button module migration is included too.

@DavideMininni-Fincons DavideMininni-Fincons linked an issue Oct 7, 2026 that may be closed by this pull request
1 of 39 tasks
@DavideMininni-Fincons
DavideMininni-Fincons marked this pull request as ready for review October 8, 2026 14:16
@github-actions github-actions Bot added the pr: peer review required A peer review is required for this pull request label Oct 8, 2026

@jeripeierSBB jeripeierSBB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! I think we can merge it and then continue with smaller PRs.

Comment thread src/angular/schematics/migrate-legacy/modules/button.cts Outdated
Comment thread src/angular/schematics/migrate-legacy/modules/button.cts Outdated
Comment thread src/angular/schematics/migrate-legacy/modules/textarea.cts Outdated
import { MigrationScope } from '../../utils.cjs';
import { CommentMigration, createCommentMigrationRule } from '../migrations/comment-migration.cjs';

const COMMENTS: CommentMigration[] = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be transferred into a menu and a button inside the header to open it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to add just the comment;
even if it can be migrated to a header-button, its properties and behavior cannot easily be migrated with a solution which covers 100% of cases (eg. displayName and username, the change when menu opens, the menu events and so on).

Comment thread src/angular/schematics/migrate-legacy/modules/button.cts Outdated
Comment thread src/angular/schematics/migrate-legacy/modules/button.cts Outdated
Comment thread src/angular/schematics/migrate-legacy/modules/textarea.cts Outdated

@jeripeierSBB jeripeierSBB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create framework you created. In my opinion we can merge the state.

const comments: CommentMigration[] = [
{
selector: 'sbb-usermenu',
message: `FIXME: this component has no direct counterpart in lyne-angular; you can replace it with a 'sbb-header-button' adapting its properties.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should not prevent any merge now. In case we want to change anything we could do it in a follow up PR.
I think if we know that a component is used very often (like the usermenu) and there is a (almost) deterministic path to migrate, we should try to do it. I think this kind of components make it hard for consumers and also AI to migrate because they need to understand exactly how the two worlds work. If we provide a starting point, they could be much faster understanding and adapting it.

Maybe you did try already much more :), but nevertheless I try with a simple idea:

before

<sbb-usermenu
  [userName]="userName"
  [displayName]="displayName"
  (loginRequest)="login()"
  [menu]="menu"
>
</sbb-usermenu>

after

<sbb-header-button
  iconName="user-small"
  (click)="displayName ? null : login()"
  [sbbMenu]="displayName ? menu : null"
>
 @if(displayName) {
    {{ displayName }}
  } @else {
    Login
  }
</sbb-header-button>
<!-- [userName]="userName" should be included in the sbb-menu --> 

In the comment it could be helpful to link an example (which we have, but without the login mechanism and only in lyne-elements): https://lyne-elements.app.sbb.ch/?path=/story/elements-header--with-user-menu. Probably it would be worth to create a full example (with login and logout functions) in lyne-angular, as this is used in almost every application.

This branch was successfully deployed

1 active deployment
pr606 — 5ca5f44d Deployed Oct 28, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: lead review approved Pull request has been approved by a lead review pr: peer review required A peer review is required for this pull request preview-available target: 22.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

story: Angular Auto Migration

4 participants