├── .dockerignore ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── LICENSE ├── README.md ├── assets ├── check ├── in └── out └── hooks └── build /.dockerignore: -------------------------------------------------------------------------------- 1 | examples 2 | images 3 | .gitignore 4 | LICENSE 5 | README.md -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at ymedlop@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mhart/alpine-node:latest 2 | 3 | # Build-time metadata as defined at http://label-schema.org 4 | ARG BUILD_DATE 5 | ARG VCS_REF 6 | ARG VERSION 7 | ARG GIT_RESOURCE_VERSION="1.10.0" 8 | 9 | LABEL org.label-schema.build-date=$BUILD_DATE \ 10 | org.label-schema.name="npm-cache-resource" \ 11 | org.label-schema.description="a Concourse resource for caching dependencies downloaded by NPM - built on mhart/alpine-node." \ 12 | org.label-schema.url="https://ymedlop.github.io/npm-cache-resource" \ 13 | org.label-schema.vcs-ref=$VCS_REF \ 14 | org.label-schema.vcs-url="https://github.com/ymedlop/npm-cache-resource" \ 15 | org.label-schema.vendor="ymedlop" \ 16 | org.label-schema.version=$VERSION \ 17 | org.label-schema.schema-version="1.0" \ 18 | org.label-schema.license="MIT" 19 | 20 | RUN apk add --update \ 21 | openssl \ 22 | sed \ 23 | ca-certificates \ 24 | bash \ 25 | openssh \ 26 | make \ 27 | git \ 28 | jq \ 29 | libstdc++ \ 30 | libpng-dev \ 31 | nasm \ 32 | build-base \ 33 | python2 \ 34 | python2-dev \ 35 | # Fix problem with some dependencies: https://github.com/ymedlop/npm-cache-resource/issues/39 36 | libtool \ 37 | automake \ 38 | autoconf \ 39 | nasm \ 40 | && rm -rf /var/cache/apk/* 41 | 42 | # according to Brian Clements, can't `git pull` unless we set these 43 | RUN git config --global user.email "git@localhost" && \ 44 | git config --global user.name "git" 45 | 46 | # install git resource (and disable LFS, which we happen not to need) 47 | RUN mkdir -p /opt/resource/git && \ 48 | wget https://github.com/concourse/git-resource/archive/v${GIT_RESOURCE_VERSION}.zip -O /opt/resource/git/git-resource.zip && \ 49 | unzip /opt/resource/git/git-resource.zip -d /opt/resource/git && \ 50 | ls /opt/resource/git/git-resource-${GIT_RESOURCE_VERSION}/assets && \ 51 | mv /opt/resource/git/git-resource-${GIT_RESOURCE_VERSION}/assets/* /opt/resource/git && \ 52 | rm -r /opt/resource/git/git-resource.zip /opt/resource/git/git-resource-${GIT_RESOURCE_VERSION} && \ 53 | sed -i '/git lfs/s/^/echo /' /opt/resource/git/in 54 | 55 | # install npm cache resource 56 | ADD assets/ /opt/resource/ 57 | RUN mkdir /var/cache/git 58 | 59 | RUN chmod +x /opt/resource/check /opt/resource/in /opt/resource/out 60 | 61 | # install npm-clip-login to help us with the npm login 62 | RUN npm install -g npm-cli-login bower 63 | 64 | HEALTHCHECK NONE 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://images.microbadger.com/badges/version/ymedlop/npm-cache-resource.svg)](https://microbadger.com/images/ymedlop/npm-cache-resource "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/ymedlop/npm-cache-resource.svg)](https://microbadger.com/images/ymedlop/npm-cache-resource "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/commit/ymedlop/npm-cache-resource.svg)](https://microbadger.com/images/ymedlop/npm-cache-resource "Get your own commit badge on microbadger.com") [![](https://images.microbadger.com/badges/license/ymedlop/npm-cache-resource.svg)](https://microbadger.com/images/ymedlop/npm-cache-resource "Get your own license badge on microbadger.com") 2 | [![](https://img.shields.io/docker/pulls/ymedlop/npm-cache-resource.svg)](https://img.shields.io/docker/pulls/ymedlop/npm-cache-resource.svg) 3 | 4 | This project has not been built nor maintained since December 2020 and has been archived 5 | 6 | If you are interested in working on the project, even when archived you can still create a fork of it. 7 | 8 | npm-cache-resource 9 | ================== 10 | 11 | a Concourse resource for caching dependencies downloaded by NPM - built on [mhart/alpine-node](https://hub.docker.com/r/mhart/alpine-node) and [git-resource](https://github.com/concourse/git-resource). 12 | 13 | [![EXAMPLE PIPELINE](https://raw.githubusercontent.com/ymedlop-sandbox/npm-cache-resource/gh-pages/images/example-pipeline.png)](https://raw.githubusercontent.com/ymedlop-sandbox/npm-cache-resource/gh-pages/images/example-pipeline.png) 14 | 15 | Versions 16 | -------- 17 | 18 | | Tag | From | Bower | Yarn | Maintained | 19 | |---|---|---|---|---| 20 | | [latest](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/master/Dockerfile) | [mhart/alpine-node:latest](https://github.com/mhart/alpine-node) | Yes | Yes | Yes | 21 | | [15](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v15/Dockerfile) | [mhart/alpine-node:15](https://github.com/mhart/alpine-node) | Yes | Yes | Yes | 22 | | [14](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v14/Dockerfile) | [mhart/alpine-node:14](https://github.com/mhart/alpine-node) | Yes | Yes | Yes | 23 | | [12](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v12/Dockerfile) | [mhart/alpine-node:12](https://github.com/mhart/alpine-node) | Yes | Yes | Yes | 24 | | [10](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v10/Dockerfile) | [mhart/alpine-node:10](https://github.com/mhart/alpine-node) | Yes | Yes | Yes | 25 | | [9](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v9/Dockerfile) | [mhart/alpine-node:9](https://github.com/mhart/alpine-node) | No | Yes | No | 26 | | [8](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v8/Dockerfile) | [mhart/alpine-node:8](https://github.com/mhart/alpine-node) | No | Yes | No | 27 | | [7](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v7/Dockerfile) | [mhart/alpine-node:7](https://github.com/mhart/alpine-node) | No | No | No | 28 | | [6](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v6/Dockerfile) | [mhart/alpine-node:6](https://github.com/mhart/alpine-node) | No | No | No | 29 | | [4](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v4/Dockerfile) | [mhart/alpine-node:4](https://github.com/mhart/alpine-node) | No | No | No | 30 | | [0.12](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v0.12/Dockerfile) | [mhart/alpine-node:0.12](https://github.com/mhart/alpine-node) | No | No | No | 31 | | [0.10](https://github.com/ymedlop-sandbox/npm-cache-resource/blob/alpine-node-v0.10/Dockerfile) | [mhart/alpine-node:0.10](https://github.com/mhart/alpine-node) | No | No | No | 32 | 33 | Resource Configuration 34 | ---------------------- 35 | 36 | ``` 37 | resource_types: 38 | 39 | - name: npm-cache 40 | type: docker-image 41 | source: {repository: ymedlop/npm-cache-resource, tag: "12"} 42 | ``` 43 | 44 | 45 | Source Configuration 46 | -------------------- 47 | 48 | * `<<:`: *Required.* The source is the same as the corresponding git resource 49 | 50 | ### Configuration to access a Git Private Repo 51 | 52 | #### SSH: 53 | 54 | * `private_key`: *Required.* Private key. 55 | 56 | #### HTTP(S): 57 | 58 | * `username_key`: *Required.* Username for HTTP(S) auth. This is needed when only HTTP/HTTPS protocol for git is available (which does not support private key auth) and auth is required. 59 | * `password_key`: *Required.* Password for HTTP(S) auth. 60 | * `skip_ssl_verification`: *Optional.* Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true. 61 | 62 | ### Configuration to access a NPM Registry or Private Registry by User and Password. 63 | 64 | * `registry-url`: *Optional.* Private NPM registry to log in to (Default: https://registry.npmjs.org) 65 | * `registry-user`: *Required.* Registry Username. 66 | * `registry-pass`: *Required.* Registry User Password. 67 | * `registry-email`: *Required.* Registry User Email. 68 | * `registry-scope`: *Optional.* Registry Scope. 69 | 70 | ### Configuration to access a Private Registry by Base64 Token 71 | 72 | * `registry`: *Required.* The location our private npm registry. 73 | * `token`: *Required.* Our npm token. 74 | 75 | # Node.js Environment variables 76 | * `node-env`: Set NODE_ENV. (Default: development) 77 | 78 | ### Configuration for projects living in subdirectories 79 | * `project-path`: *Optional* Relative path of subdirectory containing the project (i.e. where the `package.json` is). 80 | 81 | ### Configuration use for npm 82 | * `npm-args`: *Optional* Allow to add extra args to npm i / npm ci command. (Default: "-q") 83 | 84 | ### Configuration use npm ci command 85 | * `npm-ci-support`: *Optional* Allow to use npm ci instead of npm install to install the npm modules into our resource. (Default: false) 86 | 87 | ### Configuration use yarn cli 88 | * `yarn-support`: *Optional* Allow to use yarn to install the npm modules into our resource. (Default: false) 89 | * `yarn-args`: *Optional* Allow to add extra args to yarn install command. (Default: "") 90 | 91 | ### Configuration use bower cli 92 | * `bower-support`: *Optional* Allow to use bower to install packages into our resource (Bower dependency has to be in our package.json). (Default: false) 93 | * `bower-args`: *Optional* Allow to add extra args to bower install command. (Default: "-q --allow-root") 94 | 95 | ``` 96 | Whatever tool you use to generate the encoded username and password string, try to encode the string admin:admin123, which should result in YWRtaW46YWRtaW4xMjM=. ` 97 | Another example for a valid setup is jane:testpassword123 resulting in amFuZTp0ZXN0cGFzc3dvcmQxMjM=. 98 | 99 | In our demo we are using admin:123456 resulting in YWRtaW46MTIzNDU2 100 | ``` 101 | 102 | ### Example 103 | 104 | ``` 105 | resources: 106 | 107 | # a perfectly normal source repository with lashings and lashings of dependencies 108 | - name: repo 109 | type: git 110 | source: &repo-source # apply a YAML anchor so we can refer to this in the cache resource 111 | uri: https://github.com/ymedlop/npm-cache-resource.git 112 | branch: npm-package-example 113 | 114 | # a resource caching the dependencies listed in the source repository 115 | - name: npm-repo-cache 116 | type: npm-cache # as defined above 117 | source: 118 | <<: *repo-source # the source is the same as the corresponding git resource ... 119 | paths: # ... except that it's only interested in files listing dependencies 120 | - package.json 121 | 122 | ``` 123 | 124 | ## Behavior 125 | 126 | ### `check`: Check for new commits 127 | 128 | The repository is cloned (or pulled if already present), and any commits from the given version on are returned. If no version is given, the ref for HEAD is returned. 129 | 130 | Any commits that contain the string [ci skip] will be ignored. This allows you to commit to your repository without triggering a new version. 131 | 132 | ### `in`: Pulls a package from npm 133 | 134 | Clones the repository to the destination, and locks it down to a given ref. It will return the same given ref as version. And fetch npm package from the package.json`. 135 | 136 | #### Examples 137 | 138 | ``` 139 | jobs: 140 | 141 | - name: cache 142 | plan: 143 | 144 | - get: repo 145 | trigger: true 146 | 147 | - get: npm-repo-cache 148 | 149 | - name: test 150 | plan: 151 | 152 | - get: repo 153 | trigger: true 154 | passed: [cache] 155 | 156 | - get: npm-repo-cache 157 | passed: [cache] 158 | 159 | - task: run tests 160 | config: 161 | 162 | platform: linux 163 | image_resource: 164 | type: docker-image 165 | source: {repository: mhart/alpine-node, tag: "12"} 166 | 167 | inputs: 168 | - name: repo 169 | path: /src 170 | - name: npm-repo-cache 171 | path: /cache 172 | 173 | run: 174 | path: sh 175 | args: 176 | - -exc 177 | - | 178 | mv cache/node_modules src 179 | cd src && npm test 180 | 181 | - name: build 182 | plan: 183 | 184 | - get: repo 185 | trigger: true 186 | passed: [cache] 187 | 188 | - get: npm-repo-cache 189 | passed: [cache] 190 | 191 | - task: run build 192 | config: 193 | 194 | platform: linux 195 | image_resource: 196 | type: docker-image 197 | source: {repository: mhart/alpine-node, tag: "12"} 198 | 199 | inputs: 200 | - name: repo 201 | path: /src 202 | - name: npm-repo-cache 203 | path: /cache 204 | 205 | run: 206 | path: sh 207 | args: 208 | - -exc 209 | - | 210 | mv cache/node_modules src 211 | cd src && npm run build 212 | ``` 213 | 214 | ### `out`: Nothing to do here.... 215 | 216 | Getting Started 217 | --------------- 218 | 219 | You can see more examples [here](https://github.com/ymedlop-sandbox/npm-cache-resource/tree/examples). 220 | 221 | Credits: 222 | ======== 223 | 224 | * [concourse git resource](https://github.com/concourse/git-resource) 225 | * [projectfalcon/gradle-cache-resource](https://github.com/projectfalcon/gradle-cache-resource) We are following this resource to create our npm cache resource. 226 | 227 | License 228 | ------- 229 | 230 | See the [LICENSE file](LICENSE) for license text and copyright information. 231 | -------------------------------------------------------------------------------- /assets/check: -------------------------------------------------------------------------------- 1 | #! /bin/bash -eu 2 | set -o pipefail 3 | 4 | # All checking is handled by the scripts from the git resource 5 | /opt/resource/git/check 6 | -------------------------------------------------------------------------------- /assets/in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | # functions from the git resource for configuring git and ssh 5 | source /opt/resource/git/common.sh 6 | 7 | DEST_DIR="$1" 8 | 9 | GIT_DEST_DIR="$(mktemp -d -t git-resource-destination.XXXXXX)" 10 | 11 | # pull the git repo from the config passed in stdin 12 | # also handles emitting the correct output for concourse 13 | /opt/resource/git/in "$GIT_DEST_DIR" 14 | 15 | # the config passed via stdin is saved to /tmp/git-resource-request.* 16 | # by the /opt/resource/git/in script. load it back into PAYLOAD 17 | # to parse it further 18 | PAYLOAD=$(echo /tmp/git-resource-request.*) 19 | 20 | # use git-resource's helper functions to configure git credentials 21 | load_pubkey $PAYLOAD 22 | configure_git_ssl_verification $PAYLOAD 23 | configure_credentials $PAYLOAD 24 | 25 | TRACE=$(jq -r '.source["trace"] // "false"' < $PAYLOAD) 26 | 27 | # Configuration to access a NPM Registry or Private Registry by User and Password. 28 | REGISTRY_URL=$(jq -r '.source["registry-url"] // ""' < $PAYLOAD) 29 | REGISTRY_USER=$(jq -r '.source["registry-user"] // ""' < $PAYLOAD) 30 | REGISTRY_PASS=$(jq -r '.source["registry-pass"] // ""' < $PAYLOAD) 31 | REGISTRY_MAIL=$(jq -r '.source["registry-email"] // ""' < $PAYLOAD) 32 | REGISTRY_SCOPE=$(jq -r '.source["registry-scope"] // ""' < $PAYLOAD) 33 | 34 | # Configuration to access a Private Registry by Base64 Token 35 | REGISTRY=$(jq -r '.source.registry // ""' < $PAYLOAD) 36 | TOKEN=$(jq -r '.source.token // ""' < $PAYLOAD) 37 | 38 | # Node.js Environment variables 39 | NODE_ENV=$(jq -r '.source["node-env"] // "development"' < $PAYLOAD) 40 | 41 | # Configuration for projects living in subdirectories 42 | PROJECT_PATH=$(jq -r '.source["project-path"] // ""' < $PAYLOAD) 43 | 44 | # Configuration use for npm and npm ci command 45 | NPM_CI_ARGS=$(jq -r '.source["npm-args"] // "-q"' < $PAYLOAD) 46 | 47 | # Configuration use npm ci command 48 | NPM_CI_SUPPORT=$(jq -r '.source["npm-ci-support"] // false' < $PAYLOAD) 49 | 50 | # Configuration use yarn cli 51 | YARN_SUPPORT=$(jq -r '.source["yarn-support"] // false' < $PAYLOAD) 52 | YARN_CI_ARGS=$(jq -r '.source["yarn-args"] // ""' < $PAYLOAD) 53 | 54 | # Configuration use bower cli 55 | BOWER_SUPPORT=$(jq -r '.source["bower-support"] // false' < $PAYLOAD) 56 | BOWER_ARGS=$(jq -r '.source["bower-args"] // "-q --allow-root"' < $PAYLOAD) 57 | 58 | # go into the cloned sorce code 59 | cd "$GIT_DEST_DIR/$PROJECT_PATH" 60 | 61 | if [ "$TRACE" == "true" ]; then 62 | set -x 63 | else 64 | set +x 65 | fi 66 | 67 | # configure proxy 68 | if [ -n "$http_proxy" ]; then 69 | npm config set proxy $http_proxy 70 | npm config set https-proxy $https_proxy 71 | fi 72 | 73 | # login to registry 74 | if [ -n "$REGISTRY_USER" ] && [ -n "$REGISTRY_PASS" ] && [ -n "$REGISTRY_MAIL" ]; then 75 | if [ -n "$REGISTRY_URL" ] && [ -n "$REGISTRY_SCOPE" ]; then 76 | npm-cli-login -u $REGISTRY_USER -p $REGISTRY_PASS -e $REGISTRY_MAIL -r $REGISTRY_URL -s $REGISTRY_SCOPE 77 | elif [ -n "$REGISTRY_URL" ]; then 78 | npm-cli-login -u $REGISTRY_USER -p $REGISTRY_PASS -e $REGISTRY_MAIL -r $REGISTRY_URL 79 | else 80 | npm-cli-login -u $REGISTRY_USER -p $REGISTRY_PASS -e $REGISTRY_MAIL 81 | fi 82 | else 83 | if [ -n "$TOKEN" ]; then 84 | echo "always-auth=true" >> ~/.npmrc 85 | echo "_auth="$TOKEN"" >> ~/.npmrc 86 | fi 87 | if [ -n "$REGISTRY" ]; then 88 | npm config set registry $REGISTRY 89 | fi 90 | fi 91 | 92 | # use yarn, npm ci, npm install or bower to pull down packages 93 | if [ "$YARN_SUPPORT" != "false" ]; then 94 | NODE_ENV=$NODE_ENV && yarn install $YARN_CI_ARGS >&2 95 | elif [ "$NPM_CI_SUPPORT" != "false" ]; then 96 | NODE_ENV=$NODE_ENV && npm ci $NPM_CI_ARGS >&2 97 | else 98 | NODE_ENV=$NODE_ENV && npm i $NPM_CI_ARGS >&2 99 | fi 100 | 101 | if [ "$BOWER_SUPPORT" != "false" ]; then 102 | bower install $BOWER_ARGS 103 | mv bower_components "$DEST_DIR/" 104 | fi 105 | 106 | # only export the node_modules folder 107 | # the fetched version is already emitted by the git in script called at the beginning 108 | mv node_modules "$DEST_DIR/" 109 | -------------------------------------------------------------------------------- /assets/out: -------------------------------------------------------------------------------- 1 | #! /bin/bash -eu 2 | set -o pipefail 3 | 4 | # do nothing. The resource does not push any data 5 | # but makes use of concourses internal caching to 6 | # make the node_modules available over multiple 7 | # jobs in a pipeline. If the cache is lost it just 8 | # builds node_modules again in the `in` script 9 | -------------------------------------------------------------------------------- /hooks/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $IMAGE_NAME var is injected into the build so the tag is correct. 4 | 5 | echo "Build hook running" 6 | docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 7 | --build-arg VCS_REF=`git rev-parse --short HEAD` \ 8 | -t $IMAGE_NAME . --------------------------------------------------------------------------------