Skip to content

Commit

Permalink
Merge branch 'main' into pr/Hiroshiba/1967
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed May 4, 2024
2 parents 5444495 + f560c6f commit 6f2279a
Show file tree
Hide file tree
Showing 170 changed files with 11,957 additions and 20,576 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @VOICEVOX/maintainer
* @VOICEVOX/main-reviewer
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ on:

env:
VOICEVOX_ENGINE_REPO_URL: "https://github.com/VOICEVOX/voicevox_engine"
VOICEVOX_ENGINE_VERSION: 0.18.0
VOICEVOX_RESOURCE_VERSION: 0.18.0
VOICEVOX_ENGINE_VERSION: 0.19.0
VOICEVOX_RESOURCE_VERSION: 0.19.0
VOICEVOX_EDITOR_VERSION:
|- # releaseタグ名か、workflow_dispatchでのバージョン名か、999.999.999-developが入る
${{ github.event.release.tag_name || github.event.inputs.version || '999.999.999-develop' }}
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
app_asar_dir: prepackage/VOICEVOX.app/Contents/Resources
installer_artifact_name: macos-cpu-dmg
macos_artifact_name: "VOICEVOX.${version}.${ext}"
os: macos-11
os: macos-12

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:

# https://github.com/electron-userland/electron-builder/issues/3179
USE_HARD_LINKS: false
run: npm run electron:build_dir
run: npm run electron:build -- --dir

- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
Expand Down Expand Up @@ -394,14 +394,14 @@ jobs:
LINUX_ARTIFACT_NAME: ${{ matrix.linux_artifact_name }}
LINUX_EXECUTABLE_NAME: ${{ matrix.linux_executable_name }}
run: |
PREPACKAGED="prepackage" npm run electron:build_pnever_prepackaged
npm run electron:build -- --prepackaged prepackage/
- name: Build Electron (for macOS)
if: endsWith(matrix.installer_artifact_name, '-dmg') # macOS
env:
MACOS_ARTIFACT_NAME: ${{ matrix.macos_artifact_name }}
run: |
PREPACKAGED="prepackage/VOICEVOX.app" npm run electron:build_pnever_prepackaged
npm run electron:build -- --prepackaged prepackage/VOICEVOX.app
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-environment
- run: npm run electron:build_pnever
- run: npm run electron:build

# unit テスト
unit-test:
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.13.0
20.12.2
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

8 changes: 3 additions & 5 deletions build/download7z.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const fs = require("fs");
const { spawnSync } = require("child_process");

(async () => {
// node-fetchはESModuleなので、import()で読み込む
const { default: fetch } = await import("node-fetch");
const distPath = path.resolve(__dirname, "vendored", "7z");
let url;
let filesToExtract;
Expand Down Expand Up @@ -53,7 +51,7 @@ const { spawnSync } = require("child_process");
const existingFiles = await fs.promises.readdir(distPath);

const notDownloaded = filesToExtract.filter(
(file) => !existingFiles.includes(file)
(file) => !existingFiles.includes(file),
);

if (notDownloaded.length === 0) {
Expand All @@ -74,14 +72,14 @@ const { spawnSync } = require("child_process");
["x", "-y", "-o" + distPath, sevenZipPath, ...filesToExtract],
{
stdio: ["ignore", "inherit", "inherit"],
}
},
)
: spawnSync(
"tar",
["xvf", sevenZipPath, "-v", "-C", distPath, ...filesToExtract],
{
stdio: ["ignore", "inherit", "inherit"],
}
},
);

