-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring in tools used by other lightward repos
- Loading branch information
1 parent
5514652
commit f501ea4
Showing
8 changed files
with
1,378 additions
and
148 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm test | ||
npm test && npx lint-staged |
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,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode"] | ||
} |
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,7 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"files.insertFinalNewline": true, | ||
"files.trimTrailingWhitespace": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.codeActionsOnSave": ["source.formatDocument"] | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const util = require('./util') | ||
const util = require('./util'); | ||
|
||
util.formatJsonFiles() | ||
util.buildDocs() | ||
util.formatJsonFiles(); | ||
util.buildDocs(); |
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 |
---|---|---|
@@ -1,59 +1,66 @@ | ||
const dirCompare = require('dir-compare') | ||
const fs = require('fs') | ||
const glob = require('glob') | ||
const dirCompare = require('dir-compare'); | ||
const fs = require('fs'); | ||
const glob = require('glob'); | ||
|
||
const util = require('./util') | ||
const util = require('./util'); | ||
|
||
const tasksFiles = glob.sync('tasks/*') | ||
const tasksFiles = glob.sync('tasks/*'); | ||
|
||
const invalidFilenames = tasksFiles.filter(f => !f.match(/^tasks\/[0-9a-z-]+\.json$/)) | ||
const invalidFilenames = tasksFiles.filter( | ||
(f) => !f.match(/^tasks\/[0-9a-z-]+\.json$/), | ||
); | ||
|
||
if (invalidFilenames.length > 0) { | ||
console.error(`Invalid filenames in tasks/:\n${invalidFilenames.join("\n")}`) | ||
throw `Found ${invalidFilenames.length} unexpected file(s) in tasks/` | ||
console.error(`Invalid filenames in tasks/:\n${invalidFilenames.join('\n')}`); | ||
throw `Found ${invalidFilenames.length} unexpected file(s) in tasks/`; | ||
} | ||
|
||
tasksFiles.forEach(path => { | ||
const json = fs.readFileSync(path, 'UTF-8') | ||
tasksFiles.forEach((path) => { | ||
const json = fs.readFileSync(path, 'UTF-8'); | ||
|
||
let data; | ||
|
||
try { | ||
data = JSON.parse(json) | ||
data = JSON.parse(json); | ||
} catch (error) { | ||
throw `Found invalid JSON in ${path}` | ||
throw `Found invalid JSON in ${path}`; | ||
} | ||
|
||
if (!json.match(/^ "/m)) { | ||
throw `Found a JSON file that appears to not be formatted with two-space indentation: ${path}` | ||
throw `Found a JSON file that appears to not be formatted with two-space indentation: ${path}`; | ||
} | ||
|
||
if (!json.match(/\n$/)) { | ||
throw `Found a JSON file that does not have a trailing newline: ${path}` | ||
throw `Found a JSON file that does not have a trailing newline: ${path}`; | ||
} | ||
|
||
if (data.script.match(/^\s*\t/m)) { | ||
throw `Found a task that appears to use literal tab characters for indentation (only two-space indentation is allowed): ${path}` | ||
throw `Found a task that appears to use literal tab characters for indentation (only two-space indentation is allowed): ${path}`; | ||
} | ||
}) | ||
}); | ||
|
||
util.validateTasks() | ||
util.validateTasks(); | ||
|
||
try { | ||
util.buildDocs('.test-docs', {silent: true, validate: false}) | ||
util.buildDocs('.test-docs', {silent: true, validate: false}); | ||
} catch (error) { | ||
fs.rmSync('.test-docs', {recursive: true}) | ||
fs.rmSync('.test-docs', {recursive: true}); | ||
|
||
throw `Caught an error while building to .test-docs: ${error}` | ||
throw `Caught an error while building to .test-docs: ${error}`; | ||
} | ||
|
||
const comparison = dirCompare.compareSync('docs', '.test-docs', {compareContent: true}) | ||
fs.rmSync('.test-docs', {recursive: true}) | ||
const comparison = dirCompare.compareSync('docs', '.test-docs', { | ||
compareContent: true, | ||
}); | ||
fs.rmSync('.test-docs', {recursive: true}); | ||
|
||
if (!comparison.same) { | ||
console.error(`Differing content:`, comparison.diffSet.filter(d => d.state !== 'equal')) | ||
console.error( | ||
`Differing content:`, | ||
comparison.diffSet.filter((d) => d.state !== 'equal'), | ||
); | ||
|
||
throw './docs directory appears to not be up to date; please run `npm run build`' | ||
throw './docs directory appears to not be up to date; please run `npm run build`'; | ||
} | ||
|
||
console.log('Everything looks good! 🚀') | ||
console.log('Everything looks good! 🚀'); |
Oops, something went wrong.