Commit 7d14912d authored by Clive Makamara's avatar Clive Makamara

WIP

parent 44353c64
{
"presets": ["es2015"]
}
\ No newline at end of file
{
"data": {
"user": [
{
"name": "cmosh",
"email": "usew",
"createdAt": "2017-02-14T13:32:30.380Z",
"updatedAt": "2017-02-14T13:32:30.380Z",
"id": 1
},
{
"name": "cmosh",
"email": "usew",
"createdAt": "2017-02-14T13:34:29.809Z",
"updatedAt": "2017-02-14T13:34:29.809Z",
"id": 2
}
],
"project": [],
"entry": []
},
"schema": {
"user": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"id": {
"type": "integer",
"autoIncrement": true,
"primaryKey": true,
"unique": true
},
"createdAt": {
"type": "datetime"
},
"updatedAt": {
"type": "datetime"
}
},
"project": {
"repoUrl": {
"type": "string"
},
"origin": {
"type": "string"
},
"owner": {
"type": "integer",
"model": "user",
"foreignKey": true,
"alias": "owner"
},
"id": {
"type": "integer",
"autoIncrement": true,
"primaryKey": true,
"unique": true
},
"createdAt": {
"type": "datetime"
},
"updatedAt": {
"type": "datetime"
}
},
"entry": {
"timestamp": {
"type": "string"
},
"type": {
"type": "string"
},
"tracking": {
"type": "integer",
"model": "project",
"foreignKey": true,
"alias": "tracking"
},
"id": {
"type": "integer",
"autoIncrement": true,
"primaryKey": true,
"unique": true
},
"createdAt": {
"type": "datetime"
},
"updatedAt": {
"type": "datetime"
}
}
},
"counters": {
"user": {
"id": 2
},
"project": {},
"entry": {}
}
}
File added
......@@ -7,7 +7,7 @@
"src/"
],
"bin": {
"flow": "./src/flow.js"
"flow": "./src/main.js"
},
"repository": {
"type": "git",
......@@ -34,28 +34,38 @@
},
"homepage": "https://github.com/dreidev/gitflow#readme",
"dependencies": {
"async": "^2.1.4",
"babel": "^6.5.2",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.22.0",
"camo": "^0.12.3",
"chalk": "^1.1.3",
"hoard": "^0.1.5",
"homedir": "^0.6.0",
"ieee754": "^1.1.8",
"jspack": "0.0.4",
"nedb": "^1.8.0",
"nodegit": "^0.17.0",
"vorpal": "^1.11.4"
"resolve": "^1.2.0",
"sails-disk": "^0.10.10",
"underscore": "^1.8.3",
"vorpal": "^1.11.4",
"waterline": "^0.11.8"
},
"nexe": {
"input": "./src/flow.js",
"output": "flow^$",
"temp": "build",
"browserify": {
"requires": [],
"excludes": [],
"paths": []
"requires": [],
"excludes": [],
"paths": []
},
"runtime": {
"framework": "node",
"version": "6.9.1",
"js-flags": "--use_strict",
"ignoreFlags": true
"framework": "node",
"version": "6.9.1",
"js-flags": "--use_strict",
"ignoreFlags": true
}
}
}
}
var connect = require('./storage');
connect.then(function(db){
var User = db.collections.user;
User.create({name: 'cmosh', email: 'usew'}).exec(function(err, user){
User.findOne({ name: 'cmosh' })
.exec(function(err, user) {
console.log(user);
});
});
});
\ No newline at end of file
const fs = require('fs');
const path = require('path');
const resolve = require('resolve');
var NodeGit = require("nodegit");
module.exports = function(args, callback) {
this.log('init');
process.env.PWD = process.env.PWD || process.cwd();
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..');
var pathToRepo = process.env.PWD
NodeGit.Repository.openExt(pathToRepo,0,'null').then(function (repository) {
console.log('Is a repo');
console.log(repository);
var signature = repository.defaultSignature();
console.log(signature);
}, function (reasonForFailure) {
console.log(' Is not a repo'+reasonForFailure);
// NodeGit.Repository.init(pathToRepo, 0).then(function (repo) {
// // git commit --allow-empty -m "Initial commit"
// repository.createCommit(updateRef, author, committer, message, Tree, parents).then(function(oid) {
// // Use oid
// });
// });
});
const NodeGit = require('nodegit'),
Signature = NodeGit.Signature,
connect = require('./storage'),
pathToRepo = process.cwd();
module.exports = function (args, callback) {
let that = this;
connect.then(function (db) {
let User = db.collections.user;
User.find({}).exec(function (err, user) {
if (user.length < 1){
that.log(`Please run 'setup'`)
callback()
return;
}
let signature = Signature.now(user[0].name, user[0].email);
NodeGit.Repository.openExt(pathToRepo, 0, 'null').then(function (repository) {
repository.createCommitOnHead([], signature, signature, "flow init").then(function (oid) {
NodeGit.Branch.iteratorNew(repository, 3).then(function(branchIterator) {
console.log(repository);
console.log(branchIterator)
});
repository.createBranch('master', oid, false);
repository.createBranch('develop', oid, false).then(function () {
repository.checkoutBranch('develop');
});
});
callback();
}, function (reasonForFailure) {
NodeGit.Repository.init(pathToRepo, 0).then(function (repository) {
// this.log(process.env.PWD);
// this.log(process.env.CLI_ROOT);
callback();
};
\ No newline at end of file
repository.createCommitOnHead(['.', ], signature, signature, "flow init").then(function (oid) {
repository.createBranch('master', oid, false);
repository.createBranch('develop', oid, false).then(function () {
repository.checkoutBranch('develop');
});
});
});
callback();
});
});
});
};
// require babel-register and set Babel presets options to es2015
require('babel-register')({
presets: [ 'es2015' ]
});
require("./flow");
\ No newline at end of file
const fs = require('fs'),
path = require('path'),
resolve = require('resolve'),
NodeGit = require("nodegit"),
connect = require('./storage');
module.exports = function (args, callback) {
const that = this;
this.prompt([{
type: 'input',
name: 'name',
message: 'What\'s your git username?',
default: 'you'
},
{
type: 'input',
name: 'email',
message: 'What\'s your git email?',
default: 'you@youremail.com'
}],
function (result) {
connect.then(function (db) {
let User = db.collections.user;
User.destroy({}).exec(function() {
User.create({email: result.email, name: result.name}).exec(function(err) {
if (err) {
that.log(`Setup unsuccessful for ${result.name}, ${result.email}`);
callback();
};
that.log('Setup successfully!');
callback();
});
});
});
});
};
{"name":"Lassie","valuation":10,"employees":["s"],"dateFounded":{"$$date":1486903613304},"_id":"LN74nukw0czxEQyh"}
require('babel/register');
require('./test.js');
\ No newline at end of file
var Waterline = require('waterline');
var entryCollection = Waterline.Collection.extend({
identity: 'entry',
connection: 'default',
attributes: {
timestamp: 'string',
type: 'string',
// Add a reference to Project
tracking: {
model: 'project'
}
}
});
module.exports = entryCollection;
\ No newline at end of file
var Waterline = require('waterline');
var sailsDiskAdapter = require('sails-disk');
var waterline = new Waterline();
var homedir = require('homedir');
sailsDiskAdapter.defaults.filePath = homedir()+'/.flow/data/projects.';
waterline.loadCollection(require('./user'));
waterline.loadCollection(require('./project'));
waterline.loadCollection(require('./entry'));
var config = {
adapters: {
'disk': sailsDiskAdapter
},
connections: {
default: {
adapter: 'disk'
}
}
};
module.exports = new Promise(function(resolve, reject) {
waterline.initialize(config, function (err, db) {
if (err) {
reject(err);
};
resolve(db);
})
});
var Waterline = require('waterline');
var projectCollection = Waterline.Collection.extend({
identity: 'project',
connection: 'default',
attributes: {
repoUrl: 'string',
origin: 'string',
// Add a reference to Projects
entries: {
collection: 'entry',
via: 'tracking'
},
// Add a reference to User
owner: {
model: 'user'
}
}
});
module.exports = projectCollection;
var Waterline = require('waterline');
var settingCollection = Waterline.Collection.extend({
identity: 'setting',
connection: 'default',
attributes: {
name: 'string',
value: 'string'
}
});
module.exports = userCollection;
\ No newline at end of file
var connect = require('camo').connect;
var database;
var uri = 'nedb://'+__dirname;
console.log (uri);
connect(uri).then(function(db) {
var Document = require('camo').Document;
class Company extends Document {
constructor() {
super();
this.name = String;
this.valuation = {
type: Number,
default: 10000000000,
min: 0
};
this.employees = [String];
this.dateFounded = {
type: Date,
default: Date.now
};
}
static collectionName() {
return 'companies';
}
}
var company = Company.create({
name: 'Lassie',
valuation: 10,
employees:["s"]
});
company.save().then(function(l) {
console.log(l._id);
});
});
var Waterline = require('waterline');
var userCollection = Waterline.Collection.extend({
identity: 'user',
connection: 'default',
attributes: {
name: 'string',
email: 'string',
// Add a reference to Projects
projects: {
collection: 'project',
via: 'owner'
}
}
});
module.exports = userCollection;
\ No newline at end of file
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment