Procházet zdrojové kódy

remove unnecessary files

Yuki Takei před 8 roky
rodič
revize
98c484677c

+ 0 - 73
bin/migration/0.0.1-0.0.2-convert_embedded_object_to_schema.js

@@ -1,73 +0,0 @@
-/**
- * Fakie::app.js
- *
- * @package Fakie
- * @author  Sotaro KARASAWA <sotarok@crocos.co.jp>
- * @version 0.0.0
- */
-
-var util    = require('util');
-var config  = require('config');
-var mongo   = require('mongoose');
-var async   = require('async');
-
-var user  =     require('../../lib/user');
-var page  =     require('../../lib/page');
-var revision  = require('../../lib/revision');
-
-mongo.connect('mongodb://' + config.mongodb.user + ':' + config.mongodb.password + '@' + config.mongodb.host + '/' + config.mongodb.dbname);
-module.exports = {
-  user: user
-  ,page: page
-  ,revision: revision
-};
-
-
-var options = {
-  offset: 0,
-  limit : 999,
-  revisionSlice: {$slice: 9999}
-};
-
-var q = page.Page.findListByStartWith('/', options, function(err, docs) {
-  var i = 0;
-  async.forEach(docs, function(data, cb) {
-    var ii = 0;
-    var path = data.path;
-    var pageId = data._id;
-    console.log("path: ", data._id, path);
-
-    async.forEachSeries(data.revisions, function(rData, rcb) {
-      var newRevision = new revision.Revision();
-      newRevision.path      = path;
-      newRevision.body      = rData.body;
-      newRevision.format    = rData.format;
-      newRevision.createdAt = rData.createdAt;
-      newRevision.save(function (err, n) {
-        if (!err) {
-          console.log("    ", path, ii++, rData.createdAt, " ... ok", n._id);
-        } else {
-          console.log("    ", path, ii++, rData.createdAt, " ... ERROR!");
-          console.log(err);
-        }
-        rcb();
-      });
-      //rcb();
-    }, function (rErr) {
-      console.log("    ", path, " all revision imported.");
-      revision.Revision.findLatestRevision(path, function(err, fr) {
-        page.Page.updateRevision(pageId, fr._id, function(err, frr) {
-          if (!err) {
-            console.log("        Page revision updated", pageId, path, i++);
-          } else {
-            console.log("        Page revision update ERROR", pageId, path, i++);
-          }
-          cb();
-        });
-      });
-    });
-  }, function(err) {
-    console.log('end');
-    mongo.disconnect();
-  });
-});

+ 0 - 25
bin/password-hash-generator.js

@@ -1,25 +0,0 @@
-var crypto = require('crypto')
-  , cli = require('cli')
-  ;
-
-function generatePassword (seed, password) {
-  var hasher = crypto.createHash('sha256');
-  hasher.update(seed + password);
-
-  cli.debug("seed is: " + seed);
-  cli.debug("password is: " + password);
-  return hasher.digest('hex');
-}
-
-cli.parse({
-    seed:      [false, 'Password seed', 'string', ''],
-    password:  [false, 'Password raw string', 'string'],
-});
-
-cli.main(function(args, options)
-{
-  console.log("args", args);
-  console.log("options", options);
-
-  this.output(generatePassword(options.seed, options.password) + '\n');
-});

+ 0 - 112
bin/revision-string-replacer.js

@@ -1,112 +0,0 @@
-var cli = require('cli')
- , mongo   = require('mongoose')
- , async   = require('async')
- ;
-
-cli.setUsage('MONGO_URI=mongodb://user:password@host/dbnae node bin/revision-string-replacer.js --from=\'aaa\' --to=\'bbb\'\n\n  This means that replace string "aaa" to "bbb" from all revisions.');
-cli.parse({
-    from: [false, 'Specified string is a target to replace.', 'string'],
-    to: [false, 'Replace string which specified by "from" to this string.', 'string'],
-    dry: [false, 'Dry run', 'boolean'],
-});
-
-
-cli.main(function(args, options)
-{
-  var app = {set: function(v) { }}
-    , c = this
-    , from = options.from
-    , to = options.to
-    , dry = options.dry
-    ;
-
-  console.log('This scriprt is not working now. Should be fixed.');
-  cli.exit(1);
-
-  if (!to || !from) {
-    cli.error('"to" and "from" options are required.\n');
-    cli.output(cli.getUsage());
-    cli.exit(1);
-    return ;
-  }
-
-  var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || process.env.MONGO_URI || false;
-  if (!mongoUri) {
-    cli.error('Please set MONGO_URI env.\n');
-    cli.output(cli.getUsage());
-    cli.exit(1);
-    return;
-  }
-
-  mongo.connect(mongoUri);
-
-  // あー config 読み込み&model読み込み周りを app.js から切り離さないといけないにゃぁ
-  configModel = require('../lib/models/config')(app);
-
-  async.series([
-    function (next) {
-      configModel.loadAllConfig(function(err, doc) {
-
-        return next();
-      });
-    }, function (next) {
-      var config = app.set('config');
-
-      models = require('../lib/models')(app);
-      models.Config = configModel;
-
-      return next();
-    }, function (next) {
-      var limit = 100000;
-      c.spinner('Load revisions..');
-      models.Revision.find().limit(limit).exec(function(err, revs) {
-        c.spinner('Load revisions.. done!\n', true);
-        var count = Object.keys(revs).length
-          , i = 0
-          , matched = 0
-          , matchedWords = 0
-          ;
-
-        c.output('Found ' + count + ' revisions.\n');
-        c.output('Start replacing.\n');
-
-        async.each(revs, function(rev, cb) {
-          var regexp = new RegExp(from, 'g');
-          c.progress(++i/count);
-
-          var m = rev.body.match(regexp);
-          if (!m) {
-            return cb();
-          }
-
-          matched++;
-          matchedWords += m.length;
-          if (dry) {
-            return cb();
-          } else {
-            rev.body = rev.body.replace(regexp, to);
-            rev.save(function(err, s) {
-              if (err) {
-                c.error('Error on:' + rev.path);
-              } else {
-              }
-              return cb();
-            });
-          }
-        }, function(err) {
-          if (dry) {
-            cli.info(matchedWords + ' words in (' + matched + ' of ' + count + ') revisions will be replaced!');
-          } else {
-            cli.ok(matchedWords + ' words in (' + matched + ' of ' + count + ') revisions replaced!');
-          }
-          return next();
-        });
-      });
-    }
-  , function (next) {
-      cli.ok('Finished!');
-      mongo.disconnect();
-      return next();
-    }
-  ]);
-});

+ 0 - 126
bin/search.js

@@ -1,126 +0,0 @@
-
-var program = require('commander')
-  , debug = require('debug')('growi:console:search-util')
-  , colors = require('colors')
-  , crowi = new (require('../lib/crowi'))(__dirname + '/../', process.env)
-  ;
-
-crowi.init()
-  .then(function(app) {
-    program
-      .version(crowi.version);
-
-    program
-      .command('create-index')
-      .action(function (cmd, env) {
-        var search = crowi.getSearcher();
-
-        search.buildIndex()
-          .then(function(data) {
-            console.log(data);
-          })
-          .then(function() {
-            process.exit();
-          })
-          .catch(function(err) {
-            console.log("Error", err);
-
-          })
-      });
-
-    program
-      .command('add-pages')
-      .action(function (cmd, env) {
-        var search = crowi.getSearcher();
-
-        search.addAllPages()
-          .then(function(data) {
-            if (data.errors) {
-              console.error(colors.red.underline('Failed to index all pages.'));
-              console.error("");
-              data.items.forEach(function(item, i) {
-                var index = item.index || null;
-                if (index && index.status != 200) {
-                  console.error(colors.red('Error item: id=%s'), index._id)
-                  console.error('error.type=%s, error.reason=%s', index.error.type, index.error.reason);
-                  console.error(index.error.caused_by);
-                }
-                //debug('Item', i, item);
-              });
-            } else {
-              console.log('Data is successfully indexed.');
-            }
-            process.exit(0);
-          })
-          .catch(function(err) {
-            console.log("Error", err);
-          });
-      });
-
-    program
-      .command('rebuild-index')
-      .action(function (cmd, env) {
-        var search = crowi.getSearcher();
-
-        search.deleteIndex()
-          .then(function(data) {
-            if (!data.errors) {
-              console.log('Index deleted.');
-            }
-            return search.buildIndex();
-          })
-          .then(function(data) {
-            if (!data.errors) {
-              console.log('Index created.');
-            }
-            return search.addAllPages();
-          })
-          .then(function(data) {
-            if (!data.errors) {
-              console.log('Data is successfully indexed.');
-            }
-            process.exit(0);
-          })
-          .catch(function(err) {
-            console.error('Error', err);
-          });
-      });
-
-    program
-      .command('search')
-      .action(function (cmd, env) {
-        var Page = crowi.model('Page');
-        var search = crowi.getSearcher();
-        var keyword = cmd;
-
-        search.searchKeyword(keyword, {})
-          .then(function(data) {
-            debug('result is', data);
-            console.log(colors.green('Search result: %d of %d total. (%d ms)'), data.meta.results, data.meta.total, data.meta.took);
-
-            return Page.populatePageListToAnyObjects(data.data);
-          }).then(function(pages) {
-            pages.map(function(page) {
-              console.log(page._score, page._id, page.path);
-            });
-
-            process.exit(0);
-          })
-          .catch(function(err) {
-            console.error('Error', err);
-
-            process.exit(0);
-          });
-      });
-
-
-    program.parse(process.argv);
-
-  });
-
-
-//program
-//  .command('search [query]', 'search with optional query')
-//  .command('list', 'list packages installed', {isDefault: true})
-
-

+ 0 - 44
bin/util.js

@@ -1,44 +0,0 @@
-var program = require('commander')
-  , debug = require('debug')('growi:console:util')
-  , colors = require('colors')
-  , crowi = new (require('../lib/crowi'))(__dirname + '/../', process.env)
-  ;
-
-crowi.init()
-  .then(function(app) {
-    program
-      .version(crowi.version);
-
-    program
-      .command('count-page-length')
-      .action(function (cmd, env) {
-        var Page = crowi.model('Page');
-        var stream = Page.getStreamOfFindAll();
-        var pages = [];
-
-        stream.on('data', function (doc) {
-          if (!doc.creator || !doc.revision) {
-            return ;
-          }
-
-          pages.push({
-            path: doc.path,
-            body: doc.revision.body,
-            author: doc.creator.username,
-          });
-        }).on('error', function (err) {
-          // TODO: handle err
-          debug('Error stream:', err);
-        }).on('close', function () {
-          // all done
-
-          pages.forEach(function(page, i) {
-            console.log('%d\t%s', page.body.length, page.path);
-          });
-
-          process.exit(0);
-        });
-      });
-
-    program.parse(process.argv);
-  });