12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /* eslint-env node */
- /* eslint import/no-nodejs-modules:off */
- import path from 'path';
- import {glob} from 'glob';
- import SignedFileGenerator from './signed-file-generator';
- type GlobPattern = Parameters<typeof glob>[0];
- type Options = {
- cwd: string;
- output: string;
- pattern: GlobPattern;
- };
- class ListFilesPlugin extends SignedFileGenerator<string[]> {
- constructor(options: Options) {
- super('ListFilesPlugin', options);
- }
- generateData(files: string[]) {
- return Promise.resolve(files);
- }
- sourceTemplate(data: string[], signingToken: string) {
- return `
- // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
- //
- // Generated by ${this.name} (${path.basename(__filename)})
- // ${signingToken}
- //
- // This script contains a list of story files to be dynamically loaded by our
- // component library.
- const FilesList: string[] = ${JSON.stringify(data)}
- export {FilesList}
- `;
- }
- }
- export default ListFilesPlugin;
|