From 139deb8614ea7ddd7e7a51a6b2bd7369522f5297 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sat, 26 Mar 2022 13:10:11 -0400 Subject: [PATCH] hygen --- _templates/generator/help/index.ejs.t | 5 +++++ _templates/generator/new/hello.ejs.t | 18 +++++++++++++++++ _templates/generator/with-prompt/hello.ejs.t | 18 +++++++++++++++++ _templates/generator/with-prompt/prompt.js | 14 +++++++++++++ _templates/package.json | 3 +++ _templates/story/new/index.js | 11 ++++++++++ _templates/story/new/stories.svelte.temp | 21 ++++++++++++++++++++ 7 files changed, 90 insertions(+) create mode 100644 _templates/generator/help/index.ejs.t create mode 100644 _templates/generator/new/hello.ejs.t create mode 100644 _templates/generator/with-prompt/hello.ejs.t create mode 100644 _templates/generator/with-prompt/prompt.js create mode 100644 _templates/package.json create mode 100644 _templates/story/new/index.js create mode 100644 _templates/story/new/stories.svelte.temp diff --git a/_templates/generator/help/index.ejs.t b/_templates/generator/help/index.ejs.t new file mode 100644 index 0000000..90a29af --- /dev/null +++ b/_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/_templates/generator/new/hello.ejs.t b/_templates/generator/new/hello.ejs.t new file mode 100644 index 0000000..5680d96 --- /dev/null +++ b/_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/_templates/generator/with-prompt/hello.ejs.t b/_templates/generator/with-prompt/hello.ejs.t new file mode 100644 index 0000000..ba6abc5 --- /dev/null +++ b/_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/_templates/generator/with-prompt/prompt.js b/_templates/generator/with-prompt/prompt.js new file mode 100644 index 0000000..76ea532 --- /dev/null +++ b/_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?" + } +] diff --git a/_templates/package.json b/_templates/package.json new file mode 100644 index 0000000..5bbefff --- /dev/null +++ b/_templates/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/_templates/story/new/index.js b/_templates/story/new/index.js new file mode 100644 index 0000000..37b2a7e --- /dev/null +++ b/_templates/story/new/index.js @@ -0,0 +1,11 @@ +const path = require('path'); + +module.exports = { + params: ({ args }) => { + + const storypath = args.path.replace( '.svelte', '.stories.svelte' ); + const component = path.basename(args.path).replace('.svelte',''); + + return { storypath, component} + } +} diff --git a/_templates/story/new/stories.svelte.temp b/_templates/story/new/stories.svelte.temp new file mode 100644 index 0000000..fe2ba10 --- /dev/null +++ b/_templates/story/new/stories.svelte.temp @@ -0,0 +1,21 @@ +--- +to: <%= storypath %> +--- +} argTypes={{}} /> + + + + + +