diff --git a/build/main.js b/build/main.js index bb5b85f..56cdede 100644 --- a/build/main.js +++ b/build/main.js @@ -1,2 +1,2 @@ -!function(e,t){for(var r in t)e[r]=t[r]}(exports,function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t){e.exports=require("path")},function(e,t){e.exports=require("chalk")},function(e,t){e.exports=require("tacker")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsExistProm=function(e,t){return new Promise((r=u(regeneratorRuntime.mark(function r(o,a){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,!Array.isArray(e)){r.next=5;break}e.map(function(){var e=u(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.default.access(t);case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),r.next=7;break;case 5:return r.next=7,i.default.access(e);case 7:o([!0].concat(function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t1&&void 0!==h[1]?h[1]:"Path did not exist",!Array.isArray(t)){e.next=37;break}o=t.flatMap(function(e){return"object"==a(e)?Object.values(e).map(function(e){return e}):e}),c=!0,u=!1,l=void 0,e.prev=6,p=o[Symbol.iterator]();case 8:if(c=(f=p.next()).done){e.next=21;break}return d=f.value,e.prev=10,e.next=13,i.default.access(d);case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(10),s("".concat(n.default.red("Array of paths failed")," ").concat(printLine("red")," ").concat(n.default.red(r)," \n ").concat(n.default.grey(e.t0)));case 18:c=!0,e.next=8;break;case 21:e.next=27;break;case 23:e.prev=23,e.t1=e.catch(6),u=!0,l=e.t1;case 27:e.prev=27,e.prev=28,c||null==p.return||p.return();case 30:if(e.prev=30,!u){e.next=33;break}throw l;case 33:return e.finish(30);case 34:return e.finish(27);case 35:e.next=48;break;case 37:if("string"!=typeof t){e.next=48;break}return e.prev=38,e.next=41,i.default.access(t);case 41:e.next=48;break;case 43:e.prev=43,e.t2=e.catch(38),printLine("red"),s("".concat(n.default.red("Single string failed")," \n").concat(n.default.red(r)," \n ").concat(n.default.grey(e.t2))),printLine("red");case 48:case"end":return e.stop()}},e,null,[[6,23,27,35],[10,15],[28,,30,34],[38,43]])}))).apply(this,arguments)}},function(e,t,r){e.exports=r(5)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=u;var n,i=r(0),o=(n=i)&&n.__esModule?n:{default:n},a=r(6),c=r(8);r(15)();console.log;function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:process.env.configRootDir||process.cwd(),t=(0,a.getWatcherConfig)(o.default.join(e,".protato.js"));(0,c.initWatcher)(t).getDirectories()}u()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWatcherConfig=t.PTOParser=void 0;var n=c(r(0)),i=c(r(1)),o=r(2),a=r(3);function c(e){return e&&e.__esModule?e:{default:e}}var u=console.log;function s(e){var t=e.parent,r=e.children;return(0,o.printLine)("yellow"),u("".concat(i.default.yellow("parent")," and ").concat(i.default.yellow("children")," objects were both found")),(0,o.printMirror)({parent:t},"yellow","grey"),(0,o.printMirror)({children:r},"yellow","grey"),(0,o.printLine)("yellow"),this.watcher={targets:void 0,options:void 0,parent:t},this.config=e,this.config.children=e.children,this}s.prototype.getWatcherTargets=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.children,t=e.map(function(e){var t=e.dir,r=e.src,i=process.env.configRootDir||process.cwd(),o=n.default.join(i,t,r),c=n.default.join(i,t,"package.json"),u=[o,c];return(0,a.pathsExistSync)(u,"getWatcherTargets' directory and package path check"),{childDirPath:o,childPackagePath:c}});return this.watcher.targets=t,void 0!==this.watcher.targets?((0,o.printLine)("yellow"),u("".concat(i.default.yellow("watcher targets")," are defined \n")),(0,o.printMirror)({targets:t},"yellow","grey"),(0,o.printLine)("yellow",null,null,2)):((0,o.printLine)("red"),(0,o.printMirror)({targets:t},"red","white"),(0,o.printLine)("red")),this},s.prototype.getWatcherOptions=function(){var e=[];return(0,o.printLine)("green"),this.config.children.map(function(t){var r,i,c=t.dir;(0,o.printMirror)({dir:c},"green","grey"),e.push((r=c,i=n.default.join(r,"node_modules"),(0,a.pathsExistSync)(i,"getWatcherOptions -> getChildNodeModulesPath() path check"),i))}),(0,o.printLine)({character:".",color:"green"}),(0,o.printMirror)({childrenDirectoriesToIgnore:e},"green","grey"),(0,o.printLine)("green"),this.watcher.options={cwd:process.env.configRootDir||process.cwd(),ignored:["node_modules/**/*"].concat(e),ignoreInitial:!0,ignorePermissionErrors:!0,followSymlinks:!0},this},t.PTOParser=s,t.getWatcherConfig=function(e){var t=new s(e);t.getWatcherTargets().getWatcherOptions();var r=t.watcher,n=r.targets,a=r.options,c=r.parent;return(0,o.printLine)("yellow"),(0,o.printMirror)({targets:n},"yellow","grey"),u("".concat(i.default.yellow("options"),": ").concat(i.default.grey(JSON.stringify(a,null,2)))),(0,o.printLine)("yellow"),{parent:c,targets:n,options:a}}},function(e,t){e.exports=require("fs-extra")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PTOWatcher=l,t.initWatcher=function(e){var t=new l(e);return t.getDirectories().createWatcher(),t};var n,i=r(9),o=(n=i)&&n.__esModule?n:{default:n},a=r(3),c=r(10);function u(e,t){var r=Object.keys(e);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e)),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}process.env.configRootDir||process.cwd();function l(e){return(0,a.printMirror)({oWatcherConfig:e},"blue","grey"),(0,a.pathsExistSync)(e.targets),this.parent=e.parent,this.targets=e.targets,this.options=e.options,this.directoriesToWatch=[],this.packagesToWatch=[],this}l.prototype.getDirectories=function(){var e=this,t=this.targets;return(0,a.printLine)("blue"),t.map(function(t){var r=t.childDirPath,n=t.childPackagePath;(0,a.printMirror)({childDirPath:r},"blue","grey"),(0,a.printMirror)({childPackagePath:n},"blue","grey"),e.directoriesToWatch.push(r),e.packagesToWatch.push(n)}),(0,a.printLine)("blue"),this},l.prototype.createWatcher=function(){var e,t=this,r=this.directoriesToWatch,n=this.options;if((0,a.pathsExistSync)(r),(0,a.printMirror)({directoriesToWatch:r},"blue","grey"),r.length>0&&(e=o.default.watch(r[0],function(e){for(var t=1;t1)for(var i=1;i1&&void 0!==h[1]?h[1]:"Path did not exist",!Array.isArray(t)){e.next=37;break}o=t.flatMap(function(e){return"object"==a(e)?Object.values(e).map(function(e){return e}):e}),c=!0,u=!1,l=void 0,e.prev=6,p=o[Symbol.iterator]();case 8:if(c=(f=p.next()).done){e.next=21;break}return d=f.value,e.prev=10,e.next=13,i.default.access(d);case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(10),s("".concat(n.default.red("Array of paths failed")," ").concat(printLine("red")," ").concat(n.default.red(r)," \n ").concat(n.default.grey(e.t0)));case 18:c=!0,e.next=8;break;case 21:e.next=27;break;case 23:e.prev=23,e.t1=e.catch(6),u=!0,l=e.t1;case 27:e.prev=27,e.prev=28,c||null==p.return||p.return();case 30:if(e.prev=30,!u){e.next=33;break}throw l;case 33:return e.finish(30);case 34:return e.finish(27);case 35:e.next=48;break;case 37:if("string"!=typeof t){e.next=48;break}return e.prev=38,e.next=41,i.default.access(t);case 41:e.next=48;break;case 43:e.prev=43,e.t2=e.catch(38),printLine("red"),s("".concat(n.default.red("Single string failed")," \n").concat(n.default.red(r)," \n ").concat(n.default.grey(e.t2))),printLine("red");case 48:case"end":return e.stop()}},e,null,[[6,23,27,35],[10,15],[28,,30,34],[38,43]])}))).apply(this,arguments)}},function(e,t,r){e.exports=r(5)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:process.env.configRootDir||process.cwd(),t=(0,a.getWatcherConfig)(o.default.join(e,".protato.js"));(0,c.initWatcher)(t).getDirectories()};var n,i=r(0),o=(n=i)&&n.__esModule?n:{default:n},a=r(6),c=r(8);console.log},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWatcherConfig=t.PTOParser=void 0;var n=c(r(0)),i=c(r(1)),o=r(2),a=r(3);function c(e){return e&&e.__esModule?e:{default:e}}var u=console.log;function s(e){var t=e.parent,r=e.children;return(0,o.printLine)("yellow"),u("".concat(i.default.yellow("parent")," and ").concat(i.default.yellow("children")," objects were both found")),(0,o.printMirror)({parent:t},"yellow","grey"),(0,o.printMirror)({children:r},"yellow","grey"),(0,o.printLine)("yellow"),this.watcher={targets:void 0,options:void 0,parent:t},this.config=e,this.config.children=e.children,this}s.prototype.getWatcherTargets=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.children,t=e.map(function(e){var t=e.dir,r=e.src,i=process.env.configRootDir||process.cwd(),o=n.default.join(i,t,r),c=n.default.join(i,t,"package.json"),u=[o,c];return(0,a.pathsExistSync)(u,"getWatcherTargets' directory and package path check"),{childDirPath:o,childPackagePath:c}});return this.watcher.targets=t,void 0!==this.watcher.targets?((0,o.printLine)("yellow"),u("".concat(i.default.yellow("watcher targets")," are defined \n")),(0,o.printMirror)({targets:t},"yellow","grey"),(0,o.printLine)("yellow",null,null,2)):((0,o.printLine)("red"),(0,o.printMirror)({targets:t},"red","white"),(0,o.printLine)("red")),this},s.prototype.getWatcherOptions=function(){var e=[];return(0,o.printLine)("green"),this.config.children.map(function(t){var r,i,c=t.dir;(0,o.printMirror)({dir:c},"green","grey"),e.push((r=c,i=n.default.join(r,"node_modules"),(0,a.pathsExistSync)(i,"getWatcherOptions -> getChildNodeModulesPath() path check"),i))}),(0,o.printLine)({character:".",color:"green"}),(0,o.printMirror)({childrenDirectoriesToIgnore:e},"green","grey"),(0,o.printLine)("green"),this.watcher.options={cwd:process.env.configRootDir||process.cwd(),ignored:["node_modules/**/*"].concat(e),ignoreInitial:!0,ignorePermissionErrors:!0,followSymlinks:!0},this},t.PTOParser=s,t.getWatcherConfig=function(e){var t=new s(e);t.getWatcherTargets().getWatcherOptions();var r=t.watcher,n=r.targets,a=r.options,c=r.parent;return(0,o.printLine)("yellow"),(0,o.printMirror)({targets:n},"yellow","grey"),u("".concat(i.default.yellow("options"),": ").concat(i.default.grey(JSON.stringify(a,null,2)))),(0,o.printLine)("yellow"),{parent:c,targets:n,options:a}}},function(e,t){e.exports=require("fs-extra")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PTOWatcher=l,t.initWatcher=function(e){var t=new l(e);return t.getDirectories().createWatcher(),t};var n,i=r(9),o=(n=i)&&n.__esModule?n:{default:n},a=r(3),c=r(10);function u(e,t){var r=Object.keys(e);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e)),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}process.env.configRootDir||process.cwd();function l(e){return(0,a.printMirror)({oWatcherConfig:e},"blue","grey"),(0,a.pathsExistSync)(e.targets),this.parent=e.parent,this.targets=e.targets,this.options=e.options,this.directoriesToWatch=[],this.packagesToWatch=[],this}l.prototype.getDirectories=function(){var e=this,t=this.targets;return(0,a.printLine)("blue"),t.map(function(t){var r=t.childDirPath,n=t.childPackagePath;(0,a.printMirror)({childDirPath:r},"blue","grey"),(0,a.printMirror)({childPackagePath:n},"blue","grey"),e.directoriesToWatch.push(r),e.packagesToWatch.push(n)}),(0,a.printLine)("blue"),this},l.prototype.createWatcher=function(){var e,t=this,r=this.directoriesToWatch,n=this.options;if((0,a.pathsExistSync)(r),(0,a.printMirror)({directoriesToWatch:r},"blue","grey"),r.length>0&&(e=o.default.watch(r[0],function(e){for(var t=1;t1)for(var i=1;i {\n try {\n if (Array.isArray(arrPathsObj)) {\n arrPathsObj.map(async pathToCheck => {\n await fs.access(pathToCheck);\n });\n } else {\n await fs.access(arrPathsObj);\n }\n resolve([true, ...arrPathsObj]);\n } catch (err) {\n reject(`${chalk.red(szPreErrorMessage)}: \\n ${chalk.grey(err)}`);\n }\n });\n}\nexport async function pathsExistSync(\n arrPathsObj,\n szPreErrorMessage = \"Path did not exist\"\n) {\n //TODO: Consider adding a return value (or prom) so it can be caught inline\n //TODO: Consider adding option to include printLine & printMirrors for success cases\n //TODO: Convert below into unit test (should pass)\n // let rightPath = [\n // {\n // dir: \"sandbox/npm-starter-sample-module/src\",\n // name: \"npm-starter-sample-module\"\n // }\n // ];\n // pathsExistOrThrow(targets, \"PTOWatcher failed to initialize properly \");\n //TODO: Convert below code into unit test (ie. should throw error)\n // let wrongPathString = \"foo\"\n // let wrongPathArray = [\n // {\n // foo: \"bar\"\n // }\n // ];\n // pathsExistOrThrow(wrongPathArray, \"PTOWatcher failed to initialize properly \");\n // pathsExistOrThrow(wrongPathString, \"PTOWatcher failed to initialize properly \");\n\n if (Array.isArray(arrPathsObj)) {\n let arrFilePaths = arrPathsObj.flatMap(mTarget => {\n if (typeof mTarget == \"object\") {\n // * handle array of objects\n // * (ie. default case; used for testing watcherConfig's \"targets\" array)\n\n return Object.values(mTarget).map(pathToCheck => {\n return pathToCheck;\n });\n } else {\n // * handle array of strings\n // * (ie. manually defined arrays with file paths)\n\n return mTarget;\n }\n });\n for (let pathToCheck of arrFilePaths) {\n // ? Now iterate over the flattened map of paths (all should be strings)\n try {\n await fs.access(pathToCheck);\n } catch (err) {\n log(\n `${chalk.red(\"Array of paths failed\")} ${printLine(\n \"red\"\n )} ${chalk.red(szPreErrorMessage)} \\n ${chalk.grey(err)}`\n );\n }\n }\n } else if (typeof arrPathsObj == \"string\") {\n // ? handle checking path of single string\n try {\n await fs.access(arrPathsObj);\n } catch (err) {\n printLine(\"red\");\n //TODO: Add a getLine() utility so that I can include in the middle of a log without needing to log inside of a log (which doesn't process stdout in proper order)\n log(\n `${chalk.red(\"Single string failed\")} \\n${chalk.red(\n szPreErrorMessage\n )} \\n ${chalk.grey(err)}`\n );\n printLine(\"red\");\n }\n }\n}\n","const logProcessErrors = require(\"log-process-errors\");\nlogProcessErrors();\nconst log = console.log;\nimport path from \"path\";\nimport { getWatcherConfig } from \"./parser\";\nimport { initWatcher } from \"./watcher\";\n\nexport function init(cwd = process.env.configRootDir || process.cwd()) {\n let oWC = getWatcherConfig(path.join(cwd, \".protato.js\"));\n let hWatcher = initWatcher(oWC);\n hWatcher.getDirectories();\n}\n\ninit();\n","/*\n * Objective\n 1. Autodetect user config (ie. \".protato.js\")\n 2. Transform user config into: [ watchTargets, watchOptions ]\n 2a. Do this via: getWatcherConfig\n 2ai. Do this via: [getWatchTargets, getWatchOptions]\n*/\n\nconst log = console.log;\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { printLine, printMirror } from \"tacker\";\nimport { pathsExistSync } from \"./utilities\";\n\nfunction PTOParser(config) {\n const { parent, children } = config;\n printLine(\"yellow\");\n log(\n `${chalk.yellow(\"parent\")} and ${chalk.yellow(\n \"children\"\n )} objects were both found`\n );\n printMirror({ parent }, \"yellow\", \"grey\");\n printMirror({ children }, \"yellow\", \"grey\");\n printLine(\"yellow\");\n\n this.watcher = { targets: undefined, options: undefined, parent };\n this.config = config;\n this.config.children = config.children;\n return this;\n}\n\nPTOParser.prototype.getWatcherTargets = function getWatcherTargets(\n children = this.config.children\n) {\n let targets = children.map(oChild => {\n let { dir, src } = oChild;\n let rootDir = process.env.configRootDir || process.cwd();\n let childDirPath = path.join(rootDir, dir, src);\n let childPackagePath = path.join(rootDir, dir, \"package.json\");\n let pathsToCheck = [childDirPath, childPackagePath];\n\n pathsExistSync(\n pathsToCheck,\n \"getWatcherTargets' directory and package path check\"\n );\n return { childDirPath, childPackagePath };\n });\n this.watcher.targets = targets;\n if (this.watcher.targets !== undefined) {\n printLine(\"yellow\");\n log(`${chalk.yellow(\"watcher targets\")} are defined \\n`);\n printMirror({ targets }, \"yellow\", \"grey\");\n printLine(\"yellow\", null, null, 2);\n } else {\n printLine(\"red\");\n printMirror({ targets }, \"red\", \"white\");\n printLine(\"red\");\n }\n return this;\n};\n\nPTOParser.prototype.getWatcherOptions = function getWatcherOptions() {\n let childrenDirectoriesToIgnore = [];\n\n function getChildNodeModulesPath(szChildTargetPath) {\n let potentialPath = path.join(szChildTargetPath, \"node_modules\");\n pathsExistSync(\n potentialPath,\n \"getWatcherOptions -> getChildNodeModulesPath() path check\"\n );\n return potentialPath;\n }\n\n printLine(\"green\");\n this.config.children.map(child => {\n const { dir } = child;\n printMirror({ dir }, \"green\", \"grey\");\n\n childrenDirectoriesToIgnore.push(getChildNodeModulesPath(dir));\n });\n\n printLine({ character: \".\", color: \"green\" });\n printMirror({ childrenDirectoriesToIgnore }, \"green\", \"grey\");\n printLine(\"green\");\n\n this.watcher.options = {\n cwd: process.env.configRootDir || process.cwd(),\n ignored: [\"node_modules/**/*\", ...childrenDirectoriesToIgnore],\n ignoreInitial: true,\n ignorePermissionErrors: true,\n followSymlinks: true\n };\n return this;\n};\n\nfunction getWatcherConfig(oConfig) {\n let parser = new PTOParser(oConfig);\n parser.getWatcherTargets().getWatcherOptions();\n\n const {\n watcher: { targets, options, parent }\n } = parser;\n\n printLine(\"yellow\");\n printMirror({ targets }, \"yellow\", \"grey\");\n log(\n `${chalk.yellow(\"options\")}: ${chalk.grey(\n JSON.stringify(options, null, 2)\n )}`\n );\n printLine(\"yellow\");\n return {\n parent,\n targets,\n options\n };\n}\n\nexport { PTOParser, getWatcherConfig };\n","module.exports = require(\"fs-extra\");","import chokidar from \"chokidar\";\nimport { pathsExistSync } from \"./utilities\";\nimport { printLine, printMirror } from \"./utilities\";\nimport { linker } from \"./linker\";\n\nconst sampleConfig = {\n parent: {\n dir: \"sandbox/node-starter\"\n },\n targets: [\n {\n childDirPath: \"sandbox/npm-starter-sample-module/src\",\n childPackagePath: \"sandbox/npm-starter-sample-module/package.json\"\n }\n ],\n options: {\n cwd: process.env.configRootDir || process.cwd(),\n ignored: [\n \"node_modules\",\n \"sandbox/npm-starter-sample-module/node_modules\",\n \"sandbox/npm-starter-sample-module/.git\"\n ],\n ignoreInitial: true,\n ignorePermissionErrors: true,\n followSymlinks: true\n }\n};\n\nexport function PTOWatcher(oWatcherConfig) {\n printMirror({ oWatcherConfig }, \"blue\", \"grey\");\n pathsExistSync(oWatcherConfig.targets);\n this.parent = oWatcherConfig.parent;\n this.targets = oWatcherConfig.targets;\n this.options = oWatcherConfig.options;\n this.directoriesToWatch = [];\n this.packagesToWatch = [];\n\n return this;\n}\n\nPTOWatcher.prototype.getDirectories = function getDirectories() {\n let { targets } = this;\n printLine(\"blue\");\n targets.map(({ childDirPath, childPackagePath }) => {\n printMirror({ childDirPath }, \"blue\", \"grey\");\n printMirror({ childPackagePath }, \"blue\", \"grey\");\n this.directoriesToWatch.push(childDirPath);\n this.packagesToWatch.push(childPackagePath);\n });\n printLine(\"blue\");\n return this;\n};\n\nPTOWatcher.prototype.createWatcher = function createWatcher() {\n const { directoriesToWatch, options } = this;\n pathsExistSync(directoriesToWatch);\n printMirror({ directoriesToWatch }, \"blue\", \"grey\");\n var watcher;\n //TODO: Add a new sample repo to repogen\n //TODO: Create backup config to test whether this works with 2+ directories\n if (directoriesToWatch.length > 0) {\n watcher = chokidar.watch(directoriesToWatch[0], { ...options });\n }\n if (directoriesToWatch.length > 1) {\n for (let i = 1; i < directoriesToWatch.length; i++) {\n watcher.add(directoriesToWatch[i]);\n }\n }\n watcher.on(\"change\", modifiedChildPath => {\n printMirror({ modifiedChildPath }, \"green\", \"grey\");\n linker(modifiedChildPath, this.parent.dir);\n });\n};\n\nexport function initWatcher(oWatcherConfig) {\n let watcher = new PTOWatcher(oWatcherConfig);\n watcher.getDirectories().createWatcher();\n return watcher;\n}\n","module.exports = require(\"chokidar\");","const log = console.log;\nimport chalk from \"chalk\";\nimport path from \"path\";\nimport isEmpty from \"is-empty\";\nimport pkgDir from \"pkg-dir\";\nimport exec from \"await-exec\";\n\nimport { printLine, printMirror } from \"tacker\";\n\n//TODO: Try using yalc instead\n//TODO: Check to see whether yalc installed globally. If not, install. If install fails, throw err & explain\n\nexport async function linker(szModifiedFilePath, szParentDirPath) {\n if (!isEmpty(szModifiedFilePath) | !isEmpty(szParentDirPath)) {\n printMirror({ szModifiedFilePath }, \"magenta\", \"grey\");\n printMirror({ szParentDirPath }, \"magenta\", \"grey\");\n let childData, parentData, childModuleName;\n try {\n let modifiedRootDir = await pkgDir(szModifiedFilePath);\n printLine(\"blue\");\n printMirror({ modifiedRootDir }, \"magenta\", \"green\");\n let modifiedPkgPath = path.join(modifiedRootDir, \"package.json\");\n printMirror({ modifiedPkgPath }, \"magenta\", \"green\");\n const { name } = require(modifiedPkgPath);\n childModuleName = name;\n printMirror({ childModuleName }, \"blue\", \"grey\");\n printLine(\"blue\");\n childData = await exec(`cd ${modifiedRootDir} && yalc publish`);\n printLine(\"green\");\n log(`childData: ${JSON.stringify(childData, null, 2)}`);\n printLine(\"green\");\n } catch (err) {\n log(`${chalk.red(\"'yalc publish' failed\")}\\n${chalk.grey(err)}`);\n }\n\n try {\n let parentRootDir = await pkgDir(szParentDirPath);\n printMirror({ parentRootDir }, \"magenta\", \"green\");\n parentData = await exec(\n `cd ${parentRootDir} && yalc link ${childModuleName}`\n );\n printLine(\"yellow\");\n log(`parentData: ${JSON.stringify(parentData, null, 2)}`);\n printLine(\"yellow\");\n } catch (err) {\n log(\n `${chalk.red(\n `yalc add ${childModuleName} in ${chalk.yellow(parentRootDir)} failed`\n )}\\n${chalk.grey(err)}`\n );\n }\n } else {\n printLine(\"green\");\n log(`parentDirectory not set`);\n printLine(\"green\");\n }\n return this;\n}\n","module.exports = require(\"is-empty\");","module.exports = require(\"pkg-dir\");","module.exports = require(\"await-exec\");","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 14;","module.exports = require(\"log-process-errors\");"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"path\"","webpack:///external \"chalk\"","webpack:///external \"tacker\"","webpack:///./src/utilities.js","webpack:///./src/index.js","webpack:///./src/parser.js","webpack:///external \"fs-extra\"","webpack:///./src/watcher.js","webpack:///external \"chokidar\"","webpack:///./src/linker.js","webpack:///external \"is-empty\"","webpack:///external \"pkg-dir\"","webpack:///external \"await-exec\"","webpack:///./src sync"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","pathsExistProm","arrPathsObj","szPreErrorMessage","Promise","_ref","_asyncToGenerator","regeneratorRuntime","mark","_callee2","resolve","reject","wrap","_context2","prev","next","Array","isArray","map","_ref2","_callee","pathToCheck","_context","fs","access","stop","_x3","apply","this","arguments","concat","t0","chalk","red","grey","_x","_x2","pathsExistSync","log","console","_callee3","arrFilePaths","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","_step","_args3","_context3","length","undefined","flatMap","mTarget","_typeof","values","iterator","done","printLine","t1","return","finish","t2","init","cwd","process","env","configRootDir","oWC","_parser","getWatcherConfig","path","join","_watcher","initWatcher","getDirectories","_path","_tacker","_utilities","PTOParser","config","parent","children","yellow","printMirror","watcher","targets","options","getWatcherTargets","oChild","dir","src","rootDir","childDirPath","childPackagePath","pathsToCheck","getWatcherOptions","childrenDirectoriesToIgnore","child","szChildTargetPath","potentialPath","push","character","color","ignored","ignoreInitial","ignorePermissionErrors","followSymlinks","oConfig","parser","_parser$watcher","JSON","stringify","PTOWatcher","oWatcherConfig","createWatcher","_chokidar","_linker","directoriesToWatch","packagesToWatch","_this","_this2","chokidar","watch","_objectSpread","add","on","modifiedChildPath","linker","szModifiedFilePath","szParentDirPath","childData","parentData","childModuleName","modifiedRootDir","modifiedPkgPath","_require","_parentRootDir","_isEmpty2","default","_pkgDir2","sent","_awaitExec2","parentRootDir","abrupt","webpackEmptyContext","req","e","Error","code","keys","id"],"mappings":"6DACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QA0DA,OArDAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,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ApCP,QAAApC,EAAAP,KAAA,kBAwCH,EAAA6D,EAAAnB,WAAU,SACVnB,EAAG,4BACH,EAAAsC,EAAAnB,WAAU,SA1CP,eAAAnC,EAAAyH,OAAA,SA4CEnH,MA5CF,yBAAAN,EAAAG,SAAAL,EAAAQ,KAAA,0OCZP7D,EAAAD,QAAAkC,QAAA,2BCAAjC,EAAAD,QAAAkC,QAAA,0BCAAjC,EAAAD,QAAAkC,QAAA,6BCAA,SAAAgJ,EAAAC,GACA,IAAAC,EAAA,IAAAC,MAAA,uBAAAF,EAAA,KAEA,MADAC,EAAAE,KAAA,mBACAF,EAEAF,EAAAK,KAAA,WAAuC,UACvCL,EAAAtI,QAAAsI,EACAjL,EAAAD,QAAAkL,EACAA,EAAAM,GAAA","file":"main.js","sourcesContent":[" \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, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","module.exports = require(\"path\");","module.exports = require(\"chalk\");","module.exports = require(\"tacker\");","import chalk from \"chalk\";\nimport fs from \"fs-extra\";\nconst log = console.log;\n\nexport function pathsExistProm(arrPathsObj, szPreErrorMessage) {\n return new Promise(async (resolve, reject) => {\n try {\n if (Array.isArray(arrPathsObj)) {\n arrPathsObj.map(async pathToCheck => {\n await fs.access(pathToCheck);\n });\n } else {\n await fs.access(arrPathsObj);\n }\n resolve([true, ...arrPathsObj]);\n } catch (err) {\n reject(`${chalk.red(szPreErrorMessage)}: \\n ${chalk.grey(err)}`);\n }\n });\n}\nexport async function pathsExistSync(\n arrPathsObj,\n szPreErrorMessage = \"Path did not exist\"\n) {\n //TODO: Consider adding a return value (or prom) so it can be caught inline\n //TODO: Consider adding option to include printLine & printMirrors for success cases\n //TODO: Convert below into unit test (should pass)\n // let rightPath = [\n // {\n // dir: \"sandbox/npm-starter-sample-module/src\",\n // name: \"npm-starter-sample-module\"\n // }\n // ];\n // pathsExistOrThrow(targets, \"PTOWatcher failed to initialize properly \");\n //TODO: Convert below code into unit test (ie. should throw error)\n // let wrongPathString = \"foo\"\n // let wrongPathArray = [\n // {\n // foo: \"bar\"\n // }\n // ];\n // pathsExistOrThrow(wrongPathArray, \"PTOWatcher failed to initialize properly \");\n // pathsExistOrThrow(wrongPathString, \"PTOWatcher failed to initialize properly \");\n\n if (Array.isArray(arrPathsObj)) {\n let arrFilePaths = arrPathsObj.flatMap(mTarget => {\n if (typeof mTarget == \"object\") {\n // * handle array of objects\n // * (ie. default case; used for testing watcherConfig's \"targets\" array)\n\n return Object.values(mTarget).map(pathToCheck => {\n return pathToCheck;\n });\n } else {\n // * handle array of strings\n // * (ie. manually defined arrays with file paths)\n\n return mTarget;\n }\n });\n for (let pathToCheck of arrFilePaths) {\n // ? Now iterate over the flattened map of paths (all should be strings)\n try {\n await fs.access(pathToCheck);\n } catch (err) {\n log(\n `${chalk.red(\"Array of paths failed\")} ${printLine(\n \"red\"\n )} ${chalk.red(szPreErrorMessage)} \\n ${chalk.grey(err)}`\n );\n }\n }\n } else if (typeof arrPathsObj == \"string\") {\n // ? handle checking path of single string\n try {\n await fs.access(arrPathsObj);\n } catch (err) {\n printLine(\"red\");\n //TODO: Add a getLine() utility so that I can include in the middle of a log without needing to log inside of a log (which doesn't process stdout in proper order)\n log(\n `${chalk.red(\"Single string failed\")} \\n${chalk.red(\n szPreErrorMessage\n )} \\n ${chalk.grey(err)}`\n );\n printLine(\"red\");\n }\n }\n}\n","/*const logProcessErrors = require(\"log-process-errors\");*/\n/*logProcessErrors();*/\nconst log = console.log;\nimport path from \"path\";\nimport { getWatcherConfig } from \"./parser\";\nimport { initWatcher } from \"./watcher\";\n\nexport function init(cwd = process.env.configRootDir || process.cwd()) {\n let oWC = getWatcherConfig(path.join(cwd, \".protato.js\"));\n let hWatcher = initWatcher(oWC);\n hWatcher.getDirectories();\n}\n","/*\n * Objective\n 1. Autodetect user config (ie. \".protato.js\")\n 2. Transform user config into: [ watchTargets, watchOptions ]\n 2a. Do this via: getWatcherConfig\n 2ai. Do this via: [getWatchTargets, getWatchOptions]\n*/\n\nconst log = console.log;\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { printLine, printMirror } from \"tacker\";\nimport { pathsExistSync } from \"./utilities\";\n\nfunction PTOParser(config) {\n const { parent, children } = config;\n printLine(\"yellow\");\n log(\n `${chalk.yellow(\"parent\")} and ${chalk.yellow(\n \"children\"\n )} objects were both found`\n );\n printMirror({ parent }, \"yellow\", \"grey\");\n printMirror({ children }, \"yellow\", \"grey\");\n printLine(\"yellow\");\n\n this.watcher = { targets: undefined, options: undefined, parent };\n this.config = config;\n this.config.children = config.children;\n return this;\n}\n\nPTOParser.prototype.getWatcherTargets = function getWatcherTargets(\n children = this.config.children\n) {\n let targets = children.map(oChild => {\n let { dir, src } = oChild;\n let rootDir = process.env.configRootDir || process.cwd();\n let childDirPath = path.join(rootDir, dir, src);\n let childPackagePath = path.join(rootDir, dir, \"package.json\");\n let pathsToCheck = [childDirPath, childPackagePath];\n\n pathsExistSync(\n pathsToCheck,\n \"getWatcherTargets' directory and package path check\"\n );\n return { childDirPath, childPackagePath };\n });\n this.watcher.targets = targets;\n if (this.watcher.targets !== undefined) {\n printLine(\"yellow\");\n log(`${chalk.yellow(\"watcher targets\")} are defined \\n`);\n printMirror({ targets }, \"yellow\", \"grey\");\n printLine(\"yellow\", null, null, 2);\n } else {\n printLine(\"red\");\n printMirror({ targets }, \"red\", \"white\");\n printLine(\"red\");\n }\n return this;\n};\n\nPTOParser.prototype.getWatcherOptions = function getWatcherOptions() {\n let childrenDirectoriesToIgnore = [];\n\n function getChildNodeModulesPath(szChildTargetPath) {\n let potentialPath = path.join(szChildTargetPath, \"node_modules\");\n pathsExistSync(\n potentialPath,\n \"getWatcherOptions -> getChildNodeModulesPath() path check\"\n );\n return potentialPath;\n }\n\n printLine(\"green\");\n this.config.children.map(child => {\n const { dir } = child;\n printMirror({ dir }, \"green\", \"grey\");\n\n childrenDirectoriesToIgnore.push(getChildNodeModulesPath(dir));\n });\n\n printLine({ character: \".\", color: \"green\" });\n printMirror({ childrenDirectoriesToIgnore }, \"green\", \"grey\");\n printLine(\"green\");\n\n this.watcher.options = {\n cwd: process.env.configRootDir || process.cwd(),\n ignored: [\"node_modules/**/*\", ...childrenDirectoriesToIgnore],\n ignoreInitial: true,\n ignorePermissionErrors: true,\n followSymlinks: true\n };\n return this;\n};\n\nfunction getWatcherConfig(oConfig) {\n let parser = new PTOParser(oConfig);\n parser.getWatcherTargets().getWatcherOptions();\n\n const {\n watcher: { targets, options, parent }\n } = parser;\n\n printLine(\"yellow\");\n printMirror({ targets }, \"yellow\", \"grey\");\n log(\n `${chalk.yellow(\"options\")}: ${chalk.grey(\n JSON.stringify(options, null, 2)\n )}`\n );\n printLine(\"yellow\");\n return {\n parent,\n targets,\n options\n };\n}\n\nexport { PTOParser, getWatcherConfig };\n","module.exports = require(\"fs-extra\");","import chokidar from \"chokidar\";\nimport { pathsExistSync } from \"./utilities\";\nimport { printLine, printMirror } from \"./utilities\";\nimport { linker } from \"./linker\";\n\nconst sampleConfig = {\n parent: {\n dir: \"sandbox/node-starter\"\n },\n targets: [\n {\n childDirPath: \"sandbox/npm-starter-sample-module/src\",\n childPackagePath: \"sandbox/npm-starter-sample-module/package.json\"\n }\n ],\n options: {\n cwd: process.env.configRootDir || process.cwd(),\n ignored: [\n \"node_modules\",\n \"sandbox/npm-starter-sample-module/node_modules\",\n \"sandbox/npm-starter-sample-module/.git\"\n ],\n ignoreInitial: true,\n ignorePermissionErrors: true,\n followSymlinks: true\n }\n};\n\nexport function PTOWatcher(oWatcherConfig) {\n printMirror({ oWatcherConfig }, \"blue\", \"grey\");\n pathsExistSync(oWatcherConfig.targets);\n this.parent = oWatcherConfig.parent;\n this.targets = oWatcherConfig.targets;\n this.options = oWatcherConfig.options;\n this.directoriesToWatch = [];\n this.packagesToWatch = [];\n\n return this;\n}\n\nPTOWatcher.prototype.getDirectories = function getDirectories() {\n let { targets } = this;\n printLine(\"blue\");\n targets.map(({ childDirPath, childPackagePath }) => {\n printMirror({ childDirPath }, \"blue\", \"grey\");\n printMirror({ childPackagePath }, \"blue\", \"grey\");\n this.directoriesToWatch.push(childDirPath);\n this.packagesToWatch.push(childPackagePath);\n });\n printLine(\"blue\");\n return this;\n};\n\nPTOWatcher.prototype.createWatcher = function createWatcher() {\n const { directoriesToWatch, options } = this;\n pathsExistSync(directoriesToWatch);\n printMirror({ directoriesToWatch }, \"blue\", \"grey\");\n var watcher;\n //TODO: Add a new sample repo to repogen\n //TODO: Create backup config to test whether this works with 2+ directories\n if (directoriesToWatch.length > 0) {\n watcher = chokidar.watch(directoriesToWatch[0], { ...options });\n }\n if (directoriesToWatch.length > 1) {\n for (let i = 1; i < directoriesToWatch.length; i++) {\n watcher.add(directoriesToWatch[i]);\n }\n }\n watcher.on(\"change\", modifiedChildPath => {\n printMirror({ modifiedChildPath }, \"green\", \"grey\");\n linker(modifiedChildPath, this.parent.dir);\n });\n};\n\nexport function initWatcher(oWatcherConfig) {\n let watcher = new PTOWatcher(oWatcherConfig);\n watcher.getDirectories().createWatcher();\n return watcher;\n}\n","module.exports = require(\"chokidar\");","const log = console.log;\nimport chalk from \"chalk\";\nimport path from \"path\";\nimport isEmpty from \"is-empty\";\nimport pkgDir from \"pkg-dir\";\nimport exec from \"await-exec\";\n\nimport { printLine, printMirror } from \"tacker\";\n\n//TODO: Try using yalc instead\n//TODO: Check to see whether yalc installed globally. If not, install. If install fails, throw err & explain\n\nexport async function linker(szModifiedFilePath, szParentDirPath) {\n if (!isEmpty(szModifiedFilePath) | !isEmpty(szParentDirPath)) {\n printMirror({ szModifiedFilePath }, \"magenta\", \"grey\");\n printMirror({ szParentDirPath }, \"magenta\", \"grey\");\n let childData, parentData, childModuleName;\n try {\n let modifiedRootDir = await pkgDir(szModifiedFilePath);\n printLine(\"blue\");\n printMirror({ modifiedRootDir }, \"magenta\", \"green\");\n let modifiedPkgPath = path.join(modifiedRootDir, \"package.json\");\n printMirror({ modifiedPkgPath }, \"magenta\", \"green\");\n const { name } = require(modifiedPkgPath);\n childModuleName = name;\n printMirror({ childModuleName }, \"blue\", \"grey\");\n printLine(\"blue\");\n childData = await exec(`cd ${modifiedRootDir} && yalc publish`);\n printLine(\"green\");\n log(`childData: ${JSON.stringify(childData, null, 2)}`);\n printLine(\"green\");\n } catch (err) {\n log(`${chalk.red(\"'yalc publish' failed\")}\\n${chalk.grey(err)}`);\n }\n\n try {\n let parentRootDir = await pkgDir(szParentDirPath);\n printMirror({ parentRootDir }, \"magenta\", \"green\");\n parentData = await exec(\n `cd ${parentRootDir} && yalc link ${childModuleName}`\n );\n printLine(\"yellow\");\n log(`parentData: ${JSON.stringify(parentData, null, 2)}`);\n printLine(\"yellow\");\n } catch (err) {\n log(\n `${chalk.red(\n `yalc add ${childModuleName} in ${chalk.yellow(parentRootDir)} failed`\n )}\\n${chalk.grey(err)}`\n );\n }\n } else {\n printLine(\"green\");\n log(`parentDirectory not set`);\n printLine(\"green\");\n }\n return this;\n}\n","module.exports = require(\"is-empty\");","module.exports = require(\"pkg-dir\");","module.exports = require(\"await-exec\");","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 14;"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 992c255..1fb1c83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "protato-lib", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 1, "requires": true, "dependencies": {