UNPKG

2.04 kBJavaScriptView Raw
1Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib"),a=e.__importDefault(require("listr")),i=require("lodash"),t=require("path"),s=require("semver"),n=require("@navch/cli-utils");exports.publishToNpm=new a.default(n.makeTasks({title:"Fetching packages release info from NPM",task:({ws:a})=>e.__awaiter(this,void 0,void 0,function*(){const e=yield a.getPackages(),i=e.map(e=>e.packageName);return{packages:e,packageInfoMap:yield a.switchToNpm().getPackagesInfo(i)}})},{title:"Verifying packages to be published",task:({canary:a,packages:i,packageInfoMap:c})=>e.__awaiter(this,void 0,void 0,function*(){const e=[];for(const{packageName:o,packagePath:r}of i){const i=c.get(o),p=new n.Package(t.join(r,"npm")),{version:g}=yield p.readPackageJSON();if(i&&i.versions.includes(g)&&e.push(o),!a&&i&&s.compare(i.version,g)>0)throw new Error(n.theme`{package ${o}} {version ${g}} `+n.theme`is lower than the latest published version in NPM.`)}return{publishedPackages:e}})},{title:"Publishing packages to NPM",task:({ws:i,publishedPackages:s})=>e.__awaiter(this,void 0,void 0,function*(){const c=(yield i.getPackages()).map(({packageName:a,packagePath:i})=>({title:n.theme`Publishing {package ${a}}`,skip:()=>!!s.includes(a)&&"already published!",task:()=>e.__awaiter(this,void 0,void 0,function*(){const e=new n.Package(t.join(i,"npm"));yield e.exec("npm publish --access public")})}));return new a.default(c,{concurrent:!0})})},{title:"Tagging packages to published version",skip:({dry:e,tags:a})=>e?"Dry run!":!!i.isEmpty(a)&&"No tags!",task:({ws:s,tags:c})=>e.__awaiter(this,void 0,void 0,function*(){const o=(yield s.getPackages()).map(({packageName:a,packagePath:i})=>c.map(c=>({title:n.theme`Tagging {package ${a}@${c}}`,task:()=>e.__awaiter(this,void 0,void 0,function*(){const e=new n.Package(t.join(i,"npm")),{version:o}=yield e.readPackageJSON(),r=`${a}@${o}`;yield s.exec(`npm dist-tag add ${r} ${c}`)})})));return new a.default(i.flatten(o),{concurrent:!0})})}));
2//# sourceMappingURL=publish-to-npm.js.map
\No newline at end of file