Added updated admin scripts needed for dist build (#789).

This commit is contained in:
Richard Moore 2020-04-18 05:23:36 -04:00
parent 4874419119
commit 3135d7ff6c
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
4 changed files with 34 additions and 46 deletions

@ -49,13 +49,6 @@ function run(progname, args, ignoreErrorStream) {
}
function setupConfig(outDir, moduleType, targetType) {
function update(value) {
let comps = value.split("/");
if (comps.length >= 3 && comps[0] === "." && comps[1].match(/^lib(\.esm)?$/)) {
return outDir + comps.slice(2).join("/");
}
return value;
}
// Configure the tsconfit.package.json...
const path = resolve(__dirname, "../tsconfig.package.json");
@ -64,22 +57,24 @@ function setupConfig(outDir, moduleType, targetType) {
content.compilerOptions.target = targetType;
saveJson(path, content);
// Configure the browser field for every pacakge, copying the
// browser.umd filed for UMD and browser.esm for ESM
dirnames.forEach((dirname) => {
let info = loadPackage(dirname);
if (info._ethers_nobuild) { return; }
[ "browser", "_browser" ].forEach((key) => {
if (info[key]) {
if (typeof(info[key]) === "string") {
info[key] = update(info[key]);
} else {
for (let k in info[key]) {
info[key][k] = update(info[key][k]);
}
}
if (targetType === "es2015") {
if (info["browser.esm"]) {
info.browser = info["browser.esm"];
}
});
} else if (targetType === "es5") {
if (info["browser.umd"]) {
info.browser = info["browser.umd"];
}
} else {
throw new Error("unsupported target");
}
savePackage(dirname, info);
let path = resolve(__dirname, "../packages", dirname, "tsconfig.json");

@ -108,7 +108,7 @@ if (process.argv.length > 2) {
// Publish the release
const link = await createRelease(username, password, change.version, change.title, change.content, beta);
log(`<bold:Published Release:> ${ link }...`);
log(`<bold:Published Release:> ${ link }`);
}
})();

@ -4,39 +4,32 @@ const { loadPackage, savePackage } = require("../local");
const arg = process.argv[2];
(async function() {
switch(arg) {
case "esm":
setupBuild(true);
break;
process.argv.slice(2).forEach((arg) => {
console.log("Setting Option:", arg);
switch(arg) {
case "esm":
setupBuild(true);
break;
case "cjs":
setupBuild(false);
break;
case "cjs":
setupBuild(false);
break;
case "browser-lang-en": {
const info = loadPackage("wordlists");
if (info._browser) {
info.browser = info._browser;
delete info._browser;
savePackage("wordlists", info);
}
break;
}
case "browser-lang-all": {
const info = loadPackage("wordlists");
if (info.browser) {
info._browser = info.browser;
// This will remove the browser field entirely, so make sure
// to set esm of cjs first as they will restore the browser
// field
case "browser-lang-all": {
const info = loadPackage("wordlists");
delete info.browser;
savePackage("wordlists", info);
break;
}
break;
}
default:
console.log("unknown option");
return 1;
}
default:
console.log("unknown option");
return 1;
}
});
return 0;
})().then((result) => {

@ -107,7 +107,7 @@ async function fetchGitHub(user, password, url, cacheOnly) {
async function _getIssues(user, password) {
const cacheOnly = (user == null);
let issues = await fetchGitHub(user, password, "https://api.github.com/repos/ethers-io/ethers.js/issues?state=all&per_page=100", cacheOnly)
let issues = await fetchGitHub(user, password, "https:/\/api.github.com/repos/ethers-io/ethers.js/issues?state=all&per_page=100", cacheOnly)
if (!cacheOnly) { console.log(`Found ${ issues.length } issues`); }
const result = [ ];
for (let i = 0; i < issues.length; i++) {