Last active
March 24, 2016 16:12
-
-
Save frodosghost/745ca78e904e460bbca5 to your computer and use it in GitHub Desktop.
Dependency Inception: Composer, Installing NPM, Installing Bower
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "bower install", | |
"description": "Install Bower from Composer", | |
"version": "0.0.0", | |
"homepage": "https://antelopestudios.com.au", | |
"license": "MIT", | |
"private": true, | |
"dependencies": { | |
"angular": "1.4.x", | |
"angular-mocks": "1.4.x", | |
"angular-resource": "1.4.x", | |
"angular-route": "1.4.x", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"directory": "app/Resources/public/js", | |
"interactive": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
"scripts": { | |
"post-install-cmd": [ | |
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", | |
"AppBundle\\Composer\\ScriptHandler::npmInstall", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" | |
], | |
"post-update-cmd": [ | |
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", | |
"AppBundle\\Composer\\ScriptHandler::npmInstall", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" | |
] | |
}, | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bower and NPM | |
/app/Resources/public/js/* | |
/node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% block foot_script %} | |
{% javascripts | |
'%kernel.root_dir%/Resources/public/js/angular/angular.js' | |
'%kernel.root_dir%/Resources/public/js/angular-route/angular-route.js' | |
'%kernel.root_dir%/Resources/public/js/angular-resource/angular-resource.js' | |
'@AppBundle/Resources/public/js/your-script.js' | |
output="js/dashboard.js" | |
%} | |
<script type="text/javascript" src="{{ asset_url }}"></script> | |
{% endjavascripts %} | |
{% endblock foot_script %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.0.0", | |
"private": true, | |
"name": "npm packages", | |
"description": "Install NPM from Composer", | |
"license": "MIT", | |
"devDependencies": { | |
"karma": "^0.12.16", | |
"karma-chrome-launcher": "^0.1.4", | |
"karma-firefox-launcher": "^0.1.3", | |
"karma-jasmine": "~0.1.0", | |
"tmp": "0.0.23", | |
"bower": "^1.3.1", | |
"shelljs": "^0.2.6" | |
}, | |
"scripts": { | |
"postinstall": "bower install", | |
"prestart": "npm install", | |
"pretest": "npm install", | |
"test": "node node_modules/karma/bin/karma start test/karma.conf.js", | |
"test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run", | |
"preupdate-webdriver": "npm install", | |
"update-webdriver": "webdriver-manager update" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Composer; | |
use Composer\Script\Event; | |
use Symfony\Component\Process\Process; | |
/** | |
* Script for Running NPM as part of Composer Update | |
* | |
*/ | |
class ScriptHandler | |
{ | |
public static function npmInstall(Event $event) | |
{ | |
$IO = $event->getIO(); | |
$IO->write("Running NPM Install", false); | |
static::executeCommand($event, 'npm install'); | |
$IO->write(" ... <info>OK</info>"); | |
} | |
protected static function executeCommand(Event $event, $cmd, $timeout = 300) | |
{ | |
$process = new Process($cmd, null, null, null, $timeout); | |
$process->run(function ($type, $buffer) use ($event) { $event->getIO()->write($buffer, false); }); | |
if (!$process->isSuccessful()) { | |
throw new \RuntimeException(sprintf("An error occurred when executing the \"%s\" command:\n\n%s\n\n%s.", escapeshellarg($cmd), $process->getOutput(), $process->getErrorOutput())); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% block foot_script %} | |
{% javascripts | |
'%kernel.root_dir%/Resources/public/js/angular/angular.js' | |
'%kernel.root_dir%/Resources/public/js/angular-route/angular-route.js' | |
'%kernel.root_dir%/Resources/public/js/angular-resource/angular-resource.js' | |
'@AppBundle/Resources/public/js/your-script.js' | |
output="js/dashboard.js" | |
%} | |
<script type="text/javascript" src="{{ asset_url }}"></script> | |
{% endjavascripts %} | |
{% endblock foot_script %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment