Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit ad67d2f

Browse files
feat: add GitHub Action out-of-the-box (#621)
* feat(dependabot): add support for `github-actions` ecosystem πŸŽ‰ * feat(ci): add ci workflow Co-authored-by: Clark Du <[email protected]>
1 parent b90c9ef commit ad67d2f

File tree

7 files changed

+272
-5
lines changed

7 files changed

+272
-5
lines changed

β€ŽREADME.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ yarn create nuxt-app <my-project>
7575
- [jsconfig.json](https://code.visualstudio.com/docs/languages/jsconfig)
7676
- [Semantic PR](https://probot.github.io/apps/semantic-pull-requests/)
7777
- [Dependabot (for GitHub only)](https://dependabot.com/)
78+
1. Continous Integration
79+
- [GitHub Actions](https://github.com/features/actions)
7880

7981
## CLI Options
8082

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
version: 2
22
updates:
3+
# Fetch and update latest `npm` packages
34
- package-ecosystem: npm
4-
directory: "/"
5+
directory: '/'
56
schedule:
67
interval: daily
78
time: '00:00'
8-
open-pull-requests-limit: 99
9+
open-pull-requests-limit: 10
910
reviewers:
1011
- <%= gitUsername %>
1112
assignees:
1213
- <%= gitUsername %>
13-
labels:
14-
- dependencies
1514
commit-message:
1615
prefix: fix
1716
prefix-development: chore
1817
include: scope
18+
<%_ if (ci === 'github-actions') { _%>
19+
# Fetch and update latest `github-actions` pkgs
20+
- package-ecosystem: github-actions
21+
directory: '/'
22+
schedule:
23+
interval: daily
24+
time: '00:00'
25+
open-pull-requests-limit: 10
26+
reviewers:
27+
- <%= gitUsername %>
28+
assignees:
29+
- <%= gitUsername %>
30+
commit-message:
31+
prefix: fix
32+
prefix-development: chore
33+
include: scope
34+
<%_ } _%>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
13+
jobs:
14+
ci:
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest]
20+
node: [14]
21+
22+
steps:
23+
- name: Checkout πŸ›Ž
24+
uses: actions/checkout@master
25+
26+
- name: Setup node env πŸ—
27+
uses: actions/[email protected]
28+
with:
29+
node-version: ${{ matrix.node }}
30+
31+
<%_ if (pm === 'yarn') { _%>
32+
- name: Get yarn cache directory path πŸ› 
33+
id: yarn-cache-dir-path
34+
run: echo "::set-output name=dir::$(yarn cache dir)"
35+
36+
- name: Cache node_modules πŸ“¦
37+
uses: actions/cache@v2
38+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
39+
with:
40+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
41+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-yarn-
44+
<%_ } _%>
45+
<%_ if (pm === 'npm') { _%>
46+
- name: Cache node_modules πŸ“¦
47+
uses: actions/cache@v2
48+
with:
49+
path: ~/.npm
50+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
51+
restore-keys: |
52+
${{ runner.os }}-node-
53+
<%_ } _%>
54+
55+
- name: Install dependencies πŸ‘¨πŸ»β€πŸ’»
56+
run: <%= pmRun === 'yarn' ? 'yarn' : 'npm ci' %>
57+
58+
<%_ if (linter.length > 0) { _%>
59+
- name: Run linter πŸ‘€
60+
run: <%= pmRun %> lint
61+
<%_ } _%>
62+
63+
<%_ if (test !== 'none') { _%>
64+
- name: Run tests πŸ§ͺ
65+
run: <%= pmRun %> test
66+
<%_ } _%>

β€Žpackages/create-nuxt-app/lib/prompts.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,18 @@ module.exports = [
116116
default: []
117117
},
118118
{
119-
when: answers => answers.devTools.includes('dependabot'),
119+
when: ({ test, linter }) => test !== 'none' || linter.length > 0,
120+
name: 'ci',
121+
message: 'Continuous integration:',
122+
type: 'list',
123+
choices: [
124+
{ name: 'None', value: 'none' },
125+
{ name: 'GitHub Actions (GitHub only)', value: 'github-actions' }
126+
],
127+
default: 'none'
128+
},
129+
{
130+
when: ({ devTools, ci }) => devTools.includes('dependabot') || ci !== 'none',
120131
name: 'gitUsername',
121132
message: 'What is your GitHub username?',
122133
default: '{gitUser.name}',

β€Žpackages/create-nuxt-app/lib/saofile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ module.exports = {
7676
})
7777
}
7878

79+
if (this.answers.ci && this.answers.ci !== 'none') {
80+
actions.push({
81+
type: 'add',
82+
files: '**',
83+
templateDir: join(frameworksDir, this.answers.ci)
84+
})
85+
}
86+
7987
actions.push({
8088
type: 'add',
8189
files: '*',

β€Žpackages/create-nuxt-app/test/snapshots/index.test.js.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,170 @@ The actual snapshot is saved in `index.test.js.snap`.
44

55
Generated by [AVA](https://avajs.dev).
66

7+
## verify ci: GitHub Actions (GitHub only)
8+
9+
> Generated files
10+
11+
[
12+
'.editorconfig',
13+
'.gitignore',
14+
'README.md',
15+
'assets/README.md',
16+
'components/Logo.vue',
17+
'components/README.md',
18+
'layouts/README.md',
19+
'layouts/default.vue',
20+
'middleware/README.md',
21+
'nuxt.config.js',
22+
'package.json',
23+
'pages/README.md',
24+
'pages/index.vue',
25+
'plugins/README.md',
26+
'static/README.md',
27+
'static/favicon.ico',
28+
'store/README.md',
29+
]
30+
31+
> package.json
32+
33+
{
34+
dependencies: {
35+
'core-js': '^3.6.5',
36+
nuxt: '^2.14.6',
37+
},
38+
devDependencies: {},
39+
private: true,
40+
scripts: {
41+
build: 'nuxt build',
42+
dev: 'nuxt',
43+
generate: 'nuxt generate',
44+
start: 'nuxt start',
45+
},
46+
}
47+
48+
> Generated nuxt.config.js
49+
50+
`export default {␊
51+
// Global page headers (https://go.nuxtjs.dev/config-head)␊
52+
head: {␊
53+
title: 'output',␊
54+
meta: [␊
55+
{ charset: 'utf-8' },␊
56+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
57+
{ hid: 'description', name: 'description', content: '' }␊
58+
],␊
59+
link: [␊
60+
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
61+
]␊
62+
},␊
63+
␊
64+
// Global CSS (https://go.nuxtjs.dev/config-css)␊
65+
css: [␊
66+
],␊
67+
␊
68+
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)␊
69+
plugins: [␊
70+
],␊
71+
␊
72+
// Auto import components (https://go.nuxtjs.dev/config-components)␊
73+
components: true,␊
74+
␊
75+
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)␊
76+
buildModules: [␊
77+
],␊
78+
␊
79+
// Modules (https://go.nuxtjs.dev/config-modules)␊
80+
modules: [␊
81+
],␊
82+
␊
83+
// Build Configuration (https://go.nuxtjs.dev/config-build)␊
84+
build: {␊
85+
}␊
86+
}␊
87+
`
88+
89+
## verify ci: None
90+
91+
> Generated files
92+
93+
[
94+
'.editorconfig',
95+
'.gitignore',
96+
'README.md',
97+
'assets/README.md',
98+
'components/Logo.vue',
99+
'components/README.md',
100+
'layouts/README.md',
101+
'layouts/default.vue',
102+
'middleware/README.md',
103+
'nuxt.config.js',
104+
'package.json',
105+
'pages/README.md',
106+
'pages/index.vue',
107+
'plugins/README.md',
108+
'static/README.md',
109+
'static/favicon.ico',
110+
'store/README.md',
111+
]
112+
113+
> package.json
114+
115+
{
116+
dependencies: {
117+
'core-js': '^3.6.5',
118+
nuxt: '^2.14.6',
119+
},
120+
devDependencies: {},
121+
private: true,
122+
scripts: {
123+
build: 'nuxt build',
124+
dev: 'nuxt',
125+
generate: 'nuxt generate',
126+
start: 'nuxt start',
127+
},
128+
}
129+
130+
> Generated nuxt.config.js
131+
132+
`export default {␊
133+
// Global page headers (https://go.nuxtjs.dev/config-head)␊
134+
head: {␊
135+
title: 'output',␊
136+
meta: [␊
137+
{ charset: 'utf-8' },␊
138+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
139+
{ hid: 'description', name: 'description', content: '' }␊
140+
],␊
141+
link: [␊
142+
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
143+
]␊
144+
},␊
145+
␊
146+
// Global CSS (https://go.nuxtjs.dev/config-css)␊
147+
css: [␊
148+
],␊
149+
␊
150+
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)␊
151+
plugins: [␊
152+
],␊
153+
␊
154+
// Auto import components (https://go.nuxtjs.dev/config-components)␊
155+
components: true,␊
156+
␊
157+
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)␊
158+
buildModules: [␊
159+
],␊
160+
␊
161+
// Modules (https://go.nuxtjs.dev/config-modules)␊
162+
modules: [␊
163+
],␊
164+
␊
165+
// Build Configuration (https://go.nuxtjs.dev/config-build)␊
166+
build: {␊
167+
}␊
168+
}␊
169+
`
170+
7171
## verify default answers
8172

9173
> Generated files
Binary file not shown.

0 commit comments

Comments
Β (0)