feature: sk-react-toolkit holds the server helpers, web components and Vite font plugin shared by manage-ui and sql-query-webui.
Release / release (push) Failing after 1m18s
Release / release (push) Failing after 1m18s
This commit is contained in:
commit
4505b37abc
30 files changed
+4826
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Builds the published package in dist/: the toolkit compiled to JavaScript with its declarations, the declaration of
|
||||
// the font plugin's virtual module, README.md, CHANGELOG.md and a package.json whose exports name the compiled files.
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { copyFileSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const ROOT = import.meta.dirname;
|
||||
const DIST = join(ROOT, 'dist');
|
||||
const ENTRIES = ['server', 'web', 'vite'];
|
||||
|
||||
function fail(message) {
|
||||
console.error(`build: ${message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
rmSync(DIST, { recursive: true, force: true });
|
||||
const tsc = spawnSync(join(ROOT, 'node_modules', '.bin', 'tsc'), ['-p', join(ROOT, 'tsconfig.build.json')], { stdio: 'inherit' });
|
||||
if (tsc.error) fail(`tsc: ${tsc.error.message}; run npm ci first`);
|
||||
if (tsc.status !== 0) process.exit(tsc.status ?? 1);
|
||||
|
||||
// The compiled renderApp keeps its import of virtual:font, so its declarations reference the module's declaration.
|
||||
copyFileSync(join(ROOT, 'web', 'virtual-font.d.ts'), join(DIST, 'web', 'virtual-font.d.ts'));
|
||||
const renderApp = join(DIST, 'web', 'renderApp.d.ts');
|
||||
writeFileSync(renderApp, `/// <reference path="./virtual-font.d.ts" />\n${readFileSync(renderApp, 'utf8')}`);
|
||||
|
||||
for (const file of ['README.md', 'CHANGELOG.md']) copyFileSync(join(ROOT, file), join(DIST, file));
|
||||
|
||||
const source = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
||||
const published = {
|
||||
name: source.name,
|
||||
version: source.version,
|
||||
description: source.description,
|
||||
type: source.type,
|
||||
engines: source.engines,
|
||||
repository: source.repository,
|
||||
exports: Object.fromEntries(ENTRIES.map((entry) => [`./${entry}`, { types: `./${entry}/index.d.ts`, default: `./${entry}/index.js` }])),
|
||||
peerDependencies: source.peerDependencies,
|
||||
peerDependenciesMeta: source.peerDependenciesMeta,
|
||||
};
|
||||
writeFileSync(join(DIST, 'package.json'), `${JSON.stringify(published, null, 2)}\n`);
|
||||
console.log(`${published.name}@${published.version} in ${DIST}`);
|
||||
Reference in new issue
Block a user