@@ -174,6 +174,7 @@ AD.log("<yellow>--AppBuilder detected.</yellow>");
174174 'installAuthentication' ,
175175 'patchAppdevSettings' ,
176176 'moveGruntFile' ,
177+ 'createDefaultDirectories' ,
177178
178179
179180
@@ -289,7 +290,7 @@ Resource.sslDetails = function(done) {
289290 {
290291 file : path . join ( 'config' , 'local.js' ) ,
291292 tag : / ^ / ,
292- replace : 'var fs = require("fs");\n\n'
293+ replace : 'var fs = require("fs");\nvar path = require("path")\ n\n'
293294 } ,
294295 {
295296 file : path . join ( 'config' , 'local.js' ) ,
@@ -768,6 +769,7 @@ Resource.installLibraries = function(done) {
768769 if ( this . params . develop || this . params . docker ) {
769770
770771 modules . push ( 'appdevdesigns/appdev-opsportal' + branchTag ) ;
772+ modules . push ( 'skipper' ) ;
771773
772774 }
773775
@@ -1360,6 +1362,96 @@ Resource.moveGruntFile = function (done) {
13601362} ;
13611363
13621364
1365+ Resource . createDefaultDirectories = function ( done ) {
1366+
1367+ var defaultDirectories = [
1368+ path . join ( 'data' , 'opimageupload' ) , // OpsPortal: Image Upload Directory
1369+ path . join ( 'data' , 'opfileupload' ) // OpsPortal: File Upload Directory
1370+ ] ;
1371+
1372+
1373+ /**
1374+ * @function recursiveMakeDir
1375+ *
1376+ * makes sure that pathBase has a sub directory structure
1377+ * matching the pathToMake parameter.
1378+ *
1379+ *
1380+ * @param {string } pathBase the starting path
1381+ * @param {string } pathToMake a description of the directory structure to make
1382+ *
1383+ */
1384+ var recursiveMakeDir = function ( pathBase , pathToMake ) {
1385+
1386+ if ( pathToMake == '' ) {
1387+
1388+ // nothing else to make
1389+ return ;
1390+
1391+ } else {
1392+
1393+ // take next path step from pathToMake and add to base:
1394+ var parts = pathToMake . split ( path . sep ) ;
1395+ var newDir = parts . shift ( ) ;
1396+
1397+ pathBase = path . join ( pathBase , newDir ) ;
1398+
1399+ pathToMake = parts . join ( path . sep ) ;
1400+
1401+ // console.log(' base:'+pathBase+' make:'+pathToMake);
1402+
1403+ if ( ! fs . existsSync ( pathBase ) ) {
1404+
1405+ fs . mkdirSync ( pathBase ) ;
1406+ AD . log ( '<green><bold>created: </bold>' + pathBase + '</green>' ) ;
1407+
1408+ } else {
1409+
1410+ AD . log ( '<yellow><bold>exists: </bold></yellow><green>' + pathBase + '</green>' ) ;
1411+
1412+ }
1413+
1414+
1415+ recursiveMakeDir ( pathBase , pathToMake ) ;
1416+ }
1417+ } ;
1418+
1419+
1420+
1421+ function checkPath ( list , cb ) {
1422+
1423+ if ( list . length == 0 ) {
1424+ cb ( ) ;
1425+ } else {
1426+ var currPath = list . shift ( ) ;
1427+
1428+ console . log ( '... checking required path:' + currPath ) ;
1429+ var actualPath = path . join ( sails . config . appPath , currPath ) ;
1430+ fs . access ( actualPath , fs . constants . R_OK | fs . constants . W_OK , function ( err ) {
1431+
1432+ // if no error, then everything is fine and continue on.
1433+ if ( ! err ) {
1434+ checkPath ( list , cb ) ;
1435+ } else {
1436+
1437+ // create Path:
1438+ recursiveMakeDir ( sails . config . appPath , currPath ) ;
1439+ checkPath ( list , cb ) ;
1440+ }
1441+ } )
1442+
1443+ }
1444+
1445+ }
1446+ checkPath ( defaultDirectories , function ( err ) {
1447+
1448+ // console.log('!!!! TESTING STOP: did I make them?');
1449+ // process.exit(0);
1450+ done ( err ) ;
1451+ } )
1452+ }
1453+
1454+
13631455
13641456Resource . patchAppdevSettings = function ( done ) {
13651457
@@ -1413,12 +1505,23 @@ Resource.patchAppdevSettings = function (done) {
14131505Resource . patchPluginModifications = function ( done ) {
14141506 var self = this ;
14151507
1508+ // some examples:
14161509// var expr = new RegExp("module\.exports\.(\w+) = \{");
14171510// var replace = 'var $1 = module.exports.$1 = {';
14181511// var patchSet = [
14191512// { file:path.join('config', 'routes.js'), tag:expr, replace:replace },
14201513// { file:path.join('config', 'policies.js'), tag:expr, replace:replace }
14211514// ];
1515+
1516+
1517+ var bodyParserText = [
1518+ ' bodyParser: require(\'skipper\')({ ' ,
1519+ ' limit: \'10mb\',' ,
1520+ ' parameterLimit: 1000000' ,
1521+ ' })'
1522+ ] . join ( '\n' ) ;
1523+
1524+
14221525 var patchSet = [
14231526 { file :path . join ( 'config' , 'routes.js' ) , tag :'module.exports.routes' , replace :'var routes = module.exports.routes' } ,
14241527 { file :path . join ( 'config' , 'policies.js' ) , tag :'module.exports.policies' , replace :'var policies = module.exports.policies' } ,
@@ -1436,6 +1539,9 @@ Resource.patchPluginModifications = function (done) {
14361539 // disable limits to blueprint responses:
14371540 { file :path . join ( 'config' , 'blueprints.js' ) , tag :/ ( \/ \/ \s * d e f a u l t L i m i t : \s * \d + ) / m, replace :'$1\n defaultLimit: 2000000 // Number.MAX_VALUE' } ,
14381541
1542+ // file upload configurations
1543+ { file :path . join ( 'config' , 'http.js' ) , tag :/ ( \/ \/ \s * b o d y P a r s e r : .* ) / m, replace :'$1\n' + bodyParserText } ,
1544+
14391545
14401546 //// NOTE: sails v0.10.4 has all config options commented out, so we need to uncomment one for our
14411547 //// current method of patching config/local.js to work.
0 commit comments