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 type: 'select',37 name: 'tier',38 message: 'What tier schematic is this?',39 choices: [40 { title: 'atoms', value: 'atoms' },41 { title: 'molecules', value: 'molecules' },42 { title: 'organisms', value: 'organisms' },43 { title: 'templates', value: 'templates' },44 ],45 },46 ];47 const prompts = await options.dependencies.prompts(questions);4849 const files = await options.dependencies.recursiveReaddir(dir, ['!*.ejs']);50 const basedir = options.data.basedir51 ? path.resolve(cwd, options.data.basedir, prompts.name)52 : path.resolve(cwd, `.schematics/${prompts.tier}`, prompts.name);5354 options.data = {55 ...options.data,56 ...prompts,57 };5859 for (const file of files) {60 let filepath = file.replace(dir + '/', '');61 console.log(`\t - Scaffolding: ${filepath}`);62 build({ ...options, ...prompts, file, output: map[filepath], basedir });63 }6465 return options;66 } catch (err) {67 console.error(err);68 }69};
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}