0.1.4 • Published 4 years ago

broadside-core v0.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

broadside-core

The core library that contains all the logic needed to serve different campaigns dynamically

Setup


Prerequisites

To start working on broadside you will need to have a recent version of node and yarn.

To install node use Node Version Manager nvm. To download run the following from your terminal:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

Then to get the get the latest node version

nvm install stable

Set the version that is returned (ie 13.1.0) as the default

nvm alias default 13.1.0

Install yarn package globally

npm install -g yarn

Development

In order to start developing you will first need to install the project dependencies. But because this app depends on Fractal project (which is a private package in npm registry), you will need to have an npm account, and this account should be added to the Fractal team in npm.

  • Signup in npm from the link here, and activate your account.

  • Ask the team leader to add your account to Fractal team on npm

  • From any where in your machine:

npm login
# Enter your credentials, and make sure that you logged in successfully
  • Install cypressjs globally:
yarn global add cypress
  • From the root of the project:
yarn install
  • Add a .env file, which contains the needed environment variables for the lib to work, you can ask your team leader to send you that file, and place it directly inside broadside-core folder

  • In order to build the library in development mode:

yarn build:dev
  • In order to build in production mode:
yarn build

To generate a campaign that uses this package, kindly take a look at the camgen generator

Testing

There are two types of tests in this project:

  • End-to-end tests: which are using cypress.io, you can invoke them by running:
yarn cy:test

This command will start the application and run the cypress test suite

  • Api and components tests: which are using Jest, you can invoke them by running:
yarn jest:test

Also you can run the two test suites by running:

yarn test:all

Fetching data from Contentful:

This is a very useful feature for testing; as it allows us to fetch the data that is currently in Contentful, and save it locally in json files; to be used in mocking contentful responses during testing.

yarn test:update-mock-data

When running the above command a js file will be executed, and as a result the following will happen:

  • The data of page contentType will be fetched and saved to page.json
  • The data of campaign contentType will be fetched and saved to campaign.json

Note that this operation will override the current existing files

Export/Import Contentful data

We can export the data saved in Contentful to a json file by running:

yarn export-contentful

Which will export to a file with the path ./contentful-backup/exported-master.json

Note that this command depends on the configuration file ./contentful-backup/exçport-config.json

Also we can import the exported data again to Contentful using the command:

yarn import-contentful

And this command depends on the configuration file ./contentful-backup/import-config.json