mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
feat: 🎸 add --clean flag to Storybook CLI
This commit is contained in:
parent
a29a4476f4
commit
35e143d28d
2 changed files with 47 additions and 4 deletions
31
src/dev/storybook/commands/clean.ts
Normal file
31
src/dev/storybook/commands/clean.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { ToolingLog } from '@kbn/dev-utils';
|
||||
import { join } from 'path';
|
||||
import del from 'del';
|
||||
|
||||
export const clean = async ({ log, rootDir }: { log: ToolingLog; rootDir: string }) => {
|
||||
log.info('Cleaning Storybook build folder');
|
||||
|
||||
const dir = join(rootDir, 'built_assets', 'storybook');
|
||||
log.info('Deleting folder:', dir);
|
||||
await del([join(dir, '*')]);
|
||||
await del([dir]);
|
||||
};
|
|
@ -20,6 +20,7 @@
|
|||
import { join } from 'path';
|
||||
import { run, createFlagError } from '@kbn/dev-utils';
|
||||
import { storybookAliases } from './aliases';
|
||||
import { clean } from './commands/clean';
|
||||
|
||||
const rootDir = join(__dirname, '..', '..', '..');
|
||||
|
||||
|
@ -30,6 +31,15 @@ run(
|
|||
_: [alias],
|
||||
} = flags;
|
||||
|
||||
if (flags.verbose) {
|
||||
log.info('Flags:', flags);
|
||||
}
|
||||
|
||||
if (flags.clean) {
|
||||
await clean({ log, rootDir });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!alias) {
|
||||
throw createFlagError('missing alias');
|
||||
}
|
||||
|
@ -58,10 +68,12 @@ run(
|
|||
Add your alias in src/dev/storybook/aliases.ts
|
||||
`,
|
||||
flags: {
|
||||
boolean: ['fix'],
|
||||
default: {
|
||||
fix: false,
|
||||
},
|
||||
default: {},
|
||||
string: [],
|
||||
boolean: ['clean'],
|
||||
help: `
|
||||
--clean Clean Storybook build folder.
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue