npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

use-workspace

v0.1.11

Published

`use-workspace` is a set of tools designed to facilitate the creation, configuration, and maintenance of workspaces for development projects. It provides a simple API for managing directories, files, and configurations related to the development environme

Downloads

354

Readme

use-workspace

use-workspace is a set of tools designed to facilitate the creation, configuration, and maintenance of workspaces for development projects. It provides a simple API for managing directories, files, and configurations related to the development environment.

Sample:

import { useWorkspace } from "use-workspace";
import { useGit } from "use-workspace/git";

const workspace = await useWorkspace("foo");

workspace.toURL(); // 'file://$WORKSPACE_LOCATION/foo/'
workspace.toURL("biz.txt"); // 'file://$WORKSPACE_LOCATION/foo/biz.txt'

// $ ls $WORKSPACE_LOCATION/foo/
// .gitignore

const git = await useGit(workspace);
// $ ls $WORKSPACE_LOCATION/foo/
// .git/
// .gitignore

await git.config.set("taz.bar", "Bar");
await git.config.get("taz.bar"); // => "Bar"

Git integration

Allows for easy initialization of Git repositories within the workspace and their configuration.

import { useGit } from "use-workspace/git";

const git = await useGit(workspace);

const editor = await git.config.get("core.editor");

expect(editor).toEqual("vim");

Server integration

Includes the ability to launch a local server associated with the workspace for testing and development purposes.

import { useServer } from "use-workspace/server";

await using server = useServer(workspace);

server.toURL("foo.txt"); // 'https://localhost:3000/foo.txt'

Create server instance

await using server = useServer(workspace);

Get url of file

server.toURL("foo.txt"); // 'https://localhost:3000/foo.txt'

Custom fetcher

await using server = useServer(workspace, {
  fetchers: [(req: Request) => new Response("ok")],
});

Custom URL

await using server = useServer(workspace, {
  publicUrl: "https://my-url/with-subpath/",
});

NPM Pack Integration

The useNpmPack API provided by the module "use-workspace/use-npm-pack" enables the packaging of workspaces for distribution and deployment. The first argument specifies a workspace for a package, and the second argument is an array describing the list of files to observe for changes since the last packaging.

Internally, it executes the npm pack command to create a .tgz file, allowing it to be used in any other workspace seamlessly.

Example

import {useNpmPack} from "use-workspace/use-npm-pack"

const pack = await useNpmPack(workspace, ["package.json", "src/index.ts",...])
pack // => 'file://.../package.tgz'

Visual State for GIT

The visualGitState(workspace, visualState) function is a tool to make a git state easily.

The visualState is a string with instructions to make branches and files under this branch.

Sample:

branch: main
  ./file.txt
    {
      "name": "my-app",
      "version": 1
    }
branch: main..f1
  ./file.txt
    {
      "name": "my-super-app",
      "version": 2
    }
  ./f1.txt
    I'm f1
branch: main..f2
  ./file.txt
    {
      "name": "my-mega-app",
      "version": 3
    }
  ./f2.txt
    I'm f2

Example:

const workspace = await useWorkspace("my-workspace");
await visualGitState(
  workspace,
  `
    branch: main
      ./file.txt
        {
          "name": "my-app",
          "version": 1
        }
    branch: main..f1
      ./file.txt
        {
          "name": "my-super-app",
          "version": 2
        }
      ./f1.txt
        I'm f1
    branch: main..f2
      ./file.txt
        {
          "name": "my-mega-app",
          "version": 3
        }
      ./f2.txt
        I'm f2
  `,
);