Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to set cli commands #6758

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/beige-pigs-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': minor
---

Add ability to set CLI commands.
19 changes: 12 additions & 7 deletions packages/qwik/src/cli/utils/run-build-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ export async function runBuildCommand(app: AppCommand) {
const isPreviewBuild = app.args.includes('preview');
const buildLibScript = getScript('build.lib');
const isLibraryBuild = !!buildLibScript;
const buildClientScript = getScript('build.client');
const buildPreviewScript = isPreviewBuild ? getScript('build.preview') : undefined;
const buildServerScript = !isPreviewBuild ? getScript('build.server') : undefined;
const buildStaticScript = getScript('build.static');
const buildClientCommand = app.getArg("client-script") || "build.client"
const buildTypesCommand = app.getArg("types-script") || "build.types"
const buildPreviewCommand = app.getArg("preview-script") || "build.preview"
const buildServerCommand = app.getArg("server-script") || "build.server"
const buildStaticCommand = app.getArg("static-script") || "build.static"
const buildClientScript = getScript(buildClientCommand);
const buildPreviewScript = isPreviewBuild ? getScript(buildPreviewCommand) : undefined;
const buildServerScript = !isPreviewBuild ? getScript(buildServerCommand) : undefined;
const buildStaticScript = getScript(buildStaticCommand);
const runSsgScript = getScript('ssg');
const buildTypes = getScript('build.types');
const buildTypes = getScript(buildTypesCommand);
const lint = getScript('lint');
const mode = app.getArg('mode');

Expand All @@ -55,12 +60,12 @@ export async function runBuildCommand(app: AppCommand) {

if (!isLibraryBuild && !buildClientScript) {
console.log(pkgJsonScripts);
throw new Error(`"build.client" script not found in package.json`);
throw new Error(`"${buildClientCommand}" script not found in package.json`);
}

if (isPreviewBuild && !buildPreviewScript && !buildStaticScript) {
throw new Error(
`Neither "build.preview" or "build.static" script found in package.json for preview`
`Neither "${buildPreviewCommand}" or "${buildStaticCommand}" script found in package.json for preview`
);
}

Expand Down