diff --git a/changelog.md b/changelog.md index 59a9f1d..da21f00 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2026-02-09 - 1.2.0 - feat(cli) +support default cross-compilation targets from npmextra.json + +- Add @push.rocks/npmextra dependency and export plugin in ts/plugins.ts +- Introduce ITsrustConfig and read configuration via plugins.npmextra.Npmextra in TsRustCli +- Use npmextra.json targets as fallback when no CLI --target flags are provided +- Update README to document npmextra.json configuration for default targets + ## 2026-02-09 - 1.1.0 - feat(cross-compile) add cross-compilation support with --target flag, friendly target aliases, and automatic rustup target installation diff --git a/package.json b/package.json index 8c95b5c..ebc1228 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "homepage": "https://code.foss.global/git.zone/tsrust#README", "dependencies": { "@push.rocks/early": "^4.0.4", + "@push.rocks/npmextra": "^5.3.3", "@push.rocks/smartcli": "^4.0.19", "@push.rocks/smartfile": "^13.1.2", "@push.rocks/smartpath": "^6.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf86b2a..7005f15 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@push.rocks/early': specifier: ^4.0.4 version: 4.0.4 + '@push.rocks/npmextra': + specifier: ^5.3.3 + version: 5.3.3 '@push.rocks/smartcli': specifier: ^4.0.19 version: 4.0.20 diff --git a/readme.md b/readme.md index 4614dbe..f1a53ab 100644 --- a/readme.md +++ b/readme.md @@ -119,6 +119,20 @@ dist_rust/ `tsrust` automatically installs missing rustup targets via `rustup target add` when needed. +### Configuration via npmextra.json + +You can set default cross-compilation targets in your project's `npmextra.json` file so you don't need to pass `--target` flags every time: + +```json +{ + "@git.zone/tsrust": { + "targets": ["linux_arm64", "linux_amd64"] + } +} +``` + +When targets are configured in `npmextra.json`, simply running `tsrust` will cross-compile for all listed targets. CLI `--target` flags take full precedence — if any `--target` is provided, the `npmextra.json` targets are ignored entirely. + ### 🗑️ Clean Only Remove all build artifacts without rebuilding: diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5a5cde3..97b1350 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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.' } diff --git a/ts/mod_cli/classes.tsrustcli.ts b/ts/mod_cli/classes.tsrustcli.ts index 7892a54..9c3c8f2 100644 --- a/ts/mod_cli/classes.tsrustcli.ts +++ b/ts/mod_cli/classes.tsrustcli.ts @@ -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('@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 diff --git a/ts/plugins.ts b/ts/plugins.ts index 96ae043..21183d3 100644 --- a/ts/plugins.ts +++ b/ts/plugins.ts @@ -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,