UNPKG

sdin

Version:

JavaScript package builder.

2 lines 2.45 kB
var t=require("@babel/runtime/helpers/interopRequireDefault"),o=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdinAbstractProject=void 0,t(require("@babel/runtime/helpers/defineProperty"))),s=require("path"),i=require("../utils/npm"),a=require("../utils/path"),r=require("./abstract-config");function h(r,t){var e,o=Object.keys(r);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(r),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),o.push.apply(o,e)),o}function e(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?h(Object(e),!0).forEach(function(t){(0,o.default)(r,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):h(Object(e)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}return r}class n extends r.SdinAbstractConfig{constructor(t,r,e){super(t,r,e),r?(this.root=e.root?(0,s.resolve)((0,i.getPackageRootPath)(e.root)):r.root,this.root===r.root?(this.tmp=r.tmp,this.pro=r.pro,this.cfg=r.cfg,this.pkg=r.pkg):(this.tmp=this.withRoot(".tmp"),this.pro=this.withRoot("pro"),this.cfg=this.withRoot("pro/configs"),this.pkg=(0,i.readPackageInfo)(this.root,!0)),this.alias=e.alias?Object.assign({},r.alias,e.alias):r.alias,this.codes=e.codes?Object.assign({},r.codes,e.codes):r.codes):(this.root=(0,s.resolve)((0,i.getPackageRootPath)(e.root||(0,a.getWorkPath)())),this.tmp=this.withRoot(".tmp"),this.pro=this.withRoot("pro"),this.cfg=this.withRoot("pro/configs"),this.pkg=(0,i.readPackageInfo)(this.root,!0),this.alias=e.alias||{},this.codes=e.codes||{})}withRoot(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return(0,s.resolve)(this.root,...r)}withTmp(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return(0,s.resolve)(this.tmp,...r)}withPro(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return(0,s.resolve)(this.pro,...r)}withCfg(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return(0,s.resolve)(this.cfg,...r)}toMacros(){var t,r=e({},this.codes);for(t in this.datas)r[t]=JSON.stringify(this.datas[t]);return r}toTsCfgPaths(){let e={};return Object.keys(this.alias).forEach(t=>{var r=this.alias[t];e[(0,a.joinPosix)(t,"*")]=[(0,a.joinPosix)(r,"*")],e[t]=[r]}),e}}exports.SdinAbstractProject=n; //# sourceMappingURL=abstract-project.js.map