Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

pull from remote #2

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

Merged
merged 33 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b72d4d6
move plugins' specific data into separate dirs.
skygragon Oct 28, 2018
9f5db49
Bump to 2.5.3
skygragon Oct 28, 2018
657c6c5
fixes #130: create home dir if necessary
skygragon Nov 17, 2018
61becf9
[refactor] extract into file utils
skygragon Nov 17, 2018
d9e07e4
Embed meta in comment instead of filename.
skygragon Nov 18, 2018
aca4609
Update dev dependecies.
skygragon Nov 18, 2018
c20b0d9
Update dependencies.
skygragon Nov 18, 2018
045528e
Bump to 2.5.4
skygragon Nov 18, 2018
fb5f597
fixes #112: use "--" as comment in sql file
skygragon Nov 18, 2018
167fa23
[refactor] simplify template format.
skygragon Nov 18, 2018
e7ac6a6
refs #121: support customized filename.
skygragon Nov 18, 2018
6b2d514
[refactor] use file utils.
skygragon Nov 18, 2018
196cf50
fixes typo in filename.
skygragon Nov 18, 2018
10e8018
[pkg] add pkg config.
skygragon Nov 18, 2018
a37018d
[plugin] enable/disable wont touch plugins js.
skygragon Nov 18, 2018
73bf1a9
fixes plugin init order issue.
skygragon Nov 18, 2018
465b3c3
[plugin] always enable builtin plugin by default.
skygragon Nov 18, 2018
98d9a2f
[pkg] add script for linux/macos
skygragon Nov 19, 2018
863157a
fixes format in `list`
skygragon Nov 19, 2018
e3f108b
fixes UT issues on windows.
skygragon Nov 23, 2018
c957d78
[travis] enable more platforms
skygragon Nov 20, 2018
a3b384f
[pkg] refactor script for linux
skygragon Nov 24, 2018
fc4f4ac
[pkg] add script for windows
skygragon Nov 24, 2018
450f85a
exit with error code if necessary
skygragon Nov 24, 2018
7704e11
[pkg] bail out if error occurs
skygragon Nov 24, 2018
70179c8
[pkg] build from travis
skygragon Nov 24, 2018
24b85ea
Bump to 2.6.0
skygragon Nov 24, 2018
b5a5cfa
[pages] update docs.
skygragon Nov 24, 2018
bd80b3a
expose more code to plugins.
skygragon Nov 25, 2018
aaf6451
remove sprintf-js
skygragon Nov 25, 2018
168b0f4
fixes UT bug.
skygragon Nov 25, 2018
c95cea8
refs #134: remove whitespace on windows.
skygragon Nov 30, 2018
99f921e
Bump to 2.6.1
skygragon Dec 3, 2018
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
.git
.github
.npm
.nyc_output
.DS_Store

coverage
dist
node_modules
npm-debug.log*
tmp

*.log
*.swp
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
"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, // we use it on purpose
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jspm_packages
# Optional REPL history
.node_repl_history

dist/
tmp/
*.swp
.DS_Store
23 changes: 22 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
language: node_js
node_js:
- stable
- 10

os:
- linux
- osx
- windows

install:
- npm install

script:
- npm test
- if [ -n "$TRAVIS_TAG" ]; then npm run travis; fi

deploy:
provider: releases
api_key:
secure: "ayYe6HlYFrFposeIh2xX1DbdF3CRFnAHM5VvdtfVh/TtpcEvg4GRCanvzaSvsVajLjFZOZhGVgm+uZ1H6ba6jQuoOUvFJ667EVwQk7c8KDJrvZIMvzMxCgvSHb6N8VBh/5svWYa+7Kbd++3WP7XmkLpWli/DXvOSu6I6M7w+m/OI157mWPp0a7iy+Q+o1vSl/3INNIrd/vMT5F+ae1iBLFn3aHndtezhdQr+HrQCHaVP8OiK96rtjzaiRp+dyoMf4U71LoJGRpGZURv9imyXholoQutlT+bhRaumPqrqiwFRGMaL+xhfBZMySMND8wcO9rQnabiQf5Wo9J5aJMnixWjEIg9gGhJ8E96j9VwdUBA7yfHAbVhLrQ0h2TkZuUdqU1EnOWIbnPtjC9exv8R5X2WRs1fMz9j+XpNYclB4YdLclQ662nfsquccqfksDG1rS249WkSl1RIxr9fcD+60xYXgkG78wrTN8cr9NMGk5/AyMyHcvYjA+rGg1V8DZhzC3WZn9Q0NRJoc3b+xx9pxkaO7epBck5sAsNPO8b/bMGGKmgmR5tKSZUN+lTUKLI2znJcUC1dMKKpRCqr1To94ZYVe0G7SFbe+MH4guQXkd7sB6GnsR8/7g8OsVcAtV4DoEWfHwJQIE0bg/UzqubyBPSGPs1JBZm8nks/zTpOJ65o="
file: leetcode-cli.*
file_glob: true
skip_cleanup: true
overwrite: true
on:
tags: true
20 changes: 20 additions & 0 deletions bin/pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const arch = require('os').arch();
var os = process.platform;
const ver = process.versions.node.split('.')[0];

