diff --git a/src/defineGenerator.ts b/src/defineGenerator.ts index bd66163..fb965a7 100644 --- a/src/defineGenerator.ts +++ b/src/defineGenerator.ts @@ -10,8 +10,7 @@ export function vite( Generator, 'displayedCommand' | 'frameworkUrl' | 'frameworkDocumentationUrl' > & - GeneratorCommand & - GeneratorStaticOutput { + GeneratorCommand { return { command: [ `pnpm create vite fresh-app --template=${template}`, @@ -22,6 +21,19 @@ export function vite( displayedCommand: `pnpm create vite --template=${template}`, frameworkUrl: 'https://vitejs.dev/', frameworkDocumentationUrl: 'https://vitejs.dev/guide/', + } +} + +export function viteStatic( + template: string, +): Pick< + Generator, + 'displayedCommand' | 'frameworkUrl' | 'frameworkDocumentationUrl' +> & + GeneratorCommand & + GeneratorStaticOutput { + return { + ...vite(template), staticOutputDirectory: 'dist', } } diff --git a/src/generators/fresh-vite-app-lit-element-ts.ts b/src/generators/fresh-vite-app-lit-element-ts.ts index ea1412c..98dea22 100644 --- a/src/generators/fresh-vite-app-lit-element-ts.ts +++ b/src/generators/fresh-vite-app-lit-element-ts.ts @@ -1,14 +1,10 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, vite } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=lit-ts && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=lit-ts', + ...vite('lit-ts'), description: 'Fresh Lit Element', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', // Disabled due to timeout errors - // serverCommand: 'yarn dev --clearScreen=false', - // serverPort: 5173, + serverCommand: 'pnpm dev --clearScreen=false', + serverPort: 5173, }) diff --git a/src/generators/fresh-vite-app-lit-element.ts b/src/generators/fresh-vite-app-lit-element.ts index 62afb19..1b15325 100644 --- a/src/generators/fresh-vite-app-lit-element.ts +++ b/src/generators/fresh-vite-app-lit-element.ts @@ -1,14 +1,10 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, vite } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=lit && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=lit', + ...vite('lit'), description: 'Fresh Lit Element', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', // Disabled due to timeout errors - // serverCommand: 'yarn dev --clearScreen=false', - // serverPort: 5173, + serverCommand: 'pnpm dev --clearScreen=false', + serverPort: 5173, }) diff --git a/src/generators/fresh-vite-app-preact-ts.ts b/src/generators/fresh-vite-app-preact-ts.ts index 1443377..d696ba8 100644 --- a/src/generators/fresh-vite-app-preact-ts.ts +++ b/src/generators/fresh-vite-app-preact-ts.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=preact-ts && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=preact-ts', + ...viteStatic('preact-ts'), description: 'Fresh Preact app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-preact.ts b/src/generators/fresh-vite-app-preact.ts index b134bb6..4f0b16a 100644 --- a/src/generators/fresh-vite-app-preact.ts +++ b/src/generators/fresh-vite-app-preact.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=preact && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=preact', + ...viteStatic('preact'), description: 'Fresh Preact app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-react-ts.ts b/src/generators/fresh-vite-app-react-ts.ts index a90b3ff..cb24a4d 100644 --- a/src/generators/fresh-vite-app-react-ts.ts +++ b/src/generators/fresh-vite-app-react-ts.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=react-ts && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=react-ts', + ...viteStatic('react-ts'), description: 'Fresh React app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-react.ts b/src/generators/fresh-vite-app-react.ts index 0cf8d61..251cf8f 100644 --- a/src/generators/fresh-vite-app-react.ts +++ b/src/generators/fresh-vite-app-react.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=react && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=react', + ...viteStatic('react'), description: 'Fresh React app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-svelte-ts.ts b/src/generators/fresh-vite-app-svelte-ts.ts index 98e7b27..27bb6be 100644 --- a/src/generators/fresh-vite-app-svelte-ts.ts +++ b/src/generators/fresh-vite-app-svelte-ts.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=svelte-ts && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=svelte-ts', + ...viteStatic('svelte-ts'), description: 'Fresh Svelte app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-svelte.ts b/src/generators/fresh-vite-app-svelte.ts index 0d46011..37471b4 100644 --- a/src/generators/fresh-vite-app-svelte.ts +++ b/src/generators/fresh-vite-app-svelte.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=svelte && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=svelte', + ...viteStatic('svelte'), description: 'Fresh Svelte app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-ts.ts b/src/generators/fresh-vite-app-ts.ts index 4d4a702..11d2c80 100644 --- a/src/generators/fresh-vite-app-ts.ts +++ b/src/generators/fresh-vite-app-ts.ts @@ -1,11 +1,6 @@ -import { defineGenerator } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - command: - 'yarn create vite fresh-app --template=vanilla-ts && cd fresh-app && yarn && yarn build', - displayedCommand: 'yarn create vite fresh-app --template=vanilla-ts', + ...viteStatic('vanilla-ts'), description: 'Fresh Vite app', - frameworkUrl: 'https://vitejs.dev/', - frameworkDocumentationUrl: 'https://vitejs.dev/guide/', - staticOutputDirectory: 'dist', }) diff --git a/src/generators/fresh-vite-app-vue-ts.ts b/src/generators/fresh-vite-app-vue-ts.ts index f1c1474..0c4967e 100644 --- a/src/generators/fresh-vite-app-vue-ts.ts +++ b/src/generators/fresh-vite-app-vue-ts.ts @@ -1,6 +1,6 @@ -import { defineGenerator, vite } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - ...vite('vue-ts'), + ...viteStatic('vue-ts'), description: 'Fresh Vue app', }) diff --git a/src/generators/fresh-vite-app-vue.ts b/src/generators/fresh-vite-app-vue.ts index 39a4c10..c8de390 100644 --- a/src/generators/fresh-vite-app-vue.ts +++ b/src/generators/fresh-vite-app-vue.ts @@ -1,6 +1,6 @@ -import { defineGenerator, vite } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - ...vite('vue'), + ...viteStatic('vue'), description: 'Fresh Vue app', }) diff --git a/src/generators/fresh-vite-app.ts b/src/generators/fresh-vite-app.ts index 020b157..4e97825 100644 --- a/src/generators/fresh-vite-app.ts +++ b/src/generators/fresh-vite-app.ts @@ -1,6 +1,6 @@ -import { defineGenerator, vite } from '../defineGenerator' +import { defineGenerator, viteStatic } from '../defineGenerator' export default defineGenerator({ - ...vite('vanilla'), + ...viteStatic('vanilla'), description: 'Fresh Vite app', }) diff --git a/src/generators/fresh-vitepress-site.ts b/src/generators/fresh-vitepress-site.ts index f854bc1..4ede591 100644 --- a/src/generators/fresh-vitepress-site.ts +++ b/src/generators/fresh-vitepress-site.ts @@ -2,16 +2,30 @@ import { defineGenerator } from '../defineGenerator' export default defineGenerator({ description: 'Fresh VitePress site', - command: [ - 'mkdir fresh-app', - 'cd fresh-app', - 'yarn add --dev vitepress vue', - 'wget https://github.com/vuejs/vitepress/raw/main/docs/index.md -O index.md', - 'wget https://github.com/vuejs/vitepress/raw/main/.gitignore -O .gitignore', - `cat package.json | jq '.scripts.dev = "vitepress dev" | .scripts.build = "vitepress build" | .scripts.serve = "vitepress serve"' > package.json.tmp && mv package.json.tmp package.json`, - 'yarn build', - 'test -f .vitepress/dist/index.html && echo "Ok, output file exists" || (echo "Error, output file does not exist" && exit 1)', - ].join('\n'), + script: async (t) => { + await t.send('mkdir fresh-app && cd fresh-app && echo "{}" > package.json') + await t.waitForText('$') + await t.send('corepack use pnpm@latest') + await t.waitForText('$') + await t.send('pnpm add -D vitepress vue') + await t.waitForText('$') + await t.send('pnpm vitepress init') + await t.waitForText('Where') + await t.send('') + await t.waitForText('title') + await t.send('') + await t.waitForText('description') + await t.send('') + await t.waitForText('Theme') + await t.send('') + await t.waitForText('TypeScript') + await t.send('') + await t.waitForText('package') + await t.send('') + await t.waitForText('Done') + await t.send('pnpm docs:build') + await t.waitForText('$') + }, staticOutputDirectory: '.vitepress/dist', frameworkUrl: 'https://vitepress.vuejs.org/', frameworkDocumentationUrl: diff --git a/src/generators/fresh-vscode-extension.ts b/src/generators/fresh-vscode-extension.ts index ae72e22..6961413 100644 --- a/src/generators/fresh-vscode-extension.ts +++ b/src/generators/fresh-vscode-extension.ts @@ -1,9 +1,13 @@ import { defineGenerator } from '../defineGenerator' export default defineGenerator({ - command: - "yes '' | npx -p yo -p generator-code yo code fresh-extension -y > /dev/null && mv fresh-extension fresh-app", - displayedCommand: 'yo code', + command: [ + 'pnpm install --global yo generator-code', + 'yo code --quick --extensionType=ts --gitInit=false fresh-extension', + 'mv fresh-extension fresh-app', + 'test -f fresh-app/package.json', + ].join('\n'), + displayedCommand: 'yo code --extensionType=ts', description: 'Fresh VS Code extension', longDescription: 'Fresh VS Code extension', frameworkUrl: 'https://code.visualstudio.com/api', diff --git a/src/generators/fresh-vscode-web-extension.ts b/src/generators/fresh-vscode-web-extension.ts index 41e0f04..adaae05 100644 --- a/src/generators/fresh-vscode-web-extension.ts +++ b/src/generators/fresh-vscode-web-extension.ts @@ -2,14 +2,18 @@ import { defineGenerator } from '../defineGenerator' export default defineGenerator({ command: [ - 'yarn global add yo generator-code', + 'sudo pnpx playwright install-deps', + 'pnpm install --global yo generator-code @vscode/test-web', 'yo code --quick --extensionType=web --gitInit=false fresh-extension', 'mv fresh-extension fresh-app', + 'test -f fresh-app/package.json', ].join('\n'), - displayedCommand: 'yo code', + displayedCommand: 'yo code --extensionType=web', description: 'Fresh VS Code web extension', longDescription: 'Fresh VS Code web extension', frameworkUrl: 'https://code.visualstudio.com/api', frameworkDocumentationUrl: 'https://code.visualstudio.com/api/extension-guides/web-extensions', + serverCommand: 'vscode-test-web --extensionDevelopmentPath=. .', + serverPort: 3000, })