parent
0ed4ca9cab
commit
8f8a16d025
@ -5,12 +5,13 @@ project:
|
|||||||
ticket_url: null
|
ticket_url: null
|
||||||
releases:
|
releases:
|
||||||
- version: NEXT
|
- version: NEXT
|
||||||
changes:
|
changes:
|
||||||
- port the Perl changelord to JavaScript.
|
- port the Perl changelord to JavaScript.
|
||||||
change_types:
|
change_types:
|
||||||
- title: ''
|
- title: ""
|
||||||
level: minor
|
level: minor
|
||||||
keywords: ['']
|
keywords:
|
||||||
|
- ""
|
||||||
- title: Features
|
- title: Features
|
||||||
level: minor
|
level: minor
|
||||||
keywords:
|
keywords:
|
||||||
|
17
_templates/command/new/command.ejs.t
Normal file
17
_templates/command/new/command.ejs.t
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
to: src/command/<%= name %>.js
|
||||||
|
---
|
||||||
|
|
||||||
|
const handler = async (config) => {
|
||||||
|
// DO SOMETHING
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
command: '<%= name %>',
|
||||||
|
desc : 'TODO',
|
||||||
|
builder: (yargs) => {
|
||||||
|
yargs
|
||||||
|
},
|
||||||
|
handler,
|
||||||
|
}
|
||||||
|
|
5
_templates/generator/help/index.ejs.t
Normal file
5
_templates/generator/help/index.ejs.t
Normal file
@ -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
Normal file
18
_templates/generator/new/hello.ejs.t
Normal file
@ -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
Normal file
18
_templates/generator/with-prompt/hello.ejs.t
Normal file
@ -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
Normal file
14
_templates/generator/with-prompt/prompt.ejs.t
Normal file
@ -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
Normal file
4
_templates/init/repo/new-repo.ejs.t
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
setup: <%= name %>
|
||||||
|
force: true # this is because mostly, people init into existing folders is safe
|
||||||
|
---
|
@ -16,6 +16,7 @@
|
|||||||
"author": "Yanick Champoux <yanick@babyl.ca> (http://techblog.babyl.ca/)",
|
"author": "Yanick Champoux <yanick@babyl.ca> (http://techblog.babyl.ca/)",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@yanick/updeep-remeda": "^2.2.0",
|
||||||
"consola": "^3.1.0",
|
"consola": "^3.1.0",
|
||||||
"fs-extra": "^11.1.1",
|
"fs-extra": "^11.1.1",
|
||||||
"markdown-utils": "^1.0.0",
|
"markdown-utils": "^1.0.0",
|
||||||
|
@ -1,29 +1,32 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { hideBin } from 'yargs/helpers';
|
import { hideBin } from "yargs/helpers";
|
||||||
import yargs from 'yargs';
|
import yargs from "yargs";
|
||||||
import { join } from 'path';
|
import { join } from "path";
|
||||||
import yaml from 'yaml';
|
import yaml from "yaml";
|
||||||
import fs from 'fs-extra';
|
import fs from "fs-extra";
|
||||||
|
import consola from "consola";
|
||||||
|
|
||||||
import print from './command/print.js'
|
import print from "./command/print.js";
|
||||||
import init from './command/init.js'
|
import init from "./command/init.js";
|
||||||
import schema from './command/schema.js';
|
import schema from "./command/schema.js";
|
||||||
import consola from 'consola';
|
import add from "./command/add.js";
|
||||||
|
|
||||||
consola.raw = (...args) => console.log(...args);
|
consola.raw = (...args) => console.log(...args);
|
||||||
|
|
||||||
|
|
||||||
yargs(hideBin(process.argv))
|
yargs(hideBin(process.argv))
|
||||||
.config({
|
.config({
|
||||||
consola,
|
consola,
|
||||||
})
|
})
|
||||||
.default('source', join( process.cwd(), 'CHANGELOG.yml' ))
|
.default("source", join(process.cwd(), "CHANGELOG.yml"))
|
||||||
.describe('source', 'changelog source')
|
.describe("source", "changelog source")
|
||||||
.command({
|
.command({
|
||||||
...print,
|
...print,
|
||||||
command: '$0',
|
command: "$0",
|
||||||
})
|
})
|
||||||
.command(init)
|
.command(init)
|
||||||
.command(schema)
|
.command(add)
|
||||||
.command(print).help().parse();
|
.command(schema)
|
||||||
|
.command(print)
|
||||||
|
.help()
|
||||||
|
.parse();
|
||||||
|
51
src/command/add.js
Normal file
51
src/command/add.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import fs from "fs-extra";
|
||||||
|
import yaml from "yaml";
|
||||||
|
import u from "@yanick/updeep-remeda";
|
||||||
|
|
||||||
|
const handler = async (config) => {
|
||||||
|
if (!config.change)
|
||||||
|
throw new Error("can't add a change without a description");
|
||||||
|
|
||||||
|
const entry = {
|
||||||
|
desc: config.change.join(" "),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (config.ticket) entry.ticket = config.ticket;
|
||||||
|
if (config.type) entry.type = config.type;
|
||||||
|
|
||||||
|
config.consola.start(`adding '${entry.desc}' to the changelog`);
|
||||||
|
|
||||||
|
config.add_to_next(entry);
|
||||||
|
|
||||||
|
config.consola.success("done!");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
command: "add [change...]",
|
||||||
|
desc: "add a change to the NEXT release",
|
||||||
|
builder: (yargs) => {
|
||||||
|
yargs
|
||||||
|
.string("ticket")
|
||||||
|
.string("type")
|
||||||
|
.middleware((argv) => {
|
||||||
|
argv.add_to_next = async (entry) => {
|
||||||
|
const changelog = yaml.parse(await fs.readFile(argv.source, "utf-8"));
|
||||||
|
|
||||||
|
let next = changelog.releases.find(u.matches({ version: "NEXT" }));
|
||||||
|
if (!next) {
|
||||||
|
next = { version: "NEXT", changes: [] };
|
||||||
|
changelog.releases.unshift(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(entry).length === 1) {
|
||||||
|
entry = entry.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
next.changes.push(entry);
|
||||||
|
|
||||||
|
return fs.writeFile(argv.source, yaml.stringify(changelog));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handler,
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user