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

test-data-printer

v0.3.24

Published

日本語のそれっぽいテストデータを生成します。

Downloads

43

Readme

test-data-printer

テストデータの自動生成ツールです。 式言語風にデータ型を指定すると、それっぽいデータを吐き出してくれます。

why this?

ダミー生成ツールは世にたくさんありますが、 生成したデータをDBに入れるための整形が手間でしかたない!ということでこれを作りました。

  • EDMファイルからの列定義取得
  • 式言語でのダミーデータ指定

ができます。

requirements

install

    npm install test-data-printer -g

quick start

step1

EDMファイルをもとにして、ダミーデータ指定のためのseedファイルを作成します。 seedファイルはテーブルの数だけ作成されます。

    csvprint seed <edm_file> <seed_dir>

step2 自動生成されたseedファイルに、ダミーデータの指定を書き込みます。

各列にどのようなデータを入れるかを、埋め込みます。 ${}の中に自由にJavaScriptを埋め込めます。 個人情報などのダミーデータは事前に変数・関数として用意されています。

    vi <seed_file>
   /** example **/
   Object.prototype.repeat = function (count) {
       this._repeat = count;
       return this;
   };

   module.exports = {
       /** CSVヘッダー **/
       headers: ["CUST_CODE", "CUST_NAME", "ZIP_CODE", "ADDRESS1", "ADDRESS2", "ADDRESS3", "LAST_UPDATE_DATE", "LAST_UPDATE_USER", ],

       /** データ定義 **/
       entries: [
           {
               //顧客コード
               CUST_CODE: '${padZero(rownum, 4)}',

               //顧客名
               CUST_NAME: '${name.first()}',

               //郵便番号
               ZIP_CODE: '${postal.joiner("");}',

               //住所1
               ADDRESS1: '${address.prefecture()}',

               //住所2
               ADDRESS2: '${address.remain()}',

           }.repeat(1000) //データ件数
       ]
   };

functions

組み込み式の中で使える変数・関数の一覧です。

    "${rownum}" //行番号
    "${name.last()}" //姓
    "${name.first()}" //名
    "${name.last().kana()}" //セイ
    "${name.first().kana()}" //メイ
    "${age}" //年齢
    "${email}" //Email
    "${postal}" //郵便番号
    "${postal.parent()}-${postal.branch()}" //郵便番号(上下個別指定)
    "${address}" //住所
    "${address.prefecture()}" //都道府県
    "${address.detail()}" //以降の住所
    "${address.other()}" //マンション名等
    "${address.prefecture().kana()}" //都道府県カナ
    "${birthday}" //誕生日
    "${birthday.joiner('-')}" //誕生日(ハイフンつながり)
    "${birthday.year}${birthday.month}${birthday.day}" //誕生日(年月日個別)
    "${tel}" //電話番号
    "${tel[0]}-${tel[1]}-${tel[2]}" //電話番号(ハイフンつながり)

    "${toHiragana('カタカナへ')}" //カタカナへ変換
    "${toHiragana('ひらがなへ')}" //ひらがなへ変換
    "${toRomaji('ローマ字へ')}" //ローマ字へ変換
    "${padZero(12, 5)}" //ゼロ埋め(左の例は'00012'となる)
    "${randomInt(0, 100)}" //範囲内のランダムな整数