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

next: replace latest with next #1347

Merged
merged 1 commit into from
Oct 25, 2024
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
7 changes: 4 additions & 3 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { resolveImport } from "../utils/resolve-imports.js";
import { syncSvelteKit } from "../utils/sveltekit.js";
import * as templates from "../utils/templates.js";
import { resolveCommand } from "package-manager-detector/commands";
import { SITE_BASE_URL } from "../constants.js";

const PROJECT_DEPENDENCIES = [
"tailwind-variants",
Expand Down Expand Up @@ -134,7 +135,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
const langConfig = detectLanguage(cwd);
if (langConfig === undefined) {
throw error(
`Failed to find a ${highlight("tsconfig.json")} or ${highlight("jsconfig.json")} file. See: ${color.underline("https://www.shadcn-svelte.com/docs/installation#opt-out-of-typescript")}`
`Failed to find a ${highlight("tsconfig.json")} or ${highlight("jsconfig.json")} file. See: ${color.underline(`${SITE_BASE_URL}/docs/installation#opt-out-of-typescript`)}`
);
}

Expand Down Expand Up @@ -311,7 +312,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
}

const config = v.parse(cliConfig.rawConfigSchema, {
$schema: "https://shadcn-svelte.com/schema.json",
$schema: `${SITE_BASE_URL}/schema.json`,
style,
typescript: langConfig.type === "tsconfig.json",
registry: defaultConfig?.registry,
Expand Down Expand Up @@ -345,7 +346,7 @@ function validateImportAlias(alias: string, langConfig: DetectLanguageResult) {
if (resolvedPath !== undefined) {
return;
}
return `"${color.bold(alias)}" does not use an existing path alias defined in your ${color.bold(langConfig.type)}. See: ${color.underline("https://www.shadcn-svelte.com/docs/installation/manual#configure-path-aliases")}`;
return `"${color.bold(alias)}" does not use an existing path alias defined in your ${color.bold(langConfig.type)}. See: ${color.underline(`${SITE_BASE_URL}/docs/installation/manual#configure-path-aliases`)}`;
}

export async function runInit(cwd: string, config: Config, options: InitOptions) {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SITE_BASE_URL = "https://next.shadcn-svelte.com";
9 changes: 5 additions & 4 deletions packages/cli/src/utils/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as v from "valibot";
import { ConfigError, error } from "./errors.js";
import { resolveImport } from "./resolve-imports.js";
import { syncSvelteKit } from "./sveltekit.js";
import { SITE_BASE_URL } from "../constants.js";

export const DEFAULT_STYLE = "default";
export const DEFAULT_COMPONENTS = "$lib/components";
Expand Down Expand Up @@ -56,7 +57,7 @@ const newConfigFields = v.object({
typescript: v.optional(v.boolean(), true),
// TODO: if they're missing this field then they're likely using svelte 4
// and we should prompt them to see if they'd like to use the new registry
registry: v.optional(v.string(), "https://shadcn-svelte.com/registry"),
registry: v.optional(v.string(), `${SITE_BASE_URL}/registry`),
});

// combines the old with the new
Expand Down Expand Up @@ -107,7 +108,7 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) {

if (pathAliases === null) {
throw error(
`Missing ${highlight("paths")} field in your ${highlight(tsconfigType)} for path aliases. See: ${color.underline("https://www.shadcn-svelte.com/docs/installation/manual#configure-path-aliases")}`
`Missing ${highlight("paths")} field in your ${highlight(tsconfigType)} for path aliases. See: ${color.underline(`${SITE_BASE_URL}/docs/installation/manual#configure-path-aliases`)}`
);
}

Expand All @@ -120,7 +121,7 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) {
new ConfigError(
`Invalid import alias found: (${highlight(`"${type}": "${alias}"`)}) in ${highlight("components.json")}.
- Import aliases ${color.underline("must use")} existing path aliases defined in your ${highlight(tsconfigType)} (e.g. "${type}": "$lib/${type}").
- See: ${color.underline("https://www.shadcn-svelte.com/docs/installation/manual#configure-path-aliases")}.`
- See: ${color.underline(`${SITE_BASE_URL}/docs/installation/manual#configure-path-aliases`)}.`
);

if (utilsPath === undefined) throw aliasError("utils", config.aliases.utils);
Expand All @@ -147,7 +148,7 @@ export function getTSConfig(cwd: string, tsconfigName: "tsconfig.json" | "jsconf
const parsedConfig = getTsconfig(path.resolve(cwd, "package.json"), tsconfigName);
if (parsedConfig === null) {
throw error(
`Failed to find ${highlight(tsconfigName)}. See: ${color.underline("https://www.shadcn-svelte.com/docs/installation#opt-out-of-typescript")}`
`Failed to find ${highlight(tsconfigName)}. See: ${color.underline(`${SITE_BASE_URL}/docs/installation#opt-out-of-typescript`)}`
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/config-full/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"hooks": "$lib/hooks"
},
"typescript": true,
"registry": "https://shadcn-svelte.com/registry"
"registry": "https://next.shadcn-svelte.com/registry"
}
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/config-jsconfig/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"hooks": "$lib/hooks"
},
"typescript": false,
"registry": "https://shadcn-svelte.com/registry"
"registry": "https://next.shadcn-svelte.com/registry"
}
11 changes: 6 additions & 5 deletions packages/cli/test/utils/get-config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { getConfig, getRawConfig } from "../../src/utils/get-config";
import { SITE_BASE_URL } from "../../src/constants";

vi.mock("execa");

Expand Down Expand Up @@ -38,7 +39,7 @@ describe("getRawConfig", () => {
ui: "$lib/components/ui",
},
typescript: true,
registry: "https://shadcn-svelte.com/registry",
registry: `${SITE_BASE_URL}/registry`,
});
});

Expand Down Expand Up @@ -99,7 +100,7 @@ describe("getConfig", () => {
),
},
typescript: true,
registry: "https://shadcn-svelte.com/registry",
registry: `${SITE_BASE_URL}/registry`,
});
});

Expand Down Expand Up @@ -135,7 +136,7 @@ describe("getConfig", () => {
ui: path.resolve(__dirname, "../fixtures/config-full", "./src/lib/components/ui"),
},
typescript: true,
registry: "https://shadcn-svelte.com/registry",
registry: `${SITE_BASE_URL}/registry`,
});
});

Expand Down Expand Up @@ -171,7 +172,7 @@ describe("getConfig", () => {
cwd: path.resolve(__dirname, "../fixtures/config-vite"),
},
typescript: true,
registry: "https://shadcn-svelte.com/registry",
registry: `${SITE_BASE_URL}/registry`,
});
});

Expand Down Expand Up @@ -217,7 +218,7 @@ describe("getConfig", () => {
cwd: path.resolve(__dirname, "../fixtures/config-jsconfig"),
},
typescript: false,
registry: "https://shadcn-svelte.com/registry",
registry: `${SITE_BASE_URL}/registry`,
});
});
});
4 changes: 2 additions & 2 deletions sites/docs/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { colorMapping, colors } from "../src/lib/registry/colors";
import { registrySchema } from "../src/lib/registry/schema";
import { styles } from "../src/lib/registry/styles";
import { themes } from "../src/lib/registry/themes";
import { buildRegistry } from "./registry-new";
import { buildRegistry } from "./registry";
import { BASE_STYLES, BASE_STYLES_WITH_VARIABLES, THEME_STYLES_WITH_VARIABLES } from "./templates";
import { getChunks } from "./transform-chunks.js";
import { getChunks } from "./transform-chunks";
import { transformContent } from "./transformers";

const REGISTRY_PATH = path.resolve("static", "registry");
Expand Down
Loading