kintoneplugin-config-migrator
v0.1.4
Published
"KintonePluginConfigMigrator" is a handy library that allows you to easily export and import plugin configurations to JSON format. With this library, you can save plugin configurations in JSON format for backup purposes or effortless migration to differen
Downloads
11
Readme
KintonePluginConfigMigrator
本ライブラリを利用することで、kintoneプラグインの設定をJSON形式で保存し、バックアップを取ったり、異なる環境へ楽に移行することができます。
設定をエクスポートしてバックアップを作成したり、異なる環境間で設定を簡単に共有する機能を提供します。また、インポート機能を利用すれば、他の環境に設定を即座に適用することができます。
使い方
kintoneプラグインへの適用方法
import { ConfigMigrator } from "kintoneplugin-config-migrator";
(function (PLUGIN_ID: string | undefined) {
// メイン処理
// ...
// ConfigMigratorの初期化とボタンの設置
const migrator = new ConfigMigrator(PLUGIN_ID)
migrator.put_forms('config_body')
})(kintone.$PLUGIN_ID);
kintoneプラグインのメイン処理の中で呼び出せます。コンストラクタに与えるPLUGIN_IDはkintoneプラグインの初期化時に得られる情報を与えてください。
put_forms('config_body')ではインポート/エクスポートボタンを配置します。引数に渡したHTML要素IDにappendChild()する形でボタンを持ったHTML要素を配置します。
プラグイン設定の取得について
kintone APIを使ってファイル保存、ファイル読み込みをしています。特に複雑なことはしていません。
エクスポートの処理
kitnone plugin APIのgetConfig()を使って取得した設定をそのままダウンロードしています。
const CONF = kintone.plugin.app.getConfig(plugin_id);
インポートの処理
同じくkintone plugin APIのsetConfig()でアップロードしたjsonをそのまま格納しています。
const jsonData = JSON.parse(event.target.result);
kintone.plugin.app.setConfig(jsonData, function () {
alert('🆙 プラグイン設定を保存しました。アプリの更新をお忘れなく!');
window.location.href = '../../flow?app=' + kintone.app.getId();
});
License
このライブラリはMITライセンスの元で公開しています。 This plugin is licensed under MIT license.
Copyright (c) 2023 Daisuke Motohashi https://opensource.org/licenses/MIT
このライブラリについて
このライブラリは株式会社モノサスのキン担ラボ活動の一環として作成しました。