-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd60a54
commit a1cff21
Showing
2 changed files
with
90 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(/</g, "<") | ||
.replace(/>/g, ">") | ||
.replace(/=/g, "=") | ||
.replace(/"/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(/</g, "<") | ||
.replace(/>/g, ">") | ||
.replace(/=/g, "=") | ||
.replace(/"/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 | ||
}); | ||
*/ |