Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for double characters due to inquirer package: #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2018
"ecmaVersion": 2022
},
"plugins": [
"node",
Expand Down
19,140 changes: 11,299 additions & 7,841 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"deps": "npm-check -u",
"lint": "eslint src/**/*.js -c .eslintrc.js",
"dev:init": "node ./bin/moleculer init project tmp",
"test": "jest --config jest.config.js --detectOpenHandles --forceExit"
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.js --detectOpenHandles --forceExit"
},
"bin": {
"moleculer": "./bin/moleculer.js"
Expand All @@ -26,7 +26,7 @@
"exeq": "^3.0.0",
"glob": "^7.2.0",
"handlebars": "^4.7.7",
"inquirer": "^7.3.3",
"inquirer": "^9.2.7",
"kleur": "^4.1.4",
"lodash": "^4.17.21",
"metalsmith": "^2.3.0",
Expand All @@ -35,19 +35,20 @@
"moleculer": "^0.14.19",
"moleculer-repl": "^0.7.2",
"multimatch": "^4.0.0",
"nats": "^2.4.0",
"nats": "^2.15.0",
"rimraf": "^3.0.2",
"update-notifier": "^5.1.0",
"yargs": "^15.4.1"
},
"devDependencies": {
"coveralls": "^3.1.1",
"eslint": "^8.6.0",
"eslint": "^8.43.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-security": "^1.4.0",
"jest": "^27.4.7",
"jest-cli": "^27.4.7",
"jest": "^29.5.0",
"jest-cli": "^29.5.0",
"npm-check": "^6.0.1",
"yargs-promise": "^1.1.0"
},
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/alias-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("fs");
const path = require("path");
const os = require("os");

const inquirer = require("inquirer");
const inquirerModule = (async () => (await import("inquirer")).default)();
const kleur = require("kleur");
const { fail } = require("../utils");

Expand All @@ -24,7 +24,8 @@ let values = {
*
* @param {any} opts
*/
function handler(opts) {
async function handler(opts) {
const inquirer = await inquirerModule;
Object.assign(values, opts);

const configPath = path.join(os.homedir(), ".moleculer-templates.json");
Expand Down
7 changes: 3 additions & 4 deletions src/create/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const inquirerModule = (async () => (await import("inquirer")).default)();
const render = require("consolidate").handlebars.render;
const glob = require("glob").sync;
const ui = new inquirer.ui.BottomBar();
const { fail } = require("../../utils");


module.exports = async (opts) => {
const inquirer = await inquirerModule;
const ui = new inquirer.ui.BottomBar();
const values = Object.assign({}, opts);
const _typescript = values.typescript ? true : false;
const name = opts._[2];
Expand Down
5 changes: 3 additions & 2 deletions src/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const async = require("async");
const mkdirp = require("mkdirp");
const exeq = require("exeq");
const download = require("download-git-repo");
const inquirer = require("inquirer");
const inquirerModule = (async () => (await import("inquirer")).default)();
const multimatch = require("multimatch");
const render = require("consolidate").handlebars.render;
const Metalsmith = require("metalsmith");
Expand Down Expand Up @@ -77,7 +77,8 @@ Handlebars.registerHelper("raw-helper", (options) => options.fn());
* @param {any} opts
* @returns
*/
function handler(opts) {
async function handler(opts) {
const inquirer = await inquirerModule;
Object.assign(values, opts);

//console.log("Values:", values);
Expand Down
16 changes: 10 additions & 6 deletions test/e2e/create/service/create.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
const YargsPromise = require("yargs-promise");
const yargs = require("yargs");
const inquirer = require("inquirer");
const inquirerModule = (async () => (await import("inquirer")).default)();
const path = require("path");
const fs = require("fs");
const create = require("../../../../src/create");
const answers = require("./create_answers.json");
const answers_ts = require("./create_answers_ts.json");
const tmp = path.resolve(__dirname, "../../../../tmp");
const tmp = path.resolve(__dirname, "../../../../tmp");
let inquirer;

describe("test create", () => {
beforeAll(() => {
if (!fs.existsSync(tmp)) {
fs.mkdirSync(tmp,{mode: 0o777});
}
});

beforeEach(async () => {
jest.mock("inquirer");
inquirer = await inquirerModule;
inquirer.prompt = jest.fn().mockResolvedValue(answers);
});

afterEach(() => {
jest.clearAllMocks();
});
Expand All @@ -30,8 +38,6 @@ describe("test create", () => {
`./mocks/${answers.serviceName}.service.js`
);

jest.mock("inquirer");
inquirer.prompt = jest.fn().mockResolvedValue(answers);
yargs
.usage("Usage: $0 <command> [options]")
.version()
Expand Down Expand Up @@ -64,8 +70,6 @@ describe("test create", () => {
`./mocks/${answers.serviceName}.service.ts`
);

jest.mock("inquirer");
inquirer.prompt = jest.fn().mockResolvedValue(answers);
yargs
.usage("Usage: $0 <command> [options]")
.version()
Expand Down