How to use storyFileNames method in storybook-root

Best JavaScript code snippet using storybook-root

project_data.js

Source: project_data.js Github

copy

Full Screen

1const fs = require('fs');2const Store = require('electron-store');3const { ipcMain } = require('electron');4const parse = require('papaparse');5const tsvParser = require('../​../​app/​TSVParser');6const tsvBuilder = require('../​../​app/​JSONtoTSV');7const Meta = require('./​meta_data');8module.exports = class Project {9 constructor( win, path ) {10 let segments = path.split('/​');11 this.window = win;12 this.path = path;13 this.store = new Store();14 this.name = segments[segments.length - 1];15 this.metaBuilder = new Meta();16 Project.Current = this;17 }18 create() {19 let split = this.path.split('/​');20 let projectName = split[split.length - 1];21 let content = 'Scene Character Text Actions Conditions\nScene 1 Character 1 First Line';22 fs.writeFileSync(`${this.path}/​${projectName}.tsv`, content);23 this.read();24 }25 reset() {26 fs.rmdirSync(`${this.path}/​meta`, { recursive: true });27 fs.rmSync(`${this.path}/​project-meta.json`);28 this.read();29 }30 save() {31 console.time('save-all');32 this.storyFileNames.forEach((filename, index) => {33 let document = JSON.parse(this.projectData.documents[index]);34 let tsv = tsvBuilder.build(document.story);35 36 fs.writeFile(`${this.path}/​${filename}`, tsv, 37 (err) => { if (err) console.error(err); });38 });39 console.timeEnd('save-all');40 }41 read() {42 console.time('read');43 let projectContents = fs.readdirSync(this.path);44 if (!projectContents.find(f => f === 'meta'))45 fs.mkdirSync(`${this.path}/​meta`);46 47 this.storyFileNames = projectContents.filter(file => file.match(/​.*\.tsv$/​));48 this.storyFileNames49 .filter(file => !fs.existsSync(this.getMetaPath(file)))50 .forEach(file => fs.writeFileSync(this.getMetaPath(file), 51 JSON.stringify( this.buildStoryMeta(file), null, 2 )));52 53 let projectMeta = {};54 55 if (fs.existsSync(`${this.path}/​lookup/​lookup.tsv`))56 {57 let lookup = fs.readFileSync(`${this.path}/​lookup/​lookup.tsv`).toString();58 let parsedLookup = parse.parse(lookup, { delimiter: '\t', encoding: 'utf-8', header: false, trimHeaders: false, });59 60 projectMeta.lookup = parsedLookup.data61 .map(line => { return {'key': line[0], 'values': line.splice(1, line.length - 1).filter(value => value) }; });62 }63 if (!fs.existsSync(`${this.path}/​project-meta.json`))64 fs.writeFileSync(`${this.path}/​project-meta.json`, JSON.stringify(projectMeta, null, 2));65 66 this.store.set('project-path', this.path);67 this.renderProject();68 console.timeEnd('read');69 }70 renderProject() {71 console.time('renderProject');72 this.projectData = {73 names: this.name,74 documents: [],75 };76 this.storyFileNames.forEach(filename => {77 let document = fs.readFileSync( this.getMetaPath(filename), 'utf-8' ).toString();78 this.projectData.documents.push(document);79 });80 let lookup = this.metaBuilder.buildLookup(this.projectData.documents);81 var metaDataJSON = fs.readFileSync(`${this.path}/​project-meta.json`).toString();82 this.metaData = JSON.parse(metaDataJSON);83 this.metaData.lookup = lookup;84 let currentDocumentIndex = this.storyFileNames.indexOf(this.metaData.currentDocument);85 if (currentDocumentIndex < 0) currentDocumentIndex = 0;86 this.window.webContents.executeJavaScript(`setProject(${JSON.stringify(this.storyFileNames)})`);87 this.window.webContents.executeJavaScript(`setDocument(${this.projectData.documents[currentDocumentIndex]})`);88 ipcMain.removeAllListeners('commit-document');89 ipcMain.removeAllListeners('select-document');90 ipcMain.on('commit-document', (event, args) => {91 console.time('commit-document');92 let file = this.getMetaPath( args.meta.fileName );93 let json = JSON.stringify( args, null, 2 );94 95 let index = this.storyFileNames.indexOf(args.meta.fileName);96 this.projectData.documents[index] = json;97 fs.writeFileSync( file, json );98 99 this.metaData.lookup = lookup;100 metaDataJSON = JSON.stringify(this.metaData, null, 2);101 fs.writeFileSync(`${this.path}/​project-meta.json`, metaDataJSON);102 console.timeEnd('commit-document');103 });104 ipcMain.on('select-document', (event, file) => {105 let index = this.storyFileNames.indexOf(file);106 let document = this.projectData.documents[index];107 this.window.webContents.executeJavaScript(`setDocument(${document})`);108 this.metaData.currentDocument = file;109 fs.writeFileSync( `${this.path}/​project-meta.json`, JSON.stringify(this.metaData, null, 2) );110 });111 112 this.window.webContents.executeJavaScript(`setMetaData(${metaDataJSON})`);113 console.timeEnd('renderProject');114 }115 buildStoryMeta( storyFilePath ) {116 117 let fileName = storyFilePath;118 let hasChanges = false;119 let sceneColors = [];120 let currentScene = '';121 122 let tsv = fs.readFileSync(`${this.path}/​${storyFilePath}`, 'utf-8').toString();123 let json = tsvParser.parseTSV(tsv);124 125 return { meta: { fileName, hasChanges, currentScene, sceneColors }, story: json };126 }127 getMetaPath( file ) {128 return `${this.path}/​meta/​${file}-meta.json`;129 }...

Full Screen

Full Screen

build_database-DEPREC.js

Source: build_database-DEPREC.js Github

copy

Full Screen

1const fs = require('fs');2function build(storyFilesDir, indexFileName, dbFileName) {3 const db = {4 'index': JSON.parse(fs.readFileSync(indexFileName, 'utf8')),5 'stories': [],6 'search_index': []7 };8 const storyFileNames = fs.readdirSync(storyFilesDir).filter(f => f[0] != "."); /​/​ excludes hidden files9 for (const storyFileName of storyFileNames) {10 /​/​ console.log("Reading " + storyFileName);11 db['stories'].push(JSON.parse(fs.readFileSync(storyFilesDir + storyFileName, 'utf8')));12 }13 db['search_index'] = db['search_index'].concat(build_search());14 const dbPrettyString = JSON.stringify(db, null, 2);15 fs.writeFileSync(dbFileName, dbPrettyString);16 console.log("📤 The database was updated.");17}18module.exports = {19 build: build20};21function build_search() {22 const jsonFileNames = fs.readdirSync("data/​json_files");23 /​/​ const searchFileName = "data/​search_index.json";24 25 /​/​ Concatenate sentences from each story together26 let sentences = [];27 for (const jsonFileName of jsonFileNames) {28 const jsonPath = "data/​json_files/​" + jsonFileName;29 const f = require(jsonPath); /​/​ JSON.parse(fs.readFileSync(jsonPath))30 const storyID = f.metadata["story ID"];31 /​/​ not sure why _default isn't top level32 const title = f.metadata["title"]["_default"];33 const newSentences = f["sentences"];34 for (sentence in newSentences) {35 newSentences[sentence]["story ID"] = storyID;36 newSentences[sentence]["title"] = title;37 }38 sentences = sentences.concat(newSentences);39 }40 /​/​ Write sentences into search_index.json41 const data = [];42 for (i in sentences) {43 const sentence = sentences[i];44 const reformatted = {45 "num_slots" : sentence["num_slots"],46 "text" : sentence["text"],47 "story ID" : sentence["story ID"],48 "title" : sentence["title"],49 "start_time_ms" : sentence["start_time_ms"],50 "dependents" : {}51 };52 /​/​ Top level line not included in sentence.dependents so it has to be handled53 /​/​ seperately54 let tierName = sentence.tier;55 reformatted["dependents"][tierName] = {"value": sentence.text};56 for (j in sentence["dependents"]) {57 tier = sentence["dependents"][j];58 tierName = tier.tier;59 reformatted["dependents"][tierName] = tier.values;60 }61 data.push(reformatted);62 }63 return data;...

Full Screen

Full Screen

build_database.js

Source: build_database.js Github

copy

Full Screen

1const fs = require('fs');2function build(storyFilesDir, indexFileName, dbFileName) {3 const db = {4 'index': JSON.parse(fs.readFileSync(indexFileName, 'utf8')),5 'stories': []6 };7 const storyFileNames = fs.readdirSync(storyFilesDir).filter(f => f[0] != "."); /​/​ excludes hidden files8 for (const storyFileName of storyFileNames) {9 /​/​ console.log("Reading " + storyFileName);10 db['stories'].push(JSON.parse(fs.readFileSync(storyFilesDir + storyFileName, 'utf8')));11 }12 const dbPrettyString = JSON.stringify(db, null, 2);13 fs.writeFileSync(dbFileName, dbPrettyString);14 console.log("📤 The database was updated.");15}16module.exports = {17 build: build...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const storybookRoot = require('storybook-root');2const storyFileNames = storybookRoot.storyFileNames;3const storyFileNamesArray = storyFileNames();4const storybookRoot = require('storybook-root');5const storyFileNames = storybookRoot.storyFileNames;6const storyFileNamesArray = storyFileNames();7const storybookRoot = require('storybook-root');8const storyFileNames = storybookRoot.storyFileNames;9const storyFileNamesArray = storyFileNames();10const storybookRoot = require('storybook-root');11const storyFileNames = storybookRoot.storyFileNames;12const storyFileNamesArray = storyFileNames();13const storybookRoot = require('storybook-root');14const storyFileNames = storybookRoot.storyFileNames;15const storyFileNamesArray = storyFileNames();16const storybookRoot = require('storybook-root');17const storyFileNames = storybookRoot.storyFileNames;18const storyFileNamesArray = storyFileNames();19const storybookRoot = require('storybook-root');20const storyFileNames = storybookRoot.storyFileNames;21const storyFileNamesArray = storyFileNames();22const storybookRoot = require('storybook-root');23const storyFileNames = storybookRoot.storyFileNames;24const storyFileNamesArray = storyFileNames();25const storybookRoot = require('storybook-root');26const storyFileNames = storybookRoot.storyFileNames;27const storyFileNamesArray = storyFileNames();28const storybookRoot = require('storybook-root');29const storyFileNames = storybookRoot.storyFileNames;30const storyFileNamesArray = storyFileNames();31const storybookRoot = require('storybook-root');

Full Screen

Using AI Code Generation

copy

Full Screen

1const storybookRoot = require('@storybook/​react/​standalone');2const storyFileNames = storybookRoot.storyFileNames;3const storybookRoot = require('@storybook/​react/​standalone');4const storyFileNames = storybookRoot.storyFileNames;5const storybookRoot = require('@storybook/​react/​standalone');6const storyFileNames = storybookRoot.storyFileNames;7const storybookRoot = require('@storybook/​react/​standalone');8const storyFileNames = storybookRoot.storyFileNames;9const storybookRoot = require('@storybook/​react/​standalone');10const storyFileNames = storybookRoot.storyFileNames;11const storybookRoot = require('@storybook/​react/​standalone');12const storyFileNames = storybookRoot.storyFileNames;13const storybookRoot = require('@storybook/​react/​standalone');14const storyFileNames = storybookRoot.storyFileNames;15const storybookRoot = require('@storybook/​react/​standalone');16const storyFileNames = storybookRoot.storyFileNames;17const storybookRoot = require('@storybook/​react/​standalone');18const storyFileNames = storybookRoot.storyFileNames;19const storybookRoot = require('@storybook/​react/​standalone');20const storyFileNames = storybookRoot.storyFileNames;21const storybookRoot = require('@storybook/​react/​standalone');22const storyFileNames = storybookRoot.storyFileNames;23const storybookRoot = require('@storybook/​react/​standalone');24const storyFileNames = storybookRoot.storyFileNames;25const storybookRoot = require('@

Full Screen

Using AI Code Generation

copy

Full Screen

1const storyFiles = require('storybook-root').storyFileNames();2console.log(storyFiles);3const storyFiles = require('storybook-root').storyFileNames();4console.log(storyFiles);5const storyFiles = require('storybook-root').storyFileNames();6console.log(storyFiles);7const storyFiles = require('storybook-root').storyFileNames();8console.log(storyFiles);9const storyFiles = require('storybook-root').storyFileNames();10console.log(storyFiles);11const storyFiles = require('storybook-root').storyFileNames();12console.log(storyFiles);13const storyFiles = require('storybook-root').storyFileNames();14console.log(storyFiles);15const storyFiles = require('storybook-root').storyFileNames();16console.log(storyFiles);17const storyFiles = require('storybook-root').storyFileNames();18console.log(storyFiles);19const storyFiles = require('storybook-root').storyFileNames();20console.log(storyFiles);21const storyFiles = require('storybook-root').storyFileNames();22console.log(storyFiles);23const storyFiles = require('storybook-root').storyFileNames();24console.log(storyFiles);25const storyFiles = require('storybook-root').storyFileNames();26console.log(storyFiles);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storyFileNames } from 'storybook-root';2import { configure } from 'storybook-root';3import { addDecorator } from 'storybook-root';4import { addParameters } from 'storybook-root';5import { addLoader } from 'storybook-root';6import { addDecoratorWithParams } from 'storybook-root';7configure(loadStories, module);8addDecorator(decorator);9addParameters(parameter);10addLoader(loader);11addDecoratorWithParams(decorator, params);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storyFileNames } from './​storybook-root';2const storyFiles = storyFileNames();3console.log('storyFiles', storyFiles);4import glob from 'glob';5export const storyFileNames = () => {6 const storyFiles = glob.sync('./​src/​**/​*.stories.js');7 return storyFiles;8};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storiesOf } from '@storybook/​react';2import { storyFileNames } from '@storybook/​react/​demo';3import React from 'react';4const stories = storyFileNames.map(storyFileName => {5 const story = require(storyFileName);6 return story;7});8describe('The storybook', () => {9 stories.forEach(story => {10 storiesOf(story.kind, module).add(story.name, story.story);11 });12});

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Oct’22 Updates: New Analytics And App Automation Dashboard, Test On Google Pixel 7 Series, And More

Hey everyone! We hope you had a great Hacktober. At LambdaTest, we thrive to bring you the best with each update. Our engineering and tech teams work at lightning speed to deliver you a seamless testing experience.

Now Log Bugs Using LambdaTest and DevRev

In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.

How To Run Cypress Tests In Azure DevOps Pipeline

When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.

How to Position Your Team for Success in Estimation

Estimates are critical if you want to be successful with projects. If you begin with a bad estimating approach, the project will almost certainly fail. To produce a much more promising estimate, direct each estimation-process issue toward a repeatable standard process. A smart approach reduces the degree of uncertainty. When dealing with presales phases, having the most precise estimation findings can assist you to deal with the project plan. This also helps the process to function more successfully, especially when faced with tight schedules and the danger of deviation.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

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