Skip to content

Commit

Permalink
task dependencies:generate (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner authored Mar 30, 2024
1 parent e82c383 commit a6a537b
Show file tree
Hide file tree
Showing 15 changed files with 490 additions and 637 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
- name: (PREPARE) Install Dependencies
run: ./task code:install

- name: (PREPARE) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (PREPARE) Build Project
run: ./task code:build

Expand Down Expand Up @@ -113,8 +110,11 @@ jobs:
- name: (DOCS) Install Dependencies
run: ./task docs:install

- name: (DOCS) Build Documentation Commands
run: ./task docs:build:commands
- name: (DOCS) Build Documentation Tasks
run: ./task docs:build:tasks

- name: (DOCS) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (DOCS) Generate Interface Page
run: ./task docs:generate:interface
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
- name: (PREPARE) Install xOpera
run: ./src/assets/scripts/install-xopera.sh

- name: (PREPARE) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (PREPARE) Build Project
run: ./task code:build

Expand Down Expand Up @@ -169,8 +166,11 @@ jobs:
- name: (DOCS) Install Dependencies
run: ./task docs:install

- name: (DOCS) Build Documentation Commands
run: ./task docs:build:commands
- name: (DOCS) Build Documentation Tasks
run: ./task docs:build:tasks

- name: (DOCS) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (DOCS) Generate Interface Page
run: ./task docs:generate:interface
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ jobs:
- name: (PREPARE) Install xOpera
run: ./src/assets/scripts/install-xopera.sh

# TODO: split this up
# Before "./task code:build" since "dependencies.csv" is packaged
- name: (PREPARE) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (PREPARE) Build Project
run: ./task code:build

Expand Down Expand Up @@ -129,8 +124,11 @@ jobs:
- name: (DOCS) Install Dependencies
run: ./task docs:install

- name: (DOCS) Build Documentation Commands
run: ./task docs:build:commands
- name: (DOCS) Build Documentation Tasks
run: ./task docs:build:tasks

- name: (DOCS) Generate Dependencies Page
run: ./task docs:generate:dependencies

- name: (DOCS) Generate Interface Page
run: ./task docs:generate:interface
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"tabWidth": 4,
"printWidth": 120,
"semi": false,
"endOfLine": "lf",
"overrides": [
{
"files": ["*.yaml", "*.yml"],
Expand Down
431 changes: 224 additions & 207 deletions docs/docs/assets/documents/dependencies.csv

Large diffs are not rendered by default.

436 changes: 226 additions & 210 deletions docs/docs/dependencies.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tasks/code/build/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ syncdir src/assets build/assets --quiet
# Copy license
cp LICENSE build/assets

# Copy dependencies
cp docs/docs/assets/documents/dependencies.csv build/assets
# Generate dependency licenses report
license-checker --production --csv > build/assets/dependencies.csv
2 changes: 1 addition & 1 deletion tasks/dependencies/check/task.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Check license
# Check dependency licenses
license-checker --production --summary --onlyAllow "MIT;Apache-2.0;Python-2.0;BSD-2-Clause;BSD-3-Clause;ISC;CC-BY-3.0;CC0-1.0;PSF;0BSD;BlueOak-1.0.0;Public Domain"
File renamed without changes.
5 changes: 0 additions & 5 deletions tasks/docs/generate/dependencies/license-checker-format.json

This file was deleted.

38 changes: 15 additions & 23 deletions tasks/docs/generate/dependencies/task.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
/**
* This script gathers the licences from all dependencies
* and stores information in a CSV file.
* At the same time the documentation page is generated.
*/
import * as files from '#files'
import std from '#std'
import * as path from 'path'
import * as utils from './utils'

const CSV_FILE = path.join('docs', 'docs', 'assets', 'documents', 'dependencies.csv')
const SOURCE = path.join('build', 'assets', 'dependencies.csv')

async function main() {
/**
* Read current dependencies
*/
const dependencies = await utils.gatherFromLicenseChecker()
std.log('Current dependencies retrieved. There are ', dependencies.length, ' Entries')
const TARGET_CSV = path.join('docs', 'docs', 'assets', 'documents', 'dependencies.csv')
const TARGET_MD = path.join('docs', 'docs', 'dependencies.md')
const TEMPLATE = path.join(__dirname, 'template.ejs')

async function main() {
/**
* Remove older version if a newer version with the same license exists
* Copy dependencies
*/
utils.removeDependencyVersionsWithSameLicense(dependencies)
files.copy(SOURCE, TARGET_CSV)

/**
* Write list to file
* Current dependencies
*/
std.log('Store CSV')
utils.storeData(dependencies, CSV_FILE)
const dependencies = files
.loadFile(SOURCE)
.split(/\r?\n/)
.filter(it => it != '')
.map(it => it.split(',').map(it => it.slice(1, -1)))
.slice(1)

/**
* Generate documentation page for dependency table
*/
await files.renderFile(
path.join(__dirname, 'template.ejs'),
{data: dependencies, licenses: utils.LICENSES},
path.join('docs', 'docs', 'dependencies.md')
)
await files.renderFile(TEMPLATE, {data: dependencies}, TARGET_MD)
std.log('Documentation page generated')
}

Expand Down
13 changes: 5 additions & 8 deletions tasks/docs/generate/dependencies/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ tags:

This document holds the dependencies used in production.
The list is available as [CSV](assets/documents/dependencies.csv).
We ensure, that only the licenses <%- "MIT;Apache-2.0;Python-2.0;BSD-2-Clause;BSD-3-Clause;ISC;CC-BY-3.0;CC0-1.0;PSF;0BSD;BlueOak-1.0.0;Public Domain".split(";").sort().map(license => `[${license}](${licenses[license]}){target=_blank}`).join(", ") -%> are used.
We ensure, that only the licenses <%- "MIT;Apache-2.0;Python-2.0;BSD-2-Clause;BSD-3-Clause;ISC;CC-BY-3.0;CC0-1.0;PSF;0BSD;BlueOak-1.0.0;Public Domain".split(";").sort().join(", ") -%> are used.

| ID | Dependency | Version | License |
| --- | --- | --- | --- |
<% data.forEach(({name, version, url, license}, index) => { -%>
| <%- index + 1 %> | [<%- name -%>](<%- url -%>){target=_blank} | <%- version -%> | <% license.split(' ').forEach( (value) => {
if(value.match('OR') || value.match('AND')) { -%><%- value -%> | <% } else { -%> [<%- value -%>](<%- licenses[value] -%>){target=_blank} |
<% } -%>
<% }) -%>
| ID | Dependency | License | URL |
| --- | --- | --- | --- |
<% data.forEach((row, index) => { -%>
| <%- index + 1 %> | <%= row[0] -%> | <%= row[1] -%> | [<%= row[2] -%>](<%= row[2] -%>){target=_blank} |
<% }) %>

We fixed the following issues by patching the dependencies.
Expand Down
19 changes: 0 additions & 19 deletions tasks/docs/generate/dependencies/types.ts

This file was deleted.

144 changes: 0 additions & 144 deletions tasks/docs/generate/dependencies/utils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tasks/docs/generate/task.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
echo "Building commands ..."
./task docs:build:commands
./task docs:build:tasks

echo "Generating docs ..."
./task docs:generate:interface
Expand Down

0 comments on commit a6a537b

Please sign in to comment.