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.

chore: Add netlify deploy command list in cli and in export tab (#2380)

Jaya Krishna Namburuf22e0105aade
diff --git a/apps/builder/app/builder/features/topbar/publish.tsx b/apps/builder/app/builder/features/topbar/publish.tsx
index 9a16c1b58e..24136f5a07 100644
--- a/apps/builder/app/builder/features/topbar/publish.tsx
+++ b/apps/builder/app/builder/features/topbar/publish.tsx
@@ -22,7 +22,9 @@ import {
styled,
Select,
theme,
+ TextArea,
} from "@webstudio-is/design-system";
+import stripIndent from "strip-indent";
import { useIsPublishDialogOpen } from "../../shared/nano-states";
import { validateProjectDomain, type Project } from "@webstudio-is/project";
import { getPublishedUrl } from "~/shared/router-utils";
@@ -492,7 +494,11 @@ const deployTargets = {
docs: "https://vercel.com/docs/cli",
},
netlify: {
- command: "npx netlify-cli",
+ command: `
+npx netlify-cli login
+npx netlify-cli sites:create
+npx netlify-cli build
+npx netlify-cli deploy`,
docs: "https://docs.netlify.com/cli/get-started/",
},
} as const;
@@ -575,7 +581,7 @@ const ExportContent = () => {
<Text color="subtle">
Run this command to publish to{" "}
<StyledLink
- href={deployTargets[deployTarget].command}
+ href={deployTargets[deployTarget].docs}
target="_blank"
rel="noreferrer"
>
@@ -597,11 +603,13 @@ const ExportContent = () => {
}}
/>
- <Flex gap={2}>
- <InputField
+ <Flex gap={2} align="end">
+ <TextArea
css={{ flex: 1 }}
readOnly
- value={deployTargets[deployTarget].command}
+ value={stripIndent(deployTargets[deployTarget].command)
+ .trimStart()
+ .replace(/ +$/, "")}
/>
<Tooltip content={"Copy to clipboard"}>
<Button
diff --git a/apps/builder/package.json b/apps/builder/package.json
index aea4ecc688..6cc4a138ec 100644
--- a/apps/builder/package.json
+++ b/apps/builder/package.json
@@ -96,6 +96,7 @@
"remix-island": "^0.1.2",
"shallow-equal": "^3.1.0",
"slugify": "^1.6.6",
+ "strip-indent": "^4.0.0",
"title-case": "^3.0.3",
"use-debounce": "^9.0.4",
"uuid": "^9.0.0",
diff --git a/apps/builder/remix.config.js b/apps/builder/remix.config.js
index afb1e7d19e..5212fcc21d 100644
--- a/apps/builder/remix.config.js
+++ b/apps/builder/remix.config.js
@@ -35,6 +35,7 @@ module.exports = {
"longest-streak",
"node-fetch",
"immerhin",
+ "strip-indent",
],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
diff --git a/packages/cli/src/commands/init-flow.ts b/packages/cli/src/commands/init-flow.ts
index 2398e4e158..3626fb96fe 100644
--- a/packages/cli/src/commands/init-flow.ts
+++ b/packages/cli/src/commands/init-flow.ts
@@ -12,13 +12,15 @@ import { $ } from "execa";
import { PROJECT_TEMPALTES } from "../config";
import { titleCase } from "title-case";
+type ProjectTemplates = (typeof PROJECT_TEMPALTES)[number];
+
export const initFlow = async (
options: StrictYargsOptionsToInterface<typeof buildOptions>
) => {
const isProjectConfigured = await isFileExists(".webstudio/config.json");
let shouldInstallDeps = false;
let folderName;
- let projectTemplate;
+ let projectTemplate: ProjectTemplates | undefined = undefined;
if (isProjectConfigured === false) {
const { shouldCreateFolder } = await prompt({
@@ -107,9 +109,27 @@ export const initFlow = async (
"Now you can:",
folderName && `Go to your project: ${pc.dim(`cd ${folderName}`)}`,
`Run ${pc.dim("npm run dev")} to preview your site on a local server.`,
- `Run ${pc.dim("npx vercel")} to publish on Vercel.`,
+ projectTemplate && getDeploymentInstructions(projectTemplate),
]
.filter(Boolean)
.join("\n")
);
};
+
+const getDeploymentInstructions = (
+ deployTarget: ProjectTemplates
+): string | undefined => {
+ switch (deployTarget) {
+ case "vercel":
+ return `Run ${pc.dim("npx vercel")} to publish on Vercel.`;
+ case "netlify-functions":
+ case "netlify-edge-functions":
+ return [
+ `To deploy to Netlify, run the following commands: `,
+ `Run ${pc.dim("npx netlify-cli login")} to login to Netlify.`,
+ `Run ${pc.dim("npx netlify-cli sites:create")} to create a new site.`,
+ `Run ${pc.dim("npx netlify-cli build")} to build the site`,
+ `Run ${pc.dim("npx netlify-cli deploy")} to deploy on Netlify.`,
+ ].join("\n");
+ }
+};
diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts
index b94842bccd..29f3baa4ab 100644
--- a/packages/cli/src/config.ts
+++ b/packages/cli/src/config.ts
@@ -56,4 +56,4 @@ export const PROJECT_TEMPALTES = [
"vercel",
"netlify-functions",
"netlify-edge-functions",
-];
+] as const;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4f666c6060..60de55bc72 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -291,6 +291,9 @@ importers:
slugify:
specifier: ^1.6.6
version: 1.6.6
+ strip-indent:
+ specifier: ^4.0.0
+ version: 4.0.0
title-case:
specifier: ^3.0.3
version: 3.0.3