how to set a NX custom command with configuration vars? - monorepo

So inside my NX workspace, I got multiple projects that need to be deployed differently.
What I would like to have is a deployment script that sorts out the development and production enviroments.
So I would like to be able to run nx run-many -target=deploy --configuration=production
And then have something like this:
"deploy": {
"executor": "nx:run-commands",
"configuration": {
"production": {"deploymentBucket": "s3://prod-bucket"},
"development": {"deploymentBucket": "s3://dev-bucket"}
},
"options": {
"command": "echo b {deploymentBucket} f"
}
}
So that I can run it in my ci pipeline.

Related

How to make a develop env by using singularity+vscode

I created a singularity image for arm development. I installed a singularity in my WSL.
I am going to code and debug at wsl,then move it to arm platform by using Cross compiler in my singularity.
How to use vscode to build my program (arm version)? Or how to use singularity integratly with vscode?
I tried to build my program with singularity shell,and it succeed.I have learnt something about vscode's task and launch,and build my program with wsl,but I dont know how to use them to bootup a singularity and then build my program.
To use Visual Studio Code (VSCode) to build your program for the ARM platform using a Singularity image, you will need to configure the tasks and launch settings in VSCode.
First, you will need to create a tasks.json file in the .vscode folder in your project directory. This file will define the command to run the build process using Singularity. The command would look something like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "singularity exec /path/to/your/image.sif arm-linux-gnueabihf-gcc -o main main.c",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
You will also need to configure the launch settings in launch.json. This file is used to configure how your program is executed. You can use the preLaunchTask field to specify the build task you created above, so that it runs before your program is launched:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "build"
}
]
}
Once you have configured the tasks and launch settings, you should be able to use the Tasks: Run Build Task command in VSCode to build your program using the Singularity image and the Cross compiler, and use the Debug: Start Debugging command to run and debug your program.
You can also use the vscode-singularity extension, which is a Singularity extension for VSCode. It allows you to manage Singularity images, containers and shells directly from VSCode.

devcontainer.json. Breakpoints not working

I launch a debug session through the Module option and specifying a folder, the app starts up and responds to requests - and code changes are seen when other services interact with mine by calling into it (print statements show the change in the terminal output of the IDE), however, breakpoints are not hit. How come?
My devcontainer.json file looks like this:
{
"name": "Existing Dockerfile",
"build": {
"dockerfile": "../Dockerfile",
"context": "../.",
"target": "deploy"
},
}
My Dockerfile does the usual stuff and runs our app with python -m app:
FROM python:3.9.3-slim AS deploy
COPIES SOME FILES
CMD ["python", "-m", "app"]
My problem was the version of python that was pulled in.
In my Dockerfile, I had to change:
FROM python:3.9.3-slim AS base
to
FROM python:3.9.4-slim AS base
Then breakpoints started working.

How to access cypress environment variable passed in from command line

Scenario:
I have cypress tests that we run on multiple environments( more than 8), each environment with a separate domain, so we have configured all the domains in cypress.json file under env, now I need to pass the domain dynamically, i.e, from command line and be able to pick it and run the tests on respective domain. but I'm not sure how I can grab that value passed in command line.
Note: I have tried process.env method but did not work.
Code looks like this :
Cypress.json
{
"env": {
"domain1": xyz.com,
"domain2": abc.com,
"domain3": 123.com
}
}
package.json :
{
scripts: {
"test": "npm run cypress open --env domian= $1
}
}
$1 is suppose to get me the command line argument"
From my files under integration folder, Cypress.env(Cypress.env().domain) will/should fetch me the right domain.
However I'm receiving $1 as domain value.
Please help.
Can you share how $1 is supposed to reference the env file? I don't understand that part.
In the meantime, here is an alternative answer to your problem. (just tested it out)
You can write several test scripts which each provide a different domain address.
{
scripts: {
"test1": "npm run cypress open --env domian=xyz.com",
"test2": "npm run cypress open --env domian=abc.com",
"test3": "npm run cypress open --env domian=123.com"
}
}

build angularjs 2 with angularjs-cli on codeanywhere

I am getting invalid host header problem while i am trying to server my application by ng serve --host 0.0.0.0 . I have tried the following.
1.install -g angular-cli
2. cd to that app-directory
3. change port in angular-cli.json
"defaults": {
"styleExt": "css",
"component": {},
"serve": {
"port": 1337
}
}
ng serve --host 0.0.0.0
Requested url in browser is http://port-1337.angular2-jobproject0889272.codeanyapp.com/
I was looking to sovle a different problem and came across an answer that may work for you.
ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true
Angular-cli GitHub
If I'm understanding your question correctly, your issue could be stemming from Webpack's security impl.
As the Angular CLI uses Webpack by default to bundle your app, you have to abide by its requirements when using "ng serve". App bundles produced by Webpack now require the Host header of the request to match the listening address OR the host provided in the public option.
The public option is a --public flag passed with the "ng serve" command. On CodeAnywhere you should most likely care to indicate a port # as well. A valid "ng serve" command could look like this:
$ ng serve --host 0.0.0.0 --port 3000 --public myproject-myusername.codeanyapp.com
(For HTTPS service, CodeAnywhere requires you use port 3000)
You can find your specific value for the --public flag in your CodeAnywhere IDE by right-clicking on your project's tree view Connection icon and selecting the "info" option.
To simplify things, you can set this up in your package.json file and then start the Angular server with the command:
$ npm start
For example, you can modify the "start" element of the package.json "scripts" entry as follows:
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 3000 --public myproject-myusername.codeanyapp.com"
}
Hopefully this info is applicable to the issue you are facing. Good Luck!

Running react code on other machine

Hi I am working on reactJS
Would Like to understand how can I run my local React app running on http://localhost:8888/index.html#/?_k=pu9k2u through my IP address on some other machine ?
Whenever I do a "npm start" it always runs on localhost:8888
How do I change it to run on 0.0.0.0:8888 ?
I know how to change the port for the app,
Following is my webpack.congif.js
module.exports = {
entry: './index.js',
output: {
filename: 'index.js',
path: ''
},
devServer: {
inline:true,
port: 8888
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
]
}
}
Since I am very new to reactJS kindly explain the solution given below or provide with an updated webpack.config.js
How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?
only by adding host: to webpack.config.js it worked for me
devServer: {
host:'000.000.00.00',
port: 8888
},
then i started react code by giving
webpack-dev-server --host 000.000.00.00 --port 888
You need to change hosting of the react application from localhost to your local ip address. (For example 10.10.54.124), you can get it using ipconfig command in Windows command prompt.
Next you need to open your port (ex. 214) via firewall, to access from the 3rd-party machines. And after that, all of the people, how are in your local, or VPN network can access your application by link 10.10.54.124:214.
P.S. That would work only for people how are in your local network
This is what I do: instead of using an IP address I tell node to use the local hostname of the computer. This is done in the package.json file in the scripts section with the HOST param, there is a PORT param too:
{
...,
"scripts": {
"start": "node scripts/start.js",
"start-local": "HOST='BlueLight.local' node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom",
....
}
...
My hostname is BlueLight so my local address is BlueLight.local, open the terminal and write hostname command to find out yours.
So any computer in my local network can open http://BlueLight.local:3000 you can even use mobile phones, and I even use iPhone or Android simulators.
Bear in mind that some security checks like WebRTC, live camera, and other https checks will not work since you don't have a SSL certificate for your local address. Some of them can be deactivated in the advanced settings of your browser.

Resources