Yanick Champoux 6 months ago
parent
commit
9ade7e0313
  1. 1
      2022/template/part1.js
  2. 1
      2022/template/part2.js
  3. 6
      Taskfile.yaml
  4. 15
      _templates/day/new/hello.ejs.t
  5. 6
      _templates/day/new/part1.ejs
  6. 7
      _templates/day/new/part2.ejs
  7. 7
      _templates/day/new/prompt.js
  8. 11
      _templates/day/new/test.ejs
  9. 5
      _templates/generator/help/index.ejs.t
  10. 18
      _templates/generator/new/hello.ejs.t
  11. 18
      _templates/generator/with-prompt/hello.ejs.t
  12. 14
      _templates/generator/with-prompt/prompt.ejs.t
  13. 4
      _templates/init/repo/new-repo.ejs.t

1
2022/template/part1.js

@ -1 +0,0 @@ @@ -1 +0,0 @@
import * as R from "remeda";

1
2022/template/part2.js

@ -1 +0,0 @@ @@ -1 +0,0 @@
import * as R from "remeda";

6
Taskfile.yaml

@ -6,6 +6,8 @@ vars: @@ -6,6 +6,8 @@ vars:
YEAR: 2022
DAY:
sh: date '+%d' | perl -pe's/^0//'
DAY_FORMATTED:
sh: date '+%d'
GREETING: Hello, World!
tasks:
@ -25,6 +27,10 @@ tasks: @@ -25,6 +27,10 @@ tasks:
cmds:
- firefox https://adventofcode.com/{{.YEAR}}/day/{{.DAY}}
download:
cmds:
- aoc download -d {{.DAY}} -o -p 2022/{{.DAY_FORMATTED}}/puzzle.md -i 2022/{{.DAY_FORMATTED}}/input
default:
cmds:
- echo "{{.GREETING}}"

15
_templates/day/new/hello.ejs.t

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)

6
_templates/day/new/part1.ejs

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
---
to: 2022/<%= day %>/part1.js
---
import * as R from "remeda";
export default = () => {};

7
_templates/day/new/part2.ejs

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
---
to: 2022/<%= day %>/part2.js
---
import * as R from "remeda";
export default = () => {};

7
_templates/day/new/prompt.js

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
module.exports = [
{
type: 'input',
name: 'day',
message: "advent day?"
}
]

11
2022/template/test.js → _templates/day/new/test.ejs

@ -1,17 +1,20 @@ @@ -1,17 +1,20 @@
---
to: 2022/<%= day %>/test.js
---
import { test, expect, describe } from "vitest";
import { expectSolution } from "../01/main.js";
import { solutionPart1, puzzleInput } from "./part1.js";
import { solutionPart2 } from "./part2.js";
import part1, { sample, puzzleInput } from "./part1.js";
import part2 from "./part2.js";
describe("part 1", () => {
test.todo("solution", () => {
expectSolution(solutionPart1(puzzleInput)).toEqual("TODO");
expectSolution(part1(puzzleInput)).toEqual("TODO");
});
});
describe("part 2", () => {
test.todo("solution", () => {
expectSolution(solutionPart2(puzzleInput)).toEqual("TODO");
expectSolution(part2(puzzleInput)).toEqual("TODO");
});
});

5
_templates/generator/help/index.ejs.t

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
---
message: |
hygen {bold generator new} --name [NAME] --action [ACTION]
hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
---

18
_templates/generator/new/hello.ejs.t

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)

18
_templates/generator/with-prompt/hello.ejs.t

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first prompt based hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)

14
_templates/generator/with-prompt/prompt.ejs.t

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
---
// see types of prompts:
// https://github.com/enquirer/enquirer/tree/master/examples
//
module.exports = [
{
type: 'input',
name: 'message',
message: "What's your message?"
}
]

4
_templates/init/repo/new-repo.ejs.t

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
---
setup: <%= name %>
force: true # this is because mostly, people init into existing folders is safe
---
Loading…
Cancel
Save