import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { path7za } from '7zip-bin';
import caxa from 'caxa';
import esbuild from 'esbuild';
import type { Options as GlobOptions } from 'fast-glob';
import fg from 'fast-glob';
import yargs from 'yargs';
import Timer from '../src/async/timer.js';
import Logger from '../src/console/logger.js';
import { LogLevel } from '../src/console/logLevel.js';
import Package from '../src/globals/package.js';
import FsPoly from '../src/polyfill/fsPoly.js';
import IgirException from '../src/types/exceptions/igirException.js';
interface FileFilter extends GlobOptions {
include?: string;
exclude?: string;
}
const fileFilter = (filters: FileFilter[]): string[] => {
let results: string[] = [];
filters.forEach((filter) => {
if (filter.include) {
const includeNormalized = filter.include.replaceAll('\\', '/');
const include = fg.globSync(includeNormalized, filter).map((file) => path.resolve(file));
if (include.length === 0) {
throw new IgirException(`glob pattern '${includeNormalized}' returned no paths`);
}
results = [...results, ...include];
}
if (filter.exclude) {
const excludeNormalized = filter.exclude.replaceAll('\\', '/');
const exclude = new Set(
fg.globSync(excludeNormalized, filter).map((file) => path.resolve(file)),
);
if (exclude.size === 0) {
throw new IgirException(`glob pattern '${excludeNormalized}' returned no paths`);
}
results = results.filter((result) => !exclude.has(result));
}
});
return results;
};
const logger = new Logger(LogLevel.TRACE, process.stdout);
logger.info('========== PACKAGING ==========');
const argv = await yargs(process.argv.slice(2))
.locale('en')
.usage('Usage: $0