Skip to content

Commit e92aee4

Browse files
authored
add support for monorepos component generation (#1009)
1 parent ea74696 commit e92aee4

File tree

6 files changed

+32
-364
lines changed

6 files changed

+32
-364
lines changed

.changeset/eight-zoos-melt.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'qwik-ui': patch
3+
---
4+
5+
FIX: `qwik-ui.config.json` is generated at the root of the monorepo.
6+
7+
Before it got created inside of the individual project, but it was wrong because we couldn't generate components in the right place or use the CLI from the root of the monorepo.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"@floating-ui/dom": "^1.6.5",
5757
"@fontsource-variable/inter": "^5.0.18",
5858
"@img/sharp-linux-x64": "^0.33.4",
59-
"@jscutlery/semver": "^4.2.0",
6059
"@k11r/nx-cloudflare-wrangler": "3.0.0-feat-sst-upgrade.1",
6160
"@modular-forms/qwik": "^0.24.0",
6261
"@nx/devkit": "19.4.2",

packages/cli/src/generators/init/init-generator.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ describe('init generator', () => {
3838
options.projectRoot = '/my-project';
3939
await initGenerator(tree, options);
4040

41-
expect(tree.exists('my-project/qwik-ui.config.json')).toBeTruthy();
41+
expect(tree.exists('qwik-ui.config.json')).toBeTruthy();
42+
43+
const expectedContents = tree.read(QWIK_UI_CONFIG_FILENAME, 'utf-8');
44+
45+
expect(expectedContents).toMatchInlineSnapshot(`
46+
"{ "componentsRoot": "/my-project/src/components/ui" }
47+
"
48+
`);
4249
});
4350
});

packages/cli/src/generators/init/init-generator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
88
return;
99
}
1010

11-
options.projectRoot ||= '/';
11+
options.projectRoot ||= './';
1212
options.componentsRoot ||= 'src/components/ui';
1313

14-
const fullConfigPath = joinPathFragments(options.projectRoot, QWIK_UI_CONFIG_FILENAME);
14+
const fullConfigPath = joinPathFragments('./', QWIK_UI_CONFIG_FILENAME);
1515

1616
tree.write(
1717
fullConfigPath,
1818
JSON.stringify({
19-
componentsRoot: options.componentsRoot,
19+
componentsRoot: joinPathFragments(options.projectRoot, options.componentsRoot),
2020
}),
2121
);
2222

packages/kit-headless/src/components/popover/popover-panel-impl.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import {
2+
$,
23
Slot,
34
component$,
5+
createContextId,
6+
useContext,
47
useSignal,
58
useStyles$,
6-
useContext,
79
useTask$,
8-
$,
9-
createContextId,
10-
type PropsOf,
1110
type CorrectedToggleEvent,
11+
type PropsOf,
1212
} from '@builder.io/qwik';
1313

1414
import { isServer } from '@builder.io/qwik/build';
15-
import popoverStyles from './popover.css?inline';
16-
import { popoverContextId } from './popover-context';
1715
import { useCombinedRef } from '../../hooks/combined-refs';
16+
import { popoverContextId } from './popover-context';
17+
import popoverStyles from './popover.css?inline';
1818

1919
// We don't need a provider, that way we connect all context to the root
2020
const ensureContextId = createContextId('qui-popover-null-context');
@@ -107,9 +107,7 @@ export const HPopoverPanelImpl = component$((props: PropsOf<'div'>) => {
107107
id={panelId}
108108
ref={panelRef}
109109
popover={
110-
(context.manual && 'manual') || props.popover === 'manual'
111-
? 'manual'
112-
: 'auto' || 'auto'
110+
(context.manual && 'manual') || props.popover === 'manual' ? 'manual' : 'auto'
113111
}
114112
onBeforeToggle$={[
115113
$(async (e) => {

0 commit comments

Comments
 (0)