Giter VIP home page Giter VIP logo

roboter's Introduction

roboter

roboter streamlines software development by automating tasks and enforcing conventions.

roboter

Status

Category Status
Version npm
Dependencies David
Dev dependencies David
Build GitHub Actions
License GitHub

Installation

$ npm install roboter

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:

Name Description
analyze Runs code analysis.
build Builds a project using TypeScript.
deps Checks for missing, outdated, and unused dependencies.
help Shows the help.
license Checks dependencies for incompatible licenses.
qa Runs code analysis, tests and checks dependencies.
test Runs tests.

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.

The analyze task

This task runs code analysis on your code using ESLint and npm-package-json-lint. By default it uses the rules defined in the eslint-config-es module and the npm-package-json-lint-config-tnw module.

Flags

None

Exit codes

Exit code Description
0 Success
1 Code analysis failed

Details

The ESLint 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 npm-package-json-lint analysis only affects the package.json file in the root of your project. It is currently not possible to analyze package files in other locations.

To adjust the rules to be used, add an .npmpackagejsonlintrc.json file to the root directory of your module or application. You may extend the npm-package-json-lint-config-tnw/app.json configuration, the npm-package-json-lint-config-tnw/lib.json configuration or any configuration you have made yourself.

In addition to the linting provided by npm-package-json-lint, roboter checks the license provided by you against the SPDX license list. The default behavior is to reject licenses that are not present on the list, as well as deprecated licenses. If you wish to use a more exotic license that is not listed by SPDX, you may set allowUnsupportedLicenseForThisPackage to true in licenseCheck.json. Deprecated licenses can be enabled in a similar way by setting allowDeprecatedLicenseForThisPackage to true in licenseCheck.json.

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 code Description
0 Success
1 Build 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 code Description
0 Success

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 code Description
0 Success
1 Incompatible 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.

Since license compatibility is a difficult issue and depends very much on the situation, your willingness to take risks and your lawyers interpretation of license law, you need to configure which licenses you deem compatible to your project yourself. To do so, create a licenseCheck.json file in the root of your project with this general layout:

{
  "compatibleLicenses": [
    "MIT",
    "Apache-2.0",
    ...
  ]
}

The list of compatible licenses most contain only valid SPDX-expressions.

If one of your dependencies does not specify its license in a valid format and the roboter can not read it, or if you have a license agreement with someone that is not reflected in their package manifest, you can override any package's license in your licenseCheck.json file:

{
  "compatibleLicenses": [ ... ],
  "knownPackageLicenses": {
    "<package-name>": {
      "<package-version-semver>": "<license SPDX-expression>"
    }
  }
}

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 licenseCheck.json file in your application root.

The qa task

This task runs the tasks analyze, test, deps, and license sequentially.

Flags

None

Exit codes

Exit code Description
0 Success
1 Code 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 test task

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

Flags

Flag Alias Description
--type -t The test type, such as unit, integration, …
--no-bail -b Runs all tests, withouth bailing after failing tests.
--watch -w Starts the tests in watch mode and reruns tests on file changes.
--grep -g Filters tests to run according to a given regexp.

Exit codes

Exit code Description
0 Success
1 Tests 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, create a pre.js and/or a post.js file (or pre.ts and post.ts, if you use TypeScript) in the according test type folder. If you want to run some actions before or after all test types, create a pre.js / post.js / pre.ts / post.ts in the test folder.

Each of these files needs to default export a function that matches one of the ...Script types the roboter exports. The function exported from a pre.ts file must match the type TestPreScript and take the TestPreScriptParameters and vice versa.

import { TestPreScript, TestPreScriptParameters } from 'roboter';

const script: TestPreScript = async function (parameters: TestPreScriptParameters): Promise<void> {
  // ...
}

export default script;

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

Exemplary, for a project with the test types unit, integration and e2e, the scripts are run in this order:

  • global pre script
    • unit pre script
      • unit tests
    • unit post script
    • integration pre script
      • integration tests
    • integration post script
    • e2e pre script
      • e2e tests
    • e2e post script
  • global post script

