* added dotenv dev dependency, to prevent being dependent on IDE to set env variables * added biomejs to dev dependencies, was missing * fixed custom domains not working after ts conversion * fixed a bug where you could not add multiple custom domains, because the script was trying to register multiple content scripts with same id
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import 'dotenv/config';
|
|
import * as path from 'path';
|
|
import * as fs from 'fs/promises';
|
|
|
|
/**
|
|
* Gets latest VSCode Extension release version by parsing its most recent 100 commit msgs
|
|
*
|
|
* @returns {Promise<string>} The current version of the upstream repository.
|
|
*/
|
|
const getUpstreamVersion = async (): Promise<string> => {
|
|
const packagePath: string = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'node_modules',
|
|
'material-icon-theme',
|
|
'package.json'
|
|
);
|
|
const packageData: string = await fs.readFile(packagePath, {
|
|
encoding: 'utf8',
|
|
});
|
|
const packageJson = JSON.parse(packageData);
|
|
return packageJson.version;
|
|
};
|
|
|
|
/**
|
|
* Updates the version badge in the README file.
|
|
*
|
|
* @param {string} version - The new version to update the badge to.
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const updateReadmeBadge = async (version: string): Promise<void> => {
|
|
const readmeFilePath: string = path.resolve(__dirname, '..', 'README.md');
|
|
const readme: string = await fs.readFile(readmeFilePath, {
|
|
encoding: 'utf8',
|
|
});
|
|
const versionRgx: RegExp = /(badge\/[\w_]+-v)\d+\.\d+\.\d+/;
|
|
const replacement: string = `$1${version}`;
|
|
const updatedReadme: string = readme.replace(versionRgx, replacement);
|
|
|
|
await fs.writeFile(readmeFilePath, updatedReadme);
|
|
};
|
|
|
|
/**
|
|
* Main function to run the update process.
|
|
*/
|
|
const run = async (): Promise<void> => {
|
|
const latestVersion: string = await getUpstreamVersion();
|
|
await updateReadmeBadge(latestVersion);
|
|
};
|
|
|
|
run().catch(console.error);
|