JS-DevTools/npm-publish

Extend package argument to handle directory, file, or archive

razor-x opened this issue · 0 comments

          I've been working my way through the code in the main branch, and I'm starting to have a few thoughts about the existing `package` and proposed `package-spec` inputs:
  • I'm not sure overriding the working directory is important or useful, compared to exposing the package-spec arg (or a workspace option, in the future), so we can probably drop the idea of working-directory for now
  • If the package-spec is a pre-packed tarball, then we still need something to point us to package.json so we can read the package name / current version.
    • Or maybe we extract package.json from the archive?
  • If package-spec is a directory, we should use the package.json in the directory, I think

What do you think of these points? To brainstorm something:

  • Keep the package arg
  • If package unspecified, default to regular npm behavior: use the cwd as the current package
  • If package is a package.json file, use the directory of that file as the package_spec argument to npm
  • If package is a directory, look for a package.json in that directory and use the directory as the package_spec arg to npm
  • If package is an archive, I'm not sure
    • Extract package.json from the archive?
    • Require a separate package-manifest input?

Originally posted by @mcous in #69 (comment)

What do you think of these points? To brainstorm something:...

That looks like the right logic to me. And yes, we should extract the package.json file from the tar file, not require another argument. I don't think we need to extract it to the file system though, we should just be able to read it into memory.