Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Improve help and run dev-server after init of a project while using cli (#2268)

Jaya Krishna Namburua1c82cd98bbc
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts
index 7aeb0f29eb..3158556756 100644
--- a/packages/cli/src/cli.ts
+++ b/packages/cli/src/cli.ts
@@ -31,7 +31,6 @@ export const main = async () => {
.wrap(null)
.option("v", {
describe: "Show version number",
- alias: "version",
type: "boolean",
})
.option("h", {
@@ -39,19 +38,17 @@ export const main = async () => {
alias: "help",
type: "boolean",
})
- .scriptName("webstudio");
+ .scriptName("webstudio")
+ .usage(
+ `Webstudio CLI (${packageJson.version}) allows you to setup, sync, build and preview your project.`
+ );
cmd.version(packageJson.version).alias("v", "version");
- cmd.command(["build"], "build the project", buildOptions, build);
- cmd.command(
- ["link"],
- "link the project from your workspace",
- linkOptions,
- link
- );
- cmd.command(["sync"], "sync your project", {}, sync);
- cmd.command("$0", "setup the project", buildOptions, initFlow);
+ cmd.command(["build"], "Build the project", buildOptions, build);
+ cmd.command(["link"], "Link the project with the cloud", linkOptions, link);
+ cmd.command(["sync"], "Sync your project", {}, sync);
+ cmd.command(["$0", "init"], "Setup the project", buildOptions, initFlow);
await cmd.parse();
} catch (error) {
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index 7ab4a02844..acb985858f 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -11,12 +11,12 @@ export const buildOptions = (yargs: CommonYargsArgv) =>
.option("assets", {
type: "boolean",
default: true,
- describe: "Download assets",
+ describe: "[Experimental] Download assets",
})
.option("preview", {
type: "boolean",
default: false,
- describe: "use preview (opensource) version of the project",
+ describe: "[Experimental] Use preview version of the project",
});
// @todo: use options.assets to define if we need to download assets
diff --git a/packages/cli/src/commands/init-flow.ts b/packages/cli/src/commands/init-flow.ts
index 90664b3d7d..024f66524e 100644
--- a/packages/cli/src/commands/init-flow.ts
+++ b/packages/cli/src/commands/init-flow.ts
@@ -67,7 +67,12 @@ export const initFlow = async (
if (stderr) {
throw stderr;
}
- spinner.succeed("Installed dependencies");
+ spinner.succeed("Installed dependencies, starting dev server");
+
+ const { stderr: devServerError } = await exec("npm", ["run", "dev"]);
+ if (devServerError) {
+ throw devServerError;
+ }
}
};