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.

Throw error message if the project config is missing in the users env when using cli (#2289)

Jaya Krishna Namburuddff32b7ab20
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts
index 3158556756..8b94551bf9 100644
--- a/packages/cli/src/cli.ts
+++ b/packages/cli/src/cli.ts
@@ -38,7 +38,7 @@ export const main = async () => {
alias: "help",
type: "boolean",
})
- .scriptName("webstudio")
+ .scriptName("webstudio-cli")
.usage(
`Webstudio CLI (${packageJson.version}) allows you to setup, sync, build and preview your project.`
);
diff --git a/packages/cli/src/commands/sync.ts b/packages/cli/src/commands/sync.ts
index 6f6e98dee4..cb391c5b51 100644
--- a/packages/cli/src/commands/sync.ts
+++ b/packages/cli/src/commands/sync.ts
@@ -3,6 +3,7 @@ import { cwd } from "node:process";
import { join } from "node:path";
import ora from "ora";
import { loadProjectDataById } from "@webstudio-is/http-client";
+import pc from "picocolors";
import { ensureFileInPath, loadJSONFile } from "../fs-utils";
import {
@@ -36,7 +37,16 @@ export const sync = async () => {
return;
}
- const { host, token } = globalConfig[localConfig.projectId];
+ const projectConfig = globalConfig[localConfig.projectId];
+
+ if (projectConfig === undefined) {
+ spinner.fail(
+ `Project config is not found, please run ${pc.dim("webstudio-cli link")}`
+ );
+ return;
+ }
+
+ const { host, token } = projectConfig;
spinner.text = "Loading project data from webstudio\n";
const project = await loadProjectDataById({