49 lines
2.1 KiB
JavaScript
49 lines
2.1 KiB
JavaScript
'use strict';
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const releaseDir = path.join(root, 'release', 'UNIVERSAL_SpineViewer');
|
|
const archive = path.join(root, 'release', 'SpineViewer.eagleplugin');
|
|
|
|
function walk(directory, prefix = '') {
|
|
const files = [];
|
|
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
const relative = path.posix.join(prefix, entry.name);
|
|
if (entry.isDirectory()) files.push(...walk(path.join(directory, entry.name), relative));
|
|
else files.push(relative);
|
|
}
|
|
return files;
|
|
}
|
|
|
|
function zipEntries(file) {
|
|
const data = fs.readFileSync(file);
|
|
const entries = [];
|
|
for (let offset = 0; offset + 46 <= data.length;) {
|
|
const header = data.indexOf(Buffer.from([0x50, 0x4b, 0x01, 0x02]), offset);
|
|
if (header < 0) break;
|
|
const nameLength = data.readUInt16LE(header + 28);
|
|
const extraLength = data.readUInt16LE(header + 30);
|
|
const commentLength = data.readUInt16LE(header + 32);
|
|
entries.push(data.subarray(header + 46, header + 46 + nameLength).toString('utf8'));
|
|
offset = header + 46 + nameLength + extraLength + commentLength;
|
|
}
|
|
return entries;
|
|
}
|
|
|
|
for (const [label, files] of [
|
|
['release directory', walk(releaseDir)],
|
|
['eagleplugin archive', zipEntries(archive)],
|
|
]) {
|
|
assert.equal(files.some((file) => /\.log$/i.test(file)), false, label + ' must not contain runtime or historical logs');
|
|
assert.equal(files.some((file) => /(^|\/)\.DS_Store$/i.test(file)), false, label + ' must not contain macOS metadata');
|
|
assert.equal(files.includes('thumbnail/spine.js'), false, label + ' must not contain an import-time Spine thumbnail handler');
|
|
assert.equal(files.some((file) => /^node_modules\//.test(file)), false, label + ' must not contain unused native thumbnail dependencies');
|
|
}
|
|
|
|
const manifest = JSON.parse(fs.readFileSync(path.join(releaseDir, 'manifest.json'), 'utf8'));
|
|
assert.equal(Object.values(manifest.preview || {}).some((entry) => entry && entry.thumbnail), false);
|
|
|
|
console.log('PASS: release has no logs, metadata, import thumbnail handler, or unused native thumbnail dependencies');
|