How to use the @yarnpkg/lockfile.stringify function in @yarnpkg/lockfile

To help you get started, we’ve selected a few @yarnpkg/lockfile 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 ipfs-shipyard / npm-on-ipfs / src / core / commands / rewrite-lock-file.js View on Github external
writeFileSync(lockfilePath, JSON.stringify(lockfile, null, 2))
  } else if (options.packageManager === 'yarn') {
    const lockfilePath = path.join(process.cwd(), 'yarn.lock')

    if (!existsSync(lockfilePath)) {
      console.info(`🤷 No yarn.lock found`) // eslint-disable-line no-console
      return
    }

    console.info(`🔏 Updating yarn.lock`) // eslint-disable-line no-console

    const lockfile = yarnLockfile.parse(readFileSync(lockfilePath, 'utf8'))

    replaceRegistryPath(lockfile.object, new URL(options.registry))

    writeFileSync(lockfilePath, yarnLockfile.stringify(lockfile, null, 2))
  }
}
github microsoft / rushstack / apps / rush-lib / src / logic / yarn / YarnShrinkwrapFile.ts View on Github external
protected serialize(): string {
    // abstract
    return lockfile.stringify(this._shrinkwrapJson);
  }
github atlassian / yarn-deduplicate / modules / fix-duplicates.js View on Github external
json[`${name}@${p.requestedVersion}`] = dedupedPackage.pkg;
            })
            } else {
            // otherwise dedupe each package to its maxSatisfying version
            packages.forEach(p => {
                const targetVersion = semver.maxSatisfying(versions, p.requestedVersion);
                if (targetVersion === null) return;
                if (targetVersion !== p.pkg.version) {
                    const dedupedPackage = packages.find( p => p.pkg.version === targetVersion);
                    json[`${name}@${p.requestedVersion}`] = dedupedPackage.pkg;
                }
            })
            }
        });

    return lockfile.stringify(json);
}
github DefinitelyTyped / DefinitelyTyped / types / yarnpkg__lockfile / yarnpkg__lockfile-tests.ts View on Github external
import { parse, stringify, FirstLevelDependency } from '@yarnpkg/lockfile';

function testFirstLevelDependency(obj: FirstLevelDependency) {}

const file = '';
const parseResult = parse(file);
const fileAgain = stringify(parseResult);
fileAgain.toLowerCase();

if (parseResult.type === 'merge' || parseResult.type === 'success') {
  Object.keys(parseResult.object).forEach(k => {
    const value = parseResult.object[k];
    testFirstLevelDependency(value);
  });
}
github atlassian / yarn-deduplicate / index.js View on Github external
module.exports.fixDuplicates = (yarnLock, { includePackages = [], useMostCommon = false } = {}) => {
    const json = parseYarnLock(yarnLock);

    getDuplicatedPackages(json, { includePackages, useMostCommon }).forEach(
        ({ bestVersion, name, versions, requestedVersion }) => {
            json[`${name}@${requestedVersion}`] = versions[bestVersion].pkg;
        }
    );

    return lockfile.stringify(json);
};
github fusionjs / fusionjs / jazelle / utils / lockfile.js View on Github external
sets.map(async ({dir, meta, lockfile}) => {
      await exec(`mkdir -p ${dir}`);
      await write(
        `${dir}/package.json`,
        `${JSON.stringify(meta, null, 2)}\n`,
        'utf8'
      );
      await write(`${dir}/yarn.lock`, stringify(lockfile), 'utf8');
    })
  );

@yarnpkg/lockfile

The parser/stringifier for Yarn lockfiles.

BSD-2-Clause
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis

Popular @yarnpkg/lockfile functions