Skip to content

Commit 9e8407a

Browse files
committed
refactor: drop --preview flag from CLI
We figured assets can be loaded from shared url without additional manipulation. Here got rid of asset origin detection and dropped excessive --preview flag. Now local, staging and prod will work automatically.
1 parent 71f56ea commit 9e8407a

File tree

18 files changed

+25
-36
lines changed

18 files changed

+25
-36
lines changed

fixtures/ssg-netlify-by-project-id/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,6 @@
136136
"email": "hello@webstudio.is"
137137
},
138138
"projectDomain": "fixture-client-do-not-touch-wsmel",
139-
"projectTitle": "FIXTURE-CLIENT-DO-NOT-TOUCH"
139+
"projectTitle": "FIXTURE-CLIENT-DO-NOT-TOUCH",
140+
"origin": "https://main.development.webstudio.is"
140141
}

fixtures/ssg-netlify-by-project-id/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
1111
"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'",
1212
"fixtures:sync": "pnpm cli sync && pnpm prettier --write ./.webstudio/",
13-
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg-netlify --template internal --preview && prettier --write ."
13+
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg-netlify --template internal && prettier --write ."
1414
},
1515
"engines": {
1616
"node": ">=20.0.0"

fixtures/ssg/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,6 @@
493493
"email": "hello@webstudio.is"
494494
},
495495
"projectDomain": "cli-basic-test-d0osr",
496-
"projectTitle": "cli-basic-test"
496+
"projectTitle": "cli-basic-test",
497+
"origin": "https://main.development.webstudio.is"
497498
}

fixtures/ssg/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
1111
"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'",
1212
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
13-
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg --template internal --preview && prettier --write ."
13+
"fixtures:build": "rm -rf pages && pnpm cli build --template ssg --template internal && prettier --write ."
1414
},
1515
"engines": {
1616
"node": ">=20.0.0"

fixtures/webstudio-cloudflare-template/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,6 @@
493493
"email": "hello@webstudio.is"
494494
},
495495
"projectDomain": "cli-basic-test-d0osr",
496-
"projectTitle": "cli-basic-test"
496+
"projectTitle": "cli-basic-test",
497+
"origin": "https://main.development.webstudio.is"
497498
}

fixtures/webstudio-cloudflare-template/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
55
"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'",
66
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
7-
"fixtures:build": "pnpm cli build --template cloudflare --template saas-helpers --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json",
7+
"fixtures:build": "pnpm cli build --template cloudflare --template saas-helpers --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json",
88
"build": "remix vite:build",
99
"dev": "remix vite:dev",
1010
"typecheck": "tsc",

fixtures/webstudio-custom-template/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2331,5 +2331,6 @@
23312331
"email": "hello@webstudio.is"
23322332
},
23332333
"projectDomain": "webstudio-custom-template-cochj",
2334-
"projectTitle": "webstudio-custom-template"
2334+
"projectTitle": "webstudio-custom-template",
2335+
"origin": "https://main.development.webstudio.is"
23352336
}

fixtures/webstudio-custom-template/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"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'",
99
"fixtures:sync": "pnpm cli sync --buildId d48c7c5e-fdd3-4ef6-9173-ff2eaaf851d9 && pnpm prettier --write ./.webstudio/",
10-
"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"
10+
"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"
1111
},
1212
"private": true,
1313
"sideEffects": false,

fixtures/webstudio-remix-netlify-edge-functions/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,6 @@
493493
"email": "hello@webstudio.is"
494494
},
495495
"projectDomain": "cli-basic-test-d0osr",
496-
"projectTitle": "cli-basic-test"
496+
"projectTitle": "cli-basic-test",
497+
"origin": "https://main.development.webstudio.is"
497498
}

fixtures/webstudio-remix-netlify-edge-functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
99
"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'",
1010
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
11-
"fixtures:build": "pnpm cli build --template netlify-edge-functions --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
11+
"fixtures:build": "pnpm cli build --template netlify-edge-functions --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1212
},
1313
"dependencies": {
1414
"@netlify/edge-functions": "^2.11.1",

fixtures/webstudio-remix-netlify-functions/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,6 @@
493493
"email": "hello@webstudio.is"
494494
},
495495
"projectDomain": "cli-basic-test-d0osr",
496-
"projectTitle": "cli-basic-test"
496+
"projectTitle": "cli-basic-test",
497+
"origin": "https://main.development.webstudio.is"
497498
}

