nope/lib/cli/repl.ts
Martin Karkowski 02f951aa7d # 1.3.13
- Fixes:
    - `cli/runNopeBackend`: Fixing parameter `preventVarifiedNames` no works correctly.

# 1.3.14
  - Fixes:
    - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui`
    - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui`

# 1.4.0
  - Modified:
    - asyncified all ui-related services.
    - Adapted ui-defintion of functions:
      - `autoGenBySchema` Helper to enable auto generating a configuration
      - `requiresProviderForRendering` Flag to indicate, that rendering the service configuration requires a provider itself. This for instance is the case, if some needs to be called.
    - `types/ui/editor/IServiceEditPage.ts`: Asnycify the Calls
    - `types/ui/editor/render.callbacks.ts`: Asnycify the Calls

# 1.4.1
  - Modified:
    - loading all files related to `*.functions.js`
      - Adapted the following files to implement that behavior:
        - `getCentralDecoratedContainer` in `lib\decorators\container.ts` -> now provides services as Map
        - `exportFunctionAsNopeService` in `lib\decorators\functionDecorators.ts` to work with the map.
        - `loadFunctions` in `lib\loader\loadPackages.ts` to match the interface of `loadPackages` and add the functions to the package-loader.
        - added the function `addDecoratedElements` in the package-loader and the interface.
2022-09-20 20:54:53 +02:00

49 lines
1.1 KiB
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-07-27 15:45:00
* @modify date 2021-07-27 15:45:00
* @desc [description]
*/
import { start } from "repl";
import main from "./runNopeBackend";
/**
* Starts an interactive console with the loaded dispatcher.
*/
export async function repl(
additionalArguments: {
help: string;
type: "string" | "number";
name: string | string;
defaultValue?: any;
}[] = []
) {
const loader = await main(
additionalArguments,
{
// skipLoadingConfig: true
},
true
);
const interactiveConsole = start({});
// Assing the context
interactiveConsole.context.dispatcher = loader.dispatcher;
interactiveConsole.context.loader = loader;
interactiveConsole.context.nope = require("../index.nodejs");
// Promise, that will be finished on exiting the interactive console.
const promise = new Promise((resolve) => {
interactiveConsole.once("exit", resolve);
});
await promise;
await loader.dispatcher.dispose();
}
// If requested As Main => Perform the Operation.
if (require.main === module) {
repl().catch(console.error);
}