Skip to content

Commit ff12e0b

Browse files
Add support for a GitHub CI workflow (#4)
1 parent f846915 commit ff12e0b

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

.github/workflows/ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
9+
jobs:
10+
ci:
11+
if: github.repository == 'skirtles-code/create-vue-lib'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v4
18+
- name: Set up Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: 'pnpm'
23+
- name: Install dependencies
24+
run: pnpm install
25+
- name: Lint
26+
run: pnpm run lint
27+
- name: Type check
28+
run: pnpm run type-check
29+
- name: Build
30+
run: pnpm run build

packages/create-vue-lib/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type Config = {
8383
includeEsLint: boolean
8484
includeEsLintStylistic: boolean
8585
includeVitest: boolean
86+
includeGithubCi: boolean
8687
includeAtAliases: boolean
8788
includeTestVariable: boolean
8889
}
@@ -268,6 +269,7 @@ async function init() {
268269
const includeDocs = await togglePrompt('Include VitePress for documentation?', true)
269270
const includeGithubPages = includeDocs && await togglePrompt('Include GitHub Pages config for documentation?')
270271
const includePlayground = await togglePrompt('Include playground application for development?', true)
272+
const includeGithubCi = await togglePrompt('Include GitHub CI configuration?', !!githubPath)
271273
const includeExamples = await togglePromptIf(extended, 'Include example code?', true, 'Yes', 'No, just configs')
272274
const includeAtAliases = await togglePromptIf(extended, 'Configure @ as an alias for src?')
273275
const includeTestVariable = await togglePromptIf(extended, 'Configure global __TEST__ variable?')
@@ -334,6 +336,7 @@ async function init() {
334336
includeEsLint,
335337
includeEsLintStylistic,
336338
includeVitest,
339+
includeGithubCi,
337340
includeAtAliases,
338341
includeTestVariable
339342
}
@@ -360,6 +363,10 @@ async function init() {
360363
copyTemplate('vitest', config)
361364
}
362365

366+
if (config.includeGithubCi) {
367+
copyTemplate('ci', config)
368+
}
369+
363370
console.log()
364371
console.log(`${bgGreen(bold(black('DONE')))} Project created`)
365372
console.log()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
9+
jobs:
10+
ci:
11+
<%_ if (config.githubPath) { _%>
12+
if: github.repository == '<%- config.githubPath %>'
13+
<%_ } _%>
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
- name: Set up Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: 'pnpm'
25+
- name: Install dependencies
26+
run: pnpm install
27+
<%_ if (config.includeEsLint) { _%>
28+
- name: Lint
29+
run: pnpm run lint
30+
<%_ } _%>
31+
- name: Type check
32+
run: pnpm run type-check
33+
- name: Build
34+
run: pnpm run build
35+
<%_ if (config.includeVitest) { _%>
36+
- name: Test
37+
run: pnpm run test:unit
38+
<%_ } _%>

packages/docs/src/questions.md

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<span class="check">✔</span> <a href="#include-vitepress">Include VitePress for documentation? … No / Yes</a>
5151
<span class="check">✔</span> <a href="#include-github-pages">Include GitHub Pages config for documentation? … No / Yes</a>
5252
<span class="check">✔</span> <a href="#include-playground">Include playground application for development? … No / Yes</a>
53+
<span class="check">✔</span> <a href="#include-github-ci">Include GitHub CI configuration? … No / Yes</a>
5354
<span class="check">✔</span> <a href="#include-examples">Include example code? … No, just configs / Yes</a>
5455
<span class="check">✔</span> <a href="#configure-src-alias">Configure @ as an alias for src? … No / Yes</a>
5556
<span class="check">✔</span> <a href="#configure-test-variable">Configure global __TEST__ variable?</a></pre>
@@ -191,6 +192,14 @@ This isn't a playground in the same sense as the official Vue playground. Instea
191192

192193
The playground application will use your library direct from the source code, without needing to build the library separately. This is usually beneficial, as it allows for quicker development and immediate feedback on changes. But it does make the playground slightly less representative of a real consuming application, as it isn't using the built files.
193194

195+
## Include GitHub CI configuration?{#include-github-ci}
196+
197+
Continuous Integration (CI) is used to help catch problems as soon as they occur.
198+
199+
This option will include a GitHub Actions configuration for a CI workflow. It will run the `lint`, `type-check`, `build` and `test:unit` targets from the `scripts` section of the root `package.json`. The workflow is triggered by any PRs opened against the `main` branch, as well as when changes are pushed to `main`.
200+
201+
If a [GitHub path](#github-path) has been provided, the job will be configured so that it only runs for that specific fork.
202+
194203
## Include example code?{#include-examples}
195204

196205
:::info NOTE

0 commit comments

Comments
 (0)