@adonisjs/repl 3.1.11 → 4.0.0-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.
package/package.json CHANGED
@@ -1,103 +1,65 @@
1
1
  {
2
2
  "name": "@adonisjs/repl",
3
- "version": "3.1.11",
4
3
  "description": "REPL for AdonisJS",
5
- "main": "build/providers/ReplProvider.js",
4
+ "version": "4.0.0-1",
5
+ "main": "build/index.js",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=18.16.0"
9
+ },
6
10
  "files": [
7
- "build/adonis-typings",
8
- "build/commands",
9
- "build/providers",
10
11
  "build/src",
11
- "build/standalone.d.ts",
12
- "build/standalone.js"
12
+ "build/factories",
13
+ "build/index.d.ts",
14
+ "build/index.js"
13
15
  ],
14
- "typings": "./build/adonis-typings/index.d.ts",
16
+ "exports": {
17
+ ".": "./build/index.js",
18
+ "./types": "./build/src/types/main.js"
19
+ },
15
20
  "scripts": {
16
- "mrm": "mrm --preset=@adonisjs/mrm-preset",
17
21
  "pretest": "npm run lint",
18
- "test": "node -r @adonisjs/require-ts/build/register ./bin/test.ts",
22
+ "test": "c8 npm run quick:test",
23
+ "lint": "eslint . --ext=.ts",
19
24
  "clean": "del-cli build",
25
+ "typecheck": "tsc --noEmit",
20
26
  "compile": "npm run lint && npm run clean && tsc",
21
27
  "build": "npm run compile",
22
- "prepublishOnly": "npm run build",
23
- "lint": "eslint . --ext=.ts",
24
- "format": "prettier --write .",
25
- "commit": "git-cz",
26
28
  "release": "np --message=\"chore(release): %s\"",
27
29
  "version": "npm run build",
28
- "sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json adonisjs/repl"
29
- },
30
- "keywords": [
31
- "adonisjs",
32
- "repl",
33
- "node-repl"
34
- ],
35
- "author": "virk,adonisjs",
36
- "license": "MIT",
37
- "peerDependencies": {
38
- "@adonisjs/core": "^5.1.0"
30
+ "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/repl",
31
+ "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts",
32
+ "format": "prettier --write .",
33
+ "prepublishOnly": "npm run build"
39
34
  },
40
35
  "devDependencies": {
41
- "@adonisjs/core": "^5.8.2",
42
- "@adonisjs/mrm-preset": "^5.0.3",
43
- "@adonisjs/require-ts": "^2.0.12",
44
- "@japa/assert": "^1.3.4",
45
- "@japa/run-failed-tests": "^1.0.7",
46
- "@japa/runner": "^2.0.8",
47
- "@japa/spec-reporter": "^1.1.12",
48
- "@poppinss/dev-utils": "^2.0.3",
49
- "@types/node": "^17.0.35",
50
- "commitizen": "^4.2.4",
51
- "cz-conventional-changelog": "^3.3.0",
52
- "del-cli": "^4.0.1",
53
- "doctoc": "^2.2.0",
54
- "eslint": "^8.16.0",
55
- "eslint-config-prettier": "^8.5.0",
56
- "eslint-plugin-adonis": "^2.1.0",
57
- "eslint-plugin-prettier": "^4.0.0",
58
- "github-label-sync": "^2.2.0",
59
- "husky": "^8.0.1",
60
- "mrm": "^4.0.0",
61
- "np": "^7.6.1",
62
- "prettier": "^2.6.2",
63
- "typescript": "^4.6.4"
64
- },
65
- "husky": {
66
- "hooks": {
67
- "commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
68
- }
69
- },
70
- "nyc": {
71
- "exclude": [
72
- "test"
73
- ],
74
- "extension": [
75
- ".ts"
76
- ]
77
- },
78
- "config": {
79
- "commitizen": {
80
- "path": "cz-conventional-changelog"
81
- }
82
- },
83
- "np": {
84
- "contents": ".",
85
- "anyBranch": false
86
- },
87
- "publishConfig": {
88
- "access": "public",
89
- "tag": "latest"
36
+ "@adonisjs/core": "^6.1.5-4",
37
+ "@adonisjs/eslint-config": "^1.1.7",
38
+ "@adonisjs/prettier-config": "^1.1.7",
39
+ "@adonisjs/tsconfig": "^1.1.7",
40
+ "@japa/assert": "^2.0.0-1",
41
+ "@japa/file-system": "^2.0.0-1",
42
+ "@japa/runner": "^3.0.0-2",
43
+ "@swc/core": "^1.3.67",
44
+ "@types/node": "^20.3.3",
45
+ "c8": "^8.0.0",
46
+ "copyfiles": "^2.4.1",
47
+ "del-cli": "^5.0.0",
48
+ "eslint": "^8.44.0",
49
+ "github-label-sync": "^2.3.1",
50
+ "husky": "^8.0.3",
51
+ "np": "^8.0.4",
52
+ "prettier": "^2.8.8",
53
+ "ts-node": "^10.9.1",
54
+ "typescript": "^5.1.3"
90
55
  },
91
56
  "dependencies": {
92
- "@poppinss/colors": "^3.0.2",
93
- "node-repl-await": "^0.1.2",
94
- "parse-imports": "0.0.5",
95
- "string-width": "^4.2.2"
96
- },
97
- "directories": {
98
- "example": "example",
99
- "test": "test"
57
+ "@poppinss/colors": "4.1.0-2",
58
+ "string-width": "^6.1.0"
100
59
  },
60
+ "author": "virk,julien-r44,adonisjs",
61
+ "license": "MIT",
62
+ "homepage": "https://github.com/adonisjs/repl#readme",
101
63
  "repository": {
102
64
  "type": "git",
103
65
  "url": "git+https://github.com/adonisjs/repl.git"
@@ -105,57 +67,37 @@
105
67
  "bugs": {
106
68
  "url": "https://github.com/adonisjs/repl/issues"
107
69
  },
108
- "homepage": "https://github.com/adonisjs/repl#readme",
109
- "adonisjs": {
110
- "aceProviders": [
111
- "@adonisjs/repl"
112
- ],
113
- "commands": [
114
- "@adonisjs/repl/build/commands"
115
- ],
116
- "types": "@adonisjs/repl"
117
- },
118
- "mrmConfig": {
119
- "core": true,
120
- "license": "MIT",
121
- "services": [
122
- "github-actions"
123
- ],
124
- "minNodeVersion": "14.15.4",
125
- "probotApps": [
126
- "stale",
127
- "lock"
128
- ],
129
- "runGhActionsOnWindows": true
130
- },
70
+ "keywords": [
71
+ "adonisjs",
72
+ "repl",
73
+ "node-repl"
74
+ ],
131
75
  "eslintConfig": {
76
+ "extends": "@adonisjs/eslint-config/package"
77
+ },
78
+ "prettier": "@adonisjs/prettier-config",
79
+ "commitlint": {
132
80
  "extends": [
133
- "plugin:adonis/typescriptPackage",
134
- "prettier"
135
- ],
136
- "plugins": [
137
- "prettier"
138
- ],
139
- "rules": {
140
- "prettier/prettier": [
141
- "error",
142
- {
143
- "endOfLine": "auto"
144
- }
145
- ]
146
- }
81
+ "@commitlint/config-conventional"
82
+ ]
147
83
  },
148
- "eslintIgnore": [
149
- "build"
150
- ],
151
- "prettier": {
152
- "trailingComma": "es5",
153
- "semi": false,
154
- "singleQuote": true,
155
- "useTabs": false,
156
- "quoteProps": "consistent",
157
- "bracketSpacing": true,
158
- "arrowParens": "always",
159
- "printWidth": 100
84
+ "publishConfig": {
85
+ "access": "public",
86
+ "tag": "latest"
87
+ },
88
+ "np": {
89
+ "message": "chore(release): %s",
90
+ "tag": "next",
91
+ "branch": "main",
92
+ "anyBranch": false
93
+ },
94
+ "c8": {
95
+ "reporter": [
96
+ "text",
97
+ "html"
98
+ ],
99
+ "exclude": [
100
+ "tests/**"
101
+ ]
160
102
  }
161
103
  }
@@ -1,6 +0,0 @@
1
- declare module '@ioc:Adonis/Core/Application' {
2
- import { ReplContract } from '@ioc:Adonis/Addons/Repl';
3
- interface ContainerBindings {
4
- 'Adonis/Addons/Repl': ReplContract;
5
- }
6
- }
@@ -1,2 +0,0 @@
1
- /// <reference path="container.d.ts" />
2
- /// <reference path="repl.d.ts" />
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/repl
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /// <reference path="./container.ts" />
10
- /// <reference path="./repl.ts" />
@@ -1,46 +0,0 @@
1
- /// <reference types="node" />
2
- declare module '@ioc:Adonis/Addons/Repl' {
3
- import { REPLServer } from 'repl';
4
- import { getBest } from '@poppinss/colors';
5
- /**
6
- * Custom method callback
7
- */
8
- export type Handler = (repl: ReplContract, ...args: any[]) => any;
9
- /**
10
- * Options that can be set when defining a loader
11
- * method
12
- */
13
- export type ContextOptions = {
14
- description?: string;
15
- usage?: string;
16
- };
17
- /**
18
- * Shape of the REPL class
19
- */
20
- export interface ReplContract {
21
- colors: ReturnType<typeof getBest>;
22
- /**
23
- * Reference to the REPL server
24
- */
25
- server: REPLServer;
26
- /**
27
- * Start the repl
28
- */
29
- start(): this;
30
- /**
31
- * Notify by writing message to the console
32
- * and resuming the prompt
33
- */
34
- notify(message: string): void;
35
- /**
36
- * Add a method. Loader methods works as a shortcut for
37
- */
38
- addMethod(name: string, handler: Handler, options?: ContextOptions): this;
39
- /**
40
- * Register a callback to be invoked once the server is ready
41
- */
42
- ready(callback: (repl: ReplContract) => void): this;
43
- }
44
- const Repl: ReplContract;
45
- export default Repl;
46
- }
@@ -1,11 +0,0 @@
1
- import { BaseCommand } from '@adonisjs/core/build/standalone';
2
- export default class ReplCommand extends BaseCommand {
3
- static commandName: string;
4
- static description: string;
5
- static settings: {
6
- loadApp: boolean;
7
- environment: "repl";
8
- stayAlive: boolean;
9
- };
10
- run(): Promise<void>;
11
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/repl
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const standalone_1 = require("@adonisjs/core/build/standalone");
12
- class ReplCommand extends standalone_1.BaseCommand {
13
- async run() {
14
- this.application.container.withBindings(['Adonis/Core/Route'], (Route) => {
15
- Route.commit();
16
- });
17
- this.application.container.use('Adonis/Addons/Repl').start();
18
- /**
19
- * Gracefully shutdown the application
20
- */
21
- this.application.container.use('Adonis/Addons/Repl').server.on('exit', async () => {
22
- await this.application.shutdown();
23
- });
24
- }
25
- }
26
- exports.default = ReplCommand;
27
- ReplCommand.commandName = 'repl';
28
- ReplCommand.description = 'Start a new REPL session';
29
- ReplCommand.settings = {
30
- loadApp: true,
31
- environment: 'repl',
32
- stayAlive: true,
33
- };
@@ -1,2 +0,0 @@
1
- declare const _default: string[];
2
- export default _default;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/repl
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.default = ['@adonisjs/repl/build/commands/AdonisRepl'];
@@ -1,7 +0,0 @@
1
- import { ApplicationContract } from '@ioc:Adonis/Core/Application';
2
- export default class ReplProvider {
3
- protected app: ApplicationContract;
4
- constructor(app: ApplicationContract);
5
- static needsApplication: boolean;
6
- register(): void;
7
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/repl
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const path_1 = require("path");
12
- const os_1 = require("os");
13
- class ReplProvider {
14
- constructor(app) {
15
- this.app = app;
16
- }
17
- register() {
18
- this.app.container.singleton('Adonis/Addons/Repl', () => {
19
- const compiler = global[Symbol.for('REQUIRE_TS_COMPILER')];
20
- const { Repl } = require('../src/Repl');
21
- return new Repl(compiler, (0, path_1.join)((0, os_1.homedir)(), '.adonis_repl_history'));
22
- });
23
- }
24
- }
25
- exports.default = ReplProvider;
26
- ReplProvider.needsApplication = true;
@@ -1,29 +0,0 @@
1
- import { Compiler as TsCompiler } from '@adonisjs/require-ts/build/src/Compiler';
2
- /**
3
- * Exposes the API to compile the user land code to be executed
4
- * inside Node.JS REPL.
5
- */
6
- export declare class Compiler {
7
- private tsCompiler?;
8
- compilesTs: boolean;
9
- constructor(tsCompiler?: TsCompiler | undefined);
10
- /**
11
- * Process the await keywords in the code
12
- */
13
- private processAwait;
14
- /**
15
- * Compiles code using typescript
16
- */
17
- private compileTypescript;
18
- /**
19
- * Compiles the code to be executed in the Node.js REPL. Under
20
- * the hood
21
- *
22
- * - Typescript code is compiled
23
- * - Await keywords are wrapped in async IIFE
24
- */
25
- compile(statement: string, filename: string): Promise<{
26
- compiled: string;
27
- awaitPromise: boolean;
28
- }>;
29
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/repl
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.Compiler = void 0;
12
- const node_repl_await_1 = require("node-repl-await");
13
- const ImportsParser_1 = require("../ImportsParser");
14
- /**
15
- * Exposes the API to compile the user land code to be executed
16
- * inside Node.JS REPL.
17
- */
18
- class Compiler {
19
- constructor(tsCompiler) {
20
- this.tsCompiler = tsCompiler;
21
- this.compilesTs = !!this.tsCompiler;
22
- }
23
- /**
24
- * Process the await keywords in the code
25
- */
26
- processAwait(statement) {
27
- const potentialWrappedCode = (0, node_repl_await_1.processTopLevelAwait)(statement);
28
- if (!potentialWrappedCode) {
29
- return { compiled: statement, awaitPromise: false };
30
- }
31
- return { compiled: potentialWrappedCode, awaitPromise: true };
32
- }
33
- /**
34
- * Compiles code using typescript
35
- */
36
- async compileTypescript(statement, filename) {
37
- const lines = statement.split(/\n|\r\n/);
38
- let compiledOutput = statement;
39
- /**
40
- * In case of a single line, we process the import
41
- * keywords and define local variables to hold
42
- * the import reference
43
- */
44
- if (lines.length <= 2) {
45
- compiledOutput = await new ImportsParser_1.ImportsParser().parse(statement);
46
- }
47
- /**
48
- * Compile using typescript compiler and patch the
49
- * `sourceMappingUrl` comment to be a block level comment.
50
- */
51
- compiledOutput = this.tsCompiler.compile(filename, compiledOutput, true);
52
- return `${compiledOutput.replace('//# sourceMappingURL=', '/**# sourceMappingURL=')} */`;
53
- }
54
- /**
55
- * Compiles the code to be executed in the Node.js REPL. Under
56
- * the hood
57
- *
58
- * - Typescript code is compiled
59
- * - Await keywords are wrapped in async IIFE
60
- */
61
- async compile(statement, filename) {
62
- if (this.tsCompiler) {
63
- statement = await this.compileTypescript(statement, filename);
64
- }
65
- return this.processAwait(statement);
66
- }
67
- }
68
- exports.Compiler = Compiler;
@@ -1,51 +0,0 @@
1
- /**
2
- * This is a crazy attempt to hack around the Typescript behavior around un-used
3
- * imports. Writing half baked parsers is something I want to avoid everytime.
4
- * However, there isn't any other way (atleast I don't know about it).
5
- *
6
- * In REPL, you usually write one line of code at a time. For example:
7
- * - You write 2 + 2 and then press enter. The REPL prints 4
8
- * - You write `await Database.query().first()` and it prints the query result.
9
- *
10
- * However, when you write `import User from 'App/Models/User'` and expect to
11
- * access User variable then you are out of luck.
12
- *
13
- * - The import statement will go to the typescript compiler
14
- * - It will compile the code and sees that no one is using this import.
15
- * And hence it will just remove it from the compiled output.
16
- *
17
- * Bang! No import/require exists and hence no `User` variable exists.
18
- *
19
- * To hack around it, we need to monitor and parse import statements and hold
20
- * a reference to them so that the compiler doesn't remove. For example:
21
- *
22
- * Converting
23
- * ```ts
24
- * import User from 'App/Models/User'
25
- * ```
26
- *
27
- * To
28
- * ```ts
29
- * import repl_User from 'App/Models/User'; var User = repl_User
30
- * ```
31
- *
32
- * Now you can access the `User` variable.
33
- *
34
- * The tough part is attempting to parse all styles in which an import
35
- * statement can be written. Lucikly, there are 4 different ways to
36
- * do that as per the spec http://www.ecma-international.org/ecma-262/6.0/#table-40
37
- *
38
- * import v from "mod"; (Import default)
39
- * import * as ns from "mod"; (Import alias)
40
- * import {x} from "mod"; (Import named)
41
- * import {x as v} from "mod"; (Import named + aliases)
42
- *
43
- * However, we have to be tolerant to the white spaces.
44
- */
45
- export declare class ImportsParser {
46
- private parseImport;
47
- /**
48
- * Parse a given line of code
49
- */
50
- parse(line: string): Promise<string>;
51
- }