Skip to content

Commit

Permalink
💥 remove esm
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuLemoine committed Jun 28, 2022
1 parent 3dd5b4a commit 9be937c
Show file tree
Hide file tree
Showing 36 changed files with 762 additions and 1,257 deletions.
19 changes: 4 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
{
"extends": ["airbnb-base"],
"parserOptions": {
"ecmaVersion": 9
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"jest": true,
"node": true
"node": true,
"es2022": true
},
"rules": {
"no-underscore-dangle": 0,
"no-use-before-define": [
"error",
{ "functions": false, "classes": true, "variables": true }
],
"max-len": 0,
"no-restricted-syntax": 0,
"no-await-in-loop": 0
}
"rules": {}
}
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npm install immersive
## Usage

```javascript
import immersive from 'immersive';
const immersive = require('immersive');

const config = {
// Application name used for config persistence (required)
Expand Down
12 changes: 9 additions & 3 deletions examples/basic/commands/get/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const command = 'get <id>';
export const description = 'Get user info';
const command = 'get <id>';
const description = 'Get user info';

export const action = async ({ args, db, logger }) => {
const action = async ({ args, db, logger }) => {
const id = args._[0];
const user = await db.get(id);
if (!user) {
Expand All @@ -10,3 +10,9 @@ export const action = async ({ args, db, logger }) => {
}
logger.table({ name: 'Users', rows: [user] });
};

module.exports = {
command,
description,
action,
};
12 changes: 9 additions & 3 deletions examples/with-environments/commands/get/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const command = 'get <id>';
export const description = 'Get user info';
const command = 'get <id>';
const description = 'Get user info';

export const action = async ({ args, db, logger }) => {
const action = async ({ args, db, logger }) => {
const id = args._[0];
const user = await db.get(id);
if (!user) {
Expand All @@ -10,3 +10,9 @@ export const action = async ({ args, db, logger }) => {
}
logger.table({ name: 'Users', rows: [user] });
};

module.exports = {
command,
description,
action,
};
12 changes: 0 additions & 12 deletions examples/with-esm/commands/get/index.js

This file was deleted.

31 changes: 0 additions & 31 deletions examples/with-esm/helpers/db/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions examples/with-esm/index.js

This file was deleted.

37 changes: 0 additions & 37 deletions examples/with-esm/main.js

This file was deleted.

6 changes: 2 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'immersive' {
import { Context } from 'node:vm';
const { Context } = require('node:vm');
interface ImmersiveEnvironment extends Record<string, any> {}
interface ImmersiveEnvironmentConfig extends ImmersiveEnvironment {
name: string;
Expand Down Expand Up @@ -90,9 +90,7 @@ declare module 'immersive' {
>,
) => ReturnType;

export default function immersive(
configuration: ImmersiveConfiguration,
): void;
export function immersive(configuration: ImmersiveConfiguration): void;

export function repl(context: Context, customEval: any): Promise<void>;
export function mergeExport<
Expand Down
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

19 changes: 0 additions & 19 deletions jest.js

This file was deleted.

25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "immersive",
"version": "1.8.2",
"version": "2.0.0",
"description": "A framework to build immersive CLIs & great developer tools.",
"main": "index.js",
"module": "src/index.js",
"main": "src/index.js",
"repository": "https://github.com/MatthieuLemoine/immersive",
"author": "MatthieuLemoine",
"license": "MIT",
Expand All @@ -14,27 +13,25 @@
"cli-table3": "^0.5.1",
"conductor": "^1.4.1",
"conf": "^2.0.0",
"esm": "^3.2.25",
"figlet": "^1.2.0",
"ramda": "^0.25.0",
"require-dir": "^1.1.0",
"yargs-parser": "^10.1.0"
},
"devDependencies": {
"eslint": "^5.6.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.1.0",
"husky": "^1.1.1",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"prettier": "^1.14.3",
"prettier-eslint-cli": "^4.7.1"
"prettier": "^1.14.3"
},
"scripts": {
"test": "./jest.js",
"test": "jest __tests__/",
"lint": "eslint .",
"prettify": "prettier-eslint --write \"**/*.js*\" --list-different",
"pretty-check": "prettier-eslint \"**/*.js*\" --list-different",
"prettify": "prettier --write \"**/*.js*\" --list-different",
"pretty-check": "prettier \"**/*.js*\" --list-different",
"check-version": "node scripts/check-version.js"
},
"husky": {
Expand All @@ -45,12 +42,12 @@
"lint-staged": {
"linters": {
"*.js": [
"prettier-eslint --write --config .prettierrc",
"prettier --write",
"eslint --fix",
"git add"
],
"*.json": [
"prettier-eslint --write --config .prettierrc",
"prettier --write",
"git add"
]
}
Expand Down
8 changes: 5 additions & 3 deletions src/autocomplete/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { getCommands } from '../command';
const { getCommands } = require('../command');

export default (line) => {
function autocomplete(line) {
const completions = Object.keys(getCommands()).sort();
const hits = completions.filter(c => c.startsWith(line));
return [hits.length ? hits : completions, line];
};
}

module.exports = autocomplete;
34 changes: 20 additions & 14 deletions src/command/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
const {
compose,
slice,
head,
Expand All @@ -8,23 +8,23 @@ import {
values,
reduce,
join,
} from 'conductor';
import parse from 'yargs-parser';
import requireDir from 'require-dir';
import { parseCommand } from '../utils';
import eventHub, { ON_COMMAND_END } from '../event-hub';
import { getCurrentEnvironment, helpersMap } from '../environment';
import internalCommands from './internals';
import logger from '../logger';
import * as history from '../history';
import { getConfig } from '../config';
} = require('conductor');
const parse = require('yargs-parser');
const requireDir = require('require-dir');
const { parseCommand } = require('../utils');
const { ON_COMMAND_END, eventHub } = require('../event-hub');
const { getCurrentEnvironment, helpersMap } = require('../environment');
const internalCommands = require('./internals');
const logger = require('../logger');
const history = require('../history');
const { getConfig } = require('../config');

let commandsMap = {};
let commands;

export const getCommands = () => commandsMap;
const getCommands = () => commandsMap;

export const runCommand = async (command, internal) => {
const runCommand = async (command, internal) => {
const parsed = parse(command, { configuration: { 'parse-numbers': false } });
let found;
let index = 0;
Expand Down Expand Up @@ -109,7 +109,7 @@ const wrapCommand = (action, config) => (argv, command) => {
});
};

export const loadCommands = ({
const loadCommands = ({
commands: userLoadedCommands,
commandsDirectory,
...config
Expand Down Expand Up @@ -140,3 +140,9 @@ function getHelpers(env) {
}
return helpersMap;
}

module.exports = {
getCommands,
runCommand,
loadCommands,
};
12 changes: 9 additions & 3 deletions src/command/internals/config/get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
export const command = 'config get <key>';
export const description = 'Get config value';
const command = 'config get <key>';
const description = 'Get config value';

export const action = ({ args, config, logger }) => {
const action = ({ args, config, logger }) => {
const [key] = args._;
logger.log(config.get(key));
};

module.exports = {
command,
description,
action,
};
14 changes: 10 additions & 4 deletions src/command/internals/config/list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { omit } from 'ramda';
const { omit } = require('ramda');

export const command = 'config list';
export const description = 'Display configuration';
const command = 'config list';
const description = 'Display configuration';

export const action = ({ config, logger }) => {
const action = ({ config, logger }) => {
logger.log(omit(['history'], config.store));
};

module.exports = {
command,
description,
action,
};
Loading

0 comments on commit 9be937c

Please sign in to comment.