Best JavaScript code snippet using storybook-root
idl_generator.js
Source:idl_generator.js
1// Copyright (c) 2018 Intel Corporation. All rights reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14'use strict';15const dot = require('dot');16const fse = require('fs-extra');17const path = require('path');18const parser = require('../rosidl_parser/rosidl_parser.js');19const actionMsgs = require('./action_msgs.js');20dot.templateSettings.strip = false;21dot.log = process.env.RCLNODEJS_LOG_VERBOSE || false;22const dots = dot.process({23 path: path.join(__dirname, '../rosidl_gen/templates'),24});25function removeEmptyLines(str) {26 return str.replace(/^\s*\n/gm, '');27}28async function writeGeneratedCode(dir, fileName, code) {29 await fse.mkdirs(dir);30 await fse.writeFile(path.join(dir, fileName), code);31}32function generateServiceJSStruct(serviceInfo, dir) {33 dir = path.join(dir, `${serviceInfo.pkgName}`);34 const fileName =35 serviceInfo.pkgName +36 '__' +37 serviceInfo.subFolder +38 '__' +39 serviceInfo.interfaceName +40 '.js';41 const generatedCode = removeEmptyLines(42 dots.service({ serviceInfo: serviceInfo })43 );44 return writeGeneratedCode(dir, fileName, generatedCode);45}46async function generateMessageJSStruct(messageInfo, dir) {47 const spec = await parser.parseMessageFile(48 messageInfo.pkgName,49 messageInfo.filePath50 );51 await generateMessageJSStructFromSpec(messageInfo, dir, spec);52}53function generateMessageJSStructFromSpec(messageInfo, dir, spec) {54 dir = path.join(dir, `${spec.baseType.pkgName}`);55 const fileName =56 spec.baseType.pkgName +57 '__' +58 messageInfo.subFolder +59 '__' +60 spec.msgName +61 '.js';62 const generatedCode = removeEmptyLines(63 dots.message({64 messageInfo: messageInfo,65 spec: spec,66 json: JSON.stringify(spec, null, ' '),67 })68 );69 return writeGeneratedCode(dir, fileName, generatedCode);70}71async function generateActionJSStruct(actionInfo, dir) {72 const spec = await parser.parseActionFile(73 actionInfo.pkgName,74 actionInfo.filePath75 );76 const goalMsg = generateMessageJSStructFromSpec(77 {78 pkgName: actionInfo.pkgName,79 subFolder: actionInfo.subFolder,80 interfaceName: `${actionInfo.interfaceName}_Goal`,81 },82 dir,83 spec.goal84 );85 const resultMsg = generateMessageJSStructFromSpec(86 {87 pkgName: actionInfo.pkgName,88 subFolder: actionInfo.subFolder,89 interfaceName: `${actionInfo.interfaceName}_Result`,90 },91 dir,92 spec.result93 );94 const feedbackMsg = generateMessageJSStructFromSpec(95 {96 pkgName: actionInfo.pkgName,97 subFolder: actionInfo.subFolder,98 interfaceName: `${actionInfo.interfaceName}_Feedback`,99 },100 dir,101 spec.feedback102 );103 const sendGoalRequestSpec = actionMsgs.createSendGoalRequestSpec(104 actionInfo.pkgName,105 actionInfo.interfaceName106 );107 const sendGoalRequestMsg = generateMessageJSStructFromSpec(108 {109 pkgName: actionInfo.pkgName,110 subFolder: actionInfo.subFolder,111 interfaceName: `${actionInfo.interfaceName}_SendGoal_Request`,112 },113 dir,114 sendGoalRequestSpec115 );116 const sendGoalResponseSpec = actionMsgs.createSendGoalResponseSpec(117 actionInfo.pkgName,118 actionInfo.interfaceName119 );120 const sendGoalResponseMsg = generateMessageJSStructFromSpec(121 {122 pkgName: actionInfo.pkgName,123 subFolder: actionInfo.subFolder,124 interfaceName: `${actionInfo.interfaceName}_SendGoal_Response`,125 },126 dir,127 sendGoalResponseSpec128 );129 const sendGoalSrv = generateServiceJSStruct(130 {131 pkgName: actionInfo.pkgName,132 subFolder: actionInfo.subFolder,133 interfaceName: `${actionInfo.interfaceName}_SendGoal`,134 },135 dir136 );137 const getResultRequestSpec = actionMsgs.createGetResultRequestSpec(138 actionInfo.pkgName,139 actionInfo.interfaceName140 );141 const getResultRequestMsg = generateMessageJSStructFromSpec(142 {143 pkgName: actionInfo.pkgName,144 subFolder: actionInfo.subFolder,145 interfaceName: `${actionInfo.interfaceName}_GetResult_Request`,146 },147 dir,148 getResultRequestSpec149 );150 const getResultResponseSpec = actionMsgs.createGetResultResponseSpec(151 actionInfo.pkgName,152 actionInfo.interfaceName153 );154 const getResultResponseMsg = generateMessageJSStructFromSpec(155 {156 pkgName: actionInfo.pkgName,157 subFolder: actionInfo.subFolder,158 interfaceName: `${actionInfo.interfaceName}_GetResult_Response`,159 },160 dir,161 getResultResponseSpec162 );163 const getResultSrv = generateServiceJSStruct(164 {165 pkgName: actionInfo.pkgName,166 subFolder: actionInfo.subFolder,167 interfaceName: `${actionInfo.interfaceName}_GetResult`,168 },169 dir170 );171 const feedbackMessageSpec = actionMsgs.createFeedbackMessageSpec(172 actionInfo.pkgName,173 actionInfo.interfaceName174 );175 const feedbackMessageMsg = generateMessageJSStructFromSpec(176 {177 pkgName: actionInfo.pkgName,178 subFolder: actionInfo.subFolder,179 interfaceName: `${actionInfo.interfaceName}_FeedbackMessage`,180 },181 dir,182 feedbackMessageSpec183 );184 const fileName =185 actionInfo.pkgName +186 '__' +187 actionInfo.subFolder +188 '__' +189 actionInfo.interfaceName +190 '.js';191 const generatedCode = removeEmptyLines(192 dots.action({ actionInfo: actionInfo })193 );194 dir = path.join(dir, actionInfo.pkgName);195 const action = writeGeneratedCode(dir, fileName, generatedCode);196 await Promise.all([197 goalMsg,198 resultMsg,199 feedbackMsg,200 sendGoalRequestMsg,201 sendGoalResponseMsg,202 sendGoalSrv,203 getResultRequestMsg,204 getResultResponseMsg,205 getResultSrv,206 feedbackMessageMsg,207 action,208 ]);209}210async function generateJSStructFromIDL(pkg, dir) {211 await Promise.all([212 ...pkg.messages.map((messageInfo) =>213 generateMessageJSStruct(messageInfo, dir)214 ),215 ...pkg.services.map((serviceInfo) =>216 generateServiceJSStruct(serviceInfo, dir)217 ),218 ...pkg.actions.map((actionInfo) => generateActionJSStruct(actionInfo, dir)),219 ]);220}...
010-build.ts
Source:010-build.ts
1import {join} from 'path';2import {getGlobalVariable} from '../utils/env';3import {npm} from '../utils/process';4import {updateJsonFile} from '../utils/project';5const packages = require('../../../lib/packages');6export default function() {7 const argv = getGlobalVariable('argv');8 if (argv.nobuild) {9 return;10 }11 return npm('run', 'build')12 .then(() => console.log('Updating package.json from dist...'))13 .then(() => Promise.all(Object.keys(packages).map(pkgName => {14 return updateJsonFile(join(packages[pkgName].dist, 'package.json'), json => {15 Object.keys(packages).forEach(pkgName => {16 if (json['dependencies'] && pkgName in json['dependencies']) {17 json['dependencies'][pkgName] = packages[pkgName].dist;18 } else if (json['devDependencies'] && pkgName in json['devDependencies']) {19 json['devDependencies'][pkgName] = packages[pkgName].dist;20 }21 });22 });23 })))24 .then(() => {25 if (!argv.nightly && !argv['ng-sha']) {26 return;27 }28 console.log('Updating package.json from dist for nightly Angular packages...');29 const label = argv['ng-sha'] ? `#2.0.0-${argv['ng-sha']}` : '';30 return Promise.all(Object.keys(packages).map(pkgName => {31 return updateJsonFile(join(packages[pkgName].dist, 'package.json'), json => {32 Object.keys(json['dependencies'] || {})33 .filter(name => name.match(/^@angular\//))34 .forEach(name => {35 const pkgName = name.split(/\//)[1];36 json['dependencies'][`@angular/${pkgName}`]37 = `github:angular/${pkgName}-builds${label}`;38 });39 Object.keys(json['devDependencies'] || {})40 .filter(name => name.match(/^@angular\//))41 .forEach(name => {42 const pkgName = name.split(/\//)[1];43 json['devDependencies'][`@angular/${pkgName}`]44 = `github:angular/${pkgName}-builds${label}`;45 });46 });47 }));48 });...
Using AI Code Generation
1import { pkgName } from 'storybook-root';2console.log(pkgName);3{4}5import pkg from '../package.json';6export const pkgName = pkg.name;
Using AI Code Generation
1var storybookRoot = require('storybook-root');2var pkgName = storybookRoot.pkgName();3console.log(pkgName);4module.exports = {5 pkgName: function () {6 return 'storybook-root';7 }8};9{10}11{12 "dependencies": {13 }14}
Using AI Code Generation
1const pkgName = require('storybook-root').pkgName;2console.log(pkgName);3module.exports.pkgName = function() {4 return 'storybook-root';5}6{7}8{9 "dependencies": {10 }11}
Using AI Code Generation
1import pkgName from 'storybook-root';2import pkgName from 'storybook-root/lib/util';3import pkgName from 'storybook-root/lib/util/pattern';4import pkgName from 'storybook-root/lib/util/pattern/abc';5import pkgName from 'storybook-root/lib/util/pattern/abc/xyz';6import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123';7import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc';8import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc/xyz';9import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc/xyz/123';10import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc/xyz/123/abc';11import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc/xyz/123/abc/xyz';12import pkgName from 'storybook-root/lib/util/pattern/abc/xyz/123/abc/xyz/123/abc/xyz/123';
Using AI Code Generation
1const pkgName = require('@storybook/root');2console.log(pkgName);3const pkgName = require('storybook-root');4console.log(pkgName);5const pkgName = require('@storybook/root');6console.log(pkgName);
Using AI Code Generation
1import pkgName from 'storybook-root-alias';2console.log(pkgName);3module.exports = {4 stories: ['../packages/**/*.stories.@(tsx|mdx)'],5 webpackFinal: async config => {6 return config;7 },8};9import { addDecorator } from '@storybook/react';10import { withA11y } from '@storybook/addon-a11y';11import { withPaddings } from 'storybook-addon-paddings';12import { withRootAlias } from 'storybook-root-alias';13addDecorator(withA11y);14addDecorator(withPaddings);15addDecorator(withRootAlias);16module.exports = async ({ config, mode }) => {17 return config;18};19import { addons } from '@storybook/addons';20import { themes } from '@storybook/theming';21addons.setConfig({22});23{24 "compilerOptions": {25 },26 "include": ["../packages/**/*.stories.@(tsx|mdx)"],27}28{29 "compilerOptions": {30 },31 "include": ["../packages/**/*.stories.@(tsx|mdx)"],32}33{34 "compilerOptions": {35 },
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!