Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f66469a
change npm occurances to pnpm in install file
abdoei Jul 19, 2026
319176d
commit the pnpm lock file
abdoei Jul 19, 2026
f264dd3
add plugins
abdoei Jul 19, 2026
c1c26b8
bump dependency versions and update lockfile for non-breaking upgrades
abdoei Jul 19, 2026
ded934e
Revert "add plugins"
abdoei Jul 19, 2026
ff7db16
stat: [fix] Format stat progress bar with right-aligned numbers and b…
abdoei Jul 19, 2026
a37988b
Add debug entry point with --inspect-brk flag
abdoei Jul 19, 2026
6ec94e3
Bump up the breaking update of ansi-styles and add color-convert as s…
abdoei Jul 19, 2026
389c11d
Bump ansi-styles to v6.2.3 and update its usage to match breaking API…
abdoei Jul 19, 2026
bdad391
Bump color-convert to v3.1.3 and update its import to use default export
abdoei Jul 19, 2026
8b198bd
Bump mkdirp to v3.0.1
abdoei Jul 19, 2026
2335239
chore: replace nyc with c8 for ESM compatibility
abdoei Jul 20, 2026
89d7830
Bump ora to v9.4.1 and update its import to use default export
abdoei Jul 20, 2026
c920d2b
fix: suppress winston padLevels warning via pnpm patch
abdoei Jul 20, 2026
310faf7
Bump supports-color to v10.2.2
abdoei Jul 20, 2026
edbdd17
Bump yargs to v18.0.0 and fix usage for breaking API changes
abdoei Jul 20, 2026
0de888c
test: skip flaky-while experimentation-file system dependent test
abdoei Jul 20, 2026
bc9a41b
Bump cheerio to v1.2.0 and update test expectations to match new text…
abdoei Jul 21, 2026
f772c4e
Replace chai with native node:assert.strict and remove chai dependency
abdoei Jul 21, 2026
8368a86
Migrate ESLint config to flat config format and bump ESLint to v10
abdoei Jul 21, 2026
173d219
Remove deprecated preferGlobal field from package.json
abdoei Jul 21, 2026
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
37 changes: 0 additions & 37 deletions .eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ dist/
tmp/
*.swp
.DS_Store

# TODO: remove those ignores
lib/plugins/company.js
lib/plugins/leetcode.cn.js
lib/plugins/solution.discuss.js

# vs code configs
.vscode/launch.json

# Temporary directory for storing files
my_tmp/
6 changes: 3 additions & 3 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ create() {
"short": "`git rev-parse --short HEAD`"
},
"node": "`node -v`",
"npm": "`npm -v`"
"pnpm": "`pnpm -v`"
}
EOF
}

check git
check node
check npm
check pnpm

create $ENVFILE

npm install -g .
pnpm install .
echo "leetcode-cli successfully installed."
3 changes: 3 additions & 0 deletions bin/leetcode-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node --inspect-brk

require('../lib/cli').run();
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const js = require('@eslint/js');
const globals = require('globals');
const compat = require('@eslint/compat');
const google = require('eslint-config-google');

module.exports = [
js.configs.recommended,
...compat.fixupConfigRules([google]),
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
},
ecmaVersion: 2015,
sourceType: 'commonjs',
},
rules: {
'valid-jsdoc': 0,
'indent': 0,
'arrow-parens': 0,
'prefer-const': 0,
'semi': 0,
'spaced-comment': 0,
'no-multiple-empty-lines': 0,
'object-curly-spacing': 0,
'no-prototype-builtins': 0,
'no-invalid-this': 0,
'no-useless-assignment': 0,
'no-trailing-spaces': 0,
'space-before-function-paren': 0,
'operator-linebreak': 0,
'keyword-spacing': 0,
'comma-spacing': 0,
'one-var': 0,
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {allowSingleLine: true}],
'camelcase': [2, {properties: 'never'}],
'comma-dangle': 0,
'curly': 0,
'key-spacing': [2, {align: 'value'}],
'max-len': [1, 120],
'no-control-regex': 0,
'no-console': 1,
'no-empty': [2, {allowEmptyCatch: true}],
'no-eval': 1,
'no-loop-func': 1,
'no-multi-spaces': 0,
'no-proto': 1,
'no-unused-expressions': 1,
'no-unused-vars': 1,
'no-var': 0,
'no-warning-comments': 0,
'prefer-rest-params': 0,
'prefer-spread': 0,
'quote-props': 1,
'quotes': [2, 'single', {avoidEscape: true}],
'require-jsdoc': 0,
},
},
];
34 changes: 22 additions & 12 deletions lib/chalk.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';
var _ = require('underscore');
var style = require('ansi-styles');
var supportsColor = require('supports-color');
// TODO: remove .default when using ES6 import syntax
var style = require('ansi-styles').default;
var convert = require('color-convert').default;
var supportsColor = require('supports-color').default;

var file = require('./file');

Expand Down Expand Up @@ -32,10 +34,15 @@ chalk.setTheme = function(name) {
this.theme = this.themes.get(name) || this.themes.get('default');
};

