diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..5eaac196 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + checkCommit: + name: Check Commit + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - id: commit + run: echo "::set-output name=message::${{ github.even.head_commit.message }}" + outputs: + commitMessage: ${{ steps.commit.outputs.message }} + release: + name: Release + needs: [checkCommit] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: '12' + - name: Install Dependencies + run: npm ci + env: + NODE_ENV: development + - name: Test Packages + run: npm run test + - name: Release Packages + env: + NODE_ENV: production + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: |- + echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> $HOME/.npmrc 2> /dev/null + npm run lerna:deploy -- "${{ need.checkCommit.outputs.commitMsg }}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..afcb6d27 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + node: [ '10.x', '12.x', '14.x' ] + name: Node ${{ matrix.node }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - name: Install Dependencies + run: npm ci + env: + NODE_ENV: development + - name: Unit Tests + run: npm test + - name: Git History Test + run: npm run test:git-history + - name: Lockfile Lint Test + run: npm run test:lockfile + - name: Lint + run: npm run test:lint diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7be97f9c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: node_js -node_js: - - 10 - - 12 - - 14 -cache: - directories: - - node_modules -before_install: - # Create a main branch for commitlint - # https://github.com/conventional-changelog/commitlint/issues/6 - - git remote set-branches origin main && git fetch -before_deploy: - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> $HOME/.npmrc 2> /dev/null -jobs: - include: - # Define the release stage that publishes lerna to npm - - stage: release - deploy: - on: - branch: main - provider: script - skip_cleanup: true - script: - - npm run lerna:deploy -- "${TRAVIS_COMMIT_MESSAGE}" diff --git a/packages/one-app-runner/__tests__/bin/__snapshots__/one-app-runner.spec.js.snap b/packages/one-app-runner/__tests__/bin/__snapshots__/one-app-runner.spec.js.snap index c96b8909..79e060f1 100644 --- a/packages/one-app-runner/__tests__/bin/__snapshots__/one-app-runner.spec.js.snap +++ b/packages/one-app-runner/__tests__/bin/__snapshots__/one-app-runner.spec.js.snap @@ -4,37 +4,20 @@ exports[`--modules option is required if --dev-endpoints option is given 1`] = ` Array [ Array [ "Options: - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from - [string] - --root-module-name name of the module to serve as an entry point to - your application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to - use for Parrot mocking [string] - --modules path to local module to serve to One App [array] - --dev-endpoints path to dev endpoints file for One App to use for - its One App Dev Proxy set up [string] - --envVars Environment variables to be applied to the One App - instance - --output-file File to redirect all stdout and stderr from One App - Container to [string] - --create-docker-network Creates a new docker network - [boolean] [default: false] - --docker-network-to-join Connect One App container to a docker network - [string] - --use-host Use req.headers.host instead of localhost for - one-app-dev-cdn [boolean] [default: false] - --offline skip docker pull when the docker registry is not - available / offline [boolean] [default: false] - ----container-name Assign a container name with the --name option + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --help Show help [boolean]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required] + --parrot-middleware path to parrot dev middleware file for One App to use for + Parrot mocking [string] [required]", ], Array [], Array [ - "Missing dependent arguments: - dev-endpoints -> modules", + "Missing required argument: parrot-middleware +https://example.com/module-map.json", ], ] `; @@ -43,33 +26,17 @@ exports[`--modules option is required if --module-map-url option is not given 1` Array [ Array [ "Options: - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from - [string] - --root-module-name name of the module to serve as an entry point to - your application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to - use for Parrot mocking [string] - --modules path to local module to serve to One App - [array] [required] - --dev-endpoints path to dev endpoints file for One App to use for - its One App Dev Proxy set up [string] - --envVars Environment variables to be applied to the One App - instance - --output-file File to redirect all stdout and stderr from One App - Container to [string] - --create-docker-network Creates a new docker network - [boolean] [default: false] - --docker-network-to-join Connect One App container to a docker network - [string] - --use-host Use req.headers.host instead of localhost for - one-app-dev-cdn [boolean] [default: false] - --offline skip docker pull when the docker registry is not - available / offline [boolean] [default: false] - ----container-name Assign a container name with the --name option + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --help Show help [boolean]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required] + --parrot-middleware path to parrot dev middleware file for One App to use for + Parrot mocking [string] + --modules path to local module to serve to One App + [array] [required]", ], Array [], Array [ @@ -89,10 +56,10 @@ Array [ your application [string] [required] --docker-image docker image to use for One App [string] [required] --parrot-middleware path to parrot dev middleware file for One App to - use for Parrot mocking [string] + use for Parrot mocking [string] [required] --modules path to local module to serve to One App [array] --dev-endpoints path to dev endpoints file for One App to use for - its One App Dev Proxy set up [string] + its One App Dev Proxy set up [string] [required] --envVars Environment variables to be applied to the One App instance --output-file File to redirect all stdout and stderr from One App @@ -111,8 +78,8 @@ Array [ ], Array [], Array [ - "Missing dependent arguments: - parrot-middleware -> modules", + "Missing required argument: dev-endpoints +https://example.com/module-map.json", ], ] `; @@ -152,15 +119,13 @@ exports[`command errors out if --dev-endpoints is not given a value 1`] = ` Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -173,15 +138,13 @@ exports[`command errors out if --docker-image option is not given 1`] = ` Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -194,15 +157,13 @@ exports[`command errors out if --docker-image option is not given a value 1`] = Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -215,33 +176,17 @@ exports[`command errors out if --module-map-url option is not given 1`] = ` Array [ Array [ "Options: - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from - [string] - --root-module-name name of the module to serve as an entry point to - your application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to - use for Parrot mocking [string] - --modules path to local module to serve to One App - [array] [required] - --dev-endpoints path to dev endpoints file for One App to use for - its One App Dev Proxy set up [string] - --envVars Environment variables to be applied to the One App - instance - --output-file File to redirect all stdout and stderr from One App - Container to [string] - --create-docker-network Creates a new docker network - [boolean] [default: false] - --docker-network-to-join Connect One App container to a docker network - [string] - --use-host Use req.headers.host instead of localhost for - one-app-dev-cdn [boolean] [default: false] - --offline skip docker pull when the docker registry is not - available / offline [boolean] [default: false] - ----container-name Assign a container name with the --name option + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --help Show help [boolean]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required] + --parrot-middleware path to parrot dev middleware file for One App to use for + Parrot mocking [string] + --modules path to local module to serve to One App + [array] [required]", ], Array [], Array [ @@ -254,15 +199,13 @@ exports[`command errors out if --module-map-url option is not given a value 1`] Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -275,15 +218,13 @@ exports[`command errors out if --modules option is not given any values 1`] = ` Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -296,15 +237,13 @@ exports[`command errors out if --root-module-name option is not given 1`] = ` Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -317,15 +256,13 @@ exports[`command errors out if --root-module-name option is not given a value 1` Array [ Array [ "Options: - --help Show help [boolean] - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --root-module-name name of the module to serve as an entry point to your - application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to use for - Parrot mocking [string]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required]", ], Array [], Array [ @@ -338,36 +275,20 @@ exports[`command errors out if an unknown option is given 1`] = ` Array [ Array [ "Options: - --version Show version number [boolean] - --module-map-url module map for One App to use and fetch modules from - [string] - --root-module-name name of the module to serve as an entry point to - your application [string] [required] - --docker-image docker image to use for One App [string] [required] - --parrot-middleware path to parrot dev middleware file for One App to - use for Parrot mocking [string] - --modules path to local module to serve to One App [array] - --dev-endpoints path to dev endpoints file for One App to use for - its One App Dev Proxy set up [string] - --envVars Environment variables to be applied to the One App - instance - --output-file File to redirect all stdout and stderr from One App - Container to [string] - --create-docker-network Creates a new docker network - [boolean] [default: false] - --docker-network-to-join Connect One App container to a docker network - [string] - --use-host Use req.headers.host instead of localhost for - one-app-dev-cdn [boolean] [default: false] - --offline skip docker pull when the docker registry is not - available / offline [boolean] [default: false] - ----container-name Assign a container name with the --name option + --help Show help [boolean] + --version Show version number [boolean] + --module-map-url module map for One App to use and fetch modules from [string] - --help Show help [boolean]", + --root-module-name name of the module to serve as an entry point to your + application [string] [required] + --docker-image docker image to use for One App [string] [required] + --parrot-middleware path to parrot dev middleware file for One App to use for + Parrot mocking [string] [required]", ], Array [], Array [ - "Unknown arguments: not-a-valid-option, notAValidOption", + "Missing required argument: parrot-middleware +https://example.com/module-map.json", ], ] `; diff --git a/packages/one-app-runner/bin/one-app-runner.js b/packages/one-app-runner/bin/one-app-runner.js index 23f78778..77c6f08e 100644 --- a/packages/one-app-runner/bin/one-app-runner.js +++ b/packages/one-app-runner/bin/one-app-runner.js @@ -65,6 +65,8 @@ const createYargsConfig = () => { }, }) .option('parrot-middleware', { + // eslint-disable-next-line global-require + demandOption: !require('yargs').argv.modules && require('yargs').argv.moduleMapUrl, describe: 'path to parrot dev middleware file for One App to use for Parrot mocking', type: 'string', coerce: (value) => { @@ -88,6 +90,8 @@ const createYargsConfig = () => { }, }) .option('dev-endpoints', { + // eslint-disable-next-line global-require + demandOption: !require('yargs').argv.modules && require('yargs').argv.moduleMapUrl, describe: 'path to dev endpoints file for One App to use for its One App Dev Proxy set up', type: 'string', coerce: (value) => { @@ -138,10 +142,6 @@ const createYargsConfig = () => { describe: 'Assign a container name with the --name option', type: 'string', }) - .implies({ - 'parrot-middleware': 'modules', - 'dev-endpoints': 'modules', - }) .strict() .help();