Dynamic URL in more places.

This commit is contained in:
Chad Curtis committed 2025-10-08 03:55:10 +00:00
1 parent fb487ea622
commit 9a6058fedb
4 files changed
+21 -6

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@ interface ShakespearePluginOptions {
* This plugin handles specific dependencies that need custom implementations
* or dummy APIs to work correctly in the browser environment.
*/
export function shakespearePlugin(options?: ShakespearePluginOptions): Plugin {
export function shakespearePlugin(options: ShakespearePluginOptions): Plugin {
return {
name: "shakespeare",
@@ -27,7 +27,7 @@ export function shakespearePlugin(options?: ShakespearePluginOptions): Plugin {
return {
contents: `
import tailwindConfig from "@/../${pathname}";
import "${options?.esmUrl}/tailwindcss-cdn@3";
import "${options.esmUrl}/tailwindcss-cdn@3";
tailwind.config = tailwindConfig;
`,
loader: "js",
+13 -1
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { BuildProjectTool } from './BuildProjectTool';
import type { JSRuntimeFS } from '../JSRuntime';
import type { AppConfig } from '../../contexts/AppContext';
// Mock the build functions
vi.mock('../build', () => ({
@@ -11,6 +12,7 @@ import { buildProject } from '../build';
describe('BuildProjectTool', () => {
let mockFS: JSRuntimeFS;
let mockConfig: AppConfig;
let tool: BuildProjectTool;
beforeEach(() => {
@@ -24,7 +26,15 @@ describe('BuildProjectTool', () => {
mkdir: vi.fn(),
} as unknown as JSRuntimeFS;
tool = new BuildProjectTool(mockFS, '/test/project');
mockConfig = {
theme: 'light',
relayUrl: 'wss://relay.nostr.band',
deployServer: 'shakespeare.wtf',
esmUrl: 'https://esm.shakespeare.diy',
language: 'en',
};
tool = new BuildProjectTool(mockFS, '/test/project', mockConfig);
});
it('should have correct description', () => {
@@ -69,6 +79,7 @@ describe('BuildProjectTool', () => {
const result = await tool.execute();
expect(buildProject).toHaveBeenCalledWith({
esmUrl: 'https://esm.shakespeare.diy',
fs: mockFS,
projectPath: '/test/project',
domParser: expect.any(DOMParser),
@@ -100,6 +111,7 @@ describe('BuildProjectTool', () => {
await tool.execute();
expect(buildProject).toHaveBeenCalledWith({
esmUrl: 'https://esm.shakespeare.diy',
fs: mockFS,
projectPath: '/test/project',
domParser: expect.any(DOMParser),
+5 -2
View File
@@ -1,23 +1,26 @@
import type { Tool } from "./Tool";
import type { JSRuntimeFS } from "../JSRuntime";
import type { AppConfig } from "../../contexts/AppContext";
import { buildProject } from "../build";
export class BuildProjectTool implements Tool<void> {
private fs: JSRuntimeFS;
private cwd: string;
private config: AppConfig;
readonly description = "Build the project using esbuild. Creates optimized production files in the dist directory.";
constructor(fs: JSRuntimeFS, cwd: string) {
constructor(fs: JSRuntimeFS, cwd: string, config: AppConfig) {
this.fs = fs;
this.cwd = cwd;
this.config = config;
}
async execute(): Promise<string> {
try {
// Build and write the project files
const result = await buildProject({
esmUrl: 'https://esm.shakespeare.diy',
esmUrl: this.config.esmUrl,
fs: this.fs,
projectPath: this.cwd,
domParser: new DOMParser(),
+1 -1
View File
@@ -31,7 +31,7 @@ export function TestApp({ children }: TestAppProps) {
theme: 'light',
relayUrl: 'wss://relay.nostr.band',
deployServer: 'shakespeare.wtf',
esmUrl: 'https://esm.sh',
esmUrl: 'https://esm.shakespeare.diy',
language: 'en',
};