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

@drugscom/ddcjsmodules

v8.8.4

Published

Shared javascript modules.

Downloads

572

Readme

DDC JS Modules

Javascript module library as an npm package.

Local development with Docker

Dependencies

Docker Desktop

Download and install Docker Desktop from: https://www.docker.com/products/docker-desktop/

On Windows use the WSL 2 backend.

Earthly

  • macOS:

    brew install earthly/earthly/earthly && earthly bootstrap
  • Windows (inside WSL):

    sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'

For more details: https://earthly.dev/get-earthly

Running npm commands

To run npm commands:

docker-compose run --rm npm <npm options>

e.g.:

docker-compose run --rm npm install --save-dev stylelint

Running CI tests locally

To run the complete set of CI tests:

earthly +test

You can also specify a single test to run. e.g.:

earthly +jshint
earthly +mocha

Cleaning up

To clean up the project root (node_modules, ...):

earthly +clean

Release New Package Version

The CI/CD pipeline will automatically bump the package version and publish the new release to npmjs.com if the Pull Request has one of the following labels:

  • release:major (Bump the major version number e.g. from 1.8.1 to 2.0.0)
  • release:minor (Bump the minor version number e.g. from 1.8.1 to 1.9.0)
  • release:patch (Bump the patch version number e.g. from 1.8.1 to 1.8.2)

After the workflow has finished running, you can update the dependency in your project by running npm install '@drugscom/ddcjsmodules@<new version>' in your project root. E.g.:

cd ~/dev/ddcwww
npm install '@drugscom/[email protected]'

Manual mode

Note: The production staging process depends on the creation of a new project tag to get the latest version of the ddcjsmodules project.

Step 1: Create new tag (version) for ddcjsmodules

Ensure all changes have been committed (and tested). Use the command npm version patch to create a new "patch" version. (e.g. 7.17.117.17.12). Alternatively, replace patch with minor or major to increment the "minor" (7.17.117.18.0) or "major" (7.17.118.0.0) versions, if required.

[ddcjsmodules]# git status
[ddcjsmodules]# npm version patch

Push this tag change to GitHub and run npm publish to notify npmjs.com of this new version.

[ddcjsmodules]# git push --tags origin master
[ddcjsmodules]# npm publish

Enter the one-time password from your authenticator app when prompted.

Step 2: Update ddcwww

Edit the package.json file inside the ddcwww project and update the @drugscom/ddcjsmodules dependency with the new tag version created in Step 1.

"dependencies": {
   "@babel/core": "7.14.5",
   "@babel/preset-env": "7.14.5",
   "@drugscom/ddcjsmodules": "7.17.12", <-- New version here
   "autoprefixer": "9.8.6",
   ...
}

From the ddcwww project root, run npm install:

[ddcwww]# npm install

This will use the package.json file to install the specified version of ddcjsmodules into the /node_modules directory, updating the project's package-lock.json file in the process. Changes from both package.json and package-lock.json must be committed/pushed to GitHub.

Link Development Version

Any project can be set up to reference a "live" version of the ddcjsmodules project (versus using the package.json version). This can be very useful in a development environment.

  1. Define the ddcjsmodules project as a "node modules link". Note: This only needs to be done once, anytime after cloning.
[home]# git clone [email protected]:drugscom/ddcjsmodules.git
[home]# cd ddcjsmodules/
[ddcjsmodules]# npm install
[ddcjsmodules]# npm link
  1. Inside the root directory of the ddcwww project, use the npm link command to link the "live" version of ddcjsmodules set up in Step 1:
[ddcwww]# npm link @drugscom/ddcjsmodules

Note: Running npm install or npm update will break the link, reverting ddcwww to use the package.json version:

[ddcwww]# npm install
- or -
[ddcwww]# npm install @drugscom/ddcjsmodules
- or -
[ddcwww]# npm update @drugscom/ddcjsmodules

Simply repeat Step 2 to recreate the link once again.

Unit Tests

To run all unit tests from the command line:

[ddcjsmodules]# npm test

To run a specific unit test:

[ddcjsmodules]# npm test test/helper.js 

Configure Modules

To use a ddcjsmodules module inside the ddcwww project, the module path will should be aliased inside the browser section of the package.json file:

"browser": {
   "ddc-agent": "./node_modules/@drugscom/ddcjsmodules/src/agent",
   "ddc-analytics": "./node_modules/@drugscom/ddcjsmodules/src/analytics",
   "ddc-config": "./node_modules/@drugscom/ddcjsmodules/src/config",
   "ddc-debug": "./node_modules/@drugscom/ddcjsmodules/src/debug",
   "ddc-error": "./node_modules/@drugscom/ddcjsmodules/src/error",
   "ddc-helper": "./node_modules/@drugscom/ddcjsmodules/src/helper",
   "ddc-timing": "./node_modules/@drugscom/ddcjsmodules/src/timing",
   ...
}

Then the module path can be referenced inside a Javascript file using the require statement:

const Debug = require('ddc-debug');
Debug.log("API response:", data);

const Analytics = require('ddc-analytics');
Analytics.sendEvent({event: 'AdClick', drugName: 'Lexapro'});

Javascript Debugging

Return the current debug configuration (JSON string):

> DDC.Debug.get();

Set the current debug configuration (overrides any existing configuration):

> DDC.Debug.set({options});

The {options} parameter should follow this structure:

{
   show: ['DDC.Class.method', 'DDC.Class2.method2', ...], // Array of strings;
   mark: ['DDC.Class.method', ...]  // Array of strings;
}

Console logging the Debug.trace data will use the logic:

  1. if the trace method name starts with a value in the [mark] array, log to console (important color)
  2. if the trace method name starts with a value in the [show] array, log to console (standard color)
  3. else, do not log

Examples

Use your browser's Developer Tools Console to enter the following commands.

Show all debugging:

> DDC.Debug.set({show: ['']})

Show debugging for methods starting with "Mednotes.Page":

> DDC.Debug.set({show: ['Mednotes.Page']})

Show debugging for methods starting with "DDC.Ads" and "DDC.Page"; highlight methods starting with "DDC.Ads.buildAd":

> DDC.Debug.set({show: ['DDC.Ads', 'DDC.Page'], mark: ['DDC.Ads.buildAd']})

Stop all debugging:

> DDC.Debug.set({show: [], mark: []})