Skip to content

Commit

Permalink
ready to ship
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Jan 23, 2025
1 parent c825a8a commit 20a30dc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2024 iovalkey
Copyright (c) 2022 ioredis

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# interface-generator
Generate interface for ioredis

Generate interface for iovalkey

Forked from [iovalkey/interface-generator](https://github.com/ioredis/interface-generator) at commit c825a8ae2c12d450755abc4ed69ce80a871e9fc2.

## License

MIT
17 changes: 11 additions & 6 deletions lib/commander.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const camelcase = require("lodash.camelcase");
const flatMap = require("lodash.flatmap");
const Redis = require("ioredis");
const Valkey = require("iovalkey");
const { pluralize, singularize } = require("inflection");

const { packObject, addMatrix, getCommandParameters } = require("./utils");
Expand All @@ -14,7 +16,7 @@ const processArguments = (
rawAdd(defs.filter(Boolean).map((items) => items.filter(Boolean)));
};
const args = rawArgs && rawArgs.map(packObject);
const name = camelcase(rawName.toLowerCase());
let name = camelcase(rawName.toLowerCase());
const tokenDef = token
? {
name: camelcase(token.toLowerCase()) || name,
Expand All @@ -35,6 +37,9 @@ const processArguments = (
]);
break;
case "string":
if (name === "function") {
name = "fun";
}
add([
optional && [],
[
Expand Down Expand Up @@ -252,7 +257,7 @@ function processSubcommands(
async function getCommanderInterface({
commands,
complexityLimit,
redisOpts,
valkeyOpts,
overrides,
returnTypes,
argumentTypes,
Expand All @@ -261,11 +266,11 @@ async function getCommanderInterface({
ignoredBufferVariant = [],
}) {
const allDefs = [];
const redis = new Redis(redisOpts);
const valkey = new Valkey(valkeyOpts);

for (const command of commands) {
try {
const result = packObject((await redis.command("docs", command))[1]);
const result = packObject((await valkey.command("docs", command))[1]);
Object.assign(result, { name: command });
if (result.subcommands) {
processSubcommands(
Expand All @@ -286,7 +291,7 @@ async function getCommanderInterface({
);
}
} catch (err) {
console.error(`Failed to parse command: ${command}`);
console.error(`Failed to parse command: ${command} with err:`, err);
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

exports.packObject = (array) => {
const result = {};
const length = array.length;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ioredis/interface-generator",
"version": "1.3.0",
"description": "Generate interface for ioredis",
"name": "@iovalkey/interface-generator",
"version": "0.1.0",
"description": "Generate interface for iovalkey",
"publishConfig": {
"access": "public"
},
Expand All @@ -22,7 +22,7 @@
"homepage": "https://github.com/ioredis/interface-generator#readme",
"dependencies": {
"inflection": "^1.13.2",
"ioredis": "^5.0.0",
"iovalkey": "^0.2.0",
"lodash.camelcase": "^4.3.0",
"lodash.flatmap": "^4.5.0"
}
Expand Down

0 comments on commit 20a30dc

Please sign in to comment.