Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// dep link out of the edgesIn set. Choose the edge with the fewest
// number of `node_modules` sections in the requestor path, and then
// lexically sort afterwards.
const edge = [...node.edgesIn].filter(edge => edge.valid).sort((a, b) => {
const aloc = a.from.location.split('node_modules')
const bloc = b.from.location.split('node_modules')
/* istanbul ignore next - sort calling order is indeterminate */
return aloc.length > bloc.length ? 1
: bloc.length > aloc.length ? -1
: aloc[aloc.length - 1].localeCompare(bloc[bloc.length - 1])
})[0]
// if we don't have one, just an empty object so nothing matches below
// This will effectively just save the version and resolved, as if it's
// a standard version/range dep, which is a reasonable default.
const spec = !edge ? {}
: npa.resolve(node.name, edge.spec, edge.from.realpath)
const rSpec = specFromResolved(node.resolved)
if (node.target)
lock.version = `file:${relpath(this.path, node.realpath)}`
else if (spec && (spec.type === 'file' || spec.type === 'remote'))
lock.version = spec.saveSpec
else if (spec && spec.type === 'git' || rSpec && rSpec.type === 'git') {
lock.version = node.resolved
/* istanbul ignore else - don't think there are any cases where a git
* spec (or indeed, ANY npa spec) doesn't have a .raw member */
if (spec.raw)
lock.from = spec.raw
} else if (!node.isRoot &&
node.package &&
node.package.name &&
private async hasMismatchedPeer(manifest: PackageManifest): Promise {
for (const peer in manifest.peerDependencies) {
let peerIdentifier;
try {
peerIdentifier = npa.resolve(peer, manifest.peerDependencies[peer]);
} catch {
this.logger.warn(`Invalid peer dependency ${peer} found in package.`);
continue;
}
if (peerIdentifier.type === 'version' || peerIdentifier.type === 'range') {
try {
const version = await this.findProjectVersion(peer);
if (!version) {
continue;
}
// tslint:disable-next-line:no-any
const options = { includePrerelease: true } as any;
if (
export function trySpecs(specBase: string, adaptVersion: SemVer): SpecInfo[] {
const specs: SpecInfo[] = [];
let pkgInfo: pkgArg.Result | undefined;
let type: SpecInfo["type"] | undefined;
if (isLocalSpec(specBase)) type = "local";
try {
pkgInfo = pkgArg(specBase);
} catch (err) { /* */ }
if (type !== "local") {
const versions = tryVersions(adaptVersion);
if (mightBeGallerySpec(specBase)) {
const base = galleryUrl(specBase);
[ ...versions, undefined ].forEach((v) => specs.push({
base,
complete: galleryUrl(specBase, v),
type: "git",
}));
}
if (pkgInfo) {
type = toSpecInfoType(pkgInfo.type);
const configBuffer = await fse.readFile(configPath);
const appJson = configName === 'app.json' ? JSON.parse(configBuffer.toString()) : {};
/**
* Perform validations
*/
if (!exp.sdkVersion) throw new Error(`Couldn't read ${configName}`);
if (!Versions.gteSdkVersion(exp, '34.0.0')) {
throw new Error(`Ejecting to a bare project is only available for SDK 34 and higher`);
}
// Validate that the template exists
let sdkMajorVersionNumber = semver.major(exp.sdkVersion);
let templateSpec = npmPackageArg(`expo-template-bare-minimum@sdk-${sdkMajorVersionNumber}`);
try {
await pacote.manifest(templateSpec);
} catch (e) {
if (e.code === 'E404') {
throw new Error(
`Unable to eject because an eject template for SDK ${sdkMajorVersionNumber} was not found`
);
} else {
throw e;
}
}
/**
* Customize app.json
*/
let { displayName, name } = await getAppNamesAsync(projectRoot);
filterLocalDeps(name, deps) {
// Change the working directory since npm-package-arg uses it when calling
// path.resolve
let originalCwd = process.cwd();
let packagePath = path.resolve(this.root, name);
process.chdir(packagePath);
let localDeps = {};
try {
for (let [dep, version] of toPairsIn(deps)) {
let descriptor = npmPackageArg(`${dep}@${version}`);
if (descriptor.type === 'local') {
localDeps[dep] = descriptor.spec;
}
}
} finally {
process.chdir(originalCwd);
}
return localDeps;
}
let validationResult = validateName(parentDir, dirName);
if (validationResult !== true) {
throw new CommandError('INVALID_PROJECT_DIR', validationResult);
}
} else if (options.parent && options.parent.nonInteractive) {
throw new CommandError(
'NON_INTERACTIVE',
'The project dir argument is required in non-interactive mode.'
);
} else {
parentDir = process.cwd();
}
let templateSpec;
if (options.template) {
templateSpec = npmPackageArg(options.template);
// For backwards compatibility, 'blank' and 'tabs' are aliases for
// 'expo-template-blank' and 'expo-template-tabs', respectively.
if (
(templateSpec.name === 'blank' ||
templateSpec.name === 'tabs' ||
templateSpec.name === 'bare-minimum' ||
templateSpec.name === 'bare-foundation') &&
templateSpec.registry
) {
templateSpec.escapedName = `expo-template-${templateSpec.name}`;
templateSpec.name = templateSpec.escapedName;
templateSpec.raw = templateSpec.escapedName;
}
} else {
let descriptionColumn =
const versionedPackages = packages.map(arg => {
const spec = npmPackageArg(arg);
const { name } = spec;
if (['tag', 'version', 'range'].includes(spec.type) && name && bundledNativeModules[name]) {
// Unimodule packages from npm registry are modified to use the bundled version.
const version = bundledNativeModules[name];
const modifiedSpec = `${name}@${version}`;
nativeModules.push(modifiedSpec);
return modifiedSpec;
} else {
// Other packages are passed through unmodified.
others.push(spec.raw);
return spec.raw;
}
});
const messages = [];
function childDependencySpecifier (tree, name, spec, where) {
return npa.resolve(name, spec, where || packageRelativePath(tree))
}
return tree.forEachAsync((dep, next) => {
if (!this.checkDepEnv(dep)) { return }
const depPath = dep.path(this.prefix)
const spec = npa.resolve(dep.name, dep.version, this.prefix)
if (dep.isRoot) {
return next()
} else if (spec.type === 'directory') {
const relative = path.relative(path.dirname(depPath), spec.fetchSpec)
this.log.silly('extractTree', `${dep.name}@${spec.fetchSpec} -> ${depPath} (symlink)`)
return mkdirp(path.dirname(depPath))
.then(() => symlinkAsync(relative, depPath, 'junction'))
.catch(
() => rimraf(depPath)
.then(() => symlinkAsync(relative, depPath, 'junction'))
).then(() => next())
.then(() => {
this.pkgCount++
cg.completeWork(1)
})
} else {
function hasModernMeta (child) {
if (!child) return false
const resolved = child.package._resolved && npa.resolve(moduleName(child), child.package._resolved)
const version = npa.resolve(moduleName(child), child.package.version)
return child.isTop ||
isLink(child) ||
child.fromBundle || child.package._inBundle ||
child.package._integrity || child.package._shasum ||
(resolved && resolved.type === 'git') || (version && version.type === 'git')
}