diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..fdd8651f --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "plugins": ["@babel/plugin-proposal-class-properties"] +} \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..b1de71c4 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,57 @@ +version: 2.1 +executors: + node12: + docker: + - image: circleci/node:12 + environment: + NPM_CONFIG_PREFIX: "~/.npm-global" + working_directory: ~/repo + +orbs: + helix-post-deploy: adobe/helix-post-deploy@2.0.10 + +jobs: + build: + executor: node12 + steps: + - checkout + - run: + name: install latest npm + command: sudo npm -g install npm + - run: + name: Installing Dependencies + command: npm install + - persist_to_workspace: + root: /home/circleci + paths: + - project + + operations: + executor: node12 + steps: + - attach_workspace: + at: /home/circleci + - helix-post-deploy/monitoring: + newrelic_name: Adobe CC Express - Production Content + newrelic_url: https://www.adobe.com/express + newrelic_type: browser + newrelic_script: ./.monitoring/homepage-pricing.js + newrelic_group_policy: Customer Sites + newrelic_locations: AWS_US_WEST_1 + newrelic_frequency: 1 + +workflows: + version: 2 + build: + jobs: + - build: + filters: + branches: + only: ops + - operations: + requires: + - build + context: Project Helix + filters: + branches: + only: ops diff --git a/.eslintrc.js b/.eslintrc.js index bd0fdb3f..bedcd265 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,8 +16,19 @@ module.exports = { rules: { // allow reassigning param 'no-param-reassign': [2, { props: false }], + 'linebreak-style': ['error', 'unix'], + 'import/extensions': ['error', { + js: 'always', + }], }, + parser: '@babel/eslint-parser', parserOptions: { + allowImportExportEverywhere: true, sourceType: 'module', + requireConfigFile: false, + babelOptions: { + configFile: './.babelrc', + }, }, + plugins: ['@babel'], }; diff --git a/.github/workflows/purge-code.yaml b/.github/workflows/purge-code.yaml deleted file mode 100644 index 14a57bd4..00000000 --- a/.github/workflows/purge-code.yaml +++ /dev/null @@ -1,16 +0,0 @@ -on: - push: - branches: - - master - -jobs: - ci_trigger: - runs-on: ubuntu-latest - name: Purge changed files from cache - steps: - - name: Trigger - id: trigger - uses: adobe-rnd/github-purge-cache-action@master - with: - helix-url: https://spark-website--adobe.hlx.live/ - repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 655f4654..d41cee3d 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -13,6 +13,7 @@ jobs: node-version: '12' - run: npm install working-directory: test + - run: npm run lint - run: npm test working-directory: test env: diff --git a/.monitoring/homepage-pricing.js b/.monitoring/homepage-pricing.js new file mode 100644 index 00000000..13f4807b --- /dev/null +++ b/.monitoring/homepage-pricing.js @@ -0,0 +1,75 @@ +/* + * Copyright 2021 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +/* global $browser $driver */ +/* eslint-disable no-console */ + +/* + * Scripted Browser API Documentation: + * https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/scripting-monitors/writing-scripted-browsers + */ +const assert = require('assert'); + +const TIMEOUT = 10000; + +/** + * Checks if the homepage is loading and showing the expected content. + * @param {string} baseUrl The base URL to check + */ + async function checkHomepage(baseUrl) { + const url = `${baseUrl}/`; + console.log(`Verifying ${url} ...`); + $browser.get(url) + // wait for the page to fully load + .then(() => $browser.sleep(TIMEOUT)) + // check document integrity + .then(() => $browser.findElement($driver.By.css('html'))) + .then((html) => Promise.all([html.getAttribute('class'), html.getAttribute('lang')])) + .then(([template, lang]) => { + assert.ok(template === 'default', `Expected template to be "default", got "${template}" instead`); + assert.ok(lang === 'en', `Expected language to be "en", got "${lang}" instead`); + }) + // check CTA button + .then(() => $browser.findElement($driver.By.css('main a.button.primary'))) + .then(() => console.log(`${url} successfully verified.`)) + .catch((e) => { + assert.fail(`Verification of ${url} failed: ${e.message}`); + }); +} + +/** + * Checks if the pricing page is loading and showing the expected content. + * @param {string} baseUrl The base URL to check + */ +async function checkPricingPage(baseUrl) { + const url = `${baseUrl}/pricing`; + console.log(`Verifying ${url} ...`); + $browser.get(url) + // wait for the page to fully load + .then(() => $browser.sleep(TIMEOUT)) + // check buy button + .then(() => $browser.findElement($driver.By.linkText('Buy Now'))) + .then((button) => button.getAttribute('href')) + .then((buyUrl) => assert.ok(buyUrl.startsWith('https://commerce.adobe.com'))) + .then(() => console.log(`${url} successfully verified.`)) + .catch((e) => { + assert.fail(`Verification of ${url} failed: ${e.message}`); + }); +} + +// Check homepage and pricing page +(async () => { + await Promise.all([ + '$$$URL$$$', + // 'https://spark-website--adobe.hlx.live/express', + // 'https://spark-website--adobe.hlx.page/express', + ].map((baseUrl) => checkHomepage(baseUrl) && checkPricingPage(baseUrl))); +})(); diff --git a/404.html b/404.html index 18bdd778..6e70ef07 100644 --- a/404.html +++ b/404.html @@ -6,19 +6,52 @@ window.isErrorPage = true; window.errorCode = '404'; + - +
-
-
-

-

-