How to use projectRoot method in storybook-root

Best JavaScript code snippet using storybook-root

bundle.spec.js

Source:bundle.spec.js Github

copy

Full Screen

1/* global adminPath */2/* global projectRoot */3// eslint-disable-next-line4const util = require('util');5const fs = require('fs');6// eslint-disable-next-line7const path = require('path');8// eslint-disable-next-line9const { sep } = require('path');10const dircompare = require('dir-compare');11const exec = util.promisify(require('child_process').exec);12const readdir = util.promisify(fs.readdir);13jest.spyOn(global.console, 'info').mockImplementation(() => jest.fn());14const runBundleTests = process.env.CI === 'true' ? describe : describe.skip;15runBundleTests('webpack/bundle', () => {16 beforeEach(async () => {17 // Increase default timeout for the webpack build18 jest.setTimeout(5 * 60 * 1000);19 // if plugin folder exists20 if (fs.existsSync(path.resolve(projectRoot, 'custom/plugins'))) {21 // delete Backup Plugin Folder22 await exec(`rm -rf ${path.resolve(projectRoot, 'custom/plugins-backup')}`);23 // backup Plugin Folder24 // eslint-disable-next-line max-len25 await exec(`mv ${path.resolve(projectRoot, 'custom/plugins')} ${path.resolve(projectRoot, 'custom/plugins-backup')}`);26 }27 // if bundles folder exists28 if (fs.existsSync(path.resolve(projectRoot, 'public/bundles'))) {29 // delete Backup Bundle Folder30 await exec(`rm -rf ${path.resolve(projectRoot, 'public/bundles-backup')}`);31 // backup Bundle Folder32 // eslint-disable-next-line max-len33 await exec(`mv ${path.resolve(projectRoot, 'public/bundles')} ${path.resolve(projectRoot, 'public/bundles-backup')}`);34 }35 });36 afterEach(async () => {37 // // delete Plugin Folder38 await exec(`rm -rf ${path.resolve(projectRoot, 'custom/plugins')}`);39 // delete Bundle Folder40 await exec(`rm -rf ${path.resolve(projectRoot, 'public/bundles')}`);41 // if plugins-backup folder exists42 if (fs.existsSync(`${path.resolve(projectRoot, 'custom/plugins-backup')}`)) {43 // restore Plugin Folder44 // eslint-disable-next-line max-len45 await exec(`mv ${path.resolve(projectRoot, 'custom/plugins-backup')} ${path.resolve(projectRoot, 'custom/plugins')}`);46 }47 // if bundles-backup folder exists48 if (fs.existsSync(`${path.resolve(projectRoot, 'public/bundles-backup')}`)) {49 // restore Bundle Folder50 // eslint-disable-next-line max-len51 await exec(`mv ${path.resolve(projectRoot, 'public/bundles-backup')} ${path.resolve(projectRoot, 'public/bundles')}`);52 }53 });54 it('should build the bundles with the administration folder', async (done) => {55 // build administration56 await exec(`cd ${projectRoot} && bin/console bundle:dump`);57 await exec(`cd ${adminPath} && npm run build`);58 await exec(`cd ${projectRoot} && bin/console assets:install`);59 // get subfolders of bundles directory60 const directoryInfo = await readdir(`${path.resolve(projectRoot, 'public/bundles')}${sep}`);61 // delete bundles folder62 await exec(`rm -rf ${path.resolve(projectRoot, 'public/bundles')}`);63 // check if the administration folder exists64 if (directoryInfo.indexOf('administration') >= 0) {65 done();66 return;67 }68 done.fail('The directory does not contain the administration.');69 });70 it('the administration bundle should be the same independently of plugins', async (done) => {71 // create empty plugins folder72 await exec(`cd ${projectRoot} && mkdir -p custom/plugins`);73 // refresh plugins74 await exec(`cd ${projectRoot} && php bin${sep}console plugin:refresh`);75 // create clean bundle without plugin76 await exec(`cd ${projectRoot} && bin/console bundle:dump`);77 await exec(`cd ${adminPath} && npm run build`);78 await exec(`cd ${projectRoot} && bin/console assets:install`);79 // rename bundle to "bundles_without_plugin"80 // eslint-disable-next-line max-len81 await exec(`cd ${projectRoot} && mv ${path.resolve(projectRoot, 'public/bundles')} ${path.resolve(projectRoot, 'public/bundles_without_plugin')}`);82 // copy plugin to plugin folder83 // eslint-disable-next-line max-len84 await exec(`cp -R ${path.resolve(__dirname, 'assets/ExamplePluginForTesting')} ${path.resolve(projectRoot, 'custom/plugins')}${sep}`);85 // remove temp extension from plugin php file86 // eslint-disable-next-line max-len87 await exec(`cd ${projectRoot} && mv ${path.resolve(projectRoot, 'custom/plugins/ExamplePluginForTesting/src/ExamplePluginForTesting.php.temp')} ${path.resolve(projectRoot, 'custom/plugins/ExamplePluginForTesting/src/ExamplePluginForTesting.php')}`);88 // refresh plugins89 await exec(`cd ${projectRoot} && php bin${sep}console plugin:refresh`);90 // install and activate plugin91 await exec(`cd ${projectRoot} && php bin${sep}console plugin:install --activate ExamplePluginForTesting`);92 // create bundle with plugin93 await exec(`cd ${projectRoot} && bin/console bundle:dump`);94 await exec(`cd ${adminPath} && npm run build`);95 await exec(`cd ${projectRoot} && bin/console assets:install`);96 // eslint-disable-next-line max-len97 const folderComparison = await dircompare.compare(`${path.resolve(projectRoot, 'public/bundles/administration')}`, `${path.resolve(projectRoot, 'public/bundles_without_plugin/administration')}`);98 // uninstall and deactivate plugin99 await exec(`cd ${projectRoot} && php bin${sep}console plugin:deactivate ExamplePluginForTesting`);100 await exec(`cd ${projectRoot} && php bin${sep}console plugin:uninstall ExamplePluginForTesting`);101 // delete both bundles102 await exec(`rm -rf ${path.resolve(projectRoot, 'public/bundles')}`);103 await exec(`rm -rf ${path.resolve(projectRoot, 'public/bundles_without_plugin')}`);104 // delete plugins folder105 await exec(`cd ${projectRoot} && rm -rf ${path.resolve(projectRoot, 'custom/plugins')}`);106 // create empty plugin folder107 await exec(`cd ${projectRoot} && mkdir ${path.resolve(projectRoot, 'custom/plugins')}`);108 // refresh plugin list109 await exec(`cd ${projectRoot} && php bin${sep}console plugin:refresh`);110 // expect no difference in diff111 if (folderComparison && folderComparison.same) {112 done();113 return;114 }115 // fail when there is a difference116 done.fail('The administration bundle is different when a plugin is installed.');117 });...

