Skip to content

Commit a5990b0

Browse files
committed
First commit
0 parents  commit a5990b0

File tree

6 files changed

+162
-0
lines changed

6 files changed

+162
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
yarn-error.log
3+
package-lock.json

bin/lab-linter

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env node
2+
const yaml = require('js-yaml')
3+
const fs = require('fs')
4+
const { validateConfig } = require('..')
5+
6+
try {
7+
const doc = yaml.safeLoad(fs.readFileSync(process.argv[2], 'utf8'))
8+
console.log(doc)
9+
10+
const errors = validateConfig(doc)
11+
console.log('output')
12+
console.log(errors)
13+
14+
if (errors.length > 0) {
15+
process.exit(1)
16+
}
17+
} catch (e) {
18+
console.log(e)
19+
}

index.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const validateAction = (action, path) => {
2+
console.log('validating action', path)
3+
switch (action.type) {
4+
case 'getFileContents': {
5+
if (action.filename === undefined) {
6+
return {
7+
path,
8+
type: 'getFileContents',
9+
problem: 'Missing `filename`'
10+
}
11+
}
12+
}
13+
14+
default: {
15+
return undefined
16+
}
17+
}
18+
}
19+
20+
const validateStep = (step, path) =>
21+
(console.log('validating step', path), true) &&
22+
step.actions.map((action, index) =>
23+
validateAction(action, [...path, 'actions', index])
24+
)
25+
.filter((x) => x !== undefined)
26+
.reduce((a, b) => a.concat(b), [])
27+
28+
29+
const validateConfig = (config) =>
30+
(console.log('validating config'), true) &&
31+
config.steps.map((step, index) =>
32+
validateStep(step, ['steps', index])
33+
)
34+
.reduce((a, b) => a.concat(b), [])
35+
36+
module.exports = {
37+
validateAction,
38+
validateStep,
39+
validateConfig
40+
}

package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "github-learning-lab-linter",
3+
"version": "0.0.1",
4+
"bin": {
5+
"lab-linter": "./bin/lab-linter"
6+
},
7+
"main": "index.js",
8+
"author": "Fernando Via Canel <[email protected]>",
9+
"license": "MIT",
10+
"dependencies": {
11+
"js-yaml": "^3.13.1"
12+
}
13+
}

sample/config.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
title: Intro to Reason Web
2+
tagline: Learn You Some Reason for Great Good by building your first Reason React App!
3+
description: Longer explanation of the same; Reason Reason Reason Reason
4+
template:
5+
name: reason-todo-app
6+
repo: lab-template.intro-to-reason
7+
before:
8+
- type: createIssue
9+
title: Welcome
10+
body: 00.00-welcome.md
11+
comments:
12+
- 00.01-what-we-are-building.md
13+
- 00.02-begin-here.md
14+
15+
steps:
16+
17+
- title: Welcome
18+
description: Confirm that the course should begin.
19+
event: issues
20+
link: '{{ repoUrl }}/issues/1'
21+
actions:
22+
- type: gate
23+
left: '%payload.action%'
24+
operator: ===
25+
right: closed
26+
- type: createPullRequest
27+
title: Getting Started
28+
body: 01.00-setup.md
29+
head: setup
30+
action_id: setup_pr
31+
- type: assignRegistrant
32+
issue: '%actions.setup_pr.data.number%'
33+
- type: respond
34+
with: 00.03-goto-first-pr.md
35+
data:
36+
url: '%actions.setup_pr.data.html_url%'
37+
38+
- title: 'Local Setup: Install Dependencies'
39+
description: Get the repo up and working in your computer
40+
event: pull_request.synchronize
41+
link: '%actions.setup_pr.data.html_url%'
42+
actions:
43+
- type: getFileContents
44+
action_id: fileContents
45+
path: 'yarn.lock'
46+
- type: gate
47+
left: '/^# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.$/gm'
48+
operator: test
49+
right: '%actions.fileContents%'
50+
- type: respond
51+
with: 01.01-install-vs-code.md
52+
53+
- title: 'Local Setup: VS Code'
54+
description: Install VS Code
55+
event: pull_request.synchronize
56+
link: '%actions.setup_pr.data.html_url%'
57+
actions:
58+
- type: respond
59+
with: 01.02-build-project.md

yarn.lock

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
argparse@^1.0.7:
6+
version "1.0.10"
7+
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
8+
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
9+
dependencies:
10+
sprintf-js "~1.0.2"
11+
12+
esprima@^4.0.0:
13+
version "4.0.1"
14+
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
15+
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
16+
17+
js-yaml@^3.13.1:
18+
version "3.13.1"
19+
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
20+
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
21+
dependencies:
22+
argparse "^1.0.7"
23+
esprima "^4.0.0"
24+
25+
sprintf-js@~1.0.2:
26+
version "1.0.3"
27+
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
28+
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

0 commit comments

Comments
 (0)