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: 🎸 Generators dto's #71

Closed
wants to merge 2 commits into from
Closed

feat: 🎸 Generators dto's #71

wants to merge 2 commits into from

Conversation

iYadgar
Copy link
Contributor

@iYadgar iYadgar commented Feb 26, 2023

created script to generate all generators dto's according to angular's cli schema.json

✅ Closes: 70

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

created script to generate all generators dto's according to angular's
cli schema.json

✅ Closes: 70
@nx-cloud
Copy link

nx-cloud bot commented Feb 26, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit aed2a08. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


🟥 Failed Commands
nx affected --target=build --parallel=3
✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@iYadgar iYadgar linked an issue Feb 26, 2023 that may be closed by this pull request
const { readdirSync, readFileSync, writeFile } = require('fs');
const { join } = require('path');
const PATH =
'/Users/idan.yadgar/angular-cli-e-square/angular-cli/packages/schematics/angular';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this left by mistake?

Copy link
Contributor

@OmerGronich OmerGronich left a comment

Choose a reason for hiding this comment

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

Cool!

Few questions

When is the script going to run? Are we going to run it periodically?
And how are we going to make sure that the DTO's it generates are actually correct? We need to write a lot of tests for this script.

@@ -0,0 +1,98 @@
const { readdirSync, readFileSync, writeFile } = require('fs');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make this a TS file?

Comment on lines +6 to +8
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

export it to a generic place for utils

Comment on lines +6 to +8
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1).toLowerCase();
}

Copy link
Member

@ronnetzer ronnetzer left a comment

Choose a reason for hiding this comment

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

Continuing my question in your HLD, what about "workspace schematics"? (Is it possible with ng cli?), what about 3rd party schematics? how do we plan to "discover" schematics on run-time? as I understand this is a compile-time thing, we run this script before we deploy a new version.
if we do need to do this stuff in run-time, there is no point of generating DTOs, we should parse schema.json and map it to a general DTO, something like SchematicArgument[] (maybe there's an interface from angular we can use) when the client requests for the available arguments of some schematic. I guess we can also generate the class in run-time in order to use it's class-validator features when BE receives an execute/generate command

implemented - get generators list, get generator schema, execute
generator command
@iYadgar iYadgar closed this Mar 1, 2023
@iYadgar iYadgar deleted the generators/dto-script branch March 1, 2023 14:22
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.

generators script
4 participants