Skip to content

Commit 9947c6b

Browse files
reemardelarosashairezdmitry-stepanenko@qwikifiers
authored
feat: add "preset" generator (#10)
* feat(preset): feat: add "preset" generator: initial files re #7 * fix(qwik-nx): fix build on new version (#11) * feat: application & library generator updates (#5) * chore(qwik-nx): release version 0.2.0 * fix: fix npm publish dist dist folder in npm publish was pointing to the wrong folder * chore(qwik-nx): release version 0.2.1 * fix: moved vite to dependencies (#12) * Update README.md * chore(qwik-nx): release version 0.2.2 * refactor(generator.ts): point generator to application update projectDirectory, projectRoot, and projectType as an application" fix #7 * feat(preset/files): added preset files" added qwik application files to be use to create nx workspace * feat(update generator.ts): update generator and schema * docs(readme): added preset workspace create nx with qwik-nx preset * feat(preset): refactor generator reuse application generator codes and interfaces * refactor(generator): reuse applciation generator reuse addFiles from application generator * refactor(generator): reuse application generator reuse existing generator and remove unnecessary codes * fix: update schema props for preset * fix: cleanup * fix: cleanup * fix: revert verdaccio guidelines * style: added ▶ * fix: fix nexted folder for workspace preset Co-authored-by: Shai Reznik <[email protected]> Co-authored-by: Dmitriy Stepanenko <[email protected]> Co-authored-by: @qwikifiers <[email protected]>
1 parent 7cb3845 commit 9947c6b

File tree

8 files changed

+146
-2
lines changed

8 files changed

+146
-2
lines changed

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
save-exact = true
1+
save-exact = true

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ After your pull request is merged, you can safely delete your branch and pull th
138138

139139
<br/>
140140

141-
### ▶ 9. That's it! Thank you for your contribution! 🙏💓
141+
## ▶ 9. Publishing to a local registry
142+
143+
To test if your changes will actually work once the changes are published,
144+
it can be useful to publish to a local registry.
145+
146+
- Run `npm i -g verdaccio` in Terminal 1 (keep it running)
147+
- Run `verdaccio
148+
- Run `npm adduser --registry http://localhost:4873` in Terminal 2 (real credentials are not required, you just need to be logged in. You can use your own login details.
149+
- Run `npm publish [package] --registry=http://localhost:4783`
150+
151+
### ▶ 10. That's it! Thank you for your contribution! 🙏💓
142152

143153
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ npm install -D qwik-nx
3131

3232
## Usage
3333

34+
### Generating a workspace
35+
36+
```
37+
npx create-nx-workspace org-workspace --preset=qwik-nx
38+
```
39+
3440
### Generating an application
3541

3642
```

packages/qwik-nx/generators.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"schema": "./src/generators/library/schema.json",
3030
"description": "library generator",
3131
"aliases": ["lib"]
32+
},
33+
"preset": {
34+
"factory": "./src/generators/preset/generator",
35+
"schema": "./src/generators/preset/schema.json",
36+
"description": "preset generator"
3237
}
3338
}
3439
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
2+
import { Tree, readProjectConfiguration } from '@nrwl/devkit';
3+
4+
import generator from './generator';
5+
import { QwikWorkspacePresetGeneratorSchema } from './schema';
6+
7+
describe('preset generator', () => {
8+
let appTree: Tree;
9+
const options: QwikWorkspacePresetGeneratorSchema = {
10+
name: 'test',
11+
style: 'css',
12+
linter: 'none',
13+
skipFormat: false,
14+
unitTestRunner: 'none',
15+
strict: false,
16+
};
17+
18+
beforeEach(() => {
19+
appTree = createTreeWithEmptyWorkspace();
20+
});
21+
22+
it('should run successfully', async () => {
23+
await generator(appTree, options);
24+
const config = readProjectConfiguration(appTree, 'test');
25+
expect(config).toBeDefined();
26+
});
27+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Tree } from '@nrwl/devkit';
2+
import { QwikWorkspacePresetGeneratorSchema } from './schema';
3+
import applicationGenerator from '../application/generator';
4+
5+
export default async function (
6+
tree: Tree,
7+
options: QwikWorkspacePresetGeneratorSchema
8+
) {
9+
options.directory = '';
10+
options.name = options.qwikAppName ?? options.name;
11+
options.style = options.qwikAppStyle ?? options.style;
12+
return applicationGenerator(tree, options);
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface QwikWorkspacePresetGeneratorSchema {
2+
name: string;
3+
qwikAppName: string;
4+
tags?: string;
5+
directory?: string;
6+
7+
style: 'css' | 'scss' | 'styl' | 'less' | 'none';
8+
qwikAppStyle: 'css' | 'scss' | 'styl' | 'less' | 'none';
9+
linter: 'eslint' | 'none';
10+
skipFormat: boolean;
11+
unitTestRunner: 'vitest' | 'none';
12+
strict: boolean;
13+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"cli": "nx",
4+
"$id": "QwikNxPreset",
5+
"title": "",
6+
"type": "object",
7+
"properties": {
8+
"qwikAppName": {
9+
"type": "string",
10+
"description": "",
11+
"$default": {
12+
"$source": "argv",
13+
"index": 0
14+
},
15+
"x-prompt": "What name would you like to use?"
16+
},
17+
"tags": {
18+
"type": "string",
19+
"description": "Add tags to the project (used for linting)",
20+
"alias": "t"
21+
},
22+
"qwikAppStyle": {
23+
"description": "The file extension to be used for style files.",
24+
"type": "string",
25+
"default": "css",
26+
"alias": "s",
27+
"x-prompt": {
28+
"message": "Which stylesheet format would you like to use?",
29+
"type": "list",
30+
"items": [
31+
{
32+
"value": "css",
33+
"label": "CSS"
34+
},
35+
{
36+
"value": "scss",
37+
"label": "SASS(.scss) [ http://sass-lang.com ]"
38+
},
39+
{
40+
"value": "styl",
41+
"label": "Stylus(.styl) [ http://stylus-lang.com ]"
42+
},
43+
{
44+
"value": "less",
45+
"label": "LESS [ http://lesscss.org ]"
46+
}
47+
],
48+
"default": "css"
49+
}
50+
},
51+
"linter": {
52+
"description": "The tool to use for running lint checks.",
53+
"type": "string",
54+
"enum": ["eslint", "none"],
55+
"default": "eslint"
56+
},
57+
"unitTestRunner": {
58+
"type": "string",
59+
"enum": ["vitest", "none"],
60+
"description": "Test runner to use for unit tests.",
61+
"default": "vitest"
62+
},
63+
"strict": {
64+
"type": "boolean",
65+
"description": "Creates an application with strict mode and strict type checking.",
66+
"default": true
67+
}
68+
},
69+
"required": ["name"]
70+
}

0 commit comments

Comments
 (0)