0.16.0 • Published 6 years ago

roboter-server v0.16.0

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

roboter

roboter streamlines software development by automating tasks and enforcing conventions.

roboter

Status

CategoryStatus
Versionnpm
DependenciesDavid
Dev dependenciesDavid
BuildCircleCI
LicenseGitHub

Upgrading

From 8.x to 9.x

roboter 9.x dropped support for the --watch flag in the analyse and test commands, because it was unreliable and sometimes caused problems in CI/CD environments.

From 7.x to 8.x

roboter 8.x introduces a build command, which replaces the precompile command.

From 6.x to 7.x

roboter 7.x introduced support for TypeScript, but at the same time dropped support for Babel. However, TypeScript support is completely optional. If you want to use TypeScript, simply put a tsconfig.json file into the root of your package, and that's it (especially, you do not have to install TypeScript, since roboter includes TypeScript out of the box). The tests' pre and post tasks are now expected to be standalone executables instead of modules exporting async functions.

From 5.x to 6.x

roboter 6.x received a major update with respect to the ESLint rules being used. That means that when you update you should be prepared to adjust some code analysis issues in your code. Additionally, you need to change the name of the ESLint configuration module in your .eslintrc.json file: The new base name is now es/node (was es/2015/server), if you are working on a client project it's es/browser (was es/2015/client).

From 4.x to 5.x

roboter 5.x names the directory for unit tests unit, not units, to streamline things with integration and performance. This means that you need to rename the units directory to unit in your projects.

From 3.x to 4.x

roboter 4.x slightly modifies the way it generates Table of Contents inside your README.md during the publish task. It is no longer necessary to add a <!-- toc --> tag your README.md. Instead add a heading called Table of Contents and roboter will insert a TOC below this headline. For more details refer to the section Generating the TOC

From 2.x to 3.x

roboter 3.x makes the license task fail if incompatible licenses were found. This means that you may need to adjust your build scripts, if you use the license task directly (you may have to ignore the exit code).

From 1.x to 2.x

roboter 2.x introduces babel 7. If you have been using the precompilation feature of the release task, you might need to take action. If you've been using a local .babelrc make sure to upgrade it to the scoped package names of babel 7. If you have been using babel-runtime as a dependency in your module, also make sure to switch to the new scoped @babel/runtime module.

Please refer to the babel upgrading guide and the new precompile task that has been introduced to verify the precompilation result before a release.

Installation

$ npm install roboter --save-dev

Please note: Never install roboter globally, but always into the local context of your module or application.

Quick start

To run roboter, execute the following command:

$ npx roboter

Since you will run this command quite often, you may want to setup a shorter alias. To do so, add the following line to your profile file, such as .profile (or the respective file of your platform):

alias bot='npx roboter'

Then you can simply run bot instead of npx roboter. In the following we will assume that you have not setup an alias like this.

Quick start

roboter provides a variety of tasks. To run them, run roboter and provide the task's name as parameter:

NameDescription
analyseRuns code analysis.
buildBuilds a project using TypeScript.
depsChecks for missing, outdated, and unused dependencies.
helpShows the help.
licenseChecks dependencies for incompatible licenses.
qaRuns code analysis, tests and checks dependencies.
releaseReleases a new version.
testRuns tests.
updateUpdates the Node.js version.

If you don't specify a task, the qa task is run as default task.

To get help, run npx roboter --help. To get help for a specific command, run npx roboter <command> --help.

If you need more detailed output, provide the --verbose flag for any command.

Running npm scripts

If your package.json file contains custom scripts, you can run them using roboter to have a streamlined user experience. Supposed, your package.json looks like this:

{
  "scripts": {
    "analyse-css": "..."
  }
}

Then you can run the following command. If you specify any options, they will be handed over to the script:

$ npx roboter analyse-css

Setting environment variables

Environment variables you specify when running roboter are also available to the tasks. E.g., if you want to run tests with disabled TLS verification, run roboter as follows:

$ NODE_TLS_REJECT_UNAUTHORIZED=0 npx roboter test

The analyse task

This task runs code analysis on your code using ESLint. By default it uses the rules defined in the eslint-config-es module.

