Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: plugin pack command for 2 #916

Merged
merged 60 commits into from
Nov 6, 2024
Merged

chore: plugin pack command for 2 #916

merged 60 commits into from
Nov 6, 2024

Conversation

tasshi-me
Copy link
Member

@tasshi-me tasshi-me commented Oct 24, 2024

Why

Support plugin manifest v2.

What

  • refactor plugin module
  • support manifest v2
  • add plugin info command

How to test

Manual test example:

## Prepare plugin project to /tmp/hello-kintone

## Build cli-kintone
pnpm install
pnpm build

## Show pack --help
node cli.js plugin pack --help

## Run pack command
node cli.js plugin pack --input /tmp/hello-kintone/src/ --output /tmp/dist/plugin.zip

ls /tmp/dist # => plugin.zip and .ppk exist

## Run pack command with ppk file
node cli.js plugin pack --input /tmp/hello-kintone/src/ --output /tmp/dist/plugin-2.zip --private-key /tmp/dist/*.ppk

ls /tmp/dist # => plugin.zip, plugin-2.zip, and .ppk exist

## Run info command
node cli.js plugin info --input /tmp/dist/plugin.zip # => printing plugin id, name, etc.

Checklist

  • Read CONTRIBUTING.md
  • Updated documentation if it is required.
  • Added/updated tests if it is required. (or tested manually)
  • Passed pnpm lint and pnpm test on the root directory.

@tasshi-me
Copy link
Member Author

tasshi-me commented Oct 25, 2024

Base automatically changed from feat/plugin-packer to main October 25, 2024 08:15
@tasshi-me tasshi-me force-pushed the feat/plugin-packer-2 branch from 41f2bc3 to 5ec52a6 Compare October 25, 2024 08:27
@tasshi-me tasshi-me force-pushed the feat/plugin-packer-2 branch from c2d994a to 32cafad Compare October 25, 2024 19:26
@tasshi-me tasshi-me force-pushed the feat/plugin-packer-2 branch from 62f1587 to 3312a0f Compare October 28, 2024 16:38
Copy link
Member Author

@tasshi-me tasshi-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

補足コメント書きました。
かなり大胆にリファクタしたので、↓の概念図も参考にしてください! 🙏

image

"node-rsa": "^1.1.1",
"stream-buffers": "^3.0.3",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream-buffersは Node.js 標準の Utility Consumers に置き換えが案内されていたので置き換えた。
https://www.npmjs.com/package/stream-buffers

@@ -112,13 +110,9 @@
"chokidar": "^4.0.1",
"csv-parse": "^4.16.3",
"csv-stringify": "5.6.5",
"debug": "^4.3.7",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug はcli-kintoneのlogger.debug|traceに置き換えた。

"https-proxy-agent": "^7.0.5",
"iconv-lite": "^0.6.3",
"mkdirp": "^3.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.promises.mkdir(data, {recursive: true}) に置き換え

@@ -112,13 +110,9 @@
"chokidar": "^4.0.1",
"csv-parse": "^4.16.3",
"csv-stringify": "5.6.5",
"debug": "^4.3.7",
"execa": "^9.4.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用していたテストを消した。

Comment on lines +1 to +4
export { PublicKey } from "./public-key";
export type { PublicKeyInterface } from "./public-key";
export { PrivateKey } from "./private-key";
export type { PrivateKeyInterface } from "./private-key";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublicKey と PrivateKey は変わることは当面なさそうだしInterfaceを切らなくても良さそう。
(アルゴリズムなどが変わるタイミングでIFを切れば良さそう)


const debug = _debug("packer");

const packer = (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packerの処理はPluginZip.build()に移動した。

import packer from "./index";
import { createContentsZip } from "./create-contents-zip";

export const packPluginFromManifest = (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらもPluginZip.build()に集約

@@ -0,0 +1,29 @@
---
sidebar_position: 1400
draft: true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

draft: trueなのでローカルビルドでした表示されない

* @param stability "experimental" or "deprecated"
* @param message additional information
*/
export const setStability = <T = {}, U = {}>(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/kintone/cli-kintone/pull/915/files#r1815855917 の対応

setStability(cmd, stability, msg) 関数を追加した。
ヘルプメッセージにStabilityが表示され、実行時に警告が出るようになる。


どこかのflagsにstabilityの情報を集約して、それに連動して表示が変わるようにしたかったが、yargsの仕組み上難しそうだった。

コマンドの生成を全てラップするヘルパー関数を置けば実現できるが、既存のレコード系のコマンドにも影響が出るので今回は個別のコマンドをラップする方式にした。

src/plugin/packer/cli.ts Outdated Show resolved Hide resolved
@tasshi-me tasshi-me marked this pull request as ready for review October 28, 2024 16:54
@tasshi-me tasshi-me requested a review from a team as a code owner October 28, 2024 16:54
@tasshi-me tasshi-me requested review from chihiro-adachi and shabaraba and removed request for a team October 28, 2024 16:54
Copy link
Member

@shabaraba shabaraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tasshi-me
いくつかコメントしました!
定義がわかりやすくて処理が追いやすかったです!

src/plugin/core/manifest/interface.ts Show resolved Hide resolved
src/plugin/core/contents/zip.ts Outdated Show resolved Hide resolved
src/plugin/core/plugin/index.ts Show resolved Hide resolved
src/plugin/packer/cli.ts Outdated Show resolved Hide resolved
src/plugin/packer/cli.ts Outdated Show resolved Hide resolved
@tasshi-me tasshi-me force-pushed the feat/plugin-packer-2 branch from 39db43e to 95110a4 Compare November 2, 2024 08:33
Copy link
Member Author

@tasshi-me tasshi-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

レビュー対応

Copy link
Member

@shabaraba shabaraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご対応ありがとうございました!良さそうです!

@tasshi-me tasshi-me merged commit 268817c into main Nov 6, 2024
32 checks passed
@tasshi-me tasshi-me deleted the feat/plugin-packer-2 branch November 6, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants