New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bili-sapp-cli

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bili-sapp-cli - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

app-template/babelrc.json

100

index.js
#!/usr/bin/env node
var program = require('commander');
var download = require('download');
var ora = require('ora');
var info = require('./package.json');
var fs = require('fs');
var path = require('path');
var projectTpl = 'http://172.16.33.203/template.zip';
const program = require('commander');
const download = require('download');
const ora = require('ora');
const info = require('./package.json');
const fs = require('fs');
const path = require('path');
const projectTpl = 'http://172.16.33.203/template.zip';
const express = require('express');
const copyDir = require('copy-dir');
const APP_TEMPLATE = path.join(__dirname, 'app-template');
const PAGE_TEMPLATE = path.join(__dirname, 'page-template');
function copyApp(from, to) {
fs.copyFileSync(path.join(APP_TEMPLATE, from), to);
}
program.version(info.version, '-v, --version');

@@ -15,6 +24,9 @@

.command('init <project-name>')
.description('generate a new project from template')
.description('使用模板创建新项目')
.action(function (projectName) {
var spinner = ora('Downloading template ...').start();
const spinner = ora('Downloading template ...').start();
download(projectTpl, projectName, {extract: true}).then(function () {
copyApp('sapprc.json', path.join('.', projectName, '.sapprc'));
copyApp('babelrc.json', path.join('.', projectName, '.babelrc'));
copyApp('gitignore', path.join('.', projectName, '.gitignore'));
spinner.stop();

@@ -30,49 +42,39 @@ console.log(' Generated "%s".\n', projectName);

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
.command('page <page-name>')
.description('create template page dir and files')
.action(function (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 () {
});
console.log('created page "%s"', pageName);
.description('新建page目录结构')
.action(pageName => {
if (fs.existsSync('.sapprc')) {
const pageDir = path.join('.', 'src', 'pages', pageName);
if (!fs.existsSync(pageDir)) {
copyDir(PAGE_TEMPLATE, pageDir, () => {
const appJson = path.join('src', 'app.json');
const appConfig = JSON.parse(fs.readFileSync(appJson, 'utf8'));
appConfig.pages.push('/pages/' + pageName);
fs.writeFileSync(appJson, JSON.stringify(appConfig, null, ' '), 'utf8');
console.log(pageName + ' 创建成功');
});
} else {
console.log(pageDir + '文件夹已存在!');
console.log(pageName + ' 文件夹已存在');
}
});
} else {
console.log('当前目录不是小程序项目根目录');
}
});
program
.command('serve')
.description('开启真机调试服务')
.action(directory => {
const projectRoot = path.resolve('.');
if (fs.existsSync(path.join(projectRoot, '.sapprc'))) {
const app = express();
app.get('/', (req, res) => res.send('Small App Static Server'));
app.use(express.static(path.join(projectRoot, 'zip')));
app.listen(3000, () => console.log('真机调试服务正在运行,可以用手机扫码调试构建出来的安装包啦'));
} else {
console.log('当前目录不是小程序项目根目录');
}
});
program.parse(process.argv);
{
"name": "bili-sapp-cli",
"version": "0.0.9",
"version": "0.0.10",
"description": "Bilibili Small App Cli",

@@ -23,5 +23,7 @@ "main": "index.js",

"commander": "^2.15.1",
"copy-dir": "^0.4.0",
"download": "^7.0.0",
"express": "^4.16.3",
"ora": "^2.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc