ts2077 1.0.0 → 1.0.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/CHANGELOG.md +21 -11
- package/README.md +102 -174
- package/docs/README.md +2 -2
- package/docs/commands.md +125 -125
- package/docs/configuration.md +120 -120
- package/docs/debugging.md +1 -1
- package/docs/examples.md +0 -2
- package/docs/guide/deployment.md +15 -15
- package/docs/guide/first-plugin.md +22 -22
- package/docs/guide/quick-start.md +32 -32
- package/docs/index.html +872 -872
- package/docs/install.md +108 -95
- package/docs/limitations.md +1 -1
- package/package.json +77 -77
- package/packages/cli/dist/cli.js +27 -25
- package/packages/compiler/dist/build.d.ts +1 -0
- package/packages/compiler/dist/build.js +22 -4
- package/packages/compiler/dist/index.d.ts +1 -1
- package/packages/compiler/dist/index.js +2 -1
- package/packages/types/dist/generate.js +0 -2
- package/packages/types/generated/catalogue.json +1 -1
- package/packages/types/generated/client.d.ts +0 -1
- package/packages/types/generated/server.d.ts +0 -1
- package/packages/types/generated/shared.d.ts +0 -1
package/docs/install.md
CHANGED
|
@@ -1,95 +1,108 @@
|
|
|
1
|
-
# Install
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
##
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
# Install
|
|
2
|
+
|
|
3
|
+
## Install the package
|
|
4
|
+
|
|
5
|
+
Node.js 20 or newer. A Node companion needs Node.js 22.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx ts2077 create my_plugin --template basic --no-install
|
|
9
|
+
cd my_plugin
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The npm package is `ts2077`. The commands are `ts77` and `open77-ts`. The rest of this page is for working on the TS77 repository itself.
|
|
15
|
+
|
|
16
|
+
## What the repository build needs
|
|
17
|
+
|
|
18
|
+
- Node.js 20 or newer. `ts77 doctor` fails below 20 and warns below 22.
|
|
19
|
+
- An OPEN//77 dedicated server if you want to deploy a resource. Compiling a plugin does not require one.
|
|
20
|
+
- The Devkit index produced by:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx -y @open2077/mcp init --server-dir <server-directory>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The generator reads the newest `cards.json` under `~/.open77/mcp/index`, or the directory in `OPEN77_INDEX_DIR`. It refuses cards whose `since` is missing or newer than that index. The embedded npm copy of the Devkit is older and is not used.
|
|
27
|
+
|
|
28
|
+
## Install the toolchain
|
|
29
|
+
|
|
30
|
+
From the repository root:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
npm run build:tools
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`build:tools` compiles the type generator, compiler, and CLI, regenerates `packages/types/generated` from the index, then compiles the shared codec and the Node companion. After that, `npx open77-ts` runs `packages/cli/dist/cli.js`.
|
|
38
|
+
|
|
39
|
+
`npm test` runs `build:tools` and then `tests/framework.test.cjs` and `tests/bridge.test.cjs`.
|
|
40
|
+
|
|
41
|
+
## Packages the compiler resolves
|
|
42
|
+
|
|
43
|
+
These import names are resolved from inside the `ts2077` package. They are not separate packages on the public npm registry.
|
|
44
|
+
|
|
45
|
+
| Import | Runs in | Source |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `@open77-ts/client` and `@open77/sdk/client` | Client Lua | `packages/sdk/src/client` |
|
|
48
|
+
| `@open77-ts/server` and `@open77/sdk/server` | Server Lua | `packages/sdk/src/server` |
|
|
49
|
+
| `@open77-ts/server/bridge` | Server Lua | `packages/sdk/src/server/bridge.ts` |
|
|
50
|
+
| `@open77-ts/shared` in gameplay | Lua | `packages/shared/src/contracts.ts` |
|
|
51
|
+
| `@open77-ts/shared` in Node | Node | `packages/shared` (contracts plus the codec) |
|
|
52
|
+
| `@open77-ts/node` | Node only | `packages/node` |
|
|
53
|
+
| `@open77-ts/webui` | The page only | `packages/webui/src/index.ts` |
|
|
54
|
+
|
|
55
|
+
A Lua build or a page build that imports `@open77-ts/node`, `fs`, `mysql2`, `pg`, `ioredis`, `fastify`, or `zod` is a compiler error. A page that imports the client or server SDK is a compiler error. A Node file that imports the client, server, or WebUI SDK is a compiler error.
|
|
56
|
+
|
|
57
|
+
## WebUI dependencies
|
|
58
|
+
|
|
59
|
+
Vite and React are installed in the interface folder, not at the repository root. For the notes example:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install --prefix examples/player_notes/src/webui
|
|
63
|
+
node examples/player_notes/src/webui/node_modules/esbuild/install.js
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The second command is required when npm blocks esbuild's postinstall script. Without the binary, `vite build` cannot run. The `webui` template uses `ui/` instead of `src/webui/` and needs the same two commands there.
|
|
67
|
+
|
|
68
|
+
## Server configuration the companion needs
|
|
69
|
+
|
|
70
|
+
Outbound HTTP is off until `server.jsonc` names a destination. `allowedHosts` is a hostname with no scheme, path, or port:
|
|
71
|
+
|
|
72
|
+
```jsonc
|
|
73
|
+
"http": { "enabled": true, "allowedHosts": ["127.0.0.1"] }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
That entry allows `http://127.0.0.1:11782/...`. Redirects are never followed.
|
|
77
|
+
|
|
78
|
+
The reverse direction, Node calling the game, uses the opt-in listener:
|
|
79
|
+
|
|
80
|
+
```jsonc
|
|
81
|
+
"httpHandlers": { "enabled": true, "listenUrl": "http://127.0.0.1:11781", "timeoutSeconds": 5 }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
It is plain HTTP, loopback by default, and off until `enabled` is true. A resource that calls `Open77.http.listen` while the listener is off gets `http_handlers_unavailable` and keeps running. Outbound calls do not need this block.
|
|
85
|
+
|
|
86
|
+
## Secret
|
|
87
|
+
|
|
88
|
+
Generate one shared secret, 16 to 256 characters. Put it in the environment of the Node process:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# PowerShell
|
|
92
|
+
$env:OPEN77_BRIDGE_SECRET = "replace-with-16-or-more-chars"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
On the game server, set the same value as the convar or tunable `open77_bridge_secret`. The resource declares that tunable with an empty default. Do not write the secret into `server.jsonc`, client TypeScript, or the page. The schema for `convars` says that file is the wrong place for credentials.
|
|
96
|
+
|
|
97
|
+
`OPEN77_BRIDGE_PORT` defaults to `11782`. `OPEN77_NOTES_DRIVER` is `memory`, `mysql`, `postgres`, or `redis`. `OPEN77_DATABASE_URL` is required for the three database drivers.
|
|
98
|
+
|
|
99
|
+
## Regenerating declarations
|
|
100
|
+
|
|
101
|
+
When a newer Devkit index is published:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx -y @open2077/mcp init --server-dir <server-directory>
|
|
105
|
+
npm run generate
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`npx open77-ts types` runs the same generator. Do not hand-edit `packages/types/generated` or `packages/sdk/src/shared/reserved.ts`.
|
package/docs/limitations.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Limitations
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package targets OPEN//77 catalogue **2.50.0+op77.148**. A native added in a later server build is not declared until that catalogue is updated. A native removed from the catalogue is not invented.
|
|
4
4
|
|
|
5
5
|
## Runtime
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ts2077",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "TypeScript framework for OPEN//77 plugins. Compiles gameplay to Lua 5.4 and can host a React WebUI and an optional Node companion.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/ImViloh/TS77.git"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://imviloh.github.io/TS77/",
|
|
11
|
-
"bugs": "https://github.com/ImViloh/TS77/issues",
|
|
12
|
-
"type": "commonjs",
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=20"
|
|
15
|
-
},
|
|
16
|
-
"bin": {
|
|
17
|
-
"ts77": "./packages/cli/dist/cli.js",
|
|
18
|
-
"open77-ts": "./packages/cli/dist/cli.js"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"packages/cli/dist",
|
|
22
|
-
"packages/compiler/dist",
|
|
23
|
-
"packages/types/dist",
|
|
24
|
-
"packages/types/generated",
|
|
25
|
-
"packages/sdk/src",
|
|
26
|
-
"packages/shared/dist",
|
|
27
|
-
"packages/shared/src",
|
|
28
|
-
"packages/shared/package.json",
|
|
29
|
-
"packages/node/dist",
|
|
30
|
-
"packages/node/src",
|
|
31
|
-
"packages/node/package.json",
|
|
32
|
-
"packages/client/package.json",
|
|
33
|
-
"packages/server/package.json",
|
|
34
|
-
"packages/webui",
|
|
35
|
-
"templates",
|
|
36
|
-
"!templates/**/node_modules",
|
|
37
|
-
"!templates/**/dist",
|
|
38
|
-
"!**/*.lua.map",
|
|
39
|
-
"!**/.open77",
|
|
40
|
-
"!**/open77-npm.d.ts",
|
|
41
|
-
"docs",
|
|
42
|
-
"LICENSE",
|
|
43
|
-
"CHANGELOG.md",
|
|
44
|
-
"README.md"
|
|
45
|
-
],
|
|
46
|
-
"bundleDependencies": [
|
|
47
|
-
"@open77-ts/node",
|
|
48
|
-
"@open77-ts/shared"
|
|
49
|
-
],
|
|
50
|
-
"scripts": {
|
|
51
|
-
"generate": "node packages/types/dist/generate.js",
|
|
52
|
-
"build:tools": "tsc -p packages/types/tsconfig.json && tsc -p packages/compiler/tsconfig.json && tsc -p packages/cli/tsconfig.json && npm run generate && tsc -p packages/sdk/tsconfig.json && tsc -p packages/shared/tsconfig.json && tsc -p packages/node/tsconfig.json",
|
|
53
|
-
"test": "npm run build:tools && node scripts/ensure-webui.cjs && node --test tests/framework.test.cjs tests/bridge.test.cjs tests/cli.test.cjs",
|
|
54
|
-
"docs:check": "node scripts/check-docs.cjs",
|
|
55
|
-
"prepublishOnly": "npm test && npm run docs:check"
|
|
56
|
-
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"@fastify/cors": "^11.0.1",
|
|
59
|
-
"@open77-ts/node": "file:packages/node",
|
|
60
|
-
"@open77-ts/shared": "file:packages/shared",
|
|
61
|
-
"@types/luaparse": "^0.2.13",
|
|
62
|
-
"@types/pg": "^8.15.4",
|
|
63
|
-
"@types/node": "^22.19.1",
|
|
64
|
-
"@types/ws": "^8.18.1",
|
|
65
|
-
"fastify": "^5.3.3",
|
|
66
|
-
"ioredis": "^5.6.1",
|
|
67
|
-
"luaparse": "^0.3.1",
|
|
68
|
-
"mysql2": "^3.14.1",
|
|
69
|
-
"pg": "^8.16.0",
|
|
70
|
-
"source-map": "^0.7.4",
|
|
71
|
-
"tsx": "^4.20.6",
|
|
72
|
-
"typescript": "^6.0.2",
|
|
73
|
-
"typescript-to-lua": "^1.37.1",
|
|
74
|
-
"ws": "^8.18.2",
|
|
75
|
-
"zod": "^3.25.76"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ts2077",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "TypeScript framework for OPEN//77 plugins. Compiles gameplay to Lua 5.4 and can host a React WebUI and an optional Node companion.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/ImViloh/TS77.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://imviloh.github.io/TS77/",
|
|
11
|
+
"bugs": "https://github.com/ImViloh/TS77/issues",
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"ts77": "./packages/cli/dist/cli.js",
|
|
18
|
+
"open77-ts": "./packages/cli/dist/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"packages/cli/dist",
|
|
22
|
+
"packages/compiler/dist",
|
|
23
|
+
"packages/types/dist",
|
|
24
|
+
"packages/types/generated",
|
|
25
|
+
"packages/sdk/src",
|
|
26
|
+
"packages/shared/dist",
|
|
27
|
+
"packages/shared/src",
|
|
28
|
+
"packages/shared/package.json",
|
|
29
|
+
"packages/node/dist",
|
|
30
|
+
"packages/node/src",
|
|
31
|
+
"packages/node/package.json",
|
|
32
|
+
"packages/client/package.json",
|
|
33
|
+
"packages/server/package.json",
|
|
34
|
+
"packages/webui",
|
|
35
|
+
"templates",
|
|
36
|
+
"!templates/**/node_modules",
|
|
37
|
+
"!templates/**/dist",
|
|
38
|
+
"!**/*.lua.map",
|
|
39
|
+
"!**/.open77",
|
|
40
|
+
"!**/open77-npm.d.ts",
|
|
41
|
+
"docs",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"CHANGELOG.md",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"bundleDependencies": [
|
|
47
|
+
"@open77-ts/node",
|
|
48
|
+
"@open77-ts/shared"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"generate": "node packages/types/dist/generate.js",
|
|
52
|
+
"build:tools": "tsc -p packages/types/tsconfig.json && tsc -p packages/compiler/tsconfig.json && tsc -p packages/cli/tsconfig.json && npm run generate && tsc -p packages/sdk/tsconfig.json && tsc -p packages/shared/tsconfig.json && tsc -p packages/node/tsconfig.json",
|
|
53
|
+
"test": "npm run build:tools && node scripts/ensure-webui.cjs && node --test tests/framework.test.cjs tests/bridge.test.cjs tests/cli.test.cjs",
|
|
54
|
+
"docs:check": "node scripts/check-docs.cjs",
|
|
55
|
+
"prepublishOnly": "npm test && npm run docs:check"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@fastify/cors": "^11.0.1",
|
|
59
|
+
"@open77-ts/node": "file:packages/node",
|
|
60
|
+
"@open77-ts/shared": "file:packages/shared",
|
|
61
|
+
"@types/luaparse": "^0.2.13",
|
|
62
|
+
"@types/pg": "^8.15.4",
|
|
63
|
+
"@types/node": "^22.19.1",
|
|
64
|
+
"@types/ws": "^8.18.1",
|
|
65
|
+
"fastify": "^5.3.3",
|
|
66
|
+
"ioredis": "^5.6.1",
|
|
67
|
+
"luaparse": "^0.3.1",
|
|
68
|
+
"mysql2": "^3.14.1",
|
|
69
|
+
"pg": "^8.16.0",
|
|
70
|
+
"source-map": "^0.7.4",
|
|
71
|
+
"tsx": "^4.20.6",
|
|
72
|
+
"typescript": "^6.0.2",
|
|
73
|
+
"typescript-to-lua": "^1.37.1",
|
|
74
|
+
"ws": "^8.18.2",
|
|
75
|
+
"zod": "^3.25.76"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/packages/cli/dist/cli.js
CHANGED
|
@@ -16,31 +16,31 @@ function packageInfo() {
|
|
|
16
16
|
}
|
|
17
17
|
function usage() {
|
|
18
18
|
const bin = node_path_1.default.basename(process.argv[1] ?? "ts77").replace(/\.js$/, "");
|
|
19
|
-
process.stdout.write(`${bin} <command>
|
|
20
|
-
|
|
21
|
-
create [name] [--template basic|gameplay|webui|fullstack] [--out dir] [--server dir] [--install] [--no-install] [--force]
|
|
22
|
-
init [dir] add TypeScript files without replacing files that already exist
|
|
23
|
-
dev [dir] watch TypeScript, restart the Node companion only when the project has one, and start Vite when a WebUI is installed
|
|
24
|
-
build [dir] [--dev] [--deploy]
|
|
25
|
-
watch [dir]
|
|
26
|
-
deploy [dir] [--server dir] copy the built resource into the server resources directory
|
|
27
|
-
validate [dir]
|
|
28
|
-
doctor [dir]
|
|
29
|
-
types regenerate declarations from the local Devkit index
|
|
30
|
-
docs [--open] print the documentation page
|
|
31
|
-
update show the catalogue build and how to refresh it
|
|
32
|
-
map <lua-file> <line> [column]
|
|
33
|
-
help
|
|
34
|
-
|
|
35
|
-
Examples:
|
|
36
|
-
${bin} create my_plugin --template basic --no-install
|
|
37
|
-
cd my_plugin
|
|
38
|
-
npm install
|
|
39
|
-
npm run dev
|
|
40
|
-
npm run build
|
|
41
|
-
${bin} deploy --server D:\\\\open77-server
|
|
42
|
-
|
|
43
|
-
Node.js ${process.versions.node}. Add --quiet to shorten success output, or --verbose to repeat diagnostic text.
|
|
19
|
+
process.stdout.write(`${bin} <command>
|
|
20
|
+
|
|
21
|
+
create [name] [--template basic|gameplay|webui|fullstack] [--out dir] [--server dir] [--install] [--no-install] [--force]
|
|
22
|
+
init [dir] add TypeScript files without replacing files that already exist
|
|
23
|
+
dev [dir] watch TypeScript, restart the Node companion only when the project has one, and start Vite when a WebUI is installed
|
|
24
|
+
build [dir] [--dev] [--deploy]
|
|
25
|
+
watch [dir]
|
|
26
|
+
deploy [dir] [--server dir] copy the built resource into the server resources directory
|
|
27
|
+
validate [dir]
|
|
28
|
+
doctor [dir]
|
|
29
|
+
types regenerate declarations from the local Devkit index
|
|
30
|
+
docs [--open] print the documentation page
|
|
31
|
+
update show the catalogue build and how to refresh it
|
|
32
|
+
map <lua-file> <line> [column]
|
|
33
|
+
help
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
${bin} create my_plugin --template basic --no-install
|
|
37
|
+
cd my_plugin
|
|
38
|
+
npm install
|
|
39
|
+
npm run dev
|
|
40
|
+
npm run build
|
|
41
|
+
${bin} deploy --server D:\\\\open77-server
|
|
42
|
+
|
|
43
|
+
Node.js ${process.versions.node}. Add --quiet to shorten success output, or --verbose to repeat diagnostic text.
|
|
44
44
|
`);
|
|
45
45
|
}
|
|
46
46
|
function argValue(args, flag) {
|
|
@@ -283,6 +283,7 @@ async function create(args) {
|
|
|
283
283
|
}
|
|
284
284
|
copyTemplate(template, destination, name, false);
|
|
285
285
|
writeProjectPackage(destination);
|
|
286
|
+
compiler.writeTypeScriptProjects(destination);
|
|
286
287
|
if (server)
|
|
287
288
|
rememberServer(destination, server);
|
|
288
289
|
if (args.includes("--no-install"))
|
|
@@ -429,6 +430,7 @@ async function main() {
|
|
|
429
430
|
}
|
|
430
431
|
copyTemplate("basic", dir, name, true);
|
|
431
432
|
writeProjectPackage(dir);
|
|
433
|
+
compiler.writeTypeScriptProjects(dir);
|
|
432
434
|
const server = argValue(args, "--server");
|
|
433
435
|
if (server)
|
|
434
436
|
rememberServer(dir, server);
|
|
@@ -11,3 +11,4 @@ export interface BuildResult {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function buildResource(resourceDir: string, options?: BuildOptions): BuildResult;
|
|
13
13
|
export declare function validateResource(resourceDir: string): BuildResult;
|
|
14
|
+
export declare function writeTypeScriptProjects(resourceDir: string): void;
|
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.buildResource = buildResource;
|
|
40
40
|
exports.validateResource = validateResource;
|
|
41
|
+
exports.writeTypeScriptProjects = writeTypeScriptProjects;
|
|
41
42
|
const node_fs_1 = require("node:fs");
|
|
42
43
|
const node_module_1 = require("node:module");
|
|
43
44
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -69,10 +70,7 @@ function buildResource(resourceDir, options = {}) {
|
|
|
69
70
|
return { ok: false, messages: ["the node target requires a backend entry"], permissions: [], outputs: [] };
|
|
70
71
|
const entry = options.dev && config.webDevEntry ? config.webDevEntry : config.webEntry;
|
|
71
72
|
writeFlags(root, entry);
|
|
72
|
-
|
|
73
|
-
writeTsconfig(root, "client", config.client);
|
|
74
|
-
if (buildServer)
|
|
75
|
-
writeTsconfig(root, "server", config.server);
|
|
73
|
+
writeTypeScriptProjects(root);
|
|
76
74
|
const problems = [
|
|
77
75
|
...(buildClient ? checkSide(root, "client") : []),
|
|
78
76
|
...(buildServer ? checkSide(root, "server") : []),
|
|
@@ -136,6 +134,7 @@ function buildResource(resourceDir, options = {}) {
|
|
|
136
134
|
}
|
|
137
135
|
if (buildNode && config.backend) {
|
|
138
136
|
const nodeErrors = compileBackend(root, config.backend);
|
|
137
|
+
writeEditorSolution(root);
|
|
139
138
|
if (nodeErrors.length > 0)
|
|
140
139
|
return { ok: false, messages: nodeErrors, permissions: [], outputs: [] };
|
|
141
140
|
outputs.push(node_path_1.default.join(root, "dist", "backend", "index.js"));
|
|
@@ -223,6 +222,25 @@ function tsPath(fromDir, file) {
|
|
|
223
222
|
const slash = relative.replace(/\\/g, "/");
|
|
224
223
|
return slash.startsWith(".") ? slash : `./${slash}`;
|
|
225
224
|
}
|
|
225
|
+
function writeTypeScriptProjects(resourceDir) {
|
|
226
|
+
const root = node_path_1.default.resolve(resourceDir);
|
|
227
|
+
const config = (0, config_1.loadConfig)(root);
|
|
228
|
+
const buildClient = config.targets.includes("open77-client");
|
|
229
|
+
const buildServer = config.targets.includes("open77-server");
|
|
230
|
+
if (buildClient)
|
|
231
|
+
writeTsconfig(root, "client", config.client);
|
|
232
|
+
if (buildServer)
|
|
233
|
+
writeTsconfig(root, "server", config.server);
|
|
234
|
+
writeEditorSolution(root);
|
|
235
|
+
}
|
|
236
|
+
function writeEditorSolution(resourceDir) {
|
|
237
|
+
const references = ["tsconfig.client.json", "tsconfig.server.json", "tsconfig.node.json"]
|
|
238
|
+
.filter((file) => (0, node_fs_1.existsSync)(node_path_1.default.join(resourceDir, file)))
|
|
239
|
+
.map((file) => ({ path: `./${file}` }));
|
|
240
|
+
if (references.length === 0)
|
|
241
|
+
return;
|
|
242
|
+
(0, node_fs_1.writeFileSync)(node_path_1.default.join(resourceDir, "tsconfig.json"), `${JSON.stringify({ files: [], references }, null, 2)}\n`, "utf8");
|
|
243
|
+
}
|
|
226
244
|
function writeTsconfig(resourceDir, runtime, entry) {
|
|
227
245
|
const sdkRoot = node_path_1.default.join((0, config_1.repoRoot)(), "packages", "sdk", "src");
|
|
228
246
|
const types = node_path_1.default.join((0, config_1.repoRoot)(), "packages", "types", "generated", `${runtime}.d.ts`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildResource, validateResource } from "./build";
|
|
1
|
+
export { buildResource, validateResource, writeTypeScriptProjects } from "./build";
|
|
2
2
|
export type { BuildOptions, BuildResult } from "./build";
|
|
3
3
|
export { doctor } from "./doctor";
|
|
4
4
|
export type { DoctorLine } from "./doctor";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resourceNameFromLua = exports.mapLuaPosition = exports.RESOURCE_NAME = exports.repoRoot = exports.loadConfig = exports.doctor = exports.validateResource = exports.buildResource = void 0;
|
|
3
|
+
exports.resourceNameFromLua = exports.mapLuaPosition = exports.RESOURCE_NAME = exports.repoRoot = exports.loadConfig = exports.doctor = exports.writeTypeScriptProjects = exports.validateResource = exports.buildResource = void 0;
|
|
4
4
|
var build_1 = require("./build");
|
|
5
5
|
Object.defineProperty(exports, "buildResource", { enumerable: true, get: function () { return build_1.buildResource; } });
|
|
6
6
|
Object.defineProperty(exports, "validateResource", { enumerable: true, get: function () { return build_1.validateResource; } });
|
|
7
|
+
Object.defineProperty(exports, "writeTypeScriptProjects", { enumerable: true, get: function () { return build_1.writeTypeScriptProjects; } });
|
|
7
8
|
var doctor_1 = require("./doctor");
|
|
8
9
|
Object.defineProperty(exports, "doctor", { enumerable: true, get: function () { return doctor_1.doctor; } });
|
|
9
10
|
var config_1 = require("./config");
|
|
@@ -302,7 +302,6 @@ function renderRuntime(runtime, cards, build, skipped) {
|
|
|
302
302
|
`/**`,
|
|
303
303
|
` * OPEN//77 ${runtime} declarations for catalogue build ${build}.`,
|
|
304
304
|
` * Generated from the official Devkit index. Do not edit by hand.`,
|
|
305
|
-
` * Regenerate with \`npm run generate\` inside the TS77 repo.`,
|
|
306
305
|
` */`,
|
|
307
306
|
`/// <reference path="./tstl-language-extensions.d.ts" />`,
|
|
308
307
|
``,
|
|
@@ -435,7 +434,6 @@ function main() {
|
|
|
435
434
|
const reserved = [...new Set((events.reservedPrefixes ?? []).map((entry) => entry.prefix))].sort();
|
|
436
435
|
const catalogue = {
|
|
437
436
|
build,
|
|
438
|
-
indexDir: directory,
|
|
439
437
|
omittedUnavailable: omitted,
|
|
440
438
|
skipped,
|
|
441
439
|
reservedPrefixes: reserved,
|