From 8c03879dd2f25dd2880617413cd87e2be430b4df Mon Sep 17 00:00:00 2001 From: Jaeseok Yoon Date: Wed, 13 Dec 2017 22:08:45 +0900 Subject: [PATCH 1/2] Introduce `command line usage` for default command I would like to show command line usage when user type just `$./bacard` So I add command-line-usage package for generate usage contents and then add implement usage in default --- gulpfile.ts | 27 ++++++++++++++++++++++++++- package.json | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gulpfile.ts b/gulpfile.ts index 904a664..2574dc2 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import * as commandLineUsage from 'command-line-usage'; import * as generator from 'generator'; import * as globs from 'globs'; import * as gulp from 'gulp'; @@ -27,7 +28,31 @@ import * as tslint from 'tslint'; import * as ts from 'typescript'; gulp.task('default', () => { - // FIXME(zino): Should print available commands in Bacardi. + const sections: {} = [ + { + header: 'Bacardi', + content: 'Bacardi project is an effort to provide multi-language ' + + 'binding for Node.js native layer.' + }, + { + header: 'Synopsis', + content: '$ bacardi ' + }, + { + header: 'Available Commands', + content: [ + { name: 'build', summary: 'Builds bacardi project' }, + { name: 'build_electron', summary: 'Builds bacardi project as ' + + 'electron' }, + { name: 'electron', summary: 'Runs bacardi project as electron' }, + { name: 'test', summary: 'Runs Unit test bacardi project' } + ] + } + ]; + + const usage: commandLineUsage = commandLineUsage(sections); + process.stdout.write(usage); + return; }); diff --git a/package.json b/package.json index 5d1f350..d27ab21 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@types/node": "^8.0.24", "@types/through2": "^2.0.33", "bindings": "^1.3.0", + "command-line-usage": "^4.0.2", "change-case": "^3.0.1", "electron": "^1.7.8", "electron-rebuild": "^1.6.0", From 66ee5e5b32a171fb23d8dc7e03cc89e31ac2479e Mon Sep 17 00:00:00 2001 From: Jaeseok Yoon Date: Thu, 4 Jan 2018 00:27:26 +0900 Subject: [PATCH 2/2] Add reader file as a lint check target. Our lint_ts command do not include reader file. So we cannot check lint error in reader file. So I add it. But It is hard to fix no-relative-imports rule. So I would like to this rule disable temporary, Could anyone help me 'how to fix the rule issue?' ISSUE=None --- generator/reader/simple_reader.ts | 20 ++++++++++---------- tslint.json | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/generator/reader/simple_reader.ts b/generator/reader/simple_reader.ts index 9df6ca3..9f05031 100644 --- a/generator/reader/simple_reader.ts +++ b/generator/reader/simple_reader.ts @@ -16,20 +16,20 @@ import * as file from '../base/file'; -export async function readAll(idl_files: string[]): +export async function readAll(idlFiles: string[]): Promise<[string, string][]> { - let read_tasks: Promise[] = []; - idl_files.forEach((idl_file: string) => { - read_tasks.push(file.read(idl_file)); + const readTasks: Promise[] = []; + idlFiles.forEach((idlFile: string) => { + readTasks.push(file.read(idlFile)); }); - let idl_contents: string[] = await Promise.all(read_tasks); - // assert idl_files.length == idl_contents.length; + const idlContents: string[] = await Promise.all(readTasks); + // assert idlFiles.length == idlContents.length; - let idl_fragments: [string, string][] = []; - for (let i: number = 0; i < idl_files.length; i++) { - idl_fragments.push([idl_files[i], idl_contents[i]]); + const idlFragments: [string, string][] = []; + for (let i: number = 0; i < idlFiles.length; i += 1) { + idlFragments.push([idlFiles[i], idlContents[i]]); } - return idl_fragments; + return idlFragments; } diff --git a/tslint.json b/tslint.json index ec72305..23d899a 100644 --- a/tslint.json +++ b/tslint.json @@ -8,6 +8,7 @@ "match-default-export-name": false, "max-line-length": [true, 80], "no-banned-terms": false, + "no-relative-imports": false, "no-reserved-keywords": false, "no-stateless-class": false, "no-suspicious-comment": false,