npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

installer

v0.0.1

Published

template vm

Downloads

120

Readme

node-web-installer

基于Node.js的Web应用安装器,让小白用户可以通过简单的Web界面来完成应用的初始化配置

详见示例程序: 源码中的 example 目录

var fs = require('fs');
var path = require('path');
var ejs = require('ejs');
var installer = require('installer');
var mongoose = require('mongoose');


// 欢迎
installer.info({
  title:       'NodeClub安装向导',
  description: fs.readFileSync(__dirname + '/license.txt', 'utf8'),
  done:        fs.readFileSync(__dirname + '/done.txt', 'utf8')
});

installer.step(1, '数据库连接配置', function (step) {
  step.text('db', 'MongoDB连接字符串', 'mongodb://127.0.0.1/node_club_dev');
}, function (data, next) {
  // 检查能否正确连接到服务器
  mongoose.connection.close();
  mongoose.connect(data.db, function (err) {
    if (err) {
      next('db', err.toString());
    } else {
      installer.config('db', data.db);
      next();
    }
  });
});

installer.step(2, '设置管理员帐号', function (step) {
  step.text('admin_name', '用户名', 'admin');
  step.password('admin_pwd', '密码');
}, function (data, next) {
  // 添加到MongoDB中
  next();
});

installer.step(3, '网站设置', function (step) {
  step.group('基本设置', function () {
    step.text('name', '名称', 'Node Club');
    step.text('description', '简介', 'Node Club 是用Node.js开发的社区软件');
    step.text('host', '域名', 'localhost.cnodejs.org');
    step.file('site_logo', 'Logo');
  });
  step.group('SMTP发送邮件配置', function () {
    step.text('smtp_host', '主机', 'smtp.126.com');
    step.number('smtp_port', '端口', 25);
    step.text('smtp_user', '账户', '[email protected]');
    step.password('smtp_pwd', '密码');
  });
}, function (data, next) {
  installer.config(data);

  // 把Logo移到系统目录
  var site_logo = path.resolve(__dirname, '../public/logo.png');
  fileMoveTo(data.site_logo, site_logo);
  data.site_logo = site_logo;

  next();
});

// 完成
installer.done(function (next) {
  // 保存配置文件
  var config = installer.config();
  ejs.renderFile(path.resolve(__dirname, 'config.default.js'), config, function (err, content) {
    if (err) return next(err);

    fs.writeFileSync(path.resolve(__dirname, 'config.js'), content);
    next();
  });
});

// 启动Web界面
installer.listen(80);

// =============================================================================
/**
 * 移动文件
 *
 * @param {String} s
 * @param {String} t
 */
function fileMoveTo (s, t) {
  fs.writeFileSync(t, fs.readFileSync(s));
  fs.unlinkSync(s);
}