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: add plugin pack command (Experimental) #915

Merged
merged 16 commits into from
Oct 25, 2024
Merged

Conversation

tasshi-me
Copy link
Member

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

Why

What

NOTE: Be aware to add co-authors when merging. If co-authors are not automatically set in the commit message, add co-authors manually from co-authored-by.txt of #903 .

How to test

All the automated tests are inherited to /src/plugin/packer/__tests__ from plugin-packer.

Manual test example:

## Prepare plugin project
npx @kintone/create-plugin /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

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.

Co-authored-by: Teppei SATO <[email protected]>
Co-authored-by: Will <[email protected]>
Co-authored-by: teppeis <[email protected]>
Co-authored-by: Teppei Sato <[email protected]>
Co-authored-by: toshihisa-tomatsu <[email protected]>
Co-authored-by: Hiroyuki Anai <[email protected]>
Co-authored-by: renovate[bot] <renovate[bot]@users.noreply.github.com>
Co-authored-by: Toshihisa Tomatsu <[email protected]>
Co-authored-by: WhiteSource Renovate <[email protected]>
Co-authored-by: Hiroyuki ANAI <[email protected]>
Co-authored-by: Sakito Mukai <[email protected]>
Co-authored-by: toshi-toma <[email protected]>
Co-authored-by: sakito <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: shisama <[email protected]>
Co-authored-by: chick-p <[email protected]>
Co-authored-by: Sosuke Suzuki <[email protected]>
Co-authored-by: Hodaka Kasama <[email protected]>
Co-authored-by: Toru Kobayashi <[email protected]>
Co-authored-by: nakajmg <[email protected]>
Co-authored-by: Shingo Yamazaki <[email protected]>
Co-authored-by: shintaroNagata <[email protected]>
Co-authored-by: Shintaro Nagata <[email protected]>
Co-authored-by: piyo <[email protected]>
Co-authored-by: Shin'ya Ueoka <[email protected]>
Co-authored-by: Masashi Hirano <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Nguyen Thai Hung <[email protected]>
Co-authored-by: ryounasso <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: tasshi / Masaharu TASHIRO <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: tuanphamcybozu <[email protected]>
Co-authored-by: hung-nguyen <[email protected]>
Co-authored-by: tuan-pham <[email protected]>
Co-authored-by: trigger-github-actions[bot] <143469140+trigger-github-actions[bot]@users.noreply.github.com>
Co-authored-by: Masaharu TASHIRO <[email protected]>
Co-authored-by: Nguyen Thai Hung <[email protected]>
Co-authored-by: Tuan Pham <[email protected]>
Co-authored-by: trigger-github-actions-release[bot] <143469140+trigger-github-actions-release[bot]@users.noreply.github.com>
Co-authored-by: tasshi / Masaharu Tashiro <[email protected]>
Co-authored-by: nameless-mc <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@tasshi-me tasshi-me changed the title demo: plugin-packer demo: plugin pack command Oct 24, 2024
@tasshi-me tasshi-me changed the title demo: plugin pack command proto: plugin pack command Oct 24, 2024
@tasshi-me tasshi-me changed the title proto: plugin pack command proto: plugin pack command (Experimental) Oct 24, 2024
@tasshi-me tasshi-me changed the title proto: plugin pack command (Experimental) chore: plugin pack command (Experimental) Oct 24, 2024
@tasshi-me tasshi-me changed the title chore: plugin pack command (Experimental) chore: add plugin pack command (Experimental) Oct 24, 2024
@tasshi-me tasshi-me self-assigned this Oct 24, 2024
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.

差分大きいですが、 src/plugin/packer 配下はほぼ plugin-packer のファイルそのままです!

@@ -5,6 +5,7 @@ const config = {
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/src/__tests__/setup.ts",
"<rootDir>/src/plugin/packer/__tests__/helpers/",
Copy link
Member Author

Choose a reason for hiding this comment

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

理想的には__tests__の中であっても*.tests.tsのみを試験対象にするように設定変更する方が良い
が、一旦決め打ちでhelpersを除外している。

@@ -57,6 +57,14 @@ const OVERRIDE_LICENSES_TEXT = {
licensePageUrl:
"https://raw.githubusercontent.com/dominictarr/through/master/LICENSE.MIT",
},
"node-rsa": {
// License text is written in README.md
licenseText: "See https://github.com/rzcoder/node-rsa#license",
Copy link
Member Author

Choose a reason for hiding this comment

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

node-rsaはLICENSEファイルがなく、READMEに直接ライセンス本文が書かれているため、license-managerで抽出できない。
そのためREADMEへのリンクを記載する。

import packageJson from "../../package.json";
import { logHandler, logOptions } from "./logOption";

// eslint-disable-next-line no-unused-expressions
yargs
.command(recordCommand)
// NOTE: Hide the plugin command because it's in very early development.
.command({ ...pluginCommand, describe: false })
Copy link
Member Author

Choose a reason for hiding this comment

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

describe: falseでコマンド非公開になる。

Comment on lines +47 to +48
if (process.env.NODE_ENV === "test") {
console.log(JSON.stringify({ pluginDir: args.input, flags: flags }));
Copy link
Member Author

Choose a reason for hiding this comment

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

ここはplugin-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.

plugin/index.tsと合わせてrecord/index.tsを置く構成に変更

// TODO: Remove this test file
const execa = {} as ExecaMethod<{}>;

describe.skip("bin", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

この試験はコマンドラインオプションの試験なので、一旦Skipにする。
(cli-kintone側のCLIが確定したら修正する)

@tasshi-me tasshi-me marked this pull request as ready for review October 24, 2024 19:54
@tasshi-me tasshi-me requested a review from a team as a code owner October 24, 2024 19:54
@tasshi-me tasshi-me requested review from chihiro-adachi and shabaraba and removed request for a team October 24, 2024 19:54
ReturnType<typeof builder> extends yargs.Argv<infer U> ? U : never
>;

const handler = async (args: Args) => {
Copy link
Member

Choose a reason for hiding this comment

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

Static Badge
今じゃなくて全然いいのですが、今後も開発中の機能で似たようなhandlerを作る事になりそうなので、
flagscallbackから開発中のhandlerを作れるような仕組みがあると良さそうに思いました。

Copy link
Member Author

Choose a reason for hiding this comment

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

後続の #916 で対応します!

packerMock_: typeof packer;
}>;

const cli = (pluginDir: string, options_?: Options) => {
Copy link
Member

Choose a reason for hiding this comment

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

Static Badge
今回のPRのスコープ外と思いますが、メソッド名はrecordと合わせてrunとかのほうが良さそう?

Copy link
Member Author

Choose a reason for hiding this comment

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

後続の #916 で対応します!

@tasshi-me tasshi-me merged commit 9d7ee6c into main Oct 25, 2024
66 checks passed
@tasshi-me tasshi-me deleted the feat/plugin-packer branch October 25, 2024 08:15
@tasshi-me
Copy link
Member Author

The Co-authored-by: list generated by GitHub has automatically removed duplicates.
I confirmed that all original contributors were included in the list before merging.

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