mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
decaffeinate: Convert coffee files to JS
This commit is contained in:
parent
d152a79810
commit
efd16d99d6
4 changed files with 899 additions and 677 deletions
|
@ -1,216 +1,311 @@
|
||||||
coffee = require("coffee-script")
|
/*
|
||||||
fs = require "fs"
|
* decaffeinate suggestions:
|
||||||
spawn = require("child_process").spawn
|
* DS101: Remove unnecessary use of Array.from
|
||||||
exec = require("child_process").exec
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
rimraf = require "rimraf"
|
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
|
||||||
Path = require "path"
|
* DS205: Consider reworking code to avoid use of IIFEs
|
||||||
semver = require "semver"
|
* DS207: Consider shorter variations of null checks
|
||||||
knox = require "knox"
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
crypto = require "crypto"
|
*/
|
||||||
async = require "async"
|
const coffee = require("coffee-script");
|
||||||
settings = require("settings-sharelatex")
|
const fs = require("fs");
|
||||||
_ = require("underscore")
|
const {
|
||||||
|
spawn
|
||||||
|
} = require("child_process");
|
||||||
|
const {
|
||||||
|
exec
|
||||||
|
} = require("child_process");
|
||||||
|
const rimraf = require("rimraf");
|
||||||
|
const Path = require("path");
|
||||||
|
const semver = require("semver");
|
||||||
|
const knox = require("knox");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
const async = require("async");
|
||||||
|
const settings = require("settings-sharelatex");
|
||||||
|
const _ = require("underscore");
|
||||||
|
|
||||||
|
|
||||||
SERVICES = require("./config/services")
|
const SERVICES = require("./config/services");
|
||||||
|
|
||||||
module.exports = (grunt) ->
|
module.exports = function(grunt) {
|
||||||
grunt.loadNpmTasks 'grunt-bunyan'
|
let Helpers;
|
||||||
grunt.loadNpmTasks 'grunt-execute'
|
let service;
|
||||||
grunt.loadNpmTasks 'grunt-available-tasks'
|
grunt.loadNpmTasks('grunt-bunyan');
|
||||||
grunt.loadNpmTasks 'grunt-concurrent'
|
grunt.loadNpmTasks('grunt-execute');
|
||||||
grunt.loadNpmTasks "grunt-contrib-coffee"
|
grunt.loadNpmTasks('grunt-available-tasks');
|
||||||
grunt.loadNpmTasks "grunt-shell"
|
grunt.loadNpmTasks('grunt-concurrent');
|
||||||
|
grunt.loadNpmTasks("grunt-contrib-coffee");
|
||||||
|
grunt.loadNpmTasks("grunt-shell");
|
||||||
|
|
||||||
grunt.task.loadTasks "./tasks"
|
grunt.task.loadTasks("./tasks");
|
||||||
|
|
||||||
execute = {}
|
const execute = {};
|
||||||
for service in SERVICES
|
for (service of Array.from(SERVICES)) {
|
||||||
execute[service.name] =
|
execute[service.name] =
|
||||||
src: "#{service.name}/app.js"
|
{src: `${service.name}/app.js`};
|
||||||
|
}
|
||||||
|
|
||||||
grunt.initConfig
|
grunt.initConfig({
|
||||||
execute: execute
|
execute,
|
||||||
|
|
||||||
concurrent:
|
concurrent: {
|
||||||
all:
|
all: {
|
||||||
tasks: ("run:#{service.name}" for service in SERVICES)
|
tasks: (((() => {
|
||||||
options:
|
const result = [];
|
||||||
limit: SERVICES.length
|
for (service of Array.from(SERVICES)) { result.push(`run:${service.name}`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
})())),
|
||||||
|
options: {
|
||||||
|
limit: SERVICES.length,
|
||||||
logConcurrentOutput: true
|
logConcurrentOutput: true
|
||||||
|
|
||||||
availabletasks:
|
availabletasks: {
|
||||||
tasks:
|
tasks: {
|
||||||
options:
|
options: {
|
||||||
filter: 'exclude',
|
filter: 'exclude',
|
||||||
tasks: [
|
tasks: [
|
||||||
'concurrent'
|
'concurrent',
|
||||||
'execute'
|
'execute',
|
||||||
'bunyan'
|
'bunyan',
|
||||||
'availabletasks'
|
'availabletasks'
|
||||||
]
|
],
|
||||||
groups:
|
groups: {
|
||||||
"Run tasks": [
|
"Run tasks": [
|
||||||
"run"
|
"run",
|
||||||
"run:all"
|
"run:all",
|
||||||
"default"
|
"default"
|
||||||
].concat ("run:#{service.name}" for service in SERVICES)
|
].concat(((() => {
|
||||||
|
const result1 = [];
|
||||||
|
for (service of Array.from(SERVICES)) { result1.push(`run:${service.name}`);
|
||||||
|
}
|
||||||
|
return result1;
|
||||||
|
})())),
|
||||||
"Misc": [
|
"Misc": [
|
||||||
"help"
|
"help"
|
||||||
]
|
],
|
||||||
"Install tasks": ("install:#{service.name}" for service in SERVICES).concat(["install:all", "install"])
|
"Install tasks": ((() => {
|
||||||
"Update tasks": ("update:#{service.name}" for service in SERVICES).concat(["update:all", "update"])
|
const result2 = [];
|
||||||
|
for (service of Array.from(SERVICES)) { result2.push(`install:${service.name}`);
|
||||||
|
}
|
||||||
|
return result2;
|
||||||
|
})()).concat(["install:all", "install"]),
|
||||||
|
"Update tasks": ((() => {
|
||||||
|
const result3 = [];
|
||||||
|
for (service of Array.from(SERVICES)) { result3.push(`update:${service.name}`);
|
||||||
|
}
|
||||||
|
return result3;
|
||||||
|
})()).concat(["update:all", "update"]),
|
||||||
"Checks": ["check", "check:redis", "check:latexmk", "check:s3", "check:make", "check:mongo"]
|
"Checks": ["check", "check:redis", "check:latexmk", "check:s3", "check:make", "check:mongo"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
|
||||||
for service in SERVICES
|
for (service of Array.from(SERVICES)) {
|
||||||
do (service) ->
|
((service => grunt.registerTask(`install:${service.name}`, `Download and set up the ${service.name} service`, function() {
|
||||||
grunt.registerTask "install:#{service.name}", "Download and set up the #{service.name} service", () ->
|
const done = this.async();
|
||||||
done = @async()
|
return Helpers.installService(service, done);
|
||||||
Helpers.installService(service, done)
|
})))(service);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
grunt.registerTask 'install:all', "Download and set up all ShareLaTeX services",
|
grunt.registerTask('install:all', "Download and set up all ShareLaTeX services",
|
||||||
[].concat(
|
[].concat(
|
||||||
("install:#{service.name}" for service in SERVICES)
|
((() => {
|
||||||
|
const result4 = [];
|
||||||
|
for (service of Array.from(SERVICES)) { result4.push(`install:${service.name}`);
|
||||||
|
}
|
||||||
|
return result4;
|
||||||
|
})())
|
||||||
).concat(['postinstall'])
|
).concat(['postinstall'])
|
||||||
|
);
|
||||||
|
|
||||||
grunt.registerTask 'install', 'install:all'
|
grunt.registerTask('install', 'install:all');
|
||||||
grunt.registerTask 'postinstall', 'Explain postinstall steps', () ->
|
grunt.registerTask('postinstall', 'Explain postinstall steps', function() {
|
||||||
Helpers.postinstallMessage @async()
|
return Helpers.postinstallMessage(this.async());
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask 'update:all', "Checkout and update all ShareLaTeX services",
|
grunt.registerTask('update:all', "Checkout and update all ShareLaTeX services",
|
||||||
["check:make"].concat(
|
["check:make"].concat(
|
||||||
("update:#{service.name}" for service in SERVICES)
|
((() => {
|
||||||
|
const result5 = [];
|
||||||
|
for (service of Array.from(SERVICES)) { result5.push(`update:${service.name}`);
|
||||||
|
}
|
||||||
|
return result5;
|
||||||
|
})())
|
||||||
)
|
)
|
||||||
grunt.registerTask 'update', 'update:all'
|
);
|
||||||
grunt.registerTask 'run', "Run all of the sharelatex processes", ['concurrent:all']
|
grunt.registerTask('update', 'update:all');
|
||||||
grunt.registerTask 'run:all', 'run'
|
grunt.registerTask('run', "Run all of the sharelatex processes", ['concurrent:all']);
|
||||||
|
grunt.registerTask('run:all', 'run');
|
||||||
|
|
||||||
grunt.registerTask 'help', 'Display this help list', 'availabletasks'
|
grunt.registerTask('help', 'Display this help list', 'availabletasks');
|
||||||
grunt.registerTask 'default', 'run'
|
grunt.registerTask('default', 'run');
|
||||||
|
|
||||||
grunt.registerTask "check:redis", "Check that redis is installed and running", () ->
|
grunt.registerTask("check:redis", "Check that redis is installed and running", function() {
|
||||||
Helpers.checkRedisConnect @async()
|
return Helpers.checkRedisConnect(this.async());
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask "check:mongo", "Check that mongo is installed", () ->
|
grunt.registerTask("check:mongo", "Check that mongo is installed", function() {
|
||||||
Helpers.checkMongoConnect @async()
|
return Helpers.checkMongoConnect(this.async());
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:mongo", "check:make"]
|
grunt.registerTask("check", "Check that you have the required dependencies installed", ["check:redis", "check:mongo", "check:make"]);
|
||||||
|
|
||||||
grunt.registerTask "check:make", "Check that make is installed", () ->
|
grunt.registerTask("check:make", "Check that make is installed", function() {
|
||||||
Helpers.checkMake @async()
|
return Helpers.checkMake(this.async());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Helpers =
|
return Helpers = {
|
||||||
installService: (service, callback = (error) ->) ->
|
installService(service, callback) {
|
||||||
console.log "Installing #{service.name}"
|
if (callback == null) { callback = function(error) {}; }
|
||||||
Helpers.cloneGitRepo service, (error) ->
|
console.log(`Installing ${service.name}`);
|
||||||
if error?
|
return Helpers.cloneGitRepo(service, function(error) {
|
||||||
callback(error)
|
if (error != null) {
|
||||||
else
|
return callback(error);
|
||||||
callback()
|
} else {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
cloneGitRepo: (service, callback = (error) ->) ->
|
cloneGitRepo(service, callback) {
|
||||||
repo_src = service.repo
|
if (callback == null) { callback = function(error) {}; }
|
||||||
dir = service.name
|
const repo_src = service.repo;
|
||||||
if !fs.existsSync(dir)
|
const dir = service.name;
|
||||||
proc = spawn "git", [
|
if (!fs.existsSync(dir)) {
|
||||||
|
const proc = spawn("git", [
|
||||||
"clone",
|
"clone",
|
||||||
repo_src,
|
repo_src,
|
||||||
dir
|
dir
|
||||||
], stdio: "inherit"
|
], {stdio: "inherit"});
|
||||||
proc.on "close", () ->
|
return proc.on("close", () => Helpers.checkoutVersion(service, callback));
|
||||||
Helpers.checkoutVersion service, callback
|
} else {
|
||||||
else
|
console.log(`${dir} already installed, skipping.`);
|
||||||
console.log "#{dir} already installed, skipping."
|
return callback();
|
||||||
callback()
|
}
|
||||||
|
},
|
||||||
|
|
||||||
checkoutVersion: (service, callback = (error) ->) ->
|
checkoutVersion(service, callback) {
|
||||||
dir = service.name
|
if (callback == null) { callback = function(error) {}; }
|
||||||
grunt.log.write "checking out #{service.name} #{service.version}"
|
const dir = service.name;
|
||||||
proc = spawn "git", ["checkout", service.version], stdio: "inherit", cwd: dir
|
grunt.log.write(`checking out ${service.name} ${service.version}`);
|
||||||
proc.on "close", () ->
|
const proc = spawn("git", ["checkout", service.version], {stdio: "inherit", cwd: dir});
|
||||||
callback()
|
return proc.on("close", () => callback());
|
||||||
|
},
|
||||||
|
|
||||||
postinstallMessage: (callback = (error) ->) ->
|
postinstallMessage(callback) {
|
||||||
grunt.log.write """
|
if (callback == null) { callback = function(error) {}; }
|
||||||
Services cloned:
|
grunt.log.write(`\
|
||||||
#{service.name for service in SERVICES}
|
Services cloned:
|
||||||
To install services run:
|
${(() => {
|
||||||
$ source bin/install-services
|
const result6 = [];
|
||||||
This will install the required node versions and run `npm install` for each service.
|
for (service of Array.from(SERVICES)) { result6.push(service.name);
|
||||||
See https://github.com/sharelatex/sharelatex/pull/549 for more info.
|
}
|
||||||
"""
|
return result6;
|
||||||
callback()
|
})()}
|
||||||
|
To install services run:
|
||||||
|
$ source bin/install-services
|
||||||
|
This will install the required node versions and run \`npm install\` for each service.
|
||||||
|
See https://github.com/sharelatex/sharelatex/pull/549 for more info.\
|
||||||
|
`
|
||||||
|
);
|
||||||
|
return callback();
|
||||||
|
},
|
||||||
|
|
||||||
checkMake: (callback = (error) ->) ->
|
checkMake(callback) {
|
||||||
grunt.log.write "Checking make is installed... "
|
if (callback == null) { callback = function(error) {}; }
|
||||||
exec "make --version", (error, stdout, stderr) ->
|
grunt.log.write("Checking make is installed... ");
|
||||||
if error? and error.message.match("not found")
|
return exec("make --version", function(error, stdout, stderr) {
|
||||||
grunt.log.error "FAIL."
|
if ((error != null) && error.message.match("not found")) {
|
||||||
grunt.log.errorlns """
|
grunt.log.error("FAIL.");
|
||||||
Either make is not installed or is not in your path.
|
grunt.log.errorlns(`\
|
||||||
|
Either make is not installed or is not in your path.
|
||||||
|
|
||||||
On Ubuntu you can install make with:
|
On Ubuntu you can install make with:
|
||||||
|
|
||||||
sudo apt-get install build-essential
|
sudo apt-get install build-essential
|
||||||
|
\
|
||||||
|
`
|
||||||
|
);
|
||||||
|
return callback(error);
|
||||||
|
} else if (error != null) {
|
||||||
|
return callback(error);
|
||||||
|
} else {
|
||||||
|
grunt.log.write("OK.");
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
checkMongoConnect(callback) {
|
||||||
|
if (callback == null) { callback = function(error) {}; }
|
||||||
|
grunt.log.write("Checking can connect to mongo");
|
||||||
|
const mongojs = require("mongojs");
|
||||||
|
const db = mongojs(settings.mongo.url, ["tags"]);
|
||||||
|
db.runCommand({ ping: 1 }, function(err, res) {
|
||||||
|
if (!err && res.ok) {
|
||||||
|
grunt.log.write("OK.");
|
||||||
|
}
|
||||||
|
return callback();
|
||||||
|
});
|
||||||
|
return db.on('error', function(err){
|
||||||
|
err = "Can not connect to mongodb";
|
||||||
|
grunt.log.error("FAIL.");
|
||||||
|
grunt.log.errorlns(`\
|
||||||
|
!!!!!!!!!!!!!! MONGO ERROR !!!!!!!!!!!!!!
|
||||||
|
|
||||||
"""
|
ShareLaTeX can not talk to the mongodb instance
|
||||||
return callback(error)
|
|
||||||
else if error?
|
|
||||||
return callback(error)
|
|
||||||
else
|
|
||||||
grunt.log.write "OK."
|
|
||||||
return callback()
|
|
||||||
checkMongoConnect: (callback = (error) ->) ->
|
|
||||||
grunt.log.write "Checking can connect to mongo"
|
|
||||||
mongojs = require("mongojs")
|
|
||||||
db = mongojs(settings.mongo.url, ["tags"])
|
|
||||||
db.runCommand { ping: 1 }, (err, res) ->
|
|
||||||
if !err and res.ok
|
|
||||||
grunt.log.write "OK."
|
|
||||||
return callback()
|
|
||||||
db.on 'error', (err)->
|
|
||||||
err = "Can not connect to mongodb"
|
|
||||||
grunt.log.error "FAIL."
|
|
||||||
grunt.log.errorlns """
|
|
||||||
!!!!!!!!!!!!!! MONGO ERROR !!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
ShareLaTeX can not talk to the mongodb instance
|
Check the mongodb instance is running and accessible on env var SHARELATEX_MONGO_URL
|
||||||
|
|
||||||
Check the mongodb instance is running and accessible on env var SHARELATEX_MONGO_URL
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
|
||||||
|
`
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
);
|
||||||
"""
|
throw new Error("Can not connect to Mongodb");
|
||||||
throw new Error("Can not connect to Mongodb")
|
return callback(err);
|
||||||
return callback(err)
|
});
|
||||||
|
},
|
||||||
|
|
||||||
checkRedisConnect: (callback = (error) ->) ->
|
checkRedisConnect(callback) {
|
||||||
grunt.log.write "Checking can connect to redis\n"
|
if (callback == null) { callback = function(error) {}; }
|
||||||
rclient = require("redis").createClient(settings.redis.web)
|
grunt.log.write("Checking can connect to redis\n");
|
||||||
|
const rclient = require("redis").createClient(settings.redis.web);
|
||||||
|
|
||||||
rclient.ping (err, res) ->
|
rclient.ping(function(err, res) {
|
||||||
if !err?
|
if ((err == null)) {
|
||||||
grunt.log.write "OK."
|
grunt.log.write("OK.");
|
||||||
else
|
} else {
|
||||||
throw new Error("Can not connect to redis")
|
throw new Error("Can not connect to redis");
|
||||||
return callback()
|
}
|
||||||
errorHandler = _.once (err)->
|
return callback();
|
||||||
err = "Can not connect to redis"
|
});
|
||||||
grunt.log.error "FAIL."
|
const errorHandler = _.once(function(err){
|
||||||
grunt.log.errorlns """
|
err = "Can not connect to redis";
|
||||||
!!!!!!!!!!!!!! REDIS ERROR !!!!!!!!!!!!!!
|
grunt.log.error("FAIL.");
|
||||||
|
grunt.log.errorlns(`\
|
||||||
|
!!!!!!!!!!!!!! REDIS ERROR !!!!!!!!!!!!!!
|
||||||
|
|
||||||
ShareLaTeX can not talk to the redis instance
|
ShareLaTeX can not talk to the redis instance
|
||||||
|
|
||||||
Check the redis instance is running and accessible on env var SHARELATEX_REDIS_HOST
|
Check the redis instance is running and accessible on env var SHARELATEX_REDIS_HOST
|
||||||
|
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
|
||||||
"""
|
`
|
||||||
throw new Error("Can not connect to redis")
|
);
|
||||||
return callback(err)
|
throw new Error("Can not connect to redis");
|
||||||
rclient.on 'error', errorHandler
|
return callback(err);
|
||||||
|
});
|
||||||
|
return rclient.on('error', errorHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function __guard__(value, transform) {
|
||||||
|
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,60 +1,79 @@
|
||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = (grunt) ->
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.registerTask 'user:create-admin', "Create a user with the given email address and make them an admin. Update in place if the user already exists. Usage: grunt user:create-admin --email joe@example.com", () ->
|
grunt.registerTask('user:create-admin', "Create a user with the given email address and make them an admin. Update in place if the user already exists. Usage: grunt user:create-admin --email joe@example.com", function() {
|
||||||
done = @async()
|
const done = this.async();
|
||||||
email = grunt.option("email")
|
const email = grunt.option("email");
|
||||||
if !email?
|
if ((email == null)) {
|
||||||
console.error "Usage: grunt user:create-admin --email=joe@example.com"
|
console.error("Usage: grunt user:create-admin --email=joe@example.com");
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
settings = require "settings-sharelatex"
|
const settings = require("settings-sharelatex");
|
||||||
mongodb = require "../web/app/src/infrastructure/mongodb"
|
const mongodb = require("../web/app/src/infrastructure/mongodb");
|
||||||
UserRegistrationHandler = require "../web/app/src/Features/User/UserRegistrationHandler"
|
const UserRegistrationHandler = require("../web/app/src/Features/User/UserRegistrationHandler");
|
||||||
OneTimeTokenHandler = require "../web/app/src/Features/Security/OneTimeTokenHandler"
|
const OneTimeTokenHandler = require("../web/app/src/Features/Security/OneTimeTokenHandler");
|
||||||
mongodb.waitForDb().then () ->
|
return mongodb.waitForDb().then(() => UserRegistrationHandler.registerNewUser({
|
||||||
UserRegistrationHandler.registerNewUser {
|
email,
|
||||||
email: email
|
password: require("crypto").randomBytes(32).toString("hex")
|
||||||
password: require("crypto").randomBytes(32).toString("hex")
|
}, function(error, user) {
|
||||||
}, (error, user) ->
|
if ((error != null) && ((error != null ? error.message : undefined) !== "EmailAlreadyRegistered")) {
|
||||||
if error? and error?.message != "EmailAlreadyRegistered"
|
throw error;
|
||||||
throw error
|
}
|
||||||
user.isAdmin = true
|
user.isAdmin = true;
|
||||||
user.save (error) ->
|
return user.save(function(error) {
|
||||||
throw error if error?
|
if (error != null) { throw error; }
|
||||||
ONE_WEEK = 7 * 24 * 60 * 60 # seconds
|
const ONE_WEEK = 7 * 24 * 60 * 60; // seconds
|
||||||
OneTimeTokenHandler.getNewToken "password", { expiresIn: ONE_WEEK, email:user.email, user_id: user._id.toString() }, (err, token)->
|
return OneTimeTokenHandler.getNewToken("password", { expiresIn: ONE_WEEK, email:user.email, user_id: user._id.toString() }, function(err, token){
|
||||||
return next(err) if err?
|
if (err != null) { return next(err); }
|
||||||
|
|
||||||
console.log ""
|
console.log("");
|
||||||
console.log """
|
console.log(`\
|
||||||
Successfully created #{email} as an admin user.
|
Successfully created ${email} as an admin user.
|
||||||
|
|
||||||
Please visit the following URL to set a password for #{email} and log in:
|
Please visit the following URL to set a password for ${email} and log in:
|
||||||
|
|
||||||
#{settings.siteUrl}/user/password/set?passwordResetToken=#{token}
|
${settings.siteUrl}/user/password/set?passwordResetToken=${token}
|
||||||
|
\
|
||||||
|
`
|
||||||
|
);
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
"""
|
return grunt.registerTask('user:delete', "deletes a user and all their data, Usage: grunt user:delete --email joe@example.com", function() {
|
||||||
done()
|
const done = this.async();
|
||||||
|
const email = grunt.option("email");
|
||||||
grunt.registerTask 'user:delete', "deletes a user and all their data, Usage: grunt user:delete --email joe@example.com", () ->
|
if ((email == null)) {
|
||||||
done = @async()
|
console.error("Usage: grunt user:delete --email=joe@example.com");
|
||||||
email = grunt.option("email")
|
process.exit(1);
|
||||||
if !email?
|
}
|
||||||
console.error "Usage: grunt user:delete --email=joe@example.com"
|
const settings = require("settings-sharelatex");
|
||||||
process.exit(1)
|
const mongodb = require("../web/app/src/infrastructure/mongodb");
|
||||||
settings = require "settings-sharelatex"
|
const UserGetter = require("../web/app/src/Features/User/UserGetter");
|
||||||
mongodb = require "../web/app/src/infrastructure/mongodb"
|
const UserDeleter = require("../web/app/src/Features/User/UserDeleter");
|
||||||
UserGetter = require "../web/app/src/Features/User/UserGetter"
|
return mongodb.waitForDb().then(() => UserGetter.getUser({email}, function(error, user) {
|
||||||
UserDeleter = require "../web/app/src/Features/User/UserDeleter"
|
if (error != null) {
|
||||||
mongodb.waitForDb().then () ->
|
throw error;
|
||||||
UserGetter.getUser email:email, (error, user) ->
|
}
|
||||||
if error?
|
if ((user == null)) {
|
||||||
throw error
|
console.log(`user ${email} not in database, potentially already deleted`);
|
||||||
if !user?
|
return done();
|
||||||
console.log("user #{email} not in database, potentially already deleted")
|
}
|
||||||
return done()
|
return UserDeleter.deleteUser(user._id, function(err){
|
||||||
UserDeleter.deleteUser user._id, (err)->
|
if (err != null) {
|
||||||
if err?
|
throw err;
|
||||||
throw err
|
}
|
||||||
done()
|
return done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# require("coffee-script")
|
// require("coffee-script")
|
||||||
|
|
||||||
# fs = require("fs")
|
// fs = require("fs")
|
||||||
# _ = require("underscore")
|
// _ = require("underscore")
|
||||||
|
|
||||||
# if not process.argv[2]
|
// if not process.argv[2]
|
||||||
# console.log "Usage: coffee project_size.coffee user_files_path"
|
// console.log "Usage: coffee project_size.coffee user_files_path"
|
||||||
# else
|
// else
|
||||||
# dirPath = process.argv[2]
|
// dirPath = process.argv[2]
|
||||||
# if not fs.lstatSync(dirPath).isDirectory()
|
// if not fs.lstatSync(dirPath).isDirectory()
|
||||||
# console.log dirPath + " directory not exist"
|
// console.log dirPath + " directory not exist"
|
||||||
# else
|
// else
|
||||||
# fs.readdir dirPath, (err, files)->
|
// fs.readdir dirPath, (err, files)->
|
||||||
# projects = []
|
// projects = []
|
||||||
# files.forEach (file)->
|
// files.forEach (file)->
|
||||||
# project_id = file.split("_")[0]
|
// project_id = file.split("_")[0]
|
||||||
# if !projects[project_id]
|
// if !projects[project_id]
|
||||||
# projects[project_id] = 0
|
// projects[project_id] = 0
|
||||||
# projects[project_id] += fs.lstatSync(dirPath+"/"+file).size
|
// projects[project_id] += fs.lstatSync(dirPath+"/"+file).size
|
||||||
|
|
||||||
# ids = _.keys projects
|
// ids = _.keys projects
|
||||||
# console.log "project \t size"
|
// console.log "project \t size"
|
||||||
# ids.forEach (id)->
|
// ids.forEach (id)->
|
||||||
# console.log id + "\t" + projects[id]
|
// console.log id + "\t" + projects[id]
|
||||||
|
|
Loading…
Reference in a new issue