# @povio/spa-deploy-cli

> Use this tool to deploy and configure an SPA.

Latest version **4.2.2** (published 2025-06-30) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @povio/spa-deploy-cli
pnpm add @povio/spa-deploy-cli
yarn add @povio/spa-deploy-cli
bun add @povio/spa-deploy-cli
```

Provides the command `spa-deploy`.

## Health

**Score 40/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.2.2 |
| Published | 2025-06-30 |
| First published | 2022-10-21 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM |
| Node | >= 14 |
| Dependencies | 0 |
| Unpacked size | 5.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Marko Zabreznik |
| Maintainers | marzab |
| Keywords | povio, spa, deploy, aws, s3, cloudfront, aws-amplify, next-js |

## Links

- npm: https://www.npmjs.com/package/@povio/spa-deploy-cli
- Repository: https://github.com/povio/spa-deploy-cli
- Issues: https://github.com/povio/spa-deploy-cli/issues
- npm.io page: https://npm.io/package/@povio/spa-deploy-cli

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.2.2 (latest) — 2025-06-30
- 5.0.0-beta.7 (beta) — 2026-08-18
- 5.0.0-beta.6 — 2025-12-15
- 5.0.0-beta.5 — 2025-12-15
- 5.0.0-beta.4 — 2025-12-15
- 5.0.0-beta.3 — 2025-12-15
- 5.0.0-beta.2 — 2025-12-02
- 5.0.0-beta.1 — 2025-12-02
- 5.0.0-beta.0 — 2025-12-02
- 4.2.1 — 2025-06-30
- 4.2.0 — 2024-11-01
- 4.1.0 — 2024-05-19
- 3.0.5 — 2022-10-27
- 2.1.2 — 2022-10-21
- 3.0.4 — 2022-10-21
- … 1 more at https://npm.io/package/@povio/spa-deploy-cli/versions

## 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:

- [Vue Basic](./examples/vue-basic)

# Setup

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

```
yarn dlx @povio/spa-deploy-cli@4.2
```

If using yarn cache, you can install the package:

```bash
yarn add @povio/spa-deploy-cli
```

# Configure

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

# Static SPA deploy config
deploy:
    buildPath: "./dist"
      
    # only include local files matching this glob
    #includeGlob: 
    # - glob: "**.css"
    #   cacheControl: "max-age=2628000, public"
      
    # exclude local and remote files matching this glob
    #ignoreGlob: "**.css"
        
    s3:
        bucket: myapp-dev-website
        
        # prefix to upload to, default is root
        #prefix:
        
        # delete all ignored/unknown files
        #  use `--dry-run` to see what would be deleted
        #purge: false
        
        # re-upload even if the file is the same (also updates cacheControl)
        #force: false

        # changes should not invalidate cloudfront cache
        #skipChangesInvalidation: false
        
        # default cache control
        #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"
        
        # @deprecated - set matching files to "public, must-revalidate"
        #invalidateGlob: "*.html"
        
        # set ACL, not needed if using bucket policy
        #acl: "public-read"
          
    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`:

```yaml
APP_RELEASE: ${func:release}
APP_STAGE: ${func:stage}
APP_VERSION: ${env:APP_VERSION}
STATIC_URL: https://static.example.com
NEXT_PUBLIC_SENTRY_CDN: https://public@sentry.example.com/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://public@sentry.example.com/1
```

## Injecting the environment

```bash
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">`:

```html
<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

```bash
yarn spa-deploy deploy --stage myapp-stg
```

# Development

## Test locally

```bash
# 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

```

---
_Source: https://npm.io/package/@povio/spa-deploy-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
