basecamp-guide
Version:
Task automator for the Basecamp Framework.
120 lines (102 loc) • 4.22 kB
JavaScript
// Dependecies
var p = require('path');
var fs = require('fs');
var Colors = require('colors');
var FileSys = require('../FileSystem.js');
var Exec = require('child_process').execSync;
var Feedback = require('../Feedback.js');
var LaravelAppConfig = require('../LaravelAppConfig.js');
/**
* Config & Settings for the basecamp-design package.
*
* Installs composer package.
*
*
*/
var DesignInstallCommand = {
fire : function() {
// Helpers
var exportPaths = {
root : this.config.exportPaths.root,
stylus : p.join(this.config.exportPaths.root, this.config.exportPaths.stylus),
design : p.join(this.config.exportPaths.root, this.config.exportPaths.stylus, 'basecamp-design'),
vue : p.join(this.config.exportPaths.root, this.config.exportPaths.vue)
};
var packagePaths = {
design : this.config.packagePaths.design
};
// Install patrikkernke/basecamp-design package
console.log('Adding Basecamp-Design Package...'.bold);
var output = Exec('composer require patrikkernke/basecamp-design:~v0.0.1').toString();
console.log(Colors.grey(output));
// Exchange .gitignore, elixir-config and npm-packages
console.log('Exchange Config-Files...'.bold);
FileSys.copyFromStub('.gitignore', exportPaths.root);
FileSys.copyFromStub('gulpfile.js', exportPaths.root);
FileSys.copyFromStub('package.json', exportPaths.root);
console.log('');
// Config Stylus Folder
console.log('Config Stylus Folder...'.bold);
FileSys.copyFromStub('app.styl', exportPaths.stylus);
FileSys.makeDir(p.join(exportPaths.stylus, 'components'));
var that = this;
FileSys.copyFile(
p.join(packagePaths.design, 'stylus', 'design.styl'),
p.join(exportPaths.design, 'design.styl'),
function(content) {
// Change path of assets and point to basecamp-design
var relativePathToDesignLibrary = p.join(that.getRelativePrepandsToRootFrom(exportPaths.design), packagePaths.design, 'stylus');
var action = content.replace(
"framework : './'",
"framework : '" + relativePathToDesignLibrary + "/'"
);
Feedback.tell(action, "framework : './' => framework : '" + relativePathToDesignLibrary + "/'");
return content;
}
);
console.log('');
console.log('Setup stylus-config files...'.bold);
FileSys.copyDir(
p.join(packagePaths.design, 'stylus', 'vars'),
p.join(exportPaths.design, 'vars')
);
console.log('');
/**
* JS & Vue
*/
console.log('Setup JS files...'.bold);
FileSys.copyFromStub('app.js', exportPaths.vue);
FileSys.copyDir(
p.join(packagePaths.design, 'vue/components'),
p.join(exportPaths.vue, 'ui')
);
LaravelAppConfig.addVueViewDependecy('./ui/NavbarView.js', p.join(exportPaths.vue, 'app.js'));
console.log('');
/**
* Laravel Views, Controllers & Routes
*/
console.log('Setup Laravel Views, Controllers & Routes...'.bold);
FileSys.copyFromStub('routes.php', 'app/Http');
FileSys.copyFromStub('PageController.php', 'app/Http/Controllers');
FileSys.copyFromStub('app.blade.php', 'resources/views/layout');
FileSys.copyFromStub('welcome.blade.php', 'resources/views');
console.log('');
},
/*
* config-property will be injected from the
* CommandLineTool while adding the command
*/
config : {},
/**
* helper methods
*/
getRelativePrepandsToRootFrom : function(path) {
var directories = path.split(p.sep);
var prepandDirectories = '';
for (var i = 1; i <= directories.length; i++) {
prepandDirectories = prepandDirectories + '../';
}
return prepandDirectories;
}
};
module.exports = DesignInstallCommand;