@forrestjs/core
Advanced tools
Comparing version 4.7.2 to 5.0.0-alpha.0
{ | ||
"name": "@forrestjs/core", | ||
"description": "ForrestJS is the Javascript plugin syste.", | ||
"version": "4.7.2", | ||
"version": "5.0.0-alpha.0", | ||
"main": "src/index.js", | ||
@@ -34,3 +34,3 @@ "author": "Marco Pegoraro <marco.pegoraro@gmail.com", | ||
}, | ||
"gitHead": "054b178c20d72dcae28d849ee3122a52aa67cee9", | ||
"gitHead": "86d1fdf1e0a6ff0bc85d697b7e7e93d5e100d93d", | ||
"devDependencies": { | ||
@@ -37,0 +37,0 @@ "jest": "^28.1.0" |
@@ -14,12 +14,10 @@ const dotted = require('@marcopeg/dotted').default; | ||
// DEPRECATED: property "hook" is deprecated and will be removed in v5.0.0 | ||
const isDeclarativeAction = ( | ||
{ hook, target, handler }, | ||
{ target, handler }, | ||
integrationName, | ||
integrationType, | ||
) => { | ||
const _target = target || hook; | ||
if (!(typeof _target === 'string' && _target)) { | ||
if (!(typeof target === 'string' && target)) { | ||
throw new ForrestJSInvalidTargetError( | ||
`${integrationType} "${integrationName}" defines an invalid target "${_target}"`, | ||
`${integrationType} "${integrationName}" defines an invalid target "${target}"`, | ||
); | ||
@@ -84,19 +82,19 @@ } | ||
// registerAction('hook', () => {}, { name: 'name' }) | ||
if (typeof ag1 === 'string') { | ||
console.warn( | ||
`[DEPRECATED] "registerAction(name, handler, option)" is deprecated and will be remove in version 5.0.0.`, | ||
); | ||
// if (typeof ag1 === 'string') { | ||
// console.warn( | ||
// `[DEPRECATED] "registerAction(name, handler, option)" is deprecated and will be remove in version 5.0.0.`, | ||
// ); | ||
return registeredExtensions.push([ | ||
ag1, | ||
ag2, | ||
{ | ||
...(typeof ag3 === 'string' ? { name: ag3 } : ag3), | ||
name: `${prefix}${ | ||
(typeof ag3 === 'string' ? ag3 : ag3.name) || | ||
integrationName | ||
}`, | ||
}, | ||
]); | ||
} | ||
// return registeredExtensions.push([ | ||
// ag1, | ||
// ag2, | ||
// { | ||
// ...(typeof ag3 === 'string' ? { name: ag3 } : ag3), | ||
// name: `${prefix}${ | ||
// (typeof ag3 === 'string' ? ag3 : ag3.name) || | ||
// integrationName | ||
// }`, | ||
// }, | ||
// ]); | ||
// } | ||
@@ -129,39 +127,38 @@ // Handle definition as an object | ||
// [ hook, handler, { otherOptions }] | ||
else if ( | ||
Array.isArray(computed) && | ||
computed.length >= 2 && | ||
typeof computed[0] === 'string' && | ||
(typeof computed[1] === 'function' || typeof computed[1] === 'object') | ||
) { | ||
console.warn( | ||
'[DEPRECATED] please use the object base declarative pattern { hook, handler, ... } - this API will be removed in v5.0.0', | ||
); | ||
const [hook, handler, options = {}] = computed; | ||
registeredExtensions.push({ | ||
...(typeof options === 'string' | ||
? { name: `${prefix}${options}` } | ||
: { | ||
...options, | ||
name: `${prefix}${options.name || integrationName}`, | ||
}), | ||
hook, | ||
// An handler could be a simple object to skip any running function | ||
handler: typeof handler === 'function' ? handler : () => handler, | ||
}); | ||
} | ||
// else if ( | ||
// Array.isArray(computed) && | ||
// computed.length >= 2 && | ||
// typeof computed[0] === 'string' && | ||
// (typeof computed[1] === 'function' || typeof computed[1] === 'object') | ||
// ) { | ||
// console.warn( | ||
// '[DEPRECATED] please use the object base declarative pattern { hook, handler, ... } - this API will be removed in v5.0.0', | ||
// ); | ||
// const [hook, handler, options = {}] = computed; | ||
// registeredExtensions.push({ | ||
// ...(typeof options === 'string' | ||
// ? { name: `${prefix}${options}` } | ||
// : { | ||
// ...options, | ||
// name: `${prefix}${options.name || integrationName}`, | ||
// }), | ||
// hook, | ||
// // An handler could be a simple object to skip any running function | ||
// handler: typeof handler === 'function' ? handler : () => handler, | ||
// }); | ||
// } | ||
// register a single action give an a configuration object | ||
// { hook, handler, ... } | ||
// DEPRECATED: "hook" in favor for "target" - remove in v5.0.0 | ||
else if ( | ||
computed && | ||
(computed.hook || computed.target) && | ||
computed.handler | ||
) { | ||
if (computed.hook) { | ||
console.warn( | ||
`[DEPRECATED] the key "hook" is deprecated and will be removed from v5.0.0.\nPlease use "target" instead.`, | ||
); | ||
} | ||
// { target, handler, ... } | ||
else if (computed && computed.target && computed.handler) { | ||
// else if (computed) { | ||
// if (computed.hook) { | ||
// console.warn( | ||
// `[DEPRECATED] the key "hook" is deprecated and will be removed from v5.0.0.\nPlease use "target" instead.`, | ||
// ); | ||
// } | ||
// Strict check on the action format: | ||
isDeclarativeAction(computed, integrationName, integrationType); | ||
registeredExtensions.push({ | ||
@@ -222,7 +219,7 @@ ...computed, | ||
async () => { | ||
if (Array.isArray(appManifest)) { | ||
console.warn( | ||
`[DEPRECATED] The array version is deprecated and will be removed in v5.0.0.\nUse the full App Manifest definition instead.`, | ||
); | ||
} | ||
// if (Array.isArray(appManifest)) { | ||
// console.warn( | ||
// `[DEPRECATED] The array version is deprecated and will be removed in v5.0.0.\nUse the full App Manifest definition instead.`, | ||
// ); | ||
// } | ||
@@ -292,30 +289,30 @@ // accepts a single param as [] of features | ||
// DEPRECATED: remove in v5.0.0 | ||
internalContext.createHook = (...args) => { | ||
console.warn( | ||
`[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
); | ||
return _cs(...args); | ||
}; | ||
internalContext.createHook.sync = (...args) => { | ||
console.warn( | ||
`[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
); | ||
return _cs.sync(...args); | ||
}; | ||
internalContext.createHook.serie = (...args) => { | ||
console.warn( | ||
`[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
); | ||
return _cs.serie(...args); | ||
}; | ||
internalContext.createHook.parallel = (...args) => { | ||
console.warn( | ||
`[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
); | ||
return _cs.parallel(...args); | ||
}; | ||
internalContext.createHook.waterfall = (...args) => { | ||
console.warn('[DEPRECATED] createHook'); | ||
return _cs.waterfall(...args); | ||
}; | ||
// internalContext.createHook = (...args) => { | ||
// console.warn( | ||
// `[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
// ); | ||
// return _cs(...args); | ||
// }; | ||
// internalContext.createHook.sync = (...args) => { | ||
// console.warn( | ||
// `[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
// ); | ||
// return _cs.sync(...args); | ||
// }; | ||
// internalContext.createHook.serie = (...args) => { | ||
// console.warn( | ||
// `[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
// ); | ||
// return _cs.serie(...args); | ||
// }; | ||
// internalContext.createHook.parallel = (...args) => { | ||
// console.warn( | ||
// `[DEPRECATED] "createHook()" will be removed from v5.0.0.\nUse "createExtension()" instead`, | ||
// ); | ||
// return _cs.parallel(...args); | ||
// }; | ||
// internalContext.createHook.waterfall = (...args) => { | ||
// console.warn('[DEPRECATED] createHook'); | ||
// return _cs.waterfall(...args); | ||
// }; | ||
@@ -348,2 +345,3 @@ // run lifecycle | ||
// Implement trace without a Hook | ||
// TODO: move before the execution | ||
if (trace) { | ||
@@ -382,14 +380,14 @@ const lines = []; | ||
// DEPRECATED: remove in v5.0.0 | ||
const createHookApp = ($) => { | ||
console.warn( | ||
'[DEPRECATED] use "createApp()" instead of "createHookApp()". It will be removed in v5.0.0', | ||
); | ||
return createApp($); | ||
}; | ||
const runHookApp = ($) => { | ||
console.warn( | ||
'[DEPRECATED] use "createApp()" instead of "runHookApp()". It will be removed in v5.0.0', | ||
); | ||
return startApp($); | ||
}; | ||
// const createHookApp = ($) => { | ||
// console.warn( | ||
// '[DEPRECATED] use "createApp()" instead of "createHookApp()". It will be removed in v5.0.0', | ||
// ); | ||
// return createApp($); | ||
// }; | ||
// const runHookApp = ($) => { | ||
// console.warn( | ||
// '[DEPRECATED] use "createApp()" instead of "runHookApp()". It will be removed in v5.0.0', | ||
// ); | ||
// return startApp($); | ||
// }; | ||
@@ -401,4 +399,4 @@ module.exports = { | ||
isListOfDeclarativeActions, | ||
createHookApp, // DEPRECATED: remove in v5.0.0 | ||
runHookApp, // DEPRECATED: remove in v5.0.0 | ||
// createHookApp, // DEPRECATED: remove in v5.0.0 | ||
// runHookApp, // DEPRECATED: remove in v5.0.0 | ||
}; |
@@ -64,26 +64,30 @@ const { ForrestJSUnknownTargetError } = require('./errors'); | ||
const registerTargets = (name, value) => { | ||
// handle a dictionary input | ||
if (typeof name === 'object') { | ||
Object.keys(name) | ||
.filter((key) => !SKIP_REGISTER_LIFECYCLE_EXTENSIONS.includes(key)) | ||
.forEach((key) => registerTarget(key, name[key])); | ||
return; | ||
const registerTargets = (name = {}) => { | ||
if (typeof name !== 'object') { | ||
throw new Error(`registerTargets() accepts only an object`); | ||
} | ||
console.warn( | ||
'[DEPRECATED] use "registerTargets({ name: value })".\nThe support for registering a single action is deprecated and will be remove in v5.0.0', | ||
); | ||
// handle a dictionary input | ||
// if (typeof name === 'object') { | ||
Object.keys(name) | ||
.filter((key) => !SKIP_REGISTER_LIFECYCLE_EXTENSIONS.includes(key)) | ||
.forEach((key) => registerTarget(key, name[key])); | ||
return; | ||
// } | ||
registerTarget(name, value); | ||
}; | ||
// console.warn( | ||
// '[DEPRECATED] use "registerTargets({ name: value })".\nThe support for registering a single action is deprecated and will be remove in v5.0.0', | ||
// ); | ||
// DEPRECATED: remove in v5.0.0 | ||
const registerHook = (name, value) => { | ||
console.warn( | ||
'[DEPRECATED] use "registerTargets()" instead of "registerHook()".\nIt will be removed in v5.0.0', | ||
); | ||
registerTargets(name, value); | ||
// registerTarget(name, value); | ||
}; | ||
// // DEPRECATED: remove in v5.0.0 | ||
// const registerHook = (name, value) => { | ||
// console.warn( | ||
// '[DEPRECATED] use "registerTargets()" instead of "registerHook()".\nIt will be removed in v5.0.0', | ||
// ); | ||
// registerTargets(name, value); | ||
// }; | ||
// Initialize the registry with the lifecycle Actions | ||
@@ -97,5 +101,5 @@ registerTargets(initialExtensions); | ||
getTargets, | ||
getAction, // DEPRECATED: remove in v5.0.0 | ||
getHook, // DEPRECATED: remove in v5.0.0 | ||
registerHook, // DEPRECATED: remove in v5.0.0 | ||
// getAction, // DEPRECATED: remove in v5.0.0 | ||
// getHook, // DEPRECATED: remove in v5.0.0 | ||
// registerHook, // DEPRECATED: remove in v5.0.0 | ||
}; | ||
@@ -115,15 +119,15 @@ registries[registryName || `default${registries.length || ''}`] = registry; | ||
const getAction = (...args) => { | ||
console.warn( | ||
'[DEPRECATED] use "getTarget()" instead of "getHook()". It will be removed in v5.0.0', | ||
); | ||
return getTarget(...args); | ||
}; | ||
// const getAction = (...args) => { | ||
// console.warn( | ||
// '[DEPRECATED] use "getTarget()" instead of "getHook()". It will be removed in v5.0.0', | ||
// ); | ||
// return getTarget(...args); | ||
// }; | ||
const getHook = (...args) => { | ||
console.warn( | ||
'[DEPRECATED] use "getTarget()" instead of "getHook()". It will be removed in v5.0.0', | ||
); | ||
return getAction(...args); | ||
}; | ||
// const getHook = (...args) => { | ||
// console.warn( | ||
// '[DEPRECATED] use "getTarget()" instead of "getHook()". It will be removed in v5.0.0', | ||
// ); | ||
// return getAction(...args); | ||
// }; | ||
@@ -138,5 +142,5 @@ // Test support | ||
getTarget, | ||
getAction, // DEPRECATED: remove in v5.0.0 | ||
// getAction, // DEPRECATED: remove in v5.0.0 | ||
resetState, | ||
getHook, // DEPRECATED: remove in v5.0.0 | ||
// getHook, // DEPRECATED: remove in v5.0.0 | ||
}; |
@@ -66,3 +66,3 @@ class ForrestJSGetConfigError extends Error { | ||
// Deprecated, will be removed in v5.0.0 | ||
this.hook = `[DEPRECATED] "err.hook" will be remove in v5.0.0\nUse "err.target" instead.\n${action.hook}`; | ||
// this.hook = `[DEPRECATED] "err.hook" will be remove in v5.0.0\nUse "err.target" instead.\n${action.hook}`; | ||
@@ -69,0 +69,0 @@ // TODO: "action.hook" must change to "action.target" |
@@ -14,3 +14,3 @@ const { traceHook, logTrace, logBoot } = require('./tracer'); | ||
} = require('./create-app'); | ||
const { createHookContext } = require('./create-hook-context'); | ||
// const { createHookContext } = require('./create-hook-context'); | ||
const { getHook, getAction, getTarget } = require('./create-targets-registry'); | ||
@@ -21,23 +21,23 @@ const constants = require('./constants'); | ||
// Temporary hack to rename "createHook" -> "runHook" | ||
const runHookDeprecate = `[DEPRECATED] runHook is deprecated and will be removed in next major version (v5.0.0)`; | ||
const runHook = (...args) => { | ||
console.warn(runHookDeprecate); | ||
return createHook(...args); | ||
}; | ||
runHook.sync = (...args) => { | ||
console.warn(runHookDeprecate); | ||
return createHook.sync(...args); | ||
}; | ||
runHook.serie = (...args) => { | ||
console.warn(runHookDeprecate); | ||
return createHook.serie(...args); | ||
}; | ||
runHook.parallel = (...args) => { | ||
console.warn(runHookDeprecate); | ||
return createHook.parallel(...args); | ||
}; | ||
runHook.waterfall = (...args) => { | ||
console.warn(runHookDeprecate); | ||
return createHook.waterfall(...args); | ||
}; | ||
// const runHookDeprecate = `[DEPRECATED] runHook is deprecated and will be removed in next major version (v5.0.0)`; | ||
// const runHook = (...args) => { | ||
// console.warn(runHookDeprecate); | ||
// return createHook(...args); | ||
// }; | ||
// runHook.sync = (...args) => { | ||
// console.warn(runHookDeprecate); | ||
// return createHook.sync(...args); | ||
// }; | ||
// runHook.serie = (...args) => { | ||
// console.warn(runHookDeprecate); | ||
// return createHook.serie(...args); | ||
// }; | ||
// runHook.parallel = (...args) => { | ||
// console.warn(runHookDeprecate); | ||
// return createHook.parallel(...args); | ||
// }; | ||
// runHook.waterfall = (...args) => { | ||
// console.warn(runHookDeprecate); | ||
// return createHook.waterfall(...args); | ||
// }; | ||
@@ -59,9 +59,9 @@ // Export the global symbol as App runner: | ||
// DEPRECATED APIs: remove in v5.0.0 | ||
run.createHook = createHook; // DEPRECATED: to remove in v5.0.0 | ||
run.runHook = runHook; // DEPRECATED: to remove in v5.0.0 | ||
run.createHookContext = createHookContext; // DEPRECATED: to remove in v5.0.0 | ||
run.createHookApp = createHookApp; // DEPRECATED: remove in v5.0.0 | ||
run.getHook = getHook; // DEPRECATED: remove in v5.0.0 | ||
run.getAction = getAction; // DEPRECATED: remove in v5.0.0 | ||
run.runHookApp = runHookApp; // DEPRECATED: remove in v5.0.0 | ||
// run.createHook = createHook; // DEPRECATED: to remove in v5.0.0 | ||
// run.runHook = runHook; // DEPRECATED: to remove in v5.0.0 | ||
// // run.createHookContext = createHookContext; // DEPRECATED: to remove in v5.0.0 | ||
// run.createHookApp = createHookApp; // DEPRECATED: remove in v5.0.0 | ||
// run.getHook = getHook; // DEPRECATED: remove in v5.0.0 | ||
// run.getAction = getAction; // DEPRECATED: remove in v5.0.0 | ||
// run.runHookApp = runHookApp; // DEPRECATED: remove in v5.0.0 | ||
@@ -68,0 +68,0 @@ // Export the internal constants: |
@@ -20,25 +20,25 @@ /** | ||
// (name, handler, options) | ||
if (typeof __arg1 === 'string') { | ||
console.warn( | ||
`[DEPRECATED] "registerAction(name, handler, option)" is deprecated and will be remove in version 5.x.`, | ||
); | ||
// if (typeof __arg1 === 'string') { | ||
// console.warn( | ||
// `[DEPRECATED] "registerAction(name, handler, option)" is deprecated and will be remove in version 5.x.`, | ||
// ); | ||
return registerAction({ | ||
...__arg3, | ||
target: __arg1, | ||
handler: __arg2, | ||
}); | ||
} | ||
// return registerAction({ | ||
// ...__arg3, | ||
// target: __arg1, | ||
// handler: __arg2, | ||
// }); | ||
// } | ||
// ([ name, handler, options ]) | ||
if (Array.isArray(__arg1)) { | ||
console.warn( | ||
`[DEPRECATED] "registerAction([name, handler, option])" is deprecated and will be remove in version 5.x.`, | ||
); | ||
return registerAction({ | ||
...(__arg1[2] || {}), | ||
target: __arg1[0], | ||
handler: __arg1[1], | ||
}); | ||
} | ||
// if (Array.isArray(__arg1)) { | ||
// console.warn( | ||
// `[DEPRECATED] "registerAction([name, handler, option])" is deprecated and will be remove in version 5.x.`, | ||
// ); | ||
// return registerAction({ | ||
// ...(__arg1[2] || {}), | ||
// target: __arg1[0], | ||
// handler: __arg1[1], | ||
// }); | ||
// } | ||
@@ -48,3 +48,3 @@ // ({ to: 'xxx', handler: () => {}, ...options }) | ||
const { | ||
hook: deprecatedReceivedHook, // DEPRECATER: will be removed in v5.0.0 | ||
// hook: deprecatedReceivedHook, // DEPRECATER: will be removed in v5.0.0 | ||
target: receivedTarget, | ||
@@ -60,3 +60,3 @@ // action, | ||
// Backward compatibility until v5.0.0 | ||
const targetAction = receivedTarget || deprecatedReceivedHook; | ||
const targetAction = receivedTarget; // || deprecatedReceivedHook; | ||
@@ -71,7 +71,7 @@ if (!targetAction) { | ||
if (deprecatedReceivedHook) { | ||
console.warn( | ||
'[DEPRECATED] The "hook" property is deprecated and will be removed in v5.0.0\nUse "target" instead.', | ||
); | ||
} | ||
// if (deprecatedReceivedHook) { | ||
// console.warn( | ||
// '[DEPRECATED] The "hook" property is deprecated and will be removed in v5.0.0\nUse "target" instead.', | ||
// ); | ||
// } | ||
@@ -78,0 +78,0 @@ const handler = |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
44703
1