-
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
0 parents
commit a40f2f4
Showing
8 changed files
with
108 additions
and
0 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,18 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Validate Commands JSON structure | ||
run: node ./internal/validate-commands-json.js | ||
|
||
- name: Validate Commands | ||
run: node ./internal/validate-commands.js |
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 @@ | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
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 @@ | ||
# GitHub Minesweeper | ||
|
||
Gain hands-on experience with a professional Git workflow used in many real-world teams with the help of a bot teammate. Find more information at [Profy.dev](https://profy.dev/project/github-minesweeper). |
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 @@ | ||
{ | ||
"commands": [] | ||
} |
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 @@ | ||
eyJncmlkIjpbW3sieHBvcyI6MCwieXBvcyI6MCwidmFsdWUiOjAsImlzTWluZSI6ZmFsc2UsImlzUmV2ZWFsZWQiOmZhbHNlLCJpc0ZsYWdnZWQiOmZhbHNlfSx7Inhwb3MiOjEsInlwb3MiOjAsInZhbHVlIjowLCJpc01pbmUiOmZhbHNlLCJpc1JldmVhbGVkIjpmYWxzZSwiaXNGbGFnZ2VkIjpmYWxzZX0seyJ4cG9zIjoyLCJ5cG9zIjowLCJ2YWx1ZSI6MSwiaXNNaW5lIjpmYWxzZSwiaXNSZXZlYWxlZCI6ZmFsc2UsImlzRmxhZ2dlZCI6ZmFsc2V9LHsieHBvcyI6MywieXBvcyI6MCwidmFsdWUiOjEsImlzTWluZSI6ZmFsc2UsImlzUmV2ZWFsZWQiOmZhbHNlLCJpc0ZsYWdnZWQiOmZhbHNlfSx7Inhwb3MiOjQsInlwb3MiOjAsInZhbHVlIjoyLCJpc01pbmUiOmZhbHNlLCJpc1JldmVhbGVkIjpmYWxzZSwiaXNGbGFnZ2VkIjpmYWxzZX0seyJ4cG9zIjo1LCJ5cG9zIjowLCJ2YWx1ZSI6Ijpib21iOiIsImlzTWluZSI6dHJ1ZSwiaXNSZXZlYWxlZCI6ZmFsc2UsImlzRmxhZ2dlZCI6ZmFsc2V9LHsieHBvcyI6NiwieXBvcyI6MCwidmFsdWUiOiI6Ym9tYjoiLCJpc01pbmUiOnRydWUsImlzUmV2ZWFsZWQiOmZhbHNlLCJpc0ZsYWdnZWQiOmZhbHNlfSx7Inhwb3MiOjcsInlwb3MiOjAsInZhbHVlIjoiOmJvbWI6IiwiaXNNaW5lIjp0cnVlLCJpc1JldmVhbGVkIjpmYWxzZSwiaXNGbGFnZ2VkIjpmYWxzZX1dLFt7Inhwb3MiOjAsInlwb3MiOjEsInZhbHVlIjoxLCJpc01pbmUiOmZhbHNlLCJpc1Jld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NaW5lcyI6MCwic3RhdHVzIjoiT05HT0lORyIsIm1vdmVzTWFkZSI6MCwib3B0aW9ucyI6eyJyb3dzIjo4LCJjb2xzIjo4LCJtaW5lcyI6MTB9fQ== |
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,6 @@ | ||
function handleError(message) { | ||
console.error(`\n\n${message}\n\n`); | ||
process.exit(1); | ||
}; | ||
|
||
module.exports = handleError; |
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,26 @@ | ||
const fs = require('fs'); | ||
const handleError = require('./handle-error'); | ||
|
||
const commandsFile = fs.readFileSync('./commands.json'); | ||
let commandsJson; | ||
try { | ||
commandsJson = JSON.parse(commandsFile); | ||
} catch (e) { | ||
if (e instanceof SyntaxError) { | ||
handleError(`The commands.json file contains a syntax error: ${e.message}`); | ||
return; | ||
} | ||
throw e; | ||
} | ||
|
||
if (!commandsJson.commands || !Array.isArray(commandsJson.commands)) { | ||
handleError('The structure of the commands object is broken.'); | ||
return; | ||
} | ||
|
||
commandsJson.commands.forEach(command => { | ||
if (typeof command !== 'string') { | ||
handleError('Each item in the commands array must be a string'); | ||
return; | ||
} | ||
}) |
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,44 @@ | ||
const fs = require('fs'); | ||
const handleError = require('./handle-error'); | ||
|
||
const VALID_COMMANDS = { | ||
CLEAR: 'CLEAR', | ||
FLAG: 'FLAG', | ||
UNFLAG: 'UNFLAG', | ||
END: 'END' | ||
}; | ||
const NUM_ROWS = 8; | ||
const NUM_COLS = 8; | ||
|
||
const commandsFile = fs.readFileSync('./commands.json'); | ||
const { commands } = JSON.parse(commandsFile) | ||
|
||
commands.forEach(command => { | ||
const [action, cellId] = command.toUpperCase().split(/\s+/g); | ||
if (!Object.values(VALID_COMMANDS).includes(action)) { | ||
handleError(`Invalid command "${command}"`); | ||
return; | ||
} | ||
|
||
if (action === VALID_COMMANDS.END) { | ||
return; | ||
} | ||
|
||
const posX = Number(cellId.charCodeAt(0) - "A".charCodeAt(0)); | ||
const posY = Number.parseInt(cellId.charAt(1), 10) - 1; | ||
|
||
if (isNaN(posY)) { | ||
handleError(`${command}: The second character ${cellId.charAt(1)} in ${cellId} has to be a number`); | ||
return; | ||
} | ||
|
||
if ( | ||
posX < 0 || | ||
posX >= NUM_COLS || | ||
posY < 0 || | ||
posY >= NUM_ROWS | ||
) { | ||
handleError(`${command}: Field ${cellId} does not exist.`); | ||
return; | ||
} | ||
}) |