All these scripts receive some parameter as seen in the TypeScript types. These parameters are especially relevant for the watch mode:

When running the tests in watch mode, the scripts are run for every test iteration. I.e. if you change a file and tests need to be re-run, all relevant scripts are executed. Their parameters change with every execution, since they receive a running count of the amount of test iterations since watch mode was started. This way you can write your scripts so that they only execute your setup / teardown logic when you really need them to.

Returning values from pre-scripts and accessing them

The global preTscript as well as the individual pre-scripts may return arbitrary objects (not primitive values!) as can be seen in the TestPreScript type signature.

The returned objects from the global pre-script and the individual pre-scripts are available to the corresponding post-scripts via the preScriptData property. This is useful if, for example, you want to start a docker container before running your tests and to avoid collision include a random string in its name. This random string is then necessary in the post-script to cleanly stop and remove the container.

It is also possible to access the values returned by the pre-scripts inside the tests. To make these values available, they are attached to the mocha context of every suite. You can access them like this:

suite('some test suite', function (): void {
    const { someValue } = this.ctx.roboter;
});

The this.ctx.roboter property is an object that contains the merged return values from the global pre-script and the pre-script of the test type to which the suite belongs. The returned object from the test type has precedence in the merge.

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 .mocharc.json or .mocharc.js file per test type. However, the following options can not be overwritten, and are always set:

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

Running quality assurance

Since this is roboter itself, we can't just run npx roboter. But we still want to use roboter to quality test itself. So we run:

$ npm run roboter

You can use all the sub-commands and flags roboter supports.

roboter's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar goloroden avatar grundhoeferj avatar joachimhb avatar scherermichael avatar seal-mt avatar semantic-release-bot avatar simono avatar yeldirium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

roboter's Issues

build-app fails with jsx

Not able to build an react app. Always getting following error during build process.

Module parse failed: .../src/index.jsx Unexpected token (12:2)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (12:2)

Line 12 of index.jsx looks like <div className='screen-wrapper'>

roboter.js build task:

    task('client/build-app', {
      entryFiles: [
        './index.html',
        './index.scss',
        './index.jsx'
      ],
      babelize: [ '.src/' ],
      buildDir: 'build/',
      publicPath: '/'
    });

Using a .babelrc file with following configuration:

{
  "presets": [ "es2015", "react" ]
}

release task does not fully abort 'releasing' in gitcheckpending

Instead of aborting on pending changes, roboter continued bumping the version, not sure if other (git-)-checks have the same problem.

[16:49:38] Starting '_gitcheckpending'...
[16:49:38] '_gitcheckpending' errored after 421 ms
[16:49:38] Error in plugin 'gitcheckpending'
Message:
You have pending changes.
[16:49:38] Finished '_release' after 24 s
[16:49:38] Starting 'gitcheckpending'...
[16:49:38] Finished 'gitcheckpending' after 8.07 μs
...
[16:49:41] Starting '_release-bump-version'...
[16:49:41] Starting 'release'...
[16:49:41] Finished 'release' after 8.43 μs
[16:49:41] Finished '_release-force' after 3.45 s
[16:49:41] Starting 'release-force'...
[16:49:41] Finished 'release-force' after 5.87 μs
[16:49:41] Bumped 0.1.3 to 0.2.0 with type: minor
[16:49:41] Finished '_release-bump-version' after 45 ms

Rerunning 'release --type minor' after fixing the gitpending released the version 0.3.0 in this case.

My setup:
[email protected]

$ npm -v
2.14.2

$ node -v
v4.0.0

Yes, very old versions... :)

make bot publish stop on outdated and unused-dependencies

bot publish runs the analyze tasks, reporting outdated and unused-dependencies.
I wish bot publish would stop if any issues are found in these categories, and there was a flag to publish in spite of those issues. so by default the publish would only succeed on no issues.

The typecheck of `roboter analyze` requires an output configuration in `tsconfig.json`.

I found this bug when bootstrapping a Next.js application using create-next-app.

The generated tsconfig.json does not contain any output paths and roboter fails during analyze with the error message:

