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

searchquire

v1.5.2

Published

Searches proxyquire dependencies stubs recursively using configurable patterns.

Downloads

3

Readme

Searchquire

Version Build Status Codacy Badge codecov

Introduction

Searchquire easily allows to recursively override scripts dependencies during testing using configurable search patterns to locate reusable stubs and mocks.

Installing / Getting started

To install the package execute:

npm install searchquire --save-dev

Usage

Simple examples

Resolve a module using a basePath where module is found as parameter.

var searchquire = require('searchquire');

var foo = searchquire('foo', {
  basePath: './simple-example/samples'
});

Resolve a module using a mock location to resolve dependencies.

var searchquire = require('searchquire');

var foo = searchquire('foo', {
  basePath: './simple-example/samples',
  modulePaths: [{
    basePath: './simple-example/mocks',
    fileSuffix: 'Mock.js'
  }]
});

Resolve a module using a mock location to resolve dependencies with a string require pattern.

var searchquire = require('searchquire');

var foo = searchquire('foo', {
  basePath: './simple-example/samples',
  modulePaths: [{
    basePath: './simple-example/mocks',
    fileSuffix: 'Mock',
    pattern: './*'
  }]
});

Resolve a module using stubs to resolve dependencies.

var searchquire = require('searchquire');

var foo = searchquire('foo', {
  basePath: './simple-example/samples',
  moduleStubs: {
    'path': {
      basename: function() {
        return 'BASSTUB';
      }
    }
  }
});

See tests for more examples and details.

Complex examples

Resolve a module using a path alias.

var searchquire = require('searchquire');

var foo = searchquire('foo', {
  basePath: './complex-example/samples',
  pattern: '(pathAlias)/*',
  patternAlias: './opinionated/folder/hierarchy/with/many/levels'
});

Resolve a module using an array of path alias and stubs with regex pattern to resolve dependencies with logging enabled.

var searchquire = require('searchquire');

var qux = searchquire('qux', {
  basePath: './complex-example/samples',
  baseModulePaths: [
    {
      name: 'alias-path',
      pattern: /^(pathAlias)\/.*/,
      patternAlias: './opinionated/folder/hierarchy/with/many/levels'
    },
    {
      name: 'another-alias-path',
      pattern: /^(anotherPathAlias)\/.*/,
      patternAlias: './another/opinionated/folder/hierarchy/with/many/levels'
    }
  ],
  moduleStubs: [
    {
      name: 'stub-zab',
      pattern: /.*\/zab/,
      stub: {
        zab: function() {
          return 'zabstub';
        }
      }
    }
  ],
  logLevel: 1,
  logElapseTime: true
});

See tests for more examples and details.

Salesforce Commerce Cloud SFRA examples

Resolve a dw api mock.

var searchquire = require('searchquire');

var CustomerMock = searchquire('dw/customer/Customer', {
  basePath: './sfra-example/mocks/dw-api-mock'
});

Resolve a cartridge script using mocks folders with file suffix and require patterns for cartridge scripts and dw api.

var searchquire = require('searchquire');

var orderHelpersTest = searchquire('*/cartridge/scripts/order/orderHelpers', {
  basePath: './sfra-example/project/cartridges/storefront/cartridge',
  pattern: '*/cartridge/(.*)',
  modulePaths: [
    {
      name: 'storefront-mock',
      basePath: './sfra-example/mocks/storefront-mock',
      fileSuffix: 'Mock',
      pattern: '*/cartridge/(.*)'
    },
    {
      name: 'dw-mock',
      basePath: './sfra-example/mocks/dw-api-mock',
      pattern: 'dw/*'
    }
  ]
});

See tests for more examples and details.

Developing

Built with

Folder structure

  • root: Contains the README.md, the main configuration to execute the project such as package.json or any other configuration files.
  • lib: Contains the source code for application script.
  • test: Contains library tests and examples.
  • node_modules: Contains third party JS libraries used in this project

Setting up Dev

Download the code

git clone https://github.com/pikamachu/pika-searchquire.git
cd pika-searchquire

Install dependencies

bash pika install

Run application tests.

bash pika test