diff --git a/.gitignore b/.gitignore index fc7f951..829692d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ # Compiled/copied assets /public/js /public/css +/resources/assets/typescript/*.d.ts # User assets /uploads/* diff --git a/README.md b/README.md index 7fffb5d..0de4bf0 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,35 @@ # Sakura - ![StyleCI](https://styleci.io/repos/45261697/shield) ![SensioLabsInsight](https://insight.sensiolabs.com/projects/6c9b3813-0f50-406c-ab26-665e11876bc9/mini.png) ## Requirements - - PHP 7.0.0 or newer - A database engine compatible with your PHP install and Laravel/Illuminate's database abstraction layer, MySQL 5.7 recommended. +- [Composer](https://getcomposer.org/) +- [NPM from NodeJS](https://nodejs.org/) -I will include a full list of required extensions later. - -## Development setup - +## Installing +### Backend Copy config.example.ini, set everything up to your liking (database is most important). I'd also recommend setting `show_errors` to `true` for development. Then run the following commands in the root. - ``` +composer install php mahou database-install php mahou database-migrate php mahou setup ``` - After that you can either use `php mahou serve` to use the built in development server or serve the public folder through your webserver of choice. -## Contributing +### Frontend +To compile the LESS and TypeScript assets you need to have the individual compiler installed, both are available from npm and can be installed through the following command: +``` +npm install -g less typescript +``` +After that install the required libraries by running `npm install` and from then on to compile the files you need to run `build.sh`. +If your editor yells at you that it can't find certain namespaces try running `build.sh` since that generates the required typings (.d.ts files). + +## Contributing Right now I'm not accepting big PRs because of a set of big things not being fully implemented yet, bug fix PRs are more than welcome though! ## License - -Sakura is licensed under the Apache License version 2. Check the [LICENSE file](https://github.com/flashwave/sakura/blob/master/LICENSE) for the full thing or if you just want a quick summary [click here](https://i.flash.moe/vlcsnap-2016-03-09-17h45m55s452.png). +Sakura is licensed under the Apache License version 2. Check the [LICENSE file](https://github.com/flashwave/sakura/blob/master/LICENSE) for the full thing. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..1fa133b --- /dev/null +++ b/build.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +ASSETS_PATH='./resources/assets' +ASSETS_LESS="$ASSETS_PATH/less" +ASSETS_TS="$ASSETS_PATH/typescript" + +LESS_ENTRY_FILE='main.less' + +PUBLIC_DIR='./public' +PUBLIC_CSS="$PUBLIC_DIR/css" +PUBLIC_JS="$PUBLIC_DIR/js" + +NODE_PATH='./node_modules' +NODE_DEST="$PUBLIC_JS/libs.js" +NODE_IMPORT=( + 'turbolinks/dist/turbolinks.js' +) + +# delete old files, using find to avoid errors +echo "=> Cleanup" +find $ASSETS_TS -type f -name "*.d.ts" -delete -print +find $PUBLIC_CSS -type f -name "*.css" -delete -print +find $PUBLIC_JS -type f -name "*.js" -delete -print +echo + +# styles +echo +echo "=> LESS" +for STYLE_DIR in $ASSETS_LESS/*/; do +STYLE_NAME=`basename $STYLE_DIR | tr '[A-Z]' '[a-z]'` +echo "==> $STYLE_NAME" +lessc --verbose $STYLE_DIR/$LESS_ENTRY_FILE $PUBLIC_CSS/$STYLE_NAME.css +echo +done + +# scripts +echo +echo "=> TypeScript" +for SCRIPT_DIR in $ASSETS_TS/*/; do +SCRIPT_NAME=`basename $SCRIPT_DIR` +SCRIPT_NAME_LOWER=`echo $SCRIPT_NAME | tr '[A-Z]' '[a-z]'` +echo "==> $SCRIPT_NAME" +find $SCRIPT_DIR -name "*.ts" | xargs tsc \ + -d \ + -t es5 \ + --listFiles \ + --listEmittedFiles \ + --noImplicitAny \ + --removeComments \ + --outFile $PUBLIC_JS/$SCRIPT_NAME_LOWER.js +mv -v $PUBLIC_JS/$SCRIPT_NAME_LOWER.d.ts $ASSETS_TS/$SCRIPT_NAME.d.ts +echo +done + +# node imports +echo +echo "=> NPM imports" +echo "Creating $NODE_DEST" +touch $NODE_DEST +for FILE in $NODE_IMPORT; do +echo "==> $FILE" +cat "$NODE_PATH/$FILE" >> $NODE_DEST +done + diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 81372d1..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,16 +0,0 @@ -var - elixir = require('laravel-elixir'), - elixirTypscript = require('elixir-typescript'), - nodePath = '../../../node_modules/'; - -elixir(function(mix) { - mix - .less('aitemu/master.less', 'public/css/aitemu.css') - .less('yuuno/master.less', 'public/css/yuuno.css') - .typescript('Sakura/**/*.ts', 'public/js/app.js') - .typescript('Aitemu/**/*.ts', 'public/js/aitemu.js') - .typescript('Yuuno/**/*.ts', 'public/js/yuuno.js') - .scripts([ - nodePath + 'turbolinks/dist/turbolinks.js', - ], 'public/js/libraries.js'); -}); diff --git a/package.json b/package.json index 852018e..5296b1e 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,6 @@ { "private": true, - "scripts": { - "prod": "gulp --production", - "dev": "gulp watch" - }, "dependencies": { - "elixir-typescript": "^2.0.0", - "gulp": "^3.9.1", - "laravel-elixir": "^5.0.0", "turbolinks": "^5.0.0" } } diff --git a/resources/assets/less/aitemu/master.less b/resources/assets/less/aitemu/main.less similarity index 100% rename from resources/assets/less/aitemu/master.less rename to resources/assets/less/aitemu/main.less diff --git a/resources/assets/less/yuuno/master.less b/resources/assets/less/yuuno/main.less similarity index 100% rename from resources/assets/less/yuuno/master.less rename to resources/assets/less/yuuno/main.less diff --git a/resources/assets/typescript/Sakura.ts b/resources/assets/typescript/Sakura.ts deleted file mode 100644 index 0f826b1..0000000 --- a/resources/assets/typescript/Sakura.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// diff --git a/resources/assets/typescript/Sakura/tsconfig.json b/resources/assets/typescript/Sakura/tsconfig.json new file mode 100644 index 0000000..ba711ed --- /dev/null +++ b/resources/assets/typescript/Sakura/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "noImplicitAny": false, + "removeComments": true + } +} diff --git a/resources/assets/typescript/Yuuno.ts b/resources/assets/typescript/Yuuno.ts deleted file mode 100644 index 9d7da07..0000000 --- a/resources/assets/typescript/Yuuno.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// -/// -/// -/// diff --git a/resources/assets/typescript/Yuuno/Main.ts b/resources/assets/typescript/Yuuno/Main.ts index fa9629c..66ad22f 100644 --- a/resources/assets/typescript/Yuuno/Main.ts +++ b/resources/assets/typescript/Yuuno/Main.ts @@ -1,4 +1,4 @@ -/// +/// namespace Yuuno { diff --git a/resources/assets/typescript/Yuuno/Notifications.ts b/resources/assets/typescript/Yuuno/Notifications.ts index 40b0316..14badb7 100644 --- a/resources/assets/typescript/Yuuno/Notifications.ts +++ b/resources/assets/typescript/Yuuno/Notifications.ts @@ -1,5 +1,3 @@ -/// - namespace Yuuno { export class Notifications extends Sakura.Notifications diff --git a/resources/assets/typescript/Yuuno/Ybabstat.ts b/resources/assets/typescript/Yuuno/Ybabstat.ts index 503d860..bde2cd1 100644 --- a/resources/assets/typescript/Yuuno/Ybabstat.ts +++ b/resources/assets/typescript/Yuuno/Ybabstat.ts @@ -1,5 +1,3 @@ -/// - namespace Yuuno { export class Ybabstat diff --git a/resources/assets/typescript/Yuuno/tsconfig.json b/resources/assets/typescript/Yuuno/tsconfig.json new file mode 100644 index 0000000..ba711ed --- /dev/null +++ b/resources/assets/typescript/Yuuno/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "noImplicitAny": false, + "removeComments": true + } +} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index f417215..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "noImplicitAny": false, - "removeComments": true, - "preserveConstEnums": true, - "rootDir": "resources/assets/typescript" - } -}