✗ Failed to run type check.
  Error: Type script output configuration missing.

I will add a link to the project once it's published.

IMHO the type check should not require tsconfig.json to be configured to output any files from compilation, because that is dependent on the project.

Search shell commands also in current project's node_modules/.bin folder

Another convenient feature of npm is that it automatically finds the mongodb-runner script which is stored in node_modules/.bin. I tried to add some universal/shell tasks

    task('universal/shell', {
      pretest: 'mongodb-runner start --topology=standalone --port=27717',
      posttest: 'mongodb-runner stop'
    });

But running bot pretest does not work as expected:

$ bot pretest
[11:02:01] Using gulpfile ~/code/sealsystems/node-mongo/roboter.js
[11:02:01] Starting 'pretest'...
/bin/sh: mongodb-runner: command not found
[11:02:01] 'pretest' errored after 95 ms
[11:02:01] Error in plugin 'pretest'
Message:
    Failed to execute.

eslint-plugin problem with node 8/ npm 5

There is a problem with eslint-plugins when using roboter with node 8/ npm 5.

To reproduce, download the attached file.

The first is to show how it works correctly using node 6/ npm 3.10.10:

tar xvf eslinttest.tar
cd eslinttest
nvm use 6.10.3  # with npm 3.10.10
npm install
eslint test.js
# -> 3:7  error  Unexpected exclusive mocha test  mocha/no-exclusive-tests

now try the same with node 8/ npm 5:

rm -rf node_modules
nvm use 8.1.3 # with npm 5.2.0
npm install
eslint test.js
# no errors

so why is that?

it can be fixed by installing the eslint-plugin-mocha on the top level (even though the identical version is already installed as part of roboter).

npm install --save-dev [email protected]
eslint test.js
# ->  3:7  error  Unexpected exclusive mocha test  mocha/no-exclusive-tests

so that indicates to me that eslint is unable to find it's plugin if they are installed as part of roboter only.

I'm still submitting this to roboter, as this is the tool we're using to install the linting environment, and it should bring what's needed, or document what needs to be installed to make it run correctly.

bot publish throws stacktrace on pending changes

bot publish with uncommitted changes ends with an output like:

[08:49:19] Error in plugin 'gitcheckpending'
Message:
You have pending changes.
[08:49:19] '_release' errored after 9.49 s
[08:49:19] Error in plugin 'run-sequence(_gitcheckpending)'
Error
at finish (/home/stheine/js/audit-server/node_modules/run-sequence/index.js:56:13)
at Gulp.onError (/home/stheine/js/audit-server/node_modules/run-sequence/index.js:67:4)
at emitOne (events.js:101:20)
at Gulp.emit (events.js:188:7)
at Gulp.Orchestrator._emitTaskDone (/home/stheine/js/audit-server/node_modules/orchestrator/index.js:264:8)
at /home/stheine/js/audit-server/node_modules/orchestrator/index.js:275:23
at finish (/home/stheine/js/audit-server/node_modules/orchestrator/lib/runTask.js:21:8)
at cb (/home/stheine/js/audit-server/node_modules/orchestrator/lib/runTask.js:29:3)
at Gulp.gulp.task.done (/home/stheine/js/audit-server/node_modules/roboter/lib/tasks/universal/gitcheckpending/index.js:16:14)
at module.exports (/home/stheine/js/audit-server/node_modules/orchestrator/lib/runTask.js:34:7)

Make compatible licenses configuration optional

Since the licenseCheck.json configuration file is now used for two different checks - the license compatibility and the validation of the license in the project's package.json file - the field compatibleLicenses should now be optional.

If I only create the file to set the flag allowUnsupportedLicenseForThisPackage to disable the strict license validation, I should not be forced to configure the license compatibility as well. The license compatibility check should use the same defaults which it uses if no file exists at all.

remove dependency on babel

Optional: Precompile code using Babel

for this, you include babel

  "dependencies": {
    "babel-cli": "6.26.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-polyfill": "6.26.0",
    "babel-preset-env": "1.6.1",

but due to the versions in there, it prevents me from upgrading my project to @babel/core@7 with @babel/preset-env@7. (well, I can upgrade, but it will fail due to the mix of babel@6 and babel@7).

can you find a way to remove that hard dependency, and maybe switch to a peer dependency only? that would allow me to upgrade my project and continue, since I'm not using roboter's babel functionality anyhow.

roboter does not support React 16

Hi Golo,

roboter does not support React 16 (in bot watch-app) as it's using totally outdated versions of webpack-dev-server and the related packages.

I know you're working on a rewrite... and are not motivated to work on roboter. still this is an issue for us, since we'd like to use roboter for this in spite of configuring webpack on our own in all projects.

I can't do a pull request, since the roboter build process is magic for me... I can't simply fork and test, since the roboter-client (that needs the main updates) is somehow generated and automatically published on npm.

I have a working webpack configuration for React 16 running here.

please let me know if you're willing to spend some time on roboter for these updates (or if there is an ETA for the new roboter with the needed functionality).
or if you can provide assistance for me to understand how roboter can be build and tested by me, so I could fix the code and create a PR.

Regards
Stefan

latest git version on windows can't perform certain release steps anymore

When using bot release this command fails to:

  • add the new release tag to github
  • push package.json with new release number to github.

This happens on windows with latest git version 2.16.1.windows.2 (taken from https://git-scm.com/download/win) and roboter 0.15.6

In the processing output there is a fatal error:

Starting '_release-commit'...
fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

When downgrading to git version 2.11.1.windows.1 it works, though it already gives a warning:

Starting '_release-commit'...
[master 6f53d1b] Release 0.1.6.
1 file changed, 1 insertion(+), 1 deletion(-)
warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths

Why does `test -w` not run the tests at start?

When I execute npx roboter test -w, I don't see that any tests being executed. Only after saving. It would be nice if first the are executed and then watching the files.
Version: 1.0.7

Colorize analyse results

What is this feature about?

In the past, when we ran ESLint as child process, there was colored output if something went wrong. Of course, colored output is not an end in itself, but it improved readability of long linting results. Since 12.0.0 we don't have this colored output any more, but it would be nice to have it again 😉

What needs to be done to implement this feature?

  • Figure out how to colorize ESLint results
  • Enable colored output again

Check of tsconfig.json don't recognised extendes config

Node.js version: 14.17.4
Roboter version: 12.3.0


In my tsconfig.json I extend another tsconfig.json which is located in a parent folder.

The tsconfig.json looks like this:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "jsx": "preserve",
    "allowJs": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "isolatedModules": true
  },
  "extends": "../tsconfig.json"
}

When I run npx roboter I get the following result:

▸ Running code analysis...
✗ Failed to run type check.
Error: Type script output configuration missing.

In my tsconfig.json there is no option compilerOptions.outDir. The tsconfig.json I extend has this option.
When I add the option compilerOptions.outDir in the tsconfig.json everything runs fine.

I think the following check causes this error:

