How to use templateDir method in storybook-root

Best JavaScript code snippet using storybook-root

util.spec.ts

Source:util.spec.ts Github

copy

Full Screen

1import { BuildContext } from '../util/interfaces';2import { basename, join } from 'path';3import * as fs from 'fs';4import * as Constants from '../util/constants';5import * as helpers from '../util/helpers';6import * as globUtils from '../util/glob-util';7import * as util from './util';8import * as GeneratorConstants from './constants';9import * as TypeScriptUtils from '../util/typescript-utils';10describe('util', () => {11 describe('hydrateRequest', () => {12 it('should take a component request and return a hydrated component request', () => {13 // arrange14 const baseDir = join(process.cwd(), 'someDir', 'project');15 const componentsDir = join(baseDir, 'src', 'components');16 const context = {17 componentsDir: componentsDir18 };19 const request = {20 type: Constants.COMPONENT,21 name: 'settings view',22 includeSpec: true,23 includeNgModule: true24 };25 const templateDir = join(26 baseDir,27 'node_modules',28 'ionic-angular',29 'templates'30 );31 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(32 templateDir33 );34 // act35 const hydratedRequest = util.hydrateRequest(context, request);36 // assert37 expect(hydratedRequest).toEqual({38 className: 'SettingsViewComponent',39 dirToRead: join(templateDir, 'component'),40 dirToWrite: join(componentsDir, 'settings-view'),41 fileName: 'settings-view',42 importStatement: 'import { IonicPage, NavController, NavParams } from \'ionic-angular\';',43 includeNgModule: true,44 includeSpec: true,45 ionicPage: '\n@IonicPage()',46 name: 'settings view',47 type: 'component'48 });49 expect(hydratedRequest.type).toEqual(Constants.COMPONENT);50 expect(hydratedRequest.name).toEqual(request.name);51 expect(hydratedRequest.includeNgModule).toBeTruthy();52 expect(hydratedRequest.includeSpec).toBeTruthy();53 expect(hydratedRequest.className).toEqual('SettingsViewComponent');54 expect(hydratedRequest.fileName).toEqual('settings-view');55 expect(hydratedRequest.dirToRead).toEqual(56 join(templateDir, Constants.COMPONENT)57 );58 expect(hydratedRequest.dirToWrite).toEqual(59 join(componentsDir, hydratedRequest.fileName)60 );61 });62 it('should take a page request and return a hydrated page request', () => {63 // arrange64 const baseDir = join(process.cwd(), 'someDir', 'project');65 const pagesDir = join(baseDir, 'src', 'pages');66 const context = {67 pagesDir: pagesDir68 };69 const request = {70 type: Constants.PAGE,71 name: 'settings view',72 includeSpec: true,73 includeNgModule: true74 };75 const templateDir = join(76 baseDir,77 'node_modules',78 'ionic-angular',79 'templates'80 );81 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(82 templateDir83 );84 // act85 const hydratedRequest = util.hydrateRequest(context, request);86 // assert87 expect(hydratedRequest).toEqual({88 className: 'SettingsViewPage',89 dirToRead: join(templateDir, 'page'),90 dirToWrite: join(pagesDir, 'settings-view'),91 fileName: 'settings-view',92 importStatement: 'import { IonicPage, NavController, NavParams } from \'ionic-angular\';',93 includeNgModule: true,94 includeSpec: true,95 ionicPage: '\n@IonicPage()',96 name: 'settings view',97 type: 'page'98 });99 expect(hydratedRequest.type).toEqual(Constants.PAGE);100 expect(hydratedRequest.name).toEqual(request.name);101 expect(hydratedRequest.includeNgModule).toBeTruthy();102 expect(hydratedRequest.includeSpec).toBeTruthy();103 expect(hydratedRequest.className).toEqual('SettingsViewPage');104 expect(hydratedRequest.fileName).toEqual('settings-view');105 expect(hydratedRequest.dirToRead).toEqual(106 join(templateDir, Constants.PAGE)107 );108 expect(hydratedRequest.dirToWrite).toEqual(109 join(pagesDir, hydratedRequest.fileName)110 );111 });112 it('should take a page with no module request and return a hydrated page request', () => {113 // arrange114 const baseDir = join(process.cwd(), 'someDir', 'project');115 const pagesDir = join(baseDir, 'src', 'pages');116 const context = {117 pagesDir: pagesDir118 };119 const includeNgModule = false;120 const request = {121 type: Constants.PAGE,122 name: 'about',123 includeSpec: true,124 includeNgModule: false125 };126 const templateDir = join(127 baseDir,128 'node_modules',129 'ionic-angular',130 'templates'131 );132 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(133 templateDir134 );135 // act136 const hydratedRequest = util.hydrateRequest(context, request);137 // assert138 expect(hydratedRequest).toEqual({139 className: 'AboutPage',140 dirToRead: join(templateDir, 'page'),141 dirToWrite: join(pagesDir, 'about'),142 fileName: 'about',143 importStatement: 'import { NavController, NavParams } from \'ionic-angular\';',144 includeNgModule: false,145 includeSpec: true,146 ionicPage: null,147 name: 'about',148 type: 'page'149 });150 expect(hydratedRequest.ionicPage).toEqual(null);151 expect(hydratedRequest.importStatement).toEqual(152 'import { NavController, NavParams } from \'ionic-angular\';'153 );154 expect(hydratedRequest.type).toEqual(Constants.PAGE);155 expect(hydratedRequest.name).toEqual(request.name);156 expect(hydratedRequest.includeNgModule).toBeFalsy();157 expect(hydratedRequest.includeSpec).toBeTruthy();158 expect(hydratedRequest.className).toEqual('AboutPage');159 expect(hydratedRequest.fileName).toEqual('about');160 expect(hydratedRequest.dirToRead).toEqual(161 join(templateDir, Constants.PAGE)162 );163 expect(hydratedRequest.dirToWrite).toEqual(164 join(pagesDir, hydratedRequest.fileName)165 );166 });167 });168 describe('hydrateTabRequest', () => {169 it('should take a lazy loaded page set the tab root to a string', () => {170 // arrange171 const baseDir = join(process.cwd(), 'someDir', 'project');172 const pagesDir = join(baseDir, 'src', 'pages');173 const templateDir = join(174 baseDir,175 'node_modules',176 'ionic-angular',177 'templates'178 );179 const context: BuildContext = { pagesDir };180 const request = {181 type: 'tabs',182 name: 'stooges',183 includeNgModule: true,184 tabs: [185 {186 includeNgModule: true,187 type: 'page',188 name: 'moe',189 className: 'MoePage',190 fileName: 'moe',191 dirToRead: join(templateDir, 'page'),192 dirToWrite: join(pagesDir, 'moe')193 }194 ]195 };196 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(197 templateDir198 );199 // act200 const hydatedTabRequest = util.hydrateTabRequest(context, request);201 // assert202 expect(hydatedTabRequest.tabVariables).toEqual(` moeRoot = 'MoePage'\n`);203 });204 it('should take a page set the tab root to a component ref', () => {205 // arrange206 const baseDir = join(process.cwd(), 'someDir', 'project');207 const pagesDir = join(baseDir, 'src', 'pages');208 const templateDir = join(209 baseDir,210 'node_modules',211 'ionic-angular',212 'templates'213 );214 const context: BuildContext = { pagesDir };215 const request = {216 type: 'tabs',217 name: 'stooges',218 includeNgModule: false,219 tabs: [220 {221 includeNgModule: false,222 type: 'page',223 name: 'moe',224 className: 'MoePage',225 fileName: 'moe',226 dirToRead: join(templateDir, 'page'),227 dirToWrite: join(pagesDir, 'moe')228 }229 ]230 };231 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(232 templateDir233 );234 // act235 const hydatedTabRequest = util.hydrateTabRequest(context, request);236 // assert237 expect(hydatedTabRequest.tabVariables).toEqual(' moeRoot = MoePage\n');238 });239 });240 describe('readTemplates', () => {241 it('should get a map of templates and their content back', () => {242 // arrange243 const templateDir =244 '/Users/noone/project/node_modules/ionic-angular/templates/component';245 const knownValues = [246 'html.tmpl',247 'scss.tmpl',248 'spec.ts.tmpl',249 'ts.tmpl',250 'module.tmpl'251 ];252 const fileContent = 'SomeContent';253 spyOn(fs, 'readdirSync').and.returnValue(knownValues);254 spyOn(helpers, helpers.readFileAsync.name).and.returnValue(255 Promise.resolve(fileContent)256 );257 // act258 const promise = util.readTemplates(templateDir);259 // assert260 return promise.then((map: Map<string, string>) => {261 expect(map.get(join(templateDir, knownValues[0]))).toEqual(fileContent);262 expect(map.get(join(templateDir, knownValues[1]))).toEqual(fileContent);263 expect(map.get(join(templateDir, knownValues[2]))).toEqual(fileContent);264 expect(map.get(join(templateDir, knownValues[3]))).toEqual(fileContent);265 expect(map.get(join(templateDir, knownValues[4]))).toEqual(fileContent);266 });267 });268 });269 describe('filterOutTemplates', () => {270 it('should preserve all templates', () => {271 const map = new Map<string, string>();272 const templateDir =273 '/Users/noone/project/node_modules/ionic-angular/templates/component';274 const fileContent = 'SomeContent';275 const knownValues = [276 'html.tmpl',277 'scss.tmpl',278 'spec.ts.tmpl',279 'ts.tmpl',280 'module.tmpl'281 ];282 map.set(join(templateDir, knownValues[0]), fileContent);283 map.set(join(templateDir, knownValues[1]), fileContent);284 map.set(join(templateDir, knownValues[2]), fileContent);285 map.set(join(templateDir, knownValues[3]), fileContent);286 map.set(join(templateDir, knownValues[4]), fileContent);287 const newMap = util.filterOutTemplates(288 { includeNgModule: true, includeSpec: true },289 map290 );291 expect(newMap.size).toEqual(knownValues.length);292 });293 it('should remove spec', () => {294 const map = new Map<string, string>();295 const templateDir =296 '/Users/noone/project/node_modules/ionic-angular/templates/component';297 const fileContent = 'SomeContent';298 const knownValues = [299 'html.tmpl',300 'scss.tmpl',301 'spec.ts.tmpl',302 'ts.tmpl',303 'module.tmpl'304 ];305 map.set(join(templateDir, knownValues[0]), fileContent);306 map.set(join(templateDir, knownValues[1]), fileContent);307 map.set(join(templateDir, knownValues[2]), fileContent);308 map.set(join(templateDir, knownValues[3]), fileContent);309 map.set(join(templateDir, knownValues[4]), fileContent);310 const newMap = util.filterOutTemplates(311 { includeNgModule: true, includeSpec: false },312 map313 );314 expect(newMap.size).toEqual(4);315 expect(newMap.get(join(templateDir, knownValues[0]))).toBeTruthy();316 expect(newMap.get(join(templateDir, knownValues[1]))).toBeTruthy();317 expect(newMap.get(join(templateDir, knownValues[2]))).toBeFalsy();318 expect(newMap.get(join(templateDir, knownValues[3]))).toBeTruthy();319 expect(newMap.get(join(templateDir, knownValues[4]))).toBeTruthy();320 });321 it('should remove spec and module', () => {322 const map = new Map<string, string>();323 const templateDir =324 '/Users/noone/project/node_modules/ionic-angular/templates/component';325 const fileContent = 'SomeContent';326 const knownValues = [327 'html.tmpl',328 'scss.tmpl',329 'spec.ts.tmpl',330 'ts.tmpl',331 'module.ts.tmpl'332 ];333 map.set(join(templateDir, knownValues[0]), fileContent);334 map.set(join(templateDir, knownValues[1]), fileContent);335 map.set(join(templateDir, knownValues[2]), fileContent);336 map.set(join(templateDir, knownValues[3]), fileContent);337 map.set(join(templateDir, knownValues[4]), fileContent);338 const newMap = util.filterOutTemplates(339 { includeNgModule: false, includeSpec: false },340 map341 );342 expect(newMap.size).toEqual(3);343 expect(newMap.get(join(templateDir, knownValues[0]))).toBeTruthy();344 expect(newMap.get(join(templateDir, knownValues[1]))).toBeTruthy();345 expect(newMap.get(join(templateDir, knownValues[2]))).toBeFalsy();346 expect(newMap.get(join(templateDir, knownValues[3]))).toBeTruthy();347 expect(newMap.get(join(templateDir, knownValues[4]))).toBeFalsy();348 });349 });350 describe('applyTemplates', () => {351 it('should replace the template content', () => {352 const fileOne = '/Users/noone/fileOne';353 const fileOneContent = `354<!--355 Generated template for the $CLASSNAME component.356 See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html357 for more info on Angular 2 Components.358-->359{{text}}360 `;361 const fileTwo = '/Users/noone/fileTwo';362 const fileTwoContent = `363$FILENAME {364}365 `;366 const fileThree = '/Users/noone/fileThree';367 const fileThreeContent = `368describe('$CLASSNAME', () => {369 it('should do something', () => {370 expect(true).toEqual(true);371 });372});373 `;374 const fileFour = '/Users/noone/fileFour';375 const fileFourContent = `376import { Component } from '@angular/core';377/*378 Generated class for the $CLASSNAME component.379 See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html380 for more info on Angular 2 Components.381*/382@Component({383 selector: '$FILENAME',384 templateUrl: '$FILENAME.html'385})386export class $CLASSNAMEComponent {387 text: string;388 constructor() {389 console.log('Hello $CLASSNAME Component');390 this.text = 'Hello World';391 }392}393 `;394 const fileFive = '/Users/noone/fileFive';395 const fileFiveContent = `396import { NgModule } from '@angular/core';397import { $CLASSNAME } from './$FILENAME';398import { IonicModule } from 'ionic-angular';399@NgModule({400 declarations: [401 $CLASSNAME,402 ],403 imports: [404 IonicModule.forChild($CLASSNAME)405 ],406 entryComponents: [407 $CLASSNAME408 ],409 providers: []410})411export class $CLASSNAMEModule {}412 `;413 const fileSix = '/Users/noone/fileSix';414 const fileSixContent = `415<!--416 Generated template for the $CLASSNAME page.417 See http://ionicframework.com/docs/v2/components/#navigation for more info on418 Ionic pages and navigation.419-->420<ion-header>421 <ion-navbar>422 <ion-title>$SUPPLIEDNAME</ion-title>423 </ion-navbar>424</ion-header>425<ion-content padding>426</ion-content>427 `;428 const fileSeven = '/Users/noone/fileSeven';429 const fileSevenContent = `430<ion-tabs>431$TAB_CONTENT432</ion-tabs>433 `;434 const map = new Map<string, string>();435 map.set(fileOne, fileOneContent);436 map.set(fileTwo, fileTwoContent);437 map.set(fileThree, fileThreeContent);438 map.set(fileFour, fileFourContent);439 map.set(fileFive, fileFiveContent);440 map.set(fileSix, fileSixContent);441 map.set(fileSeven, fileSevenContent);442 const className = 'SettingsView';443 const fileName = 'settings-view';444 const suppliedName = 'settings view';445 const results = util.applyTemplates(446 { name: suppliedName, className: className, fileName: fileName },447 map448 );449 const modifiedContentOne = results.get(fileOne);450 const modifiedContentTwo = results.get(fileTwo);451 const modifiedContentThree = results.get(fileThree);452 const modifiedContentFour = results.get(fileFour);453 const modifiedContentFive = results.get(fileFive);454 const modifiedContentSix = results.get(fileSix);455 const modifiedContentSeven = results.get(fileSeven);456 const nonExistentVars = [457 GeneratorConstants.CLASSNAME_VARIABLE,458 GeneratorConstants.FILENAME_VARIABLE,459 GeneratorConstants.SUPPLIEDNAME_VARIABLE,460 GeneratorConstants.TAB_CONTENT_VARIABLE,461 GeneratorConstants.TAB_VARIABLES_VARIABLE462 ];463 for (let v of nonExistentVars) {464 expect(modifiedContentOne.indexOf(v)).toEqual(-1);465 expect(modifiedContentTwo.indexOf(v)).toEqual(-1);466 expect(modifiedContentThree.indexOf(v)).toEqual(-1);467 expect(modifiedContentFour.indexOf(v)).toEqual(-1);468 expect(modifiedContentFive.indexOf(v)).toEqual(-1);469 expect(modifiedContentSix.indexOf(v)).toEqual(-1);470 expect(modifiedContentSeven.indexOf(v)).toEqual(-1);471 }472 });473 });474 describe('writeGeneratedFiles', () => {475 it('should return the list of files generated', () => {476 const map = new Map<string, string>();477 const templateDir =478 '/Users/noone/project/node_modules/ionic-angular/templates/component';479 const fileContent = 'SomeContent';480 const knownValues = [481 'html.tmpl',482 'scss.tmpl',483 'spec.ts.tmpl',484 'ts.tmpl',485 'module.tmpl'486 ];487 const fileName = 'settings-view';488 const dirToWrite = join('/Users/noone/project/src/components', fileName);489 map.set(join(templateDir, knownValues[0]), fileContent);490 map.set(join(templateDir, knownValues[1]), fileContent);491 map.set(join(templateDir, knownValues[2]), fileContent);492 map.set(join(templateDir, knownValues[3]), fileContent);493 map.set(join(templateDir, knownValues[4]), fileContent);494 spyOn(helpers, helpers.mkDirpAsync.name).and.returnValue(495 Promise.resolve()496 );497 spyOn(helpers, helpers.writeFileAsync.name).and.returnValue(498 Promise.resolve()499 );500 const promise = util.writeGeneratedFiles(501 { dirToWrite: dirToWrite, fileName: fileName },502 map503 );504 return promise.then((filesCreated: string[]) => {505 const fileExtensions = knownValues.map(knownValue =>506 basename(knownValue, GeneratorConstants.KNOWN_FILE_EXTENSION)507 );508 expect(filesCreated[0]).toEqual(509 join(dirToWrite, `${fileName}.${fileExtensions[0]}`)510 );511 expect(filesCreated[1]).toEqual(512 join(dirToWrite, `${fileName}.${fileExtensions[1]}`)513 );514 expect(filesCreated[2]).toEqual(515 join(dirToWrite, `${fileName}.${fileExtensions[2]}`)516 );517 expect(filesCreated[3]).toEqual(518 join(dirToWrite, `${fileName}.${fileExtensions[3]}`)519 );520 expect(filesCreated[4]).toEqual(521 join(dirToWrite, `${fileName}.${fileExtensions[4]}`)522 );523 });524 });525 });526 describe('getDirToWriteToByType', () => {527 let context: any;528 const componentsDir = '/path/to/components';529 const directivesDir = '/path/to/directives';530 const pagesDir = '/path/to/pages';531 const pipesDir = '/path/to/pipes';532 const providersDir = '/path/to/providers';533 beforeEach(() => {534 context = {535 componentsDir,536 directivesDir,537 pagesDir,538 pipesDir,539 providersDir540 };541 });542 it('should return the appropriate components directory', () => {543 expect(util.getDirToWriteToByType(context, 'component')).toEqual(544 componentsDir545 );546 });547 it('should return the appropriate directives directory', () => {548 expect(util.getDirToWriteToByType(context, 'directive')).toEqual(549 directivesDir550 );551 });552 it('should return the appropriate pages directory', () => {553 expect(util.getDirToWriteToByType(context, 'page')).toEqual(pagesDir);554 });555 it('should return the appropriate pipes directory', () => {556 expect(util.getDirToWriteToByType(context, 'pipe')).toEqual(pipesDir);557 });558 it('should return the appropriate providers directory', () => {559 expect(util.getDirToWriteToByType(context, 'provider')).toEqual(560 providersDir561 );562 });563 it('should throw error upon unknown generator type', () => {564 expect(() => util.getDirToWriteToByType(context, 'dan')).toThrowError(565 'Unknown Generator Type: dan'566 );567 });568 });569 describe('getNgModules', () => {570 let context: any;571 const componentsDir = join(process.cwd(), 'path', 'to', 'components');572 const directivesDir = join(process.cwd(), 'path', 'to', 'directives');573 const pagesDir = join(process.cwd(), 'path', 'to', 'pages');574 const pipesDir = join(process.cwd(), 'path', 'to', 'pipes');575 const providersDir = join(process.cwd(), 'path', 'to', 'providers');576 beforeEach(() => {577 context = {578 componentsDir,579 directivesDir,580 pagesDir,581 pipesDir,582 providersDir583 };584 });585 it('should return an empty list of glob results', () => {586 const globAllSpy = spyOn(globUtils, globUtils.globAll.name);587 util.getNgModules(context, []);588 expect(globAllSpy).toHaveBeenCalledWith([]);589 });590 it('should return a list of glob results for components', () => {591 const globAllSpy = spyOn(globUtils, globUtils.globAll.name);592 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(593 '.module.ts'594 );595 util.getNgModules(context, ['component']);596 expect(globAllSpy).toHaveBeenCalledWith([597 join(componentsDir, '**', '*.module.ts')598 ]);599 });600 it('should return a list of glob results for pages and components', () => {601 const globAllSpy = spyOn(globUtils, globUtils.globAll.name);602 spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(603 '.module.ts'604 );605 util.getNgModules(context, ['page', 'component']);606 expect(globAllSpy).toHaveBeenCalledWith([607 join(pagesDir, '**', '*.module.ts'),608 join(componentsDir, '**', '*.module.ts')609 ]);610 });611 });...

Full Screen

Full Screen

webpack.config.js

Source:webpack.config.js Github

copy

Full Screen

1const path = require('path');2const fs = require('fs');3const HtmlWebpackPlugin = require('html-webpack-plugin');4const MiniCssExtractPlugin = require('mini-css-extract-plugin');5const CopyPlugin = require('copy-webpack-plugin');6const excludeDirs = ['css', 'images', 'lib', 'api', '_hello-ts'];7const htmlPlugins = generateHtmlPlugins('./src', excludeDirs);8const entryPoints = generateEntryPoints('./src', 'index.ts', excludeDirs);9module.exports = {10 entry: entryPoints,11 output: {12 filename: '[name]/index.js',13 path: path.resolve(__dirname, 'dist'),14 },15 devtool: 'inline-source-map',16 module: {17 rules: [18 {19 test: /\.ts?$/,20 use: 'ts-loader',21 exclude: /node_modules/,22 },23 {24 test: /\.(sa|sc|c)ss$/,25 use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],26 },27 ],28 },29 resolve: {30 extensions: ['.ts', '.js'],31 },32 plugins: [33 new MiniCssExtractPlugin({ filename: '[name]/style.css' }),34 new CopyPlugin({35 patterns: [36 { from: 'src/images', to: 'images' },37 { from: 'src/api', to: 'api' },38 ],39 }),40 new HtmlWebpackPlugin({41 template: './index.html',42 inject: false,43 }),44 ].concat(htmlPlugins),45 devServer: {46 contentBase: './dist',47 compress: true,48 port: 9000,49 },50};51// Create dist/templateDir/*.html file for each templateDir found in root52// Only include bundle/chunk associated with HTML file53function generateHtmlPlugins(root, excludeDirs) {54 let plugins = [];55 const rootDir = fs.readdirSync(path.resolve(__dirname, root));56 // Find directories in root folder57 rootDir.forEach((templateDir) => {58 const stats = fs.lstatSync(path.resolve(__dirname, root, templateDir));59 if (stats.isDirectory() && !excludeDirs.includes(templateDir)) {60 // Read files in template directory61 const dirName = templateDir;62 const templateFiles = fs.readdirSync(63 path.resolve(__dirname, root, templateDir),64 );65 templateFiles.forEach((item) => {66 // Split names and extension67 const parts = item.split('.');68 const name = parts[0];69 const extension = parts[1];70 // If we find an html file then create an HtmlWebpackPlugin71 if (extension === 'html') {72 // Create new HTMLWebpackPlugin with options73 plugins.push(74 new HtmlWebpackPlugin({75 filename: `${dirName}/index.html`,76 template: path.resolve(77 __dirname,78 `${root}/${templateDir}/${name}.${extension}`,79 ),80 inject: 'body',81 // Only include bundle/chunk associated with the templateDir directory82 chunks: [`${dirName}`],83 }),84 );85 }86 });87 }88 });89 return plugins;90}91// Create an entry point for each directory found in 'root'.92// This will also create a bundle/chunk for each directory93// and place it in the dist/[templateDir] directory.94function generateEntryPoints(root, entryScript, excludeDirs) {95 const rootDir = fs.readdirSync(path.resolve(__dirname, root));96 let entryPoints = { css: './src/css/style.scss' };97 rootDir.forEach((templateDir) => {98 const stats = fs.lstatSync(path.resolve(__dirname, root, templateDir));99 if (stats.isDirectory() && !excludeDirs.includes(templateDir)) {100 entryPoints[templateDir] = `${root}/${templateDir}/${entryScript}`;101 }102 });103 return entryPoints;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import templateDir from 'storybook-root-decorator';2const template = templateDir(__dirname);3export const story1 = () => template('./story1.html');4export const story2 = () => template('./story2.html');5export const story3 = () => template('./story3.html');6export const story4 = () => template('./story4.html');7export const story5 = () => template('./story5.html');8export const story6 = () => template('./story6.html');9export const story7 = () => template('./story7.html');10export const story8 = () => template('./story8.html');11export const story9 = () => template('./story9.html');12export const story10 = () => template('./story10.html');13export const story11 = () => template('./story11.html');14export const story12 = () => template('./story12.html');15export const story13 = () => template('./story13.html');16export const story14 = () => template('./story14.html');17export const story15 = () => template('./story15.html');18export const story16 = () => template('./story16.html');

Full Screen

Using AI Code Generation

copy

Full Screen

1const templateDir = require('storybook-root-config').templateDir;2const path = require('path');3module.exports = {4 stories: [templateDir(path.resolve(__dirname, '../src'))],5 webpackFinal: async config => {6 return config;7 },8};9export const parameters = {10 actions: { argTypesRegex: '^on[A-Z].*' },11 docs: {12 extractComponentDescription: (component, { notes }) => {13 if (notes) {14 return notes;15 }16 return null;17 },18 },19 options: {20 storySort: {21 },22 },23};24import { addons } from '@storybook/addons';25import { themes } from '@storybook/theming';26addons.setConfig({27});28import { configure } from '@storybook/react';29const req = require.context('../components', true, /.stories.js$/);30function loadStories() {31 req.keys().forEach(filename => req(filename));32}33configure(loadStories, module);34const path = require('path');35module.exports = ({ config }) => {36 config.module.rules.push({37 include: path.resolve(__dirname, '../'),38 });39 return config;40};41 .sbdocs.sbdocs-wrapper {42 overflow: hidden;43 }44import React from 'react';45import { storiesOf } from '@storybook/react';46import { text, boolean, select }

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require("path");2const { templateDir } = require("storybook-root-config");3module.exports = {4 stories: [templateDir("./stories/**/*.stories.js")],5};6const path = require("path");7const { templateDir } = require("storybook-root-config");8module.exports = {9 stories: [templateDir("./stories/**/*.stories.js")],10};11const path = require("path");12const { templateDir } = require("storybook-root-config");13module.exports = {14 stories: [templateDir("./stories/**/*.stories.js")],15};16const path = require("path");17const { templateDir } = require("storybook-root-config");18module.exports = {19 stories: [templateDir("./stories/**/*.stories.js")],20};21const path = require("path");22const { templateDir } = require("storybook-root-config");23module.exports = {24 stories: [templateDir("./stories/**/*.stories.js")],25};26const path = require("path");27const { templateDir } = require("storybook-root-config");28module.exports = {29 stories: [templateDir("./stories/**/*.stories.js")],30};31const path = require("path");32const { templateDir } = require("storybook-root-config");33module.exports = {34 stories: [templateDir("./stories/**/*.stories.js")],35};36const path = require("path");

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 webpackFinal: async (config, { configType }) => {3 config.module.rules.push({4 include: path.resolve(__dirname, '../'),5 });6 return config;7 },8};9import { addDecorator } from '@storybook/react';10import { withA11y } from '@storybook/addon-a11y';11import { withKnobs } from '@storybook/addon-knobs';12import { withTests } from '@storybook/addon-jest';13import { withBackgrounds } from '@storybook/addon-backgrounds';14import { withViewport } from '@storybook/addon-viewport';15import { withInfo } from '@storybook/addon-info';16import { withNotes } from '@storybook/addon-notes';17import { withStorySource } from '@storybook/addon-storysource';18import { withDocs } from '@storybook/addon-docs';19import { withCentered } from '@storybook/addon-centered/react';20import results from '../.jest-test-results.json';21import { addReadme } from 'storybook-readme';22import { withTests as withTestsAddon } from '@storybook/addon-jest';23import { withConsole } from '@storybook/addon-console';24import { withA11y } from '@storybook/addon-a11y';25import {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful