alchemymvc 1.3.21 → 1.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -3
  3. package/lib/app/behaviour/publishable_behaviour.js +5 -5
  4. package/lib/app/behaviour/revision_behaviour.js +10 -10
  5. package/lib/app/behaviour/sluggable_behaviour.js +14 -14
  6. package/lib/app/conduit/electron_conduit.js +9 -9
  7. package/lib/app/conduit/http_conduit.js +13 -13
  8. package/lib/app/conduit/loopback_conduit.js +15 -15
  9. package/lib/app/conduit/socket_conduit.js +43 -43
  10. package/lib/app/config/routes.js +26 -0
  11. package/lib/app/controller/00-default_app_controller.js +21 -0
  12. package/lib/app/controller/alchemy_info_controller.js +12 -12
  13. package/lib/app/datasource/mongo_datasource.js +16 -16
  14. package/lib/app/element/00-default_app_element.js +19 -0
  15. package/lib/app/element/time_ago.js +5 -5
  16. package/lib/app/helper/00-default_app_helper.js +11 -0
  17. package/lib/app/helper/alchemy_helper.js +22 -22
  18. package/lib/app/helper/backed_map.js +1 -1
  19. package/lib/app/helper/breadcrumb.js +10 -10
  20. package/lib/app/helper/client_collection.js +3 -3
  21. package/lib/app/helper/cron.js +29 -29
  22. package/lib/app/helper/enum_values.js +6 -6
  23. package/lib/app/helper/pagination_helper.js +36 -36
  24. package/lib/app/helper/router_helper.js +35 -35
  25. package/lib/app/helper/socket_helper.js +57 -57
  26. package/lib/app/helper/syncable.js +84 -59
  27. package/lib/app/helper_component/paginate_component.js +9 -9
  28. package/lib/app/helper_controller/component.js +1 -1
  29. package/lib/app/helper_controller/conduit.js +31 -31
  30. package/lib/app/helper_controller/controller.js +54 -39
  31. package/lib/app/helper_datasource/00-nosql_datasource.js +624 -70
  32. package/lib/app/helper_datasource/05-fallback_datasource.js +10 -10
  33. package/lib/app/helper_datasource/idb_datasource.js +6 -6
  34. package/lib/app/helper_datasource/indexed_db.js +22 -22
  35. package/lib/app/helper_datasource/remote_datasource.js +5 -5
  36. package/lib/app/helper_error/http_error.js +4 -4
  37. package/lib/app/helper_error/model_error.js +2 -2
  38. package/lib/app/helper_error/validation_error.js +12 -12
  39. package/lib/app/helper_field/00-objectid_field.js +7 -7
  40. package/lib/app/helper_field/05-string_field.js +16 -12
  41. package/lib/app/helper_field/06-text_field.js +2 -4
  42. package/lib/app/helper_field/10-number_field.js +9 -12
  43. package/lib/app/helper_field/11-date_field.js +15 -15
  44. package/lib/app/helper_field/15-local_temporal_field.js +10 -10
  45. package/lib/app/helper_field/20-decimal_field.js +8 -9
  46. package/lib/app/helper_field/belongsto_field.js +1 -1
  47. package/lib/app/helper_field/big_int_field.js +8 -8
  48. package/lib/app/helper_field/boolean_field.js +9 -11
  49. package/lib/app/helper_field/datetime_field.js +3 -3
  50. package/lib/app/helper_field/enum_field.js +13 -8
  51. package/lib/app/helper_field/fixed_decimal_field.js +6 -7
  52. package/lib/app/helper_field/geopoint_field.js +9 -10
  53. package/lib/app/helper_field/habtm_field.js +3 -3
  54. package/lib/app/helper_field/hasoneparent_field.js +1 -1
  55. package/lib/app/helper_field/html_field.js +2 -4
  56. package/lib/app/helper_field/integer_field.js +8 -11
  57. package/lib/app/helper_field/local_date_field.js +5 -5
  58. package/lib/app/helper_field/local_date_time_field.js +5 -5
  59. package/lib/app/helper_field/local_time_field.js +5 -5
  60. package/lib/app/helper_field/mixed_field.js +5 -5
  61. package/lib/app/helper_field/object_field.js +8 -8
  62. package/lib/app/helper_field/password_field.js +3 -3
  63. package/lib/app/helper_field/regexp_field.js +7 -9
  64. package/lib/app/helper_field/schema_field.js +91 -88
  65. package/lib/app/helper_field/settings_field.js +92 -0
  66. package/lib/app/helper_field/time_field.js +6 -6
  67. package/lib/app/helper_field/url_field.js +2 -4
  68. package/lib/app/helper_model/00-base_criteria.js +662 -0
  69. package/lib/app/helper_model/05-criteria_expressions.js +605 -0
  70. package/lib/app/helper_model/10-model_criteria.js +1182 -0
  71. package/lib/app/helper_model/data_provider.js +2 -2
  72. package/lib/app/helper_model/document.js +103 -92
  73. package/lib/app/helper_model/document_list.js +14 -14
  74. package/lib/app/helper_model/field_config.js +11 -11
  75. package/lib/app/helper_model/field_set.js +17 -17
  76. package/lib/app/helper_model/model.js +203 -124
  77. package/lib/app/helper_model/remote_data_provider.js +2 -2
  78. package/lib/app/helper_validator/00_validator.js +16 -16
  79. package/lib/app/helper_validator/not_empty_validator.js +9 -9
  80. package/lib/app/model/00-default_app_model.js +18 -0
  81. package/lib/app/model/05-system_model.js +27 -0
  82. package/lib/app/model/{alchemy_migration_model.js → system_migration_model.js} +4 -4
  83. package/lib/app/model/system_setting_model.js +154 -0
  84. package/lib/app/model/{alchemy_task_history_model.js → system_task_history_model.js} +7 -7
  85. package/lib/app/model/{alchemy_task_model.js → system_task_model.js} +11 -11
  86. package/lib/bootstrap.js +22 -312
  87. package/lib/class/accumulator.js +5 -5
  88. package/lib/class/behaviour.js +5 -5
  89. package/lib/class/component.js +3 -3
  90. package/lib/class/conduit.js +203 -163
  91. package/lib/class/controller.js +42 -42
  92. package/lib/class/datasource.js +74 -79
  93. package/lib/class/document.js +74 -95
  94. package/lib/class/document_list.js +5 -5
  95. package/lib/class/element.js +17 -17
  96. package/lib/class/error.js +3 -3
  97. package/lib/class/field.js +169 -91
  98. package/lib/class/field_value.js +6 -6
  99. package/lib/class/helper.js +3 -3
  100. package/lib/class/inode.js +17 -17
  101. package/lib/class/inode_dir.js +12 -12
  102. package/lib/class/inode_file.js +50 -25
  103. package/lib/class/inode_list.js +4 -4
  104. package/lib/class/migration.js +4 -4
  105. package/lib/class/model.js +182 -168
  106. package/lib/class/path_definition.js +22 -22
  107. package/lib/class/path_evaluator.js +5 -5
  108. package/lib/class/path_param_definition.js +7 -7
  109. package/lib/class/plugin.js +312 -0
  110. package/lib/class/postponement.js +29 -29
  111. package/lib/class/reciprocal.js +8 -8
  112. package/lib/class/route.js +33 -33
  113. package/lib/class/router.js +73 -73
  114. package/lib/class/schema.js +21 -21
  115. package/lib/class/schema_client.js +73 -67
  116. package/lib/class/session.js +63 -29
  117. package/lib/class/session_scene.js +4 -4
  118. package/lib/class/sitemap.js +16 -16
  119. package/lib/class/task.js +39 -39
  120. package/lib/class/task_service.js +43 -47
  121. package/lib/{init → core}/alchemy.js +413 -374
  122. package/lib/{init/functions.js → core/alchemy_functions.js} +171 -108
  123. package/lib/core/alchemy_load_functions.js +715 -0
  124. package/lib/core/base.js +50 -62
  125. package/lib/core/client_alchemy.js +144 -152
  126. package/lib/core/client_base.js +39 -52
  127. package/lib/core/discovery.js +16 -18
  128. package/lib/core/middleware.js +54 -43
  129. package/lib/core/{routing.js → prefix.js} +14 -16
  130. package/lib/core/setting.js +1684 -0
  131. package/lib/core/stage.js +758 -0
  132. package/lib/scripts/create_constants.js +119 -0
  133. package/lib/{init/languages.js → scripts/create_languages.js} +5 -5
  134. package/lib/scripts/create_settings.js +449 -0
  135. package/lib/scripts/create_shared_constants.js +95 -0
  136. package/lib/scripts/create_stages.js +55 -0
  137. package/lib/scripts/init_alchemy.js +51 -0
  138. package/lib/{init/requirements.js → scripts/preload_modules.js} +15 -2
  139. package/lib/scripts/setup_devwatch.js +238 -0
  140. package/lib/stages/00-load_core.js +342 -0
  141. package/lib/stages/05-load_app.js +57 -0
  142. package/lib/stages/10-datasource.js +61 -0
  143. package/lib/stages/15-tasks.js +27 -0
  144. package/lib/stages/20-settings.js +68 -0
  145. package/lib/stages/50-routes.js +218 -0
  146. package/lib/stages/90-server.js +347 -0
  147. package/package.json +5 -7
  148. package/lib/app/helper_model/criteria.js +0 -2294
  149. package/lib/app/helper_model/db_query.js +0 -1488
  150. package/lib/app/routes.js +0 -11
  151. package/lib/core/socket.js +0 -171
  152. package/lib/init/constants.js +0 -158
  153. package/lib/init/devwatch.js +0 -238
  154. package/lib/init/load_functions.js +0 -973
  155. package/lib/stages.js +0 -513
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Load all the stages
3
+ *
4
+ * @author Jelle De Loecker <jelle@elevenways.be>
5
+ * @since 1.4.0
6
+ * @version 1.4.0
7
+ */
8
+ requireCorePathAll('stages');
9
+
10
+ /**
11
+ * Add the launching event listener
12
+ *
13
+ * @author Jelle De Loecker <jelle@elevenways.be>
14
+ * @since 1.4.0
15
+ * @version 1.4.0
16
+ *
17
+ * @param {Alchemy.Stages.Stage} stage
18
+ */
19
+ STAGES.on('launching', function onLaunch(stage) {
20
+
21
+ if (typeof alchemy == 'undefined') {
22
+ return;
23
+ }
24
+
25
+ if (!alchemy.getSetting('debugging.debug')) {
26
+ return;
27
+ }
28
+
29
+ let id = stage.id.after('root.');
30
+
31
+ let colored_name = alchemy.colors.fg.getRgb(0, 5, 5) + id + alchemy.colors.reset;
32
+
33
+ let args = ['Launching', colored_name, 'stage…'];
34
+
35
+ let line = alchemy.printLog(alchemy.INFO, args, {level: 1});
36
+
37
+ if (line && line.args) {
38
+ stage.pledge.then(function finished() {
39
+ line.args.push('Done in', stage.ended - stage.started, 'ms');
40
+ line.dissect();
41
+ line.render();
42
+ });
43
+ }
44
+ });
45
+
46
+ /**
47
+ * Start all the stages
48
+ *
49
+ * @author Jelle De Loecker <jelle@elevenways.be>
50
+ * @since 1.4.0
51
+ * @version 1.4.0
52
+ */
53
+ STAGES.launch([
54
+ 'load_core',
55
+ ]);
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The alchemy global, where everything will be stored
3
+ *
4
+ * @author Jelle De Loecker <jelle@elevenways.be>
5
+ * @since 0.0.1
6
+ * @version 0.4.0
7
+ *
8
+ * @type {Alchemy}
9
+ */
10
+ DEFINE('alchemy', new Alchemy());
11
+
12
+ /**
13
+ * Define the log function
14
+ *
15
+ * @author Jelle De Loecker <jelle@elevenways.be>
16
+ * @since 0.0.1
17
+ * @version 0.4.0
18
+ *
19
+ * @type {Function}
20
+ */
21
+ DEFINE('log', alchemy.log);
22
+
23
+ for (let key in alchemy.Janeway.LEVELS) {
24
+ let name = key.toLowerCase();
25
+ let val = alchemy.Janeway.LEVELS[key];
26
+
27
+ log[name] = function(...args) {
28
+ return alchemy.printLog(val, args, {level: 2});
29
+ };
30
+ }
31
+
32
+ log.warn = log.warning;
33
+
34
+ /**
35
+ * Define the todo log function
36
+ *
37
+ * @author Jelle De Loecker <jelle@elevenways.be>
38
+ * @since 0.2.0
39
+ * @version 0.4.0
40
+ *
41
+ * @type {Function}
42
+ */
43
+ log.todo = function todo(...args) {
44
+
45
+ var options = {
46
+ gutter: alchemy.Janeway.esc(91) + '\u2620 Todo:' + alchemy.Janeway.esc(39),
47
+ level: 2
48
+ };
49
+
50
+ return alchemy.printLog(alchemy.TODO, args, options);
51
+ };
@@ -58,9 +58,22 @@ alchemy.hawkejs = Classes.Hawkejs.Hawkejs.getInstance();
58
58
  alchemy.toobusy = alchemy.use('toobusy-js', 'toobusy');
59
59
 
60
60
  /**
61
- * Load Sputnik, the stage-based launcher
61
+ * Compatibility for old Sputnik stage system
62
62
  */
63
- alchemy.sputnik = new (alchemy.use('sputnik', 'sputnik'))();
63
+ alchemy.sputnik = STAGES.createSputnikShim({
64
+ http : 'server.create_http',
65
+ core_app : 'load_app.core_app',
66
+ plugins : 'load_app.plugins',
67
+ base_app : 'load_app.main_app',
68
+ middleware : 'routes.middleware',
69
+ datasources : 'datasource',
70
+ define_debug : 'server.warn_debug',
71
+ socket : 'server.websocket',
72
+ hawkejs_setup : 'routes.hawkejs',
73
+ routes : 'routes',
74
+ start_server : 'server.start',
75
+ listening : 'server.listening',
76
+ });
64
77
 
65
78
  /**
66
79
  * Real-time apps made cross-browser & easy with a WebSocket-like API.
@@ -0,0 +1,238 @@
1
+ 'use strict';
2
+
3
+ if (process.argv.indexOf('--disable-devwatch') > -1) {
4
+ return;
5
+ }
6
+
7
+ if (!alchemy.settings.debugging.kill_on_file_change) {
8
+ return;
9
+ }
10
+
11
+ const chokidar = alchemy.use('chokidar');
12
+
13
+ if (!chokidar) {
14
+ log.warn('Can not watch files because Chokidar is not installed');
15
+ return;
16
+ }
17
+
18
+ let allowedPattern,
19
+ extensions,
20
+ prevcount,
21
+ watchlog,
22
+ watcher,
23
+ allowed,
24
+ ignored,
25
+ count,
26
+ cwd,
27
+ fs;
28
+
29
+ fs = alchemy.use('fs');
30
+
31
+ prevcount = 0;
32
+ count = 0;
33
+
34
+ ignored = /^app\/public\/views|^temp/;
35
+ extensions = ['js', 'json'];
36
+ cwd = process.cwd();
37
+
38
+ // Get the extensions allowed to kill the server
39
+ if (Array.isArray(alchemy.settings.debugging.kill_extensions)) {
40
+ extensions = alchemy.settings.debugging.kill_extensions;
41
+ }
42
+
43
+ allowedPattern = '';
44
+
45
+ // Go over every extensionin the array
46
+ extensions.forEach(function eachExtension(extension) {
47
+
48
+ if (allowedPattern) {
49
+ allowedPattern += '|';
50
+ }
51
+
52
+ allowedPattern += '\\.' + extension + '$';
53
+ });
54
+
55
+ // Create the regex
56
+ allowed = new RegExp(allowedPattern);
57
+
58
+ watchlog = Function.throttle(function watchlog() {
59
+
60
+ if (prevcount == count) {
61
+ return;
62
+ }
63
+
64
+ log.warn(count, 'files are being monitored for changes');
65
+ prevcount = count;
66
+ }, 1500, false, true);
67
+
68
+ // Use a map to log path results, because chokidar calls the `ignored`
69
+ // option multiple times for each file
70
+ let seen_map = new Map();
71
+
72
+ // Start watching all the files, starting with the current working directory
73
+ watcher = chokidar.watch(cwd, {ignored: function ignoreThisPath(_path) {
74
+
75
+ let cached = seen_map.get(_path);
76
+
77
+ if (cached != null) {
78
+ return cached;
79
+ }
80
+
81
+ let isAllowed,
82
+ path = _path,
83
+ stat = arguments[1],
84
+ file;
85
+
86
+ // Ignore git folders
87
+ if (~path.indexOf('.git')) {
88
+ seen_map.set(_path, true);
89
+ return true;
90
+ }
91
+
92
+ // Ignore non-stylesheet files in asset or public folders
93
+ if (~path.indexOf('/assets/') || ~path.indexOf('/public/')) {
94
+ // DO watch less files, for the stylesheet reload!
95
+ if (path.indexOf('.') > -1 && !path.endsWith('.less') && !path.endsWith('.css') && !path.endsWith('.scss')) {
96
+ seen_map.set(_path, true);
97
+ return true;
98
+ } else {
99
+ isAllowed = true;
100
+ }
101
+ }
102
+
103
+ // Skip some big module folders by default
104
+ if (path.endsWith('/less') || path.endsWith('/caniuse-lite') || path.endsWith('/bcrypt') || path.endsWith('/sass') || path.endsWith('/mmmagic') || path.endsWith('/node-gyp') || path.endsWith('/lodash')) {
105
+ seen_map.set(_path, true);
106
+ return true;
107
+ }
108
+
109
+ watchlog();
110
+
111
+ if (count > 4999) {
112
+ if (count == 5000) {
113
+ count++
114
+ log.warn('Already watching 5000 files, not watching any more');
115
+ }
116
+
117
+ seen_map.set(_path, true);
118
+ return true;
119
+ }
120
+
121
+ path = path.replace(cwd+'/', '');
122
+ file = path.split('/');
123
+ file = file[file.length-1];
124
+
125
+ if (file == 'package.json' || file == 'package-lock.json' || file.startsWith('scratch')) {
126
+ seen_map.set(_path, true);
127
+ return true;
128
+ }
129
+
130
+ if (path.count('/coverage/') || path.count('/.') || path.count('/test/') || path.count('/benchmark/') || path.count('/deoptigate/')) {
131
+ seen_map.set(_path, true);
132
+ return true;
133
+ }
134
+
135
+ if (isAllowed == null) {
136
+ // Only allow the specified extensions
137
+ isAllowed = allowed.exec(file);
138
+ }
139
+
140
+ // If it's already false, return it
141
+ if (!isAllowed) {
142
+ // Only disallow if it's not a directory
143
+ try {
144
+
145
+ // The stat supplied by chokidar (if it is suppliad at all)
146
+ // does not follow symlinks, so *sigh* get it again
147
+ stat = fs.statSync(path);
148
+
149
+ if (!stat.isDirectory()) {
150
+ seen_map.set(_path, true);
151
+ return true;
152
+ }
153
+ } catch (err) {
154
+ seen_map.set(_path, true);
155
+ // Ignore files that have been removed
156
+ return true;
157
+ }
158
+ }
159
+
160
+ // See if it's still allowed based on patterns to ignore
161
+ isAllowed = !ignored.exec(path);
162
+
163
+ if (isAllowed && path.count('/plugins/') == 1 && path.count('node_modules')) {
164
+ isAllowed = false;
165
+ }
166
+
167
+ if (isAllowed && path.count('node_modules')) {
168
+ if (path.count('/codecov/') || path.count('/mocha/') || path.count('/nyc/')) {
169
+ isAllowed = false;
170
+ }
171
+ }
172
+
173
+ // If it's still allowed, make sure it isn't 2 or more node_modules deep
174
+ if (isAllowed && path.count('node_modules') > 1) {
175
+
176
+ if (path.count('node_modules') == 2 && path.endsWith('node_modules')) {
177
+ isAllowed = true;
178
+ } else if (path.count('protoblast') || path.count('hawkejs') || path.count('janeway')) {
179
+ if (path.count('node_modules') > 2) {
180
+ isAllowed = false;
181
+ }
182
+ } else {
183
+ isAllowed = false;
184
+ }
185
+ }
186
+
187
+ // If it's still allowed, increase the watch count
188
+ if (isAllowed) {
189
+ count++;
190
+ }
191
+
192
+ seen_map.set(_path, !isAllowed);
193
+
194
+ // Return if it should be ignored or not
195
+ return !isAllowed;
196
+
197
+ }, persistent: true});
198
+
199
+ // Kill the server when any of the files change
200
+ watcher.on('change', function onFileChange(path, stats) {
201
+
202
+ // Skip hawkejs client file
203
+ if (path.indexOf('hawkejs-client-side.js') > -1) {
204
+ return false;
205
+ }
206
+
207
+ // Skip protoblast client files
208
+ if (path.indexOf('protoblast/client-file') > -1) {
209
+ return false;
210
+ }
211
+
212
+ // Also skip files in the temp directory
213
+ if (path.indexOf('temp/') === 0) {
214
+ return false;
215
+ }
216
+
217
+ // Skip assets or public files
218
+ if (path.indexOf('/assets/') > -1 || path.indexOf('/public/') > -1) {
219
+
220
+ if (path.endsWith('.css') || path.endsWith('.scss') || path.endsWith('.less')) {
221
+ broadcastReload(path);
222
+ }
223
+
224
+ return false;
225
+ }
226
+
227
+ // Only allow defined extensions
228
+ if (!allowed.exec(path)) {
229
+ return false;
230
+ }
231
+
232
+ // Kill the process, run together with something like "forever" to restart
233
+ die('Killing server because', JSON.stringify(path.replace(cwd + '/', '')), 'has been modified');
234
+ });
235
+
236
+ let broadcastReload = Function.throttle(function broadcastReload(path) {
237
+ alchemy.broadcast('css_reload', path);
238
+ }, 10, false, true);
@@ -0,0 +1,342 @@
1
+ const libpath = require('path');
2
+
3
+ /**
4
+ * The "load_core" stage
5
+ *
6
+ * @author Jelle De Loecker <jelle@elevenways.be>
7
+ * @since 1.4.0
8
+ * @version 1.4.0
9
+ *
10
+ * @type {Alchemy.Stages.Stage}
11
+ */
12
+ const load_core = STAGES.createStage('load_core');
13
+
14
+ /**
15
+ * The "load_core.init_settings" stage
16
+ *
17
+ * @author Jelle De Loecker <jelle@elevenways.be>
18
+ * @since 1.4.0
19
+ * @version 1.4.0
20
+ *
21
+ * @type {Alchemy.Stages.Stage}
22
+ */
23
+ const init_settings = load_core.createStage('init_settings', () => {
24
+ /**
25
+ * Load the setting class
26
+ */
27
+ requireCorePath('core', 'setting');
28
+
29
+ /**
30
+ * Load the actual settings
31
+ */
32
+ requireCorePath('scripts', 'create_settings');
33
+ });
34
+
35
+ /**
36
+ * The "load_core.init_alchemy" stage
37
+ *
38
+ * @author Jelle De Loecker <jelle@elevenways.be>
39
+ * @since 1.4.0
40
+ * @version 1.4.0
41
+ *
42
+ * @type {Alchemy.Stages.Stage}
43
+ */
44
+ const init_alchemy = load_core.createStage('init_alchemy', () => {
45
+ /**
46
+ * Load the setting class
47
+ */
48
+ requireCorePath('core', 'alchemy');
49
+
50
+ /**
51
+ * Load the actual settings
52
+ */
53
+ requireCorePath('scripts', 'init_alchemy');
54
+
55
+ /**
56
+ * Require basic functions
57
+ */
58
+ requireCorePath('core', 'alchemy_functions');
59
+
60
+ /**
61
+ * Require load functions
62
+ */
63
+ requireCorePath('core', 'alchemy_load_functions');
64
+ });
65
+
66
+ /**
67
+ * The "load_core.init_languages" stage
68
+ *
69
+ * @author Jelle De Loecker <jelle@elevenways.be>
70
+ * @since 1.4.0
71
+ * @version 1.4.0
72
+ *
73
+ * @type {Alchemy.Stages.Stage}
74
+ */
75
+ const init_languages = load_core.createStage('init_languages', () => {
76
+ /**
77
+ * Get all the languages by their locale
78
+ */
79
+ requireCorePath('scripts', 'create_languages');
80
+ });
81
+
82
+ /**
83
+ * The "load_core.preload_modules" stage
84
+ *
85
+ * @author Jelle De Loecker <jelle@elevenways.be>
86
+ * @since 1.4.0
87
+ * @version 1.4.0
88
+ *
89
+ * @type {Alchemy.Stages.Stage}
90
+ */
91
+ const preload_modules = load_core.createStage('preload_modules', () => {
92
+ /**
93
+ * Pre-load basic requirements
94
+ */
95
+ requireCorePath('scripts', 'preload_modules');
96
+ });
97
+
98
+ /**
99
+ * The "load_core.devwatch" stage
100
+ *
101
+ * @author Jelle De Loecker <jelle@elevenways.be>
102
+ * @since 1.4.0
103
+ * @version 1.4.0
104
+ *
105
+ * @type {Alchemy.Stages.Stage}
106
+ */
107
+ const devwatch = load_core.createStage('devwatch', () => {
108
+ /**
109
+ * Set up file change watchers for development
110
+ */
111
+ requireCorePath('scripts', 'setup_devwatch');
112
+ });
113
+
114
+ /**
115
+ * The "load_core.migration_class" stage
116
+ *
117
+ * @author Jelle De Loecker <jelle@elevenways.be>
118
+ * @since 1.4.0
119
+ * @version 1.4.0
120
+ *
121
+ * @type {Alchemy.Stages.Stage}
122
+ */
123
+ const migration_class = load_core.createStage('migration_class', () => {
124
+ /**
125
+ * The migration class
126
+ */
127
+ requireCorePath('class', 'migration');
128
+ });
129
+
130
+ /**
131
+ * The "load_core.core_classes" stage
132
+ *
133
+ * @author Jelle De Loecker <jelle@elevenways.be>
134
+ * @since 1.4.0
135
+ * @version 1.4.0
136
+ *
137
+ * @type {Alchemy.Stages.Stage}
138
+ */
139
+ const core_classes = load_core.createStage('core_classes', () => {
140
+
141
+ const CLIENT_HAWKEJS_OPTIONS = {
142
+
143
+ // Do not load on the server
144
+ server : false,
145
+
146
+ // Turn it into a commonjs load
147
+ make_commonjs: true,
148
+
149
+ // The arguments to add to the wrapper function
150
+ arguments : 'hawkejs'
151
+ };
152
+
153
+ const SERVER_HAWKEJS_OPTIONS = {
154
+
155
+ // Also load on the server
156
+ server : true,
157
+
158
+ // Turn it into a commonjs load
159
+ make_commonjs: true,
160
+
161
+ // The arguments to add to the wrapper function
162
+ arguments : 'hawkejs'
163
+ };
164
+
165
+ /**
166
+ * Require the base class on the client side too
167
+ *
168
+ * @author Jelle De Loecker <jelle@elevenways.be>
169
+ * @since 0.3.0
170
+ * @version 1.1.0
171
+ */
172
+ alchemy.hawkejs.load(resolveCorePath('core', 'base'), CLIENT_HAWKEJS_OPTIONS);
173
+
174
+ /**
175
+ * Require the client_base class on the client side too
176
+ *
177
+ * @author Jelle De Loecker <jelle@elevenways.be>
178
+ * @since 1.0.0
179
+ * @version 1.1.0
180
+ */
181
+ alchemy.hawkejs.load(resolveCorePath('core', 'client_base'), CLIENT_HAWKEJS_OPTIONS);
182
+
183
+ /**
184
+ * Require the error class
185
+ *
186
+ * @author Jelle De Loecker <jelle@elevenways.be>
187
+ * @since 1.1.0
188
+ * @version 1.1.0
189
+ */
190
+ alchemy.hawkejs.load(resolveCorePath('class', 'error'), SERVER_HAWKEJS_OPTIONS);
191
+
192
+ /**
193
+ * Require the client_alchemy class on the client side
194
+ *
195
+ * @author Jelle De Loecker <jelle@elevenways.be>
196
+ * @since 1.0.5
197
+ * @version 1.1.0
198
+ */
199
+ alchemy.hawkejs.load(resolveCorePath('core', 'client_alchemy'), SERVER_HAWKEJS_OPTIONS);
200
+
201
+ /**
202
+ * Require the path_evaluator class
203
+ *
204
+ * @author Jelle De Loecker <jelle@elevenways.be>
205
+ * @since 1.1.0
206
+ * @version 1.1.0
207
+ */
208
+ alchemy.hawkejs.load(resolveCorePath('class', 'path_evaluator'), SERVER_HAWKEJS_OPTIONS);
209
+
210
+ /**
211
+ * Require the field_value class
212
+ *
213
+ * @author Jelle De Loecker <jelle@elevenways.be>
214
+ * @since 1.1.0
215
+ * @version 1.1.0
216
+ */
217
+ alchemy.hawkejs.load(resolveCorePath('class', 'field_value'), SERVER_HAWKEJS_OPTIONS);
218
+
219
+ /**
220
+ * Require the path_definition class on the client side too
221
+ *
222
+ * @author Jelle De Loecker <jelle@elevenways.be>
223
+ * @since 1.0.0
224
+ * @version 1.1.0
225
+ */
226
+ alchemy.hawkejs.load(resolveCorePath('class', 'path_definition'), CLIENT_HAWKEJS_OPTIONS);
227
+ alchemy.hawkejs.load(resolveCorePath('class', 'path_param_definition'), CLIENT_HAWKEJS_OPTIONS);
228
+
229
+ /**
230
+ * Require the element class on the client side too
231
+ *
232
+ * @author Jelle De Loecker <jelle@elevenways.be>
233
+ * @since 1.0.0
234
+ * @version 1.1.0
235
+ */
236
+ alchemy.hawkejs.load(resolveCorePath('class', 'element'), CLIENT_HAWKEJS_OPTIONS);
237
+
238
+ /**
239
+ * Require the helper class on the client side too
240
+ *
241
+ * @author Jelle De Loecker <jelle@elevenways.be>
242
+ * @since 1.0.0
243
+ * @version 1.1.0
244
+ */
245
+ alchemy.hawkejs.load(resolveCorePath('class', 'helper'), CLIENT_HAWKEJS_OPTIONS);
246
+
247
+ /**
248
+ * Require the datasource class on the client side too
249
+ *
250
+ * @author Jelle De Loecker <jelle@elevenways.be>
251
+ * @since 1.1.0
252
+ * @version 1.1.0
253
+ */
254
+ alchemy.hawkejs.load(resolveCorePath('class', 'datasource'), CLIENT_HAWKEJS_OPTIONS);
255
+
256
+ /**
257
+ * Require the field class on the client side too
258
+ *
259
+ * @author Jelle De Loecker <jelle@elevenways.be>
260
+ * @since 1.1.0
261
+ * @version 1.1.0
262
+ */
263
+ alchemy.hawkejs.load(resolveCorePath('class', 'field'), CLIENT_HAWKEJS_OPTIONS);
264
+
265
+ /**
266
+ * Require the schema_client class on the client side too
267
+ *
268
+ * @author Jelle De Loecker <jelle@elevenways.be>
269
+ * @since 1.1.0
270
+ * @version 1.1.0
271
+ */
272
+ alchemy.hawkejs.load(resolveCorePath('class', 'schema_client'), CLIENT_HAWKEJS_OPTIONS);
273
+
274
+ /**
275
+ * Require the setting classes on the client side too
276
+ *
277
+ * @author Jelle De Loecker <jelle@elevenways.be>
278
+ * @since 1.4.0
279
+ * @version 1.4.0
280
+ */
281
+ alchemy.hawkejs.load(resolveCorePath('core', 'setting'), CLIENT_HAWKEJS_OPTIONS);
282
+
283
+ /**
284
+ * Set up prefixes
285
+ */
286
+ alchemy.useOnce(resolveCorePath('core', 'prefix'));
287
+
288
+ /**
289
+ * Set up middleware functions
290
+ */
291
+ alchemy.useOnce(resolveCorePath('core', 'middleware'));
292
+
293
+ /**
294
+ * Load discovery code
295
+ */
296
+ alchemy.useOnce(resolveCorePath('core', 'discovery'));
297
+
298
+ /**
299
+ * Load inode classes
300
+ */
301
+ alchemy.useOnce(resolveCorePath('class', 'inode'));
302
+ alchemy.useOnce(resolveCorePath('class', 'inode_file'));
303
+ alchemy.useOnce(resolveCorePath('class', 'inode_dir'));
304
+ alchemy.useOnce(resolveCorePath('class', 'inode_list'));
305
+ });
306
+
307
+ /**
308
+ * The "load_core.main_classes" stage
309
+ *
310
+ * @author Jelle De Loecker <jelle@elevenways.be>
311
+ * @since 1.4.0
312
+ * @version 1.4.0
313
+ *
314
+ * @type {Alchemy.Stages.Stage}
315
+ */
316
+ const main_classes = load_core.createStage('main_classes', () => {
317
+ // Load in all main classes
318
+ alchemy.usePath(resolveCorePath('class'));
319
+ });
320
+
321
+ /**
322
+ * The "load_core.app_bootstrap" stage
323
+ *
324
+ * @author Jelle De Loecker <jelle@elevenways.be>
325
+ * @since 1.4.0
326
+ * @version 1.4.0
327
+ *
328
+ * @type {Alchemy.Stages.Stage}
329
+ */
330
+ const app_bootstrap = load_core.createStage('app_bootstrap', () => {
331
+ // Load the base bootstrap file
332
+ try {
333
+ alchemy.useOnce(libpath.resolve(PATH_ROOT, 'app', 'config', 'bootstrap'));
334
+ } catch (err) {
335
+ if (err.message.indexOf('Cannot find') === -1) {
336
+ alchemy.printLog(alchemy.WARNING, 'Could not load app bootstrap file');
337
+ throw err;
338
+ } else {
339
+ alchemy.printLog(alchemy.SEVERE, 'Could not load config bootstrap file', {err: err});
340
+ }
341
+ }
342
+ });