Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function syncRootPackageVersion (useProjectVersion) {
const project = new Project(process.cwd())
const rootPkg = getPackage()
let projectVersion
if (project.isIndependent() || useProjectVersion) {
projectVersion = project.version
} else {
// unfortunately lerna doesn't update lerna.json for canary releases,
// so we have to do this:
const pkgs = getChangedPackages()
projectVersion = pkgs[0].get('version')
}
if (projectVersion !== rootPkg.get('version')) {
rootPkg.set('version', projectVersion)
await rootPkg.serialize()
}
module.exports = function generateScopedName (getComponentId, config, name, filepath, css) {
const componentId = getComponentId()
const context = {
env: ENV,
resourcePath: filepath,
context: process.cwd()
}
let scopedNamePattern
if (config && typeof config.generateScopedName === 'function') {
scopedNamePattern = config.generateScopedName(context, name, filepath, css, componentId)
} else if (config && typeof config.generateScopedName === 'string') {
scopedNamePattern = config.generateScopedName
} else if (UNMANGLED_CLASS_NAMES) {
const pkg = getPackage({ cwd: path.dirname(filepath) })
const pkgName = pkg.name.split('/').pop()
scopedNamePattern = `${pkgName}__[folder]--[local]`
} else {
scopedNamePattern = `${componentId}_${loaderUtils.getHashDigest(name, 'md5', 'base52', 4)}`
}
scopedNamePattern = scopedNamePattern.replace(/\[local\]/gi, name)
return loaderUtils.interpolateName(context, scopedNamePattern, { content: css })
}
async function installReact () {
const pkgInfo = JSON.parse(
runCommandSync('yarn', ['info', 'react', '--json'], [], { stdio: 'pipe' }).stdout
).data
const latest = pkgInfo['dist-tags'].latest
let version = `${argv[argv.indexOf('--install-react') + 1]}`.trim()
version = semver.coerce(version) || latest
info(`Version: ${version}`)
let originalResolutions, pkg
if ([15, 16].includes(semver.major(version))) {
pkg = getPackage()
originalResolutions = {...pkg.get('resolutions')}
pkg.set('resolutions', {
...(originalResolutions || {}),
'react': `^${version}`,
'react-dom': `^${version}`
})
info(`Updating resolutions for React to ${version}...`)
await pkg.serialize()
}
try {
info(`Installing React...`)
runCommandSync('yarn', ['--pure-lockfile', '--force'])