-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Replace old
sputnik
dependency with a new stages system
- Loading branch information
Showing
24 changed files
with
1,912 additions
and
1,044 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,7 +308,7 @@ Model.setStatic(function getClass(model_name, allow_create, parent) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.2 | ||
* @version 1.4.0 | ||
*/ | ||
Model.setStatic(function setDocumentMethod(name, fnc, on_server) { | ||
|
||
|
@@ -321,7 +321,7 @@ Model.setStatic(function setDocumentMethod(name, fnc, on_server) { | |
} | ||
|
||
if (Blast.isNode) { | ||
alchemy.sputnik.after('plugins', whenLoaded); | ||
STAGES.afterStages('load_app.plugins', whenLoaded); | ||
} else { | ||
Blast.loaded(whenLoaded); | ||
} | ||
|
@@ -336,15 +336,15 @@ Model.setStatic(function setDocumentMethod(name, fnc, on_server) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.2 | ||
* @version 1.4.0 | ||
*/ | ||
Model.setStatic(function setDocumentProperty(key, getter, setter, on_server) { | ||
|
||
var that = this, | ||
args = arguments; | ||
|
||
if (Blast.isNode) { | ||
alchemy.sputnik.after('plugins', whenLoaded); | ||
STAGES.afterStages('load_app.plugins', whenLoaded); | ||
} else { | ||
Blast.loaded(whenLoaded); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,15 @@ | ||
'use strict'; | ||
|
||
const libpath = require('path'); | ||
let starting; | ||
|
||
/** | ||
* Load Protoblast in the prototype-modifying mode. | ||
* This is the backbone of Alchemy. | ||
*/ | ||
require('protoblast')(true); | ||
|
||
/** | ||
* Resolve a core path | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.4.0 | ||
* @version 1.4.0 | ||
*/ | ||
function resolveCorePath(...args) { | ||
return libpath.resolve(PATH_CORE, ...args); | ||
} | ||
|
||
/** | ||
* Require a core path | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.4.0 | ||
* @version 1.4.0 | ||
*/ | ||
function requireCorePath(...args) { | ||
return require(resolveCorePath(...args)); | ||
} | ||
|
||
/** | ||
* Define DEFINE and constants | ||
* Define global constants and require methods | ||
*/ | ||
require('./init/constants'); | ||
require('./init_scripts/constants'); | ||
|
||
/** | ||
* Alchemy's Base class (from which all other classes inherit) | ||
|
@@ -47,224 +22,24 @@ requireCorePath('core', 'base'); | |
requireCorePath('core', 'client_base'); | ||
|
||
/** | ||
* Load the setting class | ||
*/ | ||
requireCorePath('core', 'setting.js'); | ||
|
||
/** | ||
* Load the actual settings | ||
*/ | ||
requireCorePath('init', 'settings.js'); | ||
|
||
/** | ||
* Define alchemy class and instance | ||
*/ | ||
requireCorePath('core', 'alchemy'); | ||
|
||
/** | ||
* Get all the languages by their locale | ||
*/ | ||
requireCorePath('init', 'languages'); | ||
|
||
/** | ||
* Require basic functions | ||
*/ | ||
requireCorePath('init', 'functions'); | ||
|
||
/** | ||
* Require load functions | ||
*/ | ||
requireCorePath('init', 'load_functions'); | ||
|
||
/** | ||
* Pre-load basic requirements | ||
*/ | ||
requireCorePath('init', 'preload_modules'); | ||
|
||
/** | ||
* Set up file change watchers for development | ||
*/ | ||
requireCorePath('init', 'devwatch'); | ||
|
||
/** | ||
* The migration class | ||
*/ | ||
requireCorePath('class', 'migration'); | ||
|
||
const CLIENT_HAWKEJS_OPTIONS = { | ||
|
||
// Do not load on the server | ||
server : false, | ||
|
||
// Turn it into a commonjs load | ||
make_commonjs: true, | ||
|
||
// The arguments to add to the wrapper function | ||
arguments : 'hawkejs' | ||
}; | ||
|
||
const SERVER_HAWKEJS_OPTIONS = { | ||
|
||
// Also load on the server | ||
server : true, | ||
|
||
// Turn it into a commonjs load | ||
make_commonjs: true, | ||
|
||
// The arguments to add to the wrapper function | ||
arguments : 'hawkejs' | ||
}; | ||
|
||
/** | ||
* Require the base class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.3.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('core', 'base.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the client_base class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('core', 'client_base.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the error class | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'error.js'), SERVER_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the client_alchemy class on the client side | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.5 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('core', 'client_alchemy.js'), SERVER_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the path_evaluator class | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'path_evaluator.js'), SERVER_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the field_value class | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'field_value.js'), SERVER_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the path_definition class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.0 | ||
* Load the stages classes | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'path_definition.js'), CLIENT_HAWKEJS_OPTIONS); | ||
alchemy.hawkejs.load(resolveCorePath('class', 'path_param_definition.js'), CLIENT_HAWKEJS_OPTIONS); | ||
requireCorePath('core', 'stages.js'); | ||
|
||
/** | ||
* Require the element class on the client side too | ||
* Define the Stages instance | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'element.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the helper class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.0.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'helper.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the datasource class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'datasource.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the field class on the client side too | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'field.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Require the schema_client class on the client side too | ||
* @since 1.4.0 | ||
* @version 1.4.0 | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.1.0 | ||
*/ | ||
alchemy.hawkejs.load(resolveCorePath('class', 'schema_client.js'), CLIENT_HAWKEJS_OPTIONS); | ||
|
||
/** | ||
* Set up routing functions | ||
*/ | ||
alchemy.useOnce(resolveCorePath('core', 'routing.js')); | ||
|
||
/** | ||
* Set up middleware functions | ||
*/ | ||
alchemy.useOnce(resolveCorePath('core', 'middleware.js')); | ||
|
||
/** | ||
* Load socket.io code | ||
*/ | ||
alchemy.useOnce(resolveCorePath('core', 'socket.js')); | ||
|
||
/** | ||
* Load discovery code | ||
*/ | ||
alchemy.useOnce(resolveCorePath('core', 'discovery.js')); | ||
|
||
/** | ||
* Load inode classes | ||
* @type {Alchemy.Stages.Stage} | ||
*/ | ||
alchemy.useOnce(resolveCorePath('class', 'inode.js')); | ||
alchemy.useOnce(resolveCorePath('class', 'inode_file.js')); | ||
alchemy.useOnce(resolveCorePath('class', 'inode_dir.js')); | ||
alchemy.useOnce(resolveCorePath('class', 'inode_list.js')); | ||
DEFINE('STAGES', new Classes.Alchemy.Stages.Stage('root')); | ||
|
||
/** | ||
* Load in all classes | ||
* Start the stages script | ||
*/ | ||
alchemy.usePath(libpath.resolve(__dirname, 'class'), {modular: false}); | ||
requireCorePath('init_scripts', 'stages.js'); | ||
|
||
// Load the base bootstrap file | ||
try { | ||
alchemy.useOnce(libpath.resolve(PATH_ROOT, 'app', 'config', 'bootstrap.js')); | ||
} catch (err) { | ||
if (err.message.indexOf('Cannot find') === -1) { | ||
alchemy.printLog(alchemy.WARNING, 'Could not load app bootstrap file'); | ||
throw err; | ||
} else { | ||
alchemy.printLog(alchemy.SEVERE, 'Could not load config bootstrap file', {err: err}); | ||
} | ||
} | ||
module.exports = STAGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,7 @@ Schema.setMethod(function eachAlternateIndex(data, fnc) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.1.0 | ||
* @version 1.2.0 | ||
* @version 1.4.0 | ||
* | ||
* @return {Pledge} | ||
*/ | ||
|
@@ -214,7 +214,7 @@ Schema.setMethod(function getDatasource() { | |
that.afterOnce('has_model_class', next); | ||
}, function waitForDatasources(next) { | ||
|
||
alchemy.sputnik.after('datasources', function afterDs() { | ||
STAGES.afterStages('datasource', function afterDs() { | ||
|
||
let datasource; | ||
|
||
|
Oops, something went wrong.