Skip to content

Commit

Permalink
fixed cli not checking relative global.css correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez committed Nov 4, 2024
1 parent 4424bfd commit f670e69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-snakes-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"qwik-ui": patch
---

FIX: cli not checking relative global.css correctly
17 changes: 10 additions & 7 deletions packages/cli/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
QWIK_UI_CONFIG_FILENAME,
} from '../src/_shared/config-filenames';

import path from 'path';
import externalDeps from '../src/_shared/external-deps.json';

const COMMANDS = ['init', 'add'];
Expand Down Expand Up @@ -144,8 +145,8 @@ async function handleInit() {
if (!config.projectRoot) {
config.projectRoot = cancelable(
await text({
message: cyan('Specify the root of the project (leave empty for "/")'),
initialValue: '/',
message: cyan('Specify the root of the project (leave empty for "./")'),
initialValue: './',
}),
);
}
Expand All @@ -162,9 +163,10 @@ async function handleInit() {
if (!config.rootCssPath) {
config.rootCssPath = await collectFileLocationFromUser({
message: cyan(
'Your global css file location (where you defined your tailwind directives)',
'The path to the global css file the tailwind directives are defined (relative to the root you specified above)',
),
errorMessageName: 'Global css file',
rootDir: config.projectRoot,
initialValue: 'src/global.css',
});
}
Expand All @@ -181,12 +183,12 @@ async function handleInit() {
);
}

// TODO: Add "cwd" with the project root, and see if we can skip the interactive question from qwik cli
if (installTailwind) {
execSync(
`${getPackageManagerCommand().exec} qwik add tailwind --skipConfirmation=true`,
{
stdio: 'inherit',
cwd: config.projectRoot,
},
);
}
Expand Down Expand Up @@ -507,6 +509,7 @@ function parseCommands(command: CommandModule) {
interface FilePromptInfo {
message: string;
errorMessageName: string;
rootDir: string;
initialValue?: string;
}

Expand All @@ -517,9 +520,9 @@ async function collectFileLocationFromUser(config: FilePromptInfo) {
initialValue: config.initialValue,
}),
);

if (!existsSync(filePath)) {
log.error(`${config.errorMessageName} not found at ${filePath}, want to try again?`);
const fullPath = path.join(config.rootDir, filePath);
if (!existsSync(fullPath)) {
log.error(`${config.errorMessageName} not found at ${fullPath}, want to try again?`);
return collectFileLocationFromUser({ ...config, initialValue: filePath });
}
return filePath;
Expand Down

0 comments on commit f670e69

Please sign in to comment.