wip(new-design): Added different templates
This commit is contained in:
parent
437d444462
commit
14f43fb078
38 changed files with 977 additions and 87 deletions
|
@ -5,7 +5,7 @@ import mustache from 'mustache'
|
|||
import rdir from 'recursive-readdir'
|
||||
import chalk from 'chalk'
|
||||
import prompts from 'prompts'
|
||||
import {oraPromise} from 'ora'
|
||||
import { oraPromise } from 'ora'
|
||||
import { execa } from 'execa'
|
||||
import axios from 'axios'
|
||||
import { fileURLToPath } from 'url';
|
||||
|
@ -15,7 +15,6 @@ const cwd = __dirname
|
|||
? __dirname
|
||||
: dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
console.log({cwd})
|
||||
const nl = "\n"
|
||||
const tab = " "
|
||||
const nlt = nl+tab
|
||||
|
@ -158,6 +157,20 @@ const downloadLabFiles = async (config) => {
|
|||
return
|
||||
}
|
||||
|
||||
// Helper method to initialize a git repository
|
||||
const initGitRepo = async (config, choices) => {
|
||||
await writeFile(join(config.dest, '.gitignore'), config.gitignore, 'utf-8')
|
||||
|
||||
return execa(
|
||||
`git init -b main && git add . && git commit -m ":tada: Initialized ${choices.name} repository"`,
|
||||
{
|
||||
cwd: config.dest,
|
||||
shell: true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// Creates the environment based on the user's choices
|
||||
export const createEnvironment = async (choices) => {
|
||||
|
||||
|
@ -179,13 +192,16 @@ export const createEnvironment = async (choices) => {
|
|||
shared: await rdir(config.source.shared),
|
||||
}
|
||||
|
||||
// Output a linebreak
|
||||
console.log()
|
||||
|
||||
// Copy/Template files
|
||||
await oraPromise(
|
||||
copyTemplate(config, choices),
|
||||
{
|
||||
text: chalk.white.bold(' 🟨⬜⬜ Copying template files')+chalk.white.dim(' | Just a moment'),
|
||||
successText: chalk.white.bold(' 🟩⬜⬜ Copied template files'),
|
||||
failText: chalk.white.bold(' 🟥⬜⬜ Failed to copy template files'),
|
||||
text: chalk.white.bold('🟨⬜⬜⬜ Copying template files')+chalk.white.dim(' | Just a moment'),
|
||||
successText: chalk.white.bold('🟩⬜⬜⬜ Copied template files'),
|
||||
failText: chalk.white.bold(' ⚠️ Failed to copy template files'),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -193,9 +209,9 @@ export const createEnvironment = async (choices) => {
|
|||
await oraPromise(
|
||||
installDependencies(config, choices),
|
||||
{
|
||||
text: chalk.white.bold(' 🟩🟨⬜ Installing dependencies')+chalk.white.dim(' | Please wait, this will take a while'),
|
||||
successText: chalk.white.bold(' 🟩🟩⬜ Installed dependencies'),
|
||||
failText: chalk.white.bold(' 🟩🟥⬜ Failed to install dependencies'),
|
||||
text: chalk.white.bold('🟩🟨⬜⬜ Installing dependencies')+chalk.white.dim(' | Please wait, this will take a while'),
|
||||
successText: chalk.white.bold('🟩🟩⬜⬜ Installed dependencies'),
|
||||
failText: chalk.white.bold(' ⚠️ Failed to install dependencies'),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -203,77 +219,21 @@ export const createEnvironment = async (choices) => {
|
|||
await oraPromise(
|
||||
downloadLabFiles(config),
|
||||
{
|
||||
text: chalk.white.bold(' 🟩🟩🟨 Downloading web components')+chalk.white.dim(' | Almost there'),
|
||||
successText: chalk.white.bold(' 🟩🟩🟩 Downloaded web components'),
|
||||
failText: chalk.white.bold(' 🟩🟩🟥 Failed to download web components'),
|
||||
text: chalk.white.bold('🟩🟩🟨⬜ Downloading web components')+chalk.white.dim(' | Almost there'),
|
||||
successText: chalk.white.bold('🟩🟩🟩⬜ Downloaded web components'),
|
||||
failText: chalk.white.bold(' ⚠️ Failed to download web components'),
|
||||
}
|
||||
)
|
||||
|
||||
// Initialize git repository
|
||||
await oraPromise(
|
||||
initGitRepo(config, choices),
|
||||
{
|
||||
text: chalk.white.bold('🟩🟩🟩⬜ Initializing git repository')+chalk.white.dim(' | You have git, right?'),
|
||||
successText: chalk.white.bold('🟩🟩🟩🟩 Initialized git repository'),
|
||||
failText: chalk.white.bold(' ⚠️ Failed to initialize git repository')+chalk.white.dim(' | This does not stop you from developing your design'),
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
//const handlebars = require('handlebars')
|
||||
//const execa = require('execa')
|
||||
//const fs = require('fs')
|
||||
//const globby = require('globby')
|
||||
//const normalize = require('normalize-path')
|
||||
//const mkdirp = require('make-dir')
|
||||
//const ora = require('ora')
|
||||
//const pEachSeries = require('p-each-series')
|
||||
|
||||
//const pkg = require('../package')
|
||||
/*
|
||||
const templateBlacklist = new Set([path.join('example', 'public', 'favicon.ico')])
|
||||
|
||||
module.exports = async (info) => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (git) {
|
||||
const promise = module.exports.initGitRepo({ dest })
|
||||
ora.promise(promise, 'Initializing git repo')
|
||||
await promise
|
||||
}
|
||||
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
module.exports.initGitRepo = async (opts) => {
|
||||
const { dest } = opts
|
||||
|
||||
const gitIgnorePath = path.join(dest, '.gitignore')
|
||||
fs.writeFileSync(
|
||||
gitIgnorePath,
|
||||
`
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# builds
|
||||
build
|
||||
dist
|
||||
.rpt2_cache
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
`,
|
||||
'utf8'
|
||||
)
|
||||
|
||||
const cmd = `git init && git add . && git commit -m ":tada: Initialized ${pkg.name}@${pkg.version} with create-freesewing-pattern"`
|
||||
return execa.sync(cmd, { cwd: dest, shell: true })
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue