Skip to content

Commit 9be937c

Browse files
💥 remove esm
1 parent 3dd5b4a commit 9be937c

File tree

36 files changed

+762
-1257
lines changed

36 files changed

+762
-1257
lines changed

.eslintrc

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
{
2-
"extends": ["airbnb-base"],
3-
"parserOptions": {
4-
"ecmaVersion": 9
5-
},
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
63
"env": {
74
"jest": true,
8-
"node": true
5+
"node": true,
6+
"es2022": true
97
},
10-
"rules": {
11-
"no-underscore-dangle": 0,
12-
"no-use-before-define": [
13-
"error",
14-
{ "functions": false, "classes": true, "variables": true }
15-
],
16-
"max-len": 0,
17-
"no-restricted-syntax": 0,
18-
"no-await-in-loop": 0
19-
}
8+
"rules": {}
209
}

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npm install immersive
2828
## Usage
2929

3030
```javascript
31-
import immersive from 'immersive';
31+
const immersive = require('immersive');
3232

3333
const config = {
3434
// Application name used for config persistence (required)

examples/basic/commands/get/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const command = 'get <id>';
2-
export const description = 'Get user info';
1+
const command = 'get <id>';
2+
const description = 'Get user info';
33

4-
export const action = async ({ args, db, logger }) => {
4+
const action = async ({ args, db, logger }) => {
55
const id = args._[0];
66
const user = await db.get(id);
77
if (!user) {
@@ -10,3 +10,9 @@ export const action = async ({ args, db, logger }) => {
1010
}
1111
logger.table({ name: 'Users', rows: [user] });
1212
};
13+
14+
module.exports = {
15+
command,
16+
description,
17+
action,
18+
};
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const command = 'get <id>';
2-
export const description = 'Get user info';
1+
const command = 'get <id>';
2+
const description = 'Get user info';
33

4-
export const action = async ({ args, db, logger }) => {
4+
const action = async ({ args, db, logger }) => {
55
const id = args._[0];
66
const user = await db.get(id);
77
if (!user) {
@@ -10,3 +10,9 @@ export const action = async ({ args, db, logger }) => {
1010
}
1111
logger.table({ name: 'Users', rows: [user] });
1212
};
13+
14+
module.exports = {
15+
command,
16+
description,
17+
action,
18+
};

examples/with-esm/commands/get/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/with-esm/helpers/db/index.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/with-esm/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/with-esm/main.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

index.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'immersive' {
2-
import { Context } from 'node:vm';
2+
const { Context } = require('node:vm');
33
interface ImmersiveEnvironment extends Record<string, any> {}
44
interface ImmersiveEnvironmentConfig extends ImmersiveEnvironment {
55
name: string;
@@ -90,9 +90,7 @@ declare module 'immersive' {
9090
>,
9191
) => ReturnType;
9292

93-
export default function immersive(
94-
configuration: ImmersiveConfiguration,
95-
): void;
93+
export function immersive(configuration: ImmersiveConfiguration): void;
9694

9795
export function repl(context: Context, customEval: any): Promise<void>;
9896
export function mergeExport<

index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

jest.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"name": "immersive",
3-
"version": "1.8.2",
3+
"version": "2.0.0",
44
"description": "A framework to build immersive CLIs & great developer tools.",
5-
"main": "index.js",
6-
"module": "src/index.js",
5+
"main": "src/index.js",
76
"repository": "https://github.com/MatthieuLemoine/immersive",
87
"author": "MatthieuLemoine",
98
"license": "MIT",
@@ -14,27 +13,25 @@
1413
"cli-table3": "^0.5.1",
1514
"conductor": "^1.4.1",
1615
"conf": "^2.0.0",
17-
"esm": "^3.2.25",
1816
"figlet": "^1.2.0",
1917
"ramda": "^0.25.0",
2018
"require-dir": "^1.1.0",
2119
"yargs-parser": "^10.1.0"
2220
},
2321
"devDependencies": {
24-
"eslint": "^5.6.1",
25-
"eslint-config-airbnb-base": "^13.1.0",
26-
"eslint-plugin-import": "^2.14.0",
22+
"eslint": "^8.18.0",
23+
"eslint-config-prettier": "^8.5.0",
24+
"eslint-plugin-prettier": "^4.1.0",
2725
"husky": "^1.1.1",
2826
"jest": "^23.6.0",
2927
"lint-staged": "^7.3.0",
30-
"prettier": "^1.14.3",
31-
"prettier-eslint-cli": "^4.7.1"
28+
"prettier": "^1.14.3"
3229
},
3330
"scripts": {
34-
"test": "./jest.js",
31+
"test": "jest __tests__/",
3532
"lint": "eslint .",
36-
"prettify": "prettier-eslint --write \"**/*.js*\" --list-different",
37-
"pretty-check": "prettier-eslint \"**/*.js*\" --list-different",
33+
"prettify": "prettier --write \"**/*.js*\" --list-different",
34+
"pretty-check": "prettier \"**/*.js*\" --list-different",
3835
"check-version": "node scripts/check-version.js"
3936
},
4037
"husky": {
@@ -45,12 +42,12 @@
4542
"lint-staged": {
4643
"linters": {
4744
"*.js": [
48-
"prettier-eslint --write --config .prettierrc",
45+
"prettier --write",
4946
"eslint --fix",
5047
"git add"
5148
],
5249
"*.json": [
53-
"prettier-eslint --write --config .prettierrc",
50+
"prettier --write",
5451
"git add"
5552
]
5653
}

src/autocomplete/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { getCommands } from '../command';
1+
const { getCommands } = require('../command');
22

3-
export default (line) => {
3+
function autocomplete(line) {
44
const completions = Object.keys(getCommands()).sort();
55
const hits = completions.filter(c => c.startsWith(line));
66
return [hits.length ? hits : completions, line];
7-
};
7+
}
8+
9+
module.exports = autocomplete;

src/command/index.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
const {
22
compose,
33
slice,
44
head,
@@ -8,23 +8,23 @@ import {
88
values,
99
reduce,
1010
join,
11-
} from 'conductor';
12-
import parse from 'yargs-parser';
13-
import requireDir from 'require-dir';
14-
import { parseCommand } from '../utils';
15-
import eventHub, { ON_COMMAND_END } from '../event-hub';
16-
import { getCurrentEnvironment, helpersMap } from '../environment';
17-
import internalCommands from './internals';
18-
import logger from '../logger';
19-
import * as history from '../history';
20-
import { getConfig } from '../config';
11+
} = require('conductor');
12+
const parse = require('yargs-parser');
13+
const requireDir = require('require-dir');
14+
const { parseCommand } = require('../utils');
15+
const { ON_COMMAND_END, eventHub } = require('../event-hub');
16+
const { getCurrentEnvironment, helpersMap } = require('../environment');
17+
const internalCommands = require('./internals');
18+
const logger = require('../logger');
19+
const history = require('../history');
20+
const { getConfig } = require('../config');
2121

2222
let commandsMap = {};
2323
let commands;
2424

25-
export const getCommands = () => commandsMap;
25+
const getCommands = () => commandsMap;
2626

27-
export const runCommand = async (command, internal) => {
27+
const runCommand = async (command, internal) => {
2828
const parsed = parse(command, { configuration: { 'parse-numbers': false } });
2929
let found;
3030
let index = 0;
@@ -109,7 +109,7 @@ const wrapCommand = (action, config) => (argv, command) => {
109109
});
110110
};
111111

112-
export const loadCommands = ({
112+
const loadCommands = ({
113113
commands: userLoadedCommands,
114114
commandsDirectory,
115115
...config
@@ -140,3 +140,9 @@ function getHelpers(env) {
140140
}
141141
return helpersMap;
142142
}
143+
144+
module.exports = {
145+
getCommands,
146+
runCommand,
147+
loadCommands,
148+
};

src/command/internals/config/get.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
export const command = 'config get <key>';
2-
export const description = 'Get config value';
1+
const command = 'config get <key>';
2+
const description = 'Get config value';
33

4-
export const action = ({ args, config, logger }) => {
4+
const action = ({ args, config, logger }) => {
55
const [key] = args._;
66
logger.log(config.get(key));
77
};
8+
9+
module.exports = {
10+
command,
11+
description,
12+
action,
13+
};

src/command/internals/config/list.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { omit } from 'ramda';
1+
const { omit } = require('ramda');
22

3-
export const command = 'config list';
4-
export const description = 'Display configuration';
3+
const command = 'config list';
4+
const description = 'Display configuration';
55

6-
export const action = ({ config, logger }) => {
6+
const action = ({ config, logger }) => {
77
logger.log(omit(['history'], config.store));
88
};
9+
10+
module.exports = {
11+
command,
12+
description,
13+
action,
14+
};

0 commit comments

Comments
 (0)