Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async copyScaffold() {
const { proName, proPath, projectLanguage, frameworkType, usePrecommit, cssinjs } = this.options
const extraOptions = {
year: utils.getYear(),
}
const allOptions = _.merge(this.options, extraOptions)
const scaffoldType = {
FrameworkType: frameworkType,
Language: projectLanguage,
}
// 内存管理
const store = memFs.create()
const fsEditor = editor.create(store)
const globOptions = {
globOptions: {
dot: true,
},
}
// 拷贝脚手架
fsEditor.copyTpl(utils.getScaffoldPath(scaffoldType), proPath, allOptions, {}, globOptions)
fsEditor.copyTpl(utils.getCommonPath('LICENSE', this.options.license), proPath, allOptions)
fsEditor.copyTpl(utils.getCommonPath('readme'), proPath, allOptions)
fsEditor.copyTpl(utils.getCommonPath('setup'), proPath, allOptions)
* processFiles(targetDir, templateDir) {
// const src = path.join(templateDir, 'boilerplate');
const src = path.join(templateDir);
const locals = {};
const fsEditor = editor.create(memFs.create());
const files = glob.sync('**/*', { cwd: src, dot: true, nodir: true });
for (const file of files) {
const from = path.join(src, file);
const to = path.join(
targetDir,
this.replaceTemplate(this.fileMapping[file] || file, locals)
);
fsEditor.copy(from, to, {
process: (content) => {
this.log('write to:%s', to);
return this.replaceTemplate(content, locals);
},
});
}
// write boilerplate base info to dist pkg info
beforeEach(() => {
store = memFs.create();
fs = editor.create(store);
});
beforeEach(() => {
store = memFs.create();
fs = editor.create(store);
});
beforeEach(() => {
store = memFs.create();
fs = editor.create(store);
});
function init({ es6 = false, seedersFolder = 'seeders' }) {
const store = memFs.create();
const fs = editor.create(store);
_writeUserGeneratorConfig();
_writeUserConfig();
_createSeedersFolder();
function _writeUserGeneratorConfig() {
const {
projectRoot,
userGeneratorConfigExists,
userGeneratorConfigFilename,
userGeneratorConfigFilepath,
} = config;
const generatorConfig = { es6, seedersFolder };
const debug = require('debug')('choo-cli:utils')
const store = require('mem-fs').create()
const xfs = require('mem-fs-editor').create(store)
const { kebabCase, camelCase } = require('lodash')
const { parse } = require('espree')
const exec = require('./exec')
const path = require('path')
const once = require('ramda').once
const walkBack = require('walk-back')
const chalk = require('chalk')
const delim = (require('os').platform() === 'win32') ? '\\' : '/'
const message = msg => console.log(msg)
const cwd = process.cwd()
const resolvePath = path.resolve
const newProjectPath = (projectName) => (dir) => resolvePath(cwd, projectName, dir || '')
const findConfig = once(() => walkBack(process.cwd(), 'choo.yaml'))
const findRootPath = once(() => {
constructor(options = {sourceDirectory: join(__dirname, 'templates')}) {
const {sourceDirectory} = options;
const targetDirectory = './';
const fs = editor.create(memFs.create());
const queue = new Queue({concurrency: 1});
assign(this, {fs, queue, sourceDirectory, targetDirectory});
}
/**
return __awaiter(this, void 0, void 0, function* () {
const { proName, proPath, projectLanguage, frameworkType, usePrecommit, cssinjs } = this.options;
const extraOptions = {
year: index_1.default.getYear(),
};
const allOptions = _.merge(this.options, extraOptions);
const scaffoldType = {
FrameworkType: frameworkType,
Language: projectLanguage,
};
const store = memFs.create();
const fsEditor = editor.create(store);
const globOptions = {
globOptions: {
dot: true,
},
};
fsEditor.copyTpl(index_1.default.getScaffoldPath(scaffoldType), proPath, allOptions, {}, globOptions);
fsEditor.copyTpl(index_1.default.getCommonPath('LICENSE', this.options.license), proPath, allOptions);
fsEditor.copyTpl(index_1.default.getCommonPath('readme'), proPath, allOptions);
fsEditor.copyTpl(index_1.default.getCommonPath('setup'), proPath, allOptions);
if (!cssinjs) {
fsEditor.copyTpl(index_1.default.getCommonPath('css'), `${proPath}/src/`, allOptions);
}
if (this.options.useCommitlint) {
fsEditor.copyTpl(index_1.default.getCommonPath('commitlint'), proPath, {}, {}, globOptions);
}