diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce3438a..bd85513 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,5 +41,5 @@ jobs: - name: Svelte check run: pnpm check - - name: Build site and verify installer + - name: Build site run: pnpm build diff --git a/.gitignore b/.gitignore index c86f8f0..59781ea 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,3 @@ vite.config.js.timestamp-* vite.config.ts.timestamp-* /test-results/ /playwright-report/ -/static/install.sh -/static/install.ps1 diff --git a/package.json b/package.json index 0d481f9..14e8045 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,10 @@ "private": true, "type": "module", "scripts": { - "sync:installer": "node scripts/sync-installer.mjs", - "dev": "node scripts/sync-installer.mjs && vite dev", - "build": "node scripts/sync-installer.mjs && vite build && node scripts/verify-build.mjs", + "dev": "vite dev", + "build": "vite build && node scripts/verify-build.mjs", "preview": "vite preview", - "check": "node scripts/sync-installer.mjs && svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "devDependencies": { "@sveltejs/adapter-static": "^3.0.10", diff --git a/scripts/sync-installer.mjs b/scripts/sync-installer.mjs deleted file mode 100644 index 560d239..0000000 --- a/scripts/sync-installer.mjs +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env node -import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'; -import { resolve, dirname } from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const ROOT_DIR = resolve(__dirname, '..'); -const STATIC_DIR = resolve(ROOT_DIR, 'static'); - -const installers = [ - { - name: 'install.sh', - targetFile: resolve(STATIC_DIR, 'install.sh'), - localPath: resolve(ROOT_DIR, '../wright/install.sh'), - pathEnv: 'WRIGHT_INSTALLER_PATH', - urlEnv: 'WRIGHT_INSTALLER_URL', - remoteUrl: 'https://raw.githubusercontent.com/wrightkit/wright/main/install.sh', - validate(content) { - if (!content.startsWith('#!/usr/bin/env bash') && !content.startsWith('#!/bin/bash')) { - throw new Error('install.sh must start with a bash shebang.'); - } - } - }, - { - name: 'install.ps1', - targetFile: resolve(STATIC_DIR, 'install.ps1'), - localPath: resolve(ROOT_DIR, '../wright/install.ps1'), - pathEnv: 'WRIGHT_WINDOWS_INSTALLER_PATH', - urlEnv: 'WRIGHT_WINDOWS_INSTALLER_URL', - remoteUrl: 'https://raw.githubusercontent.com/wrightkit/wright/main/install.ps1', - validate(content) { - if (!content.includes('[CmdletBinding()]') || !content.includes('x86_64-pc-windows-msvc')) { - throw new Error('install.ps1 is missing the expected PowerShell installer contract.'); - } - } - } -]; - -async function getInstallerContent(installer) { - const envPath = process.env[installer.pathEnv]; - if (envPath && existsSync(envPath)) { - return readFileSync(envPath, 'utf8'); - } - - if (existsSync(installer.localPath)) { - return readFileSync(installer.localPath, 'utf8'); - } - - const remoteUrl = process.env[installer.urlEnv] || installer.remoteUrl; - const response = await fetch(remoteUrl); - if (!response.ok) { - throw new Error(`Failed to fetch ${installer.name} from ${remoteUrl}: ${response.status} ${response.statusText}`); - } - return await response.text(); -} - -function validateInstaller(installer, content) { - if (!content || typeof content !== 'string') { - throw new Error(`${installer.name} content is empty or invalid.`); - } - installer.validate(content); - if (!content.includes('wright') || !content.includes('wright-lsp')) { - throw new Error(`${installer.name} is missing expected binary definitions (wright / wright-lsp).`); - } - if (content.length < 500) { - throw new Error(`${installer.name} is suspiciously short (${content.length} bytes).`); - } -} - -async function main() { - if (!existsSync(STATIC_DIR)) { - mkdirSync(STATIC_DIR, { recursive: true }); - } - - for (const installer of installers) { - const content = await getInstallerContent(installer); - validateInstaller(installer, content); - writeFileSync(installer.targetFile, content, 'utf8'); - } -} - -main().catch((err) => { - console.error('[sync-installer] Error:', err.message); - process.exit(1); -}); diff --git a/scripts/verify-build.mjs b/scripts/verify-build.mjs index a41bdb2..591fc3e 100644 --- a/scripts/verify-build.mjs +++ b/scripts/verify-build.mjs @@ -6,42 +6,6 @@ import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const ROOT_DIR = resolve(__dirname, '..'); -const installers = [ - { - name: 'install.sh', - path: resolve(ROOT_DIR, 'build/install.sh'), - validate(content) { - return content.startsWith('#!/usr/bin/env bash') || content.startsWith('#!/bin/bash'); - }, - error: 'build/install.sh has an invalid shebang.' - }, - { - name: 'install.ps1', - path: resolve(ROOT_DIR, 'build/install.ps1'), - validate(content) { - return content.includes('[CmdletBinding()]') && content.includes('x86_64-pc-windows-msvc'); - }, - error: 'build/install.ps1 is missing the expected PowerShell installer contract.' - } -]; - -for (const installer of installers) { - if (!existsSync(installer.path)) { - console.error(`[verify-build] Error: build/${installer.name} does not exist.`); - process.exit(1); - } - - const content = readFileSync(installer.path, 'utf8'); - if (!installer.validate(content)) { - console.error(`[verify-build] Error: ${installer.error}`); - process.exit(1); - } - if (!content.includes('wright') || !content.includes('wright-lsp')) { - console.error(`[verify-build] Error: build/${installer.name} is missing wright binary references.`); - process.exit(1); - } -} - // Each locale must ship as its own prerendered page with correct language // metadata, and commands and captured CLI output must stay untranslated. const SITE_URL = 'https://wrightkit.dev'; @@ -50,7 +14,7 @@ const pages = [ { file: 'zh-CN.html', lang: 'zh-CN', canonical: `${SITE_URL}/zh-CN` } ]; const literals = [ - 'curl -fsSL https://wrightkit.dev/install.sh | bash', + 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash', 'brew install wrightkit/tap/wright', 'wright lint rules.txt', 'warning[min-wait-loop]: loop body waits at the workshop minimum rate', @@ -79,4 +43,4 @@ for (const page of pages) { } } -console.log(`[verify-build] OK: installers and ${pages.length} localized pages verified.`); +console.log(`[verify-build] OK: ${pages.length} localized pages verified.`); diff --git a/src/lib/site.ts b/src/lib/site.ts index 59a53c3..24ff01d 100644 --- a/src/lib/site.ts +++ b/src/lib/site.ts @@ -24,7 +24,7 @@ export const site = { msrv: '1.85' } as const; -export const quickInstall = 'curl -fsSL https://wrightkit.dev/install.sh | bash'; +export const quickInstall = 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash'; export const navSections = ['start', 'features', 'languages', 'install'] as const; export type NavSection = (typeof navSections)[number]; @@ -157,23 +157,23 @@ export const installTargets = [ { id: 'macos', command: 'brew install wrightkit/tap/wright', - altCommand: 'curl -fsSL https://wrightkit.dev/install.sh | bash' + altCommand: 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash' }, { id: 'linux', - command: 'curl -fsSL https://wrightkit.dev/install.sh | bash', - altCommand: 'curl -fsSL https://wrightkit.dev/install.sh | bash -s -- --dir ~/.local/bin' + command: 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash', + altCommand: 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash -s -- --dir ~/.local/bin' }, { id: 'windows', - command: 'irm https://wrightkit.dev/install.ps1 | iex', + command: 'irm https://install.wrightkit.dev/wright/install.ps1 | iex', altCommand: - '$script = irm https://wrightkit.dev/install.ps1; & ([scriptblock]::Create($script)) -InstallDir "$HOME\\bin"' + '$script = irm https://install.wrightkit.dev/wright/install.ps1; & ([scriptblock]::Create($script)) -InstallDir "$HOME\\bin"' }, { id: 'ci', command: - 'curl -fsSL https://wrightkit.dev/install.sh | bash -s -- --version "$WRIGHT_VERSION"', + 'curl -fsSL https://install.wrightkit.dev/wright/install.sh | bash -s -- --version "$WRIGHT_VERSION"', altCommand: 'wright lint src/main.opy --format json' }, {