@maligator/cli 0.1.0-alpha.1 → 0.1.0-alpha.2
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 +162 -6
- package/index.d.ts +84 -0
- package/index.js +8 -0
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -1,14 +1,170 @@
|
|
|
1
1
|
# @maligator/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Maligator](https://github.com/dirkdev98/maligator) is a lean
|
|
4
|
+
ahead-of-time JavaScript-to-C compiler and native runtime. It turns a JavaScript or
|
|
5
|
+
erasable TypeScript entry point into a standalone native executable.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
This package is the npm launcher for the prebuilt Maligator CLI. The project is
|
|
8
|
+
pre-1.0; install prereleases through the `alpha` channel.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Install the current alpha globally:
|
|
6
13
|
|
|
7
14
|
```shell
|
|
8
15
|
npm install --global @maligator/cli@alpha
|
|
9
16
|
```
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
Or keep it in a project and invoke it through `npx`:
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
npm install --save-dev @maligator/cli@alpha
|
|
22
|
+
npx maligator --version
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The npm launcher requires Node.js 20 or newer. The native CLI and applications
|
|
26
|
+
produced by it do not require Node.js.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
From the root of an application project:
|
|
31
|
+
|
|
32
|
+
```shell
|
|
33
|
+
maligator init
|
|
34
|
+
maligator doctor
|
|
35
|
+
maligator build
|
|
36
|
+
maligator run -- first-argument "two words"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`maligator init` creates `maligator.build.ts`. If it cannot find an existing entry
|
|
40
|
+
point, it also creates `src/index.ts`. `doctor` checks the native build toolchain,
|
|
41
|
+
`build` produces a development executable, and `run` builds and launches it while
|
|
42
|
+
forwarding everything after `--` to the application.
|
|
43
|
+
|
|
44
|
+
Useful commands:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
maligator --help
|
|
48
|
+
maligator --version
|
|
49
|
+
maligator init
|
|
50
|
+
maligator doctor [--verbose] [--target rust-triple]
|
|
51
|
+
maligator build [entry] [--production] [--artifact directory] [--target rust-triple] [--config path]
|
|
52
|
+
maligator run [entry] [--config path] [-- args...]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run commands from the project root. Maligator does not search parent directories
|
|
56
|
+
for configuration.
|
|
57
|
+
|
|
58
|
+
## Production builds
|
|
59
|
+
|
|
60
|
+
Use production mode for a deployable binary:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
maligator build --production
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Production builds use optimized native compilation, add LTO when the toolchain
|
|
67
|
+
supports it, and strip native symbols when possible. To create a self-contained
|
|
68
|
+
artifact directory with a manifest, license, checksum, and binary:
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
maligator build --production --artifact dist/my-application
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The artifact destination must be absent or empty. Launch the reported binary
|
|
75
|
+
directly; neither Node.js nor the Maligator CLI is needed at runtime.
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
`maligator.build.ts` is trusted TypeScript configuration. A small configuration
|
|
80
|
+
looks like this:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { defineBuild } from "@maligator/cli";
|
|
84
|
+
|
|
85
|
+
export default defineBuild({
|
|
86
|
+
entry: "src/index.ts",
|
|
87
|
+
outputName: "my-application",
|
|
88
|
+
engine: {
|
|
89
|
+
eval: false,
|
|
90
|
+
intl: { enabled: false },
|
|
91
|
+
},
|
|
92
|
+
surface: {
|
|
93
|
+
webPlatform: false,
|
|
94
|
+
node: false,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
All fields are optional. Maligator excludes optional engine and host surfaces unless
|
|
100
|
+
the configuration requests them. See the
|
|
101
|
+
[full configuration reference](https://github.com/dirkdev98/maligator#configuration)
|
|
102
|
+
for assets, Intl features, Node compatibility, web-platform support, and target
|
|
103
|
+
selection.
|
|
104
|
+
|
|
105
|
+
## TypeScript
|
|
106
|
+
|
|
107
|
+
The package includes declarations for `maligator.build.ts` and Maligator's runtime
|
|
108
|
+
globals. Keeping the generated build file inside your TypeScript project makes the
|
|
109
|
+
types available automatically:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const path = mal.assets.materialize("templates", {
|
|
113
|
+
baseDirectory: ".cache/my-application",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const server = Mal.serve({
|
|
117
|
+
hostname: "127.0.0.1",
|
|
118
|
+
port: 3000,
|
|
119
|
+
async fetch(request) {
|
|
120
|
+
return new Response(`Hello from ${request.url}`);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log(path, server.port);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`mal` is present when `surface.maligator` is enabled. `Mal` and `Mal.serve` are
|
|
128
|
+
present when `surface.webPlatform` is enabled. The declarations describe both
|
|
129
|
+
optional surfaces, while `maligator.build.ts` controls which globals exist in the
|
|
130
|
+
compiled application.
|
|
131
|
+
|
|
132
|
+
If your `tsconfig.json` excludes `maligator.build.ts`, load the declarations
|
|
133
|
+
explicitly:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"compilerOptions": {
|
|
138
|
+
"types": ["@maligator/cli"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Build toolchain
|
|
144
|
+
|
|
145
|
+
The compiler CLI is prebuilt, but compiling an application requires:
|
|
146
|
+
|
|
147
|
+
- A C23 compiler and archive tool: Apple clang, clang 19 or newer, or GCC 15 or
|
|
148
|
+
newer
|
|
149
|
+
- Rustup with the `cargo` and `rustc` toolchain selected by Maligator
|
|
150
|
+
- A C++ compiler/runtime only when `surface.webPlatform` is enabled
|
|
151
|
+
|
|
152
|
+
On macOS, install Apple command-line tools with `xcode-select --install`. On Linux,
|
|
153
|
+
install a recent compiler and set `CC` and `CXX` when it is not your system default.
|
|
154
|
+
Run `maligator doctor --verbose` for resolved tool paths, versions, capabilities,
|
|
155
|
+
and installation hints. The
|
|
156
|
+
[native toolchain guide](https://github.com/dirkdev98/maligator#native-toolchain)
|
|
157
|
+
has the full requirements and cross-compilation instructions.
|
|
158
|
+
|
|
159
|
+
## Alpha support
|
|
160
|
+
|
|
161
|
+
`0.1.0-alpha.1` provides native packages for macOS and glibc-based Linux on arm64
|
|
162
|
+
and x64. Later alpha releases currently default to Apple Silicon macOS; consult the
|
|
163
|
+
release notes before upgrading on another host. Windows is not supported.
|
|
164
|
+
|
|
165
|
+
There is no source-build fallback for the CLI package. The alpha binaries are
|
|
166
|
+
unsigned, and macOS binaries are not notarized. APIs, configuration, and supported
|
|
167
|
+
hosts may change before 1.0.
|
|
168
|
+
|
|
169
|
+
Please report problems through the
|
|
170
|
+
[Maligator issue tracker](https://github.com/dirkdev98/maligator/issues).
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
|
|
3
|
+
export type MaligatorIntlFeature =
|
|
4
|
+
| "collator"
|
|
5
|
+
| "number-format"
|
|
6
|
+
| "date-time-format"
|
|
7
|
+
| "plural-rules"
|
|
8
|
+
| "list-format"
|
|
9
|
+
| "segmenter"
|
|
10
|
+
| "display-names"
|
|
11
|
+
| "relative-time-format"
|
|
12
|
+
| "duration-format";
|
|
13
|
+
|
|
14
|
+
export type AssetInclusion =
|
|
15
|
+
| { type: "file"; path: string }
|
|
16
|
+
| { type: "directory"; path: string; include: Array<string> };
|
|
17
|
+
|
|
18
|
+
export interface MaligatorBuildConfig {
|
|
19
|
+
entry?: string;
|
|
20
|
+
outputName?: string;
|
|
21
|
+
assets?: Record<string, AssetInclusion>;
|
|
22
|
+
engine?: {
|
|
23
|
+
eval?: boolean;
|
|
24
|
+
realms?: boolean;
|
|
25
|
+
regexp?: boolean;
|
|
26
|
+
intl?: {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
features?: Array<MaligatorIntlFeature>;
|
|
29
|
+
languages?: Array<string>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
host?: {
|
|
33
|
+
scheduler?: "single" | "multiprocessing";
|
|
34
|
+
};
|
|
35
|
+
surface?: {
|
|
36
|
+
webPlatform?: boolean;
|
|
37
|
+
node?: boolean;
|
|
38
|
+
maligator?: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare function defineBuild<const Config extends MaligatorBuildConfig>(
|
|
43
|
+
config: Config,
|
|
44
|
+
): Config;
|
|
45
|
+
|
|
46
|
+
export interface MaligatorMaterializeOptions {
|
|
47
|
+
baseDirectory?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface MaligatorAssets {
|
|
51
|
+
materialize(name: string, options?: MaligatorMaterializeOptions): string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface MaligatorRuntime {
|
|
55
|
+
readonly assets: MaligatorAssets;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface MaligatorServeOptions {
|
|
59
|
+
hostname?: string;
|
|
60
|
+
port?: number;
|
|
61
|
+
fetch(request: Request): Response | PromiseLike<Response>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface MaligatorServer {
|
|
65
|
+
readonly port: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface MaligatorWebRuntime {
|
|
69
|
+
serve(options: MaligatorServeOptions): MaligatorServer;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare global {
|
|
73
|
+
/**
|
|
74
|
+
* Maligator's core runtime namespace. Present when
|
|
75
|
+
* `surface.maligator` is enabled.
|
|
76
|
+
*/
|
|
77
|
+
var mal: MaligatorRuntime;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Maligator's web-host extension namespace. Present when
|
|
81
|
+
* `surface.webPlatform` is enabled.
|
|
82
|
+
*/
|
|
83
|
+
var Mal: MaligatorWebRuntime;
|
|
84
|
+
}
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maligator/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Ahead-of-time JavaScript compiler and native runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/dirkdev98/maligator#readme",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"runtime"
|
|
20
20
|
],
|
|
21
21
|
"publishConfig": {
|
|
22
|
-
"access": "public"
|
|
22
|
+
"access": "public",
|
|
23
|
+
"tag": "alpha"
|
|
23
24
|
},
|
|
24
25
|
"type": "module",
|
|
25
26
|
"engines": {
|
|
@@ -27,16 +28,22 @@
|
|
|
27
28
|
},
|
|
28
29
|
"files": [
|
|
29
30
|
"bin/maligator.js",
|
|
31
|
+
"index.js",
|
|
32
|
+
"index.d.ts",
|
|
30
33
|
"README.md",
|
|
31
34
|
"LICENSE"
|
|
32
35
|
],
|
|
33
36
|
"bin": {
|
|
34
37
|
"maligator": "bin/maligator.js"
|
|
35
38
|
},
|
|
39
|
+
"types": "./index.d.ts",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./index.d.ts",
|
|
43
|
+
"import": "./index.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
36
46
|
"optionalDependencies": {
|
|
37
|
-
"@maligator/cli-darwin-arm64": "0.1.0-alpha.
|
|
38
|
-
"@maligator/cli-darwin-x64": "0.1.0-alpha.1",
|
|
39
|
-
"@maligator/cli-linux-arm64": "0.1.0-alpha.1",
|
|
40
|
-
"@maligator/cli-linux-x64": "0.1.0-alpha.1"
|
|
47
|
+
"@maligator/cli-darwin-arm64": "0.1.0-alpha.2"
|
|
41
48
|
}
|
|
42
49
|
}
|