fixtures/webstudio-remix-netlify-functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"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'",
99
"fixtures:sync": "pnpm cli sync --buildId a2e8de30-03d5-4514-a3a6-406b3266a3af && pnpm prettier --write ./.webstudio/",
10-
"fixtures:build": "pnpm cli build --template netlify-functions --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
10+
"fixtures:build": "pnpm cli build --template netlify-functions --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"dependencies": {
1313
"@netlify/functions": "^2.8.2",

fixtures/webstudio-remix-vercel/.webstudio/data.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5110,5 +5110,6 @@
51105110
"email": "hello@webstudio.is"
51115111
},
51125112
"projectDomain": "webstudio-fixture-project-a-0su3o",
5113-
"projectTitle": "webstudio-fixture-project-a"
5113+
"projectTitle": "webstudio-fixture-project-a",
5114+
"origin": "https://main.development.webstudio.is"
51145115
}

fixtures/webstudio-remix-vercel/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"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'",
99
"fixtures:sync": "pnpm cli sync --buildId 0ff71ecc-db91-41d0-ba52-26d2fc6c196d && pnpm prettier --write ./.webstudio/",
10-
"fixtures:build": "pnpm cli build --template vercel --template internal --preview && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
10+
"fixtures:build": "pnpm cli build --template vercel --template internal && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"private": true,
1313
"sideEffects": false,

packages/cli/src/commands/build.ts

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ export const buildOptions = (yargs: CommonYargsArgv) =>
1616
default: true,
1717
describe: "[Experimental] Download assets",
1818
})
19-
.option("preview", {
20-
type: "boolean",
21-
default: false,
22-
describe: "[Experimental] Use preview version of the project",
23-
})
2419
.option("template", {
2520
type: "array",
2621
string: true,

packages/cli/src/commands/sync.ts

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const sync = async (
5555
seviceToken: options.authToken,
5656
origin: options.origin,
5757
});
58+
project.origin = options.origin;
5859
} else {
5960
const globalConfigText = await readFile(GLOBAL_CONFIG_FILE, "utf-8");
6061
const globalConfig = jsonToGlobalConfig(JSON.parse(globalConfigText));
@@ -100,6 +101,7 @@ export const sync = async (
100101
authToken: token,
101102
origin,
102103
});
104+
project.origin = origin;
103105
} catch (error) {
104106
// catch errors about unpublished project
105107
syncing.stop((error as Error).message, 2);

packages/cli/src/prebuild.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,6 @@ const importFrom = (importee: string, importer: string) => {
211211
};
212212

213213
export const prebuild = async (options: {
214-
/**
215-
* Use preview (opensource) version of the project
216-
**/
217-
preview: boolean;
218214
/**
219215
* Do we need download assets
220216
**/
@@ -434,19 +430,7 @@ export const prebuild = async (options: {
434430
const assetsToDownload: Promise<void>[] = [];
435431

436432
if (options.assets === true) {
437-
const appDomain = options.preview ? "wstd.work" : "wstd.io";
438-
const domain =
439-
siteData.build.deployment?.assetsDomain ??
440-
// fallback to project domain should not be used since 2025-01-01 (for now is used for backward compatibility)
441-
(siteData.build.deployment?.destination !== "static"
442-
? siteData.build.deployment?.projectDomain
443-
: undefined);
444-
445-
if (domain === undefined) {
446-
throw new Error(`Project domain is missing from the project data`);
447-
}
448-
449-
const assetOrigin = `https://${domain}.${appDomain}`;
433+
const assetOrigin = siteData.origin;
450434

451435
for (const asset of siteData.assets) {
452436
if (asset.type === "image") {

packages/http-client/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type Data = {
3535
deployment?: Deployment | undefined;
3636
};
3737
assets: Array<Asset>;
38+
origin?: string;
3839
};
3940

4041
// @todo: broken as expects non 200 code

0 commit comments

Comments
 (0)