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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@didid1/d1-core

v0.0.1

Published

provide core functions for d1 kits and plugins

Readme

D1 Core

D1 工程套件或插件核心功能封装。

| 功能模块 | 状态 | 介绍 | | ------- | ---- | --- | | auth |【待开发】| 实现对 SSO 登录的封装 | | camel |【待开发】| 提供对 camel 的对接支持 | | ESLint |【待开发】| 提供 ESLint 接入、检查、格式化 支持 | | logger | 部分👌 | 提供 D1 统一的日志封装 | | notifier |【待开发】| 提供 D1 统一的对外通知 | | userConfig | 👌 | 提供统一的 D1 用户配置的读写功能 | | d1ProjectConfig | 👌 | 提供统一的 D1 工程配置的读写功能 | | gitUtil | 部分👌 | 提供 git 操作封装 | | formatUtil | 👌 | 格式化工具 | | cliPromptUtil | 👌 | CLI 交互封装 | | yamlUtil | 👌 | yaml 类型文件读写封装 | | packageJsonUtil | 👌 | package.json 读写封装 |

功能列表

登录 【待开发】

该模块实现对 SSO 登录的封装,使用方式如下

  const { auth } = require('@didid1/d1-core');
  auth.login().then((result) => {
    // result: {
    // }
    //
  }).catch(err => {
    // ...
  });;
  auth.getUserInfo().then((result) => {
    // result: {
    // }
  }).catch(err => {
    // ...
  });

ESlint 【待开发】

实现 ESLint 接入、检查、格式化 等相关的功能

  const { eslint } = reuqire('@didid1/d1-core');
  eslint.init({
    type: 'react',
    silent: false,
    supportTypeScript: false,
    autoInstallDeps: false,
  });
  // eslintUtil.check(); 待开发
  // eslintUtil.fix(); 待开发

logger 👌

该模块提供 D1 统一的日志封装。

notifier 【待开发】

该模块提供 D1 统一的对外通知。

  const notify = require('@didid1/d1-core');

  notify(information, DChartID);

publish【待开发】

该模块提供统一的 发布 功能封装。

用户配置读写 👌

该模块提供统一的 D1 用户配置的读写功能。

  const { userConfig } = require('@didid1/d1-core');
  userConfig.get('key');
  userConfig.set('key', 'value');

工程配置读写 👌

工程目录目前采用 d1.jsond1.js 双配置方案,其中 json 文件中提供工程基础配置,js 文件提供更灵活的自定义和逻辑处理能力。

此外,d1.js 的优先级更好,会覆盖 d1.json 中的同名配置。

同时,自动化写入的配置,都会写入到 d1.json 中。

  const { projectConfig } = require('@didid1/d1-core');
  projectConfig.getProjectConfig();
  projectConfig.getProjectConfigItem('key');
  projectConfig.setProjectConfig('key', 'value');

分析【待开发】

该模块提供 D1 统一分析工具,用于提供统一的监控分析方案。

工具列表

git 操作【部分完成】

该模块提供对本地 Git 仓库及 remote 仓库的操作。

  const { gitUtil } = require('@didid1/d1-core');
  // 获取当前工程的 git origin 地址
  const gitOrigin = await gitUtil.getGit();
  // 非 git 工程或未设置 origin,return '' 
  console.log(gitOrigin);

Date 日期格式化

  const { formatUtil } = require('@didid1/d1-core');
  // format { Stirng } 时间格式
  // date { Date } 时间对象
  formatUtil('format', new Date());

prompt CLI 交互封装

  const { cliPromptUtil } = require('@didid1/d1-core');
  // true or false 型询问
  const { answer } = await cliPromptUtil.askIfORNot('question', true);
  // 文本输入型询问
  const { answer } = await cliPromptUtil.askForAnswer('question');
  // 密码输入型询问
  const { answer } = await cliPromptUtil.askForPassword('question');
  // 基于正则校验的循环询问
  const { answer } = await cliPromptUtil.askForAnswerValidated('question', /^test$/g, '输入不合法,请重试');

yaml 类型文件读写封装

  const { yamlUtil } = require('@didid1/d1-core');
  // 解析 yaml 文件
  yamlUtil.parseYaml('path-to-file');
  // 覆写 yaml 文件
  yamlUtil.safeDump(obj, 'path-to-file');

packageJson 读写

  const { packageJsonUtil } = require('@didid1/d1-core');
  // 首先执行初始化,再获取相关内容
  console.log(packageJsonUtil.init().getJSON());
  console.log(packageJsonUtil.init().getItem('name'));

发送统计日志

初始化

    // 需要提前传一些参数
  const tracker = new Tracker({
    // 应用名称
    appName: '',
    // 登陆用户
    ID: '',
    // 当前版本
    version: '1.0,0',
  });

统计命令次数

  
  //
  /**
   * 统计命令次数
   * @param {String} cmdName 命令名称
   * @param {Object} args 扩展参数,原样传递到 data 字段中
   */
  async cmdTimes(cmdName, args = {})

统计安装信息

  /**
   * 统计安装信息
   * @param {Object} params 安装信息
   * {
   *  // 当前 Node.js 版本
   *  nodeVersion: ''
   *  // 命令参数
   *  argv: ''
   *  // 是否全局安装,默认: false
   *  isGlobal: true / false
   *  // 其他自定义参数
   *  ...
   * }
   */
  async installInfo(obj = {})

统计错误信息

  /**
   * 统计日志信息(含错误)
   * @param {Object} err 经过 D1 包装过后的对象
   * 格式
   * { name: 'd1',
      msg: 'this is warin',
      time: 2018-12-17T08:19:12.318Z,
      levelName: 'WARN ' }
    */
  async log(errObj)