From 96692f4273615b233baa045098fef690e910fdc5 Mon Sep 17 00:00:00 2001 From: Masaharu Tashiro Date: Sun, 27 Oct 2024 07:55:00 +0900 Subject: [PATCH] create plugin core module --- src/plugin/core/contents.ts | 0 .../crypto/__tests__/fixtures/private.ppk | 0 .../crypto/__tests__/private-key.test.ts | 2 +- .../{packer => core}/crypto/__tests__/uuid.ts | 0 src/plugin/{packer => core}/crypto/index.ts | 0 .../{packer => core}/crypto/private-key.ts | 0 .../{packer => core}/crypto/public-key.ts | 0 src/plugin/{packer => core}/crypto/sign.ts | 0 src/plugin/{packer => core}/crypto/uuid.ts | 0 src/plugin/{packer => core}/driver/index.ts | 2 +- .../{packer => core}/driver/interface.ts | 0 .../driver/fs.ts => core/driver/local-fs.ts} | 0 src/plugin/{packer => core}/driver/zip.ts | 0 src/plugin/core/index.ts | 12 ++--- .../plugin-invalid-https-url/image/icon.png | Bin .../plugin-invalid-https-url/manifest.json | 0 .../plugin-invalid-maxFileSize/image/icon.png | Bin .../plugin-invalid-maxFileSize/manifest.json | 0 .../image/icon.png | Bin .../manifest.json | 0 .../plugin-invalid-url/image/icon.png | Bin .../fixtures/plugin-invalid-url/manifest.json | 0 .../plugin-non-file-exists/image/icon.png | Bin .../plugin-non-file-exists/js/config.js | 0 .../plugin-non-file-exists/js/desktop.js | 0 .../plugin-non-file-exists/manifest.json | 0 .../manifest/__tests__/validate.test.ts | 0 .../{packer => core}/manifest/factory.ts | 4 +- src/plugin/{packer => core}/manifest/index.ts | 0 .../{packer => core}/manifest/interface.ts | 0 .../manifest/v1/__tests__/sourcelist.test.ts | 0 .../{packer => core}/manifest/v1/index.ts | 0 .../manifest/v1/sourcelist.ts | 0 .../manifest/v2/__tests__/sourcelist.test.ts | 0 .../{packer => core}/manifest/v2/index.ts | 0 .../manifest/v2/sourcelist.ts | 0 .../{packer => core}/manifest/validate.ts | 0 .../__tests__/fixtures/contents.zip | Bin .../plugin-zip/__tests__/index.test.ts | 0 .../invalid-maxFileSize-contents.zip | Bin .../plugin-manifest-v1/image/icon.png | Bin .../fixtures/plugin-manifest-v1/manifest.json | 0 .../plugin-manifest-v2/css/config.css | 0 .../plugin-manifest-v2/css/customize.css | 0 .../plugin-manifest-v2/html/config.html | 0 .../plugin-manifest-v2/html/customize.html | 0 .../plugin-manifest-v2/image/icon.png | Bin .../fixtures/plugin-manifest-v2/js/config.js | 0 .../plugin-manifest-v2/js/customize.js | 0 .../fixtures/plugin-manifest-v2/manifest.json | 0 .../contents-zip/__tests__/index.test.ts | 0 .../plugin-zip/contents-zip/index.ts | 0 .../plugin-zip/contents-zip/validate.ts | 0 .../plugin-zip/contents-zip/zip.ts | 0 .../{packer => core}/plugin-zip/index.ts | 0 src/plugin/info/index.ts | 2 +- src/plugin/packer/cli/index.ts | 42 +++++++----------- src/plugin/packer/index.ts | 4 +- 58 files changed, 30 insertions(+), 38 deletions(-) delete mode 100644 src/plugin/core/contents.ts rename src/plugin/{packer => core}/crypto/__tests__/fixtures/private.ppk (100%) rename src/plugin/{packer => core}/crypto/__tests__/private-key.test.ts (96%) rename src/plugin/{packer => core}/crypto/__tests__/uuid.ts (100%) rename src/plugin/{packer => core}/crypto/index.ts (100%) rename src/plugin/{packer => core}/crypto/private-key.ts (100%) rename src/plugin/{packer => core}/crypto/public-key.ts (100%) rename src/plugin/{packer => core}/crypto/sign.ts (100%) rename src/plugin/{packer => core}/crypto/uuid.ts (100%) rename src/plugin/{packer => core}/driver/index.ts (67%) rename src/plugin/{packer => core}/driver/interface.ts (100%) rename src/plugin/{packer/driver/fs.ts => core/driver/local-fs.ts} (100%) rename src/plugin/{packer => core}/driver/zip.ts (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-https-url/image/icon.png (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-https-url/manifest.json (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/image/icon.png (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/manifest.json (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-relative-path/image/icon.png (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-relative-path/manifest.json (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-url/image/icon.png (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-invalid-url/manifest.json (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-non-file-exists/image/icon.png (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-non-file-exists/js/config.js (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-non-file-exists/js/desktop.js (100%) rename src/plugin/{packer => core}/manifest/__tests__/fixtures/plugin-non-file-exists/manifest.json (100%) rename src/plugin/{packer => core}/manifest/__tests__/validate.test.ts (100%) rename src/plugin/{packer => core}/manifest/factory.ts (93%) rename src/plugin/{packer => core}/manifest/index.ts (100%) rename src/plugin/{packer => core}/manifest/interface.ts (100%) rename src/plugin/{packer => core}/manifest/v1/__tests__/sourcelist.test.ts (100%) rename src/plugin/{packer => core}/manifest/v1/index.ts (100%) rename src/plugin/{packer => core}/manifest/v1/sourcelist.ts (100%) rename src/plugin/{packer => core}/manifest/v2/__tests__/sourcelist.test.ts (100%) rename src/plugin/{packer => core}/manifest/v2/index.ts (100%) rename src/plugin/{packer => core}/manifest/v2/sourcelist.ts (100%) rename src/plugin/{packer => core}/manifest/validate.ts (100%) rename src/plugin/{packer => core}/plugin-zip/__tests__/fixtures/contents.zip (100%) rename src/plugin/{packer => core}/plugin-zip/__tests__/index.test.ts (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/invalid-maxFileSize/invalid-maxFileSize-contents.zip (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/image/icon.png (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/manifest.json (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/config.css (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/customize.css (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/config.html (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/customize.html (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/image/icon.png (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/config.js (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/customize.js (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/manifest.json (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/__tests__/index.test.ts (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/index.ts (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/validate.ts (100%) rename src/plugin/{packer => core}/plugin-zip/contents-zip/zip.ts (100%) rename src/plugin/{packer => core}/plugin-zip/index.ts (100%) diff --git a/src/plugin/core/contents.ts b/src/plugin/core/contents.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/plugin/packer/crypto/__tests__/fixtures/private.ppk b/src/plugin/core/crypto/__tests__/fixtures/private.ppk similarity index 100% rename from src/plugin/packer/crypto/__tests__/fixtures/private.ppk rename to src/plugin/core/crypto/__tests__/fixtures/private.ppk diff --git a/src/plugin/packer/crypto/__tests__/private-key.test.ts b/src/plugin/core/crypto/__tests__/private-key.test.ts similarity index 96% rename from src/plugin/packer/crypto/__tests__/private-key.test.ts rename to src/plugin/core/crypto/__tests__/private-key.test.ts index 7aa0ec46a6..56df1bf308 100644 --- a/src/plugin/packer/crypto/__tests__/private-key.test.ts +++ b/src/plugin/core/crypto/__tests__/private-key.test.ts @@ -1,7 +1,7 @@ import path from "path"; import fs from "fs"; -import { PrivateKey } from "../../crypto"; +import { PrivateKey } from "../index"; const privateKeyPath = path.join(__dirname, "fixtures", "private.ppk"); diff --git a/src/plugin/packer/crypto/__tests__/uuid.ts b/src/plugin/core/crypto/__tests__/uuid.ts similarity index 100% rename from src/plugin/packer/crypto/__tests__/uuid.ts rename to src/plugin/core/crypto/__tests__/uuid.ts diff --git a/src/plugin/packer/crypto/index.ts b/src/plugin/core/crypto/index.ts similarity index 100% rename from src/plugin/packer/crypto/index.ts rename to src/plugin/core/crypto/index.ts diff --git a/src/plugin/packer/crypto/private-key.ts b/src/plugin/core/crypto/private-key.ts similarity index 100% rename from src/plugin/packer/crypto/private-key.ts rename to src/plugin/core/crypto/private-key.ts diff --git a/src/plugin/packer/crypto/public-key.ts b/src/plugin/core/crypto/public-key.ts similarity index 100% rename from src/plugin/packer/crypto/public-key.ts rename to src/plugin/core/crypto/public-key.ts diff --git a/src/plugin/packer/crypto/sign.ts b/src/plugin/core/crypto/sign.ts similarity index 100% rename from src/plugin/packer/crypto/sign.ts rename to src/plugin/core/crypto/sign.ts diff --git a/src/plugin/packer/crypto/uuid.ts b/src/plugin/core/crypto/uuid.ts similarity index 100% rename from src/plugin/packer/crypto/uuid.ts rename to src/plugin/core/crypto/uuid.ts diff --git a/src/plugin/packer/driver/index.ts b/src/plugin/core/driver/index.ts similarity index 67% rename from src/plugin/packer/driver/index.ts rename to src/plugin/core/driver/index.ts index 95b45d7cc1..ef3dcae81d 100644 --- a/src/plugin/packer/driver/index.ts +++ b/src/plugin/core/driver/index.ts @@ -1,3 +1,3 @@ export type { DriverInterface } from "./interface"; -export { LocalFSDriver } from "./fs"; +export { LocalFSDriver } from "./local-fs"; export { ZipFileDriver } from "./zip"; diff --git a/src/plugin/packer/driver/interface.ts b/src/plugin/core/driver/interface.ts similarity index 100% rename from src/plugin/packer/driver/interface.ts rename to src/plugin/core/driver/interface.ts diff --git a/src/plugin/packer/driver/fs.ts b/src/plugin/core/driver/local-fs.ts similarity index 100% rename from src/plugin/packer/driver/fs.ts rename to src/plugin/core/driver/local-fs.ts diff --git a/src/plugin/packer/driver/zip.ts b/src/plugin/core/driver/zip.ts similarity index 100% rename from src/plugin/packer/driver/zip.ts rename to src/plugin/core/driver/zip.ts diff --git a/src/plugin/core/index.ts b/src/plugin/core/index.ts index ffa41d274a..7b94ede09e 100644 --- a/src/plugin/core/index.ts +++ b/src/plugin/core/index.ts @@ -1,5 +1,7 @@ -// import type { ManifestInterface } from "../packer/manifest"; - -// class Plugin { -// manifest: ManifestInterface; -// } +export { PluginZip } from "./plugin-zip"; +export type { PluginZipInterface } from "./plugin-zip"; +export { ManifestFactory, ManifestV1, ManifestV2 } from "./manifest"; +export type { ManifestInterface } from "./manifest"; +export { ZipFileDriver, LocalFSDriver } from "./driver"; +export type { DriverInterface } from "./driver"; +export { PrivateKey, PublicKey } from "./crypto"; diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-https-url/image/icon.png b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-https-url/image/icon.png similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-https-url/image/icon.png rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-https-url/image/icon.png diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-https-url/manifest.json b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-https-url/manifest.json similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-https-url/manifest.json rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-https-url/manifest.json diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/image/icon.png b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/image/icon.png similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/image/icon.png rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/image/icon.png diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/manifest.json b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/manifest.json similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/manifest.json rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-maxFileSize/manifest.json diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-relative-path/image/icon.png b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-relative-path/image/icon.png similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-relative-path/image/icon.png rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-relative-path/image/icon.png diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-relative-path/manifest.json b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-relative-path/manifest.json similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-relative-path/manifest.json rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-relative-path/manifest.json diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-url/image/icon.png b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-url/image/icon.png similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-url/image/icon.png rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-url/image/icon.png diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-url/manifest.json b/src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-url/manifest.json similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-invalid-url/manifest.json rename to src/plugin/core/manifest/__tests__/fixtures/plugin-invalid-url/manifest.json diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/image/icon.png b/src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/image/icon.png similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/image/icon.png rename to src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/image/icon.png diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/js/config.js b/src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/js/config.js similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/js/config.js rename to src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/js/config.js diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/js/desktop.js b/src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/js/desktop.js similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/js/desktop.js rename to src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/js/desktop.js diff --git a/src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/manifest.json b/src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/manifest.json similarity index 100% rename from src/plugin/packer/manifest/__tests__/fixtures/plugin-non-file-exists/manifest.json rename to src/plugin/core/manifest/__tests__/fixtures/plugin-non-file-exists/manifest.json diff --git a/src/plugin/packer/manifest/__tests__/validate.test.ts b/src/plugin/core/manifest/__tests__/validate.test.ts similarity index 100% rename from src/plugin/packer/manifest/__tests__/validate.test.ts rename to src/plugin/core/manifest/__tests__/validate.test.ts diff --git a/src/plugin/packer/manifest/factory.ts b/src/plugin/core/manifest/factory.ts similarity index 93% rename from src/plugin/packer/manifest/factory.ts rename to src/plugin/core/manifest/factory.ts index 7938d0accf..461d9e45c9 100644 --- a/src/plugin/packer/manifest/factory.ts +++ b/src/plugin/core/manifest/factory.ts @@ -1,5 +1,5 @@ -import type { DriverInterface } from "../driver/"; -import { LocalFSDriver } from "../driver/"; +import type { DriverInterface } from "../driver"; +import { LocalFSDriver } from "../driver"; import type { ManifestInterface, ManifestStaticInterface } from "./interface"; import { ManifestV1 } from "./v1"; import { ManifestV2 } from "./v2"; diff --git a/src/plugin/packer/manifest/index.ts b/src/plugin/core/manifest/index.ts similarity index 100% rename from src/plugin/packer/manifest/index.ts rename to src/plugin/core/manifest/index.ts diff --git a/src/plugin/packer/manifest/interface.ts b/src/plugin/core/manifest/interface.ts similarity index 100% rename from src/plugin/packer/manifest/interface.ts rename to src/plugin/core/manifest/interface.ts diff --git a/src/plugin/packer/manifest/v1/__tests__/sourcelist.test.ts b/src/plugin/core/manifest/v1/__tests__/sourcelist.test.ts similarity index 100% rename from src/plugin/packer/manifest/v1/__tests__/sourcelist.test.ts rename to src/plugin/core/manifest/v1/__tests__/sourcelist.test.ts diff --git a/src/plugin/packer/manifest/v1/index.ts b/src/plugin/core/manifest/v1/index.ts similarity index 100% rename from src/plugin/packer/manifest/v1/index.ts rename to src/plugin/core/manifest/v1/index.ts diff --git a/src/plugin/packer/manifest/v1/sourcelist.ts b/src/plugin/core/manifest/v1/sourcelist.ts similarity index 100% rename from src/plugin/packer/manifest/v1/sourcelist.ts rename to src/plugin/core/manifest/v1/sourcelist.ts diff --git a/src/plugin/packer/manifest/v2/__tests__/sourcelist.test.ts b/src/plugin/core/manifest/v2/__tests__/sourcelist.test.ts similarity index 100% rename from src/plugin/packer/manifest/v2/__tests__/sourcelist.test.ts rename to src/plugin/core/manifest/v2/__tests__/sourcelist.test.ts diff --git a/src/plugin/packer/manifest/v2/index.ts b/src/plugin/core/manifest/v2/index.ts similarity index 100% rename from src/plugin/packer/manifest/v2/index.ts rename to src/plugin/core/manifest/v2/index.ts diff --git a/src/plugin/packer/manifest/v2/sourcelist.ts b/src/plugin/core/manifest/v2/sourcelist.ts similarity index 100% rename from src/plugin/packer/manifest/v2/sourcelist.ts rename to src/plugin/core/manifest/v2/sourcelist.ts diff --git a/src/plugin/packer/manifest/validate.ts b/src/plugin/core/manifest/validate.ts similarity index 100% rename from src/plugin/packer/manifest/validate.ts rename to src/plugin/core/manifest/validate.ts diff --git a/src/plugin/packer/plugin-zip/__tests__/fixtures/contents.zip b/src/plugin/core/plugin-zip/__tests__/fixtures/contents.zip similarity index 100% rename from src/plugin/packer/plugin-zip/__tests__/fixtures/contents.zip rename to src/plugin/core/plugin-zip/__tests__/fixtures/contents.zip diff --git a/src/plugin/packer/plugin-zip/__tests__/index.test.ts b/src/plugin/core/plugin-zip/__tests__/index.test.ts similarity index 100% rename from src/plugin/packer/plugin-zip/__tests__/index.test.ts rename to src/plugin/core/plugin-zip/__tests__/index.test.ts diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/invalid-maxFileSize/invalid-maxFileSize-contents.zip b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/invalid-maxFileSize/invalid-maxFileSize-contents.zip similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/invalid-maxFileSize/invalid-maxFileSize-contents.zip rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/invalid-maxFileSize/invalid-maxFileSize-contents.zip diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/image/icon.png b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/image/icon.png similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/image/icon.png rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/image/icon.png diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/manifest.json b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/manifest.json similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/manifest.json rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v1/manifest.json diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/config.css b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/config.css similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/config.css rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/config.css diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/customize.css b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/customize.css similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/customize.css rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/css/customize.css diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/config.html b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/config.html similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/config.html rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/config.html diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/customize.html b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/customize.html similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/customize.html rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/html/customize.html diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/image/icon.png b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/image/icon.png similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/image/icon.png rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/image/icon.png diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/config.js b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/config.js similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/config.js rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/config.js diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/customize.js b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/customize.js similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/customize.js rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/js/customize.js diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/manifest.json b/src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/manifest.json similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/manifest.json rename to src/plugin/core/plugin-zip/contents-zip/__tests__/fixtures/plugin-manifest-v2/manifest.json diff --git a/src/plugin/packer/plugin-zip/contents-zip/__tests__/index.test.ts b/src/plugin/core/plugin-zip/contents-zip/__tests__/index.test.ts similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/__tests__/index.test.ts rename to src/plugin/core/plugin-zip/contents-zip/__tests__/index.test.ts diff --git a/src/plugin/packer/plugin-zip/contents-zip/index.ts b/src/plugin/core/plugin-zip/contents-zip/index.ts similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/index.ts rename to src/plugin/core/plugin-zip/contents-zip/index.ts diff --git a/src/plugin/packer/plugin-zip/contents-zip/validate.ts b/src/plugin/core/plugin-zip/contents-zip/validate.ts similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/validate.ts rename to src/plugin/core/plugin-zip/contents-zip/validate.ts diff --git a/src/plugin/packer/plugin-zip/contents-zip/zip.ts b/src/plugin/core/plugin-zip/contents-zip/zip.ts similarity index 100% rename from src/plugin/packer/plugin-zip/contents-zip/zip.ts rename to src/plugin/core/plugin-zip/contents-zip/zip.ts diff --git a/src/plugin/packer/plugin-zip/index.ts b/src/plugin/core/plugin-zip/index.ts similarity index 100% rename from src/plugin/packer/plugin-zip/index.ts rename to src/plugin/core/plugin-zip/index.ts diff --git a/src/plugin/info/index.ts b/src/plugin/info/index.ts index 994bed7ac7..24385dfb96 100644 --- a/src/plugin/info/index.ts +++ b/src/plugin/info/index.ts @@ -1,5 +1,5 @@ import fs from "fs/promises"; -import { PluginZip } from "../packer"; +import { PluginZip } from "../core"; export type OutputFormat = "plain" | "json"; diff --git a/src/plugin/packer/cli/index.ts b/src/plugin/packer/cli/index.ts index 23697cfdab..5137e44454 100644 --- a/src/plugin/packer/cli/index.ts +++ b/src/plugin/packer/cli/index.ts @@ -1,20 +1,22 @@ import path from "path"; -import fs from "fs"; -import { promisify } from "util"; +import fs from "fs/promises"; import os from "os"; import * as chokidar from "chokidar"; import { mkdirp } from "mkdirp"; import _debug from "debug"; import { logger } from "../../../utils/log"; -import { ManifestFactory } from "../manifest"; -import { validateFileExists, validateMaxFileSize } from "../manifest/validate"; -import type { PluginZipInterface } from "../plugin-zip"; -import { PluginZip } from "../plugin-zip"; -import { LocalFSDriver } from "../driver"; -import { PrivateKey } from "../crypto"; +import { + ManifestFactory, + PluginZip, + PrivateKey, + LocalFSDriver, +} from "../../core"; +import { + validateFileExists, + validateMaxFileSize, +} from "../../core/manifest/validate"; const debug = _debug("cli"); -const writeFile = promisify(fs.writeFile); type Options = Partial<{ ppk: string; @@ -29,13 +31,13 @@ export const run = async (pluginDir: string, options_?: Options) => { try { // 1. check if pluginDir is a directory - if (!fs.statSync(pluginDir).isDirectory()) { + if (!(await fs.stat(pluginDir)).isDirectory()) { throw new Error(`${pluginDir} should be a directory.`); } // 2. check pluginDir/manifest.json const manifestJsonPath = path.join(pluginDir, "manifest.json"); - if (!fs.statSync(manifestJsonPath).isFile()) { + if (!(await fs.stat(manifestJsonPath)).isFile()) { throw new Error("Manifest file $PLUGIN_DIR/manifest.json not found."); } @@ -78,7 +80,7 @@ export const run = async (pluginDir: string, options_?: Options) => { let privateKey: PrivateKey; if (ppkFile) { debug(`loading an existing key: ${ppkFile}`); - const ppk = fs.readFileSync(ppkFile, "utf8"); + const ppk = await fs.readFile(ppkFile, "utf8"); privateKey = PrivateKey.importKey(ppk); } else { debug("generating a new key"); @@ -98,7 +100,7 @@ export const run = async (pluginDir: string, options_?: Options) => { const ppkFilePath = path.join(outputDir, `${id}.ppk`); if (!ppkFile) { - fs.writeFileSync(ppkFilePath, privateKey.exportPrivateKey(), "utf8"); + await fs.writeFile(ppkFilePath, privateKey.exportPrivateKey(), "utf8"); } if (options.watch) { @@ -125,7 +127,8 @@ export const run = async (pluginDir: string, options_?: Options) => { ); }); } - await outputPlugin(outputFile, pluginZip); + + await fs.writeFile(outputFile, pluginZip.buffer); logger.info(`Succeeded: ${outputFile}`); return outputFile; @@ -134,14 +137,3 @@ export const run = async (pluginDir: string, options_?: Options) => { return Promise.reject(error); } }; - -/** - * Create and save plugin.zip - */ -const outputPlugin = async ( - outputPath: string, - plugin: PluginZipInterface, -): Promise => { - await writeFile(outputPath, plugin.buffer); - return outputPath; -}; diff --git a/src/plugin/packer/index.ts b/src/plugin/packer/index.ts index afb5fd6c68..d12ad6dcec 100644 --- a/src/plugin/packer/index.ts +++ b/src/plugin/packer/index.ts @@ -1,3 +1 @@ -export { run } from "./cli"; -export { PluginZip } from "./plugin-zip"; -export { ManifestFactory, ManifestV1, ManifestV2 } from "./manifest"; +export { run } from "../packer/cli";