-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
f8c6d19
commit 682e43e
Showing
158 changed files
with
6,656 additions
and
4,940 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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//Imports | ||
import ejs from "ejs" | ||
import fs from "fs/promises" | ||
import paths from "path" | ||
import url from "url" | ||
import sgit from "simple-git" | ||
import metadata from "../source/app/metrics/metadata.mjs" | ||
|
||
//Mode | ||
const [mode = "dryrun"] = process.argv.slice(2) | ||
console.log(`Mode: ${mode}`) | ||
|
||
//Paths | ||
const __metrics = paths.join(paths.dirname(url.fileURLToPath(import.meta.url)), "..") | ||
const __action = paths.join(__metrics, "source/app/action") | ||
const __web = paths.join(__metrics, "source/app/web") | ||
const __readme = paths.join(__metrics, ".github/readme") | ||
|
||
//Git setup | ||
const git = sgit(__metrics) | ||
const staged = new Set() | ||
|
||
//Load plugins metadata | ||
const {plugins, templates} = await metadata({log:false}) | ||
|
||
//Update generated files | ||
async function update({source, output, options = {}}) { | ||
//Regenerate file | ||
console.log(`Generating ${output}`) | ||
const content = await ejs.renderFile(source, {plugins, templates}, {async:true, ...options}) | ||
//Save result | ||
const file = paths.join(__metrics, output) | ||
await fs.writeFile(file, content) | ||
//Add to git | ||
staged.add(file) | ||
} | ||
|
||
//Rendering | ||
await update({source:paths.join(__readme, "README.md"), output:"README.md", options:{root:__readme}}) | ||
await update({source:paths.join(__readme, "partials/documentation/plugins.md"), output:"source/plugins/README.md"}) | ||
await update({source:paths.join(__readme, "partials/documentation/templates.md"), output:"source/templates/README.md"}) | ||
await update({source:paths.join(__action, "action.yml"), output:"action.yml"}) | ||
await update({source:paths.join(__web, "settings.example.json"), output:"settings.example.json"}) | ||
|
||
//Commit and push | ||
if (mode === "publish") { | ||
await git | ||
.addConfig("user.name", "GitHub Action") | ||
.addConfig("user.email", "<>") | ||
.add(...staged) | ||
.commit("Auto regenerate files - [Skip GitHub Action]") | ||
.push("origin", "master") | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 📊 Metrics | ||
|
||
![Build](https://github.com/lowlighter/metrics/workflows/Build/badge.svg) | ||
|
||
<% for (const partial of ["introduction", "shared", "setup", "documentation", "references", "license"]) { -%> | ||
<%- await include(`/partials/${partial}.md`) %> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 📚 Documentation | ||
|
||
<% for (const partial of ["compatibility", "templates", "plugins", "organizations", "contributing"]) { %> | ||
<%- await include(`/partials/documentation/${partial}.md`) -%> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### 🧰 Template/plugin compatibily matrix | ||
|
||
<table> | ||
<tr> | ||
<th nowrap="nowrap">Template\Plugin</th><%# -%> | ||
<% for (const [plugin, {icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %> | ||
<th nowrap="nowrap" align="center"><%= icon %></th><% } %> | ||
</tr><%# -%> | ||
<% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %> | ||
<tr> | ||
<th nowrap="nowrap"><%= name %></th><%# -%> | ||
<% for (const [plugin] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %> | ||
<th nowrap="nowrap" align="center" data-plugin="<%= plugin %>"><%= readme.compatibility[plugin] ? "✔️" : "❌" %></th><% } %> | ||
</tr><% } %> | ||
</table> |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## 💪 Customizing and contributing | ||
|
||
Metrics is built to be easily customizable. | ||
Fork this repository, switch used action from `lowlighter/metrics@latest` to your fork and start coding! | ||
|
||
To suggest a new feature, report a bug or ask for help, fill an [issue](https://github.com/lowlighter/metrics/issues) describing it. | ||
|
||
If you want to contribute, submit a [pull request](https://github.com/lowlighter/metrics/pulls). | ||
Be sure to read [CONTRIBUTING.md](CONTRIBUTING.md) for more information about this. |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
### 🏦 Organizations metrics | ||
|
||
While metrics targets mainly user accounts, it's possible to render metrics for organization accounts. | ||
|
||
![Metrics (organization account)](https://github.com/lowlighter/lowlighter/blob/master/metrics.organization.svg) | ||
|
||
<details> | ||
<summary>💬 Metrics for organizations</summary> | ||
|
||
Setup is the same as for user accounts, though you'll need to add `read:org` scope, **whether you're member of target organization or not**. | ||
|
||
![Add read:org scope to personal token](.github/readme/imgs/setup_token_org_read_scope.png) | ||
|
||
You'll also need to set `user` option with your organization name. | ||
|
||
If you're encounting errors and your organization is using single sign-on, try to [authorize your personal token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on). | ||
|
||
Most of plugins supported by user accounts will work with organization accounts, but note that rendering metrics for organizations consume way more APIs requests. | ||
|
||
To support private repositories, add full `repo` scope to your personal token. | ||
|
||
#### ℹ️ Example workflow | ||
|
||
```yaml | ||
- uses: lowlighter/metrics@latest | ||
with: | ||
# ... other options | ||
token: ${{ secrets.METRICS_TOKEN }} # A personal token from an user account with read:org scope | ||
committer_token: ${{ secrets.GITHUB_TOKEN }} # GitHub auto-generated token | ||
user: organization-name # Organization name | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>💬 Organizations memberships for user accounts</summary> | ||
|
||
Only public memberships can be displayed by metrics by default. | ||
You can manage your membership visibility in the `People` tab of your organization: | ||
|
||
![Publish organization membership](.github/readme/imgs/setup_public_membership_org.png) | ||
|
||
For organization memberships, add `read:org` scope to your personal token. | ||
|
||
![Add read:org scope to personal token](.github/readme/imgs/setup_token_org_read_scope.png) | ||
|
||
|
||
</details> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 🧩 Plugins | ||
|
||
Plugins are features which provide additional content and lets you customize your rendered metrics. | ||
See their respective documentation for more informations about how to setup them: | ||
<% for (const [plugin, {name}] of Object.entries(plugins).filter(([key, value]) => value)) { %> | ||
* [<%= name %>](/source/plugins/<%= plugin %>/README.md)<%# -%> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 🖼️ Templates | ||
|
||
Templates lets you change general appearance of rendered metrics. | ||
See their respective documentation for more informations about how to setup them: | ||
<% for (const [template, {name}] of Object.entries(templates).filter(([key, value]) => value)) { %> | ||
* [<%= name %>](/source/templates/<%= template %>/README.md)<%# -%> | ||
<% } %> |
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Generate your metrics that you can embed everywhere, including your GitHub profile readme! It works for both user and organization accounts, and even for repositories! | ||
|
||
<table> | ||
<tr> | ||
<th align="center">For user accounts</th> | ||
<th align="center">For organization accounts</th> | ||
</tr> | ||
<tr> | ||
<%- plugins.base.readme.demo?.replace(/<img src=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/g, `<img alt="" width="400" src=`) %> | ||
</tr> | ||
</table> | ||
<% { | ||
let cell = 0 | ||
const elements = Object.entries(plugins).filter(([key, value]) => (value)&&(!["base", "core"].includes(key))) | ||
if (elements.length%2) | ||
elements.push(["", {}]) | ||
%> | ||
<table> | ||
<tr> | ||
<th colspan="2" align="center"> | ||
<a href="source/plugins/README.md">🧩 <%= elements.length %> plugins</a> | ||
</th> | ||
</tr> | ||
<% for (let i = 0; i < elements.length; i+=2) { | ||
const cells = [["even", elements[i]], ["odd", elements[i+1]]] | ||
for (const [cell, [plugin, {name, readme}]] of cells) { | ||
if (cell === "even") { | ||
-%> | ||
<tr> | ||
<% } %> <th><a href="source/plugins/<%= plugin %>/README.md"><%= name -%></a></th> | ||
<% if (cell === "odd") { | ||
-%> </tr> | ||
<% }} | ||
for (const [cell, [plugin, {name, readme}]] of cells) { | ||
if (cell === "even") { | ||
-%> | ||
<tr> | ||
<% } %> <%- readme.demo.replace(/<img src=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/g, `<img alt="" width="400" src=`)?.split("\n")?.map((x, i) => i ? ` ${x}` : x)?.join("\n") %> | ||
<% if (cell === "odd") { | ||
-%> </tr> | ||
<% }}} -%> | ||
<tr> | ||
<th colspan="2" align="center"> | ||
<a href="https://github.com/lowlighter/metrics/projects/1">More to come soon!</a> | ||
</th> | ||
</tr> | ||
</table> | ||
<% } %> | ||
<% { | ||
let cell = 0 | ||
const elements = Object.entries(templates).filter(([key, value]) => value) | ||
if (elements.length%2) | ||
elements.push(["", {}]) | ||
%> | ||
<table> | ||
<tr> | ||
<th colspan="2" align="center"> | ||
<a href="source/templates/README.md">🖼️ <%= elements.length-1 %> templates</a> | ||
</th> | ||
</tr> | ||
<% for (let i = 0; i < elements.length; i+=2) { | ||
const cells = [["even", elements[i]], ["odd", elements[i+1]]] | ||
for (const [cell, [template, {name, readme}]] of cells) { | ||
if (cell === "even") { | ||
-%> | ||
<tr> | ||
<% } %> <th><a href="source/templates/<%= template %>/README.md"><%= name -%></a></th> | ||
<% if (cell === "odd") { | ||
-%> </tr> | ||
<% }} | ||
for (const [cell, [template, {name, readme}]] of cells) { | ||
if (cell === "even") { | ||
-%> | ||
<tr> | ||
<% } %> <%- readme.demo.replace(/<img src=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/g, `<img alt="" width="400" src=`)?.split("\n")?.map((x, i) => i ? ` ${x}` : x)?.join("\n") %> | ||
<% if (cell === "odd") { | ||
-%> </tr> | ||
<% }}} -%> | ||
</table> | ||
<% } %> |
Oops, something went wrong.