Skip to content
Merged
Show file tree
Hide file tree
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 Dec 6, 2022
5765bc8
fix(qwik-nx): fix build on new version (#11)
shairez Dec 7, 2022
c2131f2
feat: application & library generator updates (#5)
dmitry-stepanenko Dec 7, 2022
0c4fc27
chore(qwik-nx): release version 0.2.0
Dec 7, 2022
2a9303f
fix: fix npm publish dist
shairez Dec 7, 2022
542e2ba
chore(qwik-nx): release version 0.2.1
Dec 7, 2022
41fcf64
fix: moved vite to dependencies (#12)
shairez Dec 7, 2022
c9d3fb6
Update README.md
shairez Dec 7, 2022
0a3eff1
chore(qwik-nx): release version 0.2.2
Dec 7, 2022
85cff91
refactor(generator.ts): point generator to application
reemardelarosa Dec 7, 2022
f3495d1
feat(preset/files): added preset files"
reemardelarosa Dec 8, 2022
8036457
Merge branch 'qwikifiers:main' into feat/preset
reemardelarosa Dec 8, 2022
9281e11
feat(update generator.ts): update generator and schema
reemardelarosa Dec 8, 2022
8c39d52
docs(readme): added preset workspace
reemardelarosa Dec 9, 2022
296ee23
feat(preset): refactor generator
reemardelarosa Dec 10, 2022
5fb2657
refactor(generator): reuse applciation generator
reemardelarosa Dec 10, 2022
bb5214b
refactor(generator): reuse application generator
reemardelarosa Dec 11, 2022
10b36ea
fix: update schema props for preset
reemardelarosa Dec 14, 2022
a8399e9
fix: cleanup
reemardelarosa Dec 14, 2022
138b109
fix: cleanup
reemardelarosa Dec 14, 2022
7944bd7
fix: revert verdaccio guidelines
reemardelarosa Dec 14, 2022
cca6c30
style: added ▶
reemardelarosa Dec 14, 2022
2e87c82
fix: fix nexted folder for workspace preset
reemardelarosa Dec 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
save-exact = true
save-exact = true
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ After your pull request is merged, you can safely delete your branch and pull th

<br/>

### ▶ 9. That's it! Thank you for your contribution! 🙏💓
## ▶ 9. Publishing to a local registry

To test if your changes will actually work once the changes are published,
it can be useful to publish to a local registry.

- Run `npm i -g verdaccio` in Terminal 1 (keep it running)
- Run `verdaccio
- 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.
- Run `npm publish [package] --registry=http://localhost:4783`

### ▶ 10. That's it! Thank you for your contribution! 🙏💓

[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ npm install -D qwik-nx

## Usage

### Generating a workspace

```
npx create-nx-workspace org-workspace --preset=qwik-nx
```

### Generating an application

```
Expand Down
5 changes: 5 additions & 0 deletions packages/qwik-nx/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"schema": "./src/generators/library/schema.json",
"description": "library generator",
"aliases": ["lib"]
},
"preset": {
"factory": "./src/generators/preset/generator",
"schema": "./src/generators/preset/schema.json",
"description": "preset generator"
}
}
}
27 changes: 27 additions & 0 deletions packages/qwik-nx/src/generators/preset/generator.spec.ts
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();
});
});
13 changes: 13 additions & 0 deletions packages/qwik-nx/src/generators/preset/generator.ts
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 = '';
Copy link
Contributor

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?

Copy link
Contributor Author

@reemardelarosa reemardelarosa Dec 11, 2022

Choose a reason for hiding this comment

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

@dmitry-stepanenko

function normalizeDirectory(options: QwikAppGeneratorSchema) {
return options.directory
? `${names(options.directory).fileName}/${names(options.name).fileName}`
: names(options.name).fileName;
}

options.directory = '' will use the names(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?

Copy link
Contributor

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?

Copy link
Contributor Author

@reemardelarosa reemardelarosa Dec 11, 2022

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

export default async function (
  tree: Tree,
  options: QwikWorkspacePresetGeneratorSchema
) {
  return applicationGenerator(tree, options);
}

Screenshot 2022-12-11 at 8 30 50 PM

Copy link
Contributor

@dmitry-stepanenko dmitry-stepanenko Dec 11, 2022

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
image

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 the preset generator by create-nx-workspace:

{ "_": ["neatspace", "Object]"], "preset": "qwik-nx", "allPrompts": false, "a": false, "skipGit": false, "g": false, "commit": "[object", "/bin/sh": "/Users/dmitriy/.npm/_npx/d2207cf76adb22dc/node_modules/.bin/create-nx-workspace", "name": "neatspace", "appName": "", "nxCloud": false, "packageManager": "npm", "defaultBase": "main", "ci": "", "cli": "nx", "style": "css", "skipInstall": false, "linter": "eslint", "directory": "neatspace", "presetVersion": "undefined", "skipFormat": false, "unitTestRunner": "vitest", "strict": true }

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:

      name,
      preset,
      appName,
      style,
      cli,
      nxCloud,
      packageManager,
      defaultBase,
      ci,

So I propose to rename the following inputs:

  • name => qwikAppName ?? options.name
  • style => qwikAppStyle

and remove the following inputs as they won't be actually used:

  • directory
  • skipFormat

Then we can map property names to what applicationGenerator needs.

@reemardelarosa @shairez maybe you have any other thoughts on this?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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 ?

Copy link
Contributor

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!

Copy link
Contributor Author

@reemardelarosa reemardelarosa Dec 14, 2022

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

name => qwikAppName ?? options.name
style => qwikAppStyle

options.name = options.qwikAppName ?? options.name;
options.style = options.qwikAppStyle ?? options.style;
return applicationGenerator(tree, options);
}
13 changes: 13 additions & 0 deletions packages/qwik-nx/src/generators/preset/schema.d.ts
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;
}
70 changes: 70 additions & 0 deletions packages/qwik-nx/src/generators/preset/schema.json
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"]
}