if (!tsconfig.compilerOptions || !tsconfig.compilerOptions.outDir) {

Exiting long running commands like analyse or build does not end child processes.

What is this bug about?

When executing long running tasks that use shelljs to spawn child processes like for example build, we currently do not exit these child processes when the main roboter process is exited by the user.

What is the expected result?

All child processes should be stopped as well when the user exits a command.

What is the actual result?

roboter does not end child processes when exiting the current task with Ctrl-C.

What steps are needed to reproduce the bug?

  • Start a long running build or analyse process
  • Hit Ctrl-C
  • Monitor the currently running Node processes (e.g. using the ActivityMonitor on macOS) to see the child process being still active

What else should we know?

In most of the use cases this is not a problem. However if the TypeScript compilation or the eslint analysis gets stuck, it is possible produce hanging processes.

The runCommand module is responsible for executing commands. We already have a blueprint for cleaning up child processes in the run-fork module. It looks like we should be able to apply the same kind of behaviour inside runCommand.

CC-BY/Artistic licenses and Compatibility

Hi Native Web folk,

I love the idea of the project. I'm a big believer that users should not be surprised when using a project to discover a dependency has a surprising license. My background is with Apache's licensing committee and OSPOs (currently a member of the AWS OSPO), so worrying about user surprise is common for me.

I wanted to question both Artistic and CC-BY being considered compatible for the permissive licenses in https://github.com/thenativeweb/roboter/blob/main/licenseCheck.json - I noticed this when seeing a roboter.js file that was considering the spdx of "MIT AND CC-BY-3.0" to be compatible with MIT.

Both of those licenses have concepts that go beyond the classic permissive licenses and may be considered a surprise. As an easy example, the Apache Software Foundation does not consider them to be akin to Apache-2.0 ( https://www.apache.org/legal/resolved.html ).

There are a lot more SPDX codes that I believe you can consider permissive-compatible; Apache's site above lists some and I can list more if you'd be interested.

AGPL is not recognised by code analysis.

I use roboter version 12.0.0.

In my package.json the license field looks like this:
"license": "AGPL-3.0-or-later".
The string "AGPL-3.0-or-later" is the SPDX license ID for the GNU Affero General Public License v3.0 or later.

When I run npx roboter I get the following result:

────────────────────────────────────────────────────────────────────────────────
▸ Running code analysis...
./package.json
  error    Invalid value for license  (license)

✖ 1 problems (1 errors, 0 warnings)

✗ Malformed package.json found.

It seams that roboter did not recognise the license as a valid license.

Add an option to disable debug messages

It would be nice if there was an option to turn off these debug messages:

[10:02:43] Finished '_test-units' after 189 ms
[10:02:43] Starting 'test-units'...
[10:02:43] Finished 'test-units' after 24 μs
[10:02:43] Starting '_test-integration'...
[10:02:43] Finished '_test-integration' after 342 μs
[10:02:43] Starting 'test-integration'...
[10:02:43] Finished 'test-integration' after 2.89 μs
[10:02:43] Finished '_test' after 194 ms
[10:02:43] Starting 'test'...
[10:02:43] Finished 'test' after 1.65 μs

The analyze task can't find the package.json file if it contains a syntax error

When I run the roboter via npx roboter in a project that has syntax errors in its package.json-file, the roboter crashes with this error:

# npx roboter
────────────────────────────────────────────────────────────────────────────────
▸ Running code analysis...
  Error: Package json missing.
(stacktrace omitted)

This is because potential errors during JSON parsing of the file are not handled individually and are reported as the file missing:

try {
const packageJsonContent = await fs.promises.readFile(path.join(absoluteDirectory, 'package.json'), 'utf-8');
const packageJson: PackageJson = JSON.parse(packageJsonContent);
return value(packageJson);
} catch (ex: unknown) {
return error(new errors.PackageJsonMissing({ cause: ex }));
}

Automatically fix the order of properties in `package.json` during `qa`.

We enforce a consistent order of properties in package.json by linting.
Unfortunately, the linter aborts after encountering the first out of place property, making fixing the ordering very tedious.
Re-ordering JSON is also not very ergonomic, as it handles line permutations poorly.

During qa, we should automatically re-order package.json to conform to our standard.

Not working with npm workspaces?

It seems not to work in combination with workspaces.
Snippet from <projectroot>/package.json:

  "workspaces": [
    "packages/*"
  ]

roboter is installed in the <projectroot>/node_modules, so this works in project root folder:

npx roboter --help

Running the following command in the same folder:

npm exec --workspace=packages/backend -- roboter --help

throws an error:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_FILE_URL_HOST]: File URL host must be "localhost" or empty on darwin
    at new NodeError (node:internal/errors:371:5)
    at getPathFromURLPosix (node:internal/url:1397:11)
    at fileURLToPath (node:internal/url:1420:50)
    at finalizeResolution (node:internal/modules/esm/resolve:395:16)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ESMLoader.import (node:internal/modules/esm/loader:276:22)
    at initializeLoader (node:internal/process/esm_loader:74:49) {
  code: 'ERR_INVALID_FILE_URL_HOST'
}

roboter broken after webpack upgrade

After upgrading to webpack 4.0.1, roboter is completely broken.

every call to bot fails with:

/home/stheine/js/quixy/node_modules/webpack/lib/webpack.js:159
                        throw new RemovedPluginError(errorMessage);
                        ^

Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.
    at Object.get [as UglifyJsPlugin] (/home/stheine/js/quixy/node_modules/webpack/lib/webpack.js:159:10)
    at getWebpackConfiguration (/home/stheine/js/quixy/node_modules/roboter/lib/tasks/client/build-app/index.js:82:28)
    at buildApp (/home/stheine/js/quixy/node_modules/roboter/lib/tasks/client/build-app/index.js:90:32)
    at Object.keys.filter.forEach.taskName (/home/stheine/js/quixy/node_modules/roboter/lib/roboter.js:75:7)
    at Array.forEach (<anonymous>)
    at Roboter.start (/home/stheine/js/quixy/node_modules/roboter/lib/roboter.js:68:5)
    at Object.<anonymous> (/home/stheine/js/quixy/roboter.js:173:4)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)

