Skip to content

Cleanup of the Netlify CLI #156

Open
@talentlessguy

Description

@talentlessguy

Currently it has 107 direct dependencies, and many more non-direct. It's worth cleaning them up.

Modules that can be replaced with other modules:

  • chalk -> picocolors (mainly a size win)
  • chokidar v3 -> v4 upgrade, -11 deps (if I remember correctly)
  • find-up -> empathic, -7 deps
  • dot-prop -> dlv + dset, might be that only one is needed
  • execa -> tinyexec

Modules that can be removed in favor of 1-3 lines of code:

  • is-stream
  • p-filter:
const filteredItems = await Promise.all(
  items.map(async (item) => {
    const shouldKeep = await someAsyncCondition(item); // Replace with your async condition
    return shouldKeep ? item : null;
  })
).then((results) => results.filter((item) => item !== null));
  • p-map, probably could be replaced with Promise.all
  • p-wait-for:
const waitFor = async (condition, interval = 100) => {
  while (!(await condition())) {
    await new Promise((resolve) => setTimeout(resolve, interval));
  }
};
  • through2-filter:
const { Transform } = require('node:stream');

const filterStream = new Transform({
  decodeStrings: false,
  transform(chunk, encoding, callback) {
    if (chunk.includes('foo')) { // Example filter condition
      this.push(chunk);
    }
    callback();
  },
});

process.stdin
  .pipe(filterStream)
  .pipe(process.stdout);
  • from2-array:
const { Readable } = require('node:stream');

const arrayToStream = (array) => {
  return new Readable({
    objectMode: true,
    read() {
      array.forEach((item) => this.push(item));
      this.push(null);
    },
  });
};
  • tempy -> os.tmpdir() + fs.createFile / fs.mkdir
  • hasha -> crypto.createHash('sha512').digest()

PRs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    umbrella issueThis issue contains a list of dependents of a package and tracks the progress in each

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions