@nl-design-system/component-progress 1.0.1-alpha.5 → 1.0.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.json +52719 -1
- package/dist/projects.json +1442 -1
- package/package.json +10 -3
- package/src/graphql/getComponentIssues.mjs +0 -56
- package/src/graphql/getProjects.mjs +0 -36
- package/src/graphql/graphqlWithAuth.mjs +0 -13
- package/src/graphql/index.mjs +0 -3
- package/src/index.mjs +0 -27
- package/src/utils/index.mjs +0 -3
- package/src/utils/mapProjects.mjs +0 -14
- package/src/utils/mapToComponentProgress.mjs +0 -85
- package/src/utils/projectData.mjs +0 -23
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.1-alpha.
|
|
2
|
+
"version": "1.0.1-alpha.7",
|
|
3
3
|
"author": "Community for NL Design System",
|
|
4
4
|
"description": "Script to get the component progress for the documentation of NL Design System",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
@@ -15,15 +15,22 @@
|
|
|
15
15
|
"type": "git+ssh",
|
|
16
16
|
"url": "git@github.com:nl-design-system/documentatie.git"
|
|
17
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/*.json"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
18
22
|
"scripts": {
|
|
19
|
-
"build": "node
|
|
23
|
+
"build": "tsc --project tsconfig.json && node dist/index.js",
|
|
20
24
|
"clean": "rm -rf dist/",
|
|
25
|
+
"lint": "tsc --noEmit --project tsconfig.json",
|
|
21
26
|
"prebuild": "npm run clean"
|
|
22
27
|
},
|
|
23
28
|
"devDependencies": {
|
|
24
29
|
"@octokit/core": "6.1.2",
|
|
25
30
|
"@octokit/plugin-paginate-graphql": "5.2.2",
|
|
31
|
+
"@types/lodash.isempty": "4.4.9",
|
|
32
|
+
"@types/node": "20.14.2",
|
|
26
33
|
"lodash.isempty": "4.4.0"
|
|
27
34
|
},
|
|
28
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ef7b2101d1ff3bc2b6b1fab2499ede559d659efc"
|
|
29
36
|
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { graphqlWithAuth } from './graphqlWithAuth.mjs';
|
|
2
|
-
|
|
3
|
-
export const getComponentIssues = async () => {
|
|
4
|
-
const octokit = graphqlWithAuth();
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
repository: { issues },
|
|
8
|
-
} = await octokit.graphql.paginate(
|
|
9
|
-
`query componentProgress($cursor: String) {
|
|
10
|
-
repository(name: "backlog", owner: "nl-design-system") {
|
|
11
|
-
issues(labels: ["component"], first: 50, after: $cursor) {
|
|
12
|
-
totalCount
|
|
13
|
-
nodes {
|
|
14
|
-
title
|
|
15
|
-
backlog: bodyUrl
|
|
16
|
-
projectItems(includeArchived: false, first: 100) {
|
|
17
|
-
nodes {
|
|
18
|
-
project {
|
|
19
|
-
title
|
|
20
|
-
number
|
|
21
|
-
url
|
|
22
|
-
}
|
|
23
|
-
fieldValues(first: 50) {
|
|
24
|
-
nodes {
|
|
25
|
-
... on ProjectV2ItemFieldValueCommon {
|
|
26
|
-
field {
|
|
27
|
-
... on ProjectV2FieldCommon {
|
|
28
|
-
dataType
|
|
29
|
-
name
|
|
30
|
-
id
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
... on ProjectV2ItemFieldSingleSelectValue {
|
|
35
|
-
value: name
|
|
36
|
-
color
|
|
37
|
-
}
|
|
38
|
-
... on ProjectV2ItemFieldTextValue {
|
|
39
|
-
value: text
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
pageInfo {
|
|
47
|
-
hasNextPage
|
|
48
|
-
endCursor
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}`,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
return issues.nodes;
|
|
56
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { graphqlWithAuth } from './graphqlWithAuth.mjs';
|
|
2
|
-
|
|
3
|
-
const octokit = graphqlWithAuth();
|
|
4
|
-
|
|
5
|
-
export const getProjects = async () => {
|
|
6
|
-
const { organization } = await octokit.graphql(
|
|
7
|
-
`query projects {
|
|
8
|
-
organization(login: "nl-design-system") {
|
|
9
|
-
projectsV2(first: 100) {
|
|
10
|
-
nodes {
|
|
11
|
-
number
|
|
12
|
-
title
|
|
13
|
-
shortDescription
|
|
14
|
-
url
|
|
15
|
-
updatedAt
|
|
16
|
-
views(first: 1) {
|
|
17
|
-
nodes {
|
|
18
|
-
fields(first: 100) {
|
|
19
|
-
nodes {
|
|
20
|
-
... on ProjectV2FieldCommon {
|
|
21
|
-
dataType
|
|
22
|
-
name
|
|
23
|
-
id
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}`,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return organization.projectsV2.nodes;
|
|
36
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
import { Octokit } from '@octokit/core';
|
|
3
|
-
import { paginateGraphQL } from '@octokit/plugin-paginate-graphql';
|
|
4
|
-
|
|
5
|
-
export const graphqlWithAuth = () => {
|
|
6
|
-
const MyOctokit = Octokit.plugin(paginateGraphQL);
|
|
7
|
-
|
|
8
|
-
if (!process.env.GH_ISSUES_TOKEN) {
|
|
9
|
-
throw Error('GH_ISSUES_TOKEN is not set');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return new MyOctokit({ auth: process.env.GH_ISSUES_TOKEN });
|
|
13
|
-
};
|
package/src/graphql/index.mjs
DELETED
package/src/index.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs/promises';
|
|
2
|
-
import { getComponentIssues, getProjects } from './graphql/index.mjs';
|
|
3
|
-
import { mapProjects, mapToComponentProgress, PROJECT_NUMBERS } from './utils/index.mjs';
|
|
4
|
-
|
|
5
|
-
const init = async () => {
|
|
6
|
-
try {
|
|
7
|
-
await fs.mkdir('./dist', { recursive: true });
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error('Could not create dist directory');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const projects = await getProjects(PROJECT_NUMBERS);
|
|
13
|
-
const mappedProjects = mapProjects(projects);
|
|
14
|
-
|
|
15
|
-
await fs
|
|
16
|
-
.writeFile('./dist/projects.json', JSON.stringify(mappedProjects))
|
|
17
|
-
.catch(() => console.error('Could not create projects.json'));
|
|
18
|
-
|
|
19
|
-
const componentIssues = await getComponentIssues();
|
|
20
|
-
const componentProgress = mapToComponentProgress(componentIssues, mappedProjects);
|
|
21
|
-
|
|
22
|
-
await fs
|
|
23
|
-
.writeFile('./dist/index.json', JSON.stringify(componentProgress))
|
|
24
|
-
.catch(() => console.error('Could not create index.json'));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
init();
|
package/src/utils/index.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PROJECTS } from './index.mjs';
|
|
2
|
-
|
|
3
|
-
const filterProjectChecks = ({ nodes: [view] }) =>
|
|
4
|
-
view.fields.nodes.filter((check) => check.dataType !== 'TITLE' && check.name !== 'Status');
|
|
5
|
-
|
|
6
|
-
export const mapProjects = (projects) =>
|
|
7
|
-
projects.map(({ views, ...project }) => {
|
|
8
|
-
return {
|
|
9
|
-
...project,
|
|
10
|
-
number: project.number,
|
|
11
|
-
key: PROJECTS[project.number],
|
|
12
|
-
tasks: filterProjectChecks(views),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import isEmpty from 'lodash.isempty';
|
|
2
|
-
import { PROJECT_NUMBERS, PROJECTS } from './index.mjs';
|
|
3
|
-
|
|
4
|
-
const cleanupValue = ({ field, value, color }) => {
|
|
5
|
-
// Only allow https values
|
|
6
|
-
if (field.dataType === 'TEXT' && URL.canParse(value)) {
|
|
7
|
-
const url = new URL(value);
|
|
8
|
-
return url.protocol === 'https:';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Assume green means checked
|
|
12
|
-
if (field.dataType === 'SINGLE_SELECT') {
|
|
13
|
-
return color === 'GREEN';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return !!value;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const cleanupFields = ({ project, fieldValues }) => ({
|
|
20
|
-
title: project.title.replace(/Components\s?-\s?([0-9]\s?-\s?)?/, ''),
|
|
21
|
-
number: project.number,
|
|
22
|
-
id: PROJECTS[project.number],
|
|
23
|
-
url: project.url,
|
|
24
|
-
tasks: fieldValues.nodes
|
|
25
|
-
.filter((node) => !isEmpty(node) && node.field.dataType !== 'TITLE' && node.field.name !== 'Status')
|
|
26
|
-
.map((node) => ({ ...node.field, value: node.value, checked: cleanupValue(node) })),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const getAllTasks = (issue, projects) => {
|
|
30
|
-
const project = projects.find((project) => project.number === issue.number);
|
|
31
|
-
const tasks = project.tasks.map((task) => {
|
|
32
|
-
const check = issue.tasks.find((check) => check.id === task.id);
|
|
33
|
-
const fallBack = {
|
|
34
|
-
...task,
|
|
35
|
-
value: '',
|
|
36
|
-
checked: false,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return check || fallBack;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const checked = issue.tasks.filter((issue) => issue.checked);
|
|
43
|
-
const done = checked.length === project.tasks.length;
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...issue,
|
|
47
|
-
done,
|
|
48
|
-
progress: { value: checked.length, max: project.tasks.length },
|
|
49
|
-
tasks,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getRelayStep = (issue) => {
|
|
54
|
-
const HELP_WANTED = issue.projects.find(({ id }) => id === 'HELP_WANTED')?.done;
|
|
55
|
-
const COMMUNITY = issue.projects.find(({ id }) => id === 'COMMUNITY')?.done;
|
|
56
|
-
const CANDIDATE = issue.projects.find(({ id }) => id === 'CANDIDATE')?.done;
|
|
57
|
-
const HALL_OF_FAME = issue.projects.find(({ id }) => id === 'HALL_OF_FAME')?.done;
|
|
58
|
-
|
|
59
|
-
const relayStep = HALL_OF_FAME
|
|
60
|
-
? 'HALL_OF_FAME'
|
|
61
|
-
: CANDIDATE
|
|
62
|
-
? 'CANDIDATE'
|
|
63
|
-
: COMMUNITY
|
|
64
|
-
? 'COMMUNITY'
|
|
65
|
-
: HELP_WANTED
|
|
66
|
-
? 'HELP_WANTED'
|
|
67
|
-
: 'UNKNOWN';
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
relayStep,
|
|
71
|
-
...issue,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const mapToComponentProgress = (issues, projects) =>
|
|
76
|
-
issues
|
|
77
|
-
.map(({ title, projectItems, ...issue }) => ({
|
|
78
|
-
title,
|
|
79
|
-
...issue,
|
|
80
|
-
projects: projectItems.nodes
|
|
81
|
-
.filter(({ project }) => Object.values(PROJECT_NUMBERS).includes(project.number))
|
|
82
|
-
.map(cleanupFields)
|
|
83
|
-
.map((component) => getAllTasks(component, projects)),
|
|
84
|
-
}))
|
|
85
|
-
.map(getRelayStep);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const PROJECT_NUMBERS = {
|
|
2
|
-
HELP_WANTED: 27,
|
|
3
|
-
COMMUNITY: 29,
|
|
4
|
-
CANDIDATE: 32,
|
|
5
|
-
HALL_OF_FAME: 30,
|
|
6
|
-
UTRECHT: 36,
|
|
7
|
-
AMSTERDAM: 48,
|
|
8
|
-
RVO: 49,
|
|
9
|
-
LOGIUS: 53,
|
|
10
|
-
DEN_HAAG: 55,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const PROJECTS = {
|
|
14
|
-
[PROJECT_NUMBERS.HELP_WANTED]: 'HELP_WANTED',
|
|
15
|
-
[PROJECT_NUMBERS.COMMUNITY]: 'COMMUNITY',
|
|
16
|
-
[PROJECT_NUMBERS.CANDIDATE]: 'CANDIDATE',
|
|
17
|
-
[PROJECT_NUMBERS.HALL_OF_FAME]: 'HALL_OF_FAME',
|
|
18
|
-
[PROJECT_NUMBERS.UTRECHT]: 'UTRECHT',
|
|
19
|
-
[PROJECT_NUMBERS.AMSTERDAM]: 'AMSTERDAM',
|
|
20
|
-
[PROJECT_NUMBERS.RVO]: 'RVO',
|
|
21
|
-
[PROJECT_NUMBERS.LOGIUS]: 'LOGIUS',
|
|
22
|
-
[PROJECT_NUMBERS.DEN_HAAG]: 'DEN_HAAG',
|
|
23
|
-
};
|