npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mornya/cli-libs

v0.20.3

Published

The project of CLI application for mornya.

Downloads

272

Readme

CLI Libs

npm node types downloads license

The project of CLI tools for mornya libraries.

This project has been created by Vessel CLI. For a simple and quick reference about it, click here.

About

CLI 개발에 사용되는 모듈들에 대해 집합적인 형태로 제공되는 패키지.

Installation

해당 라이브러리를 사용 할 프로젝트에서는 아래와 같이 의존성 모듈로 설치한다.

$ npm install --save @mornya/cli-libs
or
$ yarn add @mornya/cli-libs

Modules in the package

본 패키지에는 아래와 같은 모듈들을 포함한다. 제공되는 모듈과 메소드 사용법 등은 코드 스니핏을 참고한다.

Args module

프로세스 실행시 명령줄라인의 파라미터 값을 정제하여 제공한다.

// process.argv 커맨드라인 파라미터를 배열화하여 리턴
function parse(): string[] {}
// 커맨드라인 파라미터에 해당하는 값이 존재하는지 여부 리턴
function has(name: HasName): boolean {}
// 커맨드라인 파라미터에 해당하는 값들이 존재하는지 여부를 모두 체크하여 리턴
function hasAll<Keys extends string, T = KeyValueFlag<Keys>>(names: HasName[]): T {}
// 커맨드라인에서 수행할 액션에 대한 정의(actionMap)를 파라미터로 입력받아,
// 커맨드라인 옵션(process.argv)에 해당하는 action을 반환
function getArguments<Keys extends string>(actionMap: ActionMap<Keys>): IArguments {}

Command module

프로세스 실행 관련 메소드들을 제공한다.

// 동기적 커맨드 실행
function run(
  cmd: string,
  args: IArgs,
  executor?: (message: string, error?: Error) => void,
  hasOutput: boolean = true,
): boolean {}
// 동기적 커맨드 실행 및 결과 문자열을 리턴
function get(cmd: string, args: IArgs): string {}
// 프로젝트 내 사용중인 패키지 매니저가 NPM 혹은 Yarn인지의 여부 리턴
function getPackageManagerInfo(rootPath: string): IPackageManagerInfo {}

Files module

파일처리 관련 메소드들을 제공한다.

// 파일 경로 구분자를 정제
function dir(...names: string[]): string {}
// 입력된 GLOB 형태의 경로 내 매치되는 파일목록을 찾아 리턴
// 매치 별 콜백함수 실행 후 false를 리턴하면 이후 매치 별 콜백은 실행하지 않는다
function getGlob(
  globPath: GlobPath,
  callback: ((item: string, index: number) => boolean | void) = () => {},
): string[] {}
// 프로젝트 실경로 리턴
function getRealPath(): string {}
// 프로젝트 루트 디렉토리로부터 resolve된 경로를 리턴
function resolvePath(...args: string[]): string {}
// 입력 디렉토리 포함 모든 하위 파일/디렉토리 삭제 (rm -rf)
function rimraf(globPath: GlobPath): string[] {}
// 입력 디렉토리 내 모든 하위 파일/디렉토리 삭제
function emptyDir(globPath: GlobPath): string[] {}
// 디렉토리 트리 생성
function mkdirs(dirName: string): void {}
// 파일/디렉토리 이동
function move(srcGlobPath: GlobPath, destPath: string): string[] {}
// 일반/심볼릭링크로 대상 파일 복사
function copy(
  srcGlobPath: GlobPath,
  destPath: string,
  isSymlink: boolean = false,
): string[] {}
// 예외 디렉토리/파일을 제외한 복사
function copyDir(
  srcGlobPath: GlobPath,
  destPath: string,
  exceptFiles: string[] = [],
): string[] {}
// 디렉토리/파일이 존재하는지 여부 리턴
function isExist(dirName: string): boolean {}
// 입력 디렉토리 내 디렉토리/파일이 존재하는지 여부 리턴
function isEmptyDir(dirName: string): boolean {}
// 입력 디렉토리 내 디렉토리/파일 목록을 리턴
function list(dirName: string): string[] {}
// 텍스트 파일 컨텐츠를 읽어 리턴
function read(fileName: string): string {}
// 텍스트 파일 컨텐츠를 읽어 JSON 형태로 리턴
function readJSON<T = {}>(fileName: string): T {}
// 문자열을 텍스트 파일로 저장
function write(fileName: string, value: string): void {}
// 객체를 Prettified JSON 형태로 저장
function writePrettyJSON(
  fileName: string,
  value: {},
  maxLineLength: number = 1,
): void {}
// 입력한 디렉토리 내 디렉토리/파일 목록을 얻고 해당 아이템에 대해 콜백 실행
function getDirectoryFiles(
  dirName: string,
  executor: (isDir: boolean, relPath: string, currDir: string, file: string) => boolean | void,
): void {}
// 입력된 targetPaths 중에 존재하는 디렉토리/파일(glob 형태 가능)이 있는 목록만 골라서 리턴
function getFilteredExistPaths(
  rootPath: string,
  targetPathList: string[] = [],
  isOnly: boolean = false,
): string[] {}
// 프로젝트 내 환경설정을 가져오는 용도. 로드되는 위치별 순서:
//   1. "[rootPath]/package.json > [name]" 항목
//   2. "[rootPath]/[filename]" ([filename] 지정시)
//   3. "[rootPath]/[name].config.*"
function getConfig<T>(
  rootPath: string,
  name: string,
  filename?: string,
): GetConfig<T> {}

Icons module

OS에 맞게 변환된 출력용 이모티콘을 제공한다.

import { Icons } from '@mornya/cli-libs';
// 아이콘 출력
console.log(Icons.icon.okay);

Key module

콘솔에서 간단한 키보드 입력 관련 메소드를 제공한다.

// 표준입력을 통해 키입력 이벤트 발생시 콜백 실행
function pressed(callback: Callback): void {}

Log module

콘솔 로그 관련 메소드들을 제공한다.

// 로거 설정
function setLogger(logger: (...args: any[]) => any): void {}
// CLI에서 커서를 보이게 처리
function showCursor(): void {}
// CLI에서 커서를 안보이게 처리
function hideCursor(): void {}
// CLI에서 줄바꿈 처리
function linefeed(): void {}
// 일반 로그 출력
function out(message?: any, ...optionalParams: any[]): void {}
// 정보성 로그 출력
function info(message?: any, ...optionalParams: any[]): void {}
// 단계 로그 출력
function progress(message: string, ...optionalParams: any[]): void {}
// 개발용 로그 출력
function devOnly(message?: string, ...optionalParams: any[]): void {}
// 워치 로그 출력
function watch(message?: any, ...optionalParams: any[]): void {}
// 디버그 로그 출력
function debug(message?: any, ...optionalParams: any[]): void {}
// 경고 로그 출력
function warn(message?: any, ...optionalParams: any[]): void {}
// 오류 로그 출력
function error(message?: any, ...optionalParams: any[]): void {}
// 정상 로그 출력
function okay(message?: string, ...optionalParams: any[]): void {}
// 이상 로그 출력
function bad(message?: string, ...optionalParams: any[]): void {}
// 성공 로그 출력
function success(message?: string, ...optionalParams: any[]): void {}
// 실패 로그 출력
function failure(message?: string, ...optionalParams: any[]): void {}

Minify module

uglify-es 디펜던시를 이용하여 *.js, *.mjs 파일들에 대한 minification을 수행하는 메소드를 제공한다.

// Minification 수행
function run(buildPath: string, options?: Options): Result {}

Upgrade module

애플리케이션 수행 중에 업데이트가 필요한 디펜던시를 체크하여 종료 전에 설치할 수 있도록 하는 기능 등을 제공한다.

// NPM registry에서 현재 패키지의 최신버전을 검색 (npm)
function checkLazyNpm(dep: string): Promise<string> {}
// NPM registry에서 현재 패키지의 최신버전을 검색 (yarn)
function checkLazyYarn(dep: string): Promise<string> {}
// NPM registry에서 최신버전을 검색하여 프로그램 종료 전에 메시지 출력
function checkLazyEmitBeforeExit(
  dep: string,
  currentVersion: string,
  option?: CheckLazyEmitBeforeExitOption,
): void {}

Utils module

기타 유틸성 처리 메소드들을 제공한다.

// baseArray 내 항목들 중 dataArray 내 항목이 있는 경우 제거
function removeArrayDups(
  baseArray: string[] | undefined,
  dataArray: string[] = [],
): string[] | undefined {}
// 객체타입으로 넘어온 파라미터 obj가 값이 존재하는지 여부를 체크
// 존재할 경우 truthy|obj, 그렇지 않을 경우 falsy|undefined 리턴
function hasProps<OT = any, TT = OT, FT = OT>(
  obj: OT,
  truthyValue?: TT,
  falsyValue?: FT,
): OT | TT | FT | undefined {}
// base64 등으로 인코딩 된 data uri 등의 형태(ex: 이미지)를
// 바이너리로 변환하기 위해 UInt8Array 타입으로 리턴.
// 리턴된 값은 바이너리로, fs.writeFileSync 등으로 바로 저장 가능.
function uri2binary(data: string | undefined = ''): Uint8Array {}

Version module

버전 체크 등 메소드들을 제공한다.

// SEMVER 형태의 버전을 서로 비교하여 플래그 값을 리턴
function check(baseVersion: string, currVersion: string): -1 | 0 | 1 {}

Chalk library

터미널 스타일링을 위한 chalk 라이브러리를 제공한다.

Change Log

해당 프로젝트의 CHANGELOG.md 파일 참조.

License

해당 프로젝트의 LICENSE 파일 참조.