Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
oushihao
committed
Mar 10, 2022
1 parent
3c08ba6
commit ba84e97
Showing
6 changed files
with
99 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const path = require('path') | ||
const fs = require('fs') | ||
|
||
const renderTemplate = (src, dest) => { | ||
const stat = fs.statSync(src) | ||
|
||
if (stat.isDirectory()) { | ||
if (path.basename(src) === 'node_modules') return | ||
|
||
fs.mkdirSync(dest, { recursive: true }) | ||
for (const file of fs.readdirSync(src)) { | ||
renderTemplate(path.resolve(src, file), path.resolve(dest, file)) | ||
} | ||
return | ||
} | ||
|
||
const filename = path.basename(src) | ||
|
||
if (filename === 'package.json' && fs.existsSync(dest)) { | ||
// TODO merge | ||
|
||
return | ||
} | ||
|
||
if (/^\./.test(filename)) return | ||
|
||
if (/^\_/.test(filename)) { | ||
dest = path.resolve(path.dirname(dest), filename.replace(/^_/, '.')) | ||
} | ||
|
||
fs.copyFileSync(src, dest) | ||
} | ||
|
||
module.exports = { | ||
renderTemplate, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
const templateOptions = [ | ||
{ id: 'NODE', label: 'node-ts-template' }, | ||
{ id: 'VUE3', label: 'vue3-template' }, | ||
{ id: 'VUE3_LITE', label: 'vue3-lite-template (without router and store)' }, | ||
{ id: 'REACT', label: 'react-template' }, | ||
{ id: 'REACT_LITE', label: 'react-lite-template' }, | ||
]; | ||
// { id: 'NODE', label: 'node-ts-template' }, | ||
// { id: 'VUE3', label: 'vue3-template' }, | ||
{ id: 'vue3-lite', label: 'vue3-lite-template (without router and store)' }, | ||
// { id: 'REACT', label: 'react-template' }, | ||
// { id: 'REACT_LITE', label: 'react-lite-template' }, | ||
] | ||
|
||
const optionsToChoices = () => | ||
templateOptions.map((o) => ({ title: o.label, value: o.id })); | ||
templateOptions.map((o) => ({ title: o.label, value: o.id })) | ||
|
||
module.exports = { | ||
templateOptions, | ||
templateChoices: optionsToChoices(), | ||
}; | ||
} |