@konomi-app/k2 3.2.3 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugin.js CHANGED
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
7
7
  });
8
8
 
9
9
  // src/plugin.ts
10
- import { program as program11 } from "commander";
10
+ import { program as program10 } from "commander";
11
11
 
12
12
  // src/commands/plugin-build.ts
13
13
  import { program } from "commander";
@@ -30,11 +30,11 @@ var DEFAULT_PORT = 32767;
30
30
  // src/lib/import.ts
31
31
  import { pathToFileURL } from "url";
32
32
  import path2 from "path";
33
- var esmImport = (path18) => {
33
+ var esmImport = (path16) => {
34
34
  if (process.platform === "win32") {
35
- return import(pathToFileURL(path18).toString());
35
+ return import(pathToFileURL(path16).toString());
36
36
  } else {
37
- return import(path18);
37
+ return import(path16);
38
38
  }
39
39
  };
40
40
  var importK2PluginConfig = async (configFileName) => {
@@ -114,16 +114,16 @@ var watchTailwindCSS = async (params) => {
114
114
  watcher.on("error", (error) => {
115
115
  console.error("Error watching Tailwind CSS:", error);
116
116
  });
117
- watcher.on("add", (path18) => {
117
+ watcher.on("add", (path16) => {
118
118
  debouncedProcessChanges.call("add");
119
119
  });
120
- watcher.on("change", (path18) => {
120
+ watcher.on("change", (path16) => {
121
121
  debouncedProcessChanges.call("change");
122
122
  });
123
- watcher.on("unlink", (path18) => {
123
+ watcher.on("unlink", (path16) => {
124
124
  debouncedProcessChanges.call("unlink");
125
125
  });
126
- watcher.on("unlinkDir", (path18) => {
126
+ watcher.on("unlinkDir", (path16) => {
127
127
  debouncedProcessChanges.call("unlink");
128
128
  });
129
129
  return watcher;
@@ -272,6 +272,9 @@ async function buildSingleEntry(params) {
272
272
  const config2 = createViteConfig({
273
273
  ...viteConfig,
274
274
  mode,
275
+ esbuild: {
276
+ target: "es2022"
277
+ },
275
278
  build: {
276
279
  ...viteConfig.build,
277
280
  lib: {
@@ -284,6 +287,10 @@ async function buildSingleEntry(params) {
284
287
  ...viteConfig.build?.rollupOptions,
285
288
  output: {
286
289
  assetFileNames: `${name}.[ext]`,
290
+ // IIFEでラップしてグローバルスコープ汚染を防止
291
+ // esbuildのヘルパー関数がグローバルに露出する問題への対策
292
+ banner: "(function() {",
293
+ footer: "})();",
287
294
  // 外部ライブラリのソースマップを無視して警告を抑制
288
295
  sourcemapIgnoreList: (relativeSourcePath) => {
289
296
  return relativeSourcePath.includes("node_modules");
@@ -393,75 +400,18 @@ async function action() {
393
400
 
394
401
  // src/commands/plugin-esbuild.ts
395
402
  import { program as program2 } from "commander";
396
- import fs4 from "fs-extra";
397
- import path6 from "path";
398
- import chalk3 from "chalk";
399
403
  function command2() {
400
- program2.command("esbuild").description("Build the project for production with Vite. (Legacy command name, now uses Vite)").action(action2);
401
- }
402
- async function action2() {
403
- console.group("\u{1F373} Build the project for production");
404
- try {
405
- const config2 = await importK2PluginConfig();
406
- if (config2?.lint?.build) {
407
- await lint();
408
- console.log("\u2728 Lint success.");
409
- }
410
- if (!fs4.existsSync(PLUGIN_CONTENTS_DIRECTORY)) {
411
- await fs4.mkdir(PLUGIN_CONTENTS_DIRECTORY, { recursive: true });
412
- }
413
- const entries = getPluginEntryPoints({
414
- configEntry: path6.resolve("src", "config"),
415
- desktopEntry: path6.resolve("src", "desktop")
416
- });
417
- const entryNames = Object.keys(entries);
418
- if (entryNames.length === 0) {
419
- throw new Error("No entry points found for plugin. Check src/config and src/desktop paths.");
420
- }
421
- console.log(chalk3.gray(` Entry points: ${entryNames.join(", ")}`));
422
- const buildTasks = [];
423
- if (config2.tailwind?.css && config2.tailwind?.config) {
424
- const tailwindConfig = await getTailwindConfig(config2.tailwind);
425
- const inputFile = getTailwindInputCss(config2.tailwind);
426
- buildTasks.push(
427
- outputCss({
428
- inputPath: inputFile.config,
429
- outputPath: path6.join(PLUGIN_CONTENTS_DIRECTORY, "config.css"),
430
- config: tailwindConfig.config,
431
- minify: true
432
- }).then(() => console.log("\u2728 Built config.css")),
433
- outputCss({
434
- inputPath: inputFile.desktop,
435
- outputPath: path6.join(PLUGIN_CONTENTS_DIRECTORY, "desktop.css"),
436
- config: tailwindConfig.desktop,
437
- minify: true
438
- }).then(() => console.log("\u2728 Built desktop.css"))
439
- );
440
- }
441
- buildTasks.push(
442
- buildEntriesWithVite({
443
- entries,
444
- outDir: PLUGIN_CONTENTS_DIRECTORY,
445
- mode: "production",
446
- sourcemap: false,
447
- minify: true
448
- }).then(() => console.log("\u2728 Built desktop.js and config.js"))
449
- );
450
- await Promise.all(buildTasks);
451
- console.log("\u2728 Build success.");
452
- } catch (error) {
453
- throw error;
454
- } finally {
455
- console.groupEnd();
456
- }
404
+ program2.command("esbuild").description(
405
+ "[DEPRECATED] Build the project for production with esbuild. (Use `plugin build` instead.)"
406
+ ).action(action);
457
407
  }
458
408
 
459
409
  // src/commands/plugin-dev/index.ts
460
410
  import { program as program3 } from "commander";
461
411
  import { createServer } from "vite";
462
- import fs11 from "fs-extra";
463
- import path14 from "path";
464
- import chalk6 from "chalk";
412
+ import fs10 from "fs-extra";
413
+ import path13 from "path";
414
+ import chalk5 from "chalk";
465
415
 
466
416
  // src/lib/exec.ts
467
417
  import { exec as defaultExec } from "child_process";
@@ -469,19 +419,19 @@ import { promisify } from "util";
469
419
  var exec = promisify(defaultExec);
470
420
 
471
421
  // src/lib/cert.ts
472
- import fs5 from "fs-extra";
473
- import path7 from "path";
422
+ import fs4 from "fs-extra";
423
+ import path6 from "path";
474
424
  var CERT_KEY_FILENAME = "localhost-key.pem";
475
425
  var CERT_FILENAME = "localhost-cert.pem";
476
426
  var generateCert = async (outDir) => {
477
- await fs5.ensureDir(outDir);
427
+ await fs4.ensureDir(outDir);
478
428
  const { stdout } = await exec(`mkcert localhost 127.0.0.1 ::1`);
479
429
  [
480
430
  { input: "localhost+2.pem", output: CERT_FILENAME },
481
431
  { input: "localhost+2-key.pem", output: CERT_KEY_FILENAME }
482
432
  ].forEach(({ input, output }) => {
483
- if (fs5.existsSync(input)) {
484
- fs5.moveSync(`./${input}`, path7.join(outDir, output), {
433
+ if (fs4.existsSync(input)) {
434
+ fs4.moveSync(`./${input}`, path6.join(outDir, output), {
485
435
  overwrite: true
486
436
  });
487
437
  }
@@ -489,24 +439,24 @@ var generateCert = async (outDir) => {
489
439
  return { stdout };
490
440
  };
491
441
  function hasCertificates(certDir) {
492
- return fs5.existsSync(path7.join(certDir, CERT_KEY_FILENAME)) && fs5.existsSync(path7.join(certDir, CERT_FILENAME));
442
+ return fs4.existsSync(path6.join(certDir, CERT_KEY_FILENAME)) && fs4.existsSync(path6.join(certDir, CERT_FILENAME));
493
443
  }
494
444
  function loadCertificates(certDir) {
495
445
  return {
496
- key: fs5.readFileSync(path7.join(certDir, CERT_KEY_FILENAME)),
497
- cert: fs5.readFileSync(path7.join(certDir, CERT_FILENAME))
446
+ key: fs4.readFileSync(path6.join(certDir, CERT_KEY_FILENAME)),
447
+ cert: fs4.readFileSync(path6.join(certDir, CERT_FILENAME))
498
448
  };
499
449
  }
500
450
 
501
451
  // src/lib/plugin-manifest.ts
502
- import fs6 from "fs-extra";
503
- import path8 from "path";
452
+ import fs5 from "fs-extra";
453
+ import path7 from "path";
504
454
  import merge from "deepmerge";
505
455
  var outputManifest = async (env, options) => {
506
456
  const config2 = options?.config || await importK2PluginConfig();
507
457
  const merged = merge(config2.manifest.base, config2.manifest[env] || {});
508
- await fs6.mkdirs(PLUGIN_CONTENTS_DIRECTORY);
509
- await fs6.writeJson(path8.join(PLUGIN_CONTENTS_DIRECTORY, "manifest.json"), merged);
458
+ await fs5.mkdirs(PLUGIN_CONTENTS_DIRECTORY);
459
+ await fs5.writeJson(path7.join(PLUGIN_CONTENTS_DIRECTORY, "manifest.json"), merged);
510
460
  return merged;
511
461
  };
512
462
 
@@ -541,21 +491,21 @@ var getManifest = async (params) => {
541
491
  };
542
492
 
543
493
  // src/commands/plugin-dev/tailwind.ts
544
- import path9 from "path";
494
+ import path8 from "path";
545
495
  import "tailwindcss";
546
- import chalk4 from "chalk";
496
+ import chalk3 from "chalk";
547
497
  async function buildTailwindCSS(params) {
548
498
  const { inputFile, outputFileName, config: config2 } = params;
549
- const inputPath = path9.resolve(inputFile);
550
- const outputPath = path9.join(PLUGIN_DEVELOPMENT_DIRECTORY, outputFileName);
499
+ const inputPath = path8.resolve(inputFile);
500
+ const outputPath = path8.join(PLUGIN_DEVELOPMENT_DIRECTORY, outputFileName);
551
501
  return watchTailwindCSS({
552
502
  input: inputPath,
553
503
  output: outputPath,
554
504
  config: config2,
555
505
  onChanges: ({ output, type }) => {
556
- const outputFileName2 = path9.basename(output);
506
+ const outputFileName2 = path8.basename(output);
557
507
  console.log(
558
- chalk4.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk4.cyan(`[css] `) + outputFileName2 + (type === "init" ? " init" : ` rebuilt`)
508
+ chalk3.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk3.cyan(`[css] `) + outputFileName2 + (type === "init" ? " init" : ` rebuilt`)
559
509
  );
560
510
  }
561
511
  });
@@ -584,20 +534,20 @@ var watchCss = async (pluginConfig) => {
584
534
  import packer from "@kintone/plugin-packer";
585
535
 
586
536
  // src/lib/plugin-contents.ts
587
- import fs7 from "fs-extra";
588
- import path10 from "path";
537
+ import fs6 from "fs-extra";
538
+ import path9 from "path";
589
539
  import htmlMinifier from "html-minifier";
590
540
  var copyPluginContents = async (params = {}) => {
591
- const { inputDir = path10.join("src", "contents"), outputDir = PLUGIN_CONTENTS_DIRECTORY } = params;
592
- if (!fs7.existsSync(inputDir)) {
593
- await fs7.mkdir(inputDir, { recursive: true });
541
+ const { inputDir = path9.join("src", "contents"), outputDir = PLUGIN_CONTENTS_DIRECTORY } = params;
542
+ if (!fs6.existsSync(inputDir)) {
543
+ await fs6.mkdir(inputDir, { recursive: true });
594
544
  }
595
- await fs7.copy(inputDir, outputDir, { overwrite: true });
596
- const configHtmlPath = path10.join(outputDir, "config.html");
597
- if (!fs7.existsSync(configHtmlPath)) {
545
+ await fs6.copy(inputDir, outputDir, { overwrite: true });
546
+ const configHtmlPath = path9.join(outputDir, "config.html");
547
+ if (!fs6.existsSync(configHtmlPath)) {
598
548
  throw new Error(`Plugin HTML file not found. Create "config.html" in ${inputDir}.`);
599
549
  }
600
- const html = await fs7.readFile(configHtmlPath, "utf8");
550
+ const html = await fs6.readFile(configHtmlPath, "utf8");
601
551
  const minified = htmlMinifier.minify(html, {
602
552
  minifyCSS: true,
603
553
  collapseWhitespace: true,
@@ -608,13 +558,13 @@ var copyPluginContents = async (params = {}) => {
608
558
  removeTagWhitespace: true,
609
559
  useShortDoctype: true
610
560
  });
611
- await fs7.writeFile(configHtmlPath, minified);
561
+ await fs6.writeFile(configHtmlPath, minified);
612
562
  };
613
563
 
614
564
  // src/lib/zip.ts
615
565
  import archiver from "archiver";
616
- import fs8 from "fs-extra";
617
- import path11 from "path";
566
+ import fs7 from "fs-extra";
567
+ import path10 from "path";
618
568
  import invariant2 from "tiny-invariant";
619
569
  var outputContentsZip = async (manifest) => {
620
570
  const archive = archiver("zip", { zlib: { level: 9 } });
@@ -625,8 +575,8 @@ var outputContentsZip = async (manifest) => {
625
575
  throw error;
626
576
  }
627
577
  });
628
- const outputZipPath = path11.join(PLUGIN_WORKSPACE_DIRECTORY, "contents.zip");
629
- const outputZipStream = fs8.createWriteStream(outputZipPath);
578
+ const outputZipPath = path10.join(PLUGIN_WORKSPACE_DIRECTORY, "contents.zip");
579
+ const outputZipStream = fs7.createWriteStream(outputZipPath);
630
580
  outputZipStream.on("close", () => {
631
581
  console.log(`\u{1F4E6} ${archive.pointer()} total bytes`);
632
582
  });
@@ -657,8 +607,8 @@ var outputContentsZip = async (manifest) => {
657
607
  });
658
608
  console.groupEnd();
659
609
  for (const file of targetFiles) {
660
- const filePath = path11.join(PLUGIN_CONTENTS_DIRECTORY, file);
661
- if (!fs8.existsSync(filePath)) {
610
+ const filePath = path10.join(PLUGIN_CONTENTS_DIRECTORY, file);
611
+ if (!fs7.existsSync(filePath)) {
662
612
  throw new Error(`${filePath} does not exist`);
663
613
  }
664
614
  archive.file(filePath, { name: file });
@@ -668,16 +618,16 @@ var outputContentsZip = async (manifest) => {
668
618
  await new Promise((resolve) => outputZipStream.on("close", resolve));
669
619
  };
670
620
  var getContentsZipBuffer = async () => {
671
- const outputZipPath = path11.join(PLUGIN_WORKSPACE_DIRECTORY, "contents.zip");
672
- return fs8.readFile(outputZipPath);
621
+ const outputZipPath = path10.join(PLUGIN_WORKSPACE_DIRECTORY, "contents.zip");
622
+ return fs7.readFile(outputZipPath);
673
623
  };
674
624
  var getZipFileNameSuffix = (env) => {
675
625
  return env === "prod" ? "" : `-${env}`;
676
626
  };
677
627
 
678
628
  // src/commands/plugin-dev/upload.ts
679
- import fs10 from "fs-extra";
680
- import path13 from "path";
629
+ import fs9 from "fs-extra";
630
+ import path12 from "path";
681
631
 
682
632
  // src/lib/kintone-api-client.ts
683
633
  import { config } from "dotenv";
@@ -712,8 +662,8 @@ KINTONE_PASSWORD`);
712
662
  this.#baseUrl = KINTONE_BASE_URL;
713
663
  this.#authHeader = authHeader;
714
664
  }
715
- getEndpointUrl(path18) {
716
- return `${this.#baseUrl}${path18}`;
665
+ getEndpointUrl(path16) {
666
+ return `${this.#baseUrl}${path16}`;
717
667
  }
718
668
  async upload(params) {
719
669
  const { blob, fileName } = params;
@@ -784,8 +734,8 @@ KINTONE_PASSWORD`);
784
734
  };
785
735
 
786
736
  // src/lib/utils.ts
787
- import fs9 from "fs-extra";
788
- import path12 from "path";
737
+ import fs8 from "fs-extra";
738
+ import path11 from "path";
789
739
  var isEnv = (env) => {
790
740
  return ["prod", "dev", "standalone"].includes(env);
791
741
  };
@@ -793,7 +743,7 @@ var apiUploadZip = async (params) => {
793
743
  const { env, pluginId } = params;
794
744
  const kc = new KintoneApiClient();
795
745
  const zipFileName = `plugin${getZipFileNameSuffix(env)}.zip`;
796
- const zipFile = new Blob([await fs9.readFile(path12.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName))]);
746
+ const zipFile = new Blob([await fs8.readFile(path11.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName))]);
797
747
  const fileKey = await kc.upload({ blob: zipFile, fileName: zipFileName });
798
748
  const plugins = await kc.getAllPlugins();
799
749
  const plugin = plugins.find((p) => p.id === pluginId);
@@ -813,7 +763,7 @@ var apiUploadZip = async (params) => {
813
763
 
814
764
  // src/commands/plugin-dev/upload.ts
815
765
  import chokider from "chokidar";
816
- import chalk5 from "chalk";
766
+ import chalk4 from "chalk";
817
767
  var watchContentsAndUploadZip = async (params) => {
818
768
  const { manifest, ppkPath } = params;
819
769
  let initialScanComplete = false;
@@ -824,7 +774,7 @@ var watchContentsAndUploadZip = async (params) => {
824
774
  }
825
775
  await copyPluginContents();
826
776
  console.log(
827
- chalk5.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk5.cyan(`[contents] `) + `updated`
777
+ chalk4.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk4.cyan(`[contents] `) + `updated`
828
778
  );
829
779
  } catch (error) {
830
780
  console.error("Error copying plugin contents:", error);
@@ -833,17 +783,17 @@ var watchContentsAndUploadZip = async (params) => {
833
783
  try {
834
784
  await outputContentsZip(manifest);
835
785
  const buffer = await getContentsZipBuffer();
836
- const pluginPrivateKey = await fs10.readFile(path13.resolve(ppkPath), "utf8");
786
+ const pluginPrivateKey = await fs9.readFile(path12.resolve(ppkPath), "utf8");
837
787
  const output = await packer(buffer, pluginPrivateKey);
838
788
  const zipFileName = `plugin${getZipFileNameSuffix("dev")}.zip`;
839
- await fs10.writeFile(path13.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName), output.plugin);
789
+ await fs9.writeFile(path12.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName), output.plugin);
840
790
  const { method } = await apiUploadZip({ env: "dev", pluginId: output.id });
841
791
  console.log(
842
- chalk5.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk5.cyan(`[upload] `) + `uploaded ${method === "POST" ? "(new)" : "(update)"}`
792
+ chalk4.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk4.cyan(`[upload] `) + `uploaded ${method === "POST" ? "(new)" : "(update)"}`
843
793
  );
844
794
  } catch (error) {
845
795
  console.log(
846
- chalk5.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk5.cyan(`[upload] `) + chalk5.red(`failed`) + chalk5.hex("#e5e7eb")(`: ${error?.message ?? "Unknown error"}`)
796
+ chalk4.hex("#e5e7eb")(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} `) + chalk4.cyan(`[upload] `) + chalk4.red(`failed`) + chalk4.hex("#e5e7eb")(`: ${error?.message ?? "Unknown error"}`)
847
797
  );
848
798
  }
849
799
  };
@@ -865,46 +815,46 @@ function command3() {
865
815
  program3.command("dev").option(
866
816
  "-p, --ppk <ppk>",
867
817
  ".ppk file path",
868
- path14.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk")
869
- ).option("-c, --cert-dir <certDir>", "Certificate directory", PLUGIN_WORKSPACE_DIRECTORY).description("Start development server with Vite.").action(action3);
818
+ path13.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk")
819
+ ).option("-c, --cert-dir <certDir>", "Certificate directory", PLUGIN_WORKSPACE_DIRECTORY).description("Start development server with Vite.").action(action2);
870
820
  }
871
- async function action3(options) {
821
+ async function action2(options) {
872
822
  console.group("\u{1F373} Start development server");
873
823
  try {
874
824
  const { ppk: ppkPath, certDir } = options;
875
825
  const config2 = await importK2PluginConfig();
876
- const certDirPath = path14.resolve(certDir);
877
- const outputDir = path14.resolve(PLUGIN_DEVELOPMENT_DIRECTORY);
878
- if (!fs11.existsSync(PLUGIN_DEVELOPMENT_DIRECTORY)) {
879
- await fs11.mkdir(PLUGIN_DEVELOPMENT_DIRECTORY, { recursive: true });
826
+ const certDirPath = path13.resolve(certDir);
827
+ const outputDir = path13.resolve(PLUGIN_DEVELOPMENT_DIRECTORY);
828
+ if (!fs10.existsSync(PLUGIN_DEVELOPMENT_DIRECTORY)) {
829
+ await fs10.mkdir(PLUGIN_DEVELOPMENT_DIRECTORY, { recursive: true });
880
830
  }
881
831
  const port = config2.server?.port ?? DEFAULT_PORT;
882
832
  if (!hasCertificates(certDirPath)) {
883
- console.log(chalk6.yellow("\u{1F4DC} SSL certificates not found. Generating..."));
833
+ console.log(chalk5.yellow("\u{1F4DC} SSL certificates not found. Generating..."));
884
834
  try {
885
835
  await generateCert(certDirPath);
886
- console.log(chalk6.green("\u2705 SSL certificates generated successfully"));
836
+ console.log(chalk5.green("\u2705 SSL certificates generated successfully"));
887
837
  } catch (error) {
888
838
  console.log(
889
- chalk6.red("\u274C Failed to generate SSL certificates. Make sure mkcert is installed.")
839
+ chalk5.red("\u274C Failed to generate SSL certificates. Make sure mkcert is installed.")
890
840
  );
891
- console.log(chalk6.gray(" Install mkcert: https://github.com/FiloSottile/mkcert"));
841
+ console.log(chalk5.gray(" Install mkcert: https://github.com/FiloSottile/mkcert"));
892
842
  throw error;
893
843
  }
894
844
  }
895
845
  const manifest = await getManifest({ config: config2, port });
896
846
  console.log(`\u{1F4DD} manifest.json generated`);
897
847
  const entries = getPluginEntryPoints({
898
- configEntry: path14.resolve("src", "config"),
899
- desktopEntry: path14.resolve("src", "desktop")
848
+ configEntry: path13.resolve("src", "config"),
849
+ desktopEntry: path13.resolve("src", "desktop")
900
850
  });
901
851
  const entryNames = Object.keys(entries);
902
852
  if (entryNames.length === 0) {
903
853
  throw new Error("No entry points found for plugin. Check src/config and src/desktop paths.");
904
854
  }
905
- console.log(chalk6.gray(` Entry points: ${entryNames.join(", ")}`));
855
+ console.log(chalk5.gray(` Entry points: ${entryNames.join(", ")}`));
906
856
  const { key, cert } = loadCertificates(certDirPath);
907
- console.log(chalk6.gray(" Building..."));
857
+ console.log(chalk5.gray(" Building..."));
908
858
  await buildEntriesWithVite({
909
859
  entries,
910
860
  outDir: outputDir,
@@ -921,19 +871,19 @@ async function action3(options) {
921
871
  });
922
872
  const server = await createServer(serverConfig);
923
873
  await server.listen();
924
- console.log(chalk6.green(`
874
+ console.log(chalk5.green(`
925
875
  \u2728 Plugin development server ready!`));
926
- console.log(chalk6.cyan(` Local: https://localhost:${port}`));
927
- console.log(chalk6.gray(` Output: ${outputDir}`));
928
- console.log(chalk6.gray(` Files: config.js, desktop.js`));
929
- console.log(chalk6.gray("\n Watching for changes...\n"));
876
+ console.log(chalk5.cyan(` Local: https://localhost:${port}`));
877
+ console.log(chalk5.gray(` Output: ${outputDir}`));
878
+ console.log(chalk5.gray(` Files: config.js, desktop.js`));
879
+ console.log(chalk5.gray("\n Watching for changes...\n"));
930
880
  const chokidar2 = await import("chokidar");
931
881
  const watchDirs = [
932
- path14.resolve("src", "config"),
933
- path14.resolve("src", "desktop"),
934
- path14.resolve("src", "lib")
935
- ].filter((dir) => fs11.existsSync(dir));
936
- console.log(chalk6.gray(` Watching directories: ${watchDirs.join(", ")}`));
882
+ path13.resolve("src", "config"),
883
+ path13.resolve("src", "desktop"),
884
+ path13.resolve("src", "lib")
885
+ ].filter((dir) => fs10.existsSync(dir));
886
+ console.log(chalk5.gray(` Watching directories: ${watchDirs.join(", ")}`));
937
887
  const watcher = chokidar2.watch(watchDirs, {
938
888
  ignored: /node_modules/,
939
889
  persistent: true,
@@ -941,11 +891,11 @@ async function action3(options) {
941
891
  });
942
892
  const watchExtensions = [".ts", ".tsx", ".js", ".jsx", ".css", ".scss"];
943
893
  const shouldRebuild = (filePath) => {
944
- const ext = path14.extname(filePath).toLowerCase();
894
+ const ext = path13.extname(filePath).toLowerCase();
945
895
  return watchExtensions.includes(ext);
946
896
  };
947
897
  const rebuild = async () => {
948
- console.log(chalk6.gray(` ${(/* @__PURE__ */ new Date()).toLocaleTimeString()} Rebuilding...`));
898
+ console.log(chalk5.gray(` ${(/* @__PURE__ */ new Date()).toLocaleTimeString()} Rebuilding...`));
949
899
  await buildEntriesWithVite({
950
900
  entries,
951
901
  outDir: outputDir,
@@ -953,31 +903,31 @@ async function action3(options) {
953
903
  sourcemap: "inline",
954
904
  minify: false
955
905
  });
956
- console.log(chalk6.gray(` ${(/* @__PURE__ */ new Date()).toLocaleTimeString()} Rebuild complete`));
906
+ console.log(chalk5.gray(` ${(/* @__PURE__ */ new Date()).toLocaleTimeString()} Rebuild complete`));
957
907
  };
958
908
  watcher.on("ready", () => {
959
- console.log(chalk6.green(" \u2713 File watcher ready"));
909
+ console.log(chalk5.green(" \u2713 File watcher ready"));
960
910
  });
961
911
  watcher.on("change", (filePath) => {
962
912
  if (shouldRebuild(filePath)) {
963
- console.log(chalk6.cyan(` [change] ${filePath}`));
913
+ console.log(chalk5.cyan(` [change] ${filePath}`));
964
914
  rebuild();
965
915
  }
966
916
  });
967
917
  watcher.on("add", (filePath) => {
968
918
  if (shouldRebuild(filePath)) {
969
- console.log(chalk6.cyan(` [add] ${filePath}`));
919
+ console.log(chalk5.cyan(` [add] ${filePath}`));
970
920
  rebuild();
971
921
  }
972
922
  });
973
923
  watcher.on("unlink", (filePath) => {
974
924
  if (shouldRebuild(filePath)) {
975
- console.log(chalk6.cyan(` [unlink] ${filePath}`));
925
+ console.log(chalk5.cyan(` [unlink] ${filePath}`));
976
926
  rebuild();
977
927
  }
978
928
  });
979
929
  watcher.on("error", (error) => {
980
- console.error(chalk6.red(` Watcher error: ${error}`));
930
+ console.error(chalk5.red(` Watcher error: ${error}`));
981
931
  });
982
932
  Promise.all([watchContentsAndUploadZip({ manifest, ppkPath }), watchCss(config2)]);
983
933
  } catch (error) {
@@ -991,7 +941,7 @@ async function action3(options) {
991
941
  import { program as program4 } from "commander";
992
942
 
993
943
  // src/commands/genkey-base.ts
994
- async function action4(options) {
944
+ async function action3(options) {
995
945
  const { output } = options;
996
946
  console.group("\u{1F373} Generate SSL key for localhost");
997
947
  try {
@@ -1009,21 +959,21 @@ async function action4(options) {
1009
959
 
1010
960
  // src/commands/plugin-genkey.ts
1011
961
  function command4() {
1012
- program4.command("genkey").description("Generate SSL key for localhost. (Require mkcert)").action(action5);
962
+ program4.command("genkey").description("Generate SSL key for localhost. (Require mkcert)").action(action4);
1013
963
  }
1014
- async function action5() {
1015
- await action4({ output: PLUGIN_WORKSPACE_DIRECTORY });
964
+ async function action4() {
965
+ await action3({ output: PLUGIN_WORKSPACE_DIRECTORY });
1016
966
  }
1017
967
 
1018
968
  // src/commands/plugin-init.ts
1019
969
  import { program as program5 } from "commander";
1020
- import fs12 from "fs-extra";
1021
- import path15 from "path";
970
+ import fs11 from "fs-extra";
971
+ import path14 from "path";
1022
972
  import packer2 from "@kintone/plugin-packer";
1023
973
  function command5() {
1024
- program5.command("init").description("generate private.ppk and kitting config").action(action6);
974
+ program5.command("init").description("generate private.ppk and kitting config").action(action5);
1025
975
  }
1026
- async function action6() {
976
+ async function action5() {
1027
977
  console.group("\u{1F373} Executing plugin initialization setup");
1028
978
  try {
1029
979
  const manifest = await outputManifest("dev");
@@ -1031,20 +981,20 @@ async function action6() {
1031
981
  await copyPluginContents();
1032
982
  console.log("\u{1F4C1} contents copied");
1033
983
  let privateKey;
1034
- const keyPath = path15.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk");
1035
- if (fs12.existsSync(keyPath)) {
1036
- privateKey = await fs12.readFile(keyPath, "utf8");
984
+ const keyPath = path14.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk");
985
+ if (fs11.existsSync(keyPath)) {
986
+ privateKey = await fs11.readFile(keyPath, "utf8");
1037
987
  }
1038
988
  await outputContentsZip(manifest);
1039
989
  const buffer = await getContentsZipBuffer();
1040
990
  const output = await packer2(buffer, privateKey);
1041
991
  if (!privateKey) {
1042
- await fs12.writeFile(path15.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk"), output.privateKey);
992
+ await fs11.writeFile(path14.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk"), output.privateKey);
1043
993
  console.log("\u{1F511} private.ppk generated");
1044
994
  } else {
1045
995
  console.log("\u{1F511} private.ppk already exists. The existing private.ppk will be used.");
1046
996
  }
1047
- await fs12.writeFile(path15.join(PLUGIN_WORKSPACE_DIRECTORY, "plugin.zip"), output.plugin);
997
+ await fs11.writeFile(path14.join(PLUGIN_WORKSPACE_DIRECTORY, "plugin.zip"), output.plugin);
1048
998
  console.log("\u{1F4E6} plugin.zip generated");
1049
999
  console.log("\u2728 Plugin initialization setup completed! zip file path is ./.plugin/plugin.zip");
1050
1000
  } catch (error) {
@@ -1057,9 +1007,9 @@ async function action6() {
1057
1007
  // src/commands/manifest/index.ts
1058
1008
  import { program as program6 } from "commander";
1059
1009
  function command6() {
1060
- program6.command("manifest").option("-e, --env <env>", "create manifest", "prod").action(action7);
1010
+ program6.command("manifest").option("-e, --env <env>", "create manifest", "prod").action(action6);
1061
1011
  }
1062
- async function action7(options) {
1012
+ async function action6(options) {
1063
1013
  console.group("\u{1F680} Executing manifest generation");
1064
1014
  try {
1065
1015
  const { env } = options;
@@ -1079,13 +1029,13 @@ async function action7(options) {
1079
1029
 
1080
1030
  // src/commands/test/index.ts
1081
1031
  import { program as program7 } from "commander";
1082
- import fs13 from "fs-extra";
1032
+ import fs12 from "fs-extra";
1083
1033
  function command7() {
1084
- program7.command("test").description("test").action(action8);
1034
+ program7.command("test").description("test").action(action7);
1085
1035
  }
1086
- async function action8() {
1036
+ async function action7() {
1087
1037
  console.group("package.json");
1088
- const packageJson = fs13.readJSONSync("package.json");
1038
+ const packageJson = fs12.readJSONSync("package.json");
1089
1039
  console.log("package.json detected");
1090
1040
  console.groupEnd();
1091
1041
  console.group("Config");
@@ -1096,17 +1046,17 @@ async function action8() {
1096
1046
 
1097
1047
  // src/commands/plugin-zip.ts
1098
1048
  import { program as program8 } from "commander";
1099
- import fs14 from "fs-extra";
1100
- import path16 from "path";
1049
+ import fs13 from "fs-extra";
1050
+ import path15 from "path";
1101
1051
  import packer3 from "@kintone/plugin-packer";
1102
1052
  function command8() {
1103
1053
  program8.command("zip").description("generate plugin zip").option("-e, --env <env>", "plugin environment (dev, prod, standalone)", "prod").option(
1104
1054
  "-p, --ppk <ppk>",
1105
1055
  ".ppk file path",
1106
- path16.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk")
1107
- ).action(action9);
1056
+ path15.join(PLUGIN_WORKSPACE_DIRECTORY, "private.ppk")
1057
+ ).action(action8);
1108
1058
  }
1109
- async function action9(options) {
1059
+ async function action8(options) {
1110
1060
  console.group("\u{1F373} Executing plugin zip generation");
1111
1061
  try {
1112
1062
  const { env, ppk: ppkPath } = options;
@@ -1120,13 +1070,13 @@ async function action9(options) {
1120
1070
  await outputContentsZip(manifest);
1121
1071
  console.log("\u{1F4E6} contents.zip generated");
1122
1072
  const buffer = await getContentsZipBuffer();
1123
- const privateKey = await fs14.readFile(path16.resolve(ppkPath), "utf8");
1073
+ const privateKey = await fs13.readFile(path15.resolve(ppkPath), "utf8");
1124
1074
  const output = await packer3(buffer, privateKey);
1125
1075
  const zipFileName = `plugin${getZipFileNameSuffix(env)}.zip`;
1126
- await fs14.writeFile(path16.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName), output.plugin);
1076
+ await fs13.writeFile(path15.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName), output.plugin);
1127
1077
  console.log("\u{1F4E6} plugin.zip generated");
1128
1078
  const version = String(manifest.version);
1129
- await fs14.writeFile(path16.join(PLUGIN_WORKSPACE_DIRECTORY, "version"), version);
1079
+ await fs13.writeFile(path15.join(PLUGIN_WORKSPACE_DIRECTORY, "version"), version);
1130
1080
  console.log(`\u{1F4DD} version file generated (${version})`);
1131
1081
  console.log(`\u2728 Plugin zip generation completed! zip file path is ./.plugin/${zipFileName}`);
1132
1082
  } catch (error) {
@@ -1139,9 +1089,9 @@ async function action9(options) {
1139
1089
  // src/commands/lint.ts
1140
1090
  import { program as program9 } from "commander";
1141
1091
  function command9() {
1142
- program9.command("lint").description("Lint source files").option("-c, --config <config>", "Config file path").action(action10);
1092
+ program9.command("lint").description("Lint source files").option("-c, --config <config>", "Config file path").action(action9);
1143
1093
  }
1144
- async function action10(options) {
1094
+ async function action9(options) {
1145
1095
  try {
1146
1096
  lint();
1147
1097
  } catch (error) {
@@ -1150,90 +1100,8 @@ async function action10(options) {
1150
1100
  }
1151
1101
  }
1152
1102
 
1153
- // src/commands/plugin-tsup.ts
1154
- import { program as program10 } from "commander";
1155
- import fs15 from "fs-extra";
1156
- import path17 from "path";
1157
-
1158
- // src/lib/tsup.ts
1159
- import { build } from "tsup";
1160
- var completeBuildOptions = (params) => {
1161
- return {
1162
- bundle: true,
1163
- minify: "terser",
1164
- splitting: false,
1165
- noExternal: [/.*/],
1166
- platform: "browser",
1167
- dts: true,
1168
- ...params,
1169
- esbuildOptions(options, context) {
1170
- options.legalComments = "none";
1171
- }
1172
- };
1173
- };
1174
- var buildWithTsup = async (buildOptions) => {
1175
- const options = completeBuildOptions(buildOptions);
1176
- await build(options);
1177
- };
1178
-
1179
- // src/commands/plugin-tsup.ts
1180
- function command10() {
1181
- program10.command("tsup").description("Build the project for production. (It's a wrapper of webpack build command.)").action(action11);
1182
- }
1183
- async function action11() {
1184
- console.group("\u{1F373} Build the project for production");
1185
- try {
1186
- const config2 = await importK2PluginConfig();
1187
- if (config2?.lint?.build) {
1188
- await lint();
1189
- console.log("\u2728 Lint success.");
1190
- }
1191
- if (!fs15.existsSync(PLUGIN_CONTENTS_DIRECTORY)) {
1192
- await fs15.mkdir(PLUGIN_CONTENTS_DIRECTORY, { recursive: true });
1193
- }
1194
- if (config2.tailwind?.css && config2.tailwind?.config) {
1195
- const tailwindConfig = await getTailwindConfig(config2.tailwind);
1196
- const inputFile = getTailwindInputCss(config2.tailwind);
1197
- await outputCss({
1198
- inputPath: inputFile.config,
1199
- outputPath: path17.join(PLUGIN_CONTENTS_DIRECTORY, "config.css"),
1200
- config: tailwindConfig.config,
1201
- minify: true
1202
- });
1203
- console.log("\u2728 Built config.css");
1204
- await outputCss({
1205
- inputPath: inputFile.desktop,
1206
- outputPath: path17.join(PLUGIN_CONTENTS_DIRECTORY, "desktop.css"),
1207
- config: tailwindConfig.desktop,
1208
- minify: true
1209
- });
1210
- console.log("\u2728 Built desktop.css");
1211
- }
1212
- const entryPoints = ["desktop", "config"].reduce(
1213
- (acc, dir) => ({
1214
- ...acc,
1215
- [dir]: path17.join("src", dir, "index.ts")
1216
- }),
1217
- {}
1218
- );
1219
- await buildWithTsup({
1220
- entryPoints,
1221
- outDir: PLUGIN_CONTENTS_DIRECTORY,
1222
- minify: true,
1223
- treeshake: true,
1224
- sourcemap: false
1225
- });
1226
- console.log("\u2728 Built desktop.js and config.js");
1227
- console.log("\u2728 Build success.");
1228
- } catch (error) {
1229
- throw error;
1230
- } finally {
1231
- console.groupEnd();
1232
- }
1233
- }
1234
-
1235
1103
  // src/plugin.ts
1236
- program11.name("plugin").version("1.12.0").description("\u{1F373} kintone kitchen \u{1F373} for kintone plugin");
1104
+ program10.name("plugin").version("1.12.0").description("\u{1F373} kintone kitchen \u{1F373} for kintone plugin");
1237
1105
  command();
1238
1106
  command2();
1239
1107
  command3();
@@ -1243,6 +1111,5 @@ command6();
1243
1111
  command7();
1244
1112
  command8();
1245
1113
  command9();
1246
- command10();
1247
- program11.parse(process.argv);
1114
+ program10.parse(process.argv);
1248
1115
  //# sourceMappingURL=plugin.js.map