Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openfn/describe-package

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfn/describe-package

Utilities to inspect an npm package.

  • 0.0.17
  • npm
  • Socket score

Version published
Weekly downloads
788
increased by17.09%
Maintainers
4
Weekly downloads
 
Created
Source

@openfn/describe-package

Utility for inspecting and describing an arbitrary npm package.

Usage

There is a demo project available in examples/compiler-worker.

Inspecting a module

import { Pack, Project, describeDts } from "@openfn/describe-package";

const project = new Project();

// Load a module from Unpkg
const pack = await Pack.fromUnpkg("@openfn/language-common@2.0.0-rc1");

const packageOrDts = /(?:package.json)|(?:\.d\.ts$)/i;

if (!pack.types) {
  throw new Error(
    `No 'types' field found for ${pack.specifier}`
  );
}

// Download the `package.json` and `.d.ts` files.
const files = await pack.getFiles(
  pack.fileListing.filter((path) => packageOrDts.test(path))
);

// Add the files to the Project filesystem.
project.addToFS(files);

// Add the types entrypoint (e.g. `index.d.ts`) as a 'project file'.
project.createFile(files.get(pack.types), pack.types);

// And finally get a list of exported members from a module.
const operations = describeDts(project, pack.types);

Project

The Project object is a wrapper around the Typescript compiler, providing the necessary hooks to interact with code and module type definitions.

Workers

⛔ Not working currently.

const { startWorker } = await import("@openfn/describe-package/worker");
const worker = await startWorker();
const results = await worker.describeAdaptor("a .d.ts as a string");

Building

There are three scripts:

  • pnpm test
    Runs the tests
  • pnpm run build
    Cleans up dist and builds for packaging for npm.
  • pnpm run watch
    Rebuilds on changes.

The Worker is built in two phases:

  1. Bundle up the worker which includes the TypeScript compiler.
  2. Compile the entrypoint, which injects the worker as a string.

By splitting this up we can produce a single file that can be used in the browser.

FAQs

Package last updated on 21 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc