Skip to content

Commit

Permalink
migrate to pnpm (part 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed Jan 31, 2024
1 parent d05d20a commit 1d6d4cb
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 88 deletions.
16 changes: 14 additions & 2 deletions src/defineGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export function vite(
Generator,
'displayedCommand' | 'frameworkUrl' | 'frameworkDocumentationUrl'
> &
GeneratorCommand &
GeneratorStaticOutput {
GeneratorCommand {
return {
command: [
`pnpm create vite fresh-app --template=${template}`,
Expand All @@ -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',
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/generators/fresh-vite-app-lit-element-ts.ts
Original file line number Diff line number Diff line change
@@ -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,
})
12 changes: 4 additions & 8 deletions src/generators/fresh-vite-app-lit-element.ts
Original file line number Diff line number Diff line change
@@ -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,
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-preact-ts.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-preact.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-react-ts.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-react.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-svelte-ts.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-svelte.ts
Original file line number Diff line number Diff line change
@@ -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',
})
9 changes: 2 additions & 7 deletions src/generators/fresh-vite-app-ts.ts
Original file line number Diff line number Diff line change
@@ -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',
})
4 changes: 2 additions & 2 deletions src/generators/fresh-vite-app-vue-ts.ts
Original file line number Diff line number Diff line change
@@ -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',
})
4 changes: 2 additions & 2 deletions src/generators/fresh-vite-app-vue.ts
Original file line number Diff line number Diff line change
@@ -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',
})
4 changes: 2 additions & 2 deletions src/generators/fresh-vite-app.ts
Original file line number Diff line number Diff line change
@@ -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',
})
34 changes: 24 additions & 10 deletions src/generators/fresh-vitepress-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions src/generators/fresh-vscode-extension.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
8 changes: 6 additions & 2 deletions src/generators/fresh-vscode-web-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

0 comments on commit 1d6d4cb

Please sign in to comment.