Full Screen

Full Screen

webpack.config.dev.client.js

Source:webpack.config.dev.client.js Github

copy

Full Screen

1let webpack = require('webpack');2// let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;3let path = require( 'path');4let ExtractTextPlugin = require( 'extract-text-webpack-plugin');5const AssetsPlugin = require('assets-webpack-plugin');6const webpack_dev_server = require('../.config/configuration').webpack_dev_server;7const port = webpack_dev_server.http.port;8const host = webpack_dev_server.http.host;9let projectRoot = process.cwd();10let assetsPath = path.join(projectRoot, "public", "build");11let publicPath = `${host}:${port}/build/`;12let distPath = projectRoot;13let config = 14{15 cache: false,16 devtool: 'eval',17 context: process.cwd(),18 entry: {19 bundle: [20 path.resolve(projectRoot, './webpack/util/polyfills.js'),21 'react-hot-loader/patch',22 `webpack-hot-middleware/client?reload=true&path=${host}:${port}/__webpack_hmr`, //note that it reloads the page if hot module reloading fails.23 path.resolve(projectRoot, './src/client/index.js'),24 ]25 },26 target: 'web',27 output: {28 path: assetsPath, // Note: Physical files are only output by the production build task `npm run build`.29 publicPath: publicPath,30 filename: '[name].js',31 chunkFilename: 'chunk-[name].js'32 },33 plugins: [34 new webpack.DefinePlugin({35 'process.env.NODE_ENV': JSON.stringify('development'),36 'process.env.BROWSER': true,37 __CLIENT__: true,38 __SERVER__: false,39 __DEVELOPMENT__: true,40 __DEVTOOLS__: true // <-------- DISABLE redux-devtools HERE41 }),42 new ExtractTextPlugin({43 filename: "css/[name].css",44 disable: false,45 allChunks: true46 }), 47 new webpack.HotModuleReplacementPlugin(),48 new webpack.NoEmitOnErrorsPlugin(),49 new webpack.DllReferencePlugin({50 context: path.join(projectRoot, "src" , "client"),51 manifest: require("../dll/vendor-manifest.json")52 }),53 new AssetsPlugin({fullPath: true}) 54 ],55 module: {56 rules: [57 {58 test: /(\.jsx)|(\.js)$/i,59 exclude: /node_modules/,60 loader: 'babel-loader',61 include: [62 path.join(projectRoot, "src" , "client"),63 path.join(projectRoot, "src" , "shared")64 ],65 options: {66 cacheDirectory: true,67 babelrc: false,68 presets: [['es2015', {modules: false, loose: true}], "react"],69 plugins: [70 "react-hot-loader/babel",71 "syntax-dynamic-import",72 "transform-object-rest-spread",73 "transform-class-properties", 74 ], 75 },76 },77 {78 test: /(\.css)$/,79 include: [80 path.resolve(projectRoot, './src/shared/css/') ,81 path.resolve(projectRoot, './node_modules/font-awesome/css/') ,82 ],83 loader: "file-loader?name=css/[name].[ext]" ,84 },85 {86 test: /(\.sass|\.scss)$/,87 include: [88 path.resolve(projectRoot, './src/shared/Sass/') ,89 ],90 use: ExtractTextPlugin.extract({91 fallback: "style-loader",92 use: [93 { loader: 'raw-loader', query: { importLoaders: 2}},94 { loader: 'sass-loader'},95 ],96 })97 },98 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/i, 99 loader: "url-loader?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]" ,100 include: [101 path.resolve(projectRoot, './src/shared/fonts/') ,102 path.resolve(projectRoot, './node_modules/bootstrap/dist/fonts/') ,103 path.resolve(projectRoot, './node_modules/font-awesome/fonts/') ,104 ], 105 },106 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, 107 loader: "file-loader?name=fonts/[name].[ext]" ,108 include: [109 path.resolve(projectRoot, './src/shared/fonts/') ,110 path.resolve(projectRoot, './node_modules/bootstrap/dist/fonts/') ,111 path.resolve(projectRoot, './node_modules/font-awesome/fonts/') ,112 ],113 }, 114 { test: /\.(gif|tif|tiff|jpg|png|jpeg|ico)$/i, 115 loader: "file-loader?name=img/[path][name].[ext]&context=" + path.resolve(projectRoot, './src/shared/img') ,116 include: [117 path.resolve(projectRoot, './src/shared/img/') ,118 ],119 }, 120 ]121 },122 resolveLoader: {123 modules: [124 "node_modules"125 ],126 },127 resolve: {128 modules: [129 "node_modules"130 ],131 alias: {132 // "react-router-redux": path.resolve(projectRoot, '../react-router/packages/react-router-redux/'), 133 // "react-router": path.resolve(projectRoot, '../react-router/packages/react-router/'), 134 // "react-router-dom": path.resolve(projectRoot, '../react-router/packages/react-router-dom/'), 135 "bootstrap.css": path.resolve(projectRoot, './src/shared/css/bootstrap.min.css'), 136 "font-awesome.css": path.resolve(projectRoot, 'node_modules/font-awesome/css/font-awesome.min.css'), 137 "font-awesome.fonts": path.resolve(projectRoot, 'node_modules/font-awesome/fonts'),138 },139 unsafeCache : true,140 },141 profile: true,142 stats: {143 hash: true,144 version: true,145 timings: true,146 assets: false,147 chunks: true,148 modules: true,149 reasons: true,150 children: false,151 source: false,152 errors: true,153 errorDetails: true,154 warnings: true,155 publicPath: true,156 colors: true157 },158};...

