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

netlify-subdomain-manager

v0.1.4

Published

A CLI tool used to dynamically manage your subdomain on Netlify.

Downloads

2

Readme

npm

Netlify Subdomain Manager

This CLI tool can be used to manage your subdomain aliases on Netlify using a JSON file as a source of truth.

Usage

You can the node script like so.

npm install netlify-subdomain-manager
netlify_subdomain_manager --help

Example JSON file

Where the JSON file is just a list of subdomain aliases you want. These will be prepended by the mainDomain. For example if the json file was like this:

["abc", "xyz"]

and the main domain was haseebmajid.dev then we would create the following aliases abc.haseebmajid.dev and xyz.haseebmajid.dev. It will also create the domain aliases that begin with www so the 4 domain aliases created will be

  • www.abc.haseebmajid.dev
  • abc.haseebmajid.dev
  • www.xyz.haseebmajid.dev
  • xyz.haseebmajid.dev

Args

netlify_subdomain_manager --help
Usage: src [options]

Options:
  --version                  Show version number                       [boolean]
  -a, --accessToken          The Netlify access token to use the Netlify API.
                                                                      [required]
  -f, --subdomainFile        Path to JSON file, which contains the subdomain the
                             netlify site should have.
                                                  [default: "./subdomains.json"]
  -m, --mainDomain           The main domain you want to create subdomain
                             within.                                  [required]
  -s, --siteId               The site Id to add the subdomain to on Netlify.
                                                                      [required]
  -h, --help                 Show help                                 [boolean]

Docker

You can run the Docker container locally like so.

touch .env
docker run -rm -v ${PWD}/subdomains.json:/app/subdomains.json --env-file .env hmajid2301/netlify-subdomain-manager

or you can build it locally

npm run build
docker build -t netlify-subdomain-manager .
docker run -v ${PWD}/subdomains.json:/app/subdomain.json --env-file .env netlify-subdomain-manager

Where .env is like:

NETLIFY_ACCESS_TOKEN=xxxx
NETLIFY_SUBDOMAIN_FILE=/app/subdomain.json
NETLIFY_MAIN_DOMAIN=haseebmajid.dev
NETLIFY_SITE_ID=xxxxx

Site ID

You can find the site id in the "Site Information".

  • Go to Netlify
  • Click on your website
  • Click on "Settings"
  • Copy "API ID" from within the "Site Information" panel

Access Token

You can create an access token like so:

  • Go to Netlify
  • Click on your avatar
  • Click on "User Settings"
  • Click on "Applications" (left panel)
  • Click on "New access token" in "Personal access tokens"

Give the access token an appropriate name and copy it somewhere safe.

.gitlab-ci.yml

You can also use it during CI/CD.

edit-domains:netlify:
  stage: post-publish
  image:
    name: hmajid2301/netlify-subdomain-manager
    entrypoint: [""]
  variables:
    NETLIFY_ACCESS_TOKEN: ${ACCESS_TOKEN}
    NETLIFY_SUBDOMAIN_FILE: subdomain.json
    NETLIFY_MAIN_DOMAIN: haseebmajid.dev
    NETLIFY_SITE_ID: ${SITE_ID}
  script:
    - node /app/index.js

Build Locally

You can run the script locally like so.

npm install
touch .env
source .env
npm run start