bili-sapp-cli
Advanced tools
Comparing version 0.0.6 to 0.0.7
42
index.js
@@ -7,2 +7,4 @@ #!/usr/bin/env node | ||
var info = require('./package.json'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var projectTpl = 'http://static.hdslb.com/public/template.zip'; | ||
@@ -28,2 +30,21 @@ | ||
function copyTemplate(from, to) { | ||
from = path.join(__dirname, 'page-template', from); | ||
fs.writeFileSync(to, fs.readFileSync(from, 'utf-8'), 'utf-8'); | ||
} | ||
function copyImage(from, to) { | ||
from = path.join(__dirname, 'page-template', from); | ||
fs.writeFileSync(to, fs.readFileSync(from, 'binary'), 'binary'); | ||
} | ||
function mkdir(path, fn) { | ||
fs.mkdir(path, function () { | ||
fn && fn(); | ||
}); | ||
} | ||
var PATH = '.'; | ||
program | ||
@@ -34,4 +55,25 @@ .command('page <page-name>') | ||
console.log('exec "%s"', pageName); | ||
var pageDir = path.join(PATH, pageName); | ||
fs.exists(pageDir, function (exists) { | ||
if (!exists) { | ||
mkdir(pageDir, function () { | ||
copyTemplate('index.vue', path.join(pageDir, 'index.vue')); | ||
mkdir(path.join(pageDir, 'vue'), function () { | ||
copyTemplate(path.join('vue', 'MyComponent.vue'), path.join(pageDir, 'vue', 'MyComponent.vue')); | ||
}); | ||
mkdir(path.join(pageDir, 'style'), function () { | ||
copyTemplate(path.join('style', 'index.less'), path.join(pageDir, 'style', 'index.less')); | ||
}); | ||
mkdir(path.join(pageDir, 'js'), function () { | ||
copyTemplate(path.join('js', 'index.js'), path.join(pageDir, 'js', 'index.js')); | ||
}); | ||
mkdir(path.join(pageDir, 'img'), function () { | ||
}); | ||
}); | ||
} else { | ||
console.log(pageDir + '文件夹已存在!'); | ||
} | ||
}); | ||
}); | ||
program.parse(process.argv); |
{ | ||
"name": "bili-sapp-cli", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Bilibili Small App Cli", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3496
7
65
1