chore: initial

This commit is contained in:
cha0s 2021-01-05 12:20:20 -06:00
commit 9faf963227
28 changed files with 19468 additions and 0 deletions

116
.gitignore vendored Normal file
View File

@ -0,0 +1,116 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

26
app/.eslint.defaults.js Normal file
View File

@ -0,0 +1,26 @@
const config = {
globals: {
__non_webpack_require__: true,
process: true,
window: true,
},
rules: {
'babel/object-curly-spacing': 'off',
'brace-style': ['error', 'stroustrup'],
'no-bitwise': ['error', {int32Hint: true}],
'no-plusplus': 'off',
'no-shadow': 'off',
'no-underscore-dangle': 'off',
'padded-blocks': ['error', {classes: 'always'}],
yoda: 'off',
},
settings: {
'import/resolver': {
webpack: {
config: `${__dirname}/webpack.config.js`,
},
},
},
};
module.exports = config;

5
app/.eslintrc.js Normal file
View File

@ -0,0 +1,5 @@
const neutrino = require('neutrino');
process.env.LATUS_LINTING = true;
module.exports = neutrino(require('./.neutrinorc')).eslintrc();

119
app/.gitignore vendored Normal file
View File

@ -0,0 +1,119 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/build
/latus.yml

5
app/.mocharc.js Normal file
View File

@ -0,0 +1,5 @@
const neutrino = require('neutrino');
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
module.exports = neutrino().mocha();

90
app/.neutrinorc.js Normal file
View File

@ -0,0 +1,90 @@
require('dotenv/config');
const airbnb = require('@neutrinojs/airbnb');
const clean = require('@neutrinojs/clean');
const copy = require('@neutrinojs/copy');
const mocha = require('@neutrinojs/mocha');
const node = require('@neutrinojs/node');
const {EnvironmentPlugin} = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
options: {
root: __dirname,
},
use: [
airbnb({
eslint: {
cache: false,
baseConfig: require('./.eslint.defaults'),
},
}),
clean({
cleanOnceBeforeBuildPatterns: ['**/*.hot-update.*'],
}),
copy({
patterns: [{
from: 'src/assets',
to: 'http',
}],
}),
mocha(),
node(),
(neutrino) => {
[
'components',
'context',
'fonts',
'hooks',
'images',
'scss',
].forEach((path) => {
neutrino.config.resolve.alias
.set(path, `${neutrino.options.source}/react/${path}`);
});
if (process.env.LATUS_LINTING) {
return;
}
neutrino.config.module
.rule('compile')
.use('babel')
.get('options').plugins.push(
[
'babel-plugin-webpack-alias',
{
config: `${__dirname}/webpack.config.js`,
},
],
);
neutrino.config
.plugin('environment')
.use(EnvironmentPlugin, [{
SIDE: 'server',
}]);
neutrino.config
.entry('index')
.prepend('@latus/core/start');
if ('production' !== neutrino.config.get('mode')) {
neutrino.config
.entry('index')
.prepend('dotenv/config');
neutrino.config
.plugin('start-server')
.tap((args) => {
const options = args[0];
const inspectArg = process.argv.find((arg) => -1 !== arg.indexOf('--inspect'));
if (inspectArg) {
options.nodeArgs.push(inspectArg);
}
const profArg = process.argv.find((arg) => -1 !== arg.indexOf('--prof'));
if (profArg) {
options.nodeArgs.push(profArg);
}
options.nodeArgs.push('--experimental-repl-await');
return args;
});
}
neutrino.config.externals(nodeExternals());
},
],
};

17
app/docker-compose.yml Normal file
View File

@ -0,0 +1,17 @@
version: '2'
services:
redis:
image: redis:6
ports:
- 6380:6379
mysql:
image: mysql:8
command:
- '--default-authentication-plugin=mysql_native_password'
environment:
- MYSQL_DATABASE=db
- MYSQL_ROOT_PASSWORD=UNSAFE_DEV_PASSWORD
ports:
- 32342:3306

50
app/latus.default.yml Normal file
View File

@ -0,0 +1,50 @@
'@latus/core': {
up: [
'@latus/db',
'@latus/redis',
'@latus/user/session',
'@latus/user/passport',
'@latus/user/local',
'@latus/http',
'@latus/repl',
],
}
'@latus/db': {
models.decorate: [
'@latus/user/local',
],
docker: 'cached',
}
'@latus/governor': {}
'@latus/http': {
client.up: [
'@latus/socket/client',
'@latus/react/client',
],
request: [
'@latus/user/session',
'@latus/user/passport',
],
}
'@latus/react': {}
'@latus/redis': {
docker: 'cached',
}
'@latus/redis/session': {}
'@latus/repl': {}
'@latus/socket': {
authenticate: [
'@latus/user/session',
'@latus/user/passport',
],
connect: [
'@latus/socket',
],
packets.decorate: [
'@latus/governor',
]
}
'@latus/user/local': {}
'@latus/user/models': {}
'@latus/user/passport': {}
'@latus/user/session': {}

58
app/package.json Normal file
View File

@ -0,0 +1,58 @@
{
"name": "latus",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "webpack --mode production",
"clean": "rm -rf yarn.lock node_modules && yarn",
"dev": "webpack --mode development",
"docker": "yarn run build && docker build",
"forcelatus": "pkgs=$(find node_modules/@latus -maxdepth 1 -mindepth 1 -printf '@latus/%f '); yarn upgrade $pkgs",
"lint": "eslint --cache --format codeframe --ext mjs,jsx,js src",
"repl": "rlwrap -C qmp socat STDIO UNIX:$(ls /tmp/latus-*.sock | tail -n 1)",
"start": "NODE_ENV=production node build/index.js",
"test": "mocha --watch src",
"watch": "webpack --hot --watch --mode development"
},
"dependencies": {
"@avocado/behavior": "^2.0.0",
"@avocado/core": "^2.0.0",
"@avocado/entity": "^2.0.0",
"@avocado/graphics": "^2.0.0",
"@avocado/input": "^2.0.0",
"@avocado/math": "^2.0.0",
"@avocado/physics": "^1.0.0",
"@avocado/resource": "^2.0.0",
"@avocado/s13n": "^2.0.0",
"@avocado/sound": "^1.0.0",
"@avocado/timing": "^2.0.0",
"@avocado/topdown": "^2.0.0",
"@latus/core": "2.0.0",
"@latus/db": "2.0.0",
"@latus/governor": "2.0.0",
"@latus/http": "2.0.0",
"@latus/react": "2.0.0",
"@latus/redis": "2.0.0",
"@latus/repl": "2.0.0",
"@latus/socket": "2.0.0",
"@latus/user": "2.0.0",
"dotenv": "8.2.0",
"react": "^17.0.1",
"react-hot-loader": "4.13.0"
},
"devDependencies": {
"@neutrinojs/airbnb": "^9.4.0",
"@neutrinojs/clean": "^9.1.0",
"@neutrinojs/copy": "^9.4.0",
"@neutrinojs/mocha": "^9.1.0",
"@neutrinojs/node": "^9.1.0",
"babel-plugin-webpack-alias": "^2.1.2",
"eslint": "^6",
"eslint-import-resolver-webpack": "^0.12.1",
"js-yaml": "3.14.0",
"neutrino": "^9.1.0",
"source-map-support": "0.5.19",
"webpack": "^4",
"webpack-cli": "^3"
}
}

3
app/postcss.config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
plugins: {},
};

1
app/src/index.js Normal file
View File

@ -0,0 +1 @@
process.stdout.write('Your application is starting...\n');

18
app/src/react/index.jsx Normal file
View File

@ -0,0 +1,18 @@
import React from 'react';
import {hot} from 'react-hot-loader';
import Login from '@latus/user/client/components/login';
const App = () => (
<div className="app">
<h1>Latus react app</h1>
<p>Yay, you maaaaade it! :)</p>
<Login />
</div>
);
export default {
hooks: {
'@latus/react/components': () => hot(module)(App),
},
};

28
app/webpack.config.js Normal file
View File

@ -0,0 +1,28 @@
require('source-map-support/register');
// Whilst the configuration object can be modified here, the recommended way of making
// changes is via the presets' options or Neutrino's API in `.neutrinorc.js` instead.
// Neutrino's inspect feature can be used to view/export the generated configuration.
const {Latus} = require('@latus/core');
const neutrino = require('neutrino');
if (process.env.LATUS_LINTING) {
// eslint-disable-next-line global-require
module.exports = neutrino(require('./.neutrinorc')).webpack();
}
else {
module.exports = new Promise((resolve, reject) => {
try {
const latus = Latus.create();
const configs = {
// eslint-disable-next-line global-require
app: require('./.neutrinorc'),
};
latus.invokeFlat('@latus/core/build', configs);
const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack());
resolve(webpackConfigs);
}
catch (error) {
reject(error);
}
});
}

9441
app/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
const config = {
globals: {
process: true,
window: true,
},
ignorePatterns: [
'/*',
'!/src',
],
rules: {
'babel/object-curly-spacing': 'off',
'brace-style': ['error', 'stroustrup'],
'no-bitwise': ['error', {int32Hint: true}],
'no-plusplus': 'off',
'no-shadow': 'off',
'no-underscore-dangle': 'off',
'padded-blocks': ['error', {classes: 'always'}],
yoda: 'off',
},
};
module.exports = config;

3
config/.eslintrc.js Normal file
View File

@ -0,0 +1,3 @@
const neutrino = require('neutrino');
module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).eslintrc();

5
config/.mocharc.js Normal file
View File

@ -0,0 +1,5 @@
const neutrino = require('neutrino');
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).mocha();

80
config/.neutrinorc.js Normal file
View File

@ -0,0 +1,80 @@
const {basename, dirname, extname, join} = require('path');
const airbnbBase = require('@neutrinojs/airbnb-base');
const glob = require('glob');
const mocha = require('@neutrinojs/mocha');
const react = require('@neutrinojs/react');
const nodeExternals = require('webpack-node-externals');
module.exports = {
options: {},
use: [
airbnbBase({
eslint: {
cache: false,
baseConfig: require(`${__dirname}/.eslint.defaults`),
},
}),
(neutrino) => {
const {files = [], name} = neutrino.options.packageJson;
files
.filter((file) => {
const {source} = neutrino.options;
try {
require.resolve(`${source}/${file}`);
return true;
}
catch (error) {
const ext = extname(file);
try {
require.resolve(`${source}/${dirname(file)}/${basename(file, ext)}/index${ext}`);
return true;
}
catch (error) {
return false;
}
}
})
.forEach((file) => {
const isIndex = 'index.js' === file;
const trimmed = join(dirname(file), basename(file, extname(file)));
neutrino.options.mains[trimmed] = {entry: isIndex ? file : `./src/${trimmed}`};
});
const testPaths = glob.sync('./test/*.js');
if (testPaths.length > 0) {
const testEntry = neutrino.config.entry('test').clear();
testPaths.forEach((path) => testEntry.add(path));
}
neutrino.options.output = '.';
react({
clean: false,
})(neutrino);
Object.keys(neutrino.options.mains).forEach((main) => {
neutrino.config.plugins.delete(`html-${main}`);
});
neutrino.config
.devtool('source-map')
.target('node')
.optimization
.splitChunks(false)
.runtimeChunk(false)
.end()
.output
.filename('[name].js')
.library(name)
.libraryTarget('umd')
.umdNamedDefine(true)
.end()
.node
.set('__dirname', false)
.set('__filename', false);
const options = neutrino.config.module
.rule('compile')
.use('babel')
.get('options');
options.presets[0][1].targets = {esmodules: true};
neutrino.config.externals(nodeExternals({importType: 'umd'}));
},
mocha(),
],
};

