How to use hasLegacyPeerDeps method in storybook-root

Best JavaScript code snippet using storybook-root

sui-ssr-release.js

Source:sui-ssr-release.js Github

copy

Full Screen

1#!/usr/bin/env node2/* eslint no-console:0 no-unused-vars:0 */3const program = require('commander')4const {shell} = require('@tunnckocore/execa')5const gitUrlParse = require('git-url-parse')6const path = require('path')7program8 .option('-B, --branch <branch>', 'Release branch. Will be master by default')9 .option('-E, --email <email>', "Releaser's email")10 .option('-N, --name <name>', "Releaser's name")11 .option('-C, --commit <commit>', 'Commit to tag')12 .option('-sci, --skip-ci', 'Skip CI')13 .option('--npm7', 'Is npm 7 project')14 .on('--help', () => {15 console.log(' Description:')16 console.log('')17 console.log(18 ' Release a server version. Create a git tag and update a minor version in the package.json'19 )20 console.log(21 ' It is mandatory setup a $GITHUB_TOKEN envVar to execute this command'22 )23 console.log('')24 console.log(' Examples:')25 console.log('')26 console.log(' $ sui-ssr release')27 console.log('')28 })29 .parse(process.argv)30const {31 branch = 'master',32 email,33 name,34 skipCi = false,35 commit,36 npm7 = false37} = program.opts()38const execute = async (cmd, full) => {39 try {40 console.log('--->', cmd)41 const [resp] = await shell(cmd)42 const output = full ? resp : resp.stdout43 console.log(output)44 return output45 } catch (e) {46 const output = full ? e : e.stderr47 console.log(output)48 return e49 }50}51const getCommitToTag = async () => {52 if (commit) return commit53 return execute('git rev-parse HEAD')54}55const getNpmInstall = ({56 legacyPeerDeps: hasLegacyPeerDeps,57 packageLockOnly,58 only: onlyScope59} = {}) => {60 const installCommand = [61 'npm install',62 hasLegacyPeerDeps && '--legacy-peer-deps',63 onlyScope && `--only=${onlyScope}`,64 packageLockOnly && '--package-lock-only',65 '--prefer-online',66 '--package-lock',67 '--progress false',68 '--no-bin-links',69 '--ignore-scripts',70 '--no-audit',71 '--no-fund'72 ]73 return installCommand.filter(Boolean).join(' ')74}75;(async () => {76 const cwd = process.cwd()77 const {GITHUB_TOKEN, GH_TOKEN} = process.env78 const gitHubToken = GITHUB_TOKEN || GH_TOKEN79 if (!gitHubToken) throw new Error('Missing GITHUB_TOKEN environment variable')80 try {81 await execute(`git checkout ${branch}`)82 await execute(`git pull origin ${branch}`)83 const commitToTag = await getCommitToTag()84 const hasTag = await execute(`git tag --points-at ${commitToTag}`)85 if (hasTag) {86 console.log('We are going to release the current tag:', hasTag)87 return await execute('npm run release')88 }89 const repoURL = await execute('git config --get remote.origin.url')90 const gitURL = gitUrlParse(repoURL).toString('https')91 const authURL = new URL(gitURL)92 authURL.username = gitHubToken93 await execute(`git config --global user.email "${email}"`)94 await execute(`git config --global user.name "${name}"`)95 await execute('git remote rm origin')96 await execute(`git remote add origin ${authURL} > /dev/null 2>&1`)97 await execute(`rm -Rf ${path.join(cwd, 'package-lock.json')}`)98 if (npm7) {99 /**100 * Given '--package-lock-only' does not work as expected with npm 7.101 * Then we need to make a clean installation to updates package-lock file used in the release.102 * See: https://github.com/npm/cli/issues/2747103 */104 await execute(getNpmInstall({legacyPeerDeps: npm7}))105 } else {106 await execute(getNpmInstall({only: 'pro', packageLockOnly: true}))107 await execute(getNpmInstall({only: 'dev', packageLockOnly: true}))108 }109 await execute('npm version minor --no-git-tag-version')110 const nextVersion = require(path.join(cwd, 'package.json')).version111 await execute(112 `git add ${path.join(cwd, 'package.json')} ${path.join(113 cwd,114 'package-lock.json'115 )}`116 )117 const skipCiMessage = skipCi ? '[skip ci]' : ''118 await execute(119 `git commit -m "release(META): ${nextVersion} ${skipCiMessage}"`120 )121 await execute(`git tag -a "v${nextVersion}" -m "v${nextVersion}"`)122 await execute('git status')123 await execute(`git push --set-upstream --tags origin ${branch}`)124 } catch (err) {125 console.log(err)126 }...

Full Screen

Full Screen

NPMProxy.ts

Source:NPMProxy.ts Github

copy

Full Screen

...16 }17 getNpmVersion(): string {18 return this.executeCommand('npm', ['--version']);19 }20 hasLegacyPeerDeps() {21 const result = this.executeCommand('npm', [22 'config',23 'get',24 'legacy-peer-deps',25 '--location=project',26 ]);27 return result.trim() === 'true';28 }29 setLegacyPeerDeps() {30 this.executeCommand('npm', ['config', 'set', 'legacy-peer-deps=true', '--location=project']);31 }32 needsLegacyPeerDeps(version: string) {33 return semver.gte(version, '7.0.0') && !this.hasLegacyPeerDeps();34 }35 getInstallArgs(): string[] {36 if (!this.installArgs) {37 this.installArgs = this.needsLegacyPeerDeps(this.getNpmVersion())38 ? ['install', '--legacy-peer-deps']39 : ['install'];40 }41 return this.installArgs;42 }43 getUninstallArgs(): string[] {44 if (!this.uninstallArgs) {45 this.uninstallArgs = this.needsLegacyPeerDeps(this.getNpmVersion())46 ? ['uninstall', '--legacy-peer-deps']47 : ['uninstall'];...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1{2 "peerDependencies": {3 }4}5{6 "dependencies": {7 }8}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hasLegacyPeerDeps } = require('storybook-root-cause');2const hasLegacyPeerDepsResult = hasLegacyPeerDeps();3console.log(hasLegacyPeerDepsResult);4{5 "scripts": {6 }7}8hasLegacyPeerDeps()

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hasLegacyPeerDeps } = require('storybook-root-config');2const hasLegacyDeps = hasLegacyPeerDeps();3if (hasLegacyDeps) {4 console.log('You have legacy peer dependencies');5} else {6 console.log('You do not have legacy peer dependencies');7}8"scripts": {9}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hasLegacyPeerDeps } = require('storybook-root');2console.log(hasLegacyPeerDeps());3const { hasLegacyPeerDeps } = require('./lib/hasLegacyPeerDeps');4module.exports = {5};6const { execSync } = require('child_process');7module.exports = {8 hasLegacyPeerDeps: () => {9 const peerDeps = execSync('npm info @storybook/react peerDependencies');10 return peerDeps.includes('react@^16.8.0');11 },12};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { hasLegacyPeerDeps } from '@storybook/root';2if (hasLegacyPeerDeps()) {3 console.log('Legacy peer dependencies detected');4} else {5 console.log('No legacy peer dependencies detected');6}

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