generated from nl-design-system/example
-
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
Showing
6 changed files
with
534 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"version": "1.0.0", | ||
"author": "Community for NL Design System", | ||
"description": "Script to get the component progress for the documentation of NL Design System", | ||
"license": "EUPL-1.2", | ||
"name": "@nl-design-system/component-progress", | ||
"keywords": [ | ||
"nl-design-system" | ||
], | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git+ssh", | ||
"url": "git@github.com:nl-design-system/documentatie.git" | ||
}, | ||
"scripts": { | ||
"build": "node src/index.mjs", | ||
"clean": "rm -rf dist/", | ||
"prebuild": "npm run clean" | ||
}, | ||
"devDependencies": { | ||
"@octokit/graphql": "8.1.1", | ||
"lodash.isempty": "4.4.0", | ||
"octokit": "4.0.2" | ||
} | ||
} |
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,66 @@ | ||
import isEmpty from 'lodash.isempty'; | ||
import { PROJECT_NUMBERS } from './getProjects.mjs'; | ||
import { graphqlWithAuth } from './graphqlWithAuth.mjs'; | ||
|
||
const filterEstafetteProjects = (issues = []) => { | ||
return issues.map(({ title, projectItems, ...issue }) => ({ | ||
title, | ||
projects: projectItems.nodes.filter(({ project }) => PROJECT_NUMBERS.includes(project.number)).map(cleanupFields), | ||
...issue, | ||
})); | ||
}; | ||
|
||
const cleanupFields = ({ project, fieldValues }) => ({ | ||
[project.number]: { | ||
title: project.title, | ||
checks: fieldValues.nodes | ||
.filter((node) => !isEmpty(node)) | ||
.map(({ field: { name, id }, value }) => ({ name, id, value })), | ||
}, | ||
}); | ||
|
||
export const getComponentProgess = async () => { | ||
const { | ||
repository: { issues }, | ||
} = await graphqlWithAuth({ | ||
query: `{ | ||
repository(name: "backlog", owner: "nl-design-system") { | ||
issues(labels: ["component"], first: 100) { | ||
totalCount | ||
nodes { | ||
title | ||
url: bodyUrl | ||
projectItems(includeArchived: false, first: 10) { | ||
nodes { | ||
project { | ||
title | ||
number | ||
} | ||
fieldValues(first: 50) { | ||
nodes { | ||
... on ProjectV2ItemFieldValueCommon { | ||
field { | ||
... on ProjectV2FieldCommon { | ||
name | ||
id | ||
} | ||
} | ||
} | ||
... on ProjectV2ItemFieldSingleSelectValue { | ||
value: name | ||
} | ||
... on ProjectV2ItemFieldTextValue { | ||
value: text | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}`, | ||
}); | ||
|
||
return filterEstafetteProjects(issues.nodes); | ||
}; |
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,55 @@ | ||
import { graphqlWithAuth } from './graphqlWithAuth.mjs'; | ||
|
||
const HELP_WANTED_PROJECT = 27; | ||
const COMMUNITY_PROJECT = 29; | ||
const CANDIDATE_PROJECT = 32; | ||
const HALL_OF_FAME_PROJECT = 30; | ||
|
||
export const PROJECT_NUMBERS = [HELP_WANTED_PROJECT, COMMUNITY_PROJECT, CANDIDATE_PROJECT, HALL_OF_FAME_PROJECT]; | ||
|
||
export const getProjectDetails = async () => { | ||
const { organization } = await graphqlWithAuth({ | ||
query: `query projectDetails($helpWanted: Int!, $community: Int!, $candidate: Int!, $hallOfFame: Int!) { | ||
organization(login: "nl-design-system") { | ||
HELP_WANTED: projectV2(number:$helpWanted) { | ||
...ProjectFragment | ||
} | ||
COMMUNITY: projectV2(number:$community) { | ||
...ProjectFragment | ||
} | ||
CANDIDATE: projectV2(number:$candidate) { | ||
...ProjectFragment | ||
} | ||
HALL_OF_FAME: projectV2(number:$hallOfFame) { | ||
...ProjectFragment | ||
} | ||
} | ||
} | ||
fragment ProjectFragment on ProjectV2 { | ||
number | ||
title | ||
shortDescription | ||
url | ||
updatedAt | ||
view(number: 1) { | ||
fields(first: 50) { | ||
totalCount | ||
checks: nodes { | ||
... on ProjectV2FieldCommon { | ||
dataType | ||
name | ||
id | ||
} | ||
} | ||
} | ||
} | ||
}`, | ||
helpWanted: HELP_WANTED_PROJECT, | ||
community: COMMUNITY_PROJECT, | ||
candidate: CANDIDATE_PROJECT, | ||
hallOfFame: HALL_OF_FAME_PROJECT, | ||
}); | ||
|
||
return organization; | ||
}; |
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,8 @@ | ||
/* global process */ | ||
import { graphql } from '@octokit/graphql'; | ||
|
||
export const graphqlWithAuth = graphql.defaults({ | ||
headers: { | ||
authorization: `token ${process.env.GH_ISSUES_TOKEN}`, | ||
}, | ||
}); |
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,27 @@ | ||
import * as fs from 'fs/promises'; | ||
import { getComponentProgess } from './getComponents.mjs'; | ||
import { getProjectDetails } from './getProjects.mjs'; | ||
|
||
const init = async () => { | ||
try { | ||
await fs.mkdir('./dist', { recursive: true }); | ||
} catch (error) { | ||
console.error('Could not create dist directory', error); | ||
} | ||
|
||
try { | ||
const componentProgress = await getComponentProgess(); | ||
await fs.writeFile('./dist/component-progress.json', JSON.stringify(componentProgress)); | ||
} catch (error) { | ||
console.error('Could not create component-progress.json', error); | ||
} | ||
|
||
try { | ||
const projectDetails = await getProjectDetails(); | ||
await fs.writeFile('./dist/project-details.json', JSON.stringify(projectDetails)); | ||
} catch (error) { | ||
console.error('Could not create project-details.json', error); | ||
} | ||
}; | ||
|
||
init(); |
Oops, something went wrong.