2.0.0 • Published 1 month ago

orc-scripts v2.0.0

Weekly downloads
124
License
MIT
Repository
github
Last release
1 month ago

Script and dependency toolbox for Orckestra web applications

Build Status Coverage Status

This package contains a standard set of dependencies and tooling for web applications. It is based on kcd-scripts (copyright © 2017 Kent C. Dodds, licensed via MIT License) in both concept and code.

Installation and use

Installing this package is done via npm: npm install orc-scripts. This will also install the dependency set provided.

Scripts

Where one exists, these scripts are intended to perform the role of the eponymous npm script. The scripts are invoked by running orc-scripts <script> <options>.

prep: Sets up for the build script (below). This creates the dist/ directory and copies src/content/ to dist/content/. If not production building, also copies any files in src/static to dist/.

build: Runs the build process, creating the distribution files for the package. This is typically used for preparing a release. Adding the --watch option starts a watch for file changes, rebuilding when a source file changes. This is useful for developing in a linked library. For web apps, this will use Webpack, for libraries, it uses Babel. Expects to have prep (above) run before it.

start: Starts a web server locally, with hot module reloading enabled. Intended to support development work. You may set a specific port using the --port <port> option, or with the PORT environment variable. If a HOST environment variable is supplied, it will set up as an HTTPS server, expecting to be accessed at that hostname. Expects to have prep (above) run before it.

test: Starts the Jest test runner in watch mode. This will run and rerun all tests relating to files changed from the git HEAD by default. Adding the --no-watch option instead runs all tests once and exits. The --coverage option generates a code coverage report for the test suite under coverage/. Jest command-line options are in general applicable.

extract-messages: Searches through all JS files in the src/ directory, extracting any react-intl messages found. It creates JSON files under src/translations/ with all keys, using default values to populate the default language (by default the first supported locale). Other languages are left empty. Existing keys are not changed. Use this to ensure that translations are made. This script requires the presence of a .babelrc file; the simplest way to solve this is to create a .babelrc.js file containing only module.exports = require("orc-scripts/babel");.

The easiest way to use these scripts is to add entries to your package.json under "scripts", invoking the orc-scripts command. A typical "scripts" section might look like this:

{
	"scripts": {
		"clean": "orc-scripts clean",
		"build": "orc-scripts prep && orc-scripts build",
		"start": "orc-scripts prep && orc-scripts start",
		"test": "orc-scripts test",
		"coverage": "orc-scripts test --coverage"
	}
}

Code tools

The toolbox contains support for eslint and prettier, both for use with development tools (such as Atom or VS Code) and in git hooks. To integrate with your development tool of choice, ensure the suitable plugin is installed if applicable, and create a config file or package.json entry that points to the orc-scripts preset for that tool (orc-scripts/eslint, resp. orc-scripts/prettier).

To set up a git commit hook that runs prettier on all staged files, add the following section to package.json:

{
	"husky": {
		"hooks": {
			"pre-commit": "lint-staged"
		}
	}
}

This will run the lint-staged tool whenever you commit files to git. Configure this tool with a section in your package.json as follows:

{
	"lint-staged": {
		"linters": {
			"*.{js,json,md}": ["prettier --write", "git add"]
		},
		"ignore": ["package.json", "package-lock.json", "src/translations/*.json"]
	}
}

This instructs lint-staged to run prettier on staged files, rewriting the file to specifications, and then re-staging it for the commit. This ensures that all code in the app lives up to the strict standards set by prettier. It is recommended to not let it process package.json, package-lock.json and translation files, as these are automatically processed and changed. Prettier can be told to ignore these by adding a .prettierignore file using the same syntax as .gitignore.

Testing

Testing with Jest and unexpected is built into the toolbox, allowing test setup to be as simple as adding a file with a .test.js suffix to your file tree. A number of plugins and custom assertions are provided as well.

Deploying

An application that employs code splitting (resulting in multiple output bundle files) and is to be deployed to a CDN will need to pass the CDN location to the entry bundle to ensure that further bundles are fetched from the right location. To do this, include a script in the header of the index.html file which sets window.ASSET_PATH to the CDN location (a slash-terminated url, i.e. "https://foo.cdn.org/my-bundle/"). This needs to be executed before the entry bundle.

License

Copyright © 2018 Orckestra Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@babel/cli@babel/core@babel/plugin-proposal-class-properties@babel/plugin-proposal-object-rest-spread@babel/plugin-proposal-optional-chaining@babel/plugin-syntax-dynamic-import@babel/plugin-transform-computed-properties@babel/plugin-transform-destructuring@babel/plugin-transform-react-jsx@babel/plugin-transform-template-literals@babel/preset-env@formatjs/intl-getcanonicallocales@formatjs/intl-pluralrules@gustavnikolaj/async-main-wrap@loadable/babel-plugin@loadable/component@material-ui/core@material-ui/lab@typescript-eslint/eslint-plugin@typescript-eslint/parser@welldone-software/why-did-you-renderbabel-corebabel-eslintbabel-loaderbabel-plugin-react-intl-autobabel-plugin-root-importbabel-plugin-styled-componentsclassnamesconnected-react-routercore-jscoverallscross-spawncss-loaderdate-fnsdotenvenzymeenzyme-adapter-react-16eslinteslint-config-react-appeslint-plugin-flowtypeeslint-plugin-importeslint-plugin-jsx-a11yeslint-plugin-reacteslint-plugin-react-hooksextract-react-intl-messagesfile-loaderfull-icuhuskyicu4c-dataidentity-obj-proxyimageminimg-loaderimmutableimmutable4is-cijestjest-enzymejest-junitlint-stagedmoment-timezonencpnormalizrpkg-dirpolishedprettierreactreact-big-calendarreact-datepickerreact-domreact-hot-loaderreact-intlreact-measurereact-multi-clampreact-reduxreact-resize-detectorreact-routerreact-router-domreact-test-rendererreact-transition-groupread-pkg-uprecomposereduxredux-api-middlewareredux-immutablereselectresolverimrafseamless-immutablesinonstyle-loaderstyled-componentsstyled-transition-groupsvg-inline-loaderts-jesttypeface-open-sanstypeface-roboto-condensedunexpectedunexpected-domunexpected-immutableunexpected-reactionunexpected-sinonurl-loaderurl-patternurl-polyfillwebpackwebpack-bundle-analyzerwebpack-dev-serverwhatwg-fetch
2.0.0

1 month ago

2.1.0-dev.0

1 month ago

2.0.1-dev.0

1 month ago

1.8.0

3 months ago

1.8.1-dev.1

3 months ago

1.8.0-dev.2

6 months ago

1.9.0-dev.1

5 months ago

2.0.0-dev.3

5 months ago

2.0.0-dev.2

5 months ago

2.0.0-dev.4

5 months ago

1.8.0-dev.1

7 months ago

1.7.0

7 months ago

1.6.2

8 months ago

1.6.1

9 months ago

1.6.0

11 months ago

1.7.0-dev.1

11 months ago

1.7.0-dev.2

8 months ago

1.6.1-dev.1

11 months ago

1.6.0-dev.2

11 months ago

1.5.0

2 years ago

1.5.0-pre.1

2 years ago

1.6.0-dev.1

2 years ago

1.5.0-dev.2

2 years ago

1.4.0

2 years ago

1.5.0-dev.1

2 years ago

1.4.0-pre.1

2 years ago

1.4.0-dev.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.3.0-dev.2

2 years ago

1.2.0-pre.0

3 years ago

1.3.0-dev.1

3 years ago

1.1.0

3 years ago

1.2.0-dev.1

3 years ago

5.0.0-pre.1

3 years ago

1.1.0-pre.0

3 years ago

1.1.0-dev.26

3 years ago

1.1.0-dev.25

3 years ago

1.1.0-dev.24

3 years ago

1.1.0-dev.23

3 years ago

1.1.0-dev.22

3 years ago

1.1.0-dev.21

3 years ago

1.1.0-dev.20

3 years ago

1.1.0-dev.19

3 years ago

1.1.0-dev.18

3 years ago

1.1.0-dev.17

3 years ago

1.1.0-dev.16

3 years ago

1.1.0-dev.15

3 years ago

1.1.0-dev.14

3 years ago

1.1.0-dev.13

3 years ago

1.1.0-dev.12

3 years ago

1.1.0-dev.11

4 years ago

1.1.0-dev.10

4 years ago

1.1.0-dev.9

4 years ago

1.1.0-dev.6

4 years ago

1.1.0-dev.7

4 years ago

1.1.0-dev.8

4 years ago

1.1.0-dev.5

4 years ago

1.1.0-dev.4

4 years ago

1.1.0-dev.3

4 years ago

1.1.0-dev.2

4 years ago

1.1.0-beta.1

4 years ago

1.1.0-dev.1

4 years ago

1.0.0-dev.21

4 years ago

1.0.0-dev.20

4 years ago

1.0.0-dev.19

4 years ago

1.0.0-dev.18

4 years ago

1.0.0-dev.17

4 years ago

1.0.0-dev.16

4 years ago

1.0.0-dev.15

4 years ago

1.0.0-dev.13

4 years ago

1.0.0-dev.14

4 years ago

1.0.0-dev.12

4 years ago

1.0.0-dev.11

4 years ago

1.0.0-dev.10

4 years ago

1.0.0-dev.9

4 years ago

1.0.0-dev.8

4 years ago

1.0.0-pre.4

4 years ago

1.0.0-dev.7

4 years ago

1.0.0-dev.6

4 years ago

1.0.0-dev.5

4 years ago

1.0.0-dev.4

4 years ago

1.0.0-dev.3

4 years ago

1.0.0-dev.2

4 years ago

1.0.0-dev.0

4 years ago

1.0.0-pre.3

4 years ago

1.0.0-pre.2

4 years ago

1.0.0-pre.1

4 years ago

1.0.0-pre.0

4 years ago

0.8.11-dev.0

4 years ago

0.8.10-dev.2

4 years ago

0.8.9

4 years ago

0.8.10

4 years ago

0.8.8

4 years ago

0.8.7

4 years ago

0.6.37

4 years ago

0.6.36

4 years ago

0.8.6

4 years ago

0.6.35

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.6.34

4 years ago

0.8.3

4 years ago

0.6.33

4 years ago

0.6.32

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.3-pre.5

4 years ago

0.7.3-pre.4

4 years ago

0.7.3-pre.2

4 years ago

0.7.3-pre.3

4 years ago

0.7.3-pre.1

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.1-rc.1

4 years ago

0.7.0

4 years ago

0.7.0-rc.4

4 years ago

0.6.31

4 years ago

0.7.0-rc.3

4 years ago

0.6.30

4 years ago

0.7.0-rc.2

4 years ago

0.6.29

4 years ago

0.7.0-rc.1

4 years ago

0.6.28

5 years ago

0.6.27

5 years ago

0.6.26

5 years ago

0.6.25

5 years ago

0.6.24

5 years ago

0.6.23

5 years ago

0.6.22

5 years ago

0.6.21

5 years ago

0.6.20

5 years ago

0.6.19

5 years ago

0.6.18

5 years ago

0.6.17

5 years ago

0.6.16

5 years ago

0.6.15

5 years ago

0.6.14

5 years ago

0.6.13

5 years ago

0.6.12

5 years ago

0.6.11

5 years ago

0.6.10

5 years ago

0.6.9

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.4.2

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.4.0-rc.15

5 years ago

0.4.0-rc.14

5 years ago

0.4.0-rc.13

5 years ago

0.4.0-rc.12

5 years ago

0.4.0-rc.11

5 years ago

0.4.0-rc.10

5 years ago

0.4.0-rc.9

5 years ago

0.4.0-rc.8

6 years ago

0.4.0-rc.7

6 years ago

0.4.0-rc.6

6 years ago

0.4.0-rc.5

6 years ago

0.4.0-rc.4

6 years ago

0.4.0-rc.3

6 years ago

0.4.0-rc.2

6 years ago

0.4.0-rc.1

6 years ago

0.3.47

6 years ago

0.3.46

6 years ago

0.3.45

6 years ago

0.3.44

6 years ago

0.3.43

6 years ago

0.3.42

6 years ago

0.3.41

6 years ago

0.3.40

6 years ago

0.3.39

6 years ago

0.3.38

6 years ago

0.3.37

6 years ago

0.3.36

6 years ago

0.3.35

6 years ago

0.3.34

6 years ago

0.3.33

6 years ago

0.3.32

6 years ago

0.3.31

6 years ago

0.3.30

6 years ago

0.3.29

6 years ago

0.3.28

6 years ago

0.3.27

6 years ago

0.3.26

6 years ago

0.3.25

6 years ago

0.3.24

6 years ago

0.3.24-0

6 years ago

0.3.23

6 years ago

0.3.22

6 years ago

0.3.21

6 years ago

0.3.20

6 years ago

0.3.19

6 years ago

0.3.18

6 years ago

0.3.17

6 years ago

0.3.16

6 years ago

0.3.15

6 years ago

0.3.14

6 years ago

0.3.13

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago