mindsphere / mindconnect-nodejs

NodeJS Library for Industrial IoT Connectivity - TypeScript SDK for Industrial IoT - Command Line Interface - Development Proxy - typescript-sdk is waiting for your contributions!
https://developer.siemens.com/industrial-iot-open-source/index.html
MIT License
68 stars 23 forks source link

npm install not working in powershell #184

Closed coding4funrocks closed 4 years ago

coding4funrocks commented 4 years ago

Describe the bug npm install returns error in poweshell

To Reproduce

'cp' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @mindconnect/mindconnect-nodejs@3.8.3 prepare: `rimraf dist/ && tsc -p ./ --outDir dist/ && cross-env mkdir -p dist/src/cli/commands/html/sc/ && cp -r src/cli/commands/html/sc/* dist/src/cli/commands/html/sc/ && npm run browser:build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @mindconnect/mindconnect-nodejs@3.8.3 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
coding4funrocks commented 4 years ago

I can take care of this too. 👍

sn0wcat commented 4 years ago

Sure @coding4funrocks it is time to do some housekeeping anyhow 😃 . The problem is that the build script is using the cp command which is not running cross platform.

we can use copyfiles package instead

npm install copyfiles --save-dev

after that we should change the scripts to look like this:

 {
        "clean": "rimraf starterts/ && rimraf starterjs/ && rimraf dist/",
        "clean:dist": "rimraf dist/",
        "prepare": "npm run clean && npm run ts:build:dist && npm run copyfiles:dist && npm run browser:build",
        "copyfiles:dist": "copyfiles src/cli/commands/html/sc/* dist/src/cli/commands/html/sc/ --flat",
        "test": "npm run ts:build && mocha --colors --timeout=0",
        "test-dev": "npm run ts:build && cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --reporter=list --timeout=0",
        "mocha-run": "mocha --colors --timeout=0",
        "test-jenkins": "npm run ts:build && cross-env JUNIT_REPORT_PATH=./report.xml mocha --colors --reporter mocha-jenkins-reporter --timeout=0",
        "ts:build": "tsc",
        "ts:build:dist": "tsc -p ./ --outDir dist/",
        "ts:watch": "tsc -w",
        "browser:build": "rollup -c",
        "lint": "tslint ./src/**.ts && tslint ./test/**/*.ts",
        "test:watch": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --watch test/ --growl --reporter=spec --timeout=0",
        "start-dev": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 cross-env concurrently --raw \"npm run ts:watch\" \"npm run test:watch\" ",
        "dev": "npm run ts:build && cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 concurrently --raw \"npm run ts:watch\" \"npm run test:watch\" ",
        "start-agent-dev": "npm run ts:build && cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 cross-env DEBUG=http,mindconnect-agent,mindconnect-fileencoder node ./src/demoagent/test-agent.js ",
        "doc": "compodoc -p tsconfig.json --output docs --name \"@mindconnect/mindconnect-nodejs\" --theme material && npm run copyfiles:doc",
        "copyfiles:doc": "copyfiles images/* docs/",
        "createkey": "openssl genrsa -out private.key 3072",
        "license": "license-checker --csv --onlyAllow \"Apache-2.0; Apache*; BSD; BSD-2-Clause; BSD-3-Clause; ISC; MIT; Unlicense; WTFPL; CC-BY-3.0; CC0-1.0\" --production",
        "license:summary": "license-checker --summary --onlyAllow \"Apache-2.0; Apache*; BSD; BSD-2-Clause; BSD-3-Clause; ISC; MIT; Unlicense; WTFPL; CC-BY-3.0; CC0-1.0\" --production"
    }

I also deleted some left-over docker build scripts from 2017 :)