Prepare ForgeFlow for public release
This commit is contained in:
@@ -1,28 +1,44 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
import { readdir, readFile, stat, writeFile } from 'node:fs/promises';
|
||||
import { execFile } from 'node:child_process';
|
||||
import { readFile, stat, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const excludedDirectories = new Set(['.git', '.forgeflow', 'artifacts', 'coverage', 'dist', 'node_modules', 'playwright-report', 'ForgeFlow-runtime-win-x64']);
|
||||
const excludedFiles = new Set(['SOURCE_MANIFEST.txt']);
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
async function collect(directory, output = []) {
|
||||
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
||||
if (excludedDirectories.has(entry.name)) continue;
|
||||
const absolute = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) await collect(absolute, output);
|
||||
else if (!excludedFiles.has(entry.name)) output.push(absolute);
|
||||
async function collect() {
|
||||
const { stdout } = await execFileAsync(
|
||||
'git',
|
||||
['ls-files', '--cached', '--others', '--exclude-standard', '-z'],
|
||||
{ cwd: root, encoding: 'buffer', maxBuffer: 16 * 1024 * 1024 },
|
||||
);
|
||||
const relativePaths = stdout
|
||||
.toString('utf8')
|
||||
.split('\0')
|
||||
.filter(Boolean)
|
||||
.filter((relative) => !excludedFiles.has(relative));
|
||||
|
||||
const existing = [];
|
||||
for (const relative of relativePaths) {
|
||||
const absolute = path.resolve(root, relative);
|
||||
try {
|
||||
if ((await stat(absolute)).isFile()) existing.push(absolute);
|
||||
} catch (error) {
|
||||
if (error?.code !== 'ENOENT') throw error;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
return existing;
|
||||
}
|
||||
|
||||
const packageJson = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
|
||||
const files = (await collect(root)).sort((left, right) => left.localeCompare(right, 'en'));
|
||||
const files = (await collect()).sort((left, right) => left.localeCompare(right, 'en'));
|
||||
const lines = [
|
||||
`ForgeFlow ${packageJson.version} source manifest`,
|
||||
'SHA-256 BYTES PATH',
|
||||
'(The manifest excludes itself, dependencies and generated release artifacts.)'
|
||||
'(The manifest includes tracked and non-ignored source files, excluding itself.)'
|
||||
];
|
||||
|
||||
for (const absolute of files) {
|
||||
|
||||
Reference in New Issue
Block a user