Skip to content

Commit 682e43e

Browse files
authored
The great refactor (lowlighter#82)
1 parent f8c6d19 commit 682e43e

File tree

158 files changed

+6656
-4940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+6656
-4940
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,15 @@ assignees: ''
1212
👋 Hi there!
1313
Thanks for using metrics and helping us to improve!
1414
15-
Please check the following before filling a bug report:
16-
- It does not duplicate another existing issue
17-
- Retry at least once to confirm that it was not some random error
15+
Please:
16+
- Check you're not duplicating an existing issue
17+
- Provide a clear and concise description
1818
19-
For visual issues, mispelled words, etc. ...
20-
- Provide a description of what you expected to happen
21-
- Optionally add screenshots or additional context
19+
For workflows errors:
20+
- Retry at least once to confirm that error is reproductible
21+
- Paste an excerpt of your workflow step and error logs
2222
23-
For runtime errors...
24-
impacting action version:
25-
- Paste an excerpt of:
26-
- workflow step
27-
- error logs
28-
- direct GitHub links to the above
29-
30-
impacting web instance version:
31-
- Paste used url query
32-
33-
For other issues...
34-
- Just write a clear and concise description of what the bug is
23+
For web instance errors:
24+
- Paste used url query
3525
3626
-->

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ assignees: ''
1212
👋 Hi there!
1313
Thanks for using metrics and helping us to improve!
1414
15-
Please check the following before filling a feature request:
16-
- It does not duplicate another existing issue
15+
Please:
16+
- Check you're not duplicating an existing issue
1717
- It is not mentioned in https://github.com/lowlighter/metrics/projects/1
18-
19-
For plugin requests...
20-
- Add "plugin" label
21-
- Optionally add screenshots or additional context
22-
23-
For other requests...
24-
- Just write a clear and concise description about the feature request
25-
- Optionally add screenshots or additional context
18+
- Add correct labeling
19+
- Provide a clear and concise description
2620
2721
-->

.github/ISSUE_TEMPLATE/question.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,9 @@ assignees: ''
1212
👋 Hi there!
1313
Thanks for using metrics!
1414
15-
Before asking a question or for help, try to:
16-
- Search for a similar already existing issue
17-
- Check README.md documentation
18-
- Note that most of documentation is collapsed by default, so be sure to open sections marked with "▶",
19-
the solution to your problem may already be present!
20-
21-
For setup help...
22-
- Be sure to create required secrets (METRICS_TOKEN and other plugins token when needed)
23-
- Paste an excerpt of:
24-
- workflow step
25-
- error logs (if applicable)
26-
- direct GitHub links to the above
27-
- Optionally add screenshots or additional context
28-
29-
For other questions...
30-
- Just write about what you want to talk!
15+
Please:
16+
- Search for similar issues
17+
- Check documentation
18+
- Provide a clear and concise description
3119
3220
-->

.github/config/label.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ repository:
33
- .github/**
44
- .gitignore
55
- .gitattributes
6-
- README.md
76
- SECURITY.md
87
- LICENSE
98
- CONTRIBUTING.md
@@ -15,22 +14,17 @@ docker:
1514

1615
# Metrics source code editions
1716
core:
18-
- source/app/metrics.mjs
19-
- source/app/setup.mjs
17+
- source/app/metrics/**
2018
action:
2119
- source/app/action/**
22-
- action.yml
2320
web:
2421
- source/app/web/**
25-
- settings.example.json
2622
plugins:
2723
- source/plugins/**
28-
queries:
29-
- source/queries/**
3024
templates:
3125
- source/templates/**
3226
tests:
33-
- source/app/mocks.mjs
27+
- source/app/mocks/**
3428
- tests/**
3529
dependencies:
3630
- package.json

.github/index.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//Imports
2+
import ejs from "ejs"
3+
import fs from "fs/promises"
4+
import paths from "path"
5+
import url from "url"
6+
import sgit from "simple-git"
7+
import metadata from "../source/app/metrics/metadata.mjs"
8+
9+
//Mode
10+
const [mode = "dryrun"] = process.argv.slice(2)
11+
console.log(`Mode: ${mode}`)
12+
13+
//Paths
14+
const __metrics = paths.join(paths.dirname(url.fileURLToPath(import.meta.url)), "..")
15+
const __action = paths.join(__metrics, "source/app/action")
16+
const __web = paths.join(__metrics, "source/app/web")
17+
const __readme = paths.join(__metrics, ".github/readme")
18+
19+
//Git setup
20+
const git = sgit(__metrics)
21+
const staged = new Set()
22+
23+
//Load plugins metadata
24+
const {plugins, templates} = await metadata({log:false})
25+
26+
//Update generated files
27+
async function update({source, output, options = {}}) {
28+
//Regenerate file
29+
console.log(`Generating ${output}`)
30+
const content = await ejs.renderFile(source, {plugins, templates}, {async:true, ...options})
31+
//Save result
32+
const file = paths.join(__metrics, output)
33+
await fs.writeFile(file, content)
34+
//Add to git
35+
staged.add(file)
36+
}
37+
38+
//Rendering
39+
await update({source:paths.join(__readme, "README.md"), output:"README.md", options:{root:__readme}})
40+
await update({source:paths.join(__readme, "partials/documentation/plugins.md"), output:"source/plugins/README.md"})
41+
await update({source:paths.join(__readme, "partials/documentation/templates.md"), output:"source/templates/README.md"})
42+
await update({source:paths.join(__action, "action.yml"), output:"action.yml"})
43+
await update({source:paths.join(__web, "settings.example.json"), output:"settings.example.json"})
44+
45+
//Commit and push
46+
if (mode === "publish") {
47+
await git
48+
.addConfig("user.name", "GitHub Action")
49+
.addConfig("user.email", "<>")
50+
.add(...staged)
51+
.commit("Auto regenerate files - [Skip GitHub Action]")
52+
.push("origin", "master")
53+
}

.github/pull_request_template.md

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,10 @@
33
👋 Hi there!
44
Thanks for contributing to metrics and helping us to improve!
55
6-
Please check the following before opening a pull request:
7-
- It does not duplicate another existing pull request
8-
- It is not mentioned in https://github.com/lowlighter/metrics/projects/1
9-
- If it is, ensure that maintainers are aware that you're working on this subject
10-
11-
Then, explain briefly what your pull request is about and link any related issues (if applicable) to help us keeping track.
12-
13-
For documentation updates....
14-
- Check spelling before asking for a review
15-
- Respect current formatting (check that your editions blends well with current state)
16-
- Static images must be saved in /.github/readme/imgs and must be of width 1260px
17-
- UI should always be set in English in screenshots
18-
19-
For new plugins...
20-
- Ensure that you created:
21-
- a plugin entrypoint named index.mjs in /source/plugins
22-
- tests in /tests/metrics.test.js
23-
- mocked data if needed (required for all APIs which requires a token or limited in requests)
24-
- Ensure you updated:
25-
- /source/app/action/index.mjs to support new plugin options and use correct typing
26-
- /source/web/statics/* to support new plugin options
27-
- /settings.example.json with new plugin name
28-
- README.md to explain new plugin features
29-
- Include a screenshot in your pull request description
30-
- You can use `&config.output=png` option in your web instance for it
31-
32-
For all code editions...
33-
- Ensure retro-compatibility with previous versions (
34-
- (unless for unreleased features, for which breaking changes are allowed)
35-
- Respect current formatting
36-
- Prefers using appropriate single words for variables and plugins names
37-
- Avoid using uppercases letters, brackets and semicolons when possible to avoid visual pollution
38-
- Comments should be added before each "code paragraph" and are considered indent worthy
6+
Please:
7+
- Read CONTRIBUTING.md first
8+
- Check you're not duplicating another existing pull request
9+
- Add correct labeling
10+
- Provide a clear and concise description
3911
4012
-->

.github/readme/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 📊 Metrics
2+
3+
![Build](https://github.com/lowlighter/metrics/workflows/Build/badge.svg)
4+
5+
<% for (const partial of ["introduction", "shared", "setup", "documentation", "references", "license"]) { -%>
6+
<%- await include(`/partials/${partial}.md`) %>
7+
<% } %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 📚 Documentation
2+
3+
<% for (const partial of ["compatibility", "templates", "plugins", "organizations", "contributing"]) { %>
4+
<%- await include(`/partials/documentation/${partial}.md`) -%>
5+
<% } %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### 🧰 Template/plugin compatibily matrix
2+
3+
<table>
4+
<tr>
5+
<th nowrap="nowrap">Template\Plugin</th><%# -%>
6+
<% for (const [plugin, {icon}] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
7+
<th nowrap="nowrap" align="center"><%= icon %></th><% } %>
8+
</tr><%# -%>
9+
<% for (const [template, {name, readme}] of Object.entries(templates).filter(([key, value]) => (value)&&(!["community"].includes(key)))) { %>
10+
<tr>
11+
<th nowrap="nowrap"><%= name %></th><%# -%>
12+
<% for (const [plugin] of Object.entries(plugins).filter(([key, value]) => (value)&&(!["core"].includes(key)))) { %>
13+
<th nowrap="nowrap" align="center" data-plugin="<%= plugin %>"><%= readme.compatibility[plugin] ? "✔️" : "❌" %></th><% } %>
14+
</tr><% } %>
15+
</table>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## 💪 Customizing and contributing
2+
3+
Metrics is built to be easily customizable.
4+
Fork this repository, switch used action from `lowlighter/metrics@latest` to your fork and start coding!
5+
6+
To suggest a new feature, report a bug or ask for help, fill an [issue](https://github.com/lowlighter/metrics/issues) describing it.
7+
8+
If you want to contribute, submit a [pull request](https://github.com/lowlighter/metrics/pulls).
9+
Be sure to read [CONTRIBUTING.md](CONTRIBUTING.md) for more information about this.

0 commit comments

Comments
 (0)