How to use the @yarnpkg/core.structUtils.stringifyLocator function in @yarnpkg/core

To help you get started, we’ve selected a few @yarnpkg/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yarnpkg / berry / packages / plugin-patch / sources / PatchResolver.ts View on Github external
bindDescriptor(descriptor: Descriptor, fromLocator: Locator, opts: MinimalResolveOptions) {
    // If the patch is statically defined (ie absolute or a builtin), then we
    // don't need to bind the descriptor to its parent
    const {patchPaths} = patchUtils.parseDescriptor(descriptor);
    if (patchPaths.every(patchPath => !patchUtils.isParentRequired(patchPath)))
      return descriptor;

    return structUtils.bindDescriptor(descriptor, {
      locator: structUtils.stringifyLocator(fromLocator),
    });
  }
github yarnpkg / berry / packages / plugin-file / sources / TarballFileResolver.ts View on Github external
bindDescriptor(descriptor: Descriptor, fromLocator: Locator, opts: MinimalResolveOptions) {
    if (FILE_REGEXP.test(descriptor.range))
      descriptor = structUtils.makeDescriptor(descriptor, `${PROTOCOL}${descriptor.range}`);

    return structUtils.bindDescriptor(descriptor, {
      locator: structUtils.stringifyLocator(fromLocator),
    });
  }
github yarnpkg / berry / packages / plugin-patch / sources / patchUtils.ts View on Github external
export async function extractPackageToDisk(locator: Locator, {cache, project}: {cache: Cache, project: Project}) {
  const checksums = project.storedChecksums;
  const report = new ThrowReport();

  const fetcher = project.configuration.makeFetcher();
  const fetchResult = await fetcher.fetch(locator, {cache, project, fetcher, checksums, report});

  const temp = await xfs.mktempPromise();
  await xfs.copyPromise(temp, fetchResult.prefixPath, {
    baseFs: fetchResult.packageFs,
  });

  await xfs.writeJsonPromise(ppath.join(temp, `.yarn-patch.json` as Filename), {
    locator: structUtils.stringifyLocator(locator),
  });

  return temp;
}
github yarnpkg / berry / packages / plugin-essentials / sources / commands / why.ts View on Github external
const sortedWorkspaces = miscUtils.sortMap(project.workspaces, workspace => {
    return structUtils.stringifyLocator(workspace.anchoredLocator);
  });
github yarnpkg / berry / packages / plugin-exec / sources / ExecFetcher.ts View on Github external
private async generatePackage(locator: Locator, generatorPath: PortablePath, opts: FetchOptions) {
    const cwd = npath.toPortablePath(dirSync().name);
    const env = await scriptUtils.makeScriptEnv({project: opts.project});

    const logFile = npath.toPortablePath(tmpNameSync({
      prefix: `buildfile-`,
      postfix: `.log`,
    }));

    const stdin = null;
    const stdout = xfs.createWriteStream(logFile);
    const stderr = stdout;

    stdout.write(`# This file contains the result of Yarn generating a package (${structUtils.stringifyLocator(locator)})\n`);
    stdout.write(`\n`);

    const {code} = await execUtils.pipevp(process.execPath, [npath.fromPortablePath(generatorPath), structUtils.stringifyIdent(locator)], {cwd, env, stdin, stdout, stderr});
    if (code !== 0)
      throw new Error(`Package generation failed (exit code ${code}, logs can be found here: ${logFile})`);

    return cwd;
  }
}
github yarnpkg / berry / packages / plugin-patch / sources / patchUtils.ts View on Github external
function makeSpec({parentLocator, sourceItem, patchPaths, patchHash}: {parentLocator: Locator | null, sourceItem: T, patchPaths: Array, patchHash?: string}, sourceStringifier: (source: T) => string) {
  const parentLocatorSpread = parentLocator !== null
    ? {parentLocator: structUtils.stringifyLocator(parentLocator)}
    : {} as {};

  const patchHashSpread = typeof patchHash !== `undefined`
    ? {hash: patchHash}
    : {} as {};

  return structUtils.makeRange({
    protocol: `patch:`,
    source: sourceStringifier(sourceItem),
    selector: patchPaths.join(`&`),
    params: {
      ...parentLocatorSpread,
      ...patchHashSpread,
    },
  });
}
github yarnpkg / berry / packages / plugin-link / sources / RawLinkResolver.ts View on Github external
bindDescriptor(descriptor: Descriptor, fromLocator: Locator, opts: MinimalResolveOptions) {
    return structUtils.bindDescriptor(descriptor, {
      locator: structUtils.stringifyLocator(fromLocator),
    });
  }