Is there a gulp plugin to run Laravel Artisan tasks? - laravel

I haven't been able to find a gulp plugin whose purpose is to simply run Laravel Artisan tasks. It seems to me this would be useful.
I imagine it would be quite trivial, which makes me think it must exist.
I looked at Laravel Elixir but this doesn't seem to do what I want.
Not strictly on topic, but the problem at hand follows.
I briefly played with gulp-shell, gulp-run, and #eddieajau/shell, and for a particular task don't seem to be having any luck: the command which runs just fine when run manually from the console seems to hang. ps shows it is running but apparently doing nothing. I'm probably missing something simple, but invoking shell commands from node always seems fiddly.
My current code in Coffee is this:
gulp.task 'twig', ->
shell = require '#eddieajau/shell'
shell.setLogger console.log
return shell.exec 'php', ['artisan', 'twig:lint'],
cwd: __dirname
This is supposed to return a promise, which gulp.task is supposed to notice and deal with. But when I run it it appears to hang.

I don't pretend to know Coffeescript, however gulp-shell is blacklisted (meaning it doesn't do things "the gulp way").
gulp-exec may possibly do what you're looking for, however you don't specifically need that for a direct shell call. Here's what I have in my gulpfile (non-coffeescript) to run php artisan ide-helper:generate after any of my models change:
var exec = require('child_process').exec;
gulp.task('generate:ide-helper', function (cb) {
exec('php artisan ide-helper:generate', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});

Related

String(4) "asas" is throen in the console while running artisan command laravel

I encountered a strange error today where the error looks like in the image:
I cloned my one of my colleague's repository and ran composer install command.
As it tried to generate optimized files, the error started popping out. After that, if I try to run any artisan command, it throws the same error text string(4) "asas".
To be more precise, I already have .env configured.
Please help. Am I really missing something that I need to look at?
The most likely explanation is that your colleague dumped asas somewhere in the code base. Probably in a place that is loaded everytime you execute a command, like a service provider.
Just search for asas in all files and you'll find something like:
dd('asas');
//or
var_dump('asas');
die;
Since asas is only the result, it may be a variable, like dd($test); where asas is the value.
If you don't find anything, search for dd or var_dump.

Executing shell command after Webpack post build

I have a Laravel project and as you know when you deploy your app everything in your public directory should be copied over to your htdocs or public_html directory to hide your application's code.
I am using webpack to build my react code and everything else and each time I change my javascript webpack does what I want, it sees I make a change and then it builds it.
However I want to add one additional command after it builds and that is to copy everything from the public directory into the correct directory in htdocs/public_html.
So far I read up on this question here Run command after webpack build
It works and I can get the echo to work but I'm not sure why cp isn't working. Echo works but how do I know what shell commands I can use?
I tried 'cp' and even 'copy-item' which is powershell, but none are working.
This is my plugin so far, I figured I needed to change the directory to be safe
before copying anything over but again, nothing is working.
mix.webpackConfig(webpack => {
return {
plugins: [
new WebpackShellPlugin({
onBuildStart: ['echo "Starting Build ..."'],
onBuildEnd: ["cd 'E:\\xammp\\apps\\FactorioCalculator'",
"cp '.\\public\\*' '..\\..\\htdocs\\FactorioCalculator\\' -f -r"]
})
]
};
});
You could always use the copyDirectory mix method. Just put something like the following at the bottom of your webpack.mix.js file:
mix.copyDirectory('public', '../../htdocs/FactorioCalculator/')
You might have to change your path to ..\\..\\htdocs\\FactorioCalculator\\ as per the path in your question (I only have my mac with me so I'm unable to test on my other machine).
To answer you original question, if you want to execute a command each time webpack finishes building you can use the mix.then() which takes a closure.

Gulp Sass Watch Run only changed and dependencies

I am trying to figure out how to watch SCSS files for changes and then run task (gulp-ruby-sass) only for those that changed(added,removed) and their dependencies (#import).
My watch task code is:
gulp.task('sass-watch', function(){
gulp.watch('dev/scss/*.scss', ['sass']);
});
My "sass" task code is:
gulp.task('sass', function(event) {
return sass('dev/scss/*.scss')
.pipe(changed('dist/css'))
.on('error', sass.logError)
.pipe(gulp.dest('dist/css'));
});
Sice sass take all files in folder anyway, this cannot work as I want to, but I noticed interesting thing. In my command-line I get following logs, when "sass-watch" is triggered by saving style2.scss file.
[13:38:01] Using gulpfile C:\1HLAVNI\Lukas\Webdesign\lukasradek\gulpfile.js
[13:38:01] Starting 'sass-watch'...
[13:38:01] Finished 'sass-watch' after 42 ms
[13:38:03] Starting 'sass'...
[13:38:03] write ./\style_combined.css
[13:38:03] write ./\style2.css
[13:38:03] Finished 'sass' after 416 ms
Something logs write style_combined.css and style2.css which is exactly how the dependencies are. (styl2.scss is imported to style_combined.scss). So this means, that something knows how the dependencies are set. Problem is, that I don't know what is that something. I cannot get that info elsewhere, only in final log. If I can get that info somewhere in code, I would be able to use for triggering the task only for changed files and dependencies.
Any idea, what might emit those logs?
I tried to strip my code to bare minimum and the logs are still present even when I remove the content of "sass" task. The logs disappeared after I removed ['sass'] trigger from gulp.watch.

Livingstyleguide compile task never finishes

I have a VERY simple test site where I'm trying to experiment with the Livingstyleguide gem (https://github.com/livingstyleguide/livingstyleguide).
The problem is that when I run livingstyleguide compile my_src_file.lsg my_dest_file.html from the command line, the process hangs and the task is never carried out. There are no errors logged to the terminal window, so I'm not sure how to even start debugging this.
I've tried implementing livingstyleguide via Gulp as well, and running my task to create the style guide also fails from there. That DOES output an error, the details of which are as follows:
Error in plugin 'gulp-livingstyleguide'
Message:
Command failed:
Details:
killed: false
code: 10
signal: null
This is pretty cryptic, so I'm still not even sure what's failing.
Here's my gulpfile:
var gulp = require('gulp');
var sass = require('gulp-sass');
var livingstyleguide = require('gulp-livingstyleguide');
gulp.task('sass', function(){
return gulp.src('scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('app/css'));
});
gulp.task('watch', function(){
gulp.watch('scss/*.scss', ['sass']);
});
gulp.task('lsg', function(){
gulp.src('scss/styleguide.html.lsg')
.pipe(livingstyleguide())
.pipe(gulp.dest('app'));
});
If I comment out the livingstyleguide() line in my gulpfile, the lsg task takes the src file and outputs it into the app directory, so I know that the paths to the files are correct, and it's just something with the plugin or permissions or something that's causing everything to fail.
Any help would be very, very appreciated!

Node JS 0.6.1 msi on Windows

How do I use NodeJS on Windows? I've downloaded and installed the 0.6.1 MSI.
I can run node in the command prompt.
What do I do next? I can't seem to find much information such as where to put files etc
It's just for a little experimentation.
Thanks
Ric
Have you followed the basic tutorial exactly as it is posted? If you create a file (let's say, index.js) that looks like this...
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(204, { 'Content-Type':'text/plain'});
res.write('Hello World');
res.end();
}).listen(8080);
...and then launch it via the command line like so (assumes index.js is visible from the current directory)...
node index.js
...you should see Hello World in your browser when you point it to http://localhost:8080.
If you simply run node then you will get an interactive javascript shell, which is not what you want.
Make sure you called listen(port) and also make sure that you called res.end() in order to send the response.
I was being an idiot. I was running node at c: then typing the full path to the file within Node! If any one has the same problem then make sure you change to the folder your js files are in first, then node filename.js

Resources