You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+6-34Lines changed: 6 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ Pull requests run a CI workflow, which must pass for the PR to be merged.
38
38
#### Additional Pull Request Tips
39
39
- Try to focus on accomplishing one thing, be it a feature or a bug fix.
40
40
- Try to do the least amount of change possible to accomplish the goal.
41
-
- Skip the temptation to make unnecessary changes or refactors (this makes tracing changes easier in the future).
41
+
- Skip the temptation to make unnecessary changes or refactors (this makes tracking changes easier in the future).
42
42
- If possible try not to introduce new dependencies.
43
43
44
44
## Development Setup
@@ -61,7 +61,7 @@ npm install
61
61
```
62
62
63
63
#### `npm start`
64
-
This is the command to run the program for development. It runs the `scripts/start.js` file.
64
+
This is the command to run the program for development. It runs the `bin/start.js` file.
65
65
66
66
This file contains some logic to ensure local development is easy:
67
67
- A working directory is created (if it does not exist) at the root of the repository called `development`. This folder acts as the cwd when running commands, it is ignored by git.
@@ -94,44 +94,16 @@ The project folder structure attempts to be as flat as possible to avoid deep ne
94
94
Each js file strives to have a single purpose, and if it starts to do too much it should be split into different files. This makes finding the implementation of a feature easy and makes the code more testable. Big multipurpose files are generally avoided save for some exceptions such as `util.js` or `formatting.js`.
95
95
96
96
#### Folders
97
-
-`scripts/` contains development scripts launched by the `package.json`
97
+
-`bin/` contains development scripts launched by the `package.json`
98
98
-`src/` contains all source code necessary to run the CLI.
99
99
-`templates/` template files used by the `init` command.
100
100
-`tests/` the unit tests, matches the structure of `src/`
101
101
102
102
## Code overview
103
-
This project uses [commander](https://github.com/tj/commander.js/) for the CLI logic. In `main.js` you can see all of the commands that are added. Each command corresponds to a file in the `src/cli` folder.
103
+
This project uses [commander](https://github.com/tj/commander.js/) for the CLI logic. In `main.js` you can see all of the commands that are added. Each command corresponds to an action in the `src/commands` folder.
104
104
105
105
The project uses ESM for modules.
106
106
107
-
#### Action Chains
108
-
Commands are generally implemented using action chains. An action chain is a abstraction for combining small pieces of functionality together to accomplish complex logic. An action chain is composed of "links", each link in the chain is a small single purpose function.
109
-
110
-
The action chain executes each link sequentially. It maintains an `args` object that is passed to each link in the chain, links can modify this args object by returning an object. When a link returns an object that value is spread onto the chains current args object.
111
-
112
-
Links can halt the chain by explicitly returning `false`. When the chain is halted by a link, no further links in that chain are run. A chain is also halted if a link throws an exception.
113
-
114
-
Chains can be created using the `createChain` function which takes an array of links. This function returns a new function which executes the chain when invoked.
115
-
116
-
Here is an example chain:
117
-
```js
118
-
constexampleChain=createChain([
119
-
assertInitialized,
120
-
getYear,
121
-
getNextUnsolvedPuzzle,
122
-
outputPuzzleLink
123
-
])
124
-
125
-
awaitexampleChain();
126
-
```
127
-
The chain runs these links in order:
128
-
1.`assertInitialized` - Halts the chain if the `cwd` does not contain a user data file.
129
-
2.`getYear` - Loads the year from the user data file and adds the year to the chains args.
130
-
3.`getNextUnsolvedPuzzle` - Searches the user data file for the first puzzle the user has not solved, the puzzle day and level are added to the chain args.
131
-
4.`outputPuzzleLink` - Prints a link to the puzzle in the terminal.
132
-
133
-
Since the links in a chain are executed sequentially, the order of the links is very important. Some links expect certain args to be present and will fail if those ars are missing. For instance `outputPuzzleLink` requires an args object like `{ year, day, level }`. These fields are added to the args object by the earlier links `getYear` and `getNextUnsolvedPuzzle`.
134
-
135
107
## Tests
136
108
[Jest](https://github.com/facebook/jest) is used for unit testing. There is no set coverage target, but the goal is to have as many quality tests as possible.
137
109
@@ -155,13 +127,13 @@ The code is using the [airbnb eslint preset](https://www.npmjs.com/package/eslin
155
127
156
128
An attempt should be made follow clean coding principles and to match the existing code style and not deviate from the general conventions of the existing code. Consistency is most important.
157
129
158
-
Some basic non-exhaustive guidelines:
130
+
Some basic guidelines:
159
131
160
132
- Small single purpose methods, decompose large functions into small ones.
161
133
- Minimize state, prefer pure functions.
162
134
- Minimize coupling.
163
135
- Comment public functions with [JSDoc](https://github.com/jsdoc/jsdoc)
164
-
-Code should be self documenting, comments should explain the "whys".
136
+
-Comments should explain the "whys".
165
137
- Prefer descriptive naming and avoid abbreviations (except for common acronyms such as URL or api).
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -250,6 +250,6 @@ I am using this CLI for my own advent of code solutions. You can refer to this p
250
250
## :bell: Automation Compliance
251
251
This CLI does follow the automation guidelines on the /r/adventofcode [community wiki](https://www.reddit.com/r/adventofcode/wiki/faqs/automation/). Specifically:
252
252
- Outbound calls are throttled to every five minutes in [rateLimitDecorator.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/api/rateLimitDecorator.js)
253
-
- Once inputs are downloaded, they are cached locally in [getPuzzleInput.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/actions/getPuzzleInput.js). If you suspect your input is corrupted, you can manually request a fresh copy by deleting the downloaded file.
253
+
- Once inputs are downloaded, they are cached locally in [getPuzzleInput.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/inputs/getPuzzleInput.js). If you suspect your input is corrupted, you can manually request a fresh copy by deleting the downloaded file.
254
254
- The User-Agent header in [api.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/api/api.js) is set to `https://github.com/beakerandjake/advent-of-code-runner by beakerandjake`
255
-
- Submitted answers are tracked per puzzle and duplicate submissions are prevented in [assertAnswerNotPreviouslySubmitted.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/actions/assertAnswerNotPreviouslySubmitted.js).
255
+
- Submitted answers are tracked per puzzle and duplicate submissions are prevented in [submit.js](https://github.com/beakerandjake/advent-of-code-runner/blob/main/src/commands/submit.js).
0 commit comments