Skip to content

Commit 50d5524

Browse files
committed
fixed component generator
1 parent 8e45e15 commit 50d5524

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ npm install -D qwik-nx
88

99
## Usage
1010

11-
### Generating an Application
11+
### Generating an application
1212
```
1313
nx generate qwik-nx:app
1414
```
1515

16+
### Generating a component
17+
```
18+
nx generate qwik-nx:component
19+
```
20+
1621
## ROADMAP:
1722

1823
* [ ] Complete generators for Route, Component and more
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { component$ } from '@builder.io/qwik';
2+
3+
interface <%= className %>Props {
4+
5+
}
6+
7+
const <%= className %> = component$((props: <%= className %>Props)=>{
8+
9+
return <>
10+
11+
</>;
12+
});

packages/qwik-nx/src/generators/component/files/src/index.ts__template__

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
2-
import { Tree, readProjectConfiguration } from '@nrwl/devkit';
3-
4-
import generator from './generator';
5-
import { ComponentGeneratorSchema } from './schema';
2+
import { Tree } from '@nrwl/devkit';
3+
import componentGenerator from './generator';
64

75
describe('component generator', () => {
86
let appTree: Tree;
9-
const options: ComponentGeneratorSchema = { name: 'test' };
107

118
beforeEach(() => {
129
appTree = createTreeWithEmptyWorkspace();
1310
});
1411

15-
it('should run successfully', async () => {
16-
await generator(appTree, options);
17-
const config = readProjectConfiguration(appTree, 'test');
18-
expect(config).toBeDefined();
12+
it('should generate a component file inside a given directory', async () => {
13+
await componentGenerator(appTree, {
14+
name: 'hello',
15+
directory: 'components'
16+
});
17+
18+
expect(appTree.exists('libs/components/hello/hello.tsx')).toBeTruthy();
19+
1920
});
2021
});

packages/qwik-nx/src/generators/component/generator.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,8 @@ function createComponentFiles(tree: Tree, options: NormalizedSchema) {
4747
generateFiles(tree, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
4848
}
4949

50-
export default async function (tree: Tree, options: ComponentGeneratorSchema) {
50+
export default async function componentGenerator(tree: Tree, options: ComponentGeneratorSchema) {
5151
const normalizedOptions = normalizeOptions(tree, options);
52-
addProjectConfiguration(
53-
tree,
54-
normalizedOptions.projectName,
55-
{
56-
root: normalizedOptions.projectRoot,
57-
projectType: 'library',
58-
sourceRoot: `${normalizedOptions.projectRoot}/src`,
59-
targets: {
60-
build: {
61-
executor: "qwik-nx:build",
62-
},
63-
},
64-
tags: normalizedOptions.parsedTags,
65-
}
66-
);
6752
createComponentFiles(tree, normalizedOptions);
6853
await formatFiles(tree);
6954
}

0 commit comments

Comments
 (0)