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

@pzwik/nx-gcloud-functions-plugin

v0.0.6

Published

Downloads

18

Readme

nx-gcloud-functions-plugin

This library was being developed to support the deployment of Google Cloud Functions via one simple command while working with the Nx Monorepo.

Prerequisites

  • GCP account
  • Enabled at least following technologies/APIs on GCP: Deployment Manager, Cloud Functions, Storage
  • gcloud SDK installed
  • Make sure to have run gcloud auth login to be able to run the gcloud commands from your CLI
  • Nx Monorepo workspace

How to install the plugin

npm install -D @pzwik/nx-gcloud-function-deployment-plugin

Run installed plugin in workspace to create new cloud function app

nx generate @pzwik/nx-gcloud-functions-plugin:nxGcloudFunctionsPlugin YOUR_FUNC_NAME

How to use

Possible folder structure after you build you app:

.
├── dist
|   ├── apps
|   |   ├── myfunction
|   |   |   ├── configurable_functions.jinja
|   |   |   ├── deployment.yaml
|   |   |   ├── index.js
|   |   |   └── package.json

Snippet of workspace.json from your Nx workspace with example configuration for the above folder structure.

{
    "myfunction": {
        "root": "apps/myfunction",
        "sourceRoot": "apps/myfunction/src",
        "projectType": "application",
        "prefix": "myfunction",
        "schematics": {},
        "architect": {
            "deploy": {
                "builder": "@pzwik/nx-gcloud-function-deployment-plugin:build",
                "options": {
                    "files": ["dist/apps/myfunction/index.js", "dist/apps/myfunction/package.json"],
                    "deploymentYamlPath": "dist/apps/myfunction/deployment.yaml",
                    "bucketName": "myfunction-bucket",
                    "deploymentName": "myfunction-deployment"
                }
            }
        }
    }
}

An example .jinja file which is imported by the deployment.yaml, of course you can also do it without the .jinja and use only the deployment.yaml file:

### configurable_functions.jinja ###
resources:
- type: gcp-types/cloudfunctions-v1:projects.locations.functions
  name: {{ env['deployment'] }}-function
  properties:
    parent: projects/{{ env['project'] }}/locations/{{ properties['region'] }}
    function: {{ env['deployment'] }}
    sourceArchiveUrl: gs://{{ properties['codeBucket'] }}/{{ properties['codeBucketObject'] }}
    entryPoint: {{ properties['entryPoint'] }}
    runtime: {{ properties['runtime'] }}
    availableMemoryMb: {{ properties['availableMemoryMb'] }}
    timeout: {{ properties['timeout'] }}
    httpsTrigger: {}

The deployment.yaml file that describes the cloud function which should be deployed via the Google Deployment Manager:

### deployment.yaml ###
imports:
  - path: configurable_functions.jinja
resources:
  - name: myfunction
    type: configurable_functions.jinja
    properties:
      codeBucket: myfunction-bucket
      codeBucketObject: WILL_BE_OVERWRITTEN_ANYWAY.zip
      region: europe-west1
      entryPoint: handler
      runtime: nodejs8
      availableMemoryMb: 256
      timeout: 60s

Donate

If you like the plugin feel free to donate some $$$ for coffee :-) NX GCloud Function Plugin MoneyPool