mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
# Conflicts: # .circleci/config.yml # docs/generators/changelog/script.js # docs/history.md # meteor # npm-packages/babel-preset-meteor/package.json # npm-packages/cordova-plugin-meteor-webapp/package.json # npm-packages/eslint-plugin-meteor/scripts/dev-bundle-tool-package.js # npm-packages/meteor-babel/package-lock.json # npm-packages/meteor-babel/package.json # package-lock.json # package.json # packages/accounts-base/accounts_server.js # packages/accounts-base/package.js # packages/accounts-oauth/package.js # packages/accounts-password/package.js # packages/accounts-password/password_server.js # packages/accounts-passwordless/package.js # packages/accounts-passwordless/passwordless_server.js # packages/babel-compiler/.npm/package/npm-shrinkwrap.json # packages/babel-compiler/package.js # packages/boilerplate-generator/package.js # packages/browser-policy-content/package.js # packages/constraint-solver/catalog-loader.js # packages/constraint-solver/constraint-solver-input.js # packages/constraint-solver/constraint-solver-tests.js # packages/constraint-solver/constraint-solver.js # packages/constraint-solver/package.js # packages/constraint-solver/solver.js # packages/crosswalk/package.js # packages/ddp-rate-limiter/package.js # packages/ddp-server/package.js # packages/ecmascript/package.js # packages/facebook-oauth/package.js # packages/fetch/package.js # packages/launch-screen/package.js # packages/logging/package.js # packages/logic-solver/logic_tests.js # packages/logic-solver/package.js # packages/meteor-tool/package.js # packages/meteor/package.js # packages/mobile-experience/package.js # packages/modern-browsers/package.js # packages/modules/.npm/package/npm-shrinkwrap.json # packages/modules/package.js # packages/mongo/package.js # packages/non-core/blaze # packages/npm-mongo/.npm/package/npm-shrinkwrap.json # packages/npm-mongo/package.js # packages/oauth/package.js # packages/oauth/pending_credentials.js # packages/package-version-parser/package.js # packages/react-fast-refresh/package.js # packages/service-configuration/package.js # packages/socket-stream-client/.npm/package/npm-shrinkwrap.json # packages/socket-stream-client/package.js # packages/standard-minifier-css/.npm/plugin/minifyStdCSS/npm-shrinkwrap.json # packages/standard-minifier-css/package.js # packages/test-in-browser/package.js # packages/test-in-console/package.js # packages/test-in-console/reporter.js # packages/tinytest/package.js # packages/tracker/package.js # packages/typescript/package.js # packages/webapp/.npm/package/npm-shrinkwrap.json # packages/webapp/package.js # scripts/admin/meteor-release-experimental.json # scripts/build-dev-bundle-common.sh # scripts/dev-bundle-server-package.js # scripts/dev-bundle-tool-package.js # tools/cli/commands.js # tools/fs/files.ts # tools/runners/run-all.js # tools/static-assets/skel-chakra-ui/package.json # tools/tests/apps/dynamic-import/.meteor/packages # tools/tests/apps/dynamic-import/package.json
111 lines
3.6 KiB
JavaScript
Executable File
111 lines
3.6 KiB
JavaScript
Executable File
const _fs = require("fs");
|
|
const fs = _fs.promises;
|
|
function getPackageVersion(packageName) {
|
|
function getFile(path) {
|
|
try {
|
|
const data = _fs.readFileSync(path, "utf8");
|
|
return [data, null];
|
|
} catch (e) {
|
|
console.error(e);
|
|
return ["", e];
|
|
}
|
|
}
|
|
|
|
const [code, error] = getFile(`../packages/${packageName}/package.js`);
|
|
if (error) return "";
|
|
for (const line of code.split(/\n/)) {
|
|
// verify if the line has a version
|
|
if (!line.includes("version:")) continue;
|
|
|
|
//Package.describe({
|
|
// summary: 'some description.',
|
|
// version: '1.2.3' <--- this is the line we want, we assure that it has a version in the previous if
|
|
//});
|
|
const [_, versionValue] = line.split(":");
|
|
if (!versionValue) continue;
|
|
const removeQuotes = (v) =>
|
|
v.trim().replace(",", "").replace(/'/g, "").replace(/"/g, "");
|
|
if (versionValue.includes("-"))
|
|
return removeQuotes(versionValue.split("-")[0]);
|
|
return removeQuotes(versionValue);
|
|
}
|
|
}
|
|
|
|
const main = async () => {
|
|
try {
|
|
console.log("started concatenating files");
|
|
const files = await fs.readdir("./generators/changelog/versions", "utf8");
|
|
const filesStream = files
|
|
.map((file) => {
|
|
console.log(`reading file: ${file}`);
|
|
return {
|
|
fileName: file,
|
|
buf: fs.readFile(`./generators/changelog/versions/${file}`, "utf8"),
|
|
};
|
|
})
|
|
.map(async ({ buf, fileName }, index) => {
|
|
// first file we don't do anything
|
|
// Big file and does not follow the new standard
|
|
if (index === 0) return buf;
|
|
const content = (await buf).toString();
|
|
/**
|
|
* @type {Set<string>}
|
|
*/
|
|
const contribuitors = new Set();
|
|
|
|
// DSL Replacers
|
|
// [PR #123] -> [PR #123](https://github.com/meteor/meteor/pull/123)
|
|
// [GH meteor/meteor] -> [meteor/meteor](https://github.com/meteor/meteor)
|
|
// package-name@get-version -> package-name@1.3.3
|
|
|
|
const file = content
|
|
.replace(
|
|
/\[PR #(\d+)\]/g,
|
|
(_, number) =>
|
|
`[PR](https://github.com/meteor/meteor/pull/${number})`
|
|
)
|
|
.replace(/\[GH ([^\]]+)\]/g, (_, name) => {
|
|
contribuitors.add(name);
|
|
return `[${name}](https://github.com/${name})`;
|
|
})
|
|
.replace(
|
|
/([a-z0-9-]+)@get-version/g,
|
|
(_, name) => `${name}@${getPackageVersion(name)}`
|
|
);
|
|
|
|
// already have the contribuitors thanks in the file
|
|
if (
|
|
file.includes('## Contributors') ||
|
|
file.includes("#### Special thanks to") || // this must stay here for legacy reasons
|
|
file.includes("[//]: # (Do not edit this file by hand.)")
|
|
)
|
|
return file;
|
|
|
|
// add the contribuitors
|
|
const contribuitorsList = Array.from(contribuitors)
|
|
.map((name) => `- [@${name}](https://github.com/${name}).`)
|
|
.join("\n");
|
|
|
|
const doneFile = `${file}\n\n## Contributors\n\n${contribuitorsList}\n\n`;
|
|
|
|
//SIDE EFFECTS
|
|
// so that this is not ran every time, we will update the last file.
|
|
// this is for the expensive part of the script
|
|
if (index === files.length - 2)
|
|
await fs.writeFile(
|
|
`./generators/changelog/versions/${fileName}`,
|
|
doneFile
|
|
);
|
|
return doneFile;
|
|
})
|
|
.reverse();
|
|
console.log("Giving some touches to the files");
|
|
const filesContent = await Promise.all(filesStream);
|
|
await fs.writeFile("./history.md", filesContent.join(""));
|
|
console.log("Finished :)");
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
};
|
|
main().then((_) => _);
|