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

refactor: drop --preview flag from CLI #4707

Merged
merged 2 commits into from
Jan 3, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/cli-r2-static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
run: tar --use-compress-program="zstd -d" -xf ssg-template.tar.zst -C .

- name: Webstudio Build
run: pnpm webstudio build --template ssg --template internal --preview
run: pnpm webstudio build --template ssg --template internal
working-directory: ${{ github.workspace }}/ssg-template

- name: Build
Expand Down
3 changes: 2 additions & 1 deletion fixtures/ssg-netlify-by-project-id/.webstudio/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@
"email": "[email protected]"
},
"projectDomain": "fixture-client-do-not-touch-wsmel",
"projectTitle": "FIXTURE-CLIENT-DO-NOT-TOUCH"
"projectTitle": "FIXTURE-CLIENT-DO-NOT-TOUCH",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/ssg-netlify-by-project-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-8a7358b1-7de3-459d-b7b1-56dddfb6ce1e-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=f55154e6-36b9-4920-bc81-3095cc88f8ff'",
"fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg-netlify --template internal --preview && prettier --write ."
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg-netlify --template internal && prettier --write ."
},
"engines": {
"node": ">=20.0.0"
Expand Down
3 changes: 2 additions & 1 deletion fixtures/ssg/.webstudio/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"email": "[email protected]"
},
"projectDomain": "cli-basic-test-d0osr",
"projectTitle": "cli-basic-test"
"projectTitle": "cli-basic-test",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/ssg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link ${BUILDER_URL_DEPRECATED:-https://main.development.webstudio.is}'/builder/d845c167-ea07-4875-b08d-83e97c09dcce?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93'",
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg --template internal --preview && prettier --write ."
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg --template internal && prettier --write ."
},
"engines": {
"node": ">=20.0.0"
Expand Down
3 changes: 2 additions & 1 deletion fixtures/webstudio-cloudflare-template/.webstudio/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"email": "[email protected]"
},
"projectDomain": "cli-basic-test-d0osr",
"projectTitle": "cli-basic-test"
"projectTitle": "cli-basic-test",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/webstudio-cloudflare-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-d845c167-ea07-4875-b08d-83e97c09dcce-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93'",
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template cloudflare --template saas-helpers --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json",
"fixtures:build": "pnpm cli build --template cloudflare --template saas-helpers --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json",
"build": "remix vite:build",
"dev": "remix vite:dev",
"typecheck": "tsc",
Expand Down
3 changes: 2 additions & 1 deletion fixtures/webstudio-custom-template/.webstudio/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2331,5 +2331,6 @@
"email": "[email protected]"
},
"projectDomain": "webstudio-custom-template-cochj",
"projectTitle": "webstudio-custom-template"
"projectTitle": "webstudio-custom-template",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/webstudio-custom-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-0d856812-61d8-4014-a20a-82e01c0eb8ee-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=d225fafb-4f20-4340-9359-c21df7c49a3f'",
"fixtures:sync": "pnpm cli sync --buildId d48c7c5e-fdd3-4ef6-9173-ff2eaaf851d9 && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template defaults --template ./custom-template --template ./custom-template-stage --template internal --preview --assets false && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
"fixtures:build": "pnpm cli build --template defaults --template ./custom-template --template ./custom-template-stage --template internal --assets false && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
},
"private": true,
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"email": "[email protected]"
},
"projectDomain": "cli-basic-test-d0osr",
"projectTitle": "cli-basic-test"
"projectTitle": "cli-basic-test",
"origin": "https://main.development.webstudio.is"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-d845c167-ea07-4875-b08d-83e97c09dcce-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93'",
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template netlify-edge-functions --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
"fixtures:build": "pnpm cli build --template netlify-edge-functions --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
},
"dependencies": {
"@netlify/edge-functions": "^2.11.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"email": "[email protected]"
},
"projectDomain": "cli-basic-test-d0osr",
"projectTitle": "cli-basic-test"
"projectTitle": "cli-basic-test",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/webstudio-remix-netlify-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-d845c167-ea07-4875-b08d-83e97c09dcce-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=e9d1343f-9298-4fd3-a66e-f89a5af2dd93'",
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template netlify-functions --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
"fixtures:build": "pnpm cli build --template netlify-functions --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
},
"dependencies": {
"@netlify/functions": "^2.8.2",
Expand Down
3 changes: 2 additions & 1 deletion fixtures/webstudio-remix-vercel/.webstudio/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -5110,5 +5110,6 @@
"email": "[email protected]"
},
"projectDomain": "webstudio-fixture-project-a-0su3o",
"projectTitle": "webstudio-fixture-project-a"
"projectTitle": "webstudio-fixture-project-a",
"origin": "https://main.development.webstudio.is"
}
2 changes: 1 addition & 1 deletion fixtures/webstudio-remix-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
"fixtures:sync": "pnpm cli sync --buildId 0ff71ecc-db91-41d0-ba52-26d2fc6c196d && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template vercel --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
"fixtures:build": "pnpm cli build --template vercel --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
},
"private": true,
"sideEffects": false,
Expand Down
5 changes: 0 additions & 5 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export const buildOptions = (yargs: CommonYargsArgv) =>
default: true,
describe: "[Experimental] Download assets",
})
.option("preview", {
type: "boolean",
default: false,
describe: "[Experimental] Use preview version of the project",
})
.option("template", {
type: "array",
string: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const sync = async (
seviceToken: options.authToken,
origin: options.origin,
});
project.origin = options.origin;
} else {
const globalConfigText = await readFile(GLOBAL_CONFIG_FILE, "utf-8");
const globalConfig = jsonToGlobalConfig(JSON.parse(globalConfigText));
Expand Down Expand Up @@ -100,6 +101,7 @@ export const sync = async (
authToken: token,
origin,
});
project.origin = origin;
} catch (error) {
// catch errors about unpublished project
syncing.stop((error as Error).message, 2);
Expand Down
18 changes: 1 addition & 17 deletions packages/cli/src/prebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ const importFrom = (importee: string, importer: string) => {
};

export const prebuild = async (options: {
/**
* Use preview (opensource) version of the project
**/
preview: boolean;
/**
* Do we need download assets
**/
Expand Down Expand Up @@ -434,19 +430,7 @@ export const prebuild = async (options: {
const assetsToDownload: Promise<void>[] = [];

if (options.assets === true) {
const appDomain = options.preview ? "wstd.work" : "wstd.io";
const domain =
siteData.build.deployment?.assetsDomain ??
// fallback to project domain should not be used since 2025-01-01 (for now is used for backward compatibility)
(siteData.build.deployment?.destination !== "static"
? siteData.build.deployment?.projectDomain
: undefined);

if (domain === undefined) {
throw new Error(`Project domain is missing from the project data`);
}

const assetOrigin = `https://${domain}.${appDomain}`;
const assetOrigin = siteData.origin;

for (const asset of siteData.assets) {
if (asset.type === "image") {
Expand Down
1 change: 1 addition & 0 deletions packages/http-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Data = {
deployment?: Deployment | undefined;
};
assets: Array<Asset>;
origin?: string;
};

// @todo: broken as expects non 200 code
Expand Down
Loading