Forked from dirty-data/computer
Forked from dirty-data/computer
scripts / build.mjs
// Logic behind build.cmd / build.sh. Usage: node scripts/build.mjs <target>
// check TypeScript type check
// install npm install, type check, then install the plugin into LM Studio (lms dev --install -y)
// publish type check, then upload to LM Studio Hub as a public artifact (needs: lms login)
import { spawnSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const sh = (cmd) => {
console.log(`> ${cmd}`);
const r = spawnSync(cmd, { cwd: ROOT, stdio: 'inherit', shell: true });
if (r.status !== 0) process.exit(r.status ?? 1);
};
const targets = {
check: () => sh('npx tsc --noEmit'),
install: () => { sh('npm install --no-audit --no-fund'); targets.check(); sh('lms dev --install -y'); console.log('installed: restart the plugin in LM Studio (or LM Studio) if it was running'); },
publish: () => { targets.check(); sh('lms whoami'); sh('lms push --write-revision -y'); },
};
const t = process.argv[2];
if (!targets[t]) { console.log('usage: build.cmd <check|install|publish>'); process.exit(t ? 1 : 0); }
targets[t]();
scripts / build.mjs
// Logic behind build.cmd / build.sh. Usage: node scripts/build.mjs <target>
// check TypeScript type check
// install npm install, type check, then install the plugin into LM Studio (lms dev --install -y)
// publish type check, then upload to LM Studio Hub as a public artifact (needs: lms login)
import { spawnSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const sh = (cmd) => {
console.log(`> ${cmd}`);
const r = spawnSync(cmd, { cwd: ROOT, stdio: 'inherit', shell: true });
if (r.status !== 0) process.exit(r.status ?? 1);
};
const targets = {
check: () => sh('npx tsc --noEmit'),
install: () => { sh('npm install --no-audit --no-fund'); targets.check(); sh('lms dev --install -y'); console.log('installed: restart the plugin in LM Studio (or LM Studio) if it was running'); },
publish: () => { targets.check(); sh('lms whoami'); sh('lms push --write-revision -y'); },
};
const t = process.argv[2];
if (!targets[t]) { console.log('usage: build.cmd <check|install|publish>'); process.exit(t ? 1 : 0); }
targets[t]();