Full Screen

Full Screen

ProjectUtils.js

Source:ProjectUtils.js Github

copy

Full Screen

1/**2 * @flow3 */4import * as ConfigUtils from '@expo/config';5import path from 'path';6import * as Analytics from '../Analytics';7import Logger from '../Logger';8const MAX_MESSAGE_LENGTH = 200;9let _projectRootToLogger = {};10function _getLogger(projectRoot: string) {11 let logger = _projectRootToLogger[projectRoot];12 if (!logger) {13 logger = Logger.child({14 type: 'project',15 project: path.resolve(projectRoot),16 });17 _projectRootToLogger[projectRoot] = logger;18 }19 return logger;20}21export function logWithLevel(22 projectRoot: string,23 level: string,24 object: any,25 msg: string,26 id: ?string27) {28 if (id) {29 object.issueId = id;30 }31 let logger = _getLogger(projectRoot);32 switch (level) {33 case 'debug':34 logger.debug(object, msg);35 break;36 case 'info':37 logger.info(object, msg);38 break;39 case 'warn':40 logger.warn(object, msg);41 break;42 case 'error':43 logger.error(object, msg);44 break;45 default:46 logger.debug(object, msg);47 break;48 }49}50export function logDebug(projectRoot: string, tag: string, message: string, id: ?string) {51 _getLogger(projectRoot).debug({ tag }, message.toString());52}53export function logInfo(projectRoot: string, tag: string, message: string, id: ?string) {54 const object = { tag };55 if (id) {56 object.issueId = id;57 }58 _getLogger(projectRoot).info(object, message.toString());59}60export function logError(projectRoot: string, tag: string, message: string, id: ?string) {61 const object = { tag };62 if (id) {63 object.issueId = id;64 }65 _getLogger(projectRoot).error(object, message.toString());66 let truncatedMessage = message.toString();67 if (truncatedMessage.length > MAX_MESSAGE_LENGTH) {68 truncatedMessage = truncatedMessage.substring(0, MAX_MESSAGE_LENGTH);69 }70 // temporarily remove sentry until we can trim events71 // send error to Sentry72 // Sentry.logError(message.toString(), {73 // tags: { tag },74 // });75}76export function logWarning(projectRoot: string, tag: string, message: string, id: ?string) {77 const object = { tag };78 if (id) {79 object.issueId = id;80 }81 _getLogger(projectRoot).warn(object, message.toString());82 let truncatedMessage = message.toString();83 if (truncatedMessage.length > MAX_MESSAGE_LENGTH) {84 truncatedMessage = truncatedMessage.substring(0, MAX_MESSAGE_LENGTH);85 }86 Analytics.logEvent('Project Warning', {87 projectRoot,88 tag,89 message: truncatedMessage,90 });91}92export function clearNotification(projectRoot: string, id: string) {93 _getLogger(projectRoot).info(94 {95 tag: 'expo',96 issueCleared: true,97 issueId: id,98 },99 `No issue with ${id}`100 );101}102export function attachLoggerStream(projectRoot: string, stream: any) {103 _getLogger(projectRoot).addStream(stream);104}105// Wrap with logger106export async function findConfigFileAsync(107 projectRoot: string108): Promise<{ configPath: string, configName: string, configNamespace: ?string }> {109 try {110 return await ConfigUtils.findConfigFileAsync(projectRoot);111 } catch (error) {112 throw error;113 }114}115export async function readExpRcAsync(projectRoot: string): Promise<any> {116 try {117 return await ConfigUtils.readExpRcAsync(projectRoot);118 } catch (e) {119 logError(projectRoot, 'expo', e.message);120 return {};121 }122}123export async function readConfigJsonAsync(124 projectRoot: string125): Promise<{ exp?: Object, pkg?: Object, rootConfig?: Object }> {126 try {127 return await ConfigUtils.readConfigJsonAsync(projectRoot);128 } catch (error) {129 logError(projectRoot, 'expo', error.message);130 return { exp: null, pkg: null };131 }132}133// Legacy implementation134// TODO: Bacon: Deprecate135export async function writeConfigJsonAsync(136 projectRoot: string,137 options: Object138): Promise<{ exp: ?Object, pkg: ?Object, rootConfig: ?Object }> {139 return await ConfigUtils.writeConfigJsonAsync(projectRoot, options);140}141export function resolveModule(request, projectRoot, exp) {142 return ConfigUtils.resolveModule(request, projectRoot, exp);143}144export function setCustomConfigPath(projectRoot: string, configPath: string): void {145 return ConfigUtils.setCustomConfigPath(projectRoot, configPath);146}147export async function configFilenameAsync(projectRoot: string): Promise<string> {148 return await ConfigUtils.configFilenameAsync(projectRoot);149}150export async function fileExistsAsync(file: string): Promise<boolean> {151 return await ConfigUtils.fileExistsAsync(file);...

Full Screen

Full Screen

config-safari.mjs

Source:config-safari.mjs Github

copy

Full Screen

1import VueLoaderPlugin from 'vue-loader/lib/plugin.js'2import MiniCssExtractPlugin from 'mini-css-extract-plugin'3import path from 'path'4const projectRoot = process.cwd()5const webpack = {6 common: {7 entry: './plugin.js',8 output: {9 library: 'AlpheiosComponents',10 libraryTarget: 'window'11 },12 plugins: [13 new VueLoaderPlugin()14 ]15 },16 production: {17 mode: 'production',18 output: {19 filename: 'alpheios-components.min.js'20 },21 resolve: {22 alias: {23 // Below will force all imported modules with unresolved dependencies to use a single instance of that dependency24 'alpheios-data-models': path.join(projectRoot, 'node_modules/alpheios-data-models/dist/alpheios-data-models.min.js'),25 'alpheios-inflection-tables': path.join(projectRoot, 'node_modules/alpheios-inflection-tables/dist/alpheios-inflection-tables.min.js'),26 'alpheios-l10n': path.join(projectRoot, 'node_modules/alpheios-l10n/dist/alpheios-l10n.min.js'),27 'alpheios-client-adapters': path.join(projectRoot, 'node_modules/alpheios-client-adapters/dist/alpheios-client-adapters.min.js'),28 'alpheios-res-client': path.join(projectRoot, 'node_modules/alpheios-res-client/dist/alpheios-res-client.min.js'),29 'alpheios-wordlist': path.join(projectRoot, 'node_modules/alpheios-wordlist/dist/alpheios-wordlist.min.js'),30 'alpheios-messaging': path.join(projectRoot, '../../node_modules/alpheios-messaging/dist/prod/alpheios-messaging.min.js'),31 'vue-multiselect-css': path.join(projectRoot, '../../node_modules/vue-multiselect/dist/vue-multiselect.min.css'),32 '@vue-runtime': path.join(projectRoot, '../../node_modules/vue/dist/vue.runtime.esm.js'),33 '@': path.join(projectRoot, 'src'),34 '@comp': path.join(projectRoot, 'src'),35 /*36 Starting from version 4.5, `papaparse` uses a `stream` package from node.js.37 In webpack 4, this package was polyfilled for the browser build automatically.38 It is not so, however, with webpack 5 as it disabled all automatic polyfills.39 Solution is to use `readable-stream` as a `stream` polyfill.40 */41 stream: path.join(projectRoot, '../../node_modules/readable-stream')42 }43 },44 plugins: [45 new MiniCssExtractPlugin({46 filename: 'style/style-components-safari.min.css'47 })48 ]49 },50 development: {51 mode: 'development',52 output: {53 filename: 'alpheios-components.js'54 },55 resolve: {56 alias: {57 // Below will force all imported modules with unresolved dependencies to use a single instance of that dependency58 'alpheios-data-models': path.join(projectRoot, 'node_modules/alpheios-data-models/dist/alpheios-data-models.js'),59 'alpheios-inflection-tables': path.join(projectRoot, 'node_modules/alpheios-inflection-tables/dist/alpheios-inflection-tables.js'),60 'alpheios-l10n': path.join(projectRoot, 'node_modules/alpheios-l10n/dist/alpheios-l10n.js'),61 'alpheios-client-adapters': path.join(projectRoot, 'node_modules/alpheios-client-adapters/dist/alpheios-client-adapters.js'),62 'alpheios-res-client': path.join(projectRoot, 'node_modules/alpheios-res-client/dist/alpheios-res-client.js'),63 'alpheios-wordlist': path.join(projectRoot, 'node_modules/alpheios-wordlist/dist/alpheios-wordlist.js'),64 'alpheios-messaging': path.join(projectRoot, '../../node_modules/alpheios-messaging/dist/dev/alpheios-messaging.js'),65 'vue-multiselect-css': path.join(projectRoot, '../../node_modules/vue-multiselect/dist/vue-multiselect.min.css'),66 '@vue-runtime': path.join(projectRoot, '../../node_modules/vue/dist/vue.runtime.esm.js'),67 '@': path.join(projectRoot, 'src'),68 '@comp': path.join(projectRoot, 'src'),69 /*70 Starting from version 4.5, `papaparse` uses a `stream` package from node.js.71 In webpack 4, this package was polyfilled for the browser build automatically.72 It is not so, however, with webpack 5 as it disabled all automatic polyfills.73 Solution is to use `readable-stream` as a `stream` polyfill.74 */75 stream: path.join(projectRoot, '../../node_modules/readable-stream')76 }77 },78 plugins: [79 new MiniCssExtractPlugin({80 filename: 'style/style-components-safari.css'81 })82 ]83 }84}...

Full Screen

Full Screen

startAsync.ts

Source:startAsync.ts Github

copy

Full Screen

1import { ExpoConfig, getConfig } from '@expo/config';2import { Server } from 'http';3import Analytics from '../Analytics';4import * as Android from '../Android';5import Config from '../Config';6import * as DevSession from '../DevSession';7import { shouldUseDevServer } from '../Env';8import * as ProjectSettings from '../ProjectSettings';9import * as Webpack from '../Webpack';10import * as ProjectUtils from '../project/ProjectUtils';11import { assertValidProjectRoot } from '../project/errors';12import { startTunnelsAsync, stopTunnelsAsync } from './ngrok';13import { startDevServerAsync, StartOptions } from './startDevServerAsync';14import { startExpoServerAsync, stopExpoServerAsync } from './startLegacyExpoServerAsync';15import {16 startReactNativeServerAsync,17 stopReactNativeServerAsync,18} from './startLegacyReactNativeServerAsync';19let serverInstance: Server | null = null;20export async function startAsync(21 projectRoot: string,22 { exp = getConfig(projectRoot).exp, ...options }: StartOptions & { exp?: ExpoConfig } = {},23 verbose: boolean = true24): Promise<ExpoConfig> {25 assertValidProjectRoot(projectRoot);26 Analytics.logEvent('Start Project', {27 projectRoot,28 developerTool: Config.developerTool,29 sdkVersion: exp.sdkVersion ?? null,30 });31 if (options.webOnly) {32 await Webpack.restartAsync(projectRoot, options);33 DevSession.startSession(projectRoot, exp, 'web');34 return exp;35 } else if (shouldUseDevServer(exp) || options.devClient) {36 serverInstance = await startDevServerAsync(projectRoot, options);37 DevSession.startSession(projectRoot, exp, 'native');38 } else {39 await startExpoServerAsync(projectRoot);40 await startReactNativeServerAsync({ projectRoot, exp, options, verbose });41 DevSession.startSession(projectRoot, exp, 'native');42 }43 const { hostType } = await ProjectSettings.readAsync(projectRoot);44 if (!Config.offline && hostType === 'tunnel') {45 try {46 await startTunnelsAsync(projectRoot);47 } catch (e) {48 ProjectUtils.logDebug(projectRoot, 'expo', `Error starting tunnel ${e.message}`);49 }50 }51 return exp;52}53async function stopInternalAsync(projectRoot: string): Promise<void> {54 DevSession.stopSession();55 await Promise.all([56 Webpack.stopAsync(projectRoot),57 new Promise<void>((resolve, reject) => {58 if (serverInstance) {59 serverInstance.close(error => {60 if (error) {61 reject(error);62 } else {63 resolve();64 }65 });66 }67 }),68 stopExpoServerAsync(projectRoot),69 stopReactNativeServerAsync(projectRoot),70 async () => {71 if (!Config.offline) {72 try {73 await stopTunnelsAsync(projectRoot);74 } catch (e) {75 ProjectUtils.logDebug(projectRoot, 'expo', `Error stopping ngrok ${e.message}`);76 }77 }78 },79 await Android.maybeStopAdbDaemonAsync(),80 ]);81}82async function forceQuitAsync(projectRoot: string) {83 // find RN packager and ngrok pids, attempt to kill them manually84 const { packagerPid, ngrokPid } = await ProjectSettings.readPackagerInfoAsync(projectRoot);85 if (packagerPid) {86 try {87 process.kill(packagerPid);88 } catch (e) {}89 }90 if (ngrokPid) {91 try {92 process.kill(ngrokPid);93 } catch (e) {}94 }95 await ProjectSettings.setPackagerInfoAsync(projectRoot, {96 expoServerPort: null,97 packagerPort: null,98 packagerPid: null,99 expoServerNgrokUrl: null,100 packagerNgrokUrl: null,101 ngrokPid: null,102 webpackServerPort: null,103 });104}105export async function stopAsync(projectRoot: string): Promise<void> {106 try {107 const result = await Promise.race([108 stopInternalAsync(projectRoot),109 new Promise(resolve => setTimeout(resolve, 2000, 'stopFailed')),110 ]);111 if (result === 'stopFailed') {112 await forceQuitAsync(projectRoot);113 }114 } catch (error) {115 await forceQuitAsync(projectRoot);116 throw error;117 }...

Full Screen

Full Screen

ProjectUtils.ts

Source:ProjectUtils.ts Github

copy

Full Screen

1import path from 'path';2import Analytics from '../Analytics';3import Logger, { Log, LogStream } from '../Logger';4const MAX_MESSAGE_LENGTH = 200;5const _projectRootToLogger: { [projectRoot: string]: Log } = {};6function _getLogger(projectRoot: string): Log {7 let logger = _projectRootToLogger[projectRoot];8 if (!logger) {9 logger = Logger.child({10 type: 'project',11 project: path.resolve(projectRoot),12 });13 _projectRootToLogger[projectRoot] = logger;14 }15 return logger;16}17export type LogTag = 'expo' | 'metro' | 'device';18export type LogFields = {19 tag: LogTag;20 issueId?: string;21 issueCleared?: boolean;22 includesStack?: boolean;23 deviceId?: string;24 deviceName?: string;25 groupDepth?: number;26 shouldHide?: boolean;27 _expoEventType?: 'TUNNEL_READY';28};29export function getLogger(projectRoot: string): Log {30 return _getLogger(projectRoot);31}32export function logWithLevel(33 projectRoot: string,34 level: string,35 fields: LogFields,36 msg: string,37 id?: string38) {39 if (id) {40 fields.issueId = id;41 }42 const logger = _getLogger(projectRoot);43 switch (level) {44 case 'debug':45 logger.debug(fields, msg);46 break;47 case 'info':48 logger.info(fields, msg);49 break;50 case 'warn':51 logger.warn(fields, msg);52 break;53 case 'error':54 logger.error(fields, msg);55 break;56 default:57 logger.debug(fields, msg);58 break;59 }60}61export function logDebug(projectRoot: string, tag: LogTag, message: string, id?: string) {62 _getLogger(projectRoot).debug({ tag }, message.toString());63}64export function logInfo(projectRoot: string, tag: LogTag, message: string, id?: string) {65 const fields: LogFields = { tag };66 if (id) {67 fields.issueId = id;68 }69 _getLogger(projectRoot).info(fields, message.toString());70}71export function logError(projectRoot: string, tag: LogTag, message: string, id?: string) {72 const fields: LogFields = { tag };73 if (id) {74 fields.issueId = id;75 }76 _getLogger(projectRoot).error(fields, message.toString());77 let truncatedMessage = message.toString();78 if (truncatedMessage.length > MAX_MESSAGE_LENGTH) {79 truncatedMessage = truncatedMessage.substring(0, MAX_MESSAGE_LENGTH);80 }81 // temporarily remove sentry until we can trim events82 // send error to Sentry83 // Sentry.logError(message.toString(), {84 // tags: { tag },85 // });86}87export function logWarning(projectRoot: string, tag: LogTag, message: string, id?: string) {88 const fields: LogFields = { tag };89 if (id) {90 fields.issueId = id;91 }92 _getLogger(projectRoot).warn(fields, message.toString());93 let truncatedMessage = message.toString();94 if (truncatedMessage.length > MAX_MESSAGE_LENGTH) {95 truncatedMessage = truncatedMessage.substring(0, MAX_MESSAGE_LENGTH);96 }97 Analytics.logEvent('Project Warning', {98 projectRoot,99 tag,100 message: truncatedMessage,101 });102}103export function clearNotification(projectRoot: string, id: string) {104 _getLogger(projectRoot).info(105 {106 tag: 'expo',107 issueCleared: true,108 issueId: id,109 },110 `No issue with ${id}`111 );112}113export function attachLoggerStream(projectRoot: string, stream: LogStream) {114 _getLogger(projectRoot).addStream(stream);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { projectRoot } from 'storybook-root-decorator';2storiesOf('MyComponent', module)3 .addDecorator(projectRoot())4 .add('default', () => <MyComponent />);5import { configure } from '@storybook/react';6import { setOptions } from '@storybook/addon-options';7import { setDefaults } from 'storybook-root-decorator';8setDefaults({9});10setOptions({11});12configure(() => {13 require('../test.js');14}, module);15{16 "scripts": {17 }18}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { projectRoot } from 'storybook-root-import';2const projectRoot = require('storybook-root-import').projectRoot;3const { projectRoot } = require('storybook-root-import');4const projectRoot = require('storybook-root-import').projectRoot;5const { projectRoot } = require('storybook-root-import');6const projectRoot = require('storybook-root-import').projectRoot;7const { projectRoot } = require('storybook-root-import');8const projectRoot = require('storybook-root-import').projectRoot;9const { projectRoot } = require('storybook-root-import');10const projectRoot = require('storybook-root-import').projectRoot;11const { projectRoot } = require('storybook-root-import');12const projectRoot = require('storybook-root-import').projectRoot;13const { projectRoot } = require('storybook-root-import');14const projectRoot = require('storybook-root-import').projectRoot;15const { projectRoot } = require('storybook-root-import');16const projectRoot = require('storybook-root-import').projectRoot;17const { projectRoot } = require('storybook-root-import');18const projectRoot = require('storybook-root-import').projectRoot;19const { projectRoot } = require('storybook-root-import');20const projectRoot = require('storybook-root-import').projectRoot;

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('storybook-root-require').projectRoot;2module.exports = {3 module: {4 {5 include: path('src'),6 use: {7 options: {8 },9 },10 },11 },12};13const path = require('storybook-root-require').projectRoot;14module.exports = {15 resolve: {16 alias: {17 '@': path('src'),18 },19 },20};21import React from 'react';22import ReactDOM from 'react-dom';23import App from '@/App';24ReactDOM.render(<App />, document.getElementById('root'));25import React from 'react';26const App = () => {27 return (28 );29};30export default App;31import React from 'react';32const HelloWorld = () => {33 return (34 );35};36export default HelloWorld;37import React from 'react';38import { storiesOf } from '@storybook/react';39import HelloWorld from '@/components/HelloWorld';40storiesOf('HelloWorld', module).add('default', () => <HelloWorld />);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { withRoot } from 'storybook-root-decorator'2export default {3}4export const test = () => <div>test</div>5{6 "scripts": {7 }8}9module.exports = {10}11import { withRoot } from 'storybook-root-decorator'12import { addons } from '@storybook/addons'13addons.setConfig({14})15import { withRoot } from 'storybook-root-decorator'16export default {17}18export const test = () => <div>test</div>19{20 "scripts": {21 }22}23module.exports = {24}25import { withRoot } from 'storybook-root-decorator'26import { addons } from '@storybook/addons'

Full Screen

Using AI Code Generation

copy

Full Screen

1import { projectRoot } from 'storybook-root-decorator';2const path = projectRoot(__dirname);3import { projectRoot } from 'storybook-root-decorator';4const path = projectRoot(__dirname);5import { projectRoot } from 'storybook-root-decorator';6const path = projectRoot(__dirname);7import { projectRoot } from 'storybook-root-decorator';8const path = projectRoot(__dirname);9import { projectRoot } from 'storybook-root-decorator';10const path = projectRoot(__dirname);11import { projectRoot } from 'storybook-root-decorator';12const path = projectRoot(__dirname);13import { projectRoot } from 'storybook-root-decorator';14const path = projectRoot(__dirname);15import { projectRoot } from 'storybook-root-decorator';16const path = projectRoot(__dirname);17import { projectRoot } from 'storybook-root-decorator';18const path = projectRoot(__dirname);19import { projectRoot } from 'storybook-root-decorator';20const path = projectRoot(__dirname);21import { projectRoot } from 'storybook-root-decorator';22const path = projectRoot(__dirname);

Full Screen

Using AI Code Generation

copy

Full Screen

1import {projectRoot} from 'storybook-root'2import path from 'path'3const pathToStorybookConfig = path.join(projectRoot, '.storybook')4import pathToStorybookConfig from '../test'5module.exports = {6};

Full Screen

Using AI Code Generation

copy

Full Screen

1import {projectRoot} from 'storybook-root-require'2const path = projectRoot('src', 'test.js')3console.log(path)4import {projectRoot} from 'storybook-root-require'5const path = projectRoot('src', 'test.js')6console.log(path)7const path = require('path')

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