var bin = './bin/pkg.sh';
var args = [arch, os, ver];

if (os === 'darwin') {
args[1] = 'macos';
} else if (os === 'win32') {
bin = 'cmd.exe';
args = ['/c', 'bin\\pkg.bat'].concat(args);
}

var proc = require('child_process').spawn(bin, args);
proc.stdout.on('data', x => console.log(x.toString().trimRight('\n')));
proc.stderr.on('data', x => console.log(x.toString().trimRight('\n')));
proc.on('close', process.exit);
25 changes: 25 additions & 0 deletions bin/pkg.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off
set arch=%1
set os=%2
set ver=%3

set dist=dist\
set file=leetcode-cli.node%ver%.%os%.%arch%.zip

mkdir %dist%
del /q %dist%\*
del /q *.zip

for %%x in (company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss) do (
echo [%%x]
node bin\leetcode ext -i %%x
if %ERRORLEVEL% gtr 0 exit /b 1
)

for /r . %%x in (*.node) do copy %%x %dist%
call npm run pkg -- node%ver%-%os%-%arch%
if %ERRORLEVEL% gtr 0 exit /b 1

7z a %file% %dist%
if %ERRORLEVEL% gtr 0 exit /b 1
exit 0
26 changes: 26 additions & 0 deletions bin/pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -e

arch=$1
os=$2
ver=$3

DIST=./dist
FILE=leetcode-cli.node$ver.$os.$arch.tar.gz