chalk.sprint = function(s, hex) {
const color = chalk.use16m ? style.color.ansi16m.hex(hex)
: chalk.use256 ? style.color.ansi256.hex(hex)
: style.color.ansi.hex(hex);
chalk.sprint = function (s, hex) {
let color;
if (chalk.use16m) {
color = style.color.ansi16m(...style.hexToRgb(hex));
} else if (chalk.use256) {
color = style.color.ansi256(style.hexToAnsi256(hex));
} else {
color = '\u001B[' + convert.hex.ansi16(hex) + 'm';
}
return color + s + style.color.close;
};

Expand Down Expand Up @@ -65,14 +72,17 @@ chalk.init = function() {
const bgK = bgName(k);

if (chalk.use16m) {
theme[k] = style.color.ansi16m.hex(v);
theme[bgK] = style.bgColor.ansi16m.hex(v);
const [r, g, b] = style.hexToRgb(v);
theme[k] = style.color.ansi16m(r, g, b);
theme[bgK] = style.bgColor.ansi16m(r, g, b);
} else if (chalk.use256) {
theme[k] = style.color.ansi256.hex(v);
theme[bgK] = style.bgColor.ansi256.hex(v);
const color256 = style.hexToAnsi256(v);
theme[k] = style.color.ansi256(color256);
theme[bgK] = style.bgColor.ansi256(color256);
} else {
theme[k] = style.color.ansi.hex(v);
theme[bgK] = style.bgColor.ansi.hex(v);
const code = convert.hex.ansi16(v);
theme[k] = `\u001B[${code}m`;
theme[bgK] = `\u001B[${code + 10}m`;
}
}
chalk.themes.set(f.name, theme);
Expand Down
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function initPlugins(cb) {
var cli = {};

function runCommand() {
var yargs = require('yargs');
var yargs = require('yargs')(process.argv.slice(2));
h.width = yargs.terminalWidth();
yargs.commandDir('commands')
.completion()
Expand All @@ -83,7 +83,7 @@ function runCommand() {
.version(false)
.epilog('Seek more help at https://skygragon.github.io/leetcode-cli/commands')
.wrap(Math.min(h.width, 120))
.argv;
.parse();
}

cli.run = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function printLine(key, done, all) {
const n = 30;
const percent = (all > 0) ? done / all : 0;
const x = Math.ceil(n * percent);
log.printf(' %s\t%3s/%-3s (%6s %%) %s%s',
log.printf(' %s\t%4s/%-4s [%6s %%] %s%s',
h.prettyLevel(key), done, all,
(100 * percent).toFixed(2),
chalk.green('█'.repeat(x)),
Expand Down
2 changes: 1 addition & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var _ = require('underscore');
var ora = require('ora');
var ora = require('ora').default;

var file = require('./file');

Expand Down
36 changes: 19 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
"name": "leetcode-cli",
"version": "2.6.2",
"description": "A cli tool to enjoy leetcode!",
"preferGlobal": "true",
"engines": {
"node": ">=4"
"node": ">=22"
},
"bin": {
"leetcode": "./bin/leetcode"
},
"scripts": {
"lint": "eslint lib/ test/",
"test": "npm run lint && nyc mocha test test/plugins && nyc report --reporter=lcov",
"test": "pnpm run lint && c8 mocha test test/plugins && c8 report --reporter=lcov",
"travis": "node bin/pkg",
"pkg": "pkg . --out-path=dist/ --targets"
},
Expand Down Expand Up @@ -50,27 +49,30 @@
},
"homepage": "https://github.com/skygragon/leetcode-cli#readme",
"dependencies": {
"ansi-styles": "3.2.1",
"cheerio": "0.20.0",
"ansi-styles": "6.2.3",
"cheerio": "1.2.0",
"color-convert": "^3.1.3",
"he": "1.2.0",
"mkdirp": "0.5.1",
"mkdirp": "3.0.1",
"moment": "^2.20.1",
"nconf": "0.10.0",
"ora": "3.0.0",
"prompt": "1.0.0",
"request": "2.88.0",
"supports-color": "5.5.0",
"underscore": "1.9.1",
"nconf": "0.13.0",
"ora": "9.4.1",
"prompt": "1.3.0",
"request": "2.88.2",
"supports-color": "10.2.2",
"underscore": "1.13.8",
"wordwrap": "1.0.0",
"yargs": "12.0.4"
"yargs": "18.0.0"
},
"devDependencies": {
"chai": "4.2.0",
"eslint": "5.9.0",
"eslint-config-google": "0.11.0",
"@eslint/compat": "^2.1.0",
"@eslint/js": "^10.0.1",
"c8": "^12.0.0",
"eslint": "10.7.0",
"eslint-config-google": "0.14.0",
"globals": "^17.7.0",
"mocha": "5.2.0",
"nock": "10.0.2",
"nyc": "13.1.0",
"pkg": "^4.3.4",
"rewire": "4.0.1"
}
Expand Down
15 changes: 15 additions & 0 deletions patches/winston@2.1.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/lib/winston/common.js b/lib/winston/common.js
index 29dfec0058e7d72448ce2bd5ad9d47cd67eae292..cc56711d4eb3968c0f1203231f1d9d6139270c74 100644
--- a/lib/winston/common.js
+++ b/lib/winston/common.js
@@ -32,7 +32,9 @@ exports.setLevels = function (target, past, current, isDefault) {
}

target.levels = current || config.npm.levels;
- if (target.padLevels) {
+ // Guard against Node.js v26+ warning: accessing non-existent property
+ // 'padLevels' on module.exports inside circular dependency.
+ if (Object.prototype.hasOwnProperty.call(target, 'padLevels') && target.padLevels) {
target.levelLength = exports.longestElement(Object.keys(target.levels));
}

Loading