this is caused by the line:
https://github.com/thenativeweb/roboter/blob/master/lib/tasks/client/build-app/index.js#L82

is there a simple way to prevent that from being called by some config in roboter.js? we don't use the build-app task at all, but we would like to use other tasks of roboter.

Reflect is not defined

I just wanted to try the module. After installing roboter in a project, installing the cli module globally and creating a roboter.js file in the project, running bot results in the following exception:

./node_modules/roboter/lib/tasks/universal/coverage/index.js:32
  Reflect.deleteProperty(configuration, 'threshold');
  ^

ReferenceError: Reflect is not defined
    at userConfiguration (./node_modules/roboter/lib/tasks/universal/coverage/index.js:32:3)
    at ./node_modules/roboter/lib/roboter.js:57:5
    at Array.forEach (native)
    at Roboter.useFolder.Roboter.start.Object.keys.forEach [as start] (./node_modules/roboter/lib/roboter.js:50:27)
    at Object.<anonymous> (./roboter.js:7:3)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

I can't find any other occurrence of 'reflect' anywhere else in the project.

watch-app should support https

today, roboter watch-app only starts an http hosted webpack server.

due to the authentication built into our applications, the application must run with https, due to the need to secure cookies.

can you please enhance roboter to allow an optional setting of https set in roboter.js, and pass this into roboter/lib/tasks/client/watch-app/index.js to set into the new WebpackDevServer( configuration?

see: https://webpack.js.org/configuration/dev-server/#devserver-https

Error with command `analyse` on Windows Machines

When running npx roboter analyse on a windows machine, we got the following error:

Running code analysis...
Oops! Something went wrong! :(
ESLint: 7.13.0
No files matching the pattern "'release.config.js'" were found.
Please check for typing mistakes in the pattern.
✗ Malformed code found.
─────────────────────────────────────────────────────────────────────────────────────────────────────── Code malformed.
AnalysisFailed: Code malformed.
at analyseTask (C:\dev\demo-project\node_modules\roboter\lib\cli\tasks\analyse.js:25:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.run (C:\dev\demo-project\node_modules\roboter\lib\cli\commands\qa.js:38:5)
at async C:\dev\demo-project\node_modules\roboter\lib\bin\roboter.js:113:5

The relase.config.js File exists. It seems like the Glob-Pattern is not matching.
The error message also shows additional quotes around the file-name which might be the cause of error.

Check usage of @types dependencies.

Currently (dev-)dependencies to packages providing TypeScript type declarations are always marked as unused. They should actually be checked and only reported as unused, if their declarations are not used anywhere.

In the package we use for this (depcheck) there is an open issue for this.

how to get usage?

the documentation says:

If you want to get an overview of all available tasks, simply run bot without any parameters.
$ bot

but in fact, if I simply call 'bot', it executes the configured tasks.

but it's also not answering on 'bot --help'.

please add function to get the usage, and update the documentation.

Test Watch-Mode crashes on syntax errors

When using npx roboter test --watch, the runner crashes everytime there is a syntax error.

As this might happen during development, it would be great if, instead of crashing, it would simpyl show a message and retry whenever changes happen.

Validate license strictly if no configuration file exists

Currently, if no licenseCheck.json configuration file exists, the validation of the license in the package.json file fails, since it cannot load its configuration.

This goes against the core idea that the roboter should "work" without configuration and it also goes against the way the license check configuration file has been used so far in the actual license check, where a missing configuration file only causes a warning.

The goal of this issues is a temporary solution to our configuration problem. We want the roboter to function (albeit with reduce feature-set) if no configuration file is present. This issue proposes a default behavior for the license validation, if no configuration file is present.

In the future we'd like to implement a more holistic approach to configuration, missing configuration, and partial configuration of the roboter.

bot watch-server

while until version 0.13.8 the unit-tests were executed after each file change, in 0.13.9 and 0.13.10 the unit-tests are only executed once.
at least on my windows machine.

Return code in case bot ends without success

When I start 'bot', and one of the messages is:

[12:06:28] Error in plugin 'gitcheckpending'
Message:
You have pending changes.

I would expect the bot command to return with a non-0 exit code to indicate issues.

bot analyze does not handle multiple .eslintrc.json files

I started to create different .eslintrc.json files in my module:

/.eslintrc.json - holding the main project configuration
/tools/.eslintrc.json - holding some specifics that apply to the 'tools' folder only (disabling no-console and no-process-exit)

this is done according to the eslint documentation:
http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy

now, running eslint manually or by the editor-integration, this works ok, applying the different rulesets.

but bot analyze obviously calls eslint in a different way, and applies the main project configuration only. that results in errors being thrown for the files in the tools directory.

bot release in a forked repo with different default branch name

Hi,

I run into a problem with bot release in a forked repo. We have forked a public repo, added roboter to maintain our own releases at NPM in our namespace to be independent from the upstream maintainer release cycles. For forked repos we prefer to keep master the 1:1 copy of upstream/master to be able to send pull requests upstream. Therefore our default branch is different from master, we also changed GitHub's default branch. So a git clone normally clones our maintained branch, in our case the default branch name is sealsystems.

Now bot release has some road blocks for us as these tasks use the fixed master branch name.

  • gitnobehind
[16:54:13] Starting '_gitnobehind'...
fatal: ambiguous argument 'master...origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
[16:54:15] '_gitnobehind' errored after 1.62 s
[16:54:15] Error in plugin 'gitnobehind'
  • release-push
[17:05:44] '_release-push' errored after 10 ms
[17:05:44] Error: Command failed: git push origin master --tags
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:sealsystems/node-ipp'

I manually patched these two files to push a release to NPM:

Any idea how we can make this branch name customizable?

Some more details about my cloned repo:

$ cat .git/config 
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = [email protected]:sealsystems/node-ipp
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "sealsystems"]
	remote = origin
	merge = refs/heads/sealsystems
[branch "eslint"]
	remote = origin
	merge = refs/heads/eslint
$ git branch -a
  eslint
* sealsystems
  remotes/origin/HEAD -> origin/sealsystems
  remotes/origin/eslint
  remotes/origin/master
  remotes/origin/sealsystems
  remotes/origin/streamingclient

A git branch normally doesn't show a local master branch:

$ git branch
  eslint
* sealsystems

roboter fails when installed with react-styleguidist

here's my package json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "fqdn-multi": "0.1.1",
    "react": "15.4.2",
    "react-dom": "15.4.2",
    "react-styleguidist": "4.6.3",
    "roboter": "0.14.4",
    "roboter-client": "0.14.4",
    "webpack": "2.2.1"
  }
}

