Skip to content

Commit b1fa635

Browse files
committed
feat: copy of template
1 parent f08cd46 commit b1fa635

3 files changed

Lines changed: 77 additions & 57 deletions

File tree

lib/commands/create.js

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ async function create (opts) {
7474
}
7575

7676
await createConfigFile(config)
77+
createGitIgnore(config)
7778

7879
await createPackageJson({
7980
cwd: appPath,
@@ -97,6 +98,7 @@ async function create (opts) {
9798
}
9899
})
99100

101+
100102
gitInit(appPath)
101103
}
102104

@@ -131,66 +133,19 @@ function transformUserInput(input) {
131133

132134
function createBuildAction(config) {
133135
const workflowDir = path.join(config.path, '.github', 'workflows')
134-
fs.ensureDirSync(workflowDir)
136+
const templateFile = path.join(__dirname, 'template', 'build.yml')
135137
const configFile = path.join(workflowDir, 'build.yml')
138+
139+
fs.ensureDirSync(workflowDir)
140+
fs.copyFileSync(templateFile, configFile)
141+
}
136142

137-
const buildAction = `name: Generate Statusboard
138-
139-
on:
140-
push:
141-
branches:
142-
- main
143-
workflow_dispatch:
144-
145-
permissions:
146-
contents: read
147-
pages: write
148-
id-token: write
149-
150-
151-
concurrency:
152-
group: "pages"
153-
cancel-in-progress: false
154-
155-
jobs:
156-
index:
157-
environment:
158-
name: github-pages
159-
url: \${{ steps.deployment.outputs.page_url }}
160-
runs-on: ubuntu-latest
161-
steps:
162-
- name: Checkout
163-
uses: actions/checkout@v4
164-
- name: Setup Pages
165-
uses: actions/configure-pages@v5
166-
- uses: actions/setup-node@v4
167-
with:
168-
node-version: lts/*
169-
- uses: actions/cache@v4
170-
id: cache
171-
with:
172-
path: |
173-
~/.npm
174-
~/.cache
175-
./dist
176-
./node_modules
177-
key: \${{ runner.os }}-build-\${{ github.sha }}
178-
- if: steps.cache.outputs.cache-hit != 'true'
179-
run: npm install
180-
shell: bash
181-
- run: npm run build
182-
env:
183-
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
184-
- name: Upload artifact
185-
uses: actions/upload-pages-artifact@v3
186-
with:
187-
path: './build'
188-
- name: Deploy to GitHub Pages
189-
id: deployment
190-
uses: actions/deploy-pages@v4
191-
`
143+
function createGitIgnore(config) {
144+
const gitIgnore = path.join(config.path, '.gitignore')
145+
const templateFile = path.join(__dirname, 'template', '.gitignore')
192146

193-
fs.writeFileSync(configFile, buildAction)
147+
fs.ensureFileSync(gitIgnore)
148+
fs.copyFileSync(templateFile, gitIgnore)
194149
}
195150

196151
module.exports = create

lib/commands/template/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# dependencies
2+
node_modules
3+
.pnp
4+
.pnp.js
5+
6+
# production
7+
build
8+
9+
# local env files
10+
.env*.local
11+
.env

lib/commands/template/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Generate Statusboard
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
index:
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Setup Pages
29+
uses: actions/configure-pages@v5
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: lts/*
33+
- uses: actions/cache@v4
34+
id: cache
35+
with:
36+
path: |
37+
~/.npm
38+
~/.cache
39+
./dist
40+
./node_modules
41+
key: ${{ runner.os }}-build-${{ github.sha }}
42+
- if: steps.cache.outputs.cache-hit != 'true'
43+
run: npm install
44+
shell: bash
45+
- run: npm run build
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: './build'
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)