if (extractor.status !== 0) {
Expand Down
131 changes: 67 additions & 64 deletions build/generateLicenses.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires */

const process = require("process");
const { execFileSync } = require("child_process");
const fs = require("fs");
const fs = require("fs/promises");
const path = require("path");
const yargs = require("yargs/yargs");
const yargs = require("yargs");
const { hideBin } = require("yargs/helpers");

const argv = yargs(hideBin(process.argv))
.option("output_path", {
alias: "o",
Expand All @@ -15,54 +17,43 @@ const argv = yargs(hideBin(process.argv))
.help()
.parse();

const tmp = require("tmp");

const isWindows = process.platform === "win32";

const customFormat = {
name: "",
version: "",
description: "",
licenses: "",
copyright: "",
licenseFile: "none",
licenseText: "none",
licenseModified: "no",
};

const customFormatFile = tmp.fileSync();
fs.writeFileSync(customFormatFile.name, JSON.stringify(customFormat));
const licenseChecker = require("license-checker-rseidelsohn");

const disallowedLicenses = ["GPL", "GPL-2.0", "GPL-3.0", "AGPL", "NGPL"];

// On Windows, npm's global packages can be called with the extension `.cmd` or `.ps1`.
// On Linux (bash), they can be called without extensions.
const extension = isWindows ? ".cmd" : "";

// https://github.com/davglass/license-checker
// npm install -g license-checker
const licenseJson = execFileSync(
`license-checker${extension}`,
[
"--production",
"--excludePrivatePackages",
"--json",
`--customPath=${customFormatFile.name}`,
`--failOn=${disallowedLicenses.join(";")}`,
],
{
encoding: "utf-8",
maxBuffer: 1024 * 1024 * 10, // FIXME: stdoutではなくファイル出力にする
}
);
(async () => {
const disallowedLicenses = ["GPL", "GPL-2.0", "GPL-3.0", "AGPL", "NGPL"];

const checkerLicenses = JSON.parse(licenseJson);
/** @type {licenseChecker.ModuleInfos} */
const licenseJson = await new Promise((resolve, reject) => {
licenseChecker.init(
{
start: process.cwd(),
production: true,
failOn: disallowedLicenses.join(";"),
excludePrivatePackages: true,
customFormat: {
name: "",
version: "",
description: "",
licenses: "",
copyright: "",
licenseFile: "none",
licenseText: "none",
licenseModified: "no",
},
},
(err, json) => {
if (err) {
reject(err);
} else {
resolve(json);
}
},
);
});

const externalLicenses = [];
const externalLicenses = [];

externalLicenses.push({
name: "7-Zip",
version: execFileSync(
const sevenZipVersionMatch = execFileSync(
path.join(
__dirname,
"vendored",
Expand All @@ -71,27 +62,39 @@ externalLicenses.push({
win32: "7za.exe",
linux: "7zzs",
darwin: "7zz",
}[process.platform]
}[process.platform],
),

{
encoding: "utf-8",
}
).match(/7-Zip\s+(?:\(.\))?\s*([0-9.]+)/)[1],
license: "LGPL-2.1",
text: fs.readFileSync(path.join(__dirname, "vendored", "7z", "License.txt"), {
encoding: "utf-8",
}),
});
},
).match(/7-Zip\s+(?:\(.\))?\s*([0-9.]+)/);

if (!sevenZipVersionMatch) {
throw new Error("Failed to find 7-Zip version");
}

externalLicenses.push({
name: "7-Zip",
version: sevenZipVersionMatch[1],
license: "LGPL-2.1",
text: await fs.readFile(
path.join(__dirname, "vendored", "7z", "License.txt"),
{
encoding: "utf-8",
},
),
});

const licenses = Object.entries(checkerLicenses)
.map(([, license]) => ({
name: license.name,
version: license.version,
license: license.licenses,
text: license.licenseText,
}))
.concat(externalLicenses);
const licenses = Object.entries(licenseJson)
.map(([, license]) => ({
name: license.name,
version: license.version,
license: license.licenses,
text: license.licenseText,
}))
.concat(externalLicenses);

const outputPath = argv.output_path;
fs.writeFileSync(outputPath, JSON.stringify(licenses));
const outputPath = argv.output_path;
await fs.writeFile(outputPath, JSON.stringify(licenses));
})();
6 changes: 3 additions & 3 deletions electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const sevenZipFile = fs
.readdirSync(path.resolve(__dirname, "build", "vendored", "7z"))
.find(
// Windows: 7za.exe, Linux: 7zzs, macOS: 7zz
(fileName) => ["7za.exe", "7zzs", "7zz"].includes(fileName)
(fileName) => ["7za.exe", "7zzs", "7zz"].includes(fileName),
);

if (!sevenZipFile) {
throw new Error(
"7z binary file not found. Run `node ./build/download7z.js` first."
"7z binary file not found. Run `node ./build/download7z.js` first.",
);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ const builderOptions = {
afterAllArtifactBuild: path.resolve(
__dirname,
"build",
"afterAllArtifactBuild.js"
"afterAllArtifactBuild.js",
),
win: {
icon: "public/icon.png",
Expand Down
2 changes: 1 addition & 1 deletion openapi.json

Large diffs are not rendered by default.

Loading

0 comments on commit 6f2279a

Please sign in to comment.