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

@povio/spa-deploy-cli

v4.2.0

Published

Use this tool to deploy and configure an SPA.

Downloads

266

Readme

SPA Deploy CLI

Use this tool to deploy and configure an SPA.

Features:

Static SPA deploy:

  • Deploy to AWS S3
  • Targeted CloudFront invalidation and caching
  • Embed environment variables into HTML

Next.js Configuration:

  • From SSM Parameter Store

Examples:

Setup

Running without installing. Make sure to lock the version, check the latest version on npm.

yarn dlx @povio/[email protected]

If using yarn cache, you can install the package:

yarn add @povio/spa-deploy-cli

Configure

accountId: "000000000000"
region: us-east-1

# Static SPA deploy config
deploy:
    buildPath: "./dist"
    #includeGlob: "**"
    #ignoreGlob:
        
    s3:
        acl: "public-read"
        bucket: myapp-dev-website
        #prefix:
        purge: false
        force: false
        # extra glob for invalidation
        #invalidateGlob: 
        # ignore s3 changes for invalidation
        #skipChangesInvalidation: false
          
        cacheControl: "max-age=2628000, public"
        
        # pattern match cache control, first match wins, default is cacheControl
        #cacheControlGlob:
        # - glob: "*.html"
        #   cacheControl: "no-cache, no-store, must-revalidate"
          
    cloudfront:
        distributionId: CF000000000000
        invalidatePaths: "/*"

# Environment file config
configs:
    # Write into env file (Next.js)
    #  destination: ./.env.local
    
    # Write into yaml
    #  destination: ./production.yaml
    
    # Write into .html, in the head section or <script id="env-data"></script>
    # Warning: all values will be public
    #  destination: ./dist/index.html

    
    values:
        # load config from ./.config/${stage}.base.template.env
        # and interpolate ${arn:aws:ssm..} and ${env:ENV_VALUE} values
        # load them onto the root
      - name: "@"
        configFrom: base.template
    
        # simple value mapping
      - name: database__password
        valueFrom: arn:aws:ssm:::parameter/myapp-dev/database/password
    
        # JSON object mapping
      - name: database
        valueFrom: arn:aws:ssm:::parameter/myapp-dev/database
    
      - name: database__host
        valueFrom: env:DATABASE_HOST

Example

Where configFrom: base.template and the config file is .config/${stage}.base.template.yml:

APP_RELEASE: ${func:release}
APP_STAGE: ${func:stage}
APP_VERSION: ${env:APP_VERSION}
STATIC_URL: https://static.example.com
NEXT_PUBLIC_SENTRY_CDN: https://[email protected]/1

the output will be at the set destination, for example .env.local:

APP_RELEASE=61be6e2c61be6e2c61be6e2c61be6e2c
APP_STAGE=myapp-stg
APP_VERSION=0.0.1
STATIC_URL: https://static.example.com
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/1

Injecting the environment

yarn spa-deploy bootstrap --stage myapp-stg

Pure SPA or after build time configuration

Using the destination: ./dist/index.html option, you can inject the environment into the HTML file.

The file will be edited in place, with the following content inserted into the <head> section, replacing any existing <script id="env-data">:

<script id="env-data">
  // you can add local testing variables here,
  // this will get overwritten at build
  window.APP_STAGE = "myapp-stg";
</script>

Static SPA Deploy

yarn spa-deploy deploy --stage myapp-stg

Development

Test locally

# prerequisites
corepack install
yarn

# run tests
yarn test

# run sources with tsx
yarn start --help
yarn start bootstrap --pwd ./test --stage myapp-dev

# build new version
yarn build

# test build
yarn start:prod --help
yarn start:dist bootstrap --pwd ./test --stage myapp-dev

# test deploy
yarn start:dist deploy --pwd ./test --stage myapp-dev