- Clone the project:
git clone - Install the dependencies:
npm install - Customize the build
- Generate Builds
- Deploying
Server and cookie variables can be set in the .env-cmdrc file.
Certain files in the dependencies (i.e. node_modules) need to be overwritten. The files are located in the overrides directory.
cli.js should replace the file located at node_modules/react-snapshot/lib/cli.js.
webpack.config.prod.js should replace the file located at node_modules/react-scripts/config/webpack.config.prod.js.
In order for React routing to work properly, a few files need to be altered.
In package.json the homepage
field needs to be set to the build folder on the server, e.g. https://dev-02.cwrc.ca/cwrc-entity-management-forms-static/build/.
If you're updating this app, many of the directories can be ignored as they're part of the suicrux boilerplate that formed the basis for the app.
Listed below are the files and directories directly related to the entity forms.
Everything related to client server communication is at: https://github.com/cwrc/cwrc-entity-management-forms-static/tree/master/src/api/EntitiesSvc
Entities are stored as XML on the server, and manipulated as JSON on the client. Code for doing XML to JSON and JSON to XML conversion can be found for each entity in the relevant directory inside EntitiesSvc.
Common functions used in the conversions can be found here: https://github.com/cwrc/cwrc-entity-management-forms-static/blob/master/src/api/utils/conversion_utilities.js
Actual server calls are made at: https://github.com/cwrc/cwrc-entity-management-forms-static/blob/master/src/api/EntitiesSvc/index.js
The code for the forms themselves is at: https://github.com/cwrc/cwrc-entity-management-forms-static/tree/master/src/containers/EntityForm
Common components used in all forms can be found here: https://github.com/cwrc/cwrc-entity-management-forms-static/tree/master/src/containers/EntityForm/components
In order for React routing to work properly, you need to define the correct root path for the build according to the server you are deploing:
In package.json the homepage
field needs to be set to the build folder on the server:
- local: "/"
- development: "https://dev-02.cwrc.ca/cwrc-entity-management-forms-static/build/"
- testing: "https://test-01.cwrc.ca/cwrc-entity-management-forms-static/build/"
- staging: "https://staging-01.cwrc.ca/cwrc-entity-management-forms-static/build/"
- production: "https://cwrc.ca/cwrc-entity-management-forms-static/build/"
run one of the options on package.json:
- "build:development": "env-cmd -e development npm run build && copyfiles -u 1 "build/**/*" ./bin/dev && npm run clean:build"
- "build:testing": "env-cmd -e testing npm run build && copyfiles -u 1 "build/**/*" ./bin/testing && npm run clean:build"
- "build:staging": "env-cmd -e staging npm run build && copyfiles -u 1 "build/**/*" ./bin/staging && npm run clean:build"
- "build:production": "env-cmd -e production npm run build && copyfiles -u 1 "build/**/*" ./bin/production && npm run clean:build"
- "build:all": "npm run build:development && npm run build:testing && npm run build:staging && npm run build:production"
Each one of them takes env variables from the file .env-cmdrc.js. "build:all" will generate builds for all environments at once. The built files will be saved into each specific folder in the bin folder.
If dependencies are updated (specifically react-scripts and react-snapshop), you need to replace the override files as follows (check oveerides)
- Push files to Gihub
- Pull files on server
It is better to compile code on site becuase of the different build options. But you can use the pre-built code on bin if you like.
- From the installation directory, run
git pullto update. (You might need togit stashthe above build customizations. Thengit stash popthem after the pull is complete.) - Move or copy the content of a specific environment (e.g.:
/bin/dev) to/build. e.g.:cp -R ./bin/dev ./build
- From the installation directory, run
git pullto update. (You might need togit stashthe above build customizations. Thengit stash popthem after the pull is complete.) - run
npm ito install eventual dependencies updates. - Run
npm run {build-version}to actually create a build for a specific environment. Ornpm run build:allto create version to all environments. - Move or copy the content of a specific environment (e.g.
/bin/dev) to/build. e.g.:cp -R ./bin/dev ./build