From d4ca12c4c2ecc8e52bf1c21394d7c4992718d628 Mon Sep 17 00:00:00 2001 From: koteelok Date: Thu, 28 Sep 2023 16:22:37 +0300 Subject: [PATCH] Fixed missing bundle dependencies --- CHANGELOG.md | 6 +++ package.json | 2 +- scripts/bundle.js | 106 +++++++++++++++++++++++++++++++--------------- 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d85970..5e4026d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [1.0.3] - 2023.09.28 + +### Added + +- Fixed missing bundle dependencies + ## [1.0.2] - 2023.09.14 ### Added diff --git a/package.json b/package.json index 642d7c7..45031ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "package_version": 2, - "version": "1.0.2", + "version": "1.0.3", "name": "yandex-games-sdk", "private": true, "description": "i18n:yandex-games-sdk.description", diff --git a/scripts/bundle.js b/scripts/bundle.js index b0d8d85..7f3bb9e 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -3,53 +3,89 @@ const path = require("path"); const archiver = require("archiver"); const package = require("../package.json"); -const bundleName = `ysdk-cc-${package.version}.zip`; -const bundlePath = path.resolve(__dirname, `../bundles/${bundleName}`); -const output = fs.createWriteStream(bundlePath); +const config = { + folders: ["@cc", "@types", "dist", "docs", "i18n", "static"], + modules: ["@babel", "i18next", "regenerator-runtime"], + files: [ + "AUTHORS", + "CHANGELOG.md", + "CONTRIBUTING.md", + "LICENSE", + "package.json", + "README_ZH.md", + "README.md", + ], +}; // create directory ../bundles if not exists if (!fs.existsSync(path.resolve(__dirname, "../bundles"))) { fs.mkdirSync(path.resolve(__dirname, "../bundles")); } -const archive = archiver("zip", { - zlib: { level: 9 }, -}); +function githubBundle() { + const bundleName = `ysdk-cc-${package.version}.zip`; -output.on("close", function () { - const kib = (archive.pointer() / 1048576).toPrecision(3); - console.log(`[${bundleName}] Bundle: Success (${kib} MiB)`); -}); + const archive = archiver("zip", { + zlib: { level: 9 }, + }); + archive.on("warning", console.warn); + archive.on("error", console.error); -archive.on("warning", console.warn); -archive.on("error", console.error); + const bundlePath = path.resolve(__dirname, `../bundles/${bundleName}`); + const output = fs.createWriteStream(bundlePath); + archive.pipe(output); + output.on("close", function () { + const kib = (archive.pointer() / 1048576).toPrecision(3); + console.log(`[${bundleName}] Bundle: Success (${kib} MiB)`); + }); -archive.pipe(output); + for (const folder of config.folders) { + archive.directory("./" + folder, folder); + } -const folders = ["@cc", "@types", "dist", "docs", "i18n", "static"]; + for (const module of config.modules) { + archive.directory("./node_modules/" + module, "./node_modules/" + module); + } + for (const file of config.files) { + archive.file("./" + file, { name: file }); + } -folders.forEach((folder) => { - archive.directory("./" + folder, folder); -}); + archive.finalize(); +} + +function storeBundle() { + const bundleName = `ysdk.zip`; + + const archive = archiver("zip", { + zlib: { level: 9 }, + }); + archive.on("warning", console.warn); + archive.on("error", console.error); + + const bundlePath = path.resolve(__dirname, `../bundles/${bundleName}`); + const output = fs.createWriteStream(bundlePath); + archive.pipe(output); + output.on("close", function () { + const kib = (archive.pointer() / 1048576).toPrecision(3); + console.log(`[${bundleName}] Bundle: Success (${kib} MiB)`); + }); + + for (const folder of config.folders) { + archive.directory("./" + folder, "ysdk/" + folder); + } -const modules = ["i18next"]; + for (const module of config.modules) { + archive.directory( + "./node_modules/" + module, + "ysdk/node_modules/" + module + ); + } + for (const file of config.files) { + archive.file("./" + file, { name: "ysdk/" + file }); + } -for (const module of modules) { - archive.directory(`./node_modules/${module}`, `node_modules/${module}`); + archive.finalize(); } -const files = [ - "AUTHORS", - "CHANGELOG.md", - "CONTRIBUTING.md", - "LICENSE", - "package.json", - "README_ZH.md", - "README.md", -]; - -files.forEach((file) => { - archive.file("./" + file, { name: file }); -}); - -archive.finalize(); +githubBundle(); +storeBundle();