Flags

None

Exit codes

Exit codeDescription
0Success
1Code analysis failed

Details

Code analysis affects all .js, .jsx, .ts and .tsx files, but skips the following directories:

  • node_modules (nested)
  • build (only top-level)
  • coverage (only top-level)
  • dist (only top-level)

To exclude other files or directories, add an .eslintignore file to the root directory of your module or application.

To adjust the ESLint rules to be used, add an .eslintrc.json file to the root directory of your module or application. You may extend the built-in es/node configuration if you only need to change a few rules:

{
  "extends": "es/node",
  "rules": {
    "eqeqeq": 0
  }
};

The build task

If you want to use TypeScript, add the required tsconfig.json file to the root of your package to enable compilation on build.

Please note that you do not need to install TypeScript itself, as this is provided by roboter out of the box.

Any build options are configured using the aforementioned tsconfig.json file.

Flags

None

Exit codes

Exit codeDescription
0Success
1Build failed

Please note that missing, outdated, or unused dependencies do not lead to an erroneous exit code. This is by design, since these situations are typically not critical, and you may want to ignore them intentionally.

Details

None

The deps task

This task checks for missing, outdated, and unused dependencies.

Flags

None

Exit codes

Exit codeDescription
0Success

Please note that missing, outdated, or unused dependencies do not lead to an erroneous exit code. This is by design, since these situations are typically not critical, and you may want to ignore them intentionally.

Details

Under some circumstances, dependencies are reported as unused, although they are actually being used. This can be caused by dynamic requires, or similar things.

If you experience such a situation, feel free to ignore the warnings.

The license task

This task checks your dependencies for incompatible licenses.

Flags

None

Exit codes

Exit codeDescription
0Success
1Incompatible licenses found

Details

roboter tries to get your dependencies' licenses from their respective package.json files and, if necessary, from a variety of other places, and tries to check the license compatibility based on a compatibility chart and a license list.

If you encounter a license incompatibility, and think that it should be fixed, please submit a pull request for either the compatibility chart or the license list.

Please note: Consider the license compatibility check of roboter only to be a suggestion, not as legal advice you can rely on. If you want to be on the safe side, consult a lawyer. the native web does not provide any warranty of any kind.

To disable the license check, omit the license field in your package.json file, or set it to the value UNKNOWN.

The qa task

This task runs the tasks analyse, test, and deps sequentially.

Flags

None

Exit codes

Exit codeDescription
0Success
1Code analysis or tests failed

Please note that missing, outdated, or unused dependencies do not lead to an erroneous exit code. This is by design, since these situations are typically not critical, and you may want to ignore them intentionally.

Details

None

The release task

This task releases a new version.

It first runs the tasks analyse, test, and deps sequentially.

Afterwards, it runs the following tasks:

  • Check if you're currently in the master branch
  • Check if there are any pending, i.e. not yet committed, changes
  • Check if your local master branch is up-to-date with the remote one
  • Optional: Generate the TOC in the README.md file
  • Optional: Build code using TypeScript
  • Increase version number
  • Commit all changes
  • Create a tag for the new version
  • Push all changes and the tag

Please note: This task does not publish your module or application to the npm registry. Instead, you need to do this manually by running npm publish.

Flags

FlagAliasDescription
--force-fReleases without running tests, code analysis etc.
--type-tSpecifies the type of the release, either patch, minor, or major.

Exit codes

Exit codeDescription
0Success
1Code analysis or tests failed

Details

For generating version numbers roboter uses SemVer. It omits the leading v.

Generating the TOC

To automatically generate a TOC for your README.md file add the following line to your README.md.

## Table of Contents

Please note: roboter looks for the first heading containing 'Table of Contents', 'toc', or 'table-of-contents'. It removes all following contents until an equal or higher heading is found and inserts a table of contents.

Building the code before releasing

You can use roboter to automatically build your code before publishing. roboter will run the build task automatically for you. For details on how to enable and to configure this build step, see the build task.

The test task

This task runs unit, integration, and other tests using Mocha.

Flags

FlagAliasDescription
--type-tThe test type, such as units, integration, …

Exit codes

