Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bin/commands/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ import {
} from '../../src/constants.mjs';
import { publicGenerators } from '../../src/generators/index.mjs';
import createGenerator from '../../src/generators.mjs';
import logger from '../../src/logger/index.mjs';
import transports from '../../src/logger/transports.mjs';
import { parseChangelog, parseIndex } from '../../src/parsers/markdown.mjs';
import { loadAndParse } from '../utils.mjs';

const availableGenerators = Object.keys(publicGenerators);
const availableTransports = Object.keys(transports);

/**
* @typedef {Object} Options
* @property {Array<string>|string} input - Specifies the glob/path for input files.
* @property {Array<string>|string} [ignore] - Specifies the glob/path for ignoring files.
* @property {Array<keyof publicGenerators>} target - Specifies the generator target mode.
* @property {keyof availableTransports} transport - Specified the logging transport.
* @property {string} version - Specifies the target Node.js version.
* @property {string} changelog - Specifies the path to the Node.js CHANGELOG.md file.
* @property {string} [gitRef] - Git ref/commit URL.
Expand Down Expand Up @@ -104,6 +108,15 @@ export default {
})),
},
},
transport: {
flags: ['--transport [transport]'],
desc: 'Transport for logging',
prompt: {
type: 'multiselect',
options: availableTransports.map(t => ({ value: t, label: t })),
initialValue: 'pretty',
},
},
index: {
flags: ['--index <path>'],
desc: 'The index document, for getting the titles of various API docs',
Expand All @@ -119,6 +132,8 @@ export default {
* @returns {Promise<void>}
*/
async action(opts) {
logger.add(transports[opts.transport]());

const docs = await loadAndParse(opts.input, opts.ignore);
const releases = await parseChangelog(opts.changelog);
const index = opts.index && (await parseIndex(opts.index));
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/interactive.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@clack/prompts';

import commands from './index.mjs';
import { Logger } from '../../src/logger/index.mjs';
import logger from '../../src/logger/index.mjs';

/**
* Validates that a string is not empty.
Expand Down Expand Up @@ -166,7 +166,7 @@ export default async function interactive() {

const finalCommand = cmdParts.join(' ');

Logger.getInstance().info(`\nGenerated command:\n${finalCommand}\n`);
logger.info(`\nGenerated command:\n${finalCommand}\n`);

// Step 5: Confirm and execute the generated command
if (await confirm({ message: 'Run now?', initialValue: true })) {
Expand Down
4 changes: 2 additions & 2 deletions bin/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createMarkdownLoader from '../src/loaders/markdown.mjs';
import { Logger } from '../src/logger/index.mjs';
import logger from '../src/logger/index.mjs';
import createMarkdownParser from '../src/parsers/markdown.mjs';

/**
Expand Down Expand Up @@ -43,7 +43,7 @@ export const errorWrap =
try {
return await fn(...args);
} catch (err) {
Logger.getInstance().error(err);
logger.error(err);
process.exit(1);
}
};
Expand Down
Loading
Loading