Skip to content

Commit

Permalink
Merge b687f25 into 975336d
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jun 25, 2022
2 parents 975336d + b687f25 commit de35ace
Show file tree
Hide file tree
Showing 8 changed files with 360 additions and 411 deletions.
12 changes: 11 additions & 1 deletion bin/index.js
@@ -1,9 +1,18 @@
const returnTypes = require("./returnTypes");
const argumentTypes = require("./argumentTypes");
const sortArguments = require("./sortArguments");
const typeMaps = require("./typeMaps");
const overrides = require("./overrides");
const { getCommanderInterface } = require("@ioredis/interface-generator");

const HEADER = `/**
* This file is generated by @ioredis/interface-generator.
* Don't edit it manually. Instead, run \`npm run generate\` to update
* this file.
*/
`;

const ignoredCommands = ["monitor", "multi"];
const commands = require("@ioredis/commands")
.list.filter((name) => !ignoredCommands.includes(name))
Expand All @@ -24,6 +33,7 @@ async function main() {
overrides,
returnTypes,
argumentTypes,
sortArguments,
typeMaps: typeMaps,
ignoredBufferVariant: [
"incrbyfloat",
Expand All @@ -39,7 +49,7 @@ async function main() {

fs.writeFileSync(
path.join(__dirname, "..", "lib/utils/RedisCommander.ts"),
template.replace("////", () => interface)
HEADER + template.replace("////", () => interface)
);
}

Expand Down
2 changes: 1 addition & 1 deletion bin/overrides.js
Expand Up @@ -11,7 +11,7 @@ module.exports = {
overwrite: true,
defs: [
"$1(key: RedisKey, callback?: Callback<Record<string, string>>): Result<Record<string, string>, Context>",
"$1Buffer(key: RedisKey, callback?: Callback<[field: Buffer, value: Buffer][]>): Result<[field: Buffer, value: Buffer][], Context>",
"$1Buffer(key: RedisKey, callback?: Callback<Record<string, Buffer>>): Result<Record<string, Buffer>, Context>",
],
},
mset: msetOverrides,
Expand Down
11 changes: 11 additions & 0 deletions bin/sortArguments.js
@@ -0,0 +1,11 @@
module.exports = {
set: (args) => {
console.log(args);
const sorted = args.sort((a, b) => {
const order = ["key", "value", "expiration", "condition", "get"];
return order.indexOf(a.name) - order.indexOf(b.name);
});
console.log(sorted);
return sorted;
},
};
3 changes: 2 additions & 1 deletion bin/template.ts
Expand Up @@ -11,7 +11,8 @@ export interface ResultTypes<Result, Context> {
pipeline: ChainableCommander;
}

export interface ChainableCommander extends RedisCommander<{ type: "pipeline" }> {
export interface ChainableCommander
extends RedisCommander<{ type: "pipeline" }> {
length: number;
}

Expand Down

0 comments on commit de35ace

Please sign in to comment.