and the roboter.js:

'use strict';

const path    = require('path');

const roboter = require('roboter');
const fqdn    = require('fqdn-multi');

roboter
  .workOn('client')
  .equipWith(task => {
    task('universal/analyze', {
      src: ['src/**/*.js', 'src/**/*.jsx'],
      rules: '.eslintrc.json'
    });

    task('universal/test-units', {
      babelize: true,
      src: ['test/units/*Tests.js']
    });

    task('client/watch-app', {
      babelize: [
        path.join(process.cwd(), 'src/')
      ],
      host: fqdn(),
      port: 8888
    });

    task('client/build-app', {
      babelize: [
        path.join(process.cwd(), 'src/')
      ]
    });
  })
  .start();

when calling bot, this fails with the error:

/home/stheine/js/test/node_modules/roboter/lib/tasks/client/build-app/index.js:67
      new webpack.optimize.OccurenceOrderPlugin(),
      ^

TypeError: webpack.optimize.OccurenceOrderPlugin is not a constructor
    at getWebpackConfiguration (/home/stheine/js/test/node_modules/roboter/lib/tasks/client/build-app/index.js:67:7)
    at buildApp (/home/stheine/js/test/node_modules/roboter/lib/tasks/client/build-app/index.js:85:32)
    at Object.keys.filter.forEach.taskName (/home/stheine/js/test/node_modules/roboter/lib/roboter.js:75:7)
    at Array.forEach (native)
    at Roboter.start (/home/stheine/js/test/node_modules/roboter/lib/roboter.js:68:5)
    at Object.<anonymous> (/home/stheine/js/test/roboter.js:35:4)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

