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

k-toolkit-node

v0.1.3

Published

- [Install](#install) - [CLI Usage](#cli-usage) - [API](#api) - [KToolkit](#ktoolkit) - [createProject](#createproject) - [initProject](#initproject) - [initLocalProject](#initlocalproject) - [installPlugin](#installplugin) -

Downloads

2

Readme

KToolkit

Install

npm install k-toolkit-node

CLI Usage

Usage: k-toolkit-node [options] [command]

Options:
  -v, --version                  output the current version
  -p, --project-path <path>      set local config path (default: process.cwd())
  -u, --remote-url <url>         set remote config url (default: "https://s3.shiyou.kingsoft.com/neon/client-framework/ks-framework.json")
  -h, --help                     display help for command

Commands:
  create <projectName>
  init <repositoryUrl>
  init-local
  install-plugin <pluginName>
  uninstall-plugin <pluginName>
  help [command]                 display help for command

API

KToolkit

import { KToolkit } from 'k-toolkit-node';
let toolkit = new KToolkit(...);
toolkit.createProject(...);

createProject

创建一个新工程 | Param | Type | Description | | ----------- | ------ | ------------ | | projectName | string | 工程名称 | | projectPath | string | 工程保存路径 |

initProject

通过Git仓库初始化一个工程 | Param | Type | Description | | ------------- | ------ | ------------ | | repositoryUrl | string | Git仓库地址 | | projectPath | string | 工程保存路径 |

initLocalProject

初始化一个本地已有的工程 | Param | Type | Description | | ----- | ---- | ----------- | | None | None | None |

installPlugin

安装一个插件 | Param | Type | Description | | ---------- | ---------- | ---------------------------- | | pluginName | string | 插件名称 | | pluginInfo | PluginInfo | 插件具体信息,通过Config获取 |

uninstallPlugin

卸载一个插件 | Param | Type | Description | | ---------- | ------ | ----------- | | pluginName | string | 插件名称 |

updatePlugin

更新一个插件 | Param | Type | Description | | ---------- | ------ | ----------- | | pluginName | string | 插件名称 |

utils

import { utils } from 'k-toolkit-node';
utils.renameFiles(...);

renameFiles

递归修改目录、文件名 | Param | Type | Description | | --------- | --------------- | -------------------------------- | | dir | string | 待修改名称根路径 | | from | string / RegExp | 替换前字符 | | to | string | 替换后字符 | | recursive | boolean | 是否递归替换所有子路径,默认true |

exec

childProcess exec的Promise封装 | Param | Type | Description | | ------- | ------------------------- | ------------ | | command | string | 待执行的命令 | | options | child_process.ExecOptions | 命令执行选项 | | returns | promise | 命令执行结果 |

projectNameValidator

项目名称验证函数 | Param | Type | Description | | ----------- | ------------ | ---------------------------------------- | | projectName | string | 项目名称 | | returns | string|null | 名称有效时返回null,无效时返回原因字符串 |

isValidProjectPath

项目路径是否有效(目录不存在或为空目录即有效) | Param | Type | Description | | ----------- | ------- | ------------ | | projectPath | string | 项目路径 | | returns | boolean | 路径是否有效 |

buildLocalConfig

根据配置路径构造本地配置对象 | Param | Type | Description | | ----------- | ------------------------ | ------------ | | projectPath | string | 项目路径 | | returns | LocalConfig | undefined | 本地配置对象 |

downloadRemoteConfig

根据配置地址下载远程配置对象 | Param | Type | Description | | --------------- | ---------------------------------- | ------------ | | remoteConfigUrl | string | 配置地址 | | returns | Promise<RemoteConfig | undefined> | 远程配置对象 |

addToGitIgnore

添加记录到gitignore | Param | Type | Description | | -------------- | ------ | ------------------------------------------------------------------------------------ | | repositoryPath | string | git本地仓库地址 | | ignoreContent | string | 需要添加的ignore内容 | | matchLine | string | 匹配行,找到的话把ignoreContent插到这行后,没找到在文件尾插入该行内容和ignoreContent |

removeFromGitIgnore

从gitignore中移除记录 | Param | Type | Description | | -------------- | ------ | -------------------- | | repositoryPath | string | git本地仓库地址 | | ignoreContent | string | 需要移除的ignore内容 |