How to run lerna sequentially? - sequential

Goal
Wish to know how with Lerna to run packages in sequential mode.
Approach
This is learn.json with its packages declaration:
{
"npmClient": "npm",
"npmClientArgs": [
"--registry",
"https://npm.foo.com"
],
"command": {
"publish": {
"ignoreChanges": [
"**/.spec.*",
"**/*.md",
"**/tsconfig*.*"
],
"registry": "https://npm.foo.com"
}
},
"packages": [
"packages/commands/*",
"packages/specs/*",
"packages/support/*",
"packages/tasks/*",
"packages/tools/*"
],
"version": "independent"
}
And in package.json, the following is a sampling of its scripts making lerna run requests:
"audit": "lerna run audit --stream",
"build": "lerna run build --stream",
"clean": "lerna clean",
"postinstall": "lerna bootstrap",
"upgrade": "lerna run npm:upgrade --stream",
"test": "lerna run coverage --stream"
The goal is to modify the package.json script "test" so that lerna runs each of the packages' test sequentially over each of the packages and not in parallel.
And if possible, run tests in a specific order.
How should this "test" script be modified?:
"test": "lerna run test --stream"
lerna run does have a command option --parallel, however, I am experiencing that without this option set, execution is happening asynchronously (parallel):
--parallel Run script with unlimited concurrency, streaming prefixed output.

lerna run --concurrency 1
Global Options:
--concurrency How many processes to use when lerna parallelizes tasks. [number] [default: 10]

Related

How do I pass Cypress arguments to a NPM e2e build job?

How do I pass Cypress arguments to a NPM e2e build job?
I tried something like this but I cannot get variables to expand:
USERNAME=$EMAIL PASSWORD=$SECRET ng e2e --config-file=dev-cypress.config.ts
I also tried this:
ng e2e -- --USERNAME=$EMAIL --PASSWORD=$SECRET --CYPRESS_CONFIG_FILE=dev-cypress.config.ts
ng e2e --USERNAME=$EMAIL --PASSWORD=$SECRET --CYPRESS_CONFIG_FILE=dev-cypress.config.ts
And I tried this:
CYPRESS_CONFIG_FILE=dev-cypress.config.ts USERNAME=$EMAIL PASSWORD=$SECRET ng e2e
What am I missing? Whatever I try, the Cypress "effective configuration" does not expand the env variables correctly (at all)
Here is my build config in my angular.json config:
....
"e2e": {
"builder": "#cypress/schematic:cypress",
"options": {
"devServerTarget": "pas-ng-xdm:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "pas-ng-xdm:serve:production"
}
}
}
NOTE: Using a npx cypress command, that works for me:
"cypress:run:dev": "npx cypress run --config-file dev-cypress.config.ts --record
--key 0000000-e33c-4c88-9ead-1d0000000c --browser chrome --headless",
NOTE 2: When using the ng e2e, my only option is to allow it to load the default cypress.config.ts. Maybe that is ok: perhaps this is working as designed?

Attaching a debugger to a parcel built app

I have my project setup as follows, within my package.json I have the follow:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "parcel ./public/index.html --open",
"build": "parcel build ./public/index.html NODE_ENV=production --no-source-maps --public-url ./public --out-dir ./dist",
"lint": "eslint --ext .js,.vue src --fix"
},
I can start my project by running: npm run:dev which starts as follows:
To debug the "dev" script, make sure the $NODE_DEBUG_OPTION string is specified as the first argument for the node command you'd like to debug.
For example:
"scripts": {
"start": "node $NODE_DEBUG_OPTION server.js"
}
> impcentral#1.0.0 dev /Users/william/imp/src/impCentral
> parcel ./public/index.html --open
Server running at http://localhost:63188 - configured port 1234 could not be used.
As you can tell it does not stop at my break points within WebStorm. I've tried passing in the $NODE_DEBUG_OPTION within the package.json but to no avail.
Any ideas folks, open to trying this in Visual Studio Code too.
You don't need running your NPM configuration in debugger unless you need debugging parcel itself. As your application, served by parcel, is run in browser, you have to use JavaScript Debug run configuration to debug it.
start your app by running npm run dev (either in WebStorm or in terminal)
create a JavaScript Debug run configuration with your server URL (http://localhost:1234, or http://localhost:63188 in your case):
select this configuration and press Debug

Cant get webpack hotreload with create-react-app and docker windows

We are going to develop a react pwa with dockersetup and to publish the app on gitlab pages during deployment to master branch.
I work on a windows device and cant get the feature of hotreloading in dev-mode. Whenever i make some change, the code isnt recompiling. I have to docker-compose up --build every single time for every change.
Is there any possible way to get hotreloading working on a windows/docker/create-react-app setup?
Following the package.json:
{
"name": "Appname",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"buildandserver": "react-scripts build && serve -s build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Now the Dockerfile for Dev-Setup:
FROM node:9.6.1
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install
RUN npm install react-scripts#1.1.1 -g
# start app
CMD ["npm", "start"]
And at least the docker-compose for dev-setup:
version: '3.5'
services:
App-Name:
container_name: App-Name
build:
context: .
dockerfile: devsetup/Dockerfile
volumes:
- './:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
Im running docker for windows on the device.
I hope anyone can help me out of here...Thanks!
The problem is mainly caused by the fact you're on Windows.
Why?
Because Docker on Windows does not work well with volumes. To be more precise - it does not notify the container about the volume change. It does expose up to date files in container but the Linux inside the container "doesn't know" about the fact that file has been changed which is required to trigger webpack recompilation.
There is few solutions:
Switch to Linux for development (I know it may be not possible but if you are working with docker a lot and you can move - do that. Linux containers on Linux work much faster, no issues with volumes etc)
If you can't you can either use legacy polling in weback which is already mentioned in comments
You can use e.g. https://github.com/merofeev/docker-windows-volume-watcher which is Python based tool which watch your local files and container files inside the volumes and notify the container about the change...
I found 3 working a bit better than 2 but both will have some performance sacrifice.
I hope it helps. If you have any questions just comment and I will try to edit to explain better.

chai-http not exiting after running tests

I ran into a problem where my mocha tests were not finishing after running with chai-http. Mocha just hangs after the tests and eventually runs into a timeout (at least on my CI).
Turns out, Mocha (4.0) changed their behavior regarding the termination of the tests. The best workaround I have found is to add the --exit flag to the npm script to revert to pre-4.0 behaviour.
...
"scripts": {
"start": "node server.js",
"test": "mocha --exit"
},
...

Have npm watch files in background to enable integration with Visual Studio Task Runner

I am trying to have npm watch for file changes in my client side code. I can have it work from the command line ok but I'd really like it to work from Visual Studio task runner.
my package.json looks something like this:
...
"watch": {
"compile": {
"patterns": [
"wwwroot"
],
"extensions": "ts"
}
},
"scripts": {
"prebuild": "copyfiles -f ./node_modules/d3/build/*.js ./wwwroot/lib/d3",
"compile": "tsc && browserify ./wwwroot/app/app.js -o ./wwwroot/bundle.js",
"build": "npm run compile",
"watch": "npm-watch"
},
...
So running npm run build then npm run watch from the command line has everything running as expected.
When I use the Task Runner however to bind my watch script to the After Build event like this:
it never 'exits' and, as such, the build never completes* and Visual Studio waits for me to kill the task before the application runs. Is there a way to have the script run in the background or some kind of 'detached' mode to enable Visual Studio to complete the build and run the application?
I tried using different watch tools but can't find any such option in any of them.
*Actually, I guess the build itself probably DOES complete but VisualStudio never runs the app and just hangs waiting on the script exiting.
Change the watch Bindings to Project Open. Then it will start watching after the project is opened.

Resources