feat(cli): support default cross-compilation targets from npmextra.json

This commit is contained in:
2026-02-09 20:24:57 +00:00
parent 97cfcac82f
commit 32e3928d19
7 changed files with 41 additions and 6 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsrust',
version: '1.1.0',
version: '1.2.0',
description: 'A tool for compiling Rust projects, detecting Cargo workspaces, building with cargo, and placing binaries in a conventional dist_rust directory.'
}

View File

@@ -40,13 +40,20 @@ function friendlyName(triple: string): string {
return triple.replace(/-/g, '_');
}
interface ITsrustConfig {
targets?: string[];
}
export class TsRustCli {
private cli: plugins.smartcli.Smartcli;
private cwd: string;
private config: ITsrustConfig;
constructor(cwd: string = process.cwd()) {
this.cwd = cwd;
this.cli = new plugins.smartcli.Smartcli();
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
this.config = npmextraInstance.dataFor<ITsrustConfig>('@git.zone/tsrust', { targets: [] });
this.registerCommands();
}
@@ -99,11 +106,11 @@ export class TsRustCli {
const distDir = path.join(this.cwd, 'dist_rust');
const profile = isDebug ? 'debug' : 'release';
// Parse --target flag (can appear multiple times)
const rawTargets = (argvArg as any).target;
const targets: string[] = rawTargets
? Array.isArray(rawTargets) ? rawTargets : [rawTargets]
: [];
// Parse --target flag (can appear multiple times), fall back to npmextra.json config
const cliTargets = (argvArg as any).target;
const targets: string[] = cliTargets
? (Array.isArray(cliTargets) ? cliTargets : [cliTargets])
: this.config.targets || [];
if (targets.length > 0) {
// Cross-compilation mode

View File

@@ -1,4 +1,5 @@
import * as early from '@push.rocks/early';
import * as npmextra from '@push.rocks/npmextra';
import * as smartcli from '@push.rocks/smartcli';
import * as smartfile from '@push.rocks/smartfile';
import * as smartpath from '@push.rocks/smartpath';
@@ -6,6 +7,7 @@ import * as smartshell from '@push.rocks/smartshell';
export {
early,
npmextra,
smartcli,
smartfile,
smartpath,