@fnet/cli 0.116.2 → 0.117.0
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/fnet/index.js +1 -1
- package/dist/fnode/{index.DMkgR1Dh.js → index.B1G_No8j.js} +1 -1
- package/dist/fnode/index.BqI7rTjk.js +1 -0
- package/dist/fnode/{index.D3C-8oZW.js → index.DnA30tC4.js} +1 -1
- package/dist/fnode/index.js +1 -1
- package/dist/fservice/index.js +2 -0
- package/package.json +8 -7
- package/template/fnet/bun/src/cli/index.js.njk +1 -0
- package/template/fnet/bun/src/default/input.args.js.njk +6 -4
- package/template/fnet/node/src/cli/index.js.njk +9 -22
- package/template/fnet/node/src/default/input.args.js.njk +6 -4
- package/template/fnode/bun/src/cli/index.js.njk +1 -0
- package/template/fnode/bun/src/default/input.args.js.njk +6 -4
- package/template/fnode/node/src/cli/index.js.njk +14 -15
- package/template/fnode/node/src/default/input.args.js.njk +6 -4
- package/dist/fnode/index.D4sPJLOP.js +0 -1
|
@@ -35,15 +35,7 @@
|
|
|
35
35
|
tools: [{
|
|
36
36
|
name: "{{atom.doc.features.cli.mcp.tool.name or atom.doc.name}}",
|
|
37
37
|
description: "{{atom.doc.features.cli.mcp.tool.description or atom.doc.description}}",
|
|
38
|
-
|
|
39
|
-
inputSchema: {{atom.doc.input | dump | safe}}
|
|
40
|
-
{% else %}
|
|
41
|
-
inputSchema: {
|
|
42
|
-
type: "object",
|
|
43
|
-
properties: {},
|
|
44
|
-
additionalProperties: true
|
|
45
|
-
}
|
|
46
|
-
{% endif %}
|
|
38
|
+
inputSchema: inputSchema
|
|
47
39
|
}]
|
|
48
40
|
};
|
|
49
41
|
});
|
|
@@ -141,14 +133,14 @@
|
|
|
141
133
|
{% macro defaultModeExtend(nodeFn) %}
|
|
142
134
|
if (cliMode === 'default') {
|
|
143
135
|
// Default mode code
|
|
144
|
-
return await {{ nodeFn }}(
|
|
136
|
+
return await {{ nodeFn }}(await argv());
|
|
145
137
|
}
|
|
146
138
|
{% endmacro %}
|
|
147
139
|
|
|
148
140
|
{% macro defaultModeStandard(nodeFn) %}
|
|
149
141
|
if (cliMode === 'default') {
|
|
150
142
|
// Default mode code
|
|
151
|
-
const result = await {{ nodeFn }}(
|
|
143
|
+
const result = await {{ nodeFn }}(await argv());
|
|
152
144
|
|
|
153
145
|
if (typeof result !== 'undefined') {
|
|
154
146
|
const stdout_format = args['stdout-format'] || args.stdout_format || null;
|
|
@@ -183,6 +175,7 @@ run()
|
|
|
183
175
|
{% if atom.doc.features.project.format==='esm' %}
|
|
184
176
|
|
|
185
177
|
import argv from '../default/input.args.js';
|
|
178
|
+
import { schema as inputSchema } from '../default/validate_input.js';
|
|
186
179
|
|
|
187
180
|
{% if atom.doc.features.cli.extend===true %}
|
|
188
181
|
|
|
@@ -194,9 +187,10 @@ import Node from '../../../cli';
|
|
|
194
187
|
// Using express for HTTP mode
|
|
195
188
|
import express from 'express';
|
|
196
189
|
{% endif %}
|
|
190
|
+
import minimist from 'minimist';
|
|
197
191
|
|
|
198
192
|
const run = async () => {
|
|
199
|
-
const args =
|
|
193
|
+
const args = minimist(process.argv.slice(2));
|
|
200
194
|
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
201
195
|
|
|
202
196
|
{{ defaultModeExtend('Node') }}
|
|
@@ -225,8 +219,10 @@ import Node from '../../../src';
|
|
|
225
219
|
import express from 'express';
|
|
226
220
|
{% endif %}
|
|
227
221
|
|
|
222
|
+
import minimist from 'minimist';
|
|
223
|
+
|
|
228
224
|
const run = async () => {
|
|
229
|
-
const args =
|
|
225
|
+
const args = minimist(process.argv.slice(2));
|
|
230
226
|
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
231
227
|
|
|
232
228
|
{{ defaultModeStandard('Node') }}
|
|
@@ -261,8 +257,9 @@ const Node = require('../../../cli');
|
|
|
261
257
|
const express = require('express');
|
|
262
258
|
{% endif %}
|
|
263
259
|
|
|
260
|
+
import minimist from "minimist"
|
|
264
261
|
const run = async () => {
|
|
265
|
-
const args =
|
|
262
|
+
const args = minimist(process.argv.slice(2));
|
|
266
263
|
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
267
264
|
|
|
268
265
|
{{ defaultModeExtend('Node') }}
|
|
@@ -291,8 +288,10 @@ const Node = require('../../../src');
|
|
|
291
288
|
const express = require('express');
|
|
292
289
|
{% endif %}
|
|
293
290
|
|
|
291
|
+
const minimist=require('minimist');
|
|
292
|
+
|
|
294
293
|
const run = async () => {
|
|
295
|
-
const args =
|
|
294
|
+
const args = minimist(process.argv.slice(2));
|
|
296
295
|
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
297
296
|
|
|
298
297
|
{{ defaultModeStandard('Node') }}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{% if atom.doc.features.project.format === 'esm' %}
|
|
2
2
|
import fnetArgs from '@fnet/args';
|
|
3
|
-
import validate from "./validate_input";
|
|
3
|
+
import validate,{schema as inputSchema} from "./validate_input";
|
|
4
|
+
|
|
4
5
|
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
5
6
|
const fnetArgs = require('@fnet/args');
|
|
6
|
-
const validate = require("./validate_input");
|
|
7
|
+
const validate,{schema as inputSchema} = require("./validate_input");
|
|
7
8
|
{% endif %}
|
|
8
9
|
|
|
9
10
|
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
|
|
39
40
|
export default async () => {
|
|
40
41
|
|
|
41
|
-
let schema =
|
|
42
|
+
let schema = inputSchema;
|
|
42
43
|
let initial;
|
|
43
44
|
|
|
44
45
|
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
@@ -77,7 +78,8 @@
|
|
|
77
78
|
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
78
79
|
|
|
79
80
|
module.exports = async () => {
|
|
80
|
-
|
|
81
|
+
|
|
82
|
+
let schema = inputSchema;
|
|
81
83
|
let initial;
|
|
82
84
|
|
|
83
85
|
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"lodash.merge";import t from"node:fs";import s from"node:path";import a from"@flownet/lib-render-templates-dir";import n from"nunjucks";import r from"@flownet/lib-parse-imports-js";import o from"@fnet/npm-pick-versions";import c from"object-hash";import i from"ajv/dist/2020.js";import p from"ajv/dist/standalone/index.js";import l from"ajv-formats";import f from"@fnet/shelljs";import{w as d}from"./index.js";function u({feature:t,features:s,packageDevDependencies:a}){const{name:n,packages:r,options:o,extraCheck:c,explicit:i}=t,p=`${n}_enabled`,l=s.rollup_output||{},f=Object.keys(l);let d=o||{};const u=s[n]?.options;u&&(d=e(d,u));const m=!s[n]||!1===s[n]?.enabled;f.forEach((e=>{const t=s.rollup_output[e];if(t){if(Reflect.has(t,n)){if(m||!t[n]||!1===t[n]?.enabled)return void delete t[n];!0===t[n]&&(t[n]={enabled:!0,options:d})}else{if(m||i||!1===s[p])return;t[n]={enabled:!0}}t[n]=t[n]||{},t[n].options={...d,...t[n].options}}}));let g=f.some((e=>!0===s.rollup_output[e][n]?.enabled));c&&(g=c()&&g),s[p]=g,g&&r.forEach((e=>a.push({package:e[0],version:e[1]})))}function m(e){const{atom:t,packageDevDependencies:s}=e;u({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:t.doc.features,packageDevDependencies:s})}function g(e){const{atom:t,packageDevDependencies:s}=e;u({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:t.doc.features,packageDevDependencies:s})}function k(e){const{atom:t,packageDevDependencies:s}=e;u({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:t.doc.features,packageDevDependencies:s})}function j(e){const{atom:t,packageDevDependencies:s}=e,a=t.doc.features,n={};!0===a.app?.enabled&&(n.targets=n.targets||[],n.targets.push({src:"./src/app/index.html",dest:a.app.dir}),Reflect.has(a.app,"copy")||Reflect.has(a,"copy")||(a.copy=!0)),u({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:n},features:a,packageDevDependencies:s})}function v(e){const{atom:t,packageDevDependencies:s}=e,a=t.doc.features,n=a.css&&!1!==a.css.enabled;let r=[];if(n){r.push(["rollup-plugin-postcss","^4"]),r.push(["sass","^1.66"]);(a.css?.options?.plugins||[]).forEach((e=>{switch(e.name){case"postcss-import":r.push(["postcss-import","^15"]);break;case"postcss-url":r.push(["postcss-url","^10"]);break;case"postcss-preset-env":r.push(["postcss-preset-env","^9"]);break;case"autoprefixer":r.push(["autoprefixer","^10"]);break;case"cssnano":r.push(["cssnano","^6"])}}))}u({feature:{name:"css",packages:r},features:a,packageDevDependencies:s})}async function D({atom:e,setProgress:n,context:r,packageDependencies:o}){if(!0!==e.doc.features.app.enabled)return;await n({message:"Creating app folder"});const c={atom:e,packageDependencies:o,ts:Date.now()},i=r.templateDir,p=s.resolve(r.projectDir,"src/app");t.existsSync(p)||t.mkdirSync(p,{recursive:!0});let l=["index.js.njk"];!1!==e.doc.features.app.html&&l.push("index.html.njk"),await a({pattern:l,dir:s.resolve(i,"src/app"),outDir:p,context:c})}async function h({projectDir:e,name:a,setProgress:n,count:r=1}){let i;const p=c(["npm-pick-versions",a,r]),l=s.join(e,".cache"),f=s.join(l,p+".json");return t.existsSync(f)?(n&&n(`Picking npm version of ${a} from cache ...`),i=JSON.parse(t.readFileSync(f,"utf8"))):(n&&n(`Picking npm version of ${a} ...`),i=await o({name:a,count:r}),t.mkdirSync(l,{recursive:!0}),t.writeFileSync(f,JSON.stringify(i),"utf8")),i}async function w({atom:e,context:a,packageDependencies:o,packageDevDependencies:c,setProgress:i}){await i({message:"Creating package.json."});o.filter((e=>!0===e.dev)).forEach((e=>{c.find((t=>t.package===e.package))||c.push(e);const t=o.findIndex((t=>t.package===e.package));o.splice(t,1)}));const p=o.find((e=>"react"===e.package)),l=o.find((e=>"react-dom"===e.package));p&&!l?o.push({package:"react-dom",version:p.version}):p&&l&&(l.version=p.version),p&&e.doc.features.react_version>=17&&(o.find((e=>"@emotion/react"===e.package))||o.push({package:"@emotion/react",version:"^11"}),o.find((e=>"@emotion/styled"===e.package))||o.push({package:"@emotion/styled",version:"^11"}));const f=[];!0===e.doc.features.app.enabled&&f.push({file:s.resolve(a.projectDir,"src/app/index.js"),dev:!1!==e.doc.features.app.dev}),!0===e.doc.features.cli.enabled&&f.push({file:s.resolve(a.projectDir,"src/cli/index.js"),dev:!1!==e.doc.features.cli.dev});for await(const e of f){const s=e.file;if(!t.existsSync(s))throw new Error(`App file not found: ${s}`);const n=(await r({file:s,recursive:!0})).all;for await(const t of n){if("npm"!==t.type)continue;if(o.find((e=>e.package===t.package)))continue;if(c.find((e=>e.package===t.package)))continue;const s=await h({name:t.package,projectDir:a.projectDir,setProgress:i});(!0===e.dev?c:o).push({package:t.package,subpath:t.subpath,version:s.minorRange,type:"npm"})}}const d={atom:e,packageDependencies:o,packageDevDependencies:c},u=a.templateDir,m=n.compile(t.readFileSync(s.resolve(u,"package.json.njk"),"utf8"),n.configure(u)).render(d),g=a.projectDir,k=s.resolve(g,"package.json");t.writeFileSync(k,m,"utf8");const j=s.resolve(a.project.projectDir,"fnet");if(t.existsSync(j)){const e=s.resolve(a.projectDir,"fnet");t.existsSync(e)||t.mkdirSync(e);const n=t.readdirSync(j);for(const a of n){const n=s.resolve(j,a);if(!t.lstatSync(n).isFile())continue;const r=s.resolve(e,a);t.copyFileSync(n,r)}}}async function y({atom:e,setProgress:n,context:r,packageDependencies:o}){if(!0!==e.doc.features.cli.enabled)return;await n({message:"Creating cli."});const c={atom:e,packageDependencies:o},i=r.templateDir,p=s.resolve(r.projectDir,"src/cli");t.existsSync(p)||t.mkdirSync(p,{recursive:!0}),await a({pattern:["index.js.njk"],dir:s.resolve(i,"src/cli"),outDir:p,context:c})}async function b({atom:e,setProgress:a,context:r,njEnv:o}){if(!0!==e.doc.features.cli.enabled)return;await a({message:"Creating input args."});let c={};if(c=e.doc.input?e.doc.input:{type:"object",properties:{},required:[]},e.doc.features.cli.fargs&&!1!==e.doc.features.cli.fargs?.enabled){const t=e.doc.features.cli.fargs,s={type:"string",description:"Config name to load args",hidden:!1},a={type:"array",description:"Tags to filter the config",hidden:!1};Reflect.has(t,"default")&&(s.default=t.default),c.properties&&(c.properties.fargs=s,c.properties.ftag=a)}const f={options:c,imports:[],atom:e},d=r.templateDir,u=n.compile(t.readFileSync(s.resolve(d,"src/default/input.args.js.njk"),"utf8"),o).render(f),m=r.projectDir,g=s.resolve(m,"src/default/input.args.js");t.writeFileSync(g,u,"utf8");const k=new i({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});l(k);const j=k.compile(c),v=p(k,j);t.writeFileSync(s.resolve(m,"src/default/validate_input.js"),v,"utf8")}async function x({atom:e,setProgress:a,context:r,packageDependencies:o}){await a({message:"Creating tsconfig.json."});const c={atom:e,packageDependencies:o},i=r.templateDir,p=n.compile(t.readFileSync(s.resolve(i,"tsconfig.json.njk"),"utf8"),n.configure(i)).render(c),l=r.projectDir,f=s.resolve(l,"tsconfig.json");t.writeFileSync(f,p,"utf8")}async function S({setProgress:e,context:t}){const a=t.projectDir;await e({message:"Prettifiying source files."});let n=s.join("src","**","*");if(d("bun")){const e=await f(`prettier --write ${n} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:a});if(0!==e.code)throw new Error(e.stderr)}else{const e=await f(`prettier --write ${n} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:a});if(0!==e.code)throw new Error(e.stderr)}}async function E({setProgress:e,atom:t,context:s}){const a=s.projectDir;if(await e({message:"Installing npm packages."}),d("bun")){if(0!==(await f(`bun install ${t.doc.features.npm_install_flags}`,{cwd:a})).code)throw new Error("Couldnt install npm packages.")}else{if(0!==(await f(`npm install ${t.doc.features.npm_install_flags}`,{cwd:a})).code)throw new Error("Couldnt install npm packages.")}}async function P({setProgress:e,context:t}){const s=t.projectDir;if(await e({message:"Building main project."}),d("bun")){if(0!==(await f(t.dev?"bun run build:dev":"bun run build",{cwd:s})).code)throw new Error("Couldnt build project.")}else{if(0!==(await f(t.dev?"npm run build:dev":"npm run build",{cwd:s})).code)throw new Error("Couldnt build project.")}}export{j as a,k as b,m as c,g as d,x as e,u as f,b as g,y as h,v as i,D as j,w as k,S as l,E as m,h as p,P as r};
|