diff --git a/dist/cmd.js b/dist/cmd.js index 4639b91..07b21d4 100755 --- a/dist/cmd.js +++ b/dist/cmd.js @@ -1,3 +1,333 @@ #!/usr/bin/env node -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.library=t():e.library=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t){e.exports=require("path")},function(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(s=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(i,n[1])).done)return s;switch(i=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]=0&&(u=o.slice(0,c-1)),l=0,f=a,r.label=2;case 2:return l=0&&(i=e.slice(o+t.length+1)),n=r+i}return this.parseLocals(n)},e.prototype.writeFile=function(e,t){o.existsSync(i.dirname(e))||o.mkdirSync(i.dirname(e)),console.info("Writing file:",e),o.writeFileSync(e,t,{encoding:"utf-8"})},e.prototype.run=function(){console.log("Generating scaffold: "+this.config.name+"...");for(var e,t=this.fileList(this.config.templates),n=0;e=t.next().value;){n++;var r=e.file,o=e.base,i=this.getOutputPath(r,o),s=this.getFileContents(r),a=this.parseLocals(s);this.writeFile(i,a),console.info("Parsing:",{file:r,base:o,outputPath:i,outputContents:a.replace("\n","\\n")})}if(!n)throw new Error("No files to scaffold!");console.log("Done")},e}();t.default=c},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("glob")},function(e,t){e.exports=require("handlebars")},,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=process.argv.slice(2);(new(function(){function e(){this.config=this.getOptionsFromArgs()}return e.prototype.getOptionsFromArgs=function(){var e=this,t=!1,n={};if(o.forEach(function(r,i){if(t)return void(t=!1);if("--"==r.slice(0,2)){t=!0;var s=void 0;s=r.indexOf("=")>=0?r.split("=").slice(1).join(""):o.length>=i+1&&o[i+1]&&"--"!==o[i+1].slice(0,2)?o[i+1]:"true";var a=r.slice(2);n[a]=e.getArgValue(a,s,n)}else{if(n.name)throw new TypeError("Invalid argument: "+r);n.name=r}}),!["name","templates","output"].every(function(e){return void 0!==n[e]}))throw new Error("Config is missing keys: "+JSON.stringify(n));return n},e.prototype.getArgValue=function(e,t,n){switch(e){case"templates":return(n.templates||[]).concat([t]);case"output":return t;case"locals":for(var r=t.split(","),o=n.locals||{},i=0,s=r;i 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __webpack_require__(2); +var path = __webpack_require__(0); +var glob = __webpack_require__(3); +var handlebars = __webpack_require__(4); +var SimpleScaffold = /** @class */ (function () { + function SimpleScaffold(config) { + this.locals = {}; + var DefaultConfig = { + name: 'scaffold', + templates: [], + output: process.cwd(), + }; + this.config = Object.assign({}, DefaultConfig, config); + var DefaultLocals = { + Name: this.config.name[0].toUpperCase() + this.config.name.slice(1), + name: this.config.name[0].toLowerCase() + this.config.name.slice(1) + }; + this.locals = Object.assign({}, DefaultLocals, config.locals); + } + SimpleScaffold.prototype.parseLocals = function (text) { + var template = handlebars.compile(text, { + noEscape: true + }); + return template(this.locals); + }; + SimpleScaffold.prototype.fileList = function (input) { + var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _i = 0, input_1 = input; + _b.label = 1; + case 1: + if (!(_i < input_1.length)) return [3 /*break*/, 6]; + checkPath = input_1[_i]; + files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); }); + idx = checkPath.indexOf('*'); + cleanCheckPath = checkPath; + if (idx >= 0) { + cleanCheckPath = checkPath.slice(0, idx - 1); + } + _a = 0, files_1 = files; + _b.label = 2; + case 2: + if (!(_a < files_1.length)) return [3 /*break*/, 5]; + file = files_1[_a]; + return [4 /*yield*/, { base: cleanCheckPath, file: file }]; + case 3: + _b.sent(); + _b.label = 4; + case 4: + _a++; + return [3 /*break*/, 2]; + case 5: + _i++; + return [3 /*break*/, 1]; + case 6: return [2 /*return*/]; + } + }); + }; + SimpleScaffold.prototype.getFileContents = function (filePath) { + return fs.readFileSync(filePath).toString(); + }; + SimpleScaffold.prototype.getOutputPath = function (file, basePath) { + var out; + if (typeof this.config.output === 'function') { + out = this.config.output(file, basePath); + } + else { + var outputDir = this.config.output + ("/" + this.config.name + "/"); + var idx = file.indexOf(basePath); + var relativeFilePath = file; + if (idx >= 0) { + relativeFilePath = file.slice(idx + basePath.length + 1); + } + out = outputDir + relativeFilePath; + } + return this.parseLocals(out); + }; + SimpleScaffold.prototype.writeFile = function (filePath, fileContents) { + if (!fs.existsSync(path.dirname(filePath))) { + fs.mkdirSync(path.dirname(filePath)); + } + console.info('Writing file:', filePath); + fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' }); + }; + SimpleScaffold.prototype.run = function () { + console.log("Generating scaffold: " + this.config.name + "..."); + var templates = this.fileList(this.config.templates); + var fileConf, count = 0; + while (fileConf = templates.next().value) { + count++; + var file = fileConf.file, base = fileConf.base; + var outputPath = this.getOutputPath(file, base); + var contents = this.getFileContents(file); + var outputContents = this.parseLocals(contents); + this.writeFile(outputPath, outputContents); + console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace("\n", "\\n") }); + } + if (!count) { + throw new Error('No files to scaffold!'); + } + console.log('Done'); + }; + return SimpleScaffold; +}()); +exports.default = SimpleScaffold; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +module.exports = require("fs"); + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + +module.exports = require("glob"); + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +module.exports = require("handlebars"); + +/***/ }), +/* 5 */, +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var scaffold_1 = __webpack_require__(1); +var args = process.argv.slice(2); +var ScaffoldCmd = /** @class */ (function () { + function ScaffoldCmd() { + this.config = this.getOptionsFromArgs(); + } + ScaffoldCmd.prototype.getOptionsFromArgs = function () { + var _this = this; + var skipNext = false; + var options = {}; + args.forEach(function (arg, i) { + if (skipNext) { + skipNext = false; + return; + } + if (arg.slice(0, 2) == '--') { + skipNext = true; + var value = void 0; + if (arg.indexOf('=') >= 0) { + value = arg.split('=').slice(1).join(''); + } + else if (args.length >= i + 1 && args[i + 1] && args[i + 1].slice(0, 2) !== '--') { + value = args[i + 1]; + } + else { + value = 'true'; + } + var argName = arg.slice(2); + options[argName] = _this.getArgValue(argName, value, options); + } + else { + if (!options.name) { + options.name = arg; + } + else { + throw new TypeError("Invalid argument: " + arg); + } + } + }); + if (!['name', 'templates', 'output'].every(function (o) { return options[o] !== undefined; })) { + throw new Error("Config is missing keys: " + JSON.stringify(options)); + } + return options; + }; + ScaffoldCmd.prototype.getArgValue = function (arg, value, options) { + switch (arg) { + case 'templates': + return (options.templates || []).concat([value]); + case 'output': + return value; + case 'locals': + var split = value.split(','); + var locals = options.locals || {}; + for (var _i = 0, split_1 = split; _i < split_1.length; _i++) { + var item = split_1[_i]; + var _a = item.split('='), k = _a[0], v = _a[1]; + locals[k] = v; + } + return locals; + default: + throw TypeError("arguments invalid for config: arg=`" + arg + "`, value=`" + value + "`"); + } + }; + ScaffoldCmd.prototype.run = function () { + var config = this.config; + console.info('Config:', config); + var scf = new scaffold_1.default({ + name: config.name, + templates: config.templates, + output: config.output, + locals: config.locals, + }).run(); + }; + return ScaffoldCmd; +}()); +new ScaffoldCmd().run(); + + +/***/ }) +/******/ ]); +}); //# sourceMappingURL=cmd.js.map \ No newline at end of file diff --git a/dist/cmd.js.map b/dist/cmd.js.map index 601f44a..9267ce4 100755 --- a/dist/cmd.js.map +++ b/dist/cmd.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack/universalModuleDefinition","cmd.js","webpack/bootstrap ca74b8fede9900e58df9","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\"","/Users/chenasraf/Dev/simple-scaffold/cmd.ts"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","require","__generator","thisArg","body","verb","v","step","op","f","TypeError","_","y","t","done","value","label","ops","pop","trys","length","push","e","g","sent","next","throw","return","Symbol","iterator","fs","path","glob","handlebars","SimpleScaffold","config","locals","DefaultConfig","templates","output","process","cwd","assign","DefaultLocals","Name","toUpperCase","slice","toLowerCase","parseLocals","text","compile","noEscape","fileList","input","_i","input_1","checkPath","files","idx","cleanCheckPath","_a","files_1","file","_b","sync","map","join","indexOf","base","getFileContents","filePath","readFileSync","toString","getOutputPath","basePath","out","outputDir","relativeFilePath","writeFile","fileContents","existsSync","dirname","mkdirSync","console","info","writeFileSync","encoding","run","log","fileConf","count","outputPath","contents","outputContents","replace","Error","default","scaffold_1","args","argv","ScaffoldCmd","getOptionsFromArgs","_this","skipNext","options","forEach","arg","split","argName","getArgValue","every","undefined","JSON","stringify","concat","split_1","item","k"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,QAAAD,IAEAD,EAAA,QAAAC,KACCK,KAAA,WACD,MCCgB,UAAUC,GCP1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAV,EAAAiB,EAAA,SAAAtB,GACA,GAAAe,GAAAf,KAAAuB,WACA,WAA2B,MAAAvB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDpB,EAAAuB,EAAA,GAGAvB,IAAAwB,EAAA,KDiBM,SAA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AGtD,EAAAsD,EAAA,EACVxB,GAAOiF,GAAK/G,EAEd,MAAO8B,EACT,SACE,KAAM1B,WAAU,sCAAuCgG,EAAG,aAAe3F,EAAK,OAI7EqF,EAAAvG,UAAA0F,IAAP,WACE,GAAMpD,GAA4B7D,KAAK6D,MACvCgD,SAAQC,KAAK,UAAWjD,EAEZ,IAAI8D,GAAAD,SACd/G,KAAMkD,EAAOlD,KACbqD,UAAWH,EAAOG,UAClBC,OAAQJ,EAAOI,OACfH,OAAQD,EAAOC,SACdmD,OAEPa,OAEkBb","file":"cmd.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","#!/usr/bin/env node\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 6);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"path\");\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar fs = __webpack_require__(2);\nvar path = __webpack_require__(0);\nvar glob = __webpack_require__(3);\nvar handlebars = __webpack_require__(4);\nvar SimpleScaffold = /** @class */ (function () {\n function SimpleScaffold(config) {\n this.locals = {};\n var DefaultConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n };\n this.config = Object.assign({}, DefaultConfig, config);\n var DefaultLocals = {\n Name: this.config.name[0].toUpperCase() + this.config.name.slice(1),\n name: this.config.name[0].toLowerCase() + this.config.name.slice(1)\n };\n this.locals = Object.assign({}, DefaultLocals, config.locals);\n }\n SimpleScaffold.prototype.parseLocals = function (text) {\n var template = handlebars.compile(text, {\n noEscape: true\n });\n return template(this.locals);\n };\n SimpleScaffold.prototype.fileList = function (input) {\n var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _i = 0, input_1 = input;\n _b.label = 1;\n case 1:\n if (!(_i < input_1.length)) return [3 /*break*/, 6];\n checkPath = input_1[_i];\n files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); });\n idx = checkPath.indexOf('*');\n cleanCheckPath = checkPath;\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1);\n }\n _a = 0, files_1 = files;\n _b.label = 2;\n case 2:\n if (!(_a < files_1.length)) return [3 /*break*/, 5];\n file = files_1[_a];\n return [4 /*yield*/, { base: cleanCheckPath, file: file }];\n case 3:\n _b.sent();\n _b.label = 4;\n case 4:\n _a++;\n return [3 /*break*/, 2];\n case 5:\n _i++;\n return [3 /*break*/, 1];\n case 6: return [2 /*return*/];\n }\n });\n };\n SimpleScaffold.prototype.getFileContents = function (filePath) {\n return fs.readFileSync(filePath).toString();\n };\n SimpleScaffold.prototype.getOutputPath = function (file, basePath) {\n var out;\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath);\n }\n else {\n var outputDir = this.config.output + (\"/\" + this.config.name + \"/\");\n var idx = file.indexOf(basePath);\n var relativeFilePath = file;\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1);\n }\n out = outputDir + relativeFilePath;\n }\n return this.parseLocals(out);\n };\n SimpleScaffold.prototype.writeFile = function (filePath, fileContents) {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath));\n }\n console.info('Writing file:', filePath);\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' });\n };\n SimpleScaffold.prototype.run = function () {\n console.log(\"Generating scaffold: \" + this.config.name + \"...\");\n var templates = this.fileList(this.config.templates);\n var fileConf, count = 0;\n while (fileConf = templates.next().value) {\n count++;\n var file = fileConf.file, base = fileConf.base;\n var outputPath = this.getOutputPath(file, base);\n var contents = this.getFileContents(file);\n var outputContents = this.parseLocals(contents);\n this.writeFile(outputPath, outputContents);\n console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\") });\n }\n if (!count) {\n throw new Error('No files to scaffold!');\n }\n console.log('Done');\n };\n return SimpleScaffold;\n}());\nexports.default = SimpleScaffold;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"fs\");\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"glob\");\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"handlebars\");\n\n/***/ }),\n/* 5 */,\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar scaffold_1 = __webpack_require__(1);\nvar args = process.argv.slice(2);\nvar ScaffoldCmd = /** @class */ (function () {\n function ScaffoldCmd() {\n this.config = this.getOptionsFromArgs();\n }\n ScaffoldCmd.prototype.getOptionsFromArgs = function () {\n var _this = this;\n var skipNext = false;\n var options = {};\n args.forEach(function (arg, i) {\n if (skipNext) {\n skipNext = false;\n return;\n }\n if (arg.slice(0, 2) == '--') {\n skipNext = true;\n var value = void 0;\n if (arg.indexOf('=') >= 0) {\n value = arg.split('=').slice(1).join('');\n }\n else if (args.length >= i + 1 && args[i + 1] && args[i + 1].slice(0, 2) !== '--') {\n value = args[i + 1];\n }\n else {\n value = 'true';\n }\n var argName = arg.slice(2);\n options[argName] = _this.getArgValue(argName, value, options);\n }\n else {\n if (!options.name) {\n options.name = arg;\n }\n else {\n throw new TypeError(\"Invalid argument: \" + arg);\n }\n }\n });\n if (!['name', 'templates', 'output'].every(function (o) { return options[o] !== undefined; })) {\n throw new Error(\"Config is missing keys: \" + JSON.stringify(options));\n }\n return options;\n };\n ScaffoldCmd.prototype.getArgValue = function (arg, value, options) {\n switch (arg) {\n case 'templates':\n return (options.templates || []).concat([value]);\n case 'output':\n return value;\n case 'locals':\n var split = value.split(',');\n var locals = options.locals || {};\n for (var _i = 0, split_1 = split; _i < split_1.length; _i++) {\n var item = split_1[_i];\n var _a = item.split('='), k = _a[0], v = _a[1];\n locals[k] = v;\n }\n return locals;\n default:\n throw TypeError(\"arguments invalid for config: arg=`\" + arg + \"`, value=`\" + value + \"`\");\n }\n };\n ScaffoldCmd.prototype.run = function () {\n var config = this.config;\n console.info('Config:', config);\n var scf = new scaffold_1.default({\n name: config.name,\n templates: config.templates,\n output: config.output,\n locals: config.locals,\n }).run();\n };\n return ScaffoldCmd;\n}());\nnew ScaffoldCmd().run();\n\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// cmd.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ca74b8fede9900e58df9","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2","import SimpleScaffold from './scaffold'\nimport * as fs from 'fs'\nimport IScaffold from './index'\n\nconst args = process.argv.slice(2)\n\nclass ScaffoldCmd {\n private config: IScaffold.IConfig\n\n constructor() {\n this.config = this.getOptionsFromArgs()\n }\n\n private getOptionsFromArgs(): IScaffold.IConfig {\n let skipNext = false\n const options = {} as any\n\n args.forEach((arg, i) => {\n if (skipNext) {\n skipNext = false\n return\n }\n\n if (arg.slice(0, 2) == '--') {\n skipNext = true\n let value: string\n\n if (arg.indexOf('=') >= 0) {\n value = arg.split('=').slice(1).join('')\n } else if (args.length >= i + 1 && args[i + 1] && args[i + 1].slice(0, 2) !== '--') {\n value = args[i + 1]\n } else {\n value = 'true'\n }\n\n const argName = arg.slice(2)\n options[argName] = this.getArgValue(argName, value, options)\n } else {\n if (!options.name) {\n options.name = arg\n } else {\n throw new TypeError(`Invalid argument: ${arg}`)\n }\n }\n })\n\n if (!['name', 'templates', 'output'].every(o => options[o] !== undefined)) {\n throw new Error(`Config is missing keys: ${JSON.stringify(options)}`)\n }\n\n return options\n }\n\n private getArgValue(arg: string, value: string, options: IScaffold.IConfig) {\n switch (arg) {\n case 'templates':\n return (options.templates || []).concat([value])\n case 'output':\n return value\n case 'locals':\n const split = value.split(',')\n const locals = options.locals || {}\n for (const item of split) {\n const [k, v] = item.split('=')\n locals[k] = v\n }\n return locals\n default:\n throw TypeError(`arguments invalid for config: arg=\\`${arg}\\`, value=\\`${value}\\``)\n }\n }\n\n public run() {\n const config: IScaffold.IConfig = this.config\n console.info('Config:', config)\n\n const scf = new SimpleScaffold({\n name: config.name,\n templates: config.templates,\n output: config.output,\n locals: config.locals,\n }).run()\n }\n}\n\nnew ScaffoldCmd().run()\n\n\n\n// WEBPACK FOOTER //\n// ./cmd.ts"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack/universalModuleDefinition","webpack/bootstrap aa389e77d7fdb41199f3","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\"","/Users/chenasraf/Dev/simple-scaffold/cmd.ts"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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Content":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap aa389e77d7fdb41199f3","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2","import SimpleScaffold from './scaffold'\nimport * as fs from 'fs'\nimport IScaffold from './index'\n\nconst args = process.argv.slice(2)\n\nclass ScaffoldCmd {\n private config: IScaffold.IConfig\n\n constructor() {\n this.config = this.getOptionsFromArgs()\n }\n\n private getOptionsFromArgs(): IScaffold.IConfig {\n let skipNext = false\n const options = {} as any\n\n args.forEach((arg, i) => {\n if (skipNext) {\n skipNext = false\n return\n }\n\n if (arg.slice(0, 2) == '--') {\n skipNext = true\n let value: string\n\n if (arg.indexOf('=') >= 0) {\n value = arg.split('=').slice(1).join('')\n } else if (args.length >= i + 1 && args[i + 1] && args[i + 1].slice(0, 2) !== '--') {\n value = args[i + 1]\n } else {\n value = 'true'\n }\n\n const argName = arg.slice(2)\n options[argName] = this.getArgValue(argName, value, options)\n } else {\n if (!options.name) {\n options.name = arg\n } else {\n throw new TypeError(`Invalid argument: ${arg}`)\n }\n }\n })\n\n if (!['name', 'templates', 'output'].every(o => options[o] !== undefined)) {\n throw new Error(`Config is missing keys: ${JSON.stringify(options)}`)\n }\n\n return options\n }\n\n private getArgValue(arg: string, value: string, options: IScaffold.IConfig) {\n switch (arg) {\n case 'templates':\n return (options.templates || []).concat([value])\n case 'output':\n return value\n case 'locals':\n const split = value.split(',')\n const locals = options.locals || {}\n for (const item of split) {\n const [k, v] = item.split('=')\n locals[k] = v\n }\n return locals\n default:\n throw TypeError(`arguments invalid for config: arg=\\`${arg}\\`, value=\\`${value}\\``)\n }\n }\n\n public run() {\n const config: IScaffold.IConfig = this.config\n console.info('Config:', config)\n\n const scf = new SimpleScaffold({\n name: config.name,\n templates: config.templates,\n output: config.output,\n locals: config.locals,\n }).run()\n }\n}\n\nnew ScaffoldCmd().run()\n\n\n\n// WEBPACK FOOTER //\n// ./cmd.ts"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/main.js b/dist/main.js new file mode 100644 index 0000000..cf04983 --- /dev/null +++ b/dist/main.js @@ -0,0 +1,96 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["library"] = factory(); + else + root["library"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 7); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 7: +/***/ (function(module, exports, __webpack_require__) { + +(function webpackMissingModule() { throw new Error("Cannot find module \"add\""); }()); +module.exports = __webpack_require__(8); + + +/***/ }), + +/***/ 8: +/***/ (function(module, exports) { + +module.exports = require("jest"); + +/***/ }) + +/******/ }); +}); +//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/dist/main.js.map b/dist/main.js.map new file mode 100644 index 0000000..3fc02af --- /dev/null +++ b/dist/main.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack/universalModuleDefinition","webpack/bootstrap c994c2c400fa1fc61abe","external \"jest\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;AC7DA,iC","file":"main.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 7);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c994c2c400fa1fc61abe","module.exports = require(\"jest\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"jest\"\n// module id = 8\n// module chunks = 3"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/scaffold.js b/dist/scaffold.js index cb3930a..6b1e174 100755 --- a/dist/scaffold.js +++ b/dist/scaffold.js @@ -1,2 +1,246 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.library=t():e.library=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t){e.exports=require("path")},function(e,t,n){"use strict";var o=this&&this.__generator||function(e,t){function n(e){return function(t){return o([e,t])}}function o(n){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,i&&(s=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(i,n[1])).done)return s;switch(i=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]=0&&(u=r.slice(0,c-1)),l=0,f=a,o.label=2;case 2:return l=0&&(i=e.slice(r+t.length+1)),n=o+i}return this.parseLocals(n)},e.prototype.writeFile=function(e,t){r.existsSync(i.dirname(e))||r.mkdirSync(i.dirname(e)),console.info("Writing file:",e),r.writeFileSync(e,t,{encoding:"utf-8"})},e.prototype.run=function(){console.log("Generating scaffold: "+this.config.name+"...");for(var e,t=this.fileList(this.config.templates),n=0;e=t.next().value;){n++;var o=e.file,r=e.base,i=this.getOutputPath(o,r),s=this.getFileContents(o),a=this.parseLocals(s);this.writeFile(i,a),console.info("Parsing:",{file:o,base:r,outputPath:i,outputContents:a.replace("\n","\\n")})}if(!n)throw new Error("No files to scaffold!");console.log("Done")},e}();t.default=c},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("glob")},function(e,t){e.exports=require("handlebars")}])}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["library"] = factory(); + else + root["library"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +module.exports = require("path"); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __webpack_require__(2); +var path = __webpack_require__(0); +var glob = __webpack_require__(3); +var handlebars = __webpack_require__(4); +var SimpleScaffold = /** @class */ (function () { + function SimpleScaffold(config) { + this.locals = {}; + var DefaultConfig = { + name: 'scaffold', + templates: [], + output: process.cwd(), + }; + this.config = Object.assign({}, DefaultConfig, config); + var DefaultLocals = { + Name: this.config.name[0].toUpperCase() + this.config.name.slice(1), + name: this.config.name[0].toLowerCase() + this.config.name.slice(1) + }; + this.locals = Object.assign({}, DefaultLocals, config.locals); + } + SimpleScaffold.prototype.parseLocals = function (text) { + var template = handlebars.compile(text, { + noEscape: true + }); + return template(this.locals); + }; + SimpleScaffold.prototype.fileList = function (input) { + var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _i = 0, input_1 = input; + _b.label = 1; + case 1: + if (!(_i < input_1.length)) return [3 /*break*/, 6]; + checkPath = input_1[_i]; + files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); }); + idx = checkPath.indexOf('*'); + cleanCheckPath = checkPath; + if (idx >= 0) { + cleanCheckPath = checkPath.slice(0, idx - 1); + } + _a = 0, files_1 = files; + _b.label = 2; + case 2: + if (!(_a < files_1.length)) return [3 /*break*/, 5]; + file = files_1[_a]; + return [4 /*yield*/, { base: cleanCheckPath, file: file }]; + case 3: + _b.sent(); + _b.label = 4; + case 4: + _a++; + return [3 /*break*/, 2]; + case 5: + _i++; + return [3 /*break*/, 1]; + case 6: return [2 /*return*/]; + } + }); + }; + SimpleScaffold.prototype.getFileContents = function (filePath) { + return fs.readFileSync(filePath).toString(); + }; + SimpleScaffold.prototype.getOutputPath = function (file, basePath) { + var out; + if (typeof this.config.output === 'function') { + out = this.config.output(file, basePath); + } + else { + var outputDir = this.config.output + ("/" + this.config.name + "/"); + var idx = file.indexOf(basePath); + var relativeFilePath = file; + if (idx >= 0) { + relativeFilePath = file.slice(idx + basePath.length + 1); + } + out = outputDir + relativeFilePath; + } + return this.parseLocals(out); + }; + SimpleScaffold.prototype.writeFile = function (filePath, fileContents) { + if (!fs.existsSync(path.dirname(filePath))) { + fs.mkdirSync(path.dirname(filePath)); + } + console.info('Writing file:', filePath); + fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' }); + }; + SimpleScaffold.prototype.run = function () { + console.log("Generating scaffold: " + this.config.name + "..."); + var templates = this.fileList(this.config.templates); + var fileConf, count = 0; + while (fileConf = templates.next().value) { + count++; + var file = fileConf.file, base = fileConf.base; + var outputPath = this.getOutputPath(file, base); + var contents = this.getFileContents(file); + var outputContents = this.parseLocals(contents); + this.writeFile(outputPath, outputContents); + console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace("\n", "\\n") }); + } + if (!count) { + throw new Error('No files to scaffold!'); + } + console.log('Done'); + }; + return SimpleScaffold; +}()); +exports.default = SimpleScaffold; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +module.exports = require("fs"); + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + +module.exports = require("glob"); + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +module.exports = require("handlebars"); + +/***/ }) +/******/ ]); +}); //# sourceMappingURL=scaffold.js.map \ No newline at end of file diff --git a/dist/scaffold.js.map b/dist/scaffold.js.map index bd0d1f6..b921115 100755 --- a/dist/scaffold.js.map +++ b/dist/scaffold.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack/universalModuleDefinition","scaffold.js","webpack/bootstrap ca74b8fede9900e58df9","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\""],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","require","__generator","thisArg","body","verb","v","step","op","f","TypeError","_","y","t","done","value","label","ops","pop","trys","length","push","e","g","sent","next","throw","return","Symbol","iterator","fs","path","glob","handlebars","SimpleScaffold","config","locals","DefaultConfig","templates","output","process","cwd","assign","DefaultLocals","Name","toUpperCase","slice","toLowerCase","parseLocals","text","compile","noEscape","fileList","input","_i","input_1","checkPath","files","idx","cleanCheckPath","_a","files_1","file","_b","sync","map","join","indexOf","base","getFileContents","filePath","readFileSync","toString","getOutputPath","basePath","out","outputDir","relativeFilePath","writeFile","fileContents","existsSync","dirname","mkdirSync","console","info","writeFileSync","encoding","run","log","fileConf","count","outputPath","contents","outputContents","replace","Error","default"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,QAAAD,IAEAD,EAAA,QAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,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arH,KAAKmG,cAAcX,EAAMM,GACtCwB,EAAWtH,KAAK+F,gBAAgBP,GAChC+B,EAAiBvH,KAAK0E,YAAY4C,EAExCtH,MAAKwG,UAAUa,EAAYE,GAC3BV,QAAQC,KAAK,YAAatB,KAAIA,EAAEM,KAAIA,EAAEuB,WAAUA,EAAEE,eAAgBA,EAAeC,QAAQ,KAAM,SAGjG,IAAKJ,EACH,KAAM,IAAIK,OAAM,wBAGlBZ,SAAQK,IAAI,SAEhBtD,IAEAhE,GAAA8H,QAAe9D,GH4HT,SAAU/D,EAAQD,GIlOxBC,EAAAD,QAAA+B,QAAA,OJwOM,SAAU9B,EAAQD,GKxOxBC,EAAAD,QAAA+B,QAAA,SL8OM,SAAU9B,EAAQD,GM9OxBC,EAAAD,QAAA+B,QAAA","file":"scaffold.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"path\");\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar fs = __webpack_require__(2);\nvar path = __webpack_require__(0);\nvar glob = __webpack_require__(3);\nvar handlebars = __webpack_require__(4);\nvar SimpleScaffold = /** @class */ (function () {\n function SimpleScaffold(config) {\n this.locals = {};\n var DefaultConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n };\n this.config = Object.assign({}, DefaultConfig, config);\n var DefaultLocals = {\n Name: this.config.name[0].toUpperCase() + this.config.name.slice(1),\n name: this.config.name[0].toLowerCase() + this.config.name.slice(1)\n };\n this.locals = Object.assign({}, DefaultLocals, config.locals);\n }\n SimpleScaffold.prototype.parseLocals = function (text) {\n var template = handlebars.compile(text, {\n noEscape: true\n });\n return template(this.locals);\n };\n SimpleScaffold.prototype.fileList = function (input) {\n var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _i = 0, input_1 = input;\n _b.label = 1;\n case 1:\n if (!(_i < input_1.length)) return [3 /*break*/, 6];\n checkPath = input_1[_i];\n files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); });\n idx = checkPath.indexOf('*');\n cleanCheckPath = checkPath;\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1);\n }\n _a = 0, files_1 = files;\n _b.label = 2;\n case 2:\n if (!(_a < files_1.length)) return [3 /*break*/, 5];\n file = files_1[_a];\n return [4 /*yield*/, { base: cleanCheckPath, file: file }];\n case 3:\n _b.sent();\n _b.label = 4;\n case 4:\n _a++;\n return [3 /*break*/, 2];\n case 5:\n _i++;\n return [3 /*break*/, 1];\n case 6: return [2 /*return*/];\n }\n });\n };\n SimpleScaffold.prototype.getFileContents = function (filePath) {\n return fs.readFileSync(filePath).toString();\n };\n SimpleScaffold.prototype.getOutputPath = function (file, basePath) {\n var out;\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath);\n }\n else {\n var outputDir = this.config.output + (\"/\" + this.config.name + \"/\");\n var idx = file.indexOf(basePath);\n var relativeFilePath = file;\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1);\n }\n out = outputDir + relativeFilePath;\n }\n return this.parseLocals(out);\n };\n SimpleScaffold.prototype.writeFile = function (filePath, fileContents) {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath));\n }\n console.info('Writing file:', filePath);\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' });\n };\n SimpleScaffold.prototype.run = function () {\n console.log(\"Generating scaffold: \" + this.config.name + \"...\");\n var templates = this.fileList(this.config.templates);\n var fileConf, count = 0;\n while (fileConf = templates.next().value) {\n count++;\n var file = fileConf.file, base = fileConf.base;\n var outputPath = this.getOutputPath(file, base);\n var contents = this.getFileContents(file);\n var outputContents = this.parseLocals(contents);\n this.writeFile(outputPath, outputContents);\n console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\") });\n }\n if (!count) {\n throw new Error('No files to scaffold!');\n }\n console.log('Done');\n };\n return SimpleScaffold;\n}());\nexports.default = SimpleScaffold;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"fs\");\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"glob\");\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"handlebars\");\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// scaffold.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ca74b8fede9900e58df9","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack/universalModuleDefinition","webpack/bootstrap aa389e77d7fdb41199f3","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;AC7DA,iC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,gCAAwB;AACxB,kCAA4B;AAE5B,kCAA4B;AAC5B,wCAAwC;AAExC;IAIE,wBAAY,MAAyB;QAF7B,WAAM,GAAG,EAAS;QAGxB,IAAM,aAAa,GAAsB;YACvC,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE;SACtB;QAED,IAAI,CAAC,MAAM,GAAI,MAAc,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC;QAE/D,IAAM,aAAa,GAAG;YACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,KAAK,CAAC,CAAC,CAAC;SACtE;QAED,IA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AC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAEtD,IAAI,QAAQ,EAAE,KAAK,GAAG,CAAC;QACvB,OAAO,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YACzC,KAAK,EAAE;YACA,wBAAI,EAAE,oBAAI,CAAY;YAC7B,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC;YACjD,IAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAC3C,IAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YAEjD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,cAAc,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAC,IAAI,QAAE,IAAI,QAAE,UAAU,cAAE,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAC,CAAC;QACzG,CAAC;QAED,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC;QAC1C,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IACrB,CAAC;IACH,qBAAC;AAAD,CAAC;AAED,kBAAe,cAAc;;;;;;;ACtG7B,+B;;;;;;ACAA,iC;;;;;;ACAA,uC","file":"scaffold.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap aa389e77d7fdb41199f3","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/test.js b/dist/test.js index 1443aae..5d334fb 100755 --- a/dist/test.js +++ b/dist/test.js @@ -1,2 +1,266 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.library=t():e.library=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t){e.exports=require("path")},function(e,t,n){"use strict";var o=this&&this.__generator||function(e,t){function n(e){return function(t){return o([e,t])}}function o(n){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,i&&(s=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(i,n[1])).done)return s;switch(i=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(s=u.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]=0&&(c=r.slice(0,u-1)),l=0,f=a,o.label=2;case 2:return l=0&&(i=e.slice(r+t.length+1)),n=o+i}return this.parseLocals(n)},e.prototype.writeFile=function(e,t){r.existsSync(i.dirname(e))||r.mkdirSync(i.dirname(e)),console.info("Writing file:",e),r.writeFileSync(e,t,{encoding:"utf-8"})},e.prototype.run=function(){console.log("Generating scaffold: "+this.config.name+"...");for(var e,t=this.fileList(this.config.templates),n=0;e=t.next().value;){n++;var o=e.file,r=e.base,i=this.getOutputPath(o,r),s=this.getFileContents(o),a=this.parseLocals(s);this.writeFile(i,a),console.info("Parsing:",{file:o,base:r,outputPath:i,outputContents:a.replace("\n","\\n")})}if(!n)throw new Error("No files to scaffold!");console.log("Done")},e}();t.default=u},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("glob")},function(e,t){e.exports=require("handlebars")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=n(0),i=r.join(process.cwd(),"examples");new o.default({templates:[i+"/test-input/Component/**/*"],output:i+"/test-output",locals:{property:"myProp",value:'"value"'}}).run()}])}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["library"] = factory(); + else + root["library"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 5); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +module.exports = require("path"); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __webpack_require__(2); +var path = __webpack_require__(0); +var glob = __webpack_require__(3); +var handlebars = __webpack_require__(4); +var SimpleScaffold = /** @class */ (function () { + function SimpleScaffold(config) { + this.locals = {}; + var DefaultConfig = { + name: 'scaffold', + templates: [], + output: process.cwd(), + }; + this.config = Object.assign({}, DefaultConfig, config); + var DefaultLocals = { + Name: this.config.name[0].toUpperCase() + this.config.name.slice(1), + name: this.config.name[0].toLowerCase() + this.config.name.slice(1) + }; + this.locals = Object.assign({}, DefaultLocals, config.locals); + } + SimpleScaffold.prototype.parseLocals = function (text) { + var template = handlebars.compile(text, { + noEscape: true + }); + return template(this.locals); + }; + SimpleScaffold.prototype.fileList = function (input) { + var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _i = 0, input_1 = input; + _b.label = 1; + case 1: + if (!(_i < input_1.length)) return [3 /*break*/, 6]; + checkPath = input_1[_i]; + files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); }); + idx = checkPath.indexOf('*'); + cleanCheckPath = checkPath; + if (idx >= 0) { + cleanCheckPath = checkPath.slice(0, idx - 1); + } + _a = 0, files_1 = files; + _b.label = 2; + case 2: + if (!(_a < files_1.length)) return [3 /*break*/, 5]; + file = files_1[_a]; + return [4 /*yield*/, { base: cleanCheckPath, file: file }]; + case 3: + _b.sent(); + _b.label = 4; + case 4: + _a++; + return [3 /*break*/, 2]; + case 5: + _i++; + return [3 /*break*/, 1]; + case 6: return [2 /*return*/]; + } + }); + }; + SimpleScaffold.prototype.getFileContents = function (filePath) { + return fs.readFileSync(filePath).toString(); + }; + SimpleScaffold.prototype.getOutputPath = function (file, basePath) { + var out; + if (typeof this.config.output === 'function') { + out = this.config.output(file, basePath); + } + else { + var outputDir = this.config.output + ("/" + this.config.name + "/"); + var idx = file.indexOf(basePath); + var relativeFilePath = file; + if (idx >= 0) { + relativeFilePath = file.slice(idx + basePath.length + 1); + } + out = outputDir + relativeFilePath; + } + return this.parseLocals(out); + }; + SimpleScaffold.prototype.writeFile = function (filePath, fileContents) { + if (!fs.existsSync(path.dirname(filePath))) { + fs.mkdirSync(path.dirname(filePath)); + } + console.info('Writing file:', filePath); + fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' }); + }; + SimpleScaffold.prototype.run = function () { + console.log("Generating scaffold: " + this.config.name + "..."); + var templates = this.fileList(this.config.templates); + var fileConf, count = 0; + while (fileConf = templates.next().value) { + count++; + var file = fileConf.file, base = fileConf.base; + var outputPath = this.getOutputPath(file, base); + var contents = this.getFileContents(file); + var outputContents = this.parseLocals(contents); + this.writeFile(outputPath, outputContents); + console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace("\n", "\\n") }); + } + if (!count) { + throw new Error('No files to scaffold!'); + } + console.log('Done'); + }; + return SimpleScaffold; +}()); +exports.default = SimpleScaffold; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +module.exports = require("fs"); + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + +module.exports = require("glob"); + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +module.exports = require("handlebars"); + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var scaffold_1 = __webpack_require__(1); +var path = __webpack_require__(0); +var templateDir = path.join(process.cwd(), 'examples'); +new scaffold_1.default({ + templates: [templateDir + '/test-input/Component/**/*'], + output: templateDir + '/test-output', + locals: { + property: 'myProp', + value: '"value"' + } +}).run(); + + +/***/ }) +/******/ ]); +}); //# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/dist/test.js.map b/dist/test.js.map index a7958e0..0b77b37 100755 --- a/dist/test.js.map +++ b/dist/test.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack/universalModuleDefinition","test.js","webpack/bootstrap ca74b8fede9900e58df9","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\"","/Users/chenasraf/Dev/simple-scaffold/test.ts"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","require","__generator","thisArg","body","verb","v","step","op","f","TypeError","_","y","t","done","value","label","ops","pop","trys","length","push","e","g","sent","next","throw","return","Symbol","iterator","fs","path","glob","handlebars","SimpleScaffold","config","locals","DefaultConfig","templates","output","process","cwd","assign","DefaultLocals","Name","toUpperCase","slice","toLowerCase","parseLocals","text","compile","noEscape","fileList","input","_i","input_1","checkPath","files","idx","cleanCheckPath","_a","files_1","file","_b","sync","map","join","indexOf","base","getFileContents","filePath","readFileSync","toString","getOutputPath","basePath","out","outputDir","relativeFilePath","writeFile","fileContents","existsSync","dirname","mkdirSync","console","info","writeFileSync","encoding","run","log","fileConf","count","outputPath","contents","outputContents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9BxC,EAAGuD,cAAcf,EAAUS,GAAgBO,SAAU,WAGhDpD,EAAArC,UAAA0F,IAAP,WACEJ,QAAQK,IAAI,wBAAwBlH,KAAK6D,OAAOlD,KAAI,MAIpD,KAHA,GAEIwG,GAFEnD,EAAYhE,KAAK8E,SAAS9E,KAAK6D,OAAOG,WAE9BoD,EAAQ,EACfD,EAAWnD,EAAUb,OAAOV,OAAO,CACxC2E,GACO,IAAA5B,GAAA2B,EAAA3B,KAAMM,EAAAqB,EAAArB,KACPuB,EAAarH,KAAKmG,cAAcX,EAAMM,GACtCwB,EAAWtH,KAAK+F,gBAAgBP,GAChC+B,EAAiBvH,KAAK0E,YAAY4C,EAExCtH,MAAKwG,UAAUa,EAAYE,GAC3BV,QAAQC,KAAK,YAAatB,KAAIA,EAAEM,KAAIA,EAAEuB,WAAUA,EAAEE,eAAgBA,EAAeC,QAAQ,KAAM,SAGjG,IAAKJ,EACH,KAAM,IAAIK,OAAM,wBAGlBZ,SAAQK,IAAI,SAEhBtD,IAEAhE,GAAA8H,QAAe9D,GH4HT,SAAU/D,EAAQD,GIlOxBC,EAAAD,QAAA+B,QAAA,OJwOM,SAAU9B,EAAQD,GKxOxBC,EAAAD,QAAA+B,QAAA,SL8OM,SAAU9B,EAAQD,GM9OxBC,EAAAD,QAAA+B,QAAA,eNoPM,SAAU9B,EAAQD,EAASM,GAEjC,YAEAY,QAAOC,eAAenB,EAAS,cAAgB6C,OAAO,GOxPtD,IAAAkF,GAAAzH,EAAA,GACAuD,EAAAvD,EAAA,GAEM0H,EAAcnE,EAAKmC,KAAK1B,QAAQC,MAAO,WAE7C,IAAIwD,GAAAD,SACF1D,WAAY4D,EAAc,8BAC1B3D,OAAQ2D,EAAc,eACtB9D,QACExC,SAAU,SACVmB,MAAO,aAERwE","file":"test.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 5);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"path\");\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar fs = __webpack_require__(2);\nvar path = __webpack_require__(0);\nvar glob = __webpack_require__(3);\nvar handlebars = __webpack_require__(4);\nvar SimpleScaffold = /** @class */ (function () {\n function SimpleScaffold(config) {\n this.locals = {};\n var DefaultConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n };\n this.config = Object.assign({}, DefaultConfig, config);\n var DefaultLocals = {\n Name: this.config.name[0].toUpperCase() + this.config.name.slice(1),\n name: this.config.name[0].toLowerCase() + this.config.name.slice(1)\n };\n this.locals = Object.assign({}, DefaultLocals, config.locals);\n }\n SimpleScaffold.prototype.parseLocals = function (text) {\n var template = handlebars.compile(text, {\n noEscape: true\n });\n return template(this.locals);\n };\n SimpleScaffold.prototype.fileList = function (input) {\n var _i, input_1, checkPath, files, idx, cleanCheckPath, _a, files_1, file;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _i = 0, input_1 = input;\n _b.label = 1;\n case 1:\n if (!(_i < input_1.length)) return [3 /*break*/, 6];\n checkPath = input_1[_i];\n files = glob.sync(checkPath).map(function (g) { return g[0] == '/' ? g : path.join(process.cwd(), g); });\n idx = checkPath.indexOf('*');\n cleanCheckPath = checkPath;\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1);\n }\n _a = 0, files_1 = files;\n _b.label = 2;\n case 2:\n if (!(_a < files_1.length)) return [3 /*break*/, 5];\n file = files_1[_a];\n return [4 /*yield*/, { base: cleanCheckPath, file: file }];\n case 3:\n _b.sent();\n _b.label = 4;\n case 4:\n _a++;\n return [3 /*break*/, 2];\n case 5:\n _i++;\n return [3 /*break*/, 1];\n case 6: return [2 /*return*/];\n }\n });\n };\n SimpleScaffold.prototype.getFileContents = function (filePath) {\n return fs.readFileSync(filePath).toString();\n };\n SimpleScaffold.prototype.getOutputPath = function (file, basePath) {\n var out;\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath);\n }\n else {\n var outputDir = this.config.output + (\"/\" + this.config.name + \"/\");\n var idx = file.indexOf(basePath);\n var relativeFilePath = file;\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1);\n }\n out = outputDir + relativeFilePath;\n }\n return this.parseLocals(out);\n };\n SimpleScaffold.prototype.writeFile = function (filePath, fileContents) {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath));\n }\n console.info('Writing file:', filePath);\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' });\n };\n SimpleScaffold.prototype.run = function () {\n console.log(\"Generating scaffold: \" + this.config.name + \"...\");\n var templates = this.fileList(this.config.templates);\n var fileConf, count = 0;\n while (fileConf = templates.next().value) {\n count++;\n var file = fileConf.file, base = fileConf.base;\n var outputPath = this.getOutputPath(file, base);\n var contents = this.getFileContents(file);\n var outputContents = this.parseLocals(contents);\n this.writeFile(outputPath, outputContents);\n console.info('Parsing:', { file: file, base: base, outputPath: outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\") });\n }\n if (!count) {\n throw new Error('No files to scaffold!');\n }\n console.log('Done');\n };\n return SimpleScaffold;\n}());\nexports.default = SimpleScaffold;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"fs\");\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"glob\");\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"handlebars\");\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar scaffold_1 = __webpack_require__(1);\nvar path = __webpack_require__(0);\nvar templateDir = path.join(process.cwd(), 'examples');\nnew scaffold_1.default({\n templates: [templateDir + '/test-input/Component/**/*'],\n output: templateDir + '/test-output',\n locals: {\n property: 'myProp',\n value: '\"value\"'\n }\n}).run();\n\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// test.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ca74b8fede9900e58df9","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2","import SimpleScaffold from './scaffold'\nimport * as path from 'path'\n\nconst templateDir = path.join(process.cwd(), 'examples')\n\nnew SimpleScaffold({\n templates: [templateDir + '/test-input/Component/**/*'],\n output: templateDir + '/test-output',\n locals: {\n property: 'myProp',\n value: '\"value\"'\n }\n}).run()\n\n\n\n// WEBPACK FOOTER //\n// ./test.ts"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack/universalModuleDefinition","webpack/bootstrap aa389e77d7fdb41199f3","external \"path\"","/Users/chenasraf/Dev/simple-scaffold/scaffold.ts","external \"fs\"","external \"glob\"","external \"handlebars\"","/Users/chenasraf/Dev/simple-scaff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C;QACvB,OAAO,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YACzC,KAAK,EAAE;YACA,wBAAI,EAAE,oBAAI,CAAY;YAC7B,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC;YACjD,IAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAC3C,IAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YAEjD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,cAAc,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAC,IAAI,QAAE,IAAI,QAAE,UAAU,cAAE,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAC,CAAC;QACzG,CAAC;QAED,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC;QAC1C,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IACrB,CAAC;IACH,qBAAC;AAAD,CAAC;AAED,kBAAe,cAAc;;;;;;;ACtG7B,+B;;;;;;ACAA,iC;;;;;;ACAA,uC;;;;;;;;;ACAA,wCAAuC;AACvC,kCAA4B;AAE5B,IAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC;AAExD,IAAI,kBAAc,CAAC;IACjB,SAAS,EAAE,CAAC,WAAW,GAAG,4BAA4B,CAAC;IACvD,MAAM,EAAE,WAAW,GAAG,cAAc;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC,GAAG,EAAE","file":"test.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"library\"] = factory();\n\telse\n\t\troot[\"library\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap aa389e77d7fdb41199f3","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 0\n// module chunks = 0 1 2","import * as fs from 'fs'\nimport * as path from 'path'\nimport IScaffold from './index'\nimport * as glob from 'glob'\nimport * as handlebars from 'handlebars'\n\nclass SimpleScaffold {\n private config: IScaffold.IConfig\n private locals = {} as any\n\n constructor(config: IScaffold.IConfig) {\n const DefaultConfig: IScaffold.IConfig = {\n name: 'scaffold',\n templates: [],\n output: process.cwd(),\n }\n\n this.config = (Object as any).assign({}, DefaultConfig, config)\n\n const DefaultLocals = {\n Name: this.config.name![0].toUpperCase() + this.config.name!.slice(1),\n name: this.config.name![0].toLowerCase() + this.config.name!.slice(1)\n }\n\n this.locals = (Object as any).assign({}, DefaultLocals, config.locals)\n }\n\n private parseLocals(text: string): string {\n const template = handlebars.compile(text, {\n noEscape: true\n })\n return template(this.locals)\n }\n\n private *fileList(input: string[]): IterableIterator {\n for (const checkPath of input) {\n const files = glob.sync(checkPath).map(g => g[0] == '/' ? g : path.join(process.cwd(), g))\n const idx = checkPath.indexOf('*')\n let cleanCheckPath = checkPath\n if (idx >= 0) {\n cleanCheckPath = checkPath.slice(0, idx - 1)\n }\n for (const file of files) {\n yield {base: cleanCheckPath, file}\n }\n }\n }\n\n private getFileContents(filePath: string): string {\n return fs.readFileSync(filePath).toString()\n }\n\n private getOutputPath(file: string, basePath: string): string {\n let out\n\n if (typeof this.config.output === 'function') {\n out = this.config.output(file, basePath)\n } else {\n const outputDir = this.config.output + `/${this.config.name}/`\n const idx = file.indexOf(basePath)\n let relativeFilePath = file\n if (idx >= 0) {\n relativeFilePath = file.slice(idx + basePath.length + 1)\n }\n out = outputDir + relativeFilePath\n }\n\n return this.parseLocals(out)\n }\n\n private writeFile(filePath: string, fileContents: string): void {\n if (!fs.existsSync(path.dirname(filePath))) {\n fs.mkdirSync(path.dirname(filePath))\n }\n console.info('Writing file:', filePath)\n fs.writeFileSync(filePath, fileContents, { encoding: 'utf-8' })\n }\n\n public run(): void {\n console.log(`Generating scaffold: ${this.config.name}...`)\n const templates = this.fileList(this.config.templates)\n\n let fileConf, count = 0\n while (fileConf = templates.next().value) {\n count++\n const {file, base} = fileConf\n const outputPath = this.getOutputPath(file, base)\n const contents = this.getFileContents(file)\n const outputContents = this.parseLocals(contents)\n\n this.writeFile(outputPath, outputContents)\n console.info('Parsing:', {file, base, outputPath, outputContents: outputContents.replace(\"\\n\", \"\\\\n\")})\n }\n\n if (!count) {\n throw new Error('No files to scaffold!')\n }\n\n console.log('Done')\n }\n}\n\nexport default SimpleScaffold\n\n\n\n// WEBPACK FOOTER //\n// ./scaffold.ts","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 2\n// module chunks = 0 1 2","module.exports = require(\"glob\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"glob\"\n// module id = 3\n// module chunks = 0 1 2","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 4\n// module chunks = 0 1 2","import SimpleScaffold from './scaffold'\nimport * as path from 'path'\n\nconst templateDir = path.join(process.cwd(), 'examples')\n\nnew SimpleScaffold({\n templates: [templateDir + '/test-input/Component/**/*'],\n output: templateDir + '/test-output',\n locals: {\n property: 'myProp',\n value: '\"value\"'\n }\n}).run()\n\n\n\n// WEBPACK FOOTER //\n// ./test.ts"],"sourceRoot":""} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 6a8eb37..a486590 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,12 +7,6 @@ declare namespace IScaffold { locals?: any } - export interface IReplacement { - find: string | RegExp - replace(): string - [other: string]: any - } - export interface IFileRepr { base: string file: string diff --git a/scaffold.ts b/scaffold.ts index c9662df..9c38fc7 100644 --- a/scaffold.ts +++ b/scaffold.ts @@ -5,8 +5,8 @@ import * as glob from 'glob' import * as handlebars from 'handlebars' class SimpleScaffold { - private config: IScaffold.IConfig - private locals = {} as any + public config: IScaffold.IConfig + public locals = {} as any constructor(config: IScaffold.IConfig) { const DefaultConfig: IScaffold.IConfig = { @@ -47,6 +47,7 @@ class SimpleScaffold { } private getFileContents(filePath: string): string { + console.log(fs.readFileSync(filePath)) return fs.readFileSync(filePath).toString() }