1441 |
ariadna |
1 |
#!/usr/bin/env node
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
import { Argument, Option, program } from 'commander';
|
|
|
18 |
import chalk from 'chalk';
|
|
|
19 |
|
|
|
20 |
import { getNoteNames } from './notes/src/noteTypes.mjs';
|
|
|
21 |
import createAction from './notes/src/create.mjs';
|
|
|
22 |
import generateAction from './notes/src/generate.mjs';
|
|
|
23 |
import logger from './notes/src/logger.mjs';
|
|
|
24 |
|
|
|
25 |
console.log(`
|
|
|
26 |
${chalk.bold(chalk.underline(chalk.green('Moodle Upgrade Notes Generator')))}
|
|
|
27 |
|
|
|
28 |
This tool is used to generate the upgrade notes for changes you make in Moodle.
|
|
|
29 |
|
|
|
30 |
Please remember that the intended audience of these changes is
|
|
|
31 |
${chalk.italic('plugin developers')} who need to know how to update their plugins
|
|
|
32 |
for a new Moodle version.
|
|
|
33 |
|
|
|
34 |
Upgrade notes should not be used to document changes for site administrators, or
|
|
|
35 |
for internal API changes which are not expected to be used outside of the
|
|
|
36 |
relevant component.
|
|
|
37 |
`)
|
|
|
38 |
|
|
|
39 |
program.configureHelp({
|
|
|
40 |
helpWidth: 100,
|
|
|
41 |
});
|
|
|
42 |
|
|
|
43 |
program.on('option:verbose', () => {
|
|
|
44 |
logger.level = 'verbose';
|
|
|
45 |
});
|
|
|
46 |
|
|
|
47 |
program.addOption(
|
|
|
48 |
new Option(
|
|
|
49 |
'-v, --verbose',
|
|
|
50 |
'Output more information during the generation process',
|
|
|
51 |
)
|
|
|
52 |
.default(false)
|
|
|
53 |
);
|
|
|
54 |
|
|
|
55 |
// Define the command line options.
|
|
|
56 |
program
|
|
|
57 |
.command('create')
|
|
|
58 |
.summary('Generate a new upgrade note')
|
|
|
59 |
.addOption(
|
|
|
60 |
new Option('-t, --type <type>', `The type of change to document. Valid types are: ${getNoteNames().join(', ')}`)
|
|
|
61 |
)
|
|
|
62 |
.addOption(new Option('-i, --issue <issue>', 'The tracker issue number'))
|
|
|
63 |
.addOption(new Option('-c, --component <component>', 'The component to write a note for'))
|
|
|
64 |
.addOption(new Option(
|
|
|
65 |
'-m, --message <message>',
|
|
|
66 |
'The message to use for the upgrade note',
|
|
|
67 |
))
|
|
|
68 |
.action((options) => createAction(options));
|
|
|
69 |
|
|
|
70 |
program
|
|
|
71 |
.command('summary')
|
|
|
72 |
.summary('Generate a local copy of the upgrade notes summary')
|
|
|
73 |
.addArgument(
|
|
|
74 |
new Argument('[version]', 'The Moodle version to create the summary notes for')
|
|
|
75 |
)
|
|
|
76 |
.action((version) => generateAction(version));
|
|
|
77 |
|
|
|
78 |
program
|
|
|
79 |
.command('release')
|
|
|
80 |
.summary('Generate the markdown copies of the upgrade notes for a Moodle release')
|
|
|
81 |
.addArgument(
|
|
|
82 |
new Argument('[version]', 'The Moodle version to create the release notes for')
|
|
|
83 |
)
|
|
|
84 |
.addOption(
|
|
|
85 |
new Option(
|
|
|
86 |
'--generate-upgrade-notes',
|
|
|
87 |
'Generate the UPGRADING.md notes for the release. ' +
|
|
|
88 |
'Note: This option is intended for use by the release manager when generating the upgrade notes.',
|
|
|
89 |
)
|
|
|
90 |
.default(true)
|
|
|
91 |
)
|
|
|
92 |
.addOption(
|
|
|
93 |
new Option(
|
|
|
94 |
'-d, --delete-notes',
|
|
|
95 |
'Delete the notes after generating the UPGRADING.md notes for the release. ' +
|
|
|
96 |
'Note: This option is intended for use by the release manager when generating the upgrade notes.' +
|
|
|
97 |
'This option has no effect unless --generate-upgrade-notes is also set.'
|
|
|
98 |
)
|
|
|
99 |
.default(false)
|
|
|
100 |
)
|
|
|
101 |
.action((version, options) => generateAction(version, options));
|
|
|
102 |
|
|
|
103 |
program.parse();
|