mkdir -p $DIST
rm -rf $DIST/*
rm -rf $FILE

plugins="company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss"

for plugin in $plugins; do
echo "[$plugin]"
./bin/leetcode ext -i $plugin
done

find node_modules -name "*.node" -exec cp {} $DIST \;
npm run pkg -- node$ver-$os-$arch

tar zcvf $FILE $DIST
ls -al $FILE
exit 0
23 changes: 23 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: Advanced Topic
* [Cache](#cache)
* [Configuration](#configuration)
* [Color Themes](#color-themes)
* [File Name](#file-name)
* [Log Levels](#log-levels)
* [Plugins](#plugins)

Expand Down Expand Up @@ -91,6 +92,10 @@ The config file is saved in `~/.lc/config.json`, here is a full exmaple (include
"enable": true,
"theme": "default"
},
"file": {
"show": "${fid}.${slug}",
"submission": "${fid}.${slug}.${sid}.${ac}"
},
"icon": {
"theme": ""
},
Expand All @@ -107,6 +112,7 @@ Here are some useful settings:
* `code:lang` to set your default language used in coding.
* `color:enable` to enable colorful output.
* `color:theme` to set color theme used in output. (see [Color Theme](#color-theme))
* `file.show` to set filename pattern for generated code file. (see [File Name](#file-name))
* `icon:theme` to set icon them used in output.
* `plugins` to config each installed plugins. (see [Plugins](#plugins))

Expand Down Expand Up @@ -167,6 +173,23 @@ Of course you can create your own themes if you like, look into `colors` folder
"yellow": "#ffff00"
}

# File Name

You could configure file name pattern in code generation.

* config `file.show` for generated file in `show`.
* config `file.submission` for downloaded file in `submission`.

Followings are some variables you could used in the pattern:

* `${fid}` for question id. (e.g. `123`)
* `${slug}` for dash-separated question name. (e.g. `add-two`)
* `${name}` for space-separated questions name. (e.g. `Add Two`)
* `${level}` for question level. (e.g. `Hard`)
* `${category}` for question category. (e.g. `algorithms`)
* `${sid}` for submission id.
* `${ac}` for accept status of existing submission.

# Log Levels

* `-v` to enable debug output.
Expand Down
4 changes: 2 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Display version information.
Short:

$ leetcode version
2.5.2
2.6.1

Verbose:

Expand All @@ -475,7 +475,7 @@ Verbose:
| | ___ ___| |_ ___ ___ __| | ___
| |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \
| | __/ __/ |_ (__| (_) | (_| | __/
|_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.5.2
|_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.1

[Environment]
Node v8.1.4
Expand Down
11 changes: 11 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ layout: default
title: Installation
---

# All in One (beta)

No need to install node.js. Now available on 64bits linux, mac, and windows.

[Download](https://github.com/skygragon/leetcode-cli/releases)

# Prerequisites

Install the latest LTS version of `node.js` (`npm` included):
Expand Down Expand Up @@ -49,6 +55,11 @@ Similar with above, while you can introduce your own changes as you wish.
$ cd leetcode-cli && ./bin/install
$ leetcode version

### From source (all-in-one)

$ git clone http://github.com/skygragon/leetcode-cli
$ cd leetcode-cli && node ./bin/pkg

### From docker

NOTE: This is just a tiny taste to let you feel that leetcode-cli is. Please use other ways above to install leetcode-cli if you like it.
Expand Down
26 changes: 26 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
layout: default
title: Release Notes
---
# 2.6.1
* `submit`
* fixes 500 error on windows.

# 2.6.0
* build all-in-one binary for linux/macos/windows.
* `show`
* support customized filename.
* use "--" as comment in sql file.
* `list`
* fixes format issue.
* fixes UT failures on windows.

# 2.5.4
* fixes error in fresh env without .lc existed.
* embed meta in file content instead of file name.
* update dependencies.

# 2.5.3

* fixes "Failed to load locked problem" issue.
* move plugin's data into separate folders:
* login info
* problems list
* problem cache

# 2.5.2

* `show`
Expand Down
1 change: 1 addition & 0 deletions icons/ascii.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"like": "*",
"unlike": " ",
"lock": "$",
"nolock": " ",
"empty": " ",
"ac": "O",
"notac": "X",
Expand Down
1 change: 1 addition & 0 deletions icons/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"like": "★",
"unlike": "☆",
"lock": "🔒",
"nolock": " ",
"empty": " ",
"ac": "▣",
"notac": "▤",
Expand Down
1 change: 1 addition & 0 deletions icons/win7.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"like": "♥",
"unlike": " ",
"lock": "$",
"nolock": " ",
"empty": " ",
"ac": "O",
"notac": "X",
Expand Down
25 changes: 12 additions & 13 deletions lib/cache.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
'use strict';
var fs = require('fs');
var path = require('path');

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

const cache = {};

cache.init = function() {
h.mkdir(h.getCacheDir());
file.mkdir(file.cacheDir());
};

cache.get = function(k) {
const fullpath = h.getCacheFile(k);
if (!fs.existsSync(fullpath)) return null;
const fullpath = file.cacheFile(k);
if (!file.exist(fullpath)) return null;

return JSON.parse(fs.readFileSync(fullpath));
return JSON.parse(file.data(fullpath));
};

cache.set = function(k, v) {
const fullpath = h.getCacheFile(k);
fs.writeFileSync(fullpath, JSON.stringify(v));
const fullpath = file.cacheFile(k);
file.write(fullpath, JSON.stringify(v));
return true;
};

cache.del = function(k) {
const fullpath = h.getCacheFile(k);
if (!fs.existsSync(fullpath)) return false;
const fullpath = file.cacheFile(k);
if (!file.exist(fullpath)) return false;

fs.unlinkSync(fullpath);
file.rm(fullpath);
return true;
};

cache.list = function() {
return fs.readdirSync(h.getCacheDir())
return file.list(file.cacheDir())
.filter(x => path.extname(x) === '.json')
.map(function(filename) {
const k = path.basename(filename, '.json');
const stat = fs.statSync(h.getCacheFile(k));
const stat = file.stat(file.cacheFile(k));
return {
name: k,
size: stat.size,
Expand Down
5 changes: 3 additions & 2 deletions lib/chalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var _ = require('underscore');
var style = require('ansi-styles');
var supportsColor = require('supports-color');

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

const chalk = {
enabled: supportsColor.stdout,
use256: supportsColor.stdout && supportsColor.stdout.has256,
Expand Down Expand Up @@ -54,8 +56,7 @@ chalk.wrap = function(pre, post) {
const bgName = x => 'bg' + x[0].toUpperCase() + x.substr(1);

chalk.init = function() {
const h = require('./helper');
for (let f of h.getCodeDirData('colors')) {
for (let f of file.listCodeDir('colors')) {
const theme = {};
const data = _.extendOwn({}, DEFAULT, f.data);
for (let x of _.pairs(data)) {
Expand Down
Loading