-
Notifications
You must be signed in to change notification settings - Fork 26
feat: add "preset" generator #10
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
Merged
dmitry-stepanenko
merged 23 commits into
qwikifiers:main
from
reemardelarosa:feat/preset
Dec 15, 2022
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
04d0035
feat(preset): feat: add "preset" generator: initial files
reemardelarosa 5765bc8
fix(qwik-nx): fix build on new version (#11)
shairez c2131f2
feat: application & library generator updates (#5)
dmitry-stepanenko 0c4fc27
chore(qwik-nx): release version 0.2.0
2a9303f
fix: fix npm publish dist
shairez 542e2ba
chore(qwik-nx): release version 0.2.1
41fcf64
fix: moved vite to dependencies (#12)
shairez c9d3fb6
Update README.md
shairez 0a3eff1
chore(qwik-nx): release version 0.2.2
85cff91
refactor(generator.ts): point generator to application
reemardelarosa f3495d1
feat(preset/files): added preset files"
reemardelarosa 8036457
Merge branch 'qwikifiers:main' into feat/preset
reemardelarosa 9281e11
feat(update generator.ts): update generator and schema
reemardelarosa 8c39d52
docs(readme): added preset workspace
reemardelarosa 296ee23
feat(preset): refactor generator
reemardelarosa 5fb2657
refactor(generator): reuse applciation generator
reemardelarosa bb5214b
refactor(generator): reuse application generator
reemardelarosa 10b36ea
fix: update schema props for preset
reemardelarosa a8399e9
fix: cleanup
reemardelarosa 138b109
fix: cleanup
reemardelarosa 7944bd7
fix: revert verdaccio guidelines
reemardelarosa cca6c30
style: added ▶
reemardelarosa 2e87c82
fix: fix nexted folder for workspace preset
reemardelarosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
save-exact = true | ||
save-exact = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { Tree, readProjectConfiguration } from '@nrwl/devkit'; | ||
|
||
import generator from './generator'; | ||
import { QwikWorkspacePresetGeneratorSchema } from './schema'; | ||
|
||
describe('preset generator', () => { | ||
let appTree: Tree; | ||
const options: QwikWorkspacePresetGeneratorSchema = { | ||
name: 'test', | ||
style: 'css', | ||
linter: 'none', | ||
skipFormat: false, | ||
unitTestRunner: 'none', | ||
strict: false, | ||
}; | ||
|
||
beforeEach(() => { | ||
appTree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it('should run successfully', async () => { | ||
await generator(appTree, options); | ||
const config = readProjectConfiguration(appTree, 'test'); | ||
expect(config).toBeDefined(); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Tree } from '@nrwl/devkit'; | ||
import { QwikWorkspacePresetGeneratorSchema } from './schema'; | ||
import applicationGenerator from '../application/generator'; | ||
|
||
export default async function ( | ||
tree: Tree, | ||
options: QwikWorkspacePresetGeneratorSchema | ||
) { | ||
options.directory = ''; | ||
options.name = options.qwikAppName ?? options.name; | ||
options.style = options.qwikAppStyle ?? options.style; | ||
return applicationGenerator(tree, options); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface QwikWorkspacePresetGeneratorSchema { | ||
name: string; | ||
qwikAppName: string; | ||
tags?: string; | ||
directory?: string; | ||
|
||
style: 'css' | 'scss' | 'styl' | 'less' | 'none'; | ||
qwikAppStyle: 'css' | 'scss' | 'styl' | 'less' | 'none'; | ||
linter: 'eslint' | 'none'; | ||
skipFormat: boolean; | ||
unitTestRunner: 'vitest' | 'none'; | ||
strict: boolean; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "QwikNxPreset", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"qwikAppName": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
}, | ||
"tags": { | ||
"type": "string", | ||
"description": "Add tags to the project (used for linting)", | ||
"alias": "t" | ||
}, | ||
"qwikAppStyle": { | ||
"description": "The file extension to be used for style files.", | ||
"type": "string", | ||
"default": "css", | ||
"alias": "s", | ||
"x-prompt": { | ||
"message": "Which stylesheet format would you like to use?", | ||
"type": "list", | ||
"items": [ | ||
{ | ||
"value": "css", | ||
"label": "CSS" | ||
}, | ||
{ | ||
"value": "scss", | ||
"label": "SASS(.scss) [ http://sass-lang.com ]" | ||
}, | ||
{ | ||
"value": "styl", | ||
"label": "Stylus(.styl) [ http://stylus-lang.com ]" | ||
}, | ||
{ | ||
"value": "less", | ||
"label": "LESS [ http://lesscss.org ]" | ||
} | ||
], | ||
"default": "css" | ||
} | ||
}, | ||
"linter": { | ||
"description": "The tool to use for running lint checks.", | ||
"type": "string", | ||
"enum": ["eslint", "none"], | ||
"default": "eslint" | ||
}, | ||
"unitTestRunner": { | ||
"type": "string", | ||
"enum": ["vitest", "none"], | ||
"description": "Test runner to use for unit tests.", | ||
"default": "vitest" | ||
}, | ||
"strict": { | ||
"type": "boolean", | ||
"description": "Creates an application with strict mode and strict type checking.", | ||
"default": true | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes
directory
property basically useless. Is it intentional?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmitry-stepanenko
qwik-nx/packages/qwik-nx/src/generators/application/utils/normalize-options.ts
Lines 21 to 25 in 7cb3845
options.directory = ''
will use thenames(options.name).fileName;
There is a bug if I will just reuse the options.directory, it will create
org/apps/qwik-app/qwik-app
.Do you have any suggestions to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot reproduce this, can you please describe how exactly this comes out?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried to run
npx create-nx-workspace org-workspace --preset=qwik-nx
?This is the result of
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it's not reproducible for me if I run

npx create-nx-workspace org-workspace --preset=qwik-nx
But I can actually reproduce by running
npx nx generate qwik-nx:preset abc --no-interactive --dry-run
in an existing repo by replacing actual options with the list of options that is being provided to thepreset
generator bycreate-nx-workspace
:Since nx may use/override flags that we're using, it feels like the best what we can do is to modify the schema to have other names there. For example, it can properly generate the app name using this command
npx create-nx-workspace --preset=qwik-nx --qwikAppName=neat-qwik-app
.Here's the list of inputs that will be overridden:
So I propose to rename the following inputs:
qwikAppName ?? options.name
and remove the following inputs as they won't be actually used:
Then we can map property names to what
applicationGenerator
needs.@reemardelarosa @shairez maybe you have any other thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shairez @reemardelarosa I think it's better to ship whatever we can at this point and enhance it later down the road once we're able to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reemardelarosa did you have a chance to implement this yet?
#10 (comment)
if not please let us know and we'll do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @dmitry-stepanenko, to create separate issue/pr for standalone.
WDYT @shairez ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reemardelarosa yes, standalone could be a separate PR
I was talking about the link in my last comment, about implementing the changes you suggested in your last comment
wanted just to ask if you did that work already and didn't push, because I didn't see it in the commits yet and didn't want us to do duplicated work
Thanks!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shairez I did not implemented this yet