Skip to content

Commit

Permalink
admin: updated dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 16, 2021
1 parent 8f3d71d commit 73a46ef
Show file tree
Hide file tree
Showing 538 changed files with 4,531 additions and 5,516 deletions.
16 changes: 8 additions & 8 deletions misc/admin/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ const path_1 = require("./path");
const utils_1 = require("./utils");
function setupConfig(outDir, moduleType, targetType) {
// Configure the tsconfit.package.json...
const path = path_1.resolve("tsconfig.package.json");
const content = utils_1.loadJson(path);
const path = (0, path_1.resolve)("tsconfig.package.json");
const content = (0, utils_1.loadJson)(path);
content.compilerOptions.module = moduleType;
content.compilerOptions.target = targetType;
utils_1.saveJson(path, content, true);
(0, utils_1.saveJson)(path, content, true);
// Configure the browser field for every pacakge, copying the
// browser.umd filed for UMD and browser.esm for ESM
path_1.dirnames.forEach((dirname) => {
const filename = path_1.getPackageJsonPath(dirname);
const info = utils_1.loadJson(filename);
const filename = (0, path_1.getPackageJsonPath)(dirname);
const info = (0, utils_1.loadJson)(filename);
if (info._ethers_nobuild) {
return;
}
let path = path_1.resolve("packages", dirname, "tsconfig.json");
let content = utils_1.loadJson(path);
let path = (0, path_1.resolve)("packages", dirname, "tsconfig.json");
let content = (0, utils_1.loadJson)(path);
content.compilerOptions.outDir = outDir;
utils_1.saveJson(path, content, true);
(0, utils_1.saveJson)(path, content, true);
});
}
function setupBuild(buildModule) {
Expand Down
14 changes: 7 additions & 7 deletions misc/admin/lib/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const npm = __importStar(require("./npm"));
const path_1 = require("./path");
const run_1 = require("./run");
const utils_1 = require("./utils");
const changelogPath = path_1.resolve("CHANGELOG.md");
const changelogPath = (0, path_1.resolve)("CHANGELOG.md");
function generate() {
return __awaiter(this, void 0, void 0, function* () {
const lines = fs_1.default.readFileSync(changelogPath).toString().trim().split("\n");
Expand All @@ -59,11 +59,11 @@ function generate() {
const published = yield npm.getPackage("ethers");
if (versions.indexOf(version) >= 0) {
const line = `Version ${version} already in CHANGELOG. Please edit before committing.`;
console.log(log_1.colorify.red(utils_1.repeat("=", line.length)));
console.log(log_1.colorify.red((0, utils_1.repeat)("=", line.length)));
console.log(log_1.colorify.red(line));
console.log(log_1.colorify.red(utils_1.repeat("=", line.length)));
console.log(log_1.colorify.red((0, utils_1.repeat)("=", line.length)));
}
const gitResult = yield run_1.run("git", ["log", (published.gitHead + "..")]);
const gitResult = yield (0, run_1.run)("git", ["log", (published.gitHead + "..")]);
if (!gitResult.ok) {
console.log(gitResult);
throw new Error("Error running git log");
Expand All @@ -78,7 +78,7 @@ function generate() {
});
}
else if (line.toLowerCase().substring(0, 5) === "date:") {
changes[changes.length - 1].date = utils_1.getDateTime(new Date(line.substring(5).trim()));
changes[changes.length - 1].date = (0, utils_1.getDateTime)(new Date(line.substring(5).trim()));
}
else if (line.substring(0, 1) === " ") {
line = line.trim();
Expand All @@ -92,9 +92,9 @@ function generate() {
for (let i = 0; i < firstLine; i++) {
output.push(lines[i]);
}
const newTitle = `ethers/v${version} (${utils_1.getDateTime(new Date())})`;
const newTitle = `ethers/v${version} (${(0, utils_1.getDateTime)(new Date())})`;
output.push(newTitle);
output.push(utils_1.repeat("-", newTitle.length));
output.push((0, utils_1.repeat)("-", newTitle.length));
output.push("");
changes.forEach((change) => {
let body = change.body.trim();
Expand Down
2 changes: 1 addition & 1 deletion misc/admin/lib/cmds/bump-minor-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const path_1 = require("../path");
accum[name] = version;
return accum;
}, {});
const packageJsonPath = path_1.getPackageJsonPath(dirname);
const packageJsonPath = (0, path_1.getPackageJsonPath)(dirname);
local.updateJson(packageJsonPath, {
dependencies: deps,
version: newVersion
Expand Down
16 changes: 8 additions & 8 deletions misc/admin/lib/cmds/bump-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ const npm = __importStar(require("../npm"));
const utils_1 = require("../utils");
(function () {
return __awaiter(this, void 0, void 0, function* () {
const common = utils_1.loadJson(path_1.resolve("package.json")).common;
const progress = log_1.getProgressBar(log_1.colorify.bold("Bumping package.json versions"));
const common = (0, utils_1.loadJson)((0, path_1.resolve)("package.json")).common;
const progress = (0, log_1.getProgressBar)(log_1.colorify.bold("Bumping package.json versions"));
const latestVersions = {};
let updated = false;
const output = [];
// For each package, detect diff between tarball and remote
for (let i = 0; i < path_1.dirnames.length; i++) {
progress(i / path_1.dirnames.length);
const dirname = path_1.dirnames[i];
const packageJsonPath = path_1.getPackageJsonPath(dirname);
const packageJsonPath = (0, path_1.getPackageJsonPath)(dirname);
// Set the common elements to the package.json
local.updateJson(packageJsonPath, common, true);
const pLocal = local.getPackage(dirname);
Expand All @@ -68,7 +68,7 @@ const utils_1 = require("../utils");
output.push([
" ",
log_1.colorify.blue(pLocal.name),
utils_1.repeat(" ", 47 - pLocal.name.length - pNpm.version.length),
(0, utils_1.repeat)(" ", 47 - pLocal.name.length - pNpm.version.length),
pNpm.version,
log_1.colorify.bold(" => "),
log_1.colorify.green(version)
Expand All @@ -80,21 +80,21 @@ const utils_1 = require("../utils");
// Write out the _version.ts
if (!pLocal._ethers_nobuild) {
const code = "export const version = " + JSON.stringify(dirname + "/" + version) + ";\n";
fs_1.default.writeFileSync(path_1.resolve(path_1.getPackagePath(dirname), "src.ts/_version.ts"), code);
fs_1.default.writeFileSync((0, path_1.resolve)((0, path_1.getPackagePath)(dirname), "src.ts/_version.ts"), code);
}
}
progress(1);
if (updated) {
const filename = path_1.resolve("packages/ethers/package.json");
const info = utils_1.loadJson(filename);
const filename = (0, path_1.resolve)("packages/ethers/package.json");
const info = (0, utils_1.loadJson)(filename);
Object.keys(info.dependencies).forEach((name) => {
const version = latestVersions[name];
if (name == null) {
return;
}
info.dependencies[name] = version;
});
utils_1.saveJson(filename, info);
(0, utils_1.saveJson)(filename, info);
}
output.forEach((line) => { console.log(line); });
});
Expand Down
20 changes: 10 additions & 10 deletions misc/admin/lib/cmds/bundle-testcases.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const config = {
console.log(log_1.colorify.bold(`Bundling Testcase Data...`));
const data = { "_": JSON.stringify({ name: "browser-fs", config: config }) };
config.dirs.forEach((dirname) => {
let fulldirname = path_2.resolve("packages/testcases", dirname);
let fulldirname = (0, path_2.resolve)("packages/testcases", dirname);
fs_1.default.readdirSync(fulldirname).forEach((filename) => {
const key = path_1.join(dirname, filename);
const content = fs_1.default.readFileSync(path_1.join(fulldirname, filename));
const key = (0, path_1.join)(dirname, filename);
const content = fs_1.default.readFileSync((0, path_1.join)(fulldirname, filename));
if (filename.split(".").pop() === "gz") {
const contentData = zlib_1.default.gunzipSync(content);
data[key] = String(contentData.length) + "," + zlib_1.default.deflateRawSync(contentData).toString("base64");
Expand All @@ -52,15 +52,15 @@ const config = {
//console.log(` - Added ${ key } (${ data[key].length } bytes)`);
});
});
utils_1.mkdir(path_2.resolve("packages/testcases/lib"));
utils_1.mkdir(path_2.resolve("packages/testcases/lib._esm"));
utils_1.mkdir(path_2.resolve("packages/testcases/lib.esm"));
(0, utils_1.mkdir)((0, path_2.resolve)("packages/testcases/lib"));
(0, utils_1.mkdir)((0, path_2.resolve)("packages/testcases/lib._esm"));
(0, utils_1.mkdir)((0, path_2.resolve)("packages/testcases/lib.esm"));
// We write it out to all needed places
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib._esm/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/lib.esm/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync((0, path_2.resolve)("packages/testcases/lib/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync((0, path_2.resolve)("packages/testcases/lib._esm/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync((0, path_2.resolve)("packages/testcases/lib.esm/browser-data.json"), JSON.stringify(data));
// Write it to the TypeScript source last, in case it is running it will
// be regenerated overwriting the above files, but with identical content
fs_1.default.writeFileSync(path_2.resolve("packages/testcases/src.ts/browser-data.json"), JSON.stringify(data));
fs_1.default.writeFileSync((0, path_2.resolve)("packages/testcases/src.ts/browser-data.json"), JSON.stringify(data));
});
})();
2 changes: 1 addition & 1 deletion misc/admin/lib/cmds/cache-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const github_1 = require("../github");
return __awaiter(this, void 0, void 0, function* () {
const user = yield config_1.config.get("github-user");
const password = yield config_1.config.get("github-readonly");
yield github_1.syncIssues(user, password);
yield (0, github_1.syncIssues)(user, password);
});
})();
26 changes: 13 additions & 13 deletions misc/admin/lib/cmds/esm-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const log_1 = require("../log");
function alias(name) {
return __awaiter(this, void 0, void 0, function* () {
console.log(` Aliasing: ${name}`);
const baseDir = path_2.resolve("packages", name);
const info = utils_1.loadJson(path_2.resolve(baseDir, "package.json"));
const baseDir = (0, path_2.resolve)("packages", name);
const info = (0, utils_1.loadJson)((0, path_2.resolve)(baseDir, "package.json"));
const replacements = info["_ethers.alias"] || {};
const skip = Object.keys(replacements).reduce((accum, key) => {
const replace = replacements[key];
Expand All @@ -37,10 +37,10 @@ function alias(name) {
}, ({}));
const transforms = [];
const recurse = function (input, output) {
fs_1.default.readdirSync(path_1.join(baseDir, input)).forEach((filename) => {
const stat = fs_1.default.statSync(path_1.join(baseDir, input, filename));
fs_1.default.readdirSync((0, path_1.join)(baseDir, input)).forEach((filename) => {
const stat = fs_1.default.statSync((0, path_1.join)(baseDir, input, filename));
if (stat.isDirectory()) {
recurse(path_1.join(input, filename), path_1.join(output, filename));
recurse((0, path_1.join)(input, filename), (0, path_1.join)(output, filename));
return;
}
if (skip[filename]) {
Expand All @@ -61,7 +61,7 @@ function alias(name) {
if (replace) {
inputFilename = replace;
transform = function (content) {
content = content.replace(/(\/\/# sourceMappingURL=)(.*)$/g, (all, prefix, mapFilename) => {
content = content.replace(/^(\/\/# sourceMappingURL=)(.*)$/mg, (all, prefix, mapFilename) => {
return prefix + filename + ".map";
});
return content;
Expand Down Expand Up @@ -118,29 +118,29 @@ function alias(name) {
};
}
}
transforms.push({ input: path_1.join(input, inputFilename), output: path_1.join(output, filename), transform });
transforms.push({ input: (0, path_1.join)(input, inputFilename), output: (0, path_1.join)(output, filename), transform });
});
};
recurse("lib._esm", "lib.esm");
transforms.forEach(({ input, output, transform }) => {
const sourceFile = path_1.join(baseDir, input);
const sourceFile = (0, path_1.join)(baseDir, input);
let content = fs_1.default.readFileSync(sourceFile).toString();
if (transform) {
content = transform(content);
}
const targetFile = path_1.join(baseDir, output);
const targetDir = path_1.dirname(targetFile);
utils_1.mkdir(targetDir);
const targetFile = (0, path_1.join)(baseDir, output);
const targetDir = (0, path_1.dirname)(targetFile);
(0, utils_1.mkdir)(targetDir);
fs_1.default.writeFileSync(targetFile, content);
});
});
}
(function () {
return __awaiter(this, void 0, void 0, function* () {
console.log(log_1.colorify.bold(`Aliasing Node ESM to Browser ESM...`));
const dirnames = depgraph_1.getOrdered(true);
const dirnames = (0, depgraph_1.getOrdered)(true);
for (let i = 0; i < dirnames.length; i++) {
//if (dirnames[i] !== "base64") { continue; }
//if (dirnames[i] !== "signing-key") { continue; }
yield alias(dirnames[i]);
}
});
Expand Down
6 changes: 3 additions & 3 deletions misc/admin/lib/cmds/hoist.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const local_1 = require("../local");
const log_1 = require("../log");
(function () {
return __awaiter(this, void 0, void 0, function* () {
const dependencies = local_1.getDependencies(null, (name) => {
return !path_1.isEthers(name);
const dependencies = (0, local_1.getDependencies)(null, (name) => {
return !(0, path_1.isEthers)(name);
});
console.log(log_1.colorify.bold(`Hoisting ${Object.keys(dependencies).length} dependencies into root package...`));
local_1.updateJson(path_1.dirs.rootPackageJsonPath, { dependencies });
(0, local_1.updateJson)(path_1.dirs.rootPackageJsonPath, { dependencies });
});
})().catch((error) => {
console.log(`Error running ${process.argv[0]}: ${error.message}`);
Expand Down
20 changes: 10 additions & 10 deletions misc/admin/lib/cmds/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ function link(existing, path) {
}
}
// Link
const dir = path_1.dirname(path);
utils_1.mkdir(dir);
const dir = (0, path_1.dirname)(path);
(0, utils_1.mkdir)(dir);
fs_1.default.symlinkSync(existing, path, "junction");
}
(function () {
return __awaiter(this, void 0, void 0, function* () {
console.log(log_1.colorify.bold(`Linking ${path_2.packages.length} package node_modules rat nests...`));
const nodeModulesBase = path_1.resolve(path_2.dirs.root, ".package_node_modules");
const nodeModulesBase = (0, path_1.resolve)(path_2.dirs.root, ".package_node_modules");
// Make a symlink in the ROOT/node_mpdules to each package in this repo
path_2.packages.forEach((name) => {
// e.g. /node_modules/@ethersproject/abi => /packages/abi
link(path_2.getPackagePath(name), path_1.resolve(path_2.dirs.root, "node_modules", name));
link((0, path_2.getPackagePath)(name), (0, path_1.resolve)(path_2.dirs.root, "node_modules", name));
// e.g. /packages/abi/node_modules => /.package_node_modules/abi/
const nodeModules = path_1.resolve(nodeModulesBase, path_2.getDirname(name));
utils_1.mkdir(nodeModules);
link(nodeModules, path_1.resolve(path_2.getPackagePath(name), "node_modules"));
const nodeModules = (0, path_1.resolve)(nodeModulesBase, (0, path_2.getDirname)(name));
(0, utils_1.mkdir)(nodeModules);
link(nodeModules, (0, path_1.resolve)((0, path_2.getPackagePath)(name), "node_modules"));
});
path_2.packages.forEach((name) => {
const nodeModules = path_1.resolve(nodeModulesBase, path_2.getDirname(name));
const deps = local_1.getDependencies(name);
const nodeModules = (0, path_1.resolve)(nodeModulesBase, (0, path_2.getDirname)(name));
const deps = (0, local_1.getDependencies)(name);
Object.keys(deps).forEach((name) => {
link(path_1.resolve(path_2.dirs.root, "node_modules", name), path_1.resolve(nodeModules, name));
link((0, path_1.resolve)(path_2.dirs.root, "node_modules", name), (0, path_1.resolve)(nodeModules, name));
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions misc/admin/lib/cmds/lock-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const utils_1 = require("../utils");
(function () {
return __awaiter(this, void 0, void 0, function* () {
const versions = path_1.dirnames.reduce((accum, dirname) => {
const pkg = local_1.getPackage(dirname);
const pkg = (0, local_1.getPackage)(dirname);
accum[pkg.name] = pkg.version;
return accum;
}, ({}));
Expand All @@ -25,8 +25,8 @@ const utils_1 = require("../utils");
return;
}
console.log(dirname);
const path = path_1.resolve("packages", dirname, "package.json");
const json = utils_1.loadJson(path);
const path = (0, path_1.resolve)("packages", dirname, "package.json");
const json = (0, utils_1.loadJson)(path);
for (const name in (json.dependencies || {})) {
const version = json.dependencies[name];
const target = (versions[name] ? ("^" + versions[name]) : version);
Expand All @@ -35,7 +35,7 @@ const utils_1 = require("../utils");
}
json.dependencies[name] = target;
}
utils_1.saveJson(path, json, true);
(0, utils_1.saveJson)(path, json, true);
});
});
})();
Loading

0 comments on commit 73a46ef

Please sign in to comment.