Skip to content

Commit e626127

Browse files
authored
feat: Add Drone as an option for the CI pipeline (#40)
1 parent 5606b1e commit e626127

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

src/configs/droneCI.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { Config } from '../types'
2+
3+
const DRONE_TEMPLATE = `kind: pipeline
4+
type: kubernetes
5+
name: CI
6+
7+
trigger:
8+
event:
9+
- pull_request
10+
11+
steps:
12+
- name: lint-and-typecheck
13+
image: node:20.9.0-slim
14+
commands:
15+
- npm i -g @antfu/ni
16+
- nci
17+
- nr lint
18+
- nr typecheck
19+
- name: build
20+
image: node:20.9.0-slim
21+
commands:
22+
- npm i -g @antfu/ni
23+
- nci
24+
- nr build
25+
26+
# TODO: Add more steps here, like "nr test" as you add the tooling for it
27+
`
28+
29+
const droneCI: Config = {
30+
scripts: [],
31+
dependencies: [],
32+
nuxtConfig: {},
33+
files: [{
34+
path: '.drone.yml',
35+
content: DRONE_TEMPLATE
36+
}],
37+
}
38+
39+
export default droneCI

src/configs/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import githubActions from './github-actions'
99
import typescript from './typescript'
1010
import pnpm from './pnpm'
1111
import vscode from './vscode'
12+
import droneCI from './droneCI'
1213

1314
export type Modules = 'prisma' | 'sidebase-auth' | 'trpc' | 'tailwind' | 'naiveui'
1415
export const modules: Record<Modules, ModuleConfig> = {
@@ -19,11 +20,12 @@ export const modules: Record<Modules, ModuleConfig> = {
1920
'sidebase-auth': sidebaseAuth
2021
}
2122

22-
export type Configs = 'eslint' | 'github-actions' | 'typescript' | 'pnpm' | 'vscode'
23+
export type Configs = 'eslint' | 'github-actions' | 'typescript' | 'pnpm' | 'vscode' | 'droneCI'
2324
export const configs: Record<Configs, Config> = {
2425
'eslint': eslint,
2526
'github-actions': githubActions,
2627
'typescript': typescript,
2728
'pnpm': pnpm,
28-
'vscode': vscode
29+
'vscode': vscode,
30+
'droneCI': droneCI
2931
}

src/prompts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const PROMPT_QUESTIONS: PromptObject[] = [
4848
message: 'Initialize a default CI pipeline?',
4949
choices: [
5050
{ title: 'No CI', description: 'Scaffold a project without any CI pipeline', value: 'none' },
51-
{ title: 'GitHub Actions', description: 'Run your CI with GitHub actions.', value: 'github' },
51+
{ title: 'GitHub Actions', description: 'Run your CI with GitHub actions', value: 'github' },
52+
{ title: 'DroneCI', description: 'Run your CI with Drone', value: 'drone' },
5253
],
5354
initial: 0,
5455
},

src/steps/2.getConfigs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ export default function (preferences: Preferences) {
1010
return { configs: [], modules: [] }
1111
}
1212

13-
// 2. Add Github Actions CI, if enabled
13+
// 2. Add Prebuilt CI pipeline
1414
if (preferences.addCi === 'github') {
1515
setConfigs.push(configs['github-actions'])
1616
}
17+
if (preferences.addCi === 'drone') {
18+
setConfigs.push(configs.droneCI)
19+
}
1720

1821
// 3. Add required base configs
1922
setConfigs.push(configs.eslint)

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface Preferences {
77
setStack: Stack
88
addModules?: Modules[]
99
runGitInit: boolean
10-
addCi?: 'github'
10+
addCi?: 'github' | 'drone'
1111
runInstall: boolean
1212
}
1313

0 commit comments

Comments
 (0)