chore: added @all for updater

This commit is contained in:
Gabriel Grubba
2022-11-04 10:40:35 -03:00
parent c68af6205f
commit dbfa7abf82

View File

@@ -7,6 +7,7 @@
const semver = require('semver');
const fs = require('fs');
const { exec } = require("child_process");
const { readdir } = require("fs/promises");
const runCommand = async (command) => {
return new Promise((resolve, reject) => {
@@ -45,12 +46,23 @@ async function getFile(path) {
}
const getDirectories = async source =>
(await readdir(source, { withFileTypes: true }))
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
async function main() {
/**
* @type {string[]}
*/
let args = process.argv.slice(2);
if (args[0].startsWith('@all')) {
const [_, type] = args[0].split('.');
const allPackages = await getDirectories('../../../packages');
args = allPackages.map((packageName) => `${ packageName }.${ type }`);
}
if (args[0].startsWith('@auto')) {
const [_, type] = args[0].split('.');
// List of packages that for some reason are not in the diff.
@@ -92,6 +104,7 @@ async function main() {
// 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 currentVersion = versionValue
.trim()
.replace(',', '')
@@ -113,7 +126,7 @@ async function main() {
const newVersion = incrementNewVersion(release);
console.log(`Updating ${ name } from ${ currentVersion } to ${ newVersion }`);
const newCode = code.replace(currentVersion, "'" + newVersion + "'");
const newCode = code.replace(currentVersion, `${ newVersion }`);
await fs.promises.writeFile(filePath, newCode);
}
}