Version: 0.3.0
Last Updated: Unknown
Requires name.
1#!/usr/bin/env node2const path = require('path');3const fs = require('fs');4const dir = __dirname;5const cwd = process.cwd();6const map = JSON.parse(7 fs.readFileSync(path.resolve(dir, './map.json'), 'utf-8'),8);910let filesErr = [];1112const build = ({ dependencies, data, file, output, basedir }) => {13 dependencies.ejs.renderFile(file, data, {}, function (err, str) {14 // str => Rendered HTML string15 if (err) {16 filesErr.push(output);17 throw err;18 }1920 const outputFilePath = `${basedir}/${output}`;21 dependencies.fs.outputFileSync(outputFilePath, str);22 });23};2425module.exports = async function (options) {26 console.log('Bridging Atom for Schematics');27 try {28 // prompts for questions29 const questions = [30 {31 type: 'text',32 name: 'name',33 message: 'What is the name of the new schematic?',34 },35 ];36 const prompts = await options.dependencies.prompts(questions);3738 const files = await options.dependencies.recursiveReaddir(dir, ['!*.ejs']);39 const basedir = options.data.basedir40 ? path.resolve(cwd, options.data.basedir, prompts.name)41 : path.resolve(cwd, '.schematics/modules', prompts.name);4243 options.data = {44 ...options.data,45 ...prompts,46 };4748 for (const file of files) {49 let filepath = file.replace(dir + '/', '');50 console.log(`\t - Scaffolding: ${filepath}`);51 build({ ...options, ...prompts, file, output: map[filepath], basedir });52 }5354 return options;55 } catch (err) {56 console.error(err);57 }58};
1const { pipe } = require('../../util/pipe');23const example = ({ kratos }) =>4 kratos({5 type: 'test',6 pkg: 'base',7 })();89const <%= name %> = pipe(10 example,11);1213module.exports = {14 <%= name %>,15};
1{2 "index.js.ejs": "index.js"3}