From 1b217b9fcee57bb9d8df0f320b06689cfd45d9eb Mon Sep 17 00:00:00 2001 From: zeke Date: Tue, 8 Jan 2019 22:27:18 -0500 Subject: [PATCH 01/10] minor spelling update --- lib/commands/plugin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/commands/plugin.js b/lib/commands/plugin.js index 78a966b5..ca5a9cff 100644 --- a/lib/commands/plugin.js +++ b/lib/commands/plugin.js @@ -52,10 +52,10 @@ const cmd = { .example(chalk.yellow('leetcode plugin company'), 'Show company plugin') .example(chalk.yellow('leetcode plugin company -c'), 'Show config of company plugin') .example('', '') - .example(chalk.yellow('leetcode plugin -i'), 'Install all missing plugins from GtiHub') - .example(chalk.yellow('leetcode plugin -i company'), 'Install company plugin from GtiHub') + .example(chalk.yellow('leetcode plugin -i'), 'Install all missing plugins from GitHub') + .example(chalk.yellow('leetcode plugin -i company'), 'Install company plugin from GitHub') .example(chalk.yellow('leetcode plugin -d company'), 'Disable company plugin') - .example(chalk.yellow('leetcode plugin -e company'), 'Enable comapny plugin') + .example(chalk.yellow('leetcode plugin -e company'), 'Enable company plugin') .example(chalk.yellow('leetcode plugin -D company'), 'Delete company plugin'); } }; From 8dc0b2ab9b04771bfeef29f02e52371ff8f16db6 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sun, 3 Feb 2019 11:31:08 +0800 Subject: [PATCH 02/10] refs #139: customized delay before next try Signed-off-by: Eric Wang --- lib/config.js | 3 ++- lib/plugins/leetcode.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/config.js b/lib/config.js index cd849fae..a427b8f3 100644 --- a/lib/config.js +++ b/lib/config.js @@ -68,7 +68,8 @@ const DEFAULT_CONFIG = { theme: '' }, network: { - concurrency: 10 + concurrency: 10, + delay: 1 }, plugins: {} }; diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index 373aadfe..0ce3a66e 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -179,7 +179,7 @@ function runCode(opts, problem, cb) { opts.headers.Origin = config.sys.urls.base; opts.headers.Referer = problem.link; opts.json = true; - opts._delay = opts._delay || 1; // in seconds + opts._delay = opts._delay || config.network.delay || 1; // in seconds opts.body = opts.body || {}; _.extendOwn(opts.body, { From 694c42a5a3b22334fa1744d53a5910e32ffe0644 Mon Sep 17 00:00:00 2001 From: PoppinL Date: Fri, 22 Feb 2019 12:05:19 +0800 Subject: [PATCH 03/10] add kotlin in language param --- docs/commands.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/commands.md b/docs/commands.md index 2eda14a7..703f211b 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -234,6 +234,7 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g * golang * java * javascript + * kotlin * mysql * python * python3 From 464257cdd0c242e820f1b8237e3782e89f5ff29c Mon Sep 17 00:00:00 2001 From: PoppinL Date: Tue, 26 Feb 2019 11:29:00 +0800 Subject: [PATCH 04/10] feat: add php lang --- lib/config.js | 1 + lib/helper.js | 1 + test/test_helper.js | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/config.js b/lib/config.js index a427b8f3..373b9f0f 100644 --- a/lib/config.js +++ b/lib/config.js @@ -22,6 +22,7 @@ const DEFAULT_CONFIG = { 'javascript', 'kotlin', 'mysql', + 'php', 'python', 'python3', 'ruby', diff --git a/lib/helper.js b/lib/helper.js index c2085134..8806086e 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -39,6 +39,7 @@ const LANGS = [ {lang: 'javascript', ext: '.js', style: 'c'}, {lang: 'kotlin', ext: '.kt', style: 'c'}, {lang: 'mysql', ext: '.sql', style: '--'}, + {lang: 'php', ext: '.php', style: 'c'}, {lang: 'python', ext: '.py', style: '#'}, {lang: 'python3', ext: '.py', style: '#'}, {lang: 'ruby', ext: '.rb', style: '#'}, diff --git a/test/test_helper.js b/test/test_helper.js index 6eb6e106..143bda9e 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -128,12 +128,13 @@ describe('helper', function() { assert.equal(h.langToExt('java'), '.java'); assert.equal(h.langToExt('javascript'), '.js'); assert.equal(h.langToExt('mysql'), '.sql'); + assert.equal(h.langToExt('php'), '.php'); assert.equal(h.langToExt('python'), '.py'); assert.equal(h.langToExt('python3'), '.py'); assert.equal(h.langToExt('ruby'), '.rb'); + assert.equal(h.langToExt('rust'), '.rs'); assert.equal(h.langToExt('scala'), '.scala'); assert.equal(h.langToExt('swift'), '.swift'); - assert.equal(h.langToExt('rust'), '.rs'); }); }); // #langToExt @@ -146,13 +147,14 @@ describe('helper', function() { assert.equal(h.extToLang('../file.go'), 'golang'); assert.equal(h.extToLang('file.java'), 'java'); assert.equal(h.extToLang('c:/file.js'), 'javascript'); + assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql'); + assert.equal(h.extToLang('~/leetcode/hello.php'), 'php'); assert.equal(h.extToLang('c:/Users/skygragon/file.py'), 'python'); assert.equal(h.extToLang('~/file.rb'), 'ruby'); + assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust'); assert.equal(h.extToLang('/tmp/file.scala'), 'scala'); assert.equal(h.extToLang('~/leetcode/file.swift'), 'swift'); - assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql'); assert.equal(h.extToLang('/home/skygragon/file.dat'), 'unknown'); - assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust'); }); }); // #extToLang @@ -170,9 +172,11 @@ describe('helper', function() { assert.deepEqual(h.langToCommentStyle('java'), C_STYLE); assert.deepEqual(h.langToCommentStyle('javascript'), C_STYLE); assert.deepEqual(h.langToCommentStyle('mysql'), SQL_STYLE); + assert.deepEqual(h.langToCommentStyle('php'), C_STYLE); assert.deepEqual(h.langToCommentStyle('python'), RUBY_STYLE); assert.deepEqual(h.langToCommentStyle('python3'), RUBY_STYLE); assert.deepEqual(h.langToCommentStyle('ruby'), RUBY_STYLE); + assert.deepEqual(h.langToCommentStyle('rust'), C_STYLE); assert.deepEqual(h.langToCommentStyle('scala'), C_STYLE); assert.deepEqual(h.langToCommentStyle('swift'), C_STYLE); }); From 04250608ea5d12d8eef1caf99b0d3890da15abe7 Mon Sep 17 00:00:00 2001 From: PoppinL Date: Tue, 26 Feb 2019 11:32:11 +0800 Subject: [PATCH 05/10] docs: add php in commands doc --- docs/commands.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/commands.md b/docs/commands.md index 2eda14a7..c8467e14 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -235,6 +235,7 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g * java * javascript * mysql + * php * python * python3 * ruby From fe9a9a916ca6a7aad05db53d21dc68f5fdc30abf Mon Sep 17 00:00:00 2001 From: Le Beier Date: Sun, 7 Jul 2019 21:36:39 +0800 Subject: [PATCH 06/10] fixed the row number format for `leetcode stat -g` --- lib/commands/stat.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/commands/stat.js b/lib/commands/stat.js index 3c51ab98..772499c4 100644 --- a/lib/commands/stat.js +++ b/lib/commands/stat.js @@ -104,7 +104,8 @@ function showGraph(problems) { for (let problem of problems) graph[problem.fid] = ICONS[problem.state] || ICONS.none; - let line = [sprintf(' %03s', 0)]; + let rowNumFormat = ' %04s'; + let line = [sprintf(rowNumFormat, 0)]; for (let i = 1, n = graph.length; i <= n; ++i) { // padding before group if (i % 10 === 1) line.push(' '); @@ -114,7 +115,7 @@ function showGraph(problems) { // time to start new row if (i % (10 * groups) === 0 || i === n) { log.info(line.join(' ')); - line = [sprintf(' %03s', i)]; + line = [sprintf(rowNumFormat, i)]; } } From 9a0e155ea7f095807366f73348df8dcf69b5d1c0 Mon Sep 17 00:00:00 2001 From: Sparkles <34909275+SparklesCN@users.noreply.github.com> Date: Wed, 7 Aug 2019 08:46:02 +0800 Subject: [PATCH 07/10] Update submit.js fixed bug for "[WARN] Failed to get submission beat ratio." --- lib/commands/submit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/submit.js b/lib/commands/submit.js index 7376598b..56f5ed04 100644 --- a/lib/commands/submit.js +++ b/lib/commands/submit.js @@ -76,7 +76,7 @@ cmd.handler = function(argv) { let ratio = 0.0; for (let score of scores) { - if (parseFloat(score[0]) > myRuntime) + if (parseFloat(score[0]) >= myRuntime) ratio += parseFloat(score[1]); } From 4657db67d7834a99aa5049691d5e7d5ade3c157a Mon Sep 17 00:00:00 2001 From: Sparkles <34909275+SparklesCN@users.noreply.github.com> Date: Wed, 7 Aug 2019 08:46:45 +0800 Subject: [PATCH 08/10] Update leetcode.js fixed bug for "[WARN] Failed to get submission beat ratio." --- lib/plugins/leetcode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index 0ce3a66e..6624f6d5 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -336,7 +336,7 @@ plugin.getSubmission = function(submission, cb) { let re = body.match(/submissionCode:\s('[^']*')/); if (re) submission.code = eval(re[1]); - re = body.match(/distribution_formatted:\s('[^']+')/); + re = body.match(/runtimeDistributionFormatted:\s('[^']+')/); if (re) submission.distributionChart = JSON.parse(eval(re[1])); return cb(null, submission); }); From 183d62ddd54ae8707fd7ac83829b2233fbe10af2 Mon Sep 17 00:00:00 2001 From: nnnevermore Date: Thu, 19 Sep 2019 21:55:41 +0800 Subject: [PATCH 09/10] Bug fix for Issue #177 I encountered the same bug as Issue#177, so I created this PR. --- lib/plugins/leetcode.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index 0ce3a66e..19afecf4 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -261,7 +261,13 @@ function formatResult(result) { x.expected_answer = result.expected_output; x.stdout = result.std_output; } else { - x.stdout = util.inspect((result.code_output || []).join('\n')); + if (typeof(result.code_output) === 'string') { + x.stdout = util.inspect(result.code_output); + } else if (Array.isArray(result.code_output)) { + x.stdout = util.inspect(result.code_output.join('\n')); + } else { + x.stdout = util.inspect(''); + } } // make sure we pass eveything! From 5245886992ceb64bfb322256b2bdc24184b36d76 Mon Sep 17 00:00:00 2001 From: skygragon Date: Sun, 29 Sep 2019 08:13:44 +0800 Subject: [PATCH 10/10] Bump to 2.6.2 Signed-off-by: skygragon --- docs/commands.md | 4 ++-- docs/releases.md | 4 ++++ package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/commands.md b/docs/commands.md index 0908aec1..1893dbc4 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -467,7 +467,7 @@ Display version information. Short: $ leetcode version - 2.6.1 + 2.6.2 Verbose: @@ -477,7 +477,7 @@ Verbose: | | ___ ___| |_ ___ ___ __| | ___ | |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \ | | __/ __/ |_ (__| (_) | (_| | __/ - |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.1 + |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.2 [Environment] Node v8.1.4 diff --git a/docs/releases.md b/docs/releases.md index 7b78a5f3..77cce5eb 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -2,6 +2,10 @@ layout: default title: Release Notes --- +# 2.6.2 +* `submit` + * fixes beta ratio issue + # 2.6.1 * `submit` * fixes 500 error on windows. diff --git a/package.json b/package.json index ee8f2414..a9af9f7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leetcode-cli", - "version": "2.6.1", + "version": "2.6.2", "description": "A cli tool to enjoy leetcode!", "preferGlobal": "true", "engines": {