Is there any way to set default port for nx react apps - nrwl-nx

I create multiple apps using nx monorepo, but when I try to run nx run-many to start all apps at once, but I got the error that the port is already taken, which is true.
when I run apps one at a time, I can specify a port, but on run-many i can't. so is there any way to set the default port for every app?
Thanks in advance.

You can set the configuration of your React apps by editing project.json file
"serve": {
"executor": "#nrwl/web:dev-server",
"options": {
"buildTarget": "admin:build",
"hmr": true,
"port": 3001
},
"configurations": {
"production": {
"buildTarget": "admin:build:production",
"hmr": false
}
}
}
Under every command you want to execute, there is an options key which you can add port.

Related

Debug Flutter web app in VS Code without creating a Microsoft Edge new instance

everything is set up and working but when I start debugging flutter in vs code using microsoft edge it starts a new instance , meaning the browser data, password, settings .... are all reset, so i need to enter passwords and change settings every time i start debugging or i need to open two browser instances which is both resources intensive and clingy.
is there like vs code configuration for flutter that works as "attach" to an existing browser instance instead of "launch" a new instance ?
you have to run with following command,
flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0
then access http://<your-ip> or localhost:8080
with this you can open your flutter web-app in regular browser and also you can open it in other devices in network(with your ip)
** also you should ensure that your port(8080) is open.
Normally, if Microsoft Edge is already running when you start debugging with a launch config, then the new instance won't start in remote debugging mode.
So by default, the extension launches Microsoft Edge with a separate user profile in a temp folder. Use userDataDir to set a different path to use, or set to false to launch with your default user profile.
A simple example:
{
"configurations": [
{
"name": "Launch Microsoft Edge",
"request": "launch",
"type": "edge",
"url": "...\\Index.html", // Provide your project's url to finish configuring
"userDataDir": false // You could also add ${local_app_data}\Edge\Profile, such as C:\Users\<Current-user>\AppData\Local\Microsoft\Edge\Profile
}
]
}
I don't have a perfect solution, as this one requires you to install the Dart Debug Extension, but you can create a launch.json and paste this command:
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter Web Project",
"type": "dart",
"request": "launch",
"program": "lib/main.dart",
"args": [
"-d",
"web-server"
]
}
]
}

How to run Xdebug 3 on Vagrant / Homestead with VSCode (on Big Sur Mac)

Suddenly, with a new installation of Vagrant/Homestead running a freshly installed Big Sur (macOS), my (old) Xdebug configuration for some reason didn't want to work with my VSCode.
I spent a good few hours trying to figure it out, trying many different setups but with no luck. Xdebug didn't want to work.
So how to set it up correctly to make it work?
The main reason that it didn't work correctly anymore is that suddenly with the newest version of Homestead we have a Xdebug in version 3 which changes many options of Xdebug 2. It mostly simplifies the thing but also breaks previous setups. You can read more about the changes done to configuration variables in Xdebug 3 on their page.
For Xdebug to work on Homestead / Vagrant / macOS (Big Sur) these are the steps needed.
You have to find xdebug.ini location which is easily done displaying phpinfo() and checking the path, which in my case is: /etc/php/7.3/fpm/conf.d/20-xdebug.ini
Open it and edit: sudo vi /etc/php/7.3/fpm/conf.d/20-xdebug.ini:
My configuration looks like:
zend_extension=xdebug.so
xdebug.client_port = 9003
xdebug.max_nesting_level = 512
xdebug.mode=debug
xdebug.start_upon_error = true
xdebug.idekey = VSCODE
; The MacOS way
xdebug.discover_client_host = false
xdebug.client_host = 10.254.254.254
Things that has changed:
the port - now it is 9003,
for debugging setup - many options are now set using this one simple option: xdebug.mode=debug
You have to save the file and restart php-fpm by: sudo service php7.3-fpm reload
For macOS (on my Windows machine this wasn't needed) you have to:
Ensure you have created an Host address alias on MacOS and
10.254.254.254 is aliased to your localhost.
By doing: sudo ifconfig lo0 alias 10.254.254.254.
Which is in more detail also explained here.
Install VSCode PHP Debug (vscode-php-debug) extension.
Configure VSCode by clicking the debug icon from the left menu and then edit JSON file containing debugger configuration.
Paste this:
{
"version": "0.2.0",
"configurations": [
{
"name": "My XDebug on Homestead",
"type": "php",
"request": "launch",
"pathMappings": {
"/home/vagrant/code/myproject": "${workspaceFolder}"
},
"port": 9003
}
]
}
Finally install Chrome Xdebug Helper extension and turn on the (green bug) debug mode when you want to do the debugging.
One extra thing. If you want to enable/disable Xdebug, lets say for performance reasons there is a very easy and fast way to do this.
enable:
sudo phpenmod xdebug
sudo service php7.3-fpm reload
disable:
sudo phpdismod xdebug
sudo service php7.3-fpm reload
As you can see a lot of different things in different places must be set correctly to make it work. It takes a lot of googling and patience so I thought it would be useful to put it here for you and for my future installations. :)
First of all, make sure about which version of PHP-FPM your site is running (change laravel.test to the name of your configured site). Remember that you can choose the PHP version to use for each site in the Homested.yaml file.
$ cat /etc/nginx/sites-available/laravel.test | grep fastcgi_pass
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
This will tell you which configuration file to edit in the Homestead virtual machine (NB: change 8.0 to your version of PHP, if different).
$ sudo nano /etc/php/8.0/fpm/conf.d/20-xdebug.ini
Here, you can remove all lines starting with xdebug.* and instead add these lines:
xdebug.mode=debug
xdebug.client_host=192.168.10.1
xdebug.client_port=9003
xdebug.max_nesting_level = 512
NB: 192.168.10.1 is by default the IP address of the host machine in VirtualBox, it is supposed to be different than your actual IP address in your LAN. Note that max_nesting_level is not necessary, it's a default by Homestead so I left it there.
Now in Visual Studio Code on your host machine you can set your launch.json file to the following:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
// "stopOnEntry": true,
"pathMappings": {
"/home/vagrant/laravel.test": "${workspaceFolder}"
},
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
PS. I keep "stopOnEntry": true commented so that I can simply uncomment it when needed, otherwise I simply use breakpoints in vscode.
for Xdebug Version 3.0.3
set IDE to use a debugging port - 9003
modify the /etc/php/7.x/fpm/conf.d/20-xdebug.ini
zend_extension = xdebug.so
xdebug.remote_port = 9003
xdebug.max_nesting_level = 512
xdebug.mode = debug
xdebug.client_host = 192.168.10.1
If Homestead.yaml contains a different subnet for the IP address, this IP address may be different...
BTW, after editing 20-xdebug.ini, restart you FPM like so
$ sudo service php7.4-fpm restart
and restart your browser and IDE
PS
Tested on NetBeans and Vagrant (Laravel homestead) with php 7.4, host - WIN-10

How do I see the logs of a VSCode Language Server process?

Situation
I'm experimenting with writing a VSCode Language Server Protocol (LSP) Extension. I've got it running as follows:
An lsp-server process which is launched by running haskell-lsp-example-exe from terminal
An lsp-client written in Typescript which, for now, basically just launches lsp-server (it's based on the lsp-sample repo)
The lsp-server is launch as follows:
# extension.ts
let serverOptions: ServerOptions = {
run: {
command: "haskell-lsp-example-exe"
},
}
The lsp-client is launched using code --extensionDevelopmentPath="path/to/extension"
I can see that it launches correctly, and I can find its pid through Activity Monitor (I'm on Mac).
Question
How can I see the logs of this process which is spawned by VSCode?
Context
I have tried the following:
In lsp-client/package.json I set the following which gives me the messages going back and forth. But not the logs of lsp-server.:
"languageServerExample.trace.server": {
"scope": "window",
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "verbose",
"description": "Traces the communication between VS Code and the language server."
}
I've also tried opening up dev tools in the launched instance of VSCode, but that gives the logs of lsp-client
The log labelled Log (Extension Host) in the launched instance of VSCode also doesn't look too useful
Thanks in advance for any help!

cordova run android takes "wrong" database

Hello fellow ionic developer,
I use visual studio code (VSC) to develop an ionic 4 application.
Situation:
Usually I emulate an API 19 Android Phone but this has to be builded everytime ionic cordova run android and I can not get it running with the -livereload flag (this takes a lot of time for even little changes). That is when I tried run the app with the cordova plugin for VSC to get a live emulator for debugging and working on my app.
Problemcontext:
I added a database for local storage of patient information. Therefore, I added a seed which provides some patient data and a user. The userlogin works like a charm, during the login I immediatly load all patients for the user. And this is were the problem is:
Apparently, the underlying database / seed is in some old state since I just changed the user values and I can not login with the new seed values.
Unhandled Promise rejection: a statement error callback did not return false: Failed to import SQL; message=sqlite3_prepare_v2 failure: table patient has 14 columns but 27 values were supplied
This is the error that brought me here.
So my question is:
Is there an opportunity to rake/prebuild/... the seed file or where is the seed file located (for using the VSC emulator, since it works on the android studio emulator but also not on the physical device) for the emulator so I can delete or redesign it.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Android on emulator",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "emulator",
"port": 8100,
"sourceMaps": true,
"cwd": "${workspaceFolder}",
"ionicLiveReload": true
}
]
}
Thank you in advance
I found a workaround:
//DELETE FOR DEPLOY
this.deleteDatabase("databasename.db");
deleteDatabase(databasename: string)
{
try{
this.sqlite.deleteDatabase(
{
name: databasename,
location: 'default'
}
)
}
catch(error){
console.error(error)
}
}
You should delete the current database and just populate the database again with the new seed.sql
From: https://stackoverflow.com/questions/52033237/how-to-delete-sqlite-database-in-ionic3

Protractor test fails on CI

Currently I am trying a setup an end to end protractor tests to a a bitbucket pipelines with set up an headless chrome and i am currently getting some error message:
Failed: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
Any clue for this? how ever running tests locally is working fine; Can i set a constant session id?
Thanks
Check out your configuration file for this object
capabilities: {
"browserName": "chrome",
"chromeOptions": {
"args": ["incognito", "--window-size=1920,1080", "disable-extensions", "--no-sandbox", "start-maximized", "--test-type=browser"],
"prefs": {
"download": {
"prompt_for_download": false,
"directory_upgrade": true,
"default_directory": path.join(process.cwd(), "__test__reports/downloads")
}
}
}
},
When you find it, make sure you included "--no-sandbox" argument into args property.
What this guy does is it allows your tests to be ran from a remote container. In the meantime, if you include the argument when you run your tests on your machine, it has side effects like described here Chrome Instances don't close after running Test Case in Protractor