View File

@ -0,0 +1 @@
module.exports = require('../../config/.eslintrc');

6
config/package/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
**/*.js
**/*.map
!/.*
!/webpack.config.js
!src/**/*.js
!/test/**/*.js

View File

@ -0,0 +1 @@
module.exports = require('../../config/.neutrinorc');

View File

@ -0,0 +1,43 @@
{
"name": "@latus/package",
"version": "1.0.0",
"main": "index.js",
"author": "cha0s",
"license": "MIT",
"scripts": {
"build": "NODE_PATH=./node_modules webpack --mode production",
"clean": "rm -rf yarn.lock node_modules && yarn",
"dev": "NODE_PATH=./node_modules webpack --mode development",
"forcepub": "npm unpublish --force $(node -e 'const {name, version} = require(`./package.json`); process.stdout.write(`${name}@${version}`)') && npm publish",
"link": "node -e \"Object.keys(require('./package.json').dependencies).filter((m) => 0 === m.indexOf('@latus/')).forEach((m) => require('child_process').spawn('yarn', ['link', m]));\"",
"lint": "NODE_PATH=./node_modules eslint --format codeframe --ext mjs,js .",
"test": "NODE_PATH=./node_modules mocha --config ../../config/.mocharc.js",
"unlink": "node -e \"Object.keys(require('./package.json').dependencies).filter((m) => 0 === m.indexOf('@latus/')).forEach((m) => require('child_process').spawn('yarn', ['unlink', m]));\" && yarn install --force",
"watch": "NODE_PATH=./node_modules webpack --watch --mode development"
},
"files": [
"index.js",
"index.js.map",
"test.js",
"test.js.map"
],
"dependencies": {
"debug": "4.3.1"
},
"devDependencies": {
"@neutrinojs/airbnb-base": "^9.4.0",
"@neutrinojs/banner": "^9.4.0",
"@neutrinojs/copy": "9.4.0",
"@neutrinojs/mocha": "^9.4.0",
"@neutrinojs/react": "^9.4.0",
"chai": "4.2.0",
"eslint": "^7",
"eslint-import-resolver-webpack": "0.13.0",
"glob": "7.1.6",
"mocha": "^8",
"neutrino": "^9.4.0",
"source-map-support": "0.5.19",
"webpack": "^4",
"webpack-cli": "^3"
}
}

View File

View File

@ -0,0 +1,9 @@
import {expect} from 'chai';
const {name} = require('../package.json');
describe(name, () => {
it('exists', () => {
expect(true).to.be.true;
})
});

View File

@ -0,0 +1,3 @@
const neutrino = require('neutrino');
module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).webpack();

6
lerna.json Normal file
View File

@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "1.0.0"
}

31
package.json Normal file
View File

@ -0,0 +1,31 @@
{
"name": "@latus/monorepo",
"private": true,
"scripts": {
"build": "lerna run build",
"clean": "lerna run clean",
"dev": "lerna run dev",
"forcepub": "lerna run forcepub",
"link": "lerna run link",
"lint": "lerna run lint",
"test": "lerna run test",
"unlink": "lerna run unlink",
"watch": "lerna run watch --parallel"
},
"devDependencies": {
"@neutrinojs/airbnb-base": "^9.4.0",
"@neutrinojs/mocha": "^9.4.0",
"@neutrinojs/react": "^9.4.0",
"chai": "4.2.0",
"eslint": "^7",
"eslint-import-resolver-webpack": "0.13.0",
"glob": "7.1.6",
"lerna": "^3.22.1",
"mocha": "^8",
"neutrino": "^9.4.0",
"source-map-support": "0.5.19",
"webpack": "^4",
"webpack-cli": "^3",
"webpack-node-externals": "2.5.2"
}
}

9281
yarn.lock Normal file

File diff suppressed because it is too large Load Diff