How to use npm-packlist - 8 common examples

To help you get started, we’ve selected a few npm-packlist 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 github / vscode-codeql / tools / build-tasks / src / deploy.ts View on Github external
async function collectPackages(context: RushContext, name: string, version: string,
  pkgs: PackageMap): Promise {

  let pkg = pkgs.getPackageInfo(name, version);
  if (!pkg) {
    const info = await context.getPackageInfo(name, version);

    let files: string[];
    if (info.isLocal) {
      // For local packages, use `packlist` to get the list of files that npm would have packed
      // into the tarball.
      files = packlist.sync({ path: info.path });
    }
    else {
      // For non-local packages, just copy everything.
      files = await glob('**/*', {
        nodir: true,
        cwd: info.path
      });
    }

    pkg = {
      name: name,
      version: version,
      sourcePath: info.path,
      files: files,
      dependencies: []
    };
github preconstruct / preconstruct / packages / cli / src / validate-included-files.ts View on Github external
export async function validateIncludedFiles(pkg: Package) {
  try {
    await Promise.all(
      pkg.entrypoints.map(async entrypoint => {
        let filename = path.join(
          entrypoint.directory,
          "dist",
          "preconstruct-test-file"
        );
        await fs.ensureFile(filename);
        return fs.writeFile(filename, "test content");
      })
    );

    let result = await packlist({ path: pkg.directory });

    // Ensure consistent path separators. Without this, there's a mismatch between this result and the path it
    // checks on Windows. This value will have a forward slash (dist/preconstruct-test-file), whereas the value
    // of distFilePath below will have a backslash (dist\preconstruct-test-file). Obviously these two won't match,
    // so the distfile check will fail.
    result = result.map(p => path.normalize(p));

    // check that we're including the package.json and main file
    // TODO: add Flow and TS check and if they're ignored, don't write them
    let messages: string[] = [];
    pkg.entrypoints.forEach(entrypoint => {
      let pkgJsonPath = path.relative(
        pkg.directory,
        path.resolve(entrypoint.directory, "package.json")
      );
      let distFilePath = path.relative(
github eslint / eslint / lib / config-tester / config-tester.js View on Github external
it("should contain all files that your config referred.", () => {
                        const validFiles = new Set(
                            packlist.sync({ path: projectRoot })
                                .map(relPath => path.relative(projectRoot, path.resolve(projectRoot, relPath)))
                        );
                        const invalidFiles = getDependedFiles()
                            .map(filePath => path.relative(projectRoot, filePath))
                            .filter(filePath => !filePath.startsWith(`node_modules${path.sep}`) && !validFiles.has(filePath))
                            .sort();

                        assert.deepStrictEqual(
                            invalidFiles,
                            [],
                            `${invalidFiles.length} file(s) were not contained in your package. Check your 'package.json' and '.npmignore'.`
                        );
                    });
github netlify / zip-it-and-ship-it / src / finders.js View on Github external
modulePaths.forEach(modulePath => {
    const packageJson = pkgs[modulePath]
    let moduleFilePaths

    moduleFilePaths = packList.sync({ path: modulePath })

    moduleFilePaths.forEach(moduleFilePath => {
      if (includeModuleFile(packageJson, moduleFilePath)) {
        filePaths.add(path.join(modulePath, moduleFilePath))
      }
    })
  })
github fimbullinter / wotan / scripts / api-guard.ts View on Github external
function checkPackage(packageDir: string, baselineDir: string, callback: (content: string, filename: string) => void) {
    const list = packlist.sync({path: packageDir});
    callback(list.join('\n'), path.join(baselineDir, 'packlist.txt'));

    for (const file of list)
        if (file.endsWith('.d.ts'))
            callback(stripPrivateMembers(fs.readFileSync(path.join(packageDir, file), 'utf8')), path.join(baselineDir, file));
}
github DavidWells / serverless-manifest-plugin / src / getDeps.js View on Github external
modulePaths.forEach(modulePath => {
    const packageJson = pkgs[modulePath];
    let moduleFilePaths;

    moduleFilePaths = packList.sync({ path: modulePath });

    moduleFilePaths.forEach(moduleFilePath => {
      if (includeModuleFile(packageJson, moduleFilePath)) {
        filePaths.add(path.join(modulePath, moduleFilePath));
      }
    });
  });
github netlify / netlify-dev-plugin / src / utils / finders.js View on Github external
modulePaths.forEach(modulePath => {
    const packageJson = pkgs[modulePath];
    let moduleFilePaths;

    moduleFilePaths = packList.sync({ path: modulePath });

    moduleFilePaths.forEach(moduleFilePath => {
      if (includeModuleFile(packageJson, moduleFilePath)) {
        filePaths.add(path.join(modulePath, moduleFilePath));
      }
    });
  });
github netlify / cli / src / utils / finders.js View on Github external
modulePaths.forEach(modulePath => {
    const packageJson = pkgs[modulePath]
    let moduleFilePaths

    moduleFilePaths = packList.sync({ path: modulePath })

    moduleFilePaths.forEach(moduleFilePath => {
      if (includeModuleFile(packageJson, moduleFilePath)) {
        filePaths.add(path.join(modulePath, moduleFilePath))
      }
    })
  })

npm-packlist

Get a list of the files to add from a folder into an npm package

ISC
Latest version published 4 months ago

Package Health Score

93 / 100
Full package analysis

Popular npm-packlist functions

Similar packages