dev-dep-tool
Advanced tools
Comparing version 0.2.1 to 0.2.2-dev.0
var e=require("dr-js/library/common/module/Option/parser") | ||
var t=require("dr-js/library/common/module/Option/preset") | ||
var r=require("dr-js/library/node/module/Option") | ||
function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{} | ||
var o=Object.keys(r) | ||
"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))) | ||
o.forEach(function(t){a(e,t,r[t])})}return e}function a(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r | ||
return e}const{SingleString:n,BooleanFlag:p,Config:i}=t.ConfigPreset | ||
const s={prefixENV:"dev-dep",prefixJSON:"dev-dep",formatList:[i,o({},p,{name:"help",shortName:"h"}),o({},p,{name:"version",shortName:"v"}),o({},n,{isPath:!0,optional:(0,t.getOptionalFormatFlag)("check-outdated","pack"),name:"path-input",shortName:"i",description:"path to 'package.json', or directory with 'package.json' inside"}),o({},p,{name:"check-outdated",shortName:"C",extendFormatList:[o({},n,{isPath:!0,optional:!0,name:"path-temp"})]}),o({},p,{name:"pack",shortName:"P",extendFormatList:[o({},n,{isPath:!0,name:"path-output",shortName:"o",description:"output path"}),o({},n,{optional:!0,name:"output-name",description:"output package name"}),o({},n,{optional:!0,name:"output-version",description:"output package version"}),o({},n,{optional:!0,name:"output-description",description:"output package description"}),o({},p,{name:"publish",description:"run npm publish"}),o({},p,{name:"publish-dev",description:"run npm publish-dev"})]})]} | ||
const{parseCLI:c,parseENV:u,parseJSON:m,processOptionMap:d,formatUsage:l}=(0,e.createOptionParser)(s) | ||
exports.formatUsage=l | ||
exports.parseOption=(async()=>(0,r.createOptionGetter)(await(0,r.parseOptionMap)({parseCLI:c,parseENV:u,parseJSON:m,processOptionMap:d}))) | ||
var a=require("dr-js/library/node/module/Option") | ||
const{SingleString:o,BooleanFlag:p,Config:r}=t.ConfigPreset | ||
const i={prefixENV:"dev-dep",prefixJSON:"dev-dep",formatList:[r,{...p,name:"help",shortName:"h"},{...p,name:"version",shortName:"v"},{...o,isPath:!0,optional:(0,t.getOptionalFormatFlag)("check-outdated","pack"),name:"path-input",shortName:"i",description:"path to 'package.json', or directory with 'package.json' inside"},{...p,name:"check-outdated",shortName:"C",extendFormatList:[{...o,isPath:!0,optional:!0,name:"path-temp"}]},{...p,name:"pack",shortName:"P",extendFormatList:[{...o,isPath:!0,name:"path-output",shortName:"o",description:"output path"},{...o,optional:!0,name:"output-name",description:"output package name"},{...o,optional:!0,name:"output-version",description:"output package version"},{...o,optional:!0,name:"output-description",description:"output package description"},{...p,name:"publish",description:"run npm publish"},{...p,name:"publish-dev",description:"run npm publish-dev"}]}]} | ||
const{parseCLI:s,parseENV:n,parseJSON:m,processOptionMap:u,formatUsage:c}=(0,e.createOptionParser)(i) | ||
exports.formatUsage=c | ||
exports.parseOption=(async()=>(0,a.createOptionGetter)(await(0,a.parseOptionMap)({parseCLI:s,parseENV:n,parseJSON:m,processOptionMap:u}))) |
var e=require("path") | ||
var r=require("fs") | ||
var i=require("child_process") | ||
var i=require("fs") | ||
var r=require("child_process") | ||
var o=require("dr-js/library/common/format") | ||
var t=require("dr-js/library/common/mutable/Object") | ||
var n=require("dr-js/library/node/file/File") | ||
var n=require("dr-js/library/common/mutable/Object") | ||
var t=require("dr-js/library/node/file/File") | ||
var s=require("dr-js/library/node/file/Modify") | ||
var a=require("dr-js/library/node/system/Run") | ||
const c=(r,i=(()=>({packageJSON:{},exportFilePairList:[],installFilePairList:[]}))(),o=new Set)=>{const n=r.endsWith(".json")?r:(0,e.join)(r,"package.json") | ||
r.endsWith(".json")&&(r=(0,e.dirname)(r)) | ||
if(o.has(n))return i | ||
o.add(n) | ||
const s=require(n),{IMPORT:a,EXPORT:p,INSTALL:d}=s,u=function(e,r){if(null==e)return{} | ||
var i={} | ||
var o=Object.keys(e) | ||
var t,n | ||
for(n=0;n<o.length;n++){t=o[n] | ||
r.indexOf(t)>=0||(i[t]=e[t])}if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e) | ||
for(n=0;n<s.length;n++){t=s[n] | ||
r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}}return i}(s,["IMPORT","EXPORT","INSTALL"]) | ||
const{packageJSON:f,exportFilePairList:y,installFilePairList:b}=i | ||
a&&a.forEach(t=>c((0,e.resolve)(r,t),i,o)) | ||
console.log(`[loadPackage] load: ${n}`) | ||
d&&d.forEach(e=>b.push(l(e,r))) | ||
p&&p.forEach(e=>y.push(l(e,r))) | ||
u&&(0,t.objectMergeDeep)(f,u) | ||
return i} | ||
const l=(r,i)=>"object"==typeof r?[(0,e.resolve)(i,r.from),r.to]:[(0,e.resolve)(i,r),r] | ||
const c=(i,r=(()=>({packageJSON:{},exportFilePairList:[],installFilePairList:[]}))(),o=new Set)=>{const t=i.endsWith(".json")?i:(0,e.join)(i,"package.json") | ||
i.endsWith(".json")&&(i=(0,e.dirname)(i)) | ||
if(o.has(t))return r | ||
o.add(t) | ||
const{IMPORT:s,EXPORT:a,INSTALL:p,...d}=require(t) | ||
const{packageJSON:u,exportFilePairList:f,installFilePairList:y}=r | ||
s&&s.forEach(n=>c((0,e.resolve)(i,n),r,o)) | ||
console.log(`[loadPackage] load: ${t}`) | ||
p&&p.forEach(e=>y.push(l(e,i))) | ||
a&&a.forEach(e=>f.push(l(e,i))) | ||
d&&(0,n.objectMergeDeep)(u,d) | ||
return r} | ||
const l=(i,r)=>"object"==typeof i?[(0,e.resolve)(r,i.from),i.to]:[(0,e.resolve)(r,i),i] | ||
const p=["dependencies","devDependencies","peerDependencies","optionalDependencies","bundledDependencies"] | ||
const d=["private","name","version","description","author","contributors","license","keywords","repository","homepage","bugs","os","cpu","engines","engineStrict","preferGlobal","main","bin","man","files","directories","scripts","config","publishConfig",...p,"sideEffects"] | ||
exports.doPack=(async({pathInput:l,pathOutput:u,outputName:f,outputVersion:y,outputDescription:b,isPublish:g,isPublishDev:m})=>{const h=(0,e.resolve)(u,"install") | ||
const{packageJSON:j,exportFilePairList:v,installFilePairList:O}=c(l) | ||
exports.doPack=(async({pathInput:l,pathOutput:u,outputName:f,outputVersion:y,outputDescription:m,isPublish:g,isPublishDev:b})=>{const h=(0,e.resolve)(u,"install") | ||
const{packageJSON:j,exportFilePairList:v,installFilePairList:P}=c(l) | ||
f&&(j.name=f) | ||
y&&(j.version=y) | ||
b&&(j.description=b) | ||
m&&(j.description=m) | ||
await s.modify.delete(u).catch(()=>{}) | ||
await(0,n.createDirectory)(u) | ||
await(0,n.createDirectory)(h) | ||
await(async(e,i)=>{p.forEach(r=>{e[r]&&(0,t.objectSortKey)(e[r])}) | ||
const n=Object.keys(e).sort((e,r)=>d.indexOf(e)-d.indexOf(r)).map(r=>(0,o.stringIndentLine)(`${JSON.stringify(r)}: ${JSON.stringify(e[r],null,2)}`)) | ||
const s=Buffer.from(`{\n${n.join(",\n")}\n}\n`);(0,r.writeFileSync)(i,s) | ||
console.log(`[writePackageJSON] ${i} [${(0,o.binary)(s.length)}B]`)})(j,(0,e.join)(u,"package.json")) | ||
for(const[r,i]of v)await s.modify.copy(r,(0,e.join)(u,i)) | ||
for(const[r,i]of O)await s.modify.copy(r,(0,e.join)(h,i));(0,i.execSync)("npm pack",{cwd:u,stdio:"inherit",shell:!0}) | ||
const P=`${j.name}-${j.version}.tgz` | ||
const S=(0,e.join)(u,P) | ||
console.log(`done pack: ${P} [${(0,o.binary)((0,r.statSync)(S).size)}B]`);(g||m)&&(0,a.runSync)({command:"npm",argList:["publish",S,"--tag",m?"dev":"latest"]})}) | ||
await(0,t.createDirectory)(u) | ||
await(0,t.createDirectory)(h) | ||
await(async(e,r)=>{p.forEach(i=>{e[i]&&(0,n.objectSortKey)(e[i])}) | ||
const t=Object.keys(e).sort((e,i)=>d.indexOf(e)-d.indexOf(i)).map(i=>(0,o.stringIndentLine)(`${JSON.stringify(i)}: ${JSON.stringify(e[i],null,2)}`)) | ||
const s=Buffer.from(`{\n${t.join(",\n")}\n}\n`);(0,i.writeFileSync)(r,s) | ||
console.log(`[writePackageJSON] ${r} [${(0,o.binary)(s.length)}B]`)})(j,(0,e.join)(u,"package.json")) | ||
for(const[i,r]of v)await s.modify.copy(i,(0,e.join)(u,r)) | ||
for(const[i,r]of P)await s.modify.copy(i,(0,e.join)(h,r));(0,r.execSync)("npm pack",{cwd:u,stdio:"inherit",shell:!0}) | ||
const O=`${j.name}-${j.version}.tgz` | ||
const S=(0,e.join)(u,O) | ||
console.log(`done pack: ${O} [${(0,o.binary)((0,i.statSync)(S).size)}B]`);(g||b)&&(0,a.runSync)({command:"npm",argList:["publish",S,"--tag",b?"dev":"latest"]})}) |
@@ -8,30 +8,30 @@ var e=require("fs") | ||
var a=require("./__utils__") | ||
exports.initOutput=(async({fromRoot:t,fromOutput:r,deleteKeyList:s=["private","scripts","engines","devDependencies"],copyPathList:a=["LICENSE","README.md"],logger:{padLog:n,log:u}})=>{n("reset output") | ||
exports.initOutput=(async({fromRoot:t,fromOutput:r,deleteKeyList:s=["private","scripts","devDependencies"],copyPathList:a=["LICENSE","README.md"],logger:{padLog:u,log:n}})=>{u("reset output") | ||
await o.modify.delete(r()).catch(()=>{}) | ||
await(0,i.createDirectory)(r()) | ||
n("init output package.json") | ||
u("init output package.json") | ||
const p=require(t("package.json")) | ||
for(const e of s){delete p[e] | ||
u(`dropped key: ${e}`)}(0,e.writeFileSync)(r("package.json"),JSON.stringify(p)) | ||
n("init output file") | ||
n(`dropped key: ${e}`)}(0,e.writeFileSync)(r("package.json"),JSON.stringify(p)) | ||
u("init output file") | ||
for(const e of a){await o.modify.copy(t(e),r(e)) | ||
u(`copied: ${e}`)}return p}) | ||
exports.packOutput=(async({fromRoot:i,fromOutput:s,logger:{padLog:n,log:u}})=>{n("run pack output");(0,t.execSync)("npm pack",{cwd:s(),stdio:a.__VERBOSE__?"inherit":["ignore","ignore"],shell:!0}) | ||
u("move to root path") | ||
n(`copied: ${e}`)}return p}) | ||
exports.packOutput=(async({fromRoot:i,fromOutput:s,logger:{padLog:u,log:n}})=>{u("run pack output");(0,t.execSync)("npm pack",{cwd:s(),stdio:a.__VERBOSE__?"inherit":["ignore","ignore"],shell:!0}) | ||
n("move to root path") | ||
const p=require(s("package.json")) | ||
const c=`${p.name}-${p.version}.tgz` | ||
await o.modify.move(s(c),i(c)) | ||
n(`pack size: ${(0,r.binary)((0,e.statSync)(i(c)).size)}B`) | ||
u(`pack size: ${(0,r.binary)((0,e.statSync)(i(c)).size)}B`) | ||
return i(c)}) | ||
const n=e=>{const t=e.includes("publish-dev") | ||
const u=e=>{const t=e.includes("publish-dev") | ||
return{isPublish:t||e.includes("publish"),isDev:t}} | ||
exports.getPublishFlag=n | ||
const u=({isDev:e,version:t})=>e?c.test(t):p.test(t) | ||
exports.checkPublishVersion=u | ||
exports.getPublishFlag=u | ||
const n=({isDev:e,version:t})=>e?c.test(t):p.test(t) | ||
exports.checkPublishVersion=n | ||
const p=/^\d+\.\d+\.\d+$/ | ||
const c=/^\d+\.\d+\.\d+-dev\.\d+$/ | ||
exports.publishOutput=(async({flagList:e,packageJSON:t,pathPackagePack:r,extraArgs:i=[],logger:o})=>{const{isPublish:a,isDev:p}=n(e) | ||
exports.publishOutput=(async({flagList:e,packageJSON:t,pathPackagePack:r,extraArgs:i=[],logger:o})=>{const{isPublish:a,isDev:p}=u(e) | ||
if(!a)return o.padLog("skipped publish output, no flag found") | ||
if(!r||!r.endsWith(".tgz"))throw new Error(`[publishOutput] invalid pathPackagePack: ${r}`) | ||
if(!u({isDev:p,version:t.version}))throw new Error(`[publishOutput] invalid version: ${t.version}, isDev: ${p}`) | ||
if(!n({isDev:p,version:t.version}))throw new Error(`[publishOutput] invalid version: ${t.version}, isDev: ${p}`) | ||
o.padLog(`${p?"publish-dev":"publish"}: ${t.version}`);(0,s.runSync)({command:"npm",argList:["publish",r,"--tag",p?"dev":"latest",...i]})}) |
@@ -1,1 +0,1 @@ | ||
{"name":"dev-dep-tool","version":"0.2.1","author":"dr-js","license":"MIT","description":"Provide common package devDependencies","keywords":["Dr","Dr-js","JavaScript"],"repository":"https://github.com/dr-js/dev-dep.git","homepage":"https://github.com/dr-js/dev-dep#readme","bugs":"https://github.com/dr-js/dev-dep/issues","bin":"bin/index.js","dependencies":{"dr-js":"^0.14.0"},"sideEffects":false} | ||
{"name":"dev-dep-tool","version":"0.2.2-dev.0","author":"dr-js","license":"MIT","description":"Provide common package devDependencies","keywords":["Dr","Dr-js","JavaScript"],"repository":"github:dr-js/dev-dep","bin":"bin/index.js","engines":{"node":">=8.8","npm":">=5"},"dependencies":{"dr-js":"^0.14.0"},"sideEffects":false} |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
21765
324