@financial-times/n-myft-ui 33.1.0 → 34.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/.circleci/config.yml +109 -179
  2. package/.pa11yci.js +1 -0
  3. package/.toolkitrc.yml +32 -0
  4. package/.toolkitstate/ci.json +6 -0
  5. package/README.md +29 -4
  6. package/components/jsx/preferences-modal/index.js +0 -14
  7. package/components/unread-articles-indicator/initialise-feed-start-time.js +1 -1
  8. package/karma.conf.js +4 -1
  9. package/package.json +24 -9
  10. package/scripts/build-demo.sh +53 -0
  11. package/scripts/deploy-gh-pages.sh +5 -2
  12. package/scripts/make-static-demo.sh +6 -2
  13. package/scripts/transpile-jsx.sh +3 -0
  14. package/toolkit/demoScripts/.toolkitrc.yml +0 -0
  15. package/toolkit/demoScripts/index.js +77 -0
  16. package/toolkit/karma/.toolkitrc.yml +0 -0
  17. package/toolkit/karma/index.js +16 -0
  18. package/.circleci/shared-helpers/.github/settings.yml +0 -1
  19. package/.circleci/shared-helpers/CODEOWNERS +0 -3
  20. package/.circleci/shared-helpers/Makefile +0 -5
  21. package/.circleci/shared-helpers/README.md +0 -72
  22. package/.circleci/shared-helpers/helper-check-service-ready +0 -37
  23. package/.circleci/shared-helpers/helper-configure-awscli +0 -20
  24. package/.circleci/shared-helpers/helper-generate-build-state-artifacts +0 -29
  25. package/.circleci/shared-helpers/helper-install-awscli +0 -14
  26. package/.circleci/shared-helpers/helper-install-puppeteer-deps +0 -25
  27. package/.circleci/shared-helpers/helper-npm-install-peer-deps +0 -40
  28. package/.circleci/shared-helpers/helper-npm-store-auth-token +0 -14
  29. package/.circleci/shared-helpers/helper-npm-update +0 -26
  30. package/.circleci/shared-helpers/helper-npm-version-and-publish-public +0 -19
  31. package/.circleci/shared-helpers/helper-publish-github-pages +0 -43
  32. package/.circleci/shared-helpers/helper-setup-heroku-cli +0 -46
  33. package/.circleci/shared-helpers/helper-setup-s3-upload +0 -17
  34. package/.circleci/shared-helpers/helper-upload-assets-to-s3 +0 -69
  35. package/.circleci/shared-helpers/helper.example +0 -13
  36. package/.circleci/shared-helpers/secret-squirrel.js +0 -25
  37. package/Makefile +0 -48
  38. package/build-state/npm-shrinkwrap.json +0 -52417
