Bye Furlong

This commit is contained in:
thosakwe 2016-09-21 00:45:40 -04:00
parent d07650fd77
commit d9e8ce3bba
19 changed files with 151 additions and 204 deletions

103
.gitignore vendored
View file

@ -1,3 +1,32 @@
# Created by .ignore support plugin (hsz.mobi)
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
.buildlog
.packages
.project
.pub/
build/
**/packages/
# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
*.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json
# Directory created by dartdoc
doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@ -43,78 +72,4 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
.buildlog
.packages
.project
.pub/
build/
**/packages/
# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
*.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json
# Directory created by dartdoc
doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
# Sensitive or high-churn files:
# Gradle:
# Mongo Explorer plugin:
## File-based project format:
## Plugin-specific files:
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
# Directory created by dartdoc
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
packages
**/packages
bin/packages
.idea
logs/**/*.txt

21
.idea/angel.iml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/bin/packages" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
<excludeFolder url="file://$MODULE_DIR$/test/services/packages" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/tool/packages" />
<excludeFolder url="file://$MODULE_DIR$/web/packages" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="application" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

38
.idea/misc.xml Normal file
View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>General</id>
</State>
<State>
<id>XPath</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>AngularJS</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/angel.iml" filepath="$PROJECT_DIR$/.idea/angel.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start Server" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/bin/server.dart" />
<method />
</configuration>
</component>

1
bin/packages Symbolic link
View file

@ -0,0 +1 @@
../packages

View file

@ -1,4 +0,0 @@
library angel.migrations;
export 'util.dart';
export 'schemas/user.dart';

View file

@ -1,24 +0,0 @@
import 'dart:async';
import 'package:furlong/furlong.dart';
class UsersMigration extends Migration {
@override
String get name => "Users table";
@override
Future create(Migrator migrator) async {
migrator.create("users", (table) {
table.id();
table.string("username");
table.string("email");
table.string("password");
table.dateTime("created_at");
table.dateTime("updated_at").nullable = true;
});
}
@override
Future destroy(Migrator migrator) async {
migrator.drop(["users"]);
}
}

View file

@ -1,64 +0,0 @@
import 'dart:async';
import 'dart:io';
import 'package:angel_configuration/angel_configuration.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:furlong/furlong.dart';
import 'package:sqljocky/sqljocky.dart';
Future<ConnectionPool> createPool() async {
var app = new Angel();
await app.configure(loadConfigurationFile());
Map config = app.properties["db"]["migrate"];
if (config == null)
throw new Exception(
"Please provide Furlong configuration with your configuration file.");
String type = config["type"] ?? "mysql";
if (type == "mysql") {
return new ConnectionPool(
host: config["host"] ?? "localhost",
port: config["port"] ?? 3306,
user: config["username"],
password: config["password"],
db: config["database"],
useSSL: config["ssl"] == true);
} else
throw new Exception("Unsupported database driver '$type'.");
}
migrateDown(List<Migration> migrations) async {
print("Undoing all migrations...");
var pool = await createPool();
var furlong = new Furlong(pool, migrations: migrations);
await furlong.down();
print("Done.");
exit(0);
}
migrateReset(List<Migration> migrations) async {
var pool = await createPool();
var furlong = new Furlong(pool, migrations: migrations);
await furlong.reset();
print("Done.");
exit(0);
}
migrateRevert(List<Migration> migrations) async {
print("Reverting last batch...");
var pool = await createPool();
var furlong = new Furlong(pool, migrations: migrations);
await furlong.revert();
print("Done.");
exit(0);
}
migrateUp(List<Migration> migrations) async {
print("Running all outstanding migrations...");
var pool = await createPool();
var furlong = new Furlong(pool, migrations: migrations);
await furlong.up();
print("Done.");
exit(0);
}

View file

@ -0,0 +1,3 @@
library angel.models;
export 'user.dart';

36
lib/src/models/user.dart Normal file
View file

@ -0,0 +1,36 @@
library angel.models.user;
import 'dart:convert';
import 'package:angel_mongo/model.dart';
class User extends Model {
String email;
String username;
String password;
List<String> roles;
User(
{String this.email,
String this.username,
String this.password,
List<String> roles}) {
this.roles = roles ?? [];
}
factory User.fromJson(String json) => new User.fromMap(JSON.decode(json));
factory User.fromMap(Map data) => new User(
email: data["email"],
username: data["username"],
password: data["password"],
roles: data["roles"]);
Map toJson() {
return {
"email": email,
"username": username,
"password": password,
roles: roles
};
}
}

View file

@ -3,21 +3,8 @@ import 'package:angel_mongo/angel_mongo.dart';
import 'package:crypto/crypto.dart' show sha256;
import 'package:mongo_dart/mongo_dart.dart';
import 'package:validate/validate.dart';
import '../../models/user.dart';
class User extends Model {
String email;
String username;
String password;
List<String> roles;
User(
{String this.email,
String this.username,
String this.password,
List<String> roles}) {
this.roles = roles ?? [];
}
}
hashPassword(HookedServiceEvent event) {
if (event.data.password != null) {

3
logs/2016-09-20.txt Normal file
View file

@ -0,0 +1,3 @@
INFO: 2016-09-20 00:52:14.862305: Server listening at http://127.0.0.1:3000
CONFIG: 2016-09-20 00:52:14.864663: Starting server with given configuration: {mongo_db: mongodb://localhost:27017/angel, db: {web: {database: angel, password: password, username: username}, migrate: {database: angel, password: password, username: root}}, host: 127.0.0.1, port: 3000}
INFO: 2016-09-20 00:52:20.711300: 200 GET / (69 ms)

View file

@ -12,7 +12,6 @@ dependencies:
angel_mongo: ^1.0.0-dev
angel_mustache: ^1.0.0-dev
angel_static: ^1.0.0
furlong: ^1.0.0-dev
json_god: ^2.0.0-beta
mailer: ^1.1.0+4
validate: ^1.5.2

1
test/packages Symbolic link
View file

@ -0,0 +1 @@
../packages

1
test/services/packages Symbolic link
View file

@ -0,0 +1 @@
../../packages

View file

@ -1,12 +1,5 @@
import 'package:angel/src/migrations/migrations.dart';
import 'package:furlong/furlong.dart';
import 'package:grinder/grinder.dart';
final List<Migration> migrations = [
// Your migrations here!
new UsersMigration()
];
main(args) => grind(args);
@Task()
@ -19,19 +12,4 @@ build() {
}
@Task()
clean() => defaultClean();
@Task("Generates classes from your Furlong migrations.")
generate() async {}
@Task("Reverts the database state to before any Furlong migrations were run.")
down() => migrateDown(migrations);
@Task("Undoes and re-runs all Furlong migrations.")
reset() => migrateReset(migrations);
@Task("Undoes the last batch of Furlong migrations run.")
revert() => migrateRevert(migrations);
@Task("Runs any outstanding Furlong migrations.")
up() => migrateUp(migrations);
clean() => defaultClean();

1
tool/packages Symbolic link
View file

@ -0,0 +1 @@
../packages

1
web/packages Symbolic link
View file

@ -0,0 +1 @@
../packages