1.1.0 • Published 1 year ago

apitable-settings-generator v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

cover

APITable Settings Generator

npm GitHub Workflow Status npm bundle size npm

APITable Settings Generator convert APITable datasheet into JSON data.

For example, you have APITable like this:

nameemojicategory
jack_o_lantern🎃A
christmas_tree🎄B
fireworks🎆A
sparkler🎇C
firecracker🧨D

It will generate JSON settings like this:

{
  "jack_o_lantern": {
    "emoji": "🎃",
    "category": "A"
  },
  "christmas_tree": {
    "emoji": "🎄",
    "category": "B"
  },
  "fireworks": {
    "emoji": "🎆",
    "category": "A"
  },
  "sparkler": {
    "emoji": "🎇",
    "category": "C"
  },
  "firecracker": {
    "emoji": "🧨",
    "category": "D"
  }
}

Use Case

  • Localization
  • Features Flag
  • Software Settings
  • Game Development
  • ......

Usage

APITable Settings Generator provides 3 generated settings format:

  • rows (default)
  • columns
  • array

Assume you have this APITable:

iden_USzh_CN
login_titleLogin APITable中文 APITable
some textsome text en_USsome text zh_CN

APITable Settings Generator generate settings in different mode:

Format: Rows

You have this JSON config file config.json:

[
  {
    "dirName": "./generated",
    "fileName": "i18n.generated.json",
    "tables": {
      {
        "datasheetId": "dstbUhd5coNXQoXFD8",
        "datasheetName": "strings",
        "format": "rows",
        "params": {
        }
      }
    }
  }
]

Run APITable Settings Generator (asg):

# run in bash
npx apitable-settings-generator --config config.json --token ${HERE_IS_YOUR_APITABLE_TOKEN}

Generated settings i18n.generated.json:

{
  "strings": {
    "login_title": {
      "en_US": "Login APITable",
      "zh_CN": "中文APITable"
    },
    "some text": {
      "en_US": "some text en_US",
      "zh_CN": "some text zh_CN"
    }
  }
}

Format: Columns

You have this JSON config file config.json:

[
  {
    "dirName": "./generated",
    "fileName": "i18n.generated.json",
    "tables": {
      {
        "datasheetId": "dstbUhd5coNXQoXFD8",
        "datasheetName": "strings",
        "format": "columns",
        "params": {
        }
      }
    }
  }
]

Run APITable Settings Generator (asg):

# run in bash
npx asg --config config.json --token ${HERE_IS_YOUR_APITABLE_TOKEN}

Generated settings i18n.generated.json:

{
  "strings": {
    "zh_CN": {
      "login_title": "中文APITable",
      "some text": "some text zh_CN"
    },
    "en_US": {
      "login_title": "Login APITable",
      "some text": "some text en_US"
    }
  }
}

Format: Array

You have this JSON config file config.json:

[
  {
    "dirName": "./generated",
    "fileName": "i18n.generated.json",
    "tables": {
      {
        "datasheetId": "dstbUhd5coNXQoXFD8",
        "datasheetName": "strings",
        "format": "array",
        "params": {}
      }
    }
  }
]

Run APITable Settings Generator (asg):

# run in bash
npx apitable-settings-generator --config config.json --token ${HERE_IS_YOUR_APITABLE_TOKEN}

Generated settings i18n.generated.json:

{
  "strings": [
    {
      "id": "login_title",
      "en_US": "Login APITable",
      "zh_CN": "中文APITable"
    },
    {
      "id": "some text",
      "en_US": "some text en_US",
      "zh_CN": "some text zh_CN"
    }
  ]
}

Conventions

We make some convetion that help you do more magic work:

  • Ignore the column that name starts with .;
  • Ignore the Primary Key that valut starts with .;

If you want to more features, please new an issue for us.

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago