Skip to content

Add support for a GitHub CI workflow #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
ci:
if: github.repository == 'skirtles-code/create-vue-lib'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm run lint
- name: Type check
run: pnpm run type-check
- name: Build
run: pnpm run build
7 changes: 7 additions & 0 deletions packages/create-vue-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type Config = {
includeEsLint: boolean
includeEsLintStylistic: boolean
includeVitest: boolean
includeGithubCi: boolean
includeAtAliases: boolean
includeTestVariable: boolean
}
Expand Down Expand Up @@ -268,6 +269,7 @@ async function init() {
const includeDocs = await togglePrompt('Include VitePress for documentation?', true)
const includeGithubPages = includeDocs && await togglePrompt('Include GitHub Pages config for documentation?')
const includePlayground = await togglePrompt('Include playground application for development?', true)
const includeGithubCi = await togglePrompt('Include GitHub CI configuration?', !!githubPath)
const includeExamples = await togglePromptIf(extended, 'Include example code?', true, 'Yes', 'No, just configs')
const includeAtAliases = await togglePromptIf(extended, 'Configure @ as an alias for src?')
const includeTestVariable = await togglePromptIf(extended, 'Configure global __TEST__ variable?')
Expand Down Expand Up @@ -334,6 +336,7 @@ async function init() {
includeEsLint,
includeEsLintStylistic,
includeVitest,
includeGithubCi,
includeAtAliases,
includeTestVariable
}
Expand All @@ -360,6 +363,10 @@ async function init() {
copyTemplate('vitest', config)
}

if (config.includeGithubCi) {
copyTemplate('ci', config)
}

console.log()
console.log(`${bgGreen(bold(black('DONE')))} Project created`)
console.log()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
ci:
<%_ if (config.githubPath) { _%>
if: github.repository == '<%- config.githubPath %>'
<%_ } _%>
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
<%_ if (config.includeEsLint) { _%>
- name: Lint
run: pnpm run lint
<%_ } _%>
- name: Type check
run: pnpm run type-check
- name: Build
run: pnpm run build
<%_ if (config.includeVitest) { _%>
- name: Test
run: pnpm run test:unit
<%_ } _%>
9 changes: 9 additions & 0 deletions packages/docs/src/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<span class="check">✔</span> <a href="#include-vitepress">Include VitePress for documentation? … No / Yes</a>
<span class="check">✔</span> <a href="#include-github-pages">Include GitHub Pages config for documentation? … No / Yes</a>
<span class="check">✔</span> <a href="#include-playground">Include playground application for development? … No / Yes</a>
<span class="check">✔</span> <a href="#include-github-ci">Include GitHub CI configuration? … No / Yes</a>
<span class="check">✔</span> <a href="#include-examples">Include example code? … No, just configs / Yes</a>
<span class="check">✔</span> <a href="#configure-src-alias">Configure @ as an alias for src? … No / Yes</a>
<span class="check">✔</span> <a href="#configure-test-variable">Configure global __TEST__ variable?</a></pre>
Expand Down Expand Up @@ -191,6 +192,14 @@ This isn't a playground in the same sense as the official Vue playground. Instea

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.

## Include GitHub CI configuration?{#include-github-ci}

Continuous Integration (CI) is used to help catch problems as soon as they occur.

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`.

If a [GitHub path](#github-path) has been provided, the job will be configured so that it only runs for that specific fork.

## Include example code?{#include-examples}

:::info NOTE
Expand Down