From e89237b77cd7cd2de8a64865f749792ab761a39c Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sun, 5 Dec 2021 11:46:03 -0500 Subject: [PATCH] add hygen template --- 2021/_templates/day/new/part1.pm.t | 15 ++++++++++++++ 2021/_templates/day/new/part2.pm.t | 19 ++++++++++++++++++ 2021/_templates/day/new/prompt.js | 7 +++++++ 2021/_templates/day/new/tests.t | 20 +++++++++++++++++++ 2021/_templates/generator/help/index.ejs.t | 5 +++++ 2021/_templates/generator/new/hello.ejs.t | 18 +++++++++++++++++ .../generator/with-prompt/hello.ejs.t | 18 +++++++++++++++++ .../generator/with-prompt/prompt.js | 14 +++++++++++++ 8 files changed, 116 insertions(+) create mode 100644 2021/_templates/day/new/part1.pm.t create mode 100644 2021/_templates/day/new/part2.pm.t create mode 100644 2021/_templates/day/new/prompt.js create mode 100644 2021/_templates/day/new/tests.t create mode 100644 2021/_templates/generator/help/index.ejs.t create mode 100644 2021/_templates/generator/new/hello.ejs.t create mode 100644 2021/_templates/generator/with-prompt/hello.ejs.t create mode 100644 2021/_templates/generator/with-prompt/prompt.js diff --git a/2021/_templates/day/new/part1.pm.t b/2021/_templates/day/new/part1.pm.t new file mode 100644 index 0000000..296e081 --- /dev/null +++ b/2021/_templates/day/new/part1.pm.t @@ -0,0 +1,15 @@ +--- +to: '<%= day %>/part1.pm' +--- +package part1; + +use 5.34.0; +use warnings; +use experimental 'signatures'; + +use List::AllUtils qw/ /; + +sub solution() { +} + +1; diff --git a/2021/_templates/day/new/part2.pm.t b/2021/_templates/day/new/part2.pm.t new file mode 100644 index 0000000..ee431a4 --- /dev/null +++ b/2021/_templates/day/new/part2.pm.t @@ -0,0 +1,19 @@ +--- +to: '<%= day %>/part2.pm' +--- +package part2; + +use 5.20.0; +use warnings; +use experimental 'signatures'; + +use List::AllUtils qw/ /; + +require './part1.pm'; + +use experimental qw/ signatures postderef /; + +sub solution() { +} + +1; diff --git a/2021/_templates/day/new/prompt.js b/2021/_templates/day/new/prompt.js new file mode 100644 index 0000000..e719610 --- /dev/null +++ b/2021/_templates/day/new/prompt.js @@ -0,0 +1,7 @@ +module.exports = [ + { + type: 'input', + name: 'day', + message: "What day?" + } +] diff --git a/2021/_templates/day/new/tests.t b/2021/_templates/day/new/tests.t new file mode 100644 index 0000000..532d04b --- /dev/null +++ b/2021/_templates/day/new/tests.t @@ -0,0 +1,20 @@ +--- +to: '<%= day %>/test.t' +--- +use 5.34.0; + +use Test2::V0; +use Path::Tiny; + +require './part1.pm'; +require './part2.pm'; + +subtest part1 => sub { + my $todo = todo 'TODO'; + is part1::solution( ) => 'TODO'; +}; + +subtest part2 => sub { + my $todo = todo 'TODO'; + is part2::solution( ) => 'TODO'; +}; diff --git a/2021/_templates/generator/help/index.ejs.t b/2021/_templates/generator/help/index.ejs.t new file mode 100644 index 0000000..90a29af --- /dev/null +++ b/2021/_templates/generator/help/index.ejs.t @@ -0,0 +1,5 @@ +--- +message: | + hygen {bold generator new} --name [NAME] --action [ACTION] + hygen {bold generator with-prompt} --name [NAME] --action [ACTION] +--- \ No newline at end of file diff --git a/2021/_templates/generator/new/hello.ejs.t b/2021/_templates/generator/new/hello.ejs.t new file mode 100644 index 0000000..5680d96 --- /dev/null +++ b/2021/_templates/generator/new/hello.ejs.t @@ -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) + + diff --git a/2021/_templates/generator/with-prompt/hello.ejs.t b/2021/_templates/generator/with-prompt/hello.ejs.t new file mode 100644 index 0000000..ba6abc5 --- /dev/null +++ b/2021/_templates/generator/with-prompt/hello.ejs.t @@ -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) + + diff --git a/2021/_templates/generator/with-prompt/prompt.js b/2021/_templates/generator/with-prompt/prompt.js new file mode 100644 index 0000000..76ea532 --- /dev/null +++ b/2021/_templates/generator/with-prompt/prompt.js @@ -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?" + } +]