Skip to content

Commit

Permalink
grep
Browse files Browse the repository at this point in the history
  • Loading branch information
milankomaj authored Aug 2, 2024
1 parent bd60a54 commit a1cff21
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 91 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ jobs:
- name: E-build
id: esbuild
run: |
sed /import SVGO from 'svgo';/d' ${{ github.workspace }}/updater.js
npm run E-build
grep -w -v "import SVGO from 'svgo';" ${{ github.workspace }}/updater.js | npm run E-build
rm -r ${{ github.workspace }}/node_modules
node ./dist/esbuild_updater.js ${{github.repository_owner}} -info
ls -slh ${{ github.workspace }}/dist
Expand Down
178 changes: 89 additions & 89 deletions updater.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
import { readFileSync, writeFileSync } from 'fs';
import handlebars from 'handlebars';
import GithubUser from './src/github.js';
import SVGO from 'svgo';
// import nunjucks from 'nunjucks';
//* nunjucks.configure({ autoescape: true });
// import { networkInterfaces } from 'os';
// console.log("✅ networkInterfaces:", networkInterfaces)
// console.log("✅ process.env:", process.env)
// console.log("✅ process.argv:", process.argv)
console.log("✅ process.env.CI:", process.env.CI)
const args = process.argv.slice(2); //🔶 Remove node and script paths
const argSvgo = String(args.includes('-svgo'));
const useSvgo = argSvgo ? argSvgo : ''; //
console.info("✅ useSvgo:", useSvgo)

let username = process.argv[2];
let user = new GithubUser(username);

let templateOverview = readFileSync("templates/overview.svg", 'utf-8');
let templateLanguages = readFileSync("templates/languages.svg", 'utf-8');

user.fetchContent()
.then(() => {
let overviewTemplate = handlebars.compile(templateOverview);
let overviewString = overviewTemplate({ data: user })


// Optimize overview SVG
if (useSvgo === 'true') {
overviewString = SVGO.optimize(overviewString, {
path: './generated/overview.svg', // For debugging, optional
multipass: true,
plugins: [
'convertStyleToAttrs',
'minifyStyles',
'convertColors',
'removeUselessStrokeAndFill',
'collapseGroups',
'reusePaths',
'convertTransform',
'removeEmptyContainers',
'convertTransform',
'sortAttrs'
]
}).data;
}
writeFileSync("./generated/overview.svg", overviewString);

let languageTemplate = handlebars.compile(templateLanguages);
let languageString = languageTemplate({ data: user });

// Modify the language SVG string directly
languageString = languageString
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&#x3D;/g, "=")
.replace(/&quot;/g, '"');


// Optimize languages SVG
if (useSvgo === 'true') {
languageString = SVGO.optimize(languageString, {
path: './generated/languages.svg', // For debugging, optional
multipass: true,
plugins: [
'minifyStyles',
'convertColors',
'removeUselessStrokeAndFill',
'collapseGroups',
'reusePaths',
'convertTransform',
'removeEmptyContainers',
'convertTransform',
'sortAttrs'
]
}).data;
}
writeFileSync('./generated/languages.svg', languageString);
})
.catch((error) => {
console.error("Error fetching content:", error);
});


/*
let overviewString = nunjucks.renderString(templateOverview, {
data: user
});
import { readFileSync, writeFileSync } from 'fs';
import handlebars from 'handlebars';
import GithubUser from './src/github.js';
import SVGO from 'svgo';
// import nunjucks from 'nunjucks';
//* nunjucks.configure({ autoescape: true });
// import { networkInterfaces } from 'os';
// console.log("✅ networkInterfaces:", networkInterfaces)
// console.log("✅ process.env:", process.env)
// console.log("✅ process.argv:", process.argv)
console.log("✅ process.env.CI:", process.env.CI)
const args = process.argv.slice(2); //🔶 Remove node and script paths
const argSvgo = String(args.includes('-svgo'));
const useSvgo = argSvgo ? argSvgo : ''; //
console.info("✅ useSvgo:", useSvgo)

let username = process.argv[2];
let user = new GithubUser(username);

let templateOverview = readFileSync("templates/overview.svg", 'utf-8');
let templateLanguages = readFileSync("templates/languages.svg", 'utf-8');

user.fetchContent()
.then(() => {
let overviewTemplate = handlebars.compile(templateOverview);
let overviewString = overviewTemplate({ data: user })


// Optimize overview SVG
if (useSvgo === 'true') {
overviewString = SVGO.optimize(overviewString, {
path: './generated/overview.svg', // For debugging, optional
multipass: true,
plugins: [
'convertStyleToAttrs',
'minifyStyles',
'convertColors',
'removeUselessStrokeAndFill',
'collapseGroups',
'reusePaths',
'convertTransform',
'removeEmptyContainers',
'convertTransform',
'sortAttrs'
]
}).data;
}
writeFileSync("./generated/overview.svg", overviewString);

let languageTemplate = handlebars.compile(templateLanguages);
let languageString = languageTemplate({ data: user });

// Modify the language SVG string directly
languageString = languageString
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&#x3D;/g, "=")
.replace(/&quot;/g, '"');


// Optimize languages SVG
if (useSvgo === 'true') {
languageString = SVGO.optimize(languageString, {
path: './generated/languages.svg', // For debugging, optional
multipass: true,
plugins: [
'minifyStyles',
'convertColors',
'removeUselessStrokeAndFill',
'collapseGroups',
'reusePaths',
'convertTransform',
'removeEmptyContainers',
'convertTransform',
'sortAttrs'
]
}).data;
}
writeFileSync('./generated/languages.svg', languageString);
})
.catch((error) => {
console.error("Error fetching content:", error);
});


/*
let overviewString = nunjucks.renderString(templateOverview, {
data: user
});
*/

0 comments on commit a1cff21

Please sign in to comment.