@fnet/cli 0.2.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/fbin/index.js +2 -0
- package/dist/fnet/index.-SGbq2cI.js +1 -0
- package/dist/fnet/index.B0TQiWy6.js +1 -0
- package/dist/fnet/index.B5XE4ChJ.js +1 -0
- package/dist/fnet/index.Bft2w7m3.js +1 -0
- package/dist/fnet/index.BuYxdKtK.js +1 -0
- package/dist/fnet/index.C2S9JYhS.js +1 -0
- package/dist/fnet/index.C7saWH6d.js +1 -0
- package/dist/fnet/index.CDct_kkF.js +1 -0
- package/dist/fnet/index.CMC8mlye.js +1 -0
- package/dist/fnet/index.CmMM-Ek9.js +1 -0
- package/dist/fnet/index.CuMyez3E.js +1 -0
- package/dist/fnet/index.CzAV0S36.js +1 -0
- package/dist/fnet/index.D2N9YZmA.js +1 -0
- package/dist/fnet/index.D3p7pncT.js +1 -0
- package/dist/fnet/index.DG8TqL-1.js +1 -0
- package/dist/fnet/index.DI3yyTtl.js +1 -0
- package/dist/fnet/index.DWpw12No.js +1 -0
- package/dist/fnet/index.DrwlOzAe.js +1 -0
- package/dist/fnet/index.Q-CYRcna.js +1 -0
- package/dist/fnet/index.W6RYgypK.js +1 -0
- package/dist/fnet/index.js +2 -0
- package/dist/fnet/index.rSKuKke7.js +1 -0
- package/dist/fnet/index.xd8c7XMr.js +1 -0
- package/dist/fnode/index.-SGbq2cI.js +1 -0
- package/dist/fnode/index.1IxoA5DY.js +1 -0
- package/dist/fnode/index.B5XE4ChJ.js +1 -0
- package/dist/fnode/index.Bft2w7m3.js +1 -0
- package/dist/fnode/index.BuYxdKtK.js +1 -0
- package/dist/fnode/index.C2S9JYhS.js +1 -0
- package/dist/fnode/index.C7saWH6d.js +1 -0
- package/dist/fnode/index.CDct_kkF.js +1 -0
- package/dist/fnode/index.CJ4EhqPO.js +1 -0
- package/dist/fnode/index.CMC8mlye.js +1 -0
- package/dist/fnode/index.CmMM-Ek9.js +1 -0
- package/dist/fnode/index.CuMyez3E.js +1 -0
- package/dist/fnode/index.CzAV0S36.js +1 -0
- package/dist/fnode/index.D2N9YZmA.js +1 -0
- package/dist/fnode/index.D3p7pncT.js +1 -0
- package/dist/fnode/index.DG8TqL-1.js +1 -0
- package/dist/fnode/index.DI3yyTtl.js +1 -0
- package/dist/fnode/index.DWpw12No.js +1 -0
- package/dist/fnode/index.DrwlOzAe.js +1 -0
- package/dist/fnode/index.N_a5FdgA.js +1 -0
- package/dist/fnode/index.Q-CYRcna.js +1 -0
- package/dist/fnode/index.UNoFg95r.js +1 -0
- package/dist/fnode/index.W6RYgypK.js +1 -0
- package/dist/fnode/index.js +2 -0
- package/dist/fnode/index.tq-9YxMP.js +1 -0
- package/dist/fnode/index.xd8c7XMr.js +1 -0
- package/dist/frun/index.js +2 -0
- package/dist/fservice/index.js +2 -0
- package/package.json +89 -0
- package/readme.md +251 -0
- package/template/fnet/core/assert.js +6 -0
- package/template/fnet/core/message.js +3 -0
- package/template/fnet/core/object.js +47 -0
- package/template/fnet/core/print.js +1 -0
- package/template/fnet/core/sleep.js +5 -0
- package/template/fnet/node/.gitignore.njk +9 -0
- package/template/fnet/node/build.js.njk +153 -0
- package/template/fnet/node/package.json.njk +118 -0
- package/template/fnet/node/readme.md.njk +21 -0
- package/template/fnet/node/rollup.config.mjs.njk +498 -0
- package/template/fnet/node/src/app/index.html.njk +67 -0
- package/template/fnet/node/src/app/index.js.njk +36 -0
- package/template/fnet/node/src/cli/index.js.njk +319 -0
- package/template/fnet/node/src/default/blocks/assign.js.njk +53 -0
- package/template/fnet/node/src/default/blocks/call.js.njk +156 -0
- package/template/fnet/node/src/default/blocks/for.js.njk +87 -0
- package/template/fnet/node/src/default/blocks/form.js.njk +69 -0
- package/template/fnet/node/src/default/blocks/modules.js.njk +57 -0
- package/template/fnet/node/src/default/blocks/new.js.njk +87 -0
- package/template/fnet/node/src/default/blocks/next.js.njk +37 -0
- package/template/fnet/node/src/default/blocks/output.js.njk +53 -0
- package/template/fnet/node/src/default/blocks/raise.js.njk +31 -0
- package/template/fnet/node/src/default/blocks/return.js.njk +33 -0
- package/template/fnet/node/src/default/blocks/signal.js.njk +37 -0
- package/template/fnet/node/src/default/blocks/steps.js.njk +63 -0
- package/template/fnet/node/src/default/blocks/switch.js.njk +79 -0
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +74 -0
- package/template/fnet/node/src/default/blocks/wait.js.njk +34 -0
- package/template/fnet/node/src/default/engine.js.njk +79 -0
- package/template/fnet/node/src/default/input.args.js.njk +122 -0
- package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-entry-args.js.njk +2 -0
- package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-header.js.njk +14 -0
- package/template/fnet/node/src/default/macros/block-library-header.js.njk +43 -0
- package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
- package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
- package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
- package/template/fnet/node/src/default/macros/block-next.js.njk +21 -0
- package/template/fnet/node/src/default/macros/block-run-footer.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
- package/template/fnet/node/src/default/macros/block-run-header.js.njk +31 -0
- package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -0
- package/template/fnet/node/src/default/macros/page.js.njk +8 -0
- package/template/fnet/node/src/default/macros/workflow-header.js.njk +7 -0
- package/template/fnet/node/src/default/workflow.js.njk +123 -0
- package/template/fnet/node/tsconfig.json.njk +16 -0
- package/template/fnet/project/.gitignore.njk +7 -0
- package/template/fnet/project/.vscode/launch.json.njk +41 -0
- package/template/fnet/project/.vscode/tasks.json.njk +46 -0
- package/template/fnet/project/fnet/flows.yaml.njk +4 -0
- package/template/fnet/project/fnet/targets.yaml.njk +7 -0
- package/template/fnet/project/fnet.yaml.njk +3 -0
- package/template/fnode/node/.gitignore.njk +9 -0
- package/template/fnode/node/build.js.njk +149 -0
- package/template/fnode/node/package.json.njk +120 -0
- package/template/fnode/node/readme.md.njk +21 -0
- package/template/fnode/node/rollup.config.mjs.njk +498 -0
- package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
- package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
- package/template/fnode/node/src/app/index.html.njk +67 -0
- package/template/fnode/node/src/app/index.js.njk +9 -0
- package/template/fnode/node/src/cli/index.js.njk +403 -0
- package/template/fnode/node/src/default/engine.js.njk +17 -0
- package/template/fnode/node/src/default/input.args.js.njk +122 -0
- package/template/fnode/node/tsconfig.json.njk +16 -0
- package/template/fnode/project/.gitignore.njk +11 -0
- package/template/fnode/project/.vscode/launch.json.njk +78 -0
- package/template/fnode/project/.vscode/tasks.json.njk +46 -0
- package/template/fnode/project/fnet/targets.yaml.njk +25 -0
- package/template/fnode/project/fnode.yaml.njk +12 -0
- package/template/fnode/python/.gitignore.njk +7 -0
- package/template/fnode/python/package.json.njk +4 -0
- package/template/fnode/python/pyproject.toml.njk +3 -0
- package/template/fnode/python/readme.md.njk +12 -0
- package/template/fnode/python/setup.py.njk +19 -0
- package/template/fnode/python/src/cli/index.py.njk +25 -0
- package/template/schemas/to-npm.yaml +14 -0
package/readme.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# @fnet/cli: Flownet CLI
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/fnetai/cli/main/assets/flownet-logo.png" alt="Flownet Logo" width="200"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b>Focus on functional code, let Flownet handle the rest</b>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@fnet/cli"><img src="https://img.shields.io/npm/v/@fnet/cli.svg" alt="npm version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@fnet/cli"><img src="https://img.shields.io/npm/dm/@fnet/cli.svg" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://github.com/fnetai/cli/blob/main/LICENSE"><img src="https://img.shields.io/github/license/fnetai/cli.svg" alt="license"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
Flownet is a revolutionary development framework that isolates non-functional components, allowing developers to focus solely on functional code. The `@fnet/cli` package provides command-line tools to create, build, and manage Flownet projects.
|
|
20
|
+
|
|
21
|
+
### Key Features
|
|
22
|
+
|
|
23
|
+
- **Language Agnostic**: Support for multiple programming languages (JavaScript, Python) in the same project
|
|
24
|
+
- **Runtime Flexibility**: Choose the best runtime for each task (Node.js, Python, Bun)
|
|
25
|
+
- **Unified Interface**: Consistent commands across different project types
|
|
26
|
+
- **Tag-Based Configuration**: Powerful conditional configuration with `--ftag` parameter
|
|
27
|
+
- **Isolated Workspace**: All build artifacts and dependencies are kept in `.workspace` directory
|
|
28
|
+
- **Binary System**: Compile, install, and manage CLI tools with the integrated binary system
|
|
29
|
+
- **Project File Configuration**: Configure CLI features directly in your project files
|
|
30
|
+
- **Fast Startup**: Pre-compiled binaries start much faster than interpreted scripts
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Using npm
|
|
36
|
+
npm install -g @fnet/cli
|
|
37
|
+
|
|
38
|
+
# Using yarn
|
|
39
|
+
yarn global add @fnet/cli
|
|
40
|
+
|
|
41
|
+
# Using bun
|
|
42
|
+
bun install -g @fnet/cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### Create a New Project
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Create a Node.js project
|
|
51
|
+
fnode create my-node-project
|
|
52
|
+
|
|
53
|
+
# Create a Python project
|
|
54
|
+
fnode create my-python-project --runtime python
|
|
55
|
+
|
|
56
|
+
# Create a Bun project
|
|
57
|
+
fnode create my-bun-project --runtime bun
|
|
58
|
+
|
|
59
|
+
# Create a workflow project
|
|
60
|
+
fnet create my-workflow-project
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Build and Run
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Build the project
|
|
67
|
+
frun build
|
|
68
|
+
|
|
69
|
+
# Run the project
|
|
70
|
+
fnode cli
|
|
71
|
+
|
|
72
|
+
# Execute a command group from project file
|
|
73
|
+
frun <command-group> [--ftag <tags>]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Compile and Install
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Compile a JavaScript file to a binary
|
|
80
|
+
fbin compile script.js -o my-tool
|
|
81
|
+
|
|
82
|
+
# Install a compiled binary
|
|
83
|
+
fbin install ./my-tool --name awesome-tool
|
|
84
|
+
|
|
85
|
+
# Install a CLI-enabled project
|
|
86
|
+
cd my-project
|
|
87
|
+
fnode install --yes
|
|
88
|
+
|
|
89
|
+
# Or use npm scripts in your project
|
|
90
|
+
npm run compile
|
|
91
|
+
npm run install-bin
|
|
92
|
+
|
|
93
|
+
# List installed binaries
|
|
94
|
+
fbin list
|
|
95
|
+
|
|
96
|
+
# Uninstall a binary
|
|
97
|
+
fbin uninstall awesome-tool --yes
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Project Types
|
|
101
|
+
|
|
102
|
+
Flownet supports two main project types:
|
|
103
|
+
|
|
104
|
+
### fnode Project
|
|
105
|
+
|
|
106
|
+
An **fnode project** (Flow Node Project) is a classic/node-style project that focuses on creating reusable components or standalone applications. These projects:
|
|
107
|
+
|
|
108
|
+
- Use `fnode.yaml` as their configuration file
|
|
109
|
+
- Typically contain a single code file in the `src` directory
|
|
110
|
+
- Can be built with different runtimes (Node.js, Python, Bun)
|
|
111
|
+
- Support multiple programming languages simultaneously
|
|
112
|
+
|
|
113
|
+
### fnet Project
|
|
114
|
+
|
|
115
|
+
An **fnet project** (Flow Project) is a workflow-oriented project that focuses on orchestrating multiple components. These projects:
|
|
116
|
+
|
|
117
|
+
- Use `fnet.yaml` as their configuration file
|
|
118
|
+
- Define workflows that connect multiple components
|
|
119
|
+
- Support complex data flows and transformations
|
|
120
|
+
|
|
121
|
+
## CLI Tools
|
|
122
|
+
|
|
123
|
+
Flownet provides four main CLI tools:
|
|
124
|
+
|
|
125
|
+
- **`fnode`**: For Node/classic projects (uses `fnode.yaml`)
|
|
126
|
+
- **`fnet`**: For Workflow projects (uses `fnet.yaml`)
|
|
127
|
+
- **`frun`**: Unified interface that works with both project types (auto-detects project file)
|
|
128
|
+
- **`fbin`**: Binary management system for installing, compiling, and managing CLI tools
|
|
129
|
+
|
|
130
|
+
## Multi-Language Support
|
|
131
|
+
|
|
132
|
+
Flownet supports multiple programming languages simultaneously within the same project:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
my-project/
|
|
136
|
+
├── src/
|
|
137
|
+
│ ├── index.js # JavaScript implementation (used by both Node.js and Bun)
|
|
138
|
+
│ └── index.py # Python implementation
|
|
139
|
+
├── fnode.yaml # Project configuration file
|
|
140
|
+
└── .workspace/ # Build infrastructure (managed by CLI)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This allows you to:
|
|
144
|
+
|
|
145
|
+
- Write your core logic once and migrate it to other languages as needed
|
|
146
|
+
- Choose the best language for each specific use case
|
|
147
|
+
- Use JavaScript with Node.js for quick development, Python for data processing, and JavaScript with Bun for improved performance
|
|
148
|
+
|
|
149
|
+
## Tag-Based Configuration
|
|
150
|
+
|
|
151
|
+
Both CLI tools support the `--ftag` parameter for powerful conditional configuration:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
frun build --ftag dev --ftag local
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This activates sections in your project file marked with `t::dev::` or `t::local::` tags:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
# Base configuration
|
|
161
|
+
name: my-project
|
|
162
|
+
|
|
163
|
+
# Development environment configuration
|
|
164
|
+
t::dev::database:
|
|
165
|
+
url: "mongodb://localhost:27017"
|
|
166
|
+
|
|
167
|
+
# Production environment configuration
|
|
168
|
+
t::prod::database:
|
|
169
|
+
url: "mongodb://production-server:27017"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Binary System
|
|
173
|
+
|
|
174
|
+
Flownet includes a powerful binary system that makes it easy to create, distribute, and manage CLI tools:
|
|
175
|
+
|
|
176
|
+
### Binary System Features
|
|
177
|
+
|
|
178
|
+
- **Fast Startup**: Pre-compiled binaries start much faster than interpreted scripts
|
|
179
|
+
- **Cross-Platform Support**: Works on macOS, Linux, and Windows
|
|
180
|
+
- **Multiple Shell Support**: Compatible with Bash, Zsh, Fish, PowerShell, and more
|
|
181
|
+
- **Version Management**: Keeps track of binary versions and metadata
|
|
182
|
+
- **Project Integration**: Easily compile and install CLI-enabled projects
|
|
183
|
+
- **Automation Support**: All commands support the `--yes` flag for scripting
|
|
184
|
+
|
|
185
|
+
### Setup and Usage
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Initialize the bin system
|
|
189
|
+
fbin setup
|
|
190
|
+
|
|
191
|
+
# Add bin directory to PATH
|
|
192
|
+
fbin path
|
|
193
|
+
|
|
194
|
+
# Compile a JavaScript file to a binary
|
|
195
|
+
fbin compile script.js -o my-tool
|
|
196
|
+
|
|
197
|
+
# Install a binary to the bin directory
|
|
198
|
+
fbin install ./my-tool --name awesome-tool
|
|
199
|
+
|
|
200
|
+
# List installed binaries
|
|
201
|
+
fbin list
|
|
202
|
+
|
|
203
|
+
# Uninstall a binary
|
|
204
|
+
fbin uninstall awesome-tool
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Project Integration
|
|
208
|
+
|
|
209
|
+
The binary system integrates seamlessly with Flownet projects:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Compile and install a CLI-enabled fnode project
|
|
213
|
+
fnode compile
|
|
214
|
+
fnode install
|
|
215
|
+
|
|
216
|
+
# Compile and install a CLI-enabled fnet project
|
|
217
|
+
fnet compile
|
|
218
|
+
fnet install
|
|
219
|
+
|
|
220
|
+
# Using npm scripts in your project
|
|
221
|
+
npm run compile
|
|
222
|
+
npm run install-bin
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
This makes it easy to distribute your Flownet projects as standalone CLI tools.
|
|
226
|
+
|
|
227
|
+
### CLI Configuration in Project Files
|
|
228
|
+
|
|
229
|
+
You can configure CLI features directly in your project files:
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
# In fnode.yaml or fnet.yaml
|
|
233
|
+
name: my-project
|
|
234
|
+
|
|
235
|
+
features:
|
|
236
|
+
# For fnode projects
|
|
237
|
+
s::runtime.type: node # or python, bun
|
|
238
|
+
|
|
239
|
+
# CLI configuration
|
|
240
|
+
cli:
|
|
241
|
+
enabled: true
|
|
242
|
+
bin: custom-bin-name # Name of the binary (defaults to project name)
|
|
243
|
+
installable: true # Enable 'fnode install' or 'fnet install' command
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
This configuration will:
|
|
247
|
+
|
|
248
|
+
1. Enable CLI functionality for your project
|
|
249
|
+
2. Set the binary name to `custom-bin-name`
|
|
250
|
+
3. Add `compile` and `install-bin` scripts to your package.json
|
|
251
|
+
4. Allow you to install the binary with `fnode install` or `npm run install-bin`
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import getValue from "get-value";
|
|
2
|
+
import setValue from "set-value";
|
|
3
|
+
import print from "./print.js";
|
|
4
|
+
|
|
5
|
+
export default class Object {
|
|
6
|
+
#property;
|
|
7
|
+
#context;
|
|
8
|
+
#module;
|
|
9
|
+
|
|
10
|
+
constructor(context) {
|
|
11
|
+
|
|
12
|
+
this.#property = {}
|
|
13
|
+
this.#module = {};
|
|
14
|
+
this.#context = context;
|
|
15
|
+
|
|
16
|
+
this.get = (path, options) => {
|
|
17
|
+
return getValue(this.#property, path, options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.set = (path, value, options) => {
|
|
21
|
+
return setValue(this.#property, path, value, options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.print = print;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get module() {
|
|
28
|
+
return this.#module;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getModule(path) {
|
|
32
|
+
return getValue(this.#module, path);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setModule(path, module) {
|
|
36
|
+
if (typeof module !== "function") throw new Error("Module must be a function");
|
|
37
|
+
return setValue(this.#module, path, module);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get getValue() {
|
|
41
|
+
return getValue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get setValue() {
|
|
45
|
+
return setValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default console.log;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Build script for Bun projects
|
|
4
|
+
* This script uses Bun's built-in bundler instead of Rollup
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { join, dirname } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
|
|
12
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
|
|
14
|
+
async function ensureDir(dir) {
|
|
15
|
+
try {
|
|
16
|
+
await mkdir(dir, { recursive: true });
|
|
17
|
+
} catch (err) {
|
|
18
|
+
if (err.code !== 'EEXIST') throw err;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function buildOutput(name, config) {
|
|
23
|
+
console.log(`Building ${name}...`);
|
|
24
|
+
|
|
25
|
+
const outdir = config.outdir || join(__dirname, `dist/${name}`);
|
|
26
|
+
await ensureDir(outdir);
|
|
27
|
+
|
|
28
|
+
{% if atom.doc.features.app.enabled !== false %}
|
|
29
|
+
// Copy HTML file if it exists and this is an app build
|
|
30
|
+
if (name === 'app') {
|
|
31
|
+
try {
|
|
32
|
+
const htmlPath = './src/app/index.html';
|
|
33
|
+
if (fs.existsSync(htmlPath)) {
|
|
34
|
+
const htmlContent = await Bun.file(htmlPath).text();
|
|
35
|
+
await writeFile(join(outdir, 'index.html'), htmlContent);
|
|
36
|
+
}
|
|
37
|
+
} catch (err) {
|
|
38
|
+
if (err.code !== 'ENOENT') {
|
|
39
|
+
console.warn('Warning: Could not copy HTML file:', err.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
{% endif %}
|
|
44
|
+
|
|
45
|
+
const buildConfig = {
|
|
46
|
+
entrypoints: config.entrypoints || [`./src/${name}/index.js`],
|
|
47
|
+
outdir: outdir,
|
|
48
|
+
format: config.format || 'esm',
|
|
49
|
+
{% if atom.doc.features.runtime.target === 'bun' %}
|
|
50
|
+
target: "bun",
|
|
51
|
+
{% else %}
|
|
52
|
+
target: config.target || "browser",
|
|
53
|
+
{% endif %}
|
|
54
|
+
minify: config.minify !== undefined ? config.minify : false,
|
|
55
|
+
sourcemap: config.sourcemap || 'external',
|
|
56
|
+
splitting: true,
|
|
57
|
+
// Add environment variables to help with module resolution
|
|
58
|
+
define: {
|
|
59
|
+
'process.env.NODE_PATH': JSON.stringify('./node_modules')
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
plugins: [
|
|
63
|
+
...(config.plugins || [])
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if(config.external) buildConfig.external = config.external;
|
|
68
|
+
if(config.packages) buildConfig.packages = config.packages;
|
|
69
|
+
if(config.banner) buildConfig.banner = config.banner;
|
|
70
|
+
if(config.footer) buildConfig.footer = config.footer;
|
|
71
|
+
|
|
72
|
+
// Build with Bun.build
|
|
73
|
+
const result = await Bun.build(buildConfig);
|
|
74
|
+
|
|
75
|
+
if (!result.success) {
|
|
76
|
+
console.error(`${name} build failed:`, result.logs);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function main() {
|
|
84
|
+
try {
|
|
85
|
+
{% if atom.doc.features.project.format === 'esm' or atom.doc.features.project.format === undefined %}
|
|
86
|
+
// Build default ESM
|
|
87
|
+
await buildOutput('default', {
|
|
88
|
+
format: "esm",
|
|
89
|
+
target: "browser",
|
|
90
|
+
minify: false,
|
|
91
|
+
sourcemap: "external",
|
|
92
|
+
entrypoints: ["./src/default/index.js"],
|
|
93
|
+
outdir: "./dist/default/esm",
|
|
94
|
+
packages: "external"
|
|
95
|
+
});
|
|
96
|
+
{% endif %}
|
|
97
|
+
|
|
98
|
+
{% if atom.doc.features.project.format !== 'esm' %}
|
|
99
|
+
// Build default CJS
|
|
100
|
+
await buildOutput('defaultCjs', {
|
|
101
|
+
format: "cjs",
|
|
102
|
+
target: "browser",
|
|
103
|
+
minify: false,
|
|
104
|
+
sourcemap: "external",
|
|
105
|
+
entrypoints: ["./src/default/index.js"],
|
|
106
|
+
outdir: "./dist/default/cjs",
|
|
107
|
+
packages: "external"
|
|
108
|
+
});
|
|
109
|
+
{% endif %}
|
|
110
|
+
|
|
111
|
+
{% if atom.doc.features.cli.enabled !== false %}
|
|
112
|
+
// Build CLI if exists
|
|
113
|
+
if (fs.existsSync('./src/cli/index.js')) {
|
|
114
|
+
await buildOutput('cli', {
|
|
115
|
+
format: "esm",
|
|
116
|
+
target: "browser",
|
|
117
|
+
minify: false,
|
|
118
|
+
sourcemap: "external",
|
|
119
|
+
entrypoints: ["./src/cli/index.js"],
|
|
120
|
+
outdir: "{{ atom.doc.features.cli.dir | default('./dist/cli/esm') }}",
|
|
121
|
+
packages: "external",
|
|
122
|
+
banner: "#!/usr/bin/env bun"
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
console.log('CLI not found, skipping CLI build');
|
|
126
|
+
}
|
|
127
|
+
{% endif %}
|
|
128
|
+
|
|
129
|
+
{% if atom.doc.features.app.enabled !== false %}
|
|
130
|
+
// Build App if exists
|
|
131
|
+
if (fs.existsSync('./src/app/index.js')) {
|
|
132
|
+
await buildOutput('app', {
|
|
133
|
+
format: "esm",
|
|
134
|
+
target: "browser",
|
|
135
|
+
minify: false,
|
|
136
|
+
sourcemap: "external",
|
|
137
|
+
entrypoints: ["./src/app/index.js"],
|
|
138
|
+
outdir: "{{ atom.doc.features.app.dir | default('./dist/app/esm') }}",
|
|
139
|
+
packages: "bundle"
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
console.log('App not found, skipping App build');
|
|
143
|
+
}
|
|
144
|
+
{% endif %}
|
|
145
|
+
|
|
146
|
+
console.log('Build completed successfully!');
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.error('Build failed:', err);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
main();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{atom.doc['npm::name'] or atom.doc['name'] or atom['id']}}",
|
|
3
|
+
"version": "{{atom.doc['npm::version'] or '0.1.0'}}",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist/*",
|
|
6
|
+
"fnet/input.yaml",
|
|
7
|
+
"fnet/output.yaml"
|
|
8
|
+
],
|
|
9
|
+
{# "sideEffects": false, #}
|
|
10
|
+
{% if atom.doc['npm::author'] %}
|
|
11
|
+
"author": "{{atom.doc['npm::author'] | safe}}",
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if atom.doc['npm::description'] %}
|
|
15
|
+
"description": "{{atom.doc['npm::description'] | safe}}",
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
19
|
+
{% if atom.doc.features.rollup_output.esm.enabled === true%}
|
|
20
|
+
"main": "dist/default/esm/index.js",
|
|
21
|
+
"type":"module",
|
|
22
|
+
{% else %}
|
|
23
|
+
"main": "dist/default/cjs/index.cjs",
|
|
24
|
+
{% endif %}
|
|
25
|
+
|
|
26
|
+
{% if atom.doc.features.dts_enabled ===true %}
|
|
27
|
+
"types": "dist/default/types/index.d.ts",
|
|
28
|
+
{% endif %}
|
|
29
|
+
|
|
30
|
+
"exports":{
|
|
31
|
+
".":{
|
|
32
|
+
"import":"./dist/default/esm/index.js",
|
|
33
|
+
"require":"./dist/default/cjs/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{% else %}
|
|
37
|
+
"main": "dist/default/esm/index.js",
|
|
38
|
+
{% if atom.doc.features.dts_enabled ===true %}
|
|
39
|
+
"types": "dist/default/types/index.d.ts",
|
|
40
|
+
{% endif %}
|
|
41
|
+
"type":"module",
|
|
42
|
+
"exports":{
|
|
43
|
+
".":{
|
|
44
|
+
"import":"./dist/default/esm/index.js",
|
|
45
|
+
"require":"./dist/default/cjs/index.cjs"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{% endif %}
|
|
49
|
+
"flownet": {
|
|
50
|
+
"type": "flow",
|
|
51
|
+
},
|
|
52
|
+
{% if atom.doc.repo.url %}
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "{{atom.doc.repo.type or 'git'}}",
|
|
55
|
+
"url": "{{atom.doc.repo.url}}"
|
|
56
|
+
},
|
|
57
|
+
{% endif %}
|
|
58
|
+
"license": "{{atom.doc.license or 'MIT'}}",
|
|
59
|
+
"scripts": {
|
|
60
|
+
{% if atom.doc.features.runtime.type === 'bun' %}
|
|
61
|
+
"build": "bun ./build.js",
|
|
62
|
+
"build:dev": "bun ./build.js --dev",
|
|
63
|
+
"watch": "bun --watch --watch-mode=poll --watch-ignore-dirs=node_modules,dist --watch-paths=./src ./build.js --dev",
|
|
64
|
+
"serve": "bunx serve ./"
|
|
65
|
+
{% else %}
|
|
66
|
+
"build": "rollup --config",
|
|
67
|
+
"build:dev": "rollup --config --sourcemap --environment DEVELOPMENT",
|
|
68
|
+
"watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT --environment FLOWNET_WATCH",
|
|
69
|
+
"serve": "bunx serve ./"
|
|
70
|
+
{% endif %}
|
|
71
|
+
|
|
72
|
+
{% if atom.doc.features.cli.enabled %}
|
|
73
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
74
|
+
,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs"
|
|
75
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
76
|
+
,"mcp": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs --cli-mode=mcp"
|
|
77
|
+
,"mcp-inspect": "bunx @modelcontextprotocol/inspector bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs --cli-mode=mcp"
|
|
78
|
+
{% endif %}
|
|
79
|
+
{% else %}
|
|
80
|
+
,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}}"
|
|
81
|
+
,"cli:dev": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}}"
|
|
82
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
83
|
+
,"cli:mcp": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}} --cli-mode=mcp"
|
|
84
|
+
,"cli:mcp:inspect": "bunx @modelcontextprotocol/inspector bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}} --cli-mode=mcp"
|
|
85
|
+
,"cli:mcp:dev": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}} --cli-mode=mcp"
|
|
86
|
+
,"cli:mcp:inspect:dev": "bunx @modelcontextprotocol/inspector bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}} --cli-mode=mcp"
|
|
87
|
+
{% endif %}
|
|
88
|
+
{% endif %}
|
|
89
|
+
,"cli:compile": "fbin compile {{atom.doc.features.cli.output.file}} -o .bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
|
|
90
|
+
,"cli:compile:dev": "fbin compile {{atom.doc.features.cli.input.file}} -o .bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
|
|
91
|
+
,"cli:install": "fbin install ./.bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
|
|
92
|
+
{% endif %}
|
|
93
|
+
|
|
94
|
+
{% if atom.doc.features.app.enabled %}
|
|
95
|
+
,"app": "bunx serve {{atom.doc.features.app.dir}}/"
|
|
96
|
+
{% endif %}
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
{% for dep in packageDevDependencies %}
|
|
100
|
+
"{{dep.package}}":"{{dep.version}}" {% if not loop.last%},{%endif%}
|
|
101
|
+
{% endfor%}
|
|
102
|
+
},
|
|
103
|
+
"dependencies": {
|
|
104
|
+
{% for dep in packageDependencies %}
|
|
105
|
+
"{{dep.package}}":"{{dep.version}}" {% if not loop.last%},{%endif%}
|
|
106
|
+
{% endfor%}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
{% if atom.doc.features.cli.enabled and atom.doc['npm::bin'] %}
|
|
110
|
+
,"bin":{
|
|
111
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
112
|
+
"{{atom.doc['npm::bin']}}":"{{atom.doc.features.cli.dir}}/index.cjs"
|
|
113
|
+
{% else %}
|
|
114
|
+
"{{atom.doc['npm::bin']}}":"{{atom.doc.features.cli.output.file}}"
|
|
115
|
+
{% endif %}
|
|
116
|
+
}
|
|
117
|
+
{% endif %}
|
|
118
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{{content | safe}}
|
|
2
|
+
|
|
3
|
+
{% if howto %}
|
|
4
|
+
{{howto | safe}}
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
{% if input %}
|
|
8
|
+
# Input Schema
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
{{ input | safe}}
|
|
12
|
+
```
|
|
13
|
+
{% endif %}
|
|
14
|
+
|
|
15
|
+
{% if output %}
|
|
16
|
+
# Output Schema
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
{{ output | safe}}
|
|
20
|
+
```
|
|
21
|
+
{% endif %}
|