fly-lang 0.3.6

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/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # fly-lang (npm)
2
+
3
+ Fly-Lang 的 npm 分发包:把预编译的 Go 二进制打进 npm 包,`npm install -g` 后直接获得 `fly` 命令。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g fly-lang
9
+ ```
10
+
11
+ 支持平台:Linux(x64/arm64)、macOS(x64/arm64)、Windows(x64/arm64)。
12
+
13
+ ## 使用
14
+
15
+ ```bash
16
+ fly build example.fly -o out.py
17
+ fly check app.fly
18
+ fly run app.fly
19
+ fly error E0031 # 查询错误码示例报错与修复方法
20
+ fly update # 自更新(GitHub Releases 渠道,与原生安装一致)
21
+ ```
22
+
23
+ ## 工作原理
24
+
25
+ - `bin/` 打包全部平台的静态二进制(Go 交叉编译,CGO_ENABLED=0)
26
+ - `fly` 入口(package.json `bin`)由 `cli.js` 按 `process.platform + process.arch` 选择二进制并透传参数(`spawnSync` inherit stdio,退出码透传)
27
+ - 版本号与 Go 版本同步:CI 用 tag(`v0.3.6`)注入 package.json version
28
+
29
+ ## 发布
30
+
31
+ 完整发布走 GitHub Actions(release.yml 的 `npm` job:三平台交叉编译 → 组装 → `npm publish`),依赖 `NPM_TOKEN` secret,未配置时跳过发布只留 artifact。
package/bin/.gitkeep ADDED
@@ -0,0 +1,4 @@
1
+ # 本目录存放 CI 注入的预编译二进制:
2
+ # fly-linux-amd64 / fly-linux-arm64
3
+ # fly-darwin-amd64 / fly-darwin-arm64
4
+ # fly-windows-amd64.exe / fly-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/cli.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+
8
+ const BIN_MAP = {
9
+ linux: { x64: "fly-linux-amd64", arm64: "fly-linux-arm64" },
10
+ darwin: { x64: "fly-darwin-amd64", arm64: "fly-darwin-arm64" },
11
+ win32: { x64: "fly-windows-amd64.exe", arm64: "fly-windows-arm64.exe" },
12
+ };
13
+
14
+ function binaryPath() {
15
+ const binDir = path.join(__dirname, "bin");
16
+ const sys = process.platform;
17
+ const arch = process.arch;
18
+ const name = BIN_MAP[sys] && BIN_MAP[sys][arch];
19
+ if (name) {
20
+ const p = path.join(binDir, name);
21
+ if (fs.existsSync(p)) {
22
+ return p;
23
+ }
24
+ }
25
+ const fallbacks = [path.join(binDir, "fly"), path.join(__dirname, "..", "..", "fly")];
26
+ for (const c of fallbacks) {
27
+ if (fs.existsSync(c)) {
28
+ return c;
29
+ }
30
+ }
31
+ console.error(`未找到 ${sys}/${arch} 的 fly 二进制,请检查安装是否完整(bin/)`);
32
+ process.exit(1);
33
+ }
34
+
35
+ function main() {
36
+ const binary = binaryPath();
37
+ if (process.platform !== "win32") {
38
+ fs.chmodSync(binary, 0o755);
39
+ }
40
+ const r = spawnSync(binary, process.argv.slice(2), {
41
+ stdio: "inherit",
42
+ windowsHide: false,
43
+ });
44
+ if (r.error) {
45
+ console.error(r.error.message);
46
+ process.exit(1);
47
+ }
48
+ process.exit(r.status === null ? 1 : r.status);
49
+ }
50
+
51
+ main();
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "fly-lang",
3
+ "version": "0.3.6",
4
+ "description": "Fly-Lang: Python 3.10+ 安全增强超集转译器(safe/only/lock/mask/cage/guard/seal/trace)",
5
+ "license": "MIT",
6
+ "author": "anan29_china (https://www.npmjs.com/~anan29_china)",
7
+ "bin": {
8
+ "fly": "cli.js"
9
+ },
10
+ "files": [
11
+ "cli.js",
12
+ "bin"
13
+ ],
14
+ "keywords": [
15
+ "transpiler",
16
+ "python",
17
+ "security",
18
+ "compiler"
19
+ ],
20
+ "engines": {
21
+ "node": ">=14"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/29anan29/Fly-lang.git"
26
+ }
27
+ }