qcobjects-cli
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -30,5 +30,8 @@ /** | ||
const templatePath = path.resolve( __dirname, "./templates/apps/" )+'/'; | ||
const templatePwaPath = path.resolve( __dirname, "./templates/pwa/" )+'/'; | ||
const package_config = require(absolutePath+'/package.json'); | ||
const { exec,execSync } = require('child_process'); | ||
const Handlebars = require('handlebars'); | ||
const readline = require('readline'); | ||
@@ -43,5 +46,34 @@ | ||
Package('org.quickcorp.qcobjects.cli',[ | ||
Class('SwitchCommander',{ | ||
program:require('commander'), | ||
fileListRecursive : function (dir) { | ||
var instance = this; | ||
return (fs.statSync(dir).isDirectory()) | ||
? (Array.prototype.concat(...fs.readdirSync(dir).map(f =>instance.fileListRecursive(path.join(dir, f)))) | ||
.filter((f)=>{return !f.startsWith('.git') | ||
&& f.lastIndexOf('.DS_Store')==-1 | ||
}) | ||
) | ||
: (dir); | ||
}, | ||
generateServiceWorker: function (appName){ | ||
var filelist = ["/"].concat(this.fileListRecursive('./')); | ||
filelist = filelist.filter(function (fl){return fl!= "sw.js"}); | ||
fs.readFile(templatePwaPath+'/sw.js', function(err, data) { | ||
const swTemplate = Handlebars.compile(data.toString()); | ||
var swContent = swTemplate({appName: appName,filelist:"\n\t\""+filelist.join("\",\n\t\"")+"\""}); | ||
fs.writeFile('./sw.js', swContent, err => { | ||
logger.info("Service Worker Generated"); | ||
console.log('') | ||
console.log('Now simply put:'); | ||
console.log('CONFIG.set(\'serviceWorkerURI\',\'/sw.js\');'); | ||
console.log(' In your init.js file '); | ||
console.log('') | ||
process.exit(0); | ||
}); | ||
}); | ||
}, | ||
copyTemplate: function (){ | ||
@@ -102,2 +134,8 @@ var map_files = function (pathname,callback){ | ||
choiceOption:{ | ||
generateSw: function (_appName){ | ||
let switchCommander = this; | ||
let appName = (typeof _appName ==='undefined' || _appName === true)?('MyAppName'):(_appName); | ||
switchCommander.generateServiceWorker(appName); | ||
}, | ||
create:function (_appName){ | ||
@@ -123,2 +161,4 @@ let switchCommander = this; | ||
logger.info("Test certificates generated"); | ||
switchCommander.generateServiceWorker(appName); | ||
}); | ||
@@ -166,2 +206,8 @@ setTimeout(()=>{ | ||
this.program.command('generate-sw <appname>') | ||
.description('Generates the service worker <appname>') | ||
.action(function(args, options){ | ||
switchCommander.choiceOption.generateSw.call(switchCommander,args,options); | ||
}); | ||
this.program.on('--help', function(){ | ||
@@ -168,0 +214,0 @@ console.log('') |
{ | ||
"name": "qcobjects-cli", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "qcobjects cli command line tool", | ||
@@ -5,0 +5,0 @@ "main": "qcobjects-cli.js", |
@@ -20,3 +20,2 @@ #!/usr/bin/env node | ||
//Import(templatePath+'spa-local'); | ||
require(absolutePath+'/org.quickcorp.qcobjects.cli'); | ||
@@ -23,0 +22,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35832
14
748
5