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

cicd-spa-website

v0.1.2

Published

A CDK construct which creates a pipeline that pulls code from a source repository, builds it, then deploys to an S3 bucket (with CloudFront if a certificate is required)

Downloads

1

Readme

SPA + CICD Website Construct

This CDK construct is used to create a static website with a CodePipeline to deploy from source code on pushes to master. The goal of this construct is to be able to point it at a git repository, give it a url, and you've got a continuously deployed static website.

This is a pre-release!

This is a quick first-draft. All the options that will likely need to be added to accomodate a large number of use-cases are still needed. If you'd like to make requests or help update this construct, please open an Issue or a PR.

What Gets Created

At the base level, the following will be built:

  • An S3 bucket for build artifacts
  • An S3 bucket for the website content
  • CICD Pipeline - CodePipeline sourced from Github, built using CodeBuild and deployed to an S3 bucket.

If a certificate is supplied or requested:

  • An ACM certificate will be provisioned via DNS if requested
  • A CloudFront Distribution pointing to the S3 bucket.

Example

This will create the website, the deployment pipeline, and add a generated certificate (and CloudFront) for HTTPS support.

new CicdSpaWebsite(stack, 'public-site', {
    url: 'www.matthewbonig.com',
    githubSource: {
        owner: 'mbonig',
        repo: 'public_site',
        oauthToken: SecretValue.secretsManager('github-oauth-token')
    },
    hostedZone: {
        hostedZoneId: 'ABCDEFGHIJKLM',
        zoneName: 'matthewbonig.com'
    },
    certificate: true
});

Input Properties

|property|description|example |---|---|--- |url|The url you'd like your website to be available at. Must be full url and must be controlled by the given HostedZone| www.matthewbonig.com |githubSource.owner|The Github repository's owner | mbonig |githubSource.repo|The GH repo name | public_site |githubSource.branch|An optional branch name. Defaults to 'master'| qa |githubSource.oauthToken|An ISecret pointing to an oauthToken. | SecretValue.secretsManager('github-oauth-token') |hostedZone|(Optional) - If provided, used to create DNS Records. |hostedZone.hostedZoneId|The hostedZone ID for the 'url's domain | ABCDEFGHI |hostedZone.zoneName|The hostedZone's name | matthewbonig.com |certificate|(Optional) - If provided, creates a CloudFront Distribution with the given certificate. If 'true' is provided, then a certificate will be generated.| true |buildSpec|(Optional) - If provided, will override the default BuildSpec in the CodeBuild project. Accepts either a string value (the filename in the source code) or an object. The object is passed to the BuildSpec.fromObject(). If not provided, see BuildSpec.|build-prod.yaml

Design Notes

Certificates

If a certificate is required to provide HTTPS support then a simple S3 Bucket with website hosting will not work. This construct chooses to put a CloudFront Distribution in front of it when a certificate is required.

If that certificate already exists, it can be supplied as an ICertificate. If not, then it will be created using a DNSValidatedCertificate.

If no certificate is supplied or requested, then the site will be hosted using a public S3 Bucket with Website Hosting enabled. No CloudFront Distribution will be created in that case.

Github Sources

Github source information is provided through props for the construct.

If you'd like to see support for another type of Source action, please open an Issue or a PR.

BuildSpec

The default buildspec is defined at DEFAULT_BUILD_SPEC. It uses a Node v12 runtime, runs an npm install and then an npm run build and assumes the static deliverables are in the dist directory.

You may override the BuildSpec with either your own object or by passing a string which will be interpreted as a filename within the source to use.

Contributing

Please open Pull Requests and Issues on the Github Repo.

License

MIT