-
Notifications
You must be signed in to change notification settings - Fork 0
feat: configure preview and simulator URL on init #183
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,13 @@ import { relative } from "node:path"; | |
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| import { Adapter } from "."; | ||
| import { getHost, getToken } from "../auth"; | ||
| import { addPreview, getPreviews, getSimulatorUrl, setSimulatorUrl } from "../clients/core"; | ||
| import { exists, writeFileRecursive } from "../lib/file"; | ||
| import { addDependencies, findPackageJson, getNpmPackageVersion } from "../lib/packageJson"; | ||
| import { dedent } from "../lib/string"; | ||
| import { appendTrailingSlash } from "../lib/url"; | ||
| import { buildRoutePath } from "../project"; | ||
| import { buildRoutePath, getRepositoryName } from "../project"; | ||
| import { checkIsTypeScriptProject, findProjectRoot } from "../project"; | ||
| import { | ||
| pageServerTemplate, | ||
|
|
@@ -42,7 +44,24 @@ export class SvelteKitAdapter extends Adapter { | |
| await modifyViteConfig(); | ||
| } | ||
|
|
||
| onProjectInitialized(): void {} | ||
| async onProjectInitialized(): Promise<void> { | ||
| const repo = await getRepositoryName(); | ||
| const token = await getToken(); | ||
| const host = await getHost(); | ||
|
|
||
| const simulatorUrl = await getSimulatorUrl({ repo, token, host }); | ||
| if (!simulatorUrl) { | ||
| await setSimulatorUrl("http://localhost:5173/slice-simulator", { repo, token, host }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 I always wondered why we don’t also use localhost:3000 for SvelteKit. I know 5173 is the default from Vite, but having 3000 everywhere could make things simpler and more consistent I guess.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5173 is 1337 for SITE 🤓
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also VITE since 5 is V in Roman numerals!
It's better to follow each framework's conventions, in my opinion, rather than force our conventions. Developers will be less surprised and will have less to learn if we follow what they expect. |
||
| } | ||
|
|
||
| const previews = await getPreviews({ repo, token, host }); | ||
| if (previews.length === 0) { | ||
| await addPreview( | ||
| { name: "Development", websiteURL: "http://localhost:5173", resolverPath: "/api/preview" }, | ||
| { repo, token, host }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| async onSliceCreated(model: SharedSlice, library: URL): Promise<void> { | ||
| const sliceDirectoryName = pascalCase(model.name); | ||
|
|
@@ -103,7 +122,7 @@ export class SvelteKitAdapter extends Adapter { | |
|
|
||
| async getDefaultCustomTypeLibrary(): Promise<URL> { | ||
| const projectRoot = await findProjectRoot(); | ||
| const defaultCustomTypeLibrary = new URL("customtypes/", projectRoot) | ||
| const defaultCustomTypeLibrary = new URL("customtypes/", projectRoot); | ||
| return defaultCustomTypeLibrary; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.