-
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
Showing
7 changed files
with
2,040 additions
and
27 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
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,97 @@ | ||
import { PlopTypes } from "@turbo/gen"; | ||
|
||
export default function generator(plop: PlopTypes.NodePlopAPI): void { | ||
plop.setGenerator('Typescript', { | ||
description: 'Generate Typescript AoC day skeleton', | ||
prompts: [ | ||
{ | ||
type: 'input', | ||
name: 'year', | ||
message: 'Enter year in which you want to create day skeleton', | ||
default: (new Date()).getFullYear(), | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'day', | ||
message: 'Enter day which you are working on', | ||
default: (new Date()).getDate().toString().padStart(2, '0') | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'withTestRuns', | ||
message: 'Do you want to include test runs skeleton?', | ||
choices: [ | ||
{ name: 'Yes', value: true }, | ||
{ name: 'No', value: false }, | ||
], | ||
default: true | ||
} | ||
], | ||
actions: [ | ||
{ | ||
type: 'add', | ||
path: '{{ turbo.paths.root }}/{{ year }}/d{{ day }}/main.ts', | ||
templateFile: 'templates/typescript/main.ts', | ||
}, | ||
{ | ||
type: 'add', | ||
path: '{{ turbo.paths.root }}/{{ year }}/d{{ day }}/input.txt', | ||
templateFile: 'templates/typescript/input.txt', | ||
}, | ||
{ | ||
type: 'add', | ||
path: '{{ turbo.paths.root }}/{{ year }}/d{{ day }}/test-runs/0.txt', | ||
templateFile: 'templates/typescript/test-runs/0.txt', | ||
skip: ({ withTestRuns }: { withTestRuns: boolean }) => { | ||
if (withTestRuns) { | ||
return false | ||
} | ||
|
||
return 'Test runs skipped' | ||
} | ||
} | ||
] | ||
}) | ||
|
||
// plop.setGenerator("example", { | ||
// description: | ||
// "An example Turborepo generator - creates a new file at the root of the project", | ||
// prompts: [ | ||
// { | ||
// type: "input", | ||
// name: "file", | ||
// message: "What is the name of the new file to create?", | ||
// validate: (input: string) => { | ||
// if (input.includes(".")) { | ||
// return "file name cannot include an extension"; | ||
// } | ||
// if (input.includes(" ")) { | ||
// return "file name cannot include spaces"; | ||
// } | ||
// if (!input) { | ||
// return "file name is required"; | ||
// } | ||
// return true; | ||
// }, | ||
// }, | ||
// { | ||
// type: "list", | ||
// name: "type", | ||
// message: "What type of file should be created?", | ||
// choices: [".md", ".txt"], | ||
// }, | ||
// { | ||
// type: "input", | ||
// name: "title", | ||
// message: "What should be the title of the new file?", | ||
// }, | ||
// ], | ||
// actions: [ | ||
// { | ||
// type: "add", | ||
// path: "{{ turbo.paths.root }}/{{ dashCase file }}{{ type }}", | ||
// templateFile: "templates/turborepo-generators.hbs", | ||
// }, | ||
// ], | ||
// }); | ||
} |
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 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
Empty file.
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 @@ | ||
import { readFileSync } from 'node:fs' | ||
|
||
import { testRuns, solutionRuns } from '../util/aoc' | ||
|
||
const part1 = (data: string): number => { | ||
return 0 | ||
} | ||
|
||
const part2 = (data: string): number => { | ||
return 0 | ||
} | ||
|
||
const reader = (file: string): string => { | ||
return readFileSync(file, 'utf-8').trim() | ||
} | ||
|
||
testRuns('{{ day }}', reader, part1, part2) | ||
solutionRuns('{{ day }}', reader, part1, part2) |
Empty file.
Oops, something went wrong.