Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deploy-gen): adds new main deploy generator #2891

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cianmSAP
Copy link
Contributor

@cianmSAP cianmSAP commented Feb 7, 2025

  • Add new deployment sub generator
  • Tests to be added

Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: f9f188f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sap-ux/deploy-config-sub-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@longieirl longieirl self-assigned this Feb 19, 2025
@longieirl longieirl marked this pull request as ready for review February 19, 2025 13:44
@longieirl longieirl requested a review from a team as a code owner February 19, 2025 13:44
Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

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

New module set-up looks good. 1 query.

@@ -0,0 +1,3 @@
// When deployment generator is bundled the namespacing is relative to the root generator
export const bundledRootGeneratorName = '@sap/fiori:fiori-deployment';
Copy link
Member

Choose a reason for hiding this comment

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

Should this be passed in from @sap/generator-fiori?

@@ -0,0 +1,467 @@
import { basename, dirname, join } from 'path';
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

Do you think we can we reduce the size of this file perhaps by only including direct lifecycle methods. Refactor the private function out to a new file.

super(args, opts);
// this.env.adapter.promptModule is undefined when running in YUI
this.env.adapter.promptModule?.registerPrompt('autocomplete', autocomplete);
this.launchDeployConfigAsSubGenerator = opts.launchDeployConfigAsSubGenerator ?? false;
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

Do we still need this concept launchDeployConfigAsSubGenerator? If we do then can we determine if there is a caller (composeWith(subgenName')) programmatically instead of expecting the consumer to set this? Might be a stretch...

* The main deployment configuration generator.
*/
export default class extends DeploymentGenerator {
private readonly launchDeployConfigAsSubGenerator: boolean;
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

Can we document all of these properties as its not clear why they are needed? Should there be instead a deploy 'state' type defined that encapsulates the required state for deploy config generation. This might make for a cleaner implementation.

export default class extends DeploymentGenerator {
private readonly launchDeployConfigAsSubGenerator: boolean;
private readonly launchStandaloneFromYui: boolean;
private readonly abapChoice: Target = { name: TargetName.ABAP, description: 'ABAP' };
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

Is it correct to define inquirer related concepts in a generator constructor. Can these be moved to where they are used?

// Load .env file for api hub config
dotenv.config();

// Application Modeler launches Deployment Configuration Generator YUI.
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

This refers to a non-open source module here (Application Modeler)? Maybe consider a more generic approach that supports 2 cases: 1) Where this is called as a subgenerator 2) Where its called standalone.

constructor(args: string | string[], opts: DeployConfigOptions) {
super(args, opts);
// this.env.adapter.promptModule is undefined when running in YUI
this.env.adapter.promptModule?.registerPrompt('autocomplete', autocomplete);
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

Im not sure this is a valid comment (deploy already uses this plugin in YUI for transport type ahead I think?). Better if the adaptor is passed down to the inquirers (it is a prompting plugin) and registered there. Inquirers may need to register other plugins...seems to be an assumption here that autocomplete is needed?

/**
* The connected system from the generator
*/
connectedSystem?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to use the existing type since thats where this definition originates from:

import { type OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
...
    connectedSystem?: OdataServiceAnswers['connectedSystem'];
...

/**
* Whether the system is a cloud system
*/
scp?: boolean;
Copy link
Contributor

@IainSAP IainSAP Feb 19, 2025

Choose a reason for hiding this comment

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

This property is no longer being passed and should be considered deprecated. It can be calculated internally if required?

}

public async initializing(): Promise<void> {
await super.initializing();
Copy link
Contributor

@IainSAP IainSAP Feb 20, 2025

Choose a reason for hiding this comment

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

Should we also be initialising the VSCode logging here if this generator can be directly launched in YUI...as is done here:

or is that delegated to subgens...in in which case there wont be any vscode logging output from here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants