CLI Commands

September 29, 2020 ยท View on GitHub

one-app Server consists of NPM Script Commands that determine its runtime configuration and behaviors.

npm run <one-app-npm-command> [--] [--some-flag]
# e.g. npm run test:unit -- --watch

We describe each command and a description of its usage below.

Contents

Install Commands

CommandDescription
preinstallRuns check-engines package to ensure a compatible Node version is used before npm install.
postinstallRuns a build after npm install.

Development Commands

๐Ÿ’ฌ These commands are for Development only

CommandDescription
serve-moduleAccepts a path to a Holocron Module and adds it to the local development CDN. See serve-module Arguments.
drop-moduleAccepts a Holocron Module name and removes the Module from the local development CDN. See drop-module Arguments.
set-middlewareAccepts a file path to JS file that defines custom Express Middleware for the development proxy. See set-middleware Arguments.
set-dev-endpointsAccepts a Node file containing development endpoints for the development proxy. See set-dev-endpoints Arguments.

serve-module Arguments

npm run serve-module <path-to-module-folder>...
# e.g. npm run serve-module ../../my-module

drop-module Arguments

npm run drop-module <module-name>...
# e.g. npm run drop-module my-module

set-middleware Arguments

npm run set-middleware <path-to-middleware-js>
# e.g. npm run set-middleware ../dev.middleware.js

The contents of the Express Middleware JS file should match the following shape:

Shape

// (app: ExpressApp) => (req: ExpressRequest, res: ExpressResponse, next: ExpressNext) => undefined
module.exports = (app) => (req, res, next) => {
  next();
};

set-dev-endpoints Arguments

npm run set-dev-endpoints <path-to-endpoints-js>...
# e.g. npm run set-dev-endpoints ../dev.endpoints.js

The contents of the endpoints JS file should match the following shape:

Shape

module.exports = {
  someIdReference: {
    devProxyPath: String, // String local URL path
    destination: String, // String of Destination Hostname
  },
  // ... More entries of the same shape
};

Start Commands

CommandDescription
startRuns one-app Server and accepts the flags listed below.
start:watchExecutes one-app Server and watches Server source files with nodemon. When source changes, one-app reloads with the npm start. This command accepts all the flags as start.
prestart:prod-sampleRuns build:sample-modules before start:prod-sample.
start:prod-sampleRuns a Docker Compose file to start up the Integration Test Suite containers.

Build Commands

CommandDescription
buildUsing the concurrently package, runs build:server and build:bundle.
build:serverExecutes Babel to transpile ES6 Server source files
build:bundleExecutes One App Bundler to build Browser assets
build:artifacts:staticsRuns Static Assets Script for Integration Tests
build:prod-sampleRuns build:sample-modules and runs the Build One App Docker Setup Script for Integration Tests
build:sample-modulesBuilds the Holocron Modules in prod-sample/sample-modules folder for Integration Tests. See build:sample-modules Usage.

build:sample-modules Usage

npm run build:sample-modules [--] [--archive-built-artifacts]
# e.g. npm run build:sample-modules -- --archive-built-artifacts

Flags

FlagDescription
--archive-built-artifactsRuns tar and gzip on the the built sample Holocron Modules bundles. Used in Integration Test Suite

Start Usage

[ONE_CONFIG_ENV=<runtime-level>] npm run start (--) (--root-module-name=<root-module-name>) [--module-map-url=<module-map-url>] [--use-middleware]
# e.g. ONE_CONFIG_ENV=development npm run start -- --root-module-name=my-root-module

Flags

FlagDescription
--root-module-nameName of the Holocron Module that serves as the entry point to your application.
--module-map-urlRemote Module Map URL for one-app-dev-cdn to proxy. For Development.
--use-middlewareApply a custom middleware configuration for one-app-dev-proxy. For Development.
--use-hostUse req.headers.host instead of localhost. Passed as true or false to one-app-dev-cdn. For Development.

Environment Variables

Please see the Environment Variables API docs.

Clean Commands

CommandDescription
cleanExecutes clean:build and clean:test.
clean:buildRemoves folders and files related to Babel and Webpack builds.
clean:testRemoves Jest Integration Test Report folder.

Test Commands

CommandDescription
testRuns all test:* scripts.
test:unitRuns all Jest Unit Tests. Accepts Jest flags.
test:lintRuns ESLint rules against source.
pretest:integrationUsing concurrently, runs build:prod-sample and pulls Docker containers to prepare the Integration Test Suite.
test:integrationExecutes the Integration Test Suite using Jest.
test:dangerRuns the DangerJS tool that returns bundle size stats and a preflight checklist for PRs.
test:git-historyValidates the Git commit message format using the commitlint tool.
test:lockfileValidates that the package-lock.json file contains valid NPM registry URLs using the lockfile-lint tool.

๐Ÿ“˜ More Information

โ˜๏ธ Return To Top