Skip to content

Commit

Permalink
Ready to launch v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MeLlamoPablo committed Jan 5, 2017
1 parent 12bc1e8 commit 69caf3c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 82 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schedulebot",
"version": "1.0.6",
"version": "1.1.0",
"description": "A Discord bot that makes scheduling easy",
"homepage": "https://github.com/mellamopablo/schedulebot#readme",
"author": "Pablo Rodríguez <pabloviolin8@gmail.com> (https://github.com/MeLlamoPablo)",
Expand All @@ -15,11 +15,11 @@
],
"scripts": {
"bot": "node ./lib/index.js",
"setup": "node ./setup.js",
"setup-steam": "node ./setup-steam.js",
"setup": "node ./scripts/setup.js",
"setup-steam": "node ./scripts/setup-steam.js",
"update": "node ./scripts/update.js",
"prepublish": "gulp nsp",
"postinstall": "node ./postinstall.js"
"postinstall": "node ./scripts/postinstall.js",
"prepublish": "gulp nsp"
},
"devDependencies": {
"gulp": "^3.9.0",
Expand Down
File renamed without changes.
37 changes: 4 additions & 33 deletions setup-steam.js → scripts/setup-steam.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const dbDetailsGen = require("./shared/db-details");
const fs = require("fs");
const inquirer = require("inquirer");
const pg = require("pg");
let cfg = require("./config");
let cfg = require("../config");

// So that we don't get a "can't read property of undefined" error
cfg.db = cfg.db || {};
let dbDetails = dbDetailsGen(cfg.db);

console.log("Hello! Welcome to the ScheduleBot setup script - Steam edition!\n" +
"This script assumes that you've already created your database structure with:\n\n" +
Expand All @@ -16,38 +18,7 @@ console.log("Hello! Welcome to the ScheduleBot setup script - Steam edition!\n"
"This script will store your Steam bot credentials in the database,\n" +
"so first we need to connect to it.\n");

inquirer.prompt([
{
type: "input",
name: "db_host",
message: "Host",
default: cfg.db.host || null
},
{
type: "input",
name: "db_database",
message: "Database",
default: cfg.db.database || null
},
{
type: "input",
name: "db_user",
message: "User",
default: cfg.db.user || null
},
{
type: "password",
name: "db_password",
message: "Password",
default: cfg.db.password || null
},
{
type: "confirm",
name: "db_ssl",
message: "Use SSL?",
default: true
}
]).then(answers => {
inquirer.prompt(dbDetails).then(answers => {

pg.defaults.ssl = answers.db_ssl;

Expand Down
46 changes: 8 additions & 38 deletions setup.js → scripts/setup.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,18 @@
const fs = require("fs");
const inquirer = require("inquirer");
const pg = require("pg");
let cfg = require("./config");

const dbDetailsGen = require("./shared/db-details");
const fs = require("fs");
const inquirer = require("inquirer");
const pg = require("pg");
let cfg = require("../config");

// So that we don't get a "can't read property of undefined" error
cfg.db = cfg.db || {};
let dbDetails = dbDetailsGen(cfg.db);

console.log("Hello! Welcome to the ScheduleBot setup script.\n" +
"This script will create your database structure to get ScheduleBot working.\n" +
"First, let's connect to your postgres database. Enter your db info:\n");

inquirer.prompt([
{
type: "input",
name: "db_host",
message: "Host",
default: cfg.db.host || null
},
{
type: "input",
name: "db_database",
message: "Database",
default: cfg.db.database || null
},
{
type: "input",
name: "db_user",
message: "User",
default: cfg.db.user || null
},
{
type: "password",
name: "db_password",
message: "Password",
default: cfg.db.password || null
},
{
type: "confirm",
name: "db_ssl",
message: "Use SSL?",
default: true
}
]).then(answers => {
inquirer.prompt(dbDetails).then(answers => {
pg.defaults.ssl = answers.db_ssl;

let conStr = "postgres://" + answers.db_user + ":" + answers.db_password
Expand Down Expand Up @@ -156,7 +126,7 @@ function createDbStructure(client) {
return new Promise((fulfill, reject) => {
let sql;
try {
sql = fs.readFileSync("./db_setup.sql", {encoding: "utf-8"});
sql = fs.readFileSync("./scripts/sql/db_setup.sql", {encoding: "utf-8"});
} catch (err) {
reject(err);
}
Expand Down
1 change: 1 addition & 0 deletions scripts/shared/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"v1.1.0-dota",
"v1.0.6-dota",
"v1.0.5-dota",
"v1.0.4-dota",
Expand Down
12 changes: 12 additions & 0 deletions scripts/sql/1.0.6-to-1.1.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- !!! WARNING !!!
--
-- By updating to v1.1.0-dota, all your events (and therefore, all confirms) will be removed. If
-- you want to keep them, backup your database first. The rest of your data will be fine.

TRUNCATE TABLE public.events
RESTART IDENTITY
CASCADE;

ALTER TABLE public.events ADD instant BOOLEAN DEFAULT FALSE NOT NULL;
ALTER TABLE public.events DROP lobby_ended;
ALTER TABLE public.events ADD lobby_status INT DEFAULT 1 NOT NULL;
4 changes: 2 additions & 2 deletions db_setup.sql → scripts/sql/db_setup.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--TODO update this script as well
CREATE TABLE public.config
(
bot_token TEXT,
Expand Down Expand Up @@ -29,7 +28,8 @@ CREATE TABLE events
"limit" INTEGER DEFAULT 5,
waiting JSON,
inhouse JSON,
lobby_ended BOOLEAN DEFAULT false NOT NULL
instant BOOLEAN DEFAULT FALSE NOT NULL,
lobby_status INT DEFAULT 1 NOT NULL
);

CREATE TABLE confirms
Expand Down
3 changes: 0 additions & 3 deletions scripts/sql/next_version.sql

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function loadScripts(fileNames) {
return new Promise((fulfill, reject) => {
let readScriptPromisess = [];
for (let i = 0; i < fileNames.length; i++) {
readScriptPromisess.push(readFile("./sql/" + fileNames[i]));
readScriptPromisess.push(readFile("./scripts/sql/" + fileNames[i]));
}

Promise.all(readScriptPromisess).then(scripts => {
Expand Down

0 comments on commit 69caf3c

Please sign in to comment.