Skip to content

Commit ea74696

Browse files
authored
fixed cli not checking relative global.css correctly (#1003)
* fixed cli not checking relative global.css correctly * make continues-release depends on test * fixed cli e2e test
1 parent 4424bfd commit ea74696

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

.changeset/soft-snakes-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"qwik-ui": patch
3+
---
4+
5+
FIX: cli not checking relative global.css correctly

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Test
22

33
on:
4-
- push
5-
- pull_request
4+
pull_request:
5+
push:
6+
branches:
7+
- main
68

79
jobs:
810
test:
@@ -32,8 +34,9 @@ jobs:
3234
chromatic_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
3335

3436
continuous-release:
35-
runs-on: ubuntu-latest
3637
if: github.event_name == 'pull_request'
38+
needs: test
39+
runs-on: ubuntu-latest
3740
steps:
3841
- uses: actions/checkout@v3
3942
- name: Setup

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"release": "pnpm release.prepare && pnpm release.setroot && pnpm release.publish && pnpm release.resetroot",
3030
"release.publish": "changeset publish",
3131
"release.resetroot": "cp dist/pnpm-workspace.yaml pnpm-workspace.yaml",
32-
"release.e2e": "pnpm release.prepare && pnpm release.setroot && pnpm -r exec pnpm version patch && pnpm -r publish --tag e2e --no-git-checks && pnpm release.resetroot",
32+
"release.e2e": "pnpm release.prepare && pnpm release.setroot && pnpm -r exec pnpm version patch && pnpm -r exec pnpm publish --tag e2e --no-git-checks && pnpm release.resetroot",
3333
"test.cli": "NODE_OPTIONS=--experimental-vm-modules nx test cli",
34+
"test.cli.e2e": "nx e2e cli-e2e",
3435
"test.headless": "nx component-test headless --skip-nx-cache",
3536
"test.visual.headless": "nx visual-test headless",
3637
"test.pw.headless": "nx e2e headless",
@@ -147,7 +148,7 @@
147148
"includedScripts": []
148149
},
149150
"volta": {
150-
"node": "20.9.0",
151+
"node": "22.7.0",
151152
"pnpm": "9.7.0"
152153
}
153154
}

packages/cli-e2e/src/cli.smoke.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Qwik UI CLI Smoke test', () => {
2323

2424
it('should be installed and add the button file', () => {
2525
execSync(
26-
'npx -y qwik-ui@e2e init --e2e --projectRoot / --uiComponentsPath "src/components/ui" --rootCssPath "src/global.css" --installTailwind --style "simple" --components=button',
26+
'npx -y qwik-ui@e2e init --e2e --projectRoot ./ --uiComponentsPath "src/components/ui" --rootCssPath "src/global.css" --installTailwind --style "simple" --components=button',
2727
{
2828
cwd: projectDirectory,
2929
env: process.env,

packages/cli/bin/index.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
QWIK_UI_CONFIG_FILENAME,
3838
} from '../src/_shared/config-filenames';
3939

40+
import path from 'path';
4041
import externalDeps from '../src/_shared/external-deps.json';
4142

4243
const COMMANDS = ['init', 'add'];
@@ -144,8 +145,8 @@ async function handleInit() {
144145
if (!config.projectRoot) {
145146
config.projectRoot = cancelable(
146147
await text({
147-
message: cyan('Specify the root of the project (leave empty for "/")'),
148-
initialValue: '/',
148+
message: cyan('Specify the root of the project (leave empty for "./")'),
149+
initialValue: './',
149150
}),
150151
);
151152
}
@@ -162,9 +163,10 @@ async function handleInit() {
162163
if (!config.rootCssPath) {
163164
config.rootCssPath = await collectFileLocationFromUser({
164165
message: cyan(
165-
'Your global css file location (where you defined your tailwind directives)',
166+
'The path to the global css file the tailwind directives are defined (relative to the root you specified above)',
166167
),
167168
errorMessageName: 'Global css file',
169+
rootDir: config.projectRoot,
168170
initialValue: 'src/global.css',
169171
});
170172
}
@@ -181,12 +183,12 @@ async function handleInit() {
181183
);
182184
}
183185

184-
// TODO: Add "cwd" with the project root, and see if we can skip the interactive question from qwik cli
185186
if (installTailwind) {
186187
execSync(
187-
`${getPackageManagerCommand().exec} qwik add tailwind --skipConfirmation=true`,
188+
`${getPackageManagerCommand().exec} qwik add tailwind --skipConfirmation=true --projectDir=${config.projectRoot}`,
188189
{
189190
stdio: 'inherit',
191+
cwd: config.projectRoot,
190192
},
191193
);
192194
}
@@ -430,9 +432,9 @@ Options: [${possibleComponentNames.join(', ')}]`,
430432
coerce: (components) => componentTypesFromString(components),
431433
})
432434
.option('projectRoot', {
433-
description: 'The root of the project (default: "/")',
435+
description: 'The root of the project (default: "./")',
434436
type: 'string',
435-
default: '/',
437+
default: './',
436438
}),
437439
handler: () => {},
438440
};
@@ -448,8 +450,8 @@ Options: [${possibleComponentNames.join(', ')}]`,
448450
if (!projectRoot && !args['projectRoot']) {
449451
projectRoot = cancelable(
450452
await text({
451-
message: cyan('Specify the root of the project (leave empty for "/")'),
452-
initialValue: '/',
453+
message: cyan('Specify the root of the project (leave empty for "./")'),
454+
initialValue: './',
453455
}),
454456
);
455457
}
@@ -507,6 +509,7 @@ function parseCommands(command: CommandModule) {
507509
interface FilePromptInfo {
508510
message: string;
509511
errorMessageName: string;
512+
rootDir: string;
510513
initialValue?: string;
511514
}
512515

@@ -517,9 +520,9 @@ async function collectFileLocationFromUser(config: FilePromptInfo) {
517520
initialValue: config.initialValue,
518521
}),
519522
);
520-
521-
if (!existsSync(filePath)) {
522-
log.error(`${config.errorMessageName} not found at ${filePath}, want to try again?`);
523+
const fullPath = path.join(config.rootDir, filePath);
524+
if (!existsSync(fullPath)) {
525+
log.error(`${config.errorMessageName} not found at ${fullPath}, want to try again?`);
523526
return collectFileLocationFromUser({ ...config, initialValue: filePath });
524527
}
525528
return filePath;

0 commit comments

Comments
 (0)