mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
experimenting with gradual loading of features in cli...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
98bc9ecc24
commit
f17280597e
@ -21,14 +21,16 @@
|
||||
|
||||
var _requirejs = typeof(requirejs) != 'undefined' && requirejs
|
||||
|
||||
var setup = function(require){
|
||||
var setup = function(require, root){
|
||||
var res = {}
|
||||
var requirejs = _requirejs
|
||||
|
||||
var requirejs_cfg = {
|
||||
// NOTE: this is really odd: running electron as a packed binary breaks
|
||||
// requirejs' paths...
|
||||
baseUrl: typeof(process) != 'undefined'
|
||||
baseUrl: root ?
|
||||
root
|
||||
: typeof(process) != 'undefined'
|
||||
&& process.versions.electron ?
|
||||
(require.main ?
|
||||
require.main.filename.split(/[\\\/]/g).slice(0, -1).join('/')
|
||||
@ -79,7 +81,6 @@ var setup = function(require){
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
// node contexts...
|
||||
if(typeof(process) != 'undefined'){
|
||||
var nodeRequire =
|
||||
|
||||
@ -56,8 +56,7 @@ require('features/examples')
|
||||
if(typeof(window) == 'undefined' || window.nodejs != null){
|
||||
require('features/filesystem')
|
||||
require('features/sharp')
|
||||
require('features/cli')
|
||||
}
|
||||
require('features/cli') }
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@ -19,12 +19,14 @@ var core = require('features/core')
|
||||
var base = require('features/base')
|
||||
|
||||
|
||||
//require('features/all')
|
||||
|
||||
|
||||
if(typeof(process) != 'undefined'){
|
||||
var pathlib = requirejs('path')
|
||||
var argv = requirejs('lib/argv')
|
||||
var progress = requirejs('cli-progress')
|
||||
var colors = requirejs('colors')
|
||||
}
|
||||
var colors = requirejs('colors') }
|
||||
|
||||
|
||||
|
||||
@ -175,6 +177,18 @@ var CLIActions = actions.Actions({
|
||||
}],
|
||||
|
||||
|
||||
// XXX SETUP revise default...
|
||||
setupFeatures: ['- System/',
|
||||
function(...tags){
|
||||
var features = this.features.FeatureSet
|
||||
requirejs('features/all')
|
||||
features.setup(this, tags.length == 0 ?
|
||||
[
|
||||
'imagegrid-testing',
|
||||
...this.features.input,
|
||||
]
|
||||
: tags) }],
|
||||
|
||||
|
||||
// Startup commands...
|
||||
//
|
||||
@ -187,6 +201,9 @@ var CLIActions = actions.Actions({
|
||||
var that = this
|
||||
var repl = nodeRequire('repl')
|
||||
|
||||
// XXX SETUP
|
||||
this.setupFeatures()
|
||||
|
||||
this.__keep_running = true
|
||||
|
||||
// setup the global ns...
|
||||
@ -197,10 +214,12 @@ var CLIActions = actions.Actions({
|
||||
global.help = function(...actions){
|
||||
global.ig.help(...actions) }
|
||||
|
||||
require('features/all')
|
||||
global.ImageGridFeatures = core.ImageGridFeatures
|
||||
var features = global.ImageGridFeatures = core.ImageGridFeatures
|
||||
|
||||
//var ig = core.ImageGridFeatures
|
||||
|
||||
// print banner...
|
||||
//XXX
|
||||
|
||||
repl
|
||||
.start({
|
||||
@ -292,7 +311,11 @@ var CLIActions = actions.Actions({
|
||||
doc: 'Show image filename pattern info and exit',
|
||||
priority: 89,
|
||||
handler: function(){
|
||||
this.parent.context.help('formatImageName')
|
||||
this.parent.context
|
||||
// XXX SETUP
|
||||
//.setupFeatures('fs', 'commandline')
|
||||
.setupFeatures()
|
||||
.help('formatImageName')
|
||||
return argv.STOP } },
|
||||
'-version': undefined,
|
||||
'-quiet': undefined,
|
||||
@ -347,6 +370,9 @@ var CLIActions = actions.Actions({
|
||||
function(path, options={}){
|
||||
var that = this
|
||||
|
||||
// XXX SETUP
|
||||
this.setupFeatures()
|
||||
|
||||
path = path || options.from
|
||||
path = util.normalizePath(
|
||||
path ?
|
||||
@ -398,6 +424,9 @@ var CLIActions = actions.Actions({
|
||||
//valueRequired: true,
|
||||
}},
|
||||
function(path, options){
|
||||
// XXX SETUP
|
||||
this.setupFeatures()
|
||||
|
||||
// get mode...
|
||||
if(path == 'create' || path == 'update'){
|
||||
var [mode, path, options] = arguments }
|
||||
@ -490,6 +519,9 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
// XXX
|
||||
var interactive = false
|
||||
|
||||
// XXX SETUP need to setup everything that has command-line features...
|
||||
//this.setupFeatures()
|
||||
|
||||
argv.Parser({
|
||||
context: this,
|
||||
|
||||
|
||||
@ -76,6 +76,8 @@ var text = module.text = object.text
|
||||
//
|
||||
var ImageGridMetaActions =
|
||||
module.ImageGridMetaActions = {
|
||||
__proto__: actions.MetaActions,
|
||||
|
||||
// Test if the action is a Toggler...
|
||||
//
|
||||
isToggler:
|
||||
@ -109,19 +111,21 @@ module.ImageGridMetaActions = {
|
||||
}
|
||||
}),
|
||||
}
|
||||
ImageGridMetaActions.__proto__ = actions.MetaActions
|
||||
|
||||
var ImageGrid =
|
||||
module.ImageGrid =
|
||||
object.Constructor('ImageGrid', ImageGridMetaActions)
|
||||
|
||||
|
||||
// Root ImageGrid feature set....
|
||||
var ImageGridFeatures =
|
||||
module.ImageGridFeatures = new features.FeatureSet()
|
||||
module.ImageGridFeatures =
|
||||
new features.FeatureSet()
|
||||
|
||||
// setup base instance constructor...
|
||||
ImageGridFeatures.__actions__ =
|
||||
function(){ return actions.Actions(ImageGrid()) }
|
||||
function(){
|
||||
return actions.Actions(ImageGrid()) }
|
||||
|
||||
|
||||
|
||||
@ -994,6 +998,7 @@ var LifeCycleActions = actions.Actions({
|
||||
&& func.call(this) } }],
|
||||
|
||||
// helpers...
|
||||
//
|
||||
restart: ['System/Soft restart',
|
||||
doc`Soft restart
|
||||
|
||||
@ -1004,8 +1009,6 @@ var LifeCycleActions = actions.Actions({
|
||||
.stop()
|
||||
.clear()
|
||||
.start() }],
|
||||
|
||||
|
||||
})
|
||||
|
||||
var LifeCycle =
|
||||
|
||||
10
Viewer/ig.js
10
Viewer/ig.js
@ -26,8 +26,10 @@ require('v8-compile-cache')
|
||||
// conflicting with stuff...
|
||||
require('repl')
|
||||
|
||||
var path = require('path')
|
||||
|
||||
// setup module loaders...
|
||||
require = require('./cfg/requirejs')(require).requirejs
|
||||
require = require('./cfg/requirejs')(require, path.resolve(__dirname)).requirejs
|
||||
require.main = {filename: (nodeRequire.main || {}).filename}
|
||||
|
||||
var core = require('features/core')
|
||||
@ -40,6 +42,9 @@ var meta = require('features/meta')
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// XXX SETUP
|
||||
//require('features/all')
|
||||
|
||||
// NOTE: this is here to simplify importing...
|
||||
var ImageGridFeatures =
|
||||
module.ImageGridFeatures =
|
||||
@ -48,7 +53,8 @@ module.ImageGridFeatures =
|
||||
// setup actions and start...
|
||||
ImageGridFeatures
|
||||
.setup([
|
||||
'imagegrid-testing',
|
||||
// XXX SETUP should this do a full setup...
|
||||
//'imagegrid-testing',
|
||||
'imagegrid-commandline',
|
||||
])
|
||||
.start()
|
||||
|
||||
6
Viewer/package-lock.json
generated
6
Viewer/package-lock.json
generated
@ -1197,9 +1197,9 @@
|
||||
}
|
||||
},
|
||||
"ig-features": {
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.4.5.tgz",
|
||||
"integrity": "sha512-koFV8Rx5MUmnbwQcGKuO6A62XQB4F/TJ2ZwDwpTGDkeUmNkLLkPaPaW9fwMosUZRZoKCiH6evARqaSW/PX91Ww==",
|
||||
"version": "3.4.7",
|
||||
"resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.4.7.tgz",
|
||||
"integrity": "sha512-ejwYjnP1K5mXzbnLTrsuuB0lGSeUtO6UtBxYcGbXGdu9rgKjz3Q46qC9XYiM01zYw3MltivLCdc2kN6/RiOvZw==",
|
||||
"requires": {
|
||||
"ig-actions": "^3.24.28",
|
||||
"ig-object": "^5.4.14"
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
"guarantee-events": "^1.0.0",
|
||||
"ig-actions": "^3.24.29",
|
||||
"ig-argv": "^2.16.3",
|
||||
"ig-features": "^3.4.5",
|
||||
"ig-features": "^3.4.7",
|
||||
"ig-object": "^5.4.14",
|
||||
"ig-types": "^6.0.7",
|
||||
"json5": "^2.1.3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user