This is a bare-bones React project. It contains a simple React view with the libraries for using the CODAP Plugin API.
There are two ways to create a new repository from this template:
- Go to this repository's GitHub page
- Click the green "Use this template" button at the top
- Select "Create a new repository"
- Set your repository name (e.g.
new-repository
) - Choose visibility (public/private)
- Click "Create repository from template"
- Clone your new repository:
git clone https://github.com/your-username/new-repository.git cd new-repository
- Create a new public repository for your project (e.g.
new-repository
) - Create a clone of the starter repo
git clone --single-branch https://github.com/concord-consortium/codap-plugin-starter-project.git new-repository cd new-repository
- Next, re-initialize the repo to create a new history
rm -rf .git git init
- Add a remote to your GitHub repository
git remote add origin https://github.com/concord-consortium/new-repository.git
-
Run
npm install
to install dependencies -
Optionally Run:
npm update
to update the dependencies. If you can, it is best to do this in thecodap-plugin-starter-project
first before making your new repository. -
Run
npm start
to start thewebpack-dev-server
in development mode with hot module replacement -
Open localhost:8080 (or use port 8081 if you are already using 8080). You should see a basic plugin with a heading of "CODAP Starter Plugin".
It's ok if you see an error like
handleResponse: CODAP request timed out: [{"action":"update","resource":"interactiveFrame","values":{"name":"Sample Plugin","version":"0.0.1","dimensions":{"width":380,"height":680}}},{"action":"get","resource":"interactiveFrame"}]
. This just means that the plugin is running outside of Codap, so is not receiving responses to API requests, which is expected. -
Run
npm test
to verify that the test suite still passes. -
Run
npx playwright install
to install the playwright browsers -
Run
npm run test:playwright
to verify the playwright tests still pass. The Playwright tests verify that the plugin works correctly inside CODAP. -
Search and replace instances of
codap-plugin-starter-project
withnew-repository
. -
Search and replace instances of
CODAP Starter Plugin
andCODAP Plugin Starter Project
withNew Plugin
. -
Update the general description of the project in the first section above.
-
Setup AWS keys for S3 Deployment. This is so the GitHub actions can deploy to S3 and save the Playwright results.
-
Configure the Codecov token.
- Find the new repository at https://app.codecov.io/gh/concord-consortium
- Choose the repository token option
- Add the token to the GitHub repository as described on the codecov page.
-
Remove this
Copying from the starter project
section of theREADME
, but keep track of the next step. -
Create an initial commit for your new project and push it.
git add . git commit -m "Initial commit" git push -u origin master
Your new repository is ready!
-
Clone this repository and
cd
into the new folder. -
Install the dependencies
npm install
. -
Run the development server
npm start
. -
Open localhost:8080 (or use port 8081 if you are already using 8080). You should see a basic plugin with a heading of "CODAP Starter Plugin".
It's ok if you see an error like
handleResponse: CODAP request timed out: [{"action":"update","resource":"interactiveFrame","values":{"name":"Sample Plugin","version":"0.0.1","dimensions":{"width":380,"height":680}}},{"action":"get","resource":"interactiveFrame"}]
. This just means that the plugin is running outside of Codap, so is not receiving responses to API requests, which is expected.
The project uses Jest for unit testing. To run the tests:
npm test
The project uses Playwright for end-to-end testing. These tests verify that the plugin works correctly inside CODAP. Playwright has lots of features including a VSCode plugin. Below are some basic steps to get started.
Before running tests for the first time you need to install the Playwright browsers:
npx playwright install
After this you can run the tests without showing a browser or run them with a visible browser.
npm run test:playwright
If you want to view a test report of these tests you can run:
npx playwright show-report
npm run test:playwright:open
There are two ways to test the plugin in CODAP:
- running it locally on https and use the deployed CODAP
- running it and CODAP locally on http
- Start the plugin with
npm run start:secure
. You need to first setup a local http certificate if you haven't done so: https://github.com/concord-consortium/codap/blob/main/v3/README.md#run-using-https - Run CODAP v2 or v3 with the
di
parameter:
- Start plugin webserver
npm start
(it will be on 8080 by default) - Setup a local webserver running CODAP.
- v2: Download the latest
build_[...].zip
file https://codap.concord.org/releases/zips/. Extract the zip to a folder and run it with a local webserver. For examplenpx httpserver -p 8081
- v3: Checkout the v3 source, install the dependencies, and start the dev server: https://github.com/concord-consortium/codap/blob/main/v3/README.md#initial-steps. The dev server should automatically choose the next avaiable port which would normally be 8081
- v2: Download the latest
- Open CODAP with the plugin embedded in it: http://localhost:8081/static/dg/en/cert/index.html?di=http://localhost:8080
For further information on CODAP Data Interactive Plugin API.