Skip to content

Commit

Permalink
Fixed missing bundle dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
koteelok committed Sep 28, 2023
1 parent 7087c5a commit d4ca12c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 36 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
106 changes: 71 additions & 35 deletions scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit d4ca12c

Please sign in to comment.