Skip to content

Latest commit

 

History

History
220 lines (173 loc) · 10 KB

Cli-Commands.md

File metadata and controls

220 lines (173 loc) · 10 KB

👈 Return to Overview

CLI Commands

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

Command Description
preinstall Runs check-engines package to ensure a compatible Node version is used before npm install.
postinstall Runs a build after npm install.

Development Commands

💬 These commands are for Development only

Command Description
serve-module Accepts a path to a Holocron Module and adds it to the local development CDN. See serve-module Arguments.
drop-module Accepts a Holocron Module name and removes the Module from the local development CDN. See drop-module Arguments.
set-middleware Accepts a file path to JS file that defines custom Express Middleware for the development proxy. See set-middleware Arguments.
set-dev-endpoints Accepts 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

Command Description
start Runs one-app Server and accepts the flags listed below.
start:watch Executes 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-sample Runs build:sample-modules before start:prod-sample.
start:prod-sample Runs a Docker Compose file to start up the Integration Test Suite containers.

Build Commands

Command Description
build Using the concurrently package, runs build:server and build:bundle.
build:server Executes Babel to transpile ES6 Server source files
build:bundle Executes One App Bundler to build Browser assets
build:artifacts:statics Runs Static Assets Script for Integration Tests
build:prod-sample Runs build:sample-modules and runs the Build One App Docker Setup Script for Integration Tests
build:sample-modules Builds 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

Flag Description
--archive-built-artifacts Runs 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

Flag Description
--root-module-name Name of the Holocron Module that serves as the entry point to your application.
--module-map-url Remote Module Map URL for one-app-dev-cdn to proxy. For Development.
--use-middleware Apply a custom middleware configuration for one-app-dev-proxy. For Development.
--use-host Use 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

Command Description
clean Executes clean:build and clean:test.
clean:build Removes folders and files related to Babel and Webpack builds.
clean:test Removes Jest Integration Test Report folder.

Test Commands

Command Description
test Runs all test:* scripts.
test:unit Runs all Jest Unit Tests. Accepts Jest flags.
test:lint Runs ESLint rules against source.
pretest:integration Using concurrently, runs build:prod-sample and pulls Docker containers to prepare the Integration Test Suite.
test:integration Executes the Integration Test Suite using Jest.
test:danger Runs the DangerJS tool that returns bundle size stats and a preflight checklist for PRs.
test:git-history Validates the Git commit message format using the commitlint tool.
test:lockfile Validates that the package-lock.json file contains valid NPM registry URLs using the lockfile-lint tool.

📘 More Information

☝️ Return To Top