Exit codeDescription
0Success
1Tests failed

Details

roboter will look for test types in the test directory of your module or application. You can add a type by simply creating a directory with the desired name, e.g. unit, integration, performance, …

Creating tests

To create tests, add files with the naming schema *Tests.js (or *Tests.ts, if you use TypeScript) to your test type directories. Use Mocha's tdd interface when writing tests. Please also note that all your tests must be asynchronous, i.e. they must either use the done callback or use the async keyword:

// test/integration/databaseTests.js

suite('connect', () => {
  test('connects to the database.', async () => {
    // ...
  });
});

The test types are run in a specific order. If present, roboter will first run unit, integration, e2e, and performance. After those test types, all remaining ones will be run in alphabetical order.

Using shared test helpers

If you want to use functions shared across multiple tests or test types, create a directory test/shared and put your code into it. This directory is handled as a special case and will not be picked up as a test type.

Setting up and tearing down test types

If you need to register any additional pre or post actions (such as starting or stopping Docker containers, …) that shall be run before or after all tests of a given type, add a pre.js respectively a post.js file (or pre.ts and post.ts, if you use TypeScript), that act as standalone modules. If you want to use async and await, you have to wrap the file's content in an asynchronous IIFE:

'use strict';

(async () => {
  // ...
})();

Please note: The post.js respectively post.ts file will be run no matter whether the tests themselves were run successfully or not.

Setting environment variables

To set environment variables that are available in the tests, you can create a .env file per test type:

SOME_ENV=foo

Configuring test execution

To adjust test execution, you can provide a mocha.opts file per test type. However, the following options can not be overwritten, and are always set:

  • --async-only
  • --bail
  • --colors
  • --exit
  • --ui tdd

The update task

This task updates the Node.js version to the latest available LTS version as long as it is newer than the currently used version, commits it and optionally pushes the changes.

I.e. if you're on version 8.2.0, it will update to the latest LTS (at the time of writing 10.16.3). But if you're on 12.11.0 (the most current version at the time of writing), it won't change anything.

Flags

FlagAliasDescription
--no-push-pPrevents pushing the changes.
--node-nWhether Node.js should be updated. True by default, currently has no effect.

Exit codes

Exit codeDescription
0Success (either updates were made or were not necessary)
1Update failed

Running the tests

To run the tests run the following command:

$ npm run test

You can run all integration tests for one task by specifying the task name as an additional argument:

$ npm run test release

You can run a single integration test case by specifying the individual test as an additional argument:

$ npm run test release/bumps-minor-version

Running the build

Unfortunately, this module can not be used to build itself. Hence you have to use npm for that.

To analyse the source code run the following command:

$ npm run analyse

To release a new version run the following command:

$ npm run release-patch

Alternatively you may also use release-minor and release-major, depending on the changes you have made.

0.16.0

6 years ago

0.15.6

6 years ago

0.15.5

6 years ago

0.15.4

7 years ago

0.15.3

7 years ago

0.15.2

7 years ago

0.15.1

7 years ago

0.15.0

7 years ago

0.14.11

7 years ago

0.14.10

7 years ago

0.14.9

7 years ago

0.14.8

7 years ago

0.14.7

7 years ago

0.14.6

7 years ago

0.14.5

7 years ago

0.14.4

7 years ago

0.14.3

7 years ago

0.14.2

7 years ago

0.14.1

7 years ago

0.14.0

7 years ago

0.13.17

7 years ago

0.13.16

7 years ago

0.13.15

7 years ago

0.13.14

7 years ago

0.13.14-0

7 years ago

0.13.13-0

7 years ago

0.13.12

7 years ago

0.13.11

7 years ago

0.13.10

7 years ago

0.13.9

7 years ago

0.13.8

7 years ago

0.13.7

7 years ago

0.13.6

7 years ago

0.13.5

8 years ago

0.13.4

8 years ago

0.13.3

8 years ago

0.13.2

8 years ago

0.13.0

8 years ago

0.12.4

8 years ago

0.12.3

8 years ago

0.12.2

8 years ago

0.12.1

8 years ago

0.12.0

8 years ago

0.11.16

8 years ago