@adonisjs/repl 4.0.0-0 → 4.0.0-10
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.
- package/LICENSE.md +9 -9
- package/README.md +3 -6
- package/build/index.d.ts +0 -2
- package/build/index.js +302 -2
- package/build/index.js.map +1 -0
- package/build/src/repl.d.ts +42 -7
- package/build/src/types.d.ts +20 -0
- package/package.json +46 -71
- package/build/commands/adonis_repl.d.ts +0 -9
- package/build/commands/adonis_repl.d.ts.map +0 -1
- package/build/commands/adonis_repl.js +0 -17
- package/build/commands/commands.json +0 -1
- package/build/commands/main.js +0 -36
- package/build/index.d.ts.map +0 -1
- package/build/providers/repl_provider.d.ts +0 -8
- package/build/providers/repl_provider.d.ts.map +0 -1
- package/build/providers/repl_provider.js +0 -40
- package/build/src/adonis_bindings.d.ts +0 -4
- package/build/src/adonis_bindings.d.ts.map +0 -1
- package/build/src/adonis_bindings.js +0 -26
- package/build/src/colorizer.d.ts +0 -5
- package/build/src/colorizer.d.ts.map +0 -1
- package/build/src/colorizer.js +0 -39
- package/build/src/repl.d.ts.map +0 -1
- package/build/src/repl.js +0 -214
- package/build/src/types/extended.d.ts +0 -7
- package/build/src/types/extended.d.ts.map +0 -1
- package/build/src/types/extended.js +0 -1
- package/build/src/types/main.d.ts +0 -11
- package/build/src/types/main.d.ts.map +0 -1
- package/build/src/types/main.js +0 -1
- package/build/src/utils.d.ts +0 -2
- package/build/src/utils.d.ts.map +0 -1
- package/build/src/utils.js +0 -11
- package/commands/adonis_repl.ts +0 -38
- package/index.ts +0 -12
- package/providers/repl_provider.ts +0 -61
- package/src/adonis_bindings.ts +0 -63
- package/src/colorizer.ts +0 -62
- package/src/repl.ts +0 -423
- package/src/types/extended.ts +0 -16
- package/src/types/main.ts +0 -33
- package/src/utils.ts +0 -14
package/LICENSE.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright 2022 Harminder Virk, contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
# The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Harminder Virk, contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<br />
|
|
4
4
|
|
|
5
|
-
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
5
|
+
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
REPL for AdonisJS applications. Syntax highlighting, bracket matching, ESM and TypeScript support out of the box.
|
|
@@ -21,8 +21,8 @@ In order to ensure that the AdonisJS community is welcoming to all, please revie
|
|
|
21
21
|
## License
|
|
22
22
|
AdonisJS Repl is open-sourced software licensed under the [MIT license](LICENSE.md).
|
|
23
23
|
|
|
24
|
-
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/repl/
|
|
25
|
-
[gh-workflow-url]: https://github.com/adonisjs/repl/actions/workflows/
|
|
24
|
+
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/repl/checks.yml?style=for-the-badge
|
|
25
|
+
[gh-workflow-url]: https://github.com/adonisjs/repl/actions/workflows/checks.yml "Github action"
|
|
26
26
|
|
|
27
27
|
[npm-image]: https://img.shields.io/npm/v/@adonisjs/repl/latest.svg?style=for-the-badge&logo=npm
|
|
28
28
|
[npm-url]: https://www.npmjs.com/package/@adonisjs/repl/v/latest "npm"
|
|
@@ -31,6 +31,3 @@ AdonisJS Repl is open-sourced software licensed under the [MIT license](LICENSE.
|
|
|
31
31
|
|
|
32
32
|
[license-url]: LICENSE.md
|
|
33
33
|
[license-image]: https://img.shields.io/github/license/adonisjs/repl?style=for-the-badge
|
|
34
|
-
|
|
35
|
-
[snyk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/repl?label=Snyk%20Vulnerabilities&style=for-the-badge
|
|
36
|
-
[snyk-url]: https://snyk.io/test/github/adonisjs/repl?targetFile=package.json "snyk"
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,2 +1,302 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/repl.ts
|
|
2
|
+
import stringWidth from "string-width";
|
|
3
|
+
import useColors from "@poppinss/colors";
|
|
4
|
+
import { inspect, promisify as utilPromisify } from "node:util";
|
|
5
|
+
import { Recoverable, start as startRepl } from "node:repl";
|
|
6
|
+
var GLOBAL_NODE_PROPERTIES = [
|
|
7
|
+
"performance",
|
|
8
|
+
"global",
|
|
9
|
+
"clearInterval",
|
|
10
|
+
"clearTimeout",
|
|
11
|
+
"setInterval",
|
|
12
|
+
"setTimeout",
|
|
13
|
+
"queueMicrotask",
|
|
14
|
+
"clearImmediate",
|
|
15
|
+
"setImmediate",
|
|
16
|
+
"structuredClone",
|
|
17
|
+
"atob",
|
|
18
|
+
"btoa",
|
|
19
|
+
"fetch",
|
|
20
|
+
"crypto",
|
|
21
|
+
"navigator"
|
|
22
|
+
];
|
|
23
|
+
var TS_UTILS_HELPERS = [
|
|
24
|
+
"__extends",
|
|
25
|
+
"__assign",
|
|
26
|
+
"__rest",
|
|
27
|
+
"__decorate",
|
|
28
|
+
"__param",
|
|
29
|
+
"__esDecorate",
|
|
30
|
+
"__runInitializers",
|
|
31
|
+
"__propKey",
|
|
32
|
+
"__setFunctionName",
|
|
33
|
+
"__metadata",
|
|
34
|
+
"__awaiter",
|
|
35
|
+
"__generator",
|
|
36
|
+
"__exportStar",
|
|
37
|
+
"__createBinding",
|
|
38
|
+
"__values",
|
|
39
|
+
"__read",
|
|
40
|
+
"__spread",
|
|
41
|
+
"__spreadArrays",
|
|
42
|
+
"__spreadArray",
|
|
43
|
+
"__await",
|
|
44
|
+
"__asyncGenerator",
|
|
45
|
+
"__asyncDelegator",
|
|
46
|
+
"__asyncValues",
|
|
47
|
+
"__makeTemplateObject",
|
|
48
|
+
"__importStar",
|
|
49
|
+
"__importDefault",
|
|
50
|
+
"__classPrivateFieldGet",
|
|
51
|
+
"__classPrivateFieldSet",
|
|
52
|
+
"__classPrivateFieldIn"
|
|
53
|
+
];
|
|
54
|
+
var Repl = class {
|
|
55
|
+
#replOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Length of the longest custom method name. We need to show a
|
|
58
|
+
* symmetric view of custom methods and their description
|
|
59
|
+
*/
|
|
60
|
+
#longestCustomMethodName = 0;
|
|
61
|
+
/**
|
|
62
|
+
* Reference to the original `eval` method of the repl server.
|
|
63
|
+
* Since we are monkey patching it, we need a reference to it
|
|
64
|
+
* to call it after our custom logic
|
|
65
|
+
*/
|
|
66
|
+
#originalEval;
|
|
67
|
+
/**
|
|
68
|
+
* Compiler that will transform the user input just
|
|
69
|
+
* before evaluation
|
|
70
|
+
*/
|
|
71
|
+
#compiler;
|
|
72
|
+
/**
|
|
73
|
+
* Path to the history file
|
|
74
|
+
*/
|
|
75
|
+
#historyFilePath;
|
|
76
|
+
/**
|
|
77
|
+
* Set of registered ready callbacks
|
|
78
|
+
*/
|
|
79
|
+
#onReadyCallbacks = [];
|
|
80
|
+
/**
|
|
81
|
+
* A set of registered custom methods
|
|
82
|
+
*/
|
|
83
|
+
#customMethods = {};
|
|
84
|
+
/**
|
|
85
|
+
* Colors reference
|
|
86
|
+
*/
|
|
87
|
+
colors = useColors.ansi();
|
|
88
|
+
/**
|
|
89
|
+
* Reference to the repl server. Available after the `start` method
|
|
90
|
+
* is invoked
|
|
91
|
+
*/
|
|
92
|
+
server;
|
|
93
|
+
constructor(options) {
|
|
94
|
+
const { compiler, historyFilePath, ...rest } = options || {};
|
|
95
|
+
this.#compiler = compiler;
|
|
96
|
+
this.#historyFilePath = historyFilePath;
|
|
97
|
+
this.#replOptions = rest;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Registering custom methods with the server context by wrapping
|
|
101
|
+
* them inside a function and passes the REPL server instance
|
|
102
|
+
* to the method
|
|
103
|
+
*/
|
|
104
|
+
#registerCustomMethodWithContext(name) {
|
|
105
|
+
const customMethod = this.#customMethods[name];
|
|
106
|
+
if (!customMethod) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const handler = (...args) => customMethod.handler(this, ...args);
|
|
110
|
+
Object.defineProperty(handler, "name", { value: customMethod.handler.name });
|
|
111
|
+
this.server.context[name] = handler;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Setup context with default globals
|
|
115
|
+
*/
|
|
116
|
+
#setupContext() {
|
|
117
|
+
this.addMethod(
|
|
118
|
+
"clear",
|
|
119
|
+
function clear(repl, key) {
|
|
120
|
+
if (!key) {
|
|
121
|
+
console.log(repl.colors.red("Define a property name to remove from the context"));
|
|
122
|
+
} else {
|
|
123
|
+
delete repl.server.context[key];
|
|
124
|
+
}
|
|
125
|
+
repl.server.displayPrompt();
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
description: "Clear a property from the REPL context",
|
|
129
|
+
usage: `clear ${this.colors.gray("(propertyName)")}`
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
this.addMethod(
|
|
133
|
+
"p",
|
|
134
|
+
function promisify(_, fn) {
|
|
135
|
+
return utilPromisify(fn);
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
description: 'Promisify a function. Similar to Node.js "util.promisify"',
|
|
139
|
+
usage: `p ${this.colors.gray("(function)")}`
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
Object.keys(this.#customMethods).forEach((name) => {
|
|
143
|
+
this.#registerCustomMethodWithContext(name);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Find if the error is recoverable or not
|
|
148
|
+
*/
|
|
149
|
+
#isRecoverableError(error) {
|
|
150
|
+
return /^(Unexpected end of input|Unexpected token|' expected)/.test(error.message);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Custom eval method to execute the user code
|
|
154
|
+
*
|
|
155
|
+
* Basically we are monkey patching the original eval method, because
|
|
156
|
+
* we want to:
|
|
157
|
+
* - Compile the user code before executing it
|
|
158
|
+
* - And also benefit from the original eval method that supports
|
|
159
|
+
* cool features like top level await
|
|
160
|
+
*/
|
|
161
|
+
#eval(code, context, filename, callback) {
|
|
162
|
+
try {
|
|
163
|
+
const compiled = this.#compiler ? this.#compiler.compile(code, filename) : code;
|
|
164
|
+
return this.#originalEval(compiled, context, filename, callback);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (this.#isRecoverableError(error)) {
|
|
167
|
+
callback(new Recoverable(error), null);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
callback(error, null);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Setup history file
|
|
175
|
+
*/
|
|
176
|
+
#setupHistory() {
|
|
177
|
+
if (!this.#historyFilePath) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.server.setupHistory(this.#historyFilePath, (error) => {
|
|
181
|
+
if (!error) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
console.log(this.colors.red("Unable to write to the history file. Exiting"));
|
|
185
|
+
console.error(error);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Prints the help for the context properties
|
|
191
|
+
*/
|
|
192
|
+
#printContextHelp() {
|
|
193
|
+
console.log("");
|
|
194
|
+
console.log(this.colors.green("CONTEXT PROPERTIES/METHODS:"));
|
|
195
|
+
const context = Object.keys(this.server.context).reduce(
|
|
196
|
+
(result, key) => {
|
|
197
|
+
if (!this.#customMethods[key] && !GLOBAL_NODE_PROPERTIES.includes(key) && !TS_UTILS_HELPERS.includes(key)) {
|
|
198
|
+
result[key] = this.server.context[key];
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
},
|
|
202
|
+
{}
|
|
203
|
+
);
|
|
204
|
+
console.log(inspect(context, false, 1, true));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Prints the help for the custom methods
|
|
208
|
+
*/
|
|
209
|
+
#printCustomMethodsHelp() {
|
|
210
|
+
console.log("");
|
|
211
|
+
console.log(this.colors.green("GLOBAL METHODS:"));
|
|
212
|
+
Object.keys(this.#customMethods).forEach((method) => {
|
|
213
|
+
const { options } = this.#customMethods[method];
|
|
214
|
+
const usage = this.colors.yellow(options.usage || method);
|
|
215
|
+
const spaces = " ".repeat(this.#longestCustomMethodName - options.width + 2);
|
|
216
|
+
const description = this.colors.dim(options.description || "");
|
|
217
|
+
console.log(`${usage}${spaces}${description}`);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Prints the context to the console
|
|
222
|
+
*/
|
|
223
|
+
#ls() {
|
|
224
|
+
this.#printCustomMethodsHelp();
|
|
225
|
+
this.#printContextHelp();
|
|
226
|
+
this.server.displayPrompt();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Notify by writing to the console
|
|
230
|
+
*/
|
|
231
|
+
notify(message) {
|
|
232
|
+
console.log(this.colors.yellow().italic(message));
|
|
233
|
+
if (this.server) {
|
|
234
|
+
this.server.displayPrompt();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Register a callback to be invoked once the server is ready
|
|
239
|
+
*/
|
|
240
|
+
ready(callback) {
|
|
241
|
+
this.#onReadyCallbacks.push(callback);
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Register a custom loader function to be added to the context
|
|
246
|
+
*/
|
|
247
|
+
addMethod(name, handler, options) {
|
|
248
|
+
const width = stringWidth(options?.usage || name);
|
|
249
|
+
if (width > this.#longestCustomMethodName) {
|
|
250
|
+
this.#longestCustomMethodName = width;
|
|
251
|
+
}
|
|
252
|
+
this.#customMethods[name] = { handler, options: Object.assign({ width }, options) };
|
|
253
|
+
if (this.server) {
|
|
254
|
+
this.#registerCustomMethodWithContext(name);
|
|
255
|
+
}
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Returns the collection of registered methods
|
|
260
|
+
*/
|
|
261
|
+
getMethods() {
|
|
262
|
+
return this.#customMethods;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Register a compiler. Make sure register the compiler before
|
|
266
|
+
* calling the start method
|
|
267
|
+
*/
|
|
268
|
+
useCompiler(compiler) {
|
|
269
|
+
this.#compiler = compiler;
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Start the REPL server
|
|
274
|
+
*/
|
|
275
|
+
start() {
|
|
276
|
+
console.log("");
|
|
277
|
+
this.notify('Type ".ls" to a view list of available context methods/properties');
|
|
278
|
+
this.server = startRepl({
|
|
279
|
+
prompt: `> ${this.#compiler?.supportsTypescript ? "(ts) " : "(js) "}`,
|
|
280
|
+
input: process.stdin,
|
|
281
|
+
output: process.stdout,
|
|
282
|
+
terminal: process.stdout.isTTY && !Number.parseInt(process.env.NODE_NO_READLINE, 10),
|
|
283
|
+
useGlobal: true,
|
|
284
|
+
...this.#replOptions
|
|
285
|
+
});
|
|
286
|
+
this.server.defineCommand("ls", {
|
|
287
|
+
help: "View list of available context methods/properties",
|
|
288
|
+
action: this.#ls.bind(this)
|
|
289
|
+
});
|
|
290
|
+
this.#setupContext();
|
|
291
|
+
this.#setupHistory();
|
|
292
|
+
this.#originalEval = this.server.eval;
|
|
293
|
+
this.server.eval = this.#eval.bind(this);
|
|
294
|
+
this.server.displayPrompt();
|
|
295
|
+
this.#onReadyCallbacks.forEach((callback) => callback(this));
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
export {
|
|
300
|
+
Repl
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/repl.ts"],"sourcesContent":["/*\n * @adonisjs/repl\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport stringWidth from 'string-width'\nimport useColors from '@poppinss/colors'\nimport type { Colors } from '@poppinss/colors/types'\nimport { inspect, promisify as utilPromisify } from 'node:util'\nimport { type REPLServer, Recoverable, type ReplOptions, start as startRepl } from 'node:repl'\n\nimport type { MethodCallback, MethodOptions, Compiler } from './types.js'\n\n/**\n * List of node global properties to remove from the\n * ls inspect\n */\nconst GLOBAL_NODE_PROPERTIES = [\n 'performance',\n 'global',\n 'clearInterval',\n 'clearTimeout',\n 'setInterval',\n 'setTimeout',\n 'queueMicrotask',\n 'clearImmediate',\n 'setImmediate',\n 'structuredClone',\n 'atob',\n 'btoa',\n 'fetch',\n 'crypto',\n 'navigator',\n]\n\nconst TS_UTILS_HELPERS = [\n '__extends',\n '__assign',\n '__rest',\n '__decorate',\n '__param',\n '__esDecorate',\n '__runInitializers',\n '__propKey',\n '__setFunctionName',\n '__metadata',\n '__awaiter',\n '__generator',\n '__exportStar',\n '__createBinding',\n '__values',\n '__read',\n '__spread',\n '__spreadArrays',\n '__spreadArray',\n '__await',\n '__asyncGenerator',\n '__asyncDelegator',\n '__asyncValues',\n '__makeTemplateObject',\n '__importStar',\n '__importDefault',\n '__classPrivateFieldGet',\n '__classPrivateFieldSet',\n '__classPrivateFieldIn',\n]\n\nexport class Repl {\n #replOptions: ReplOptions\n\n /**\n * Length of the longest custom method name. We need to show a\n * symmetric view of custom methods and their description\n */\n #longestCustomMethodName = 0\n\n /**\n * Reference to the original `eval` method of the repl server.\n * Since we are monkey patching it, we need a reference to it\n * to call it after our custom logic\n */\n #originalEval?: Function\n\n /**\n * Compiler that will transform the user input just\n * before evaluation\n */\n #compiler?: Compiler\n\n /**\n * Path to the history file\n */\n #historyFilePath?: string\n\n /**\n * Set of registered ready callbacks\n */\n #onReadyCallbacks: ((repl: Repl) => void)[] = []\n\n /**\n * A set of registered custom methods\n */\n #customMethods: {\n [name: string]: { handler: MethodCallback; options: MethodOptions & { width: number } }\n } = {}\n\n /**\n * Colors reference\n */\n colors: Colors = useColors.ansi()\n\n /**\n * Reference to the repl server. Available after the `start` method\n * is invoked\n */\n server?: REPLServer\n\n constructor(options?: { compiler?: Compiler; historyFilePath?: string } & ReplOptions) {\n const { compiler, historyFilePath, ...rest } = options || {}\n this.#compiler = compiler\n this.#historyFilePath = historyFilePath\n this.#replOptions = rest\n }\n\n /**\n * Registering custom methods with the server context by wrapping\n * them inside a function and passes the REPL server instance\n * to the method\n */\n #registerCustomMethodWithContext(name: string) {\n const customMethod = this.#customMethods[name]\n if (!customMethod) {\n return\n }\n\n /**\n * Wrap handler\n */\n const handler = (...args: any[]) => customMethod.handler(this, ...args)\n\n /**\n * Re-define the function name to be more description\n */\n Object.defineProperty(handler, 'name', { value: customMethod.handler.name })\n\n /**\n * Register with the context\n */\n this.server!.context[name] = handler\n }\n\n /**\n * Setup context with default globals\n */\n #setupContext() {\n /**\n * Register \"clear\" method\n */\n this.addMethod(\n 'clear',\n function clear(repl: Repl, key: string) {\n if (!key) {\n console.log(repl.colors.red('Define a property name to remove from the context'))\n } else {\n delete repl.server!.context[key]\n }\n repl.server!.displayPrompt()\n },\n {\n description: 'Clear a property from the REPL context',\n usage: `clear ${this.colors.gray('(propertyName)')}`,\n }\n )\n\n /**\n * Register \"p\" method\n */\n this.addMethod(\n 'p',\n function promisify(_: Repl, fn: Function) {\n return utilPromisify(fn)\n },\n {\n description: 'Promisify a function. Similar to Node.js \"util.promisify\"',\n usage: `p ${this.colors.gray('(function)')}`,\n }\n )\n\n /**\n * Register all custom methods with the context\n */\n Object.keys(this.#customMethods).forEach((name) => {\n this.#registerCustomMethodWithContext(name)\n })\n }\n\n /**\n * Find if the error is recoverable or not\n */\n #isRecoverableError(error: any) {\n return /^(Unexpected end of input|Unexpected token|' expected)/.test(error.message)\n }\n\n /**\n * Custom eval method to execute the user code\n *\n * Basically we are monkey patching the original eval method, because\n * we want to:\n * - Compile the user code before executing it\n * - And also benefit from the original eval method that supports\n * cool features like top level await\n */\n #eval(\n code: string,\n context: any,\n filename: string,\n callback: (err: Error | null, result?: any) => void\n ) {\n try {\n const compiled = this.#compiler ? this.#compiler!.compile(code, filename) : code\n return this.#originalEval!(compiled, context, filename, callback)\n } catch (error) {\n if (this.#isRecoverableError(error)) {\n callback(new Recoverable(error), null)\n return\n }\n\n callback(error, null)\n }\n }\n\n /**\n * Setup history file\n */\n #setupHistory() {\n if (!this.#historyFilePath) {\n return\n }\n\n this.server!.setupHistory(this.#historyFilePath, (error) => {\n if (!error) {\n return\n }\n\n console.log(this.colors.red('Unable to write to the history file. Exiting'))\n console.error(error)\n process.exit(1)\n })\n }\n\n /**\n * Prints the help for the context properties\n */\n #printContextHelp() {\n /**\n * Print context properties\n */\n console.log('')\n console.log(this.colors.green('CONTEXT PROPERTIES/METHODS:'))\n\n const context = Object.keys(this.server!.context).reduce(\n (result, key) => {\n if (\n !this.#customMethods[key] &&\n !GLOBAL_NODE_PROPERTIES.includes(key) &&\n !TS_UTILS_HELPERS.includes(key)\n ) {\n result[key] = this.server!.context[key]\n }\n\n return result\n },\n {} as Record<string, any>\n )\n\n console.log(inspect(context, false, 1, true))\n }\n\n /**\n * Prints the help for the custom methods\n */\n #printCustomMethodsHelp() {\n /**\n * Print loader methods\n */\n console.log('')\n console.log(this.colors.green('GLOBAL METHODS:'))\n\n Object.keys(this.#customMethods).forEach((method) => {\n const { options } = this.#customMethods[method]\n\n const usage = this.colors.yellow(options.usage || method)\n const spaces = ' '.repeat(this.#longestCustomMethodName - options.width + 2)\n const description = this.colors.dim(options.description || '')\n\n console.log(`${usage}${spaces}${description}`)\n })\n }\n\n /**\n * Prints the context to the console\n */\n #ls() {\n this.#printCustomMethodsHelp()\n this.#printContextHelp()\n this.server!.displayPrompt()\n }\n\n /**\n * Notify by writing to the console\n */\n notify(message: string) {\n console.log(this.colors.yellow().italic(message))\n if (this.server) {\n this.server.displayPrompt()\n }\n }\n\n /**\n * Register a callback to be invoked once the server is ready\n */\n ready(callback: (repl: Repl) => void): this {\n this.#onReadyCallbacks.push(callback)\n return this\n }\n\n /**\n * Register a custom loader function to be added to the context\n */\n addMethod(name: string, handler: MethodCallback, options?: MethodOptions): this {\n const width = stringWidth(options?.usage || name)\n if (width > this.#longestCustomMethodName) {\n this.#longestCustomMethodName = width\n }\n\n this.#customMethods[name] = { handler, options: Object.assign({ width }, options) }\n\n /**\n * Register method right away when server has been started\n */\n if (this.server) {\n this.#registerCustomMethodWithContext(name)\n }\n\n return this\n }\n\n /**\n * Returns the collection of registered methods\n */\n getMethods() {\n return this.#customMethods\n }\n\n /**\n * Register a compiler. Make sure register the compiler before\n * calling the start method\n */\n useCompiler(compiler: Compiler): this {\n this.#compiler = compiler\n return this\n }\n\n /**\n * Start the REPL server\n */\n start() {\n console.log('')\n this.notify('Type \".ls\" to a view list of available context methods/properties')\n\n this.server = startRepl({\n prompt: `> ${this.#compiler?.supportsTypescript ? '(ts) ' : '(js) '}`,\n input: process.stdin,\n output: process.stdout,\n terminal: process.stdout.isTTY && !Number.parseInt(process.env.NODE_NO_READLINE!, 10),\n useGlobal: true,\n ...this.#replOptions,\n })\n\n /**\n * Define the `ls` command\n */\n this.server!.defineCommand('ls', {\n help: 'View list of available context methods/properties',\n action: this.#ls.bind(this),\n })\n\n /**\n * Setup context and history\n */\n this.#setupContext()\n this.#setupHistory()\n\n /**\n * Monkey patch the eval method\n */\n this.#originalEval = this.server.eval\n // @ts-ignore\n this.server.eval = this.#eval.bind(this)\n\n /**\n * Display prompt\n */\n this.server.displayPrompt()\n\n /**\n * Execute onReady callbacks\n */\n this.#onReadyCallbacks.forEach((callback) => callback(this))\n\n return this\n }\n}\n"],"mappings":";AASA,OAAO,iBAAiB;AACxB,OAAO,eAAe;AAEtB,SAAS,SAAS,aAAa,qBAAqB;AACpD,SAA0B,aAA+B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AO;AAAA,MACnE,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ,OAAO,SAAS,CAAC,OAAO,SAAS,QAAQ,IAAI,kBAAmB,EAAE;AAAA,MACpF,WAAW;AAAA,MACX,GAAG,KAAK;AAAA,IACV,CAAC;AAKD,SAAK,OAAQ,cAAc,MAAM;AAAA,MAC/B,MAAM;AAAA,MACN,QAAQ,KAAK,IAAI,KAAK,IAAI;AAAA,IAC5B,CAAC;AAKD,SAAK,cAAc;AACnB,SAAK,cAAc;AAKnB,SAAK,gBAAgB,KAAK,OAAO;AAEjC,SAAK,OAAO,OAAO,KAAK,MAAM,KAAK,IAAI;AAKvC,SAAK,OAAO,cAAc;AAK1B,SAAK,kBAAkB,QAAQ,CAAC,aAAa,SAAS,IAAI,CAAC;AAE3D,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/build/src/repl.d.ts
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Colors } from '@poppinss/colors/types';
|
|
3
|
+
import { type REPLServer, type ReplOptions } from 'node:repl';
|
|
4
|
+
import type { MethodCallback, MethodOptions, Compiler } from './types.js';
|
|
4
5
|
export declare class Repl {
|
|
5
6
|
#private;
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Colors reference
|
|
9
|
+
*/
|
|
10
|
+
colors: Colors;
|
|
11
|
+
/**
|
|
12
|
+
* Reference to the repl server. Available after the `start` method
|
|
13
|
+
* is invoked
|
|
14
|
+
*/
|
|
7
15
|
server?: REPLServer;
|
|
8
16
|
constructor(options?: {
|
|
9
17
|
compiler?: Compiler;
|
|
10
18
|
historyFilePath?: string;
|
|
11
|
-
});
|
|
19
|
+
} & ReplOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Notify by writing to the console
|
|
22
|
+
*/
|
|
12
23
|
notify(message: string): void;
|
|
13
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Register a callback to be invoked once the server is ready
|
|
26
|
+
*/
|
|
14
27
|
ready(callback: (repl: Repl) => void): this;
|
|
15
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Register a custom loader function to be added to the context
|
|
30
|
+
*/
|
|
31
|
+
addMethod(name: string, handler: MethodCallback, options?: MethodOptions): this;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the collection of registered methods
|
|
34
|
+
*/
|
|
35
|
+
getMethods(): {
|
|
36
|
+
[name: string]: {
|
|
37
|
+
handler: MethodCallback;
|
|
38
|
+
options: MethodOptions & {
|
|
39
|
+
width: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Register a compiler. Make sure register the compiler before
|
|
45
|
+
* calling the start method
|
|
46
|
+
*/
|
|
47
|
+
useCompiler(compiler: Compiler): this;
|
|
48
|
+
/**
|
|
49
|
+
* Start the REPL server
|
|
50
|
+
*/
|
|
51
|
+
start(): this;
|
|
16
52
|
}
|
|
17
|
-
//# sourceMappingURL=repl.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Repl } from './repl.js';
|
|
2
|
+
/**
|
|
3
|
+
* Custom method callback function
|
|
4
|
+
*/
|
|
5
|
+
export type MethodCallback = (repl: Repl, ...args: any[]) => any;
|
|
6
|
+
/**
|
|
7
|
+
* Options that can be set when defining a custom method
|
|
8
|
+
*/
|
|
9
|
+
export type MethodOptions = {
|
|
10
|
+
description?: string;
|
|
11
|
+
usage?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Shape of the Compiler that must be passed to the
|
|
15
|
+
* repl constructor
|
|
16
|
+
*/
|
|
17
|
+
export type Compiler = {
|
|
18
|
+
compile: (code: string, fileName: string) => string;
|
|
19
|
+
supportsTypescript: boolean;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,97 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/repl",
|
|
3
3
|
"description": "REPL for AdonisJS",
|
|
4
|
-
"version": "4.0.0-
|
|
4
|
+
"version": "4.0.0-10",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18.16.0"
|
|
7
|
+
},
|
|
5
8
|
"main": "build/index.js",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"src",
|
|
12
|
-
"services",
|
|
13
|
-
"providers",
|
|
14
|
-
"factories",
|
|
15
|
-
"build/configure.js",
|
|
16
|
-
"build/configure.d.ts",
|
|
17
|
-
"build/configure.d.ts.map",
|
|
18
|
-
"build/index.js",
|
|
19
|
-
"build/index.d.ts",
|
|
20
|
-
"build/index.d.ts.map",
|
|
21
|
-
"build/src",
|
|
22
|
-
"build/services",
|
|
23
|
-
"build/providers",
|
|
24
|
-
"build/commands",
|
|
25
|
-
"build/factories",
|
|
26
|
-
"build/stubs",
|
|
27
|
-
"build/index.d.ts",
|
|
28
|
-
"build/index.d.ts.map",
|
|
29
|
-
"build/index.js"
|
|
11
|
+
"build",
|
|
12
|
+
"!build/bin",
|
|
13
|
+
"!build/examples"
|
|
30
14
|
],
|
|
31
15
|
"exports": {
|
|
32
16
|
".": "./build/index.js",
|
|
33
|
-
"./
|
|
34
|
-
"./commands/*": "./build/commands/*.js",
|
|
35
|
-
"./providers/repl_provider": "./build/providers/repl_provider.js",
|
|
36
|
-
"./services/main": "./build/services/main.js",
|
|
37
|
-
"./types": "./build/src/types/main.js"
|
|
17
|
+
"./types": "./build/src/types.js"
|
|
38
18
|
},
|
|
39
19
|
"scripts": {
|
|
40
20
|
"pretest": "npm run lint",
|
|
41
21
|
"test": "c8 npm run quick:test",
|
|
42
22
|
"lint": "eslint . --ext=.ts",
|
|
43
23
|
"clean": "del-cli build",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"precompile": "npm run lint && npm run clean",
|
|
26
|
+
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
|
|
46
27
|
"build": "npm run compile",
|
|
47
|
-
"release": "np
|
|
28
|
+
"release": "np",
|
|
48
29
|
"version": "npm run build",
|
|
49
30
|
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/repl",
|
|
50
|
-
"quick:test": "node --loader=ts-node/esm bin/test.ts",
|
|
31
|
+
"quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts",
|
|
51
32
|
"format": "prettier --write .",
|
|
52
|
-
"prepublishOnly": "npm run build"
|
|
53
|
-
"index:commands": "adonis-kit index build/commands"
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
54
34
|
},
|
|
55
35
|
"devDependencies": {
|
|
56
|
-
"@adonisjs/
|
|
57
|
-
"@adonisjs/
|
|
58
|
-
"@adonisjs/
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@japa/
|
|
62
|
-
"@japa/
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"copyfiles": "^2.4.1",
|
|
69
|
-
"del-cli": "^5.0.0",
|
|
70
|
-
"eslint": "^8.43.0",
|
|
36
|
+
"@adonisjs/eslint-config": "^1.2.0",
|
|
37
|
+
"@adonisjs/prettier-config": "^1.2.0",
|
|
38
|
+
"@adonisjs/tsconfig": "^1.2.0",
|
|
39
|
+
"@commitlint/cli": "^18.4.3",
|
|
40
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
41
|
+
"@japa/assert": "^2.1.0",
|
|
42
|
+
"@japa/runner": "^3.1.1",
|
|
43
|
+
"@swc/core": "^1.3.101",
|
|
44
|
+
"@types/node": "^20.10.5",
|
|
45
|
+
"c8": "^8.0.1",
|
|
46
|
+
"del-cli": "^5.1.0",
|
|
47
|
+
"eslint": "^8.56.0",
|
|
71
48
|
"github-label-sync": "^2.3.1",
|
|
72
49
|
"husky": "^8.0.3",
|
|
73
|
-
"np": "^
|
|
74
|
-
"prettier": "^
|
|
75
|
-
"ts-node": "^10.9.
|
|
76
|
-
"
|
|
50
|
+
"np": "^9.2.0",
|
|
51
|
+
"prettier": "^3.1.1",
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
53
|
+
"tsup": "^8.0.1",
|
|
54
|
+
"typescript": "^5.3.3"
|
|
77
55
|
},
|
|
78
56
|
"dependencies": {
|
|
79
|
-
"@poppinss/colors": "4.1.
|
|
80
|
-
"
|
|
81
|
-
"pretty-repl": "^4.0.0",
|
|
82
|
-
"string-width": "^6.1.0"
|
|
83
|
-
},
|
|
84
|
-
"peerDependencies": {
|
|
85
|
-
"@adonisjs/core": "^6.1.5-4",
|
|
86
|
-
"ts-node": "^10.4.0"
|
|
87
|
-
},
|
|
88
|
-
"peerDependenciesMeta": {
|
|
89
|
-
"@adonisjs/core": {
|
|
90
|
-
"optional": true
|
|
91
|
-
},
|
|
92
|
-
"ts-node": {
|
|
93
|
-
"optional": true
|
|
94
|
-
}
|
|
57
|
+
"@poppinss/colors": "^4.1.2",
|
|
58
|
+
"string-width": "^7.0.0"
|
|
95
59
|
},
|
|
96
60
|
"author": "virk,julien-r44,adonisjs",
|
|
97
61
|
"license": "MIT",
|
|
@@ -109,7 +73,7 @@
|
|
|
109
73
|
"node-repl"
|
|
110
74
|
],
|
|
111
75
|
"eslintConfig": {
|
|
112
|
-
"extends": "@adonisjs/eslint-config/
|
|
76
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
113
77
|
},
|
|
114
78
|
"prettier": "@adonisjs/prettier-config",
|
|
115
79
|
"commitlint": {
|
|
@@ -119,7 +83,7 @@
|
|
|
119
83
|
},
|
|
120
84
|
"publishConfig": {
|
|
121
85
|
"access": "public",
|
|
122
|
-
"tag": "
|
|
86
|
+
"tag": "next"
|
|
123
87
|
},
|
|
124
88
|
"np": {
|
|
125
89
|
"message": "chore(release): %s",
|
|
@@ -135,5 +99,16 @@
|
|
|
135
99
|
"exclude": [
|
|
136
100
|
"tests/**"
|
|
137
101
|
]
|
|
102
|
+
},
|
|
103
|
+
"tsup": {
|
|
104
|
+
"entry": [
|
|
105
|
+
"./index.ts"
|
|
106
|
+
],
|
|
107
|
+
"outDir": "./build",
|
|
108
|
+
"clean": true,
|
|
109
|
+
"format": "esm",
|
|
110
|
+
"dts": false,
|
|
111
|
+
"sourcemap": true,
|
|
112
|
+
"target": "esnext"
|
|
138
113
|
}
|
|
139
114
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
-
import { CommandOptions } from '@adonisjs/core/types/ace';
|
|
3
|
-
export default class ReplCommand extends BaseCommand {
|
|
4
|
-
static commandName: string;
|
|
5
|
-
static description: string;
|
|
6
|
-
static options: CommandOptions;
|
|
7
|
-
run(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=adonis_repl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adonis_repl.d.ts","sourceRoot":"","sources":["../../commands/adonis_repl.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,MAAM,CAAC,WAAW,SAAS;IAC3B,MAAM,CAAC,WAAW,SAA6B;IAE/C,MAAM,CAAC,OAAO,EAAE,cAAc,CAG7B;IAEK,GAAG;CAgBV"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
-
export default class ReplCommand extends BaseCommand {
|
|
3
|
-
static commandName = 'repl';
|
|
4
|
-
static description = 'Start a new REPL session';
|
|
5
|
-
static options = {
|
|
6
|
-
startApp: true,
|
|
7
|
-
staysAlive: true,
|
|
8
|
-
};
|
|
9
|
-
async run() {
|
|
10
|
-
this.app.container.resolving('router', (router) => router.commit());
|
|
11
|
-
const repl = await this.app.container.make('repl');
|
|
12
|
-
repl.start();
|
|
13
|
-
repl.server.on('exit', async () => {
|
|
14
|
-
await this.app.terminate();
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|