Multiple analyze scopes.

If you are building a wolkenkit application with server and client in the same project it is currently not possible to lint server and client with different sets of rules.

It would be great if you could apply multiple sets of rules, each with a different src and rules option.

Skipping license check – a good idea?

What is this question about?

I was wondering whether it's actually a good idea to skip the license check if no license configuration file was found. Of course, on the one hand, that's the way it worked before 12.0.0, and you also get a hint in the output.

On the other hand, so far we had a license check, if a license was given in the package.json file. This is not the case any more. Instead, it (more or less silently) gets skipped. And even if you define a license configuration file – you just have to have a typo in the file name, and it will be skipped. That could be critical.

What if we said that you always have to have a license configuration file, which, in doubt, allows you to disable the license check? This way you would be on the much more safe side.

(Another scenario I fear is: Creating a new project, someone forgets to copy over the license configuration file ("we'll do that later…"), and boom, you have introduced a legal problem.

@yeldiRium What do you think?

Support running multiple test types at once

What is this feature about?

When running only the tests of a specific type using

$ npx roboter test --type <…>

it is only possible to select a single type. We should turn this flag to a multi flag, so that you can run more than one test type using a single call.

However, we should make sure that even when multiple types are provided, their order is handled correctly. Additionally, when handing over a type that does not exist, it should fail right from the start, in the same way as if you only provide a single invalid type.

What needs to be done to implement this feature?

  • Turn --type into a multi flag
  • Ensure that tests run in correct order, even when given multiple types
  • Fail if an invalid type is given
    • For single types
    • For multiple types
  • Adjust tests
  • Adjust documentation

`test` command fails with `typescript >= 4.7`

Repo for reproduction: https://github.com/strangedev/temp--roboter-ts-bug

What is happening?

When I install roboter in a fresh repository, use TypeScript, add tests and run them using npx roboter test, roboter crashes and prints a stack trace:

▸ Running tests...
  Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:42537:18)
    at /home/nh/devel/temp--roboter-ts-bug/node_modules/ts-node/src/resolver-functions.ts:131:51
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (/home/nh/devel/temp--roboter-ts-bug/node_modules/ts-node/src/resolver-functions.ts:130:31)
    at actualResolveTypeReferenceDirectiveNamesWorker (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:116674:163)
    at resolveTypeReferenceDirectiveNamesWorker (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:116974:26)
    at processTypeReferenceDirectives (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:118456:31)
    at findSourceFileWorker (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:118341:21)
    at findSourceFile (/home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:118196:26)
    at /home/nh/devel/temp--roboter-ts-bug/node_modules/typescript/lib/typescript.js:118148:85

What do you expect to happen?

Roboter doesn't crash and runs the tests.

What else do we need to know?

Manually installing TypeScript 4.6 fixes the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.