@@ -0,0 +1,77 @@
1
+ const { Task, Hook } = require('@dotcom-tool-kit/types');
2
+ const { spawn } = require('child_process');
3
+ const { hookFork, waitOnExit } = require('@dotcom-tool-kit/logger');
4
+
5
+ class ShExcutor extends Task {
6
+ async executeCommand (command, scriptPath, args = []) {
7
+ if (!command) {
8
+ throw new Error('Invalid command');
9
+ }
10
+
11
+ this.logger.info(`running sh script: ${command}`);
12
+ const deployChild = spawn(scriptPath, args, { shell: true });
13
+ hookFork(this.logger, command, deployChild);
14
+ return waitOnExit(command, deployChild);
15
+ }
16
+ }
17
+
18
+ class DemoBuilder extends ShExcutor {
19
+ async run () {
20
+ let command = process.argv[4];
21
+ if (!['demo-build', 'demo', 'static-demo'].includes(command)) {
22
+ command = 'demo-build';
23
+ }
24
+
25
+ return this.executeCommand(`build-demo: ${command}`, 'scripts/build-demo.sh', [command]);
26
+ }
27
+ }
28
+
29
+ class TranspileJsx extends ShExcutor {
30
+ async run () {
31
+ return this.executeCommand('transpile-jsx', 'scripts/transpile-jsx.sh');
32
+ }
33
+ }
34
+
35
+ class RunPa11yCi extends Task {
36
+ async run () {
37
+ let serverProcess;
38
+
39
+ const serverStartedPromise = new Promise((resolve, reject) => {
40
+ serverProcess = spawn('node', ['demos/app.js']);
41
+ hookFork(this.logger, 'server', serverProcess);
42
+
43
+ serverProcess.stdout.on('data', data => {
44
+ const message = data.toString();
45
+ if (message.includes('event: "EXPRESS_START"')) {
46
+ this.logger.info('Server started successfully.');
47
+ resolve();
48
+ }
49
+ });
50
+
51
+ serverProcess.on('error', error => {
52
+ reject(error);
53
+ });
54
+ });
55
+
56
+ await serverStartedPromise;
57
+
58
+ const pa11yProcess = spawn('pa11y-ci', ['--config', '.pa11yci.js']);
59
+ hookFork(this.logger, 'pa11y', pa11yProcess);
60
+
61
+ await waitOnExit('pa11y', pa11yProcess);
62
+
63
+ serverProcess.kill('SIGINT');
64
+ this.logger.info('Server and related processes stopped.');
65
+ }
66
+ }
67
+ class buildDemo extends Hook {
68
+ async check () {
69
+ return true;
70
+ }
71
+ }
72
+
73
+ exports.hooks = {
74
+ 'build:demo': buildDemo,
75
+ };
76
+
77
+ exports.tasks = [ DemoBuilder, TranspileJsx, RunPa11yCi ];
File without changes
@@ -0,0 +1,16 @@
1
+ const { Task } = require('@dotcom-tool-kit/types');
2
+ const { spawn } = require('child_process');
3
+ const { hookFork, waitOnExit } = require('@dotcom-tool-kit/logger');
4
+ const karmaCLIPath = require.resolve('karma/bin/karma');
5
+
6
+ class Karma extends Task {
7
+ async run () {
8
+ const args = ['start', 'karma.conf.js'];
9
+ this.logger.info(`running karma ${args.join(' ')}`);
10
+ const child = spawn(karmaCLIPath, args);
11
+ hookFork(this.logger, 'karma', child);
12
+ return waitOnExit('karma', child);
13
+ }
14
+ }
15
+
16
+ exports.tasks = [ Karma ];
@@ -1 +0,0 @@
1
- _extends: github-apps-config-next
@@ -1,3 +0,0 @@
1
- # See https://help.github.com/articles/about-codeowners/ for more information about this file.
2
-
3
- * @financial-times/platforms
@@ -1,5 +0,0 @@
1
- install:
2
- @echo '#!/bin/sh\n\nnpx --package @financial-times/secret-squirrel@^2.9.0 secret-squirrel' > .git/hooks/pre-commit;
3
- @echo '#!/bin/sh\n\nnpx --package @financial-times/secret-squirrel@^2.9.0 secret-squirrel-commitmsg' > .git/hooks/commit-msg;
4
- @chmod +x .git/hooks/pre-commit .git/hooks/commit-msg;
5
- @echo "Installed pre-commit and commit-msg .git/hooks for @financial-times/secret-squirrel";
@@ -1,72 +0,0 @@
1
- # Next CI Helper Scripts [![CircleCI](https://circleci.com/gh/Financial-Times/next-ci-shared-helpers.svg?style=svg&circle-token=33bcf2eb98fe2e875cc66de93d7e4a50369c952d)](https://github.com/Financial-Times/next-ci-shared-helpers)
2
-
3
- This repo contains a set of common bash scripts to be used in the delivery pipeline.
4
-
5
-
6
- ## Installation
7
-
8
- ```sh
9
- git clone git@github.com:Financial-Times/next-ci-shared-helpers.git
10
- cd next-ci-shared-helpers
11
- ```
12
-
13
-
14
- ## Development
15
-
16
- ### Working locally
17
-
18
- Many of the scripts require a Unix environment so in order to run existing scripts you'll need to be familiar with [Docker](https://www.docker.com/get-started).
19
-
20
- The first step is to [install docker](https://www.docker.com/get-started) and once you're up and running you'll be able to run the scripts locally inside a Docker container.
21
-
22
- For example, the following command will run the `helper-install-awscli` script inside the container (this will output many logs but if it has worked correctly the last line on the console should read `Setting up awscli (1.11.13-1) ...`.
23
-
24
- ```shell
25
- docker run --rm -it -w /tmp --mount type=bind,source="$(pwd)",destination=/tmp circleci/node:12.18-browsers ./helper-install-awscli
26
- ```
27
-
28
- The command in the example can be largely re-used by simply changing the Docker image and script to run:
29
-
30
- ```shell
31
- docker run --rm -it -w /tmp --mount type=bind,source="$(pwd)",destination=/tmp DOCKER_IMAGE_NAME ./SCRIPT_TO_RUN
32
- ```
33
-
34
-
35
- ### Usage
36
-
37
- To make use of this package in your CircleCI deployment pipeline, firstly create a new `step` and clone the package:
38
-
39
- ```yaml
40
- - run:
41
- name: Checkout next-ci-shared-helpers
42
- command: git clone --depth 1 git@github.com:Financial-Times/next-ci-shared-helpers.git .circleci/shared-helpers
43
- ```
44
-
45
- _The convention across all FT repos is to put the helpers inside the `.circleci/shared-helpers` folder._
46
-
47
- Then add another step after it to run one of the scripts:
48
-
49
- ```yaml
50
- - run:
51
- name: shared-helper / npm-install-peer-deps
52
- command: .circleci/shared-helpers/helper-npm-install-peer-deps
53
- ```
54
-
55
- _The convention across all FT repos is to name the step as follows: `shared-helper / NAME_OF_SCRIPT`._
56
-
57
- ### General guidelines for helper scripts
58
-
59
- - Copy `helper.example` as a starting point
60
- - Avoid being "clever" - developers shouldn't require knowledge of obscure bash syntax to understand the helper scripts that you write
61
- - Comment liberally - help others (and your future self) understand *why* the helper script is doing the things it's doing
62
- - Include links to any relevant documentation in your comments
63
- - Try and avoid noisy output - it's hard to debug CI builds or understand what has happened if there are lots of unnecessary messages in the shell output
64
- - Echo out useful messages about progress and actions taken by the script - the flip side of avoiding noisy output: humans want to know what's happening/happened with their build
65
- - Remember to make your script executable by running the command `chmod +x ./<NAME_OF_SCRIPT>`
66
-
67
- ### Naming guidelines
68
-
69
- The filename of a helper script should give a clear indication of what it does:
70
-
71
- - ❌ `helper-test`
72
- - ✅ `helper-run-mocha-tests`
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Checks availability of service containers
6
-
7
- # Set error handling
8
- set -eu -o pipefail
9
-
10
- DOCKERIZE_VERSION=v0.3.0
11
-
12
- if hash wget 2>/dev/null; then
13
- wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz;
14
- elif hash curl 2>/dev/null; then
15
- curl -XGET -L https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz --output dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz;
16
- else
17
- echo 'wget or curl are required to run helper-check-service-ready'
18
- exit 1
19
- fi
20
- mkdir -p ~/tmp
21
- tar -C ~/tmp -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
22
- rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
23
-
24
- for var in "$@"
25
- do
26
- case $var in
27
- redis)
28
- ~/tmp/dockerize -wait tcp://localhost:6379 -timeout 1m
29
- ;;
30
- neo4j)
31
- ~/tmp/dockerize -wait tcp://localhost:7687 -timeout 1m
32
- ;;
33
- mongo)
34
- ~/tmp/dockerize -wait tcp://localhost:27017 -timeout 1m
35
- ;;
36
- esac
37
- done
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Configures the awscli tool with aws authentication keys
6
- #
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- # provide keys as arguments when invoking the helper
14
- access_key_id="$1"
15
- secret_access_key="$2"
16
-
17
- # write the auth keys to .aws/credentials
18
- aws configure set aws_access_key_id "$access_key_id"
19
- aws configure set aws_secret_access_key "$secret_access_key"
20
-
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Generate artifacts that represent the state of
6
- # the build and can be used after the build has
7
- # run to aid with debugging
8
- #
9
-
10
- # Set error handling
11
- set -eu -o pipefail
12
-
13
- # HELPER COMMANDS
14
-
15
- BUILD_STATE_DIR_PATH="build-state/"
16
-
17
- mkdir -p "${BUILD_STATE_DIR_PATH}";
18
-
19
- echo -e ">> You can find all build-state artifacts under the 'Artifacts' tab for this build\n";
20
-
21
- # artifact: npm-shrinkwrap.json
22
- npm shrinkwrap --loglevel=warn && mv npm-shrinkwrap.json "${BUILD_STATE_DIR_PATH}";
23
- echo ">> artifact: npm-shrinkwrap.json generated, saved";
24
-
25
- # artifact: npm-debug.log
26
- if [ -e npm-debug.log ]; then
27
- mv npm-debug.log "${BUILD_STATE_DIR_PATH}";
28
- echo ">> artifact: npm-debug.log exists, saved";
29
- fi
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Installs the awscli tool
6
- #
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- # install the awscli
14
- sudo apt-get install awscli
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Required for pupeteer on docker based CI
6
- # https://github.com/GoogleChrome/puppeteer/issues/290
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- sudo apt-get update
14
-
15
- sudo apt-get install -yq \
16
- gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
17
- libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 \
18
- libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 \
19
- libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
20
- libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 \
21
- libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \
22
- fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
23
-
24
- # This is used in the request to the Change API made after deployments
25
- sudo apt-get install -yq jq
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
-
5
- # Workaround for a bug in npm where it doesn't correctly
6
- # resolve conflicting peer dependencies.
7
- #
8
- # Parses errors for missing peer dependencies from
9
- # the output of `npm ls` and then pipes the package
10
- # names to `npm install`.
11
- #
12
- # Why we pass the flags we do to `npm install`:
13
- #
14
- # --no-package-lock - While we now use package-lock.json
15
- # in our repos, skip package-lock.json in this instance
16
- # as we don't want to accidentally modify the file
17
- # for subsequent steps in the workflow, e.g cache keys
18
- # and artefact generation.
19
- #
20
- # --no-save - We don't want to modify package.json as we
21
- # use its checksum for some CI tasks e.g. naming node_module caches
22
- #
23
-
24
- # Set error handling
25
- #
26
- # Do *not* set `-o pipefail` as `npm ls --production --parseable`
27
- # will have an exit code of 1 when there are missing peer
28
- # dependencies, but that's what we're expecting to happen
29
- set -eu
30
-
31
- # HELPER COMMANDS
32
-
33
- if [ -e package.json ]; then
34
-
35
- npm ls --production --parseable 2>&1 >/dev/null | \
36
- sed -n -e 's/^npm ERR! peer dep missing: \(.*\),.*/\1/p' | \
37
- xargs -I{} echo -n '"{}" ' | \
38
- xargs npm install --no-package-lock --no-save
39
-
40
- fi
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Store npmjs registry auth token so npm can authenticate with it
6
- # e.g. for `npm publish` (see `helper-npm-publish`)
7
- #
8
-
9
- # Set error handling
10
- set -eu -o pipefail
11
-
12
- # HELPER COMMANDS
13
-
14
- echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ${HOME}/.npmrc
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Run npm update to ensure npm packages in node_modules are the latest.
6
- #
7
- # Why we pass the flags we do to `npm update`:
8
- #
9
- # --dev - Also update devDependencies
10
- #
11
- # --no-package-lock - While we now use package-lock.json
12
- # in our repos, skip package-lock.json in this instance
13
- # as we don't want to accidentally modify the file
14
- # for subsequent steps in the workflow, e.g cache keys
15
- # and artefact generation.
16
- #
17
- # --no-save - We don't want to modify package.json as we
18
- # use its checksum for some CI tasks e.g. naming node_module caches
19
- #
20
-
21
- # Set error handling
22
- set -eu -o pipefail
23
-
24
- # HELPER COMMANDS
25
-
26
- npm update --dev --no-package-lock --no-save
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Bump package version and publicly publish to npm
6
- #
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- PRERELEASE_IDENTIFIER="-[a-z-]+"
14
- RELEASE_TAG="latest"
15
-
16
- if [[ $CIRCLE_TAG =~ $PRERELEASE_IDENTIFIER ]]; then RELEASE_TAG="pre-release"; fi
17
-
18
- npm version --no-git-tag-version ${CIRCLE_TAG}
19
- npm publish --access public --tag=${RELEASE_TAG}
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # HELPER PURPOSE
4
- #
5
- # Deploy to Github Pages
6
- # Your project should set the GITHUB_EMAIL, GITHUB_NAME and TARGET_DIR variables in Vault
7
-
8
- TARGET_BRANCH=gh-pages
9
- TEMP_DIR=tmp
10
-
11
- # Set error handling
12
- set -eu -o pipefail
13
-
14
- # Set GitHub user information (the email must match the SSH key provided to Circle)
15
- git config --global user.email $GITHUB_EMAIL
16
- git config --global user.name $GITHUB_NAME
17
-
18
- # HACK: Add GitHub to known hosts to avoid an interactive prompt when cloning over SSH
19
- mkdir -p ~/.ssh
20
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
21
-
22
- # Clone only the branch we need so we don't download all of the project history
23
- git clone $CIRCLE_REPOSITORY_URL $TEMP_DIR --single-branch --branch $TARGET_BRANCH
24
-
25
- # Remove all of the files, -q prevents logging every filename
26
- cd $TEMP_DIR
27
- git rm -rf .
28
- cd ..
29
-
30
- # Copy contents of target directory to the deployment directory
31
- cp -R -L $TARGET_DIR $TEMP_DIR
32
-
33
- # Copy CI config (which should instruct Circle to ignore this branch)
34
- cp -r .circleci $TEMP_DIR
35
-
36
- cd $TEMP_DIR
37
-
38
- # Stage and commit all of the files
39
- git add -A &> /dev/null
40
- git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty
41
-
42
- # Push to the target branch, staying quiet unless something goes wrong
43
- git push -q origin $TARGET_BRANCH
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Download heroku-cli tool, config auth with .netrc
6
- #
7
- # Based on standalone script from https://devcenter.heroku.com/articles/heroku-cli#standalone-installation
8
- #
9
-
10
- # Set error handling
11
- set -eu -o pipefail
12
-
13
- # HELPER COMMANDS
14
-
15
- # Install Heroku CLI
16
- wget https://cli-assets.heroku.com/channels/stable/heroku-linux-x64.tar.gz
17
- sudo mkdir -p /usr/local/lib /usr/local/bin
18
- sudo tar -xzf heroku-linux-x64.tar.gz -C /usr/local/lib
19
- sudo ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku
20
-
21
- # Output heroku-cli version so user can see in
22
- # build log what version is being used
23
- heroku --version
24
-
25
- # Heroku Repo plugin allows us to clear the git repo, so we can force deploys on circle rebuild
26
- heroku plugins:install heroku-repo
27
-
28
- # Heroku CLI Authentication - Netrc file format
29
- # https://devcenter.heroku.com/articles/authentication#netrc-file-format
30
-
31
- cat > ~/.netrc << EOF
32
- machine api.heroku.com
33
- login $HEROKU_LOGIN
34
- password $HEROKU_AUTH_TOKEN
35
-
36
- machine git.heroku.com
37
- login $HEROKU_LOGIN
38
- password $HEROKU_AUTH_TOKEN
39
-
40
- machine code.heroku.com
41
- login $HEROKU_LOGIN
42
- password $HEROKU_AUTH_TOKEN
43
- EOF
44
-
45
- # Set umask - owner r+w only
46
- chmod 0600 ~/.netrc
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Download s3up for uploading files to Amazon S3 buckets
6
- #
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- # Install S3UP binary
14
- sudo mkdir -p /usr/local/bin
15
-
16
- sudo curl -sfL https://github.com/matthew-andrews/s3up/releases/download/v1.0.5/s3up_linux_386 -o /usr/local/bin/s3up
17
- sudo chmod +x /usr/local/bin/s3up
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # Uploads the compressed assets generated by apps using Page kit to S3
6
- #
7
- # This helper will be executed in place of the current deploy-hashed-assets
8
- # command in n-heroku-tools for all apps that are using Page Kit.
9
- #
10
- # It uploads JavaScipt, CSS, sourcemaps and compressed files to the EU and US
11
- # regions, making the assets available to our CDN layer.
12
- #
13
-
14
- # Set error handling
15
- set -eu -o pipefail
16
-
17
- # HELPER COMMANDS
18
-
19
-
20
- SOURCE_FOLDER=${1:-"public"}
21
- DESTINATION_FOLDER=${2:-"hashed-assets/uploads"}
22
- DESTINATION_BUCKET_EU="ft-next-hashed-assets-prod"
23
- DESTINATION_BUCKET_US="ft-next-hashed-assets-prod-us"
24
-
25
- upload_file() {
26
- local FILE="$1"
27
- local BASENAME=$(basename $FILE)
28
- local DESTINATION_BUCKET="$2"
29
- local ENCODING="identity"
30
- local TYPE
31
-
32
- if [[ "$FILE" == *".gz" ]]; then
33
- ENCODING="gzip"
34
- elif [[ "$FILE" == *".br" ]]; then
35
- ENCODING="br"
36
- fi
37
-
38
- # the AWS CLI can guess content types but not the original type of compressed files
39
- # <https://github.com/aws/aws-cli/issues/3817>
40
- case "$FILE" in
41
- *".js"|*".js.gz"|*".js.br")
42
- TYPE="application/javascript"
43
- ;;
44
- *".css"|*".css.gz"|*".css.br")
45
- TYPE="text/css"
46
- ;;
47
- *".map")
48
- TYPE="application/octet-stream"
49
- ;;
50
- esac
51
-
52
- aws s3 cp $FILE "s3://$DESTINATION_BUCKET/$DESTINATION_FOLDER/$BASENAME" \
53
- --cache-control=31536000 \
54
- --content-type="$TYPE; charset=utf-8" \
55
- --content-encoding="$ENCODING" \
56
- --acl="public-read"
57
- }
58
-
59
- upload_files() {
60
- local SOURCE_FILES=($(find $SOURCE_FOLDER/*.{js,css,gz,br,map} 2>/dev/null))
61
-
62
- for FILE in ${SOURCE_FILES[@]}; do
63
- # Uploading to both regions to remove the dependency on our AWS poller
64
- upload_file "$FILE" $DESTINATION_BUCKET_EU
65
- upload_file "$FILE" $DESTINATION_BUCKET_US
66
- done
67
- }
68
-
69
- upload_files
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # HELPER PURPOSE
4
- #
5
- # TODO: Make this example a bit more useful
6
- #
7
-
8
- # Set error handling
9
- set -eu -o pipefail
10
-
11
- # HELPER COMMANDS
12
-
13
- # ...
@@ -1,25 +0,0 @@
1
- module.exports = {
2
- files: {
3
- allow: [
4
- 'helper-generate-build-state-artifacts',
5
- 'helper-configure-awscli',
6
- 'helper-install-awscli',
7
- 'helper-install-puppeteer-deps',
8
- 'helper-npm-install-peer-deps',
9
- 'helper-npm-store-auth-token',
10
- 'helper-npm-update',
11
- 'helper-check-service-ready',
12
- 'helper-npm-version-and-publish-public',
13
- 'helper-publish-github-pages',
14
- 'helper-setup-heroku-cli',
15
- 'helper-setup-s3-upload',
16
- 'helper-upload-assets-to-s3',
17
- 'helper.example'
18
- ],
19
- allowOverrides: []
20
- },
21
- strings: {
22
- deny: [],
23
- denyOverrides: []
24
- }
25
- };