Upload Plug-in Files using plugin-uploader

Contents

Introduction

This article introduces plugin-uploader, a plug-in development tool designed to make the development of Kintone plug-ins easier by allowing users to upload plug-ins to the Kintone environment through the command line.

What is plugin-uploader?

plugin-uploader is a CLI tool that makes it easy to upload plug-in zip files from your Desktop to Kintone.

It supports npm and can run on Windows, macOS, and Linux.

The source code is published 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 more is required.

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

Installation

Install plugin-uploader globally using the following command. plugin-uploader can also be installed locally, but this tutorial will use the global installation.

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

Basic Usage

Zip files are uploaded to Kintone using plugin-uploader with the kintone-plugin-uploader command and one of three different ways to authenticate the user. These three authentication types are explained below.

In order to execute plugin-uploader, the authenticated user must be at least a Kintone System Administrator. For information on the types of Kintone Administrators, refer to the Types of Kintone Administrators (External link) article from the Kintone Help Center.

Inputting authentication information directly

The subdomain, user login name, password, and plug-in zip file are all specified in the same command. This method is suitable for scheduled processes. Note that the password is not concealed in this command.

1
2
3
4
5
6
7
8
9
$ cd sample_project
$ kintone-plugin-uploader --domain <subdomain>.kintone.com --username <user name> --password <user password> plugin.zip


> Open https://<subdomain>.kintone.com/login?saml=off
> Trying to log in...
> Navigate to https://<subdomain>.kintone.com/k/admin/system/plugin/
> Trying to upload plugin.zip
> plugin.zip has been uploaded!

Inputting authentication information in a dialog style

Specifying only the plug-in zip file in the command will prompt a dialog that will ask the user to input the subdomain, login name, and password individually. The password is concealed in this command.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ cd sample_project
$ kintone-plugin-uploader plugin.zip


# Enter environmental information interactively
? Input your kintone's domain (example.kintone.com): <subdomain>.kintone.com
? Input your username: <user name>
? Input your password: <user password>
> Open https://<subdomain>.kintone.com/login?saml=off
> Trying to log-in...
> Navigate to https://<subdomain>.kintone.com/k/admin/system/plugin/
> Trying to upload plugin.zip
> plugin.zip has been uploaded!

Inputting authentication information using environment variables

Environment variables for the subdomain and login information can be set in advance. This method allows the password (and other environmental information) to be hidden when using the single-line command.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# For Windows(PowerShell)
# Set environment variables with Kintone information in advance
set-item "env:KINTONE_DOMAIN" <subdomain>.kintone.com
set-item "env:KINTONE_USERNAME" <user name>
set-item "env:KINTONE_PASSWORD" <user password>
set-item "env:HTTPS_PROXY or HTTP_PROXY" <proxy settings>

# Command prompt execution
$ cd sample_project
$ kintone-plugin-uploader --domain $env:KINTONE_DOMAIN --username $env:KINTONE_USERNAME --password $env:KINTONE_PASSWORD plugin.zip


# For Mac
# Set environment variables with Kintone information in advance
export KINTONE_DOMAIN=<subdomain>.kintone.com
export KINTONE_USERNAME=<user name>
export KINTONE_PASSWORD=<user password>
export HTTPS_PROXY or HTTP_PROXY=<proxy settings>

# Terminal execution
$ cd sample_project
$ kintone-plugin-uploader --domain $KINTONE_DOMAIN --username $KINTONE_USERNAME --password $KINTONE_PASSWORD plugin.zip

Optional Features

There are also other optional features that can be specified in the command.

Proxy settings

If a proxy server is being used, the proxy information can be entered with --proxy.

1
2
3
4
$ kintone-plugin-uploader --proxy Proxy server plugin.zip

# When environment variable is used
$ kintone-plugin-uploader --proxy $HTTP_PROXY plugin.zip

File monitoring

Plug-in zip files can be uploaded to Kintone each time they are updated using --watch. This option is especially useful for developing plug-ins and checking them immediately after making changes.

1
$ kintone-plugin-uploader --watch plugin.zip

Using plugin-packer and plugin-uploader Together

Plug-in files can be zipped using Package Plug-in Files using plugin-packer , which can be used with plugin-uploader to automate the process of zipping and uploading a modified plug-in source code to Kintone.

Set Up

Open two terminals and follow the below examples.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Change to the directory containing the plug-in file
$ cd sample_project

# Terminal 1
# Run plugin-packer with watch option
$ kintone-plugin-packer --watch src
# => A plugin.zip file is created to monitor changes to the src directory

# Terminal 2
# Run plugin-uploader with watch option
$ kintone-plugin-uploader --watch plugin.zip
# => The plug-in file is uploaded to monitor changes to the src directory

Once the above set up is complete, modifications to the plug-in's source code will automatically be zipped and uploaded to Kintone, and changes can be checked with a simple page refresh.

Finally

With plugin-uploader, zipped plug-in files can be uploaded to Kintone using just the command line, and when used with plugin-packer, the process of developing Kintone plug-ins is even more efficient. Create a simple plug-in from scratch, or use a sample plug-in such as the Date Input Button Plug-in and try using plugin-packer and plugin-uploader.

Important Notes

The operation of this program is not guaranteed.
Modification, redistribution, commercial use, etc. of the source code is subject to the license agreement.