0.0.3 • Published 10 months ago

@bernankez/npm-open v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

npm-open

npm CI

Type npm-open to open the npm package page in the browser. Similar to git-open.

Install

pnpm add -g @bernankez/npm-open

Usage

Run in the project root directory:

npm-open

You can also specify the root directory using the --cwd flag:

npm-open --cwd <path to project>

By default, it opens page with your current npm registry. If you want to open the npm package page, using the -n or --npm:

npm-open -n

Config

npm-open suppports customizing npm registry config via npmopen.config.ts. You can customize the website page url.

// npmopen.config.ts
import { defineConfig } from "@bernankez/npm-open";

export default defineConfig({
  // Always open npm package page or not
  npm: false,
  // Custom registry config
  registry: [
    {
      name: "custom",
      url: "https://your-custom-registry/",
      website: pkgName => `https://your-custom-registry/page/${pkgName}`
    }
  ]
});

API Usage

import { resolvePackage } from "@bernankez/npm-open";

const pkgName = "@bernankez/npm-open";

async function load(): Promise<void> {
  const pkg = await resolvePackage(pkgName, {
    npm: true,
  });
  console.log(pkg);
  // {
  //   name: "npm",
  //   url: "https://registry.npmjs.org/@bernankez/npm-open",
  //   website: "https://www.npmjs.com/package/@bernankez/npm-open",
  // }
}

load();

License

MIT License © 2024-PRESENT 科科Cole

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago