Package Plug-in Files using plugin-packer

Contents

Overview

This article introduces "plugin-packer", a plug-in development tool designed to make the development of Kintone plug-ins easier.

What is plugin-packer?

Plugin-packer is a CLI tool that packages the plug-in directory to generate plug-in zip files.
The tool is published on npm and is available for Windows, macOS, and Linux. Find the source code on GitHub (External link) .

Check the engines property in package.json (External link) for the Node.js version requirements.
For example, if the following property is stated, version 10 or higher is required.

1
2
3
"engines": {
  "node": ">=10"
}

Installation

An example of global installation of plugin-packer using npm:

1
$ npm install -g @kintone/plugin-packer

Basic usage

First, arrange the plug-in files as shown in the image below.
The contents and locations of the files are described in the article, Steps for Plug-in Development.

Run the following command to package the files (suppose that the src file lies under the sample_project directory):

1
2
$ cd sample_project
$ kintone-plugin-packer src

Execution sample

Initially, the file tree including the plug-in files should be in this structure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Confirm the directory structure before execution
$ tree
.
└── src
    ├── css
    │   ├── 51-modern-default.css
    │   ├── config.css
    │   └── desktop.css
    ├── html
    │   └── config.html
    ├── image
    │   └── icon.png
    ├── js
    │   ├── config.js
    │   └── desktop.js
    └── manifest.json

Run the following command to package the files within the src file into a plug-in:

1
2
3
4
# Running plugin-packer
$ kintone-plugin-packer src

Succeeded: dir_path/plugin-packer/plugin.zip

The file tree should now be updated into the following structure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Confirm execution result
# => plugin.zip and ppk file are generated
$ tree

.
├── faabchdodajloackbgnipilddblmkejp.ppk
├── plugin.zip
└── src
    ├── css
    │   ├── 51-modern-default.css
    │   ├── config.css
    │   └── desktop.css
    ├── html
    │   └── config.html
    ├── image
    │   └── icon.png
    ├── js
    │   ├── config.js
    │   └── desktop.js
    └── manifest.json

After running the command, a plugin.zip file and a secret key are generated.
This plugin.zip file can be installed into a Kintone domain. (External link)

Optional features

Packaging for the second time

When running the command to package the files for the second time, specify the secret key using the --ppk option.

1
$ kintone-plugin-packer --ppk plugin_key src

Specifying the output directory and file name of the zip file

The output directory and file name of the plug-in zip file can be specified using the --out option.

1
$ kintone-plugin-packer --put ../zip_dir/test.zip src

If the --out option is not specified, a zip file named "plugin.zip" is created under the same directory where the src file is located.

File monitoring

A plug-in zip file can be created automatically at specific timings by monitoring directory changes using --watch.

1
$ kintone-plugin-packer --watch src

To stop monitoring, cancel the command with "Ctrl + c".

The plugin zip file is created/updated at the following times with the --watch command:

  • When the --watch command is first enabled
  • When a file inside the monitored folder is opened
  • When a file inside the monitored folder is saved

If the plug-in zip file already exists, the file will be updated instead of creating duplicates. If the .ppk file (the file created along with the plugin zip file) is deleted while the --watch command is enabled, the plug-in zip file will not be created/updated. In this case, restart the --watch command.

Web version

Plugin-packer is also available on the web. Zip all the directories under the src file into one file, and drag and drop the zip file into the browser to package it.

https://plugin-packer.kintone.dev/ (External link)

Notes

For questions on how to use the plugin-packer tool, post a question in the Kintone Developer Forum (External link) . For reporting bugs and other issues, post it as a GitHub Issue in the plugin-packer repository (External link) . Modification, redistribution, and commercial use of the source code is subject to the license agreement.