gradle not passing args to gulp with extended use options - angularjs

Using the following Gradle gulp plugin which simply executes the gulp task from a gradle task via a simple naming convention gulp_<task name>
In the extended options on the docs : Gradle gulp plugin extended docs it demonstrates the following:
task gulpBuildWithOpts(type: GulpTask) {
args = ["build", "arg1", "arg2"]
}
In my standard build task executed by gradle like so:
// runs "gulp build" as part of your gradle build
bootRepackage.dependsOn gulpBuildWithOpts
task gulpBuildWithOpts(type: GulpTask) {
args = ["build", "--env prod", "--buildType gradle"]
}
The following is executed and built, however the args are ignored, gulp never picks them up. The args should be handled by Yargs command line parser
If I run direct with gulp (like below) then this works fine, so why am I getting my args ignored when ran from gradle?
gulp build --env dev --buildType gulp
NOTE - App layout is Springboot / AngularJS (^1.5) if you're wondering about choice of tooling.

You need to pass those options in separately:
task gulpBuildWithOpts(type: GulpTask) {
args = ["build", "--env", "prod", "--buildType", "gradle"]
}
Otherwise "--env prod" is interpreted by yargs as a single option named env prod, instead of an option named env with an argument of prod.

Related

How to fix missing functions directory problem with Netlify continuous deployment?

I followed steps from the official Netlify Docs:
I run npm run build and building process was finish correctly.
Then the docs suggest to run netlify deploy --open but it gives me the following error:
No such directory C:\Users\Concierge\Downloads\prod\ColorApp2\MaterialColorPickerCOM\functions! Did you forget to create a functions folder or run a build?
I tried to use command netlify deploy --prod as recommended by one user but it gives me the same error. The website is visible on my Netlify account but doesn't work: Here is the link
Do you guys have any idea how to fix it?
Not building Netlify functions
If you are not building functions, then make sure to not include a functions target directory in your netlify.toml
[build]
command = "npm run build"
publish = "build"
# functions = "functions"
Including Netlify functions
If you are including Netlify lamdbda functions with your project. Make sure after a build that there is a directory created that is specified in the functions value.
The example below expects there to be functions in a /functions directory after a build prior to a deploy or it will fail.
netlify.toml
[build]
command = "npm run build"
publish = "build"
functions = "functions"

React: Environment Specific Config on Production Builds

My company uses the three standard environments: Development, Test, and Production. My create-react-app based application is hosted as a content item within our CMS, so to get it into any environment, I need to run the npm run build command.
I've created a file, config.js, which exports a different configuration object based on variables in process.env, but the default behavior here has the limitation that npm run build is always considered production. This makes sense, I just need different behavior.
What I'd like to do is run a script like npm run build:dev, etc, which sets a process.env variable that I can switch on. Essentially I need to create an npm script that sets a dotenv variable, then calls npm run build.
What is the best way to accomplish this?
You can use cross-env package (from npm) to define a environment variable.
Just install the package:
npm install --save-dev cross-env
And create your custom script hwere do you define your variable, for example:
{
"scripts": {
"build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
}
}
It worked like a charm on my projects.
More information here cross-env

webpack -p not running on create-react-app

I have a big project which I was trying to reduce in size using webpack-p according to here: https://hackernoon.com/reduce-webpack-bundle-size-for-production-880bb6b2c72f
I could not run it as I was encountering problems when running webpack -p (it threw an error on every function of index.js
I thought it might be something with my packages. I decided to create new create-react-app and run the command there. To my surprise, there I get the same error:
What might be the problem here?
If your app uses webpack v4 you must use webpack --mode=production instead of webpack -p.
Possible values for mode are: none, development or production.
Another usage:
// webpack.config.js
module.exports = {
...
mode: 'production',
...
}
You don't have a config file because the command you are trying to run is global, it is not getting from your current working directory. Run npm run build instead, which does that under the hood, but has a lot of other things created by the contributors of create-react-app.
You could pass a config file for the global webpack cli, but you don't have access for that in your folder since it is "not" available for your. npm run build also already applies a lot of optimizations for you.

angular app, run gradle task with npm run build

I have an angular 1 app. Every time I run
npm run build
I also want to start a gradle task. Can I automatize that somehow?
Of course you can, the command npm run build run the script defined in you package.json file.
It looks like this :
"scripts": {
"build": "myAwesomeCommand; gradle myTask"
},
You can change the command executed by npm run build. If your command is too long or if you need a script, you can also create a shell script in your current directory and execute it.
The idea of using Gradle is that it automates the commands. Thus, you can use some construction of that type (in your build.gradle file):
task someGradleTask {
// ... Do something
}
task someNpmTask(type: NpmTask) {
args = ['run', 'build']
}
And then make one of the tasks dependant on the other:
someGradleTask.dependsOn(someNpmTask)
// Moreover
someNpmTask.dependsOn(npm_install) // This task comes with the plugin below
You will need an NPM plugin for Gradle, which may be included like this:
buildscript {
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
}
}
apply plugin: 'com.moowork.node'

Separating a Build and Test on Jenkins

I have a angular application which i develop using source control ofcourse (gitlab), I recently integrated it with jenkins so that everytime i push to my git it triggers a build. In my jenkins i created a job that pretty much builds the application (installs dependencies) and runs test. Following is what my execute shell looks like in my job.
export npm_config_prefix=.npm/
export PATH=.npm/bin:$PATH
npm install -g bower grunt-cli
npm install
bower install
gulp test
Now the issue is that I do not want to build and run test as a same step i want them to seprate. So how do i achieve this ? Do i create a new job and add gulp test in the execute shell of the new job ? Or is there some other approach. I am new to jenkins and CI in general so was wondering what would be the approach in this situation ?
As you have found, Jenkins is a super advanced shell script runner to take the boring part out of repeatable steps in the build process.
The next step is to hunt down plugins to do those steps for you in a cleaner way. This is where plugins come in
These is a Node Plugin which will install npm packages outside the job so you don't have to do the npm install -g step every single job
You would want to keep the build step as shell
npm install
bower install
gulp test
I think that is your concern because you only need to run the job if the code has changed, including local dependencies. You could add a second shell step and just have the tests in there as it will run in the same workspace but all the build logs will be in one place
You didn't say what test runner your using but you will probably find a publisher step which will bring that into Jenkins for you xUnit plugin covers quite a few runners so might work for you
And this is the tutorial on installing plugins into Jenkins

Resources