@fnet/cli 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frun/index.js +1 -1
- package/package.json +1 -1
package/dist/frun/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import G from"yargs";import{hideBin as A}from"yargs/helpers";import{promisify as W}from"node:util";import X from"tree-kill";var F=W(X),M=!1;function J(){process.on("uncaughtException",($)=>{if(!M)M=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!M)M=!0,setTimeout(()=>process.exit(1),500)})}import U from"fs";import N from"path";import Z from"@fnet/yaml";import _ from"@fnet/shell-flow";async function O({projectType:$,group:B,tags:I,args:H,argv:q}){try{let L=await C($),{parsed:V}=await Z({file:L.path,tags:I}),z=V.commands;if(!z)throw Error(`Commands section not found in ${L.name}`);let D=z[B];if(!D)throw Error(`Command group '${B}' not found in ${L.name}`);await _({commands:D,context:{args:H,argv:q,projectType:L.type}})}catch(L){console.error(`Error: ${L.message}`),process.exit(1)}}async function C($){let B=process.cwd(),I=N.resolve(B,"fnode.yaml"),H=N.resolve(B,"fnet.yaml");if($==="fnode"){if(U.existsSync(I))return{path:I,name:"fnode.yaml",type:"fnode"};throw Error("fnode.yaml file not found in current directory")}if($==="fnet"){if(U.existsSync(H))return{path:H,name:"fnet.yaml",type:"fnet"};throw Error("fnet.yaml file not found in current directory")}if(U.existsSync(I))return{path:I,name:"fnode.yaml",type:"fnode"};if(U.existsSync(H))return{path:H,name:"fnet.yaml",type:"fnet"};throw Error("No project file (fnode.yaml or fnet.yaml) found in current directory")}var R={command:"$0 <group> [options..]",describe:"Run a command group from project file",builder:($)=>{return $.parserConfiguration({}).middleware((B)=>{let I=/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)+$/;Object.keys(B).forEach((H)=>{if(I.test(H)){let q=H.replace(/-/g,"_");B[q]=B[H]}})}).positional("group",{type:"string",describe:"Command group to run"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).example("$0 build","Run the build command group").example("$0 test --ftag dev","Run the test command group with dev tag")},handler:async($)=>{try{await O({projectType:"auto",group:$.group,tags:$.ftag,args:$,argv:process.argv})}catch(B){console.error(`Error: ${B.message}`),process.exit(1)}}},Q=R;J();async function w(){try{let $=G(A(process.argv)).usage("Usage: $0 <command> [options]").command(Q).help().version().argv}catch($){console.error(`Fatal error: ${$.message}`),process.exit(1)}}w().catch(($)=>{console.error(`Fatal error: ${$.message}`),process.exit(1)});
|