* Add support for Azure DevOps and BitBucket * Remove `console.log` * Fix ESLint config - Fix the ESLint config - Fix all lint errors that cropped up as a result - Add scripts to lint - Add prettier format script - Add `husky` / `lint-staged` to lint/format files when they're pushed * Move provider configs to new file as requested * Fixes to meet maintainers specs * Fix remaining lint warns/errs * eslint fix * Update eslint/prettier packges Remove unused `@types/node-fetch` package * Add `eslint-plugin-jsdoc` * Add eslint rule for allowing providers to reassign params in their `replaceIcon` functions * Add sensible defaults for prettier to override any local editor settings * Some final cleanup * Loosen the required engines to allow for easier installing Co-authored-by: Claudio Santos <Claudiohbsantos@users.noreply.github.com>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
/**
|
|
* External depedencies
|
|
*/
|
|
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
const rimraf = require('rimraf');
|
|
const simpleGit = require('simple-git');
|
|
const { execSync } = require('child_process');
|
|
|
|
/**
|
|
* Internal depedencies
|
|
*/
|
|
const srcPath = path.resolve(__dirname, '..', 'src');
|
|
const vsExtPath = path.resolve(__dirname, '..', 'temp');
|
|
const destSVGPath = path.resolve(__dirname, '..', 'svg');
|
|
const commitLockPath = path.resolve(__dirname, '..', 'upstream.commit');
|
|
|
|
const vsExtExecOptions = {
|
|
cwd: vsExtPath,
|
|
stdio: 'inherit',
|
|
};
|
|
const distIconsExecOptions = {
|
|
cwd: path.resolve(destSVGPath),
|
|
stdio: 'inherit',
|
|
};
|
|
|
|
async function main() {
|
|
rimraf.sync(vsExtPath);
|
|
rimraf.sync(destSVGPath);
|
|
await fs.ensureDir(destSVGPath);
|
|
|
|
console.log('[1/7] Cloning PKief/vscode-material-icon-theme into temporary cache.');
|
|
const git = simpleGit();
|
|
await git.clone(`https://github.com/PKief/vscode-material-icon-theme.git`, vsExtPath, [
|
|
'--depth',
|
|
'100', // fetch only last 100 commits. Guesswork, could be too shallow if upstream doesnt release often
|
|
]);
|
|
|
|
const commit = fs.readFileSync(commitLockPath, { encoding: 'utf8' })?.trim();
|
|
console.log('Checking out to upstream commit:', commit);
|
|
const upstreamGit = simpleGit(vsExtPath);
|
|
await upstreamGit.checkout(commit, ['--force']);
|
|
|
|
console.log('[2/7] Terminate Git repository in temporary cache.');
|
|
rimraf.sync(path.resolve(vsExtPath, '.git'));
|
|
|
|
console.log('[3/7] Install NPM dependencies for VSC extension.');
|
|
execSync(`npm install --ignore-scripts`, vsExtExecOptions);
|
|
|
|
console.log('[4/7] Terminate Git tracking in temporary cache.');
|
|
await fs.copy(path.resolve(vsExtPath, 'icons'), path.resolve(destSVGPath));
|
|
|
|
console.log('[5/7] Optimise extension icons using SVGO.');
|
|
execSync(`npx svgo -r .`, distIconsExecOptions);
|
|
|
|
console.log('[6/7] Run build tasks for VSC extension.');
|
|
execSync(`npm run build`, vsExtExecOptions);
|
|
|
|
console.log('[7/7] Copy file icon configuration to source code directory.');
|
|
await fs.copy(
|
|
path.resolve(vsExtPath, 'dist', 'material-icons.json'),
|
|
path.resolve(srcPath, 'icon-map.json')
|
|
);
|
|
|
|
rimraf.sync(vsExtPath);
|
|
}
|
|
|
|
main();
|