This package contains static assets (JS, CSS and more) for use by "dashboard," our Rails app ("dashboard" is studio.code.org, also known as "Code Studio"). Dashboard consumes a transpiled, concatenated, factored, compressed, mangled distribution version of this package (which it unpacks to dashboard/public/code-studio-package). What you're looking at is the original source for that package, and the tools to build the distribution.
This includes (not an exhaustive list):
- Our video player/fallback player system
- React and a number of our custom components
- Some app initialization glue logic (see initApp.js)
- Levelbuildler-specific JavaScript and CSS
It does not include:
- The apps package, which contains our puzzle and project level types
- blockly-core, our fork of the Blockly visual programming environment
- dashboard, the actual Rails app that serves these assets at studio.code.org
- pegasus, the Sinatra app that serves pages at code.org.
You should have the following tools installed globally.
Then, run npm install from the code-studio directory (the location of this README), which will do the following:
- Downloads and installs all package dependencies, dev utilities, etc into the
node_modulesdirectory. - Creates a symlink from
node_modules/vendorto thevendordirectory in the package root, for easily including vendor code from our source files.
You have a few options. In each case, the package will end up in code-studio/build.
Running npm run build:dist will create the whole distribution package from scratch - it runs linting and tests, wipes the build directory, and generates all the appropriate JS, CSS, and other assets, mangled and ready for production use.
Most of the time, though, you'll want a development build. npm run build is faster and generates prettier output - and for JS and JSX files, it includes embedded sourcemaps for easy debugging.
We support auto-rebuilding too. npm start beings a watch process that updates the build any time a JS or JSX file changes (Press Ctrl+C to stop).
There are other useful commands, like npm run build-css or npm run copy-assets - use npm run to list them all.
Tests are found in the test subdirectory. Use npm test to run Mocha tests with Chai assertions and Istanbul coverage.
To debug tests in the browser, add a debugger statement in the test you want
to debug and invoke npm run debug from the shell. This will launch the
Chrome debugger at an initial breakpoint before any tests have any run. Go to
the source tab, click the run button, and the debugger will stop at your
breakpoint.
Please follow our style guide. We've set up linting to help:
- If you haven't already, run
rake install:hooksto ensure our precommit linting is set up. - Use
npm run lintto lint the code-studio package.
Places we looked while getting this build system working: