skir 1.0.21 β 1.0.23
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 +55 -29
- package/dist/project_initializer.d.ts.map +1 -1
- package/dist/project_initializer.js +12 -11
- package/dist/project_initializer.js.map +1 -1
- package/package.json +4 -4
- package/src/project_initializer.ts +12 -11
package/README.md
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Skir</h1>
|
|
3
|
+
<p><strong>Like Protocol Buffer, but better.</strong></p>
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://skir.build"><b>skir.build</b></a>
|
|
7
|
+
</p>
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/skir)
|
|
10
|
+
[](https://github.com/gepheum/skir/actions)
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+

|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
**Skir** is a universal language for representing data types, constants, and RPC interfaces. Define your schema once in a `.skir` file and generate idiomatic, type-safe code in TypeScript, Python, Java, C++, and more.
|
|
18
|
+
|
|
19
|
+
## β¨ Features
|
|
20
|
+
|
|
21
|
+
- π **Single source of truth** - Define your data types and APIs once and share them between your backend, frontend, and microservices.
|
|
22
|
+
- π **Multi-language** - First-class support for TypeScript, Python, C++, Java, Kotlin, and Dart.
|
|
23
|
+
- βοΈ **Idiomatic code gen** - Generates code that feels native to each language.
|
|
24
|
+
- π **Effortless serialization** - Skir generates functions to serialize your data to JSON or binary, so you never have to write parsing code manually.
|
|
25
|
+
- π¦ **Schema evolution** - Simple guidelines and built-in checks to evolve your schema without breaking backward compatibility.
|
|
26
|
+
- π€ **RPCs with end-to-end type safety** - Like tRPC, but for every language. Call your backend functions directly from your frontend or microservices with full compile-time safety.
|
|
27
|
+
- π οΈ **Delightful developer experience** - Automatic recompilation in watch mode, built-in code formatter, official VSCode extension.
|
|
28
|
+
- π¦ **Built-in package manager** - Import types from other GitHub repositories to easily share common data structures across projects.
|
|
29
|
+
- π **Easy setup** - Get started with `npx skir init`, manage your entire project configuration from a single YAML file.
|
|
30
|
+
|
|
31
|
+
## β‘ Syntax example
|
|
9
32
|
|
|
10
33
|
```d
|
|
11
34
|
// shapes.skir
|
|
@@ -32,36 +55,39 @@ const TOP_RIGHT_CORNER: Point = {
|
|
|
32
55
|
method IsConvex(Shape): bool = 12345;
|
|
33
56
|
```
|
|
34
57
|
|
|
35
|
-
|
|
58
|
+
Skir compiles these definitions into native, type-safe code you can use in your project:
|
|
36
59
|
|
|
37
60
|
```python
|
|
38
61
|
# my_project.py
|
|
39
62
|
|
|
40
|
-
from skirout.shapes_skir import Point #
|
|
63
|
+
from skirout.shapes_skir import Point # Python module generated by Skir
|
|
41
64
|
|
|
42
65
|
point = Point(x=3, y=4, label="P")
|
|
43
|
-
point_json = Point.serializer.to_json(point)
|
|
44
|
-
assert(Point.serializer.from_json(json) == point)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Documentation
|
|
48
|
-
|
|
49
|
-
1. [Why Skir?](docs/introduction.md)
|
|
50
|
-
2. [Getting started: setup & workflow](docs/setup.md)
|
|
51
|
-
3. [Language reference](docs/language-reference.md)
|
|
52
|
-
4. [Serialization formats](docs/serialization.md)
|
|
53
|
-
5. [Schema evolution & compatibility](docs/compatibility.md)
|
|
54
|
-
6. [Typesafe RPC interfaces](docs/services.md)
|
|
55
|
-
7. [External dependencies](docs/dependencies.md)
|
|
56
|
-
8. [Comparisons](docs/comparisons.md)
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
# Roundβtrip serialization to JSON
|
|
68
|
+
point_json = Point.serializer.to_json(point)
|
|
69
|
+
restored = Point.serializer.from_json(point_json)
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* C++: [documentation](https://github.com/gepheum/skir-cc-gen), [example](https://github.com/gepheum/skir-cc-example)
|
|
63
|
-
* Java: [documentation](https://github.com/gepheum/skir-java-gen), [example](https://github.com/gepheum/skir-java-example)
|
|
64
|
-
* Kotlin: [documentation](https://github.com/gepheum/skir-kotlin-gen), [example](https://github.com/gepheum/skir-kotlin-example)
|
|
65
|
-
* Dart: [documentation](https://github.com/gepheum/skir-dart-gen), [example](https://github.com/gepheum/skir-dart-example)
|
|
71
|
+
assert(restored == point)
|
|
72
|
+
```
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
## π Documentation
|
|
75
|
+
|
|
76
|
+
- [Getting started: setup & workflow](https://skir.build/docs/setup)
|
|
77
|
+
- [Language reference](https://skir.build/docs/language-reference)
|
|
78
|
+
- [Serialization](https://skir.build/docs/serialization)
|
|
79
|
+
- [Schema evolution](https://skir.build/docs/schema-evolution)
|
|
80
|
+
- [RPC services](https://skir.build/docs/services)
|
|
81
|
+
- [External dependencies](https://skir.build/docs/dependencies)
|
|
82
|
+
- [Coming from Protocol Buffer](https://skir.build/docs/protobuf)
|
|
83
|
+
|
|
84
|
+
## π Supported languages
|
|
85
|
+
|
|
86
|
+
| Language | Documentation | Example |
|
|
87
|
+
| :--- | :--- | :--- |
|
|
88
|
+
| π¦ **TypeScript** | [Documentation](https://github.com/gepheum/skir-typescript-gen) | [Example](https://github.com/gepheum/skir-typescript-example) |
|
|
89
|
+
| π **Python** | [Documentation](https://github.com/gepheum/skir-python-gen) | [Example](https://github.com/gepheum/skir-python-example) |
|
|
90
|
+
| β‘ **C++** | [Documentation](https://github.com/gepheum/skir-cc-gen) | [Example](https://github.com/gepheum/skir-cc-example) |
|
|
91
|
+
| β **Java** | [Documentation](https://github.com/gepheum/skir-java-gen) | [Example](https://github.com/gepheum/skir-java-example) |
|
|
92
|
+
| π **Kotlin** | [Documentation](https://github.com/gepheum/skir-kotlin-gen) | [Example](https://github.com/gepheum/skir-kotlin-example) |
|
|
93
|
+
| π― **Dart** | [Documentation](https://github.com/gepheum/skir-dart-gen) | [Example](https://github.com/gepheum/skir-dart-example) |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project_initializer.d.ts","sourceRoot":"","sources":["../src/project_initializer.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"project_initializer.d.ts","sourceRoot":"","sources":["../src/project_initializer.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAiDvD"}
|
|
@@ -37,6 +37,7 @@ export function initializeProject(rootDir) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
console.log(`Done. Please edit: ${rewritePathForRendering(skirYmlPath)}`);
|
|
40
|
+
console.log("To generate code, run: npx skir gen [--watch]");
|
|
40
41
|
}
|
|
41
42
|
const SKIR_YML_CONTENT = `# Configuration file for Skir code generator
|
|
42
43
|
#
|
|
@@ -118,26 +119,26 @@ generators:
|
|
|
118
119
|
# # To install runtime dependencies: npm i skir-client
|
|
119
120
|
# # --------------------------------------------------------------------------
|
|
120
121
|
# - mod: skir-typescript-gen
|
|
121
|
-
# outDir: ./
|
|
122
|
+
# outDir: ./skirout
|
|
122
123
|
# config:
|
|
123
124
|
# # Use ".js" for ES modules, "" for CommonJS
|
|
124
125
|
# importPathExtension: ".js"
|
|
125
126
|
|
|
126
|
-
# --------------------------------------------------------------------------
|
|
127
|
-
# External Skir dependencies hosted on GitHub
|
|
128
|
-
# To use an external repository, specify the GitHub repository identifier
|
|
129
|
-
# in the format "@owner/repository-name" and the release tag version.
|
|
130
|
-
# --------------------------------------------------------------------------
|
|
127
|
+
# # --------------------------------------------------------------------------
|
|
128
|
+
# # External Skir dependencies hosted on GitHub
|
|
129
|
+
# # To use an external repository, specify the GitHub repository identifier
|
|
130
|
+
# # in the format "@owner/repository-name" and the release tag version.
|
|
131
|
+
# # --------------------------------------------------------------------------
|
|
131
132
|
# dependencies:
|
|
132
133
|
# # Add a dependency to:
|
|
133
134
|
# # https://github.com/gepheum/fantasy-game-skir-example/tree/v1.0.0
|
|
134
135
|
# "@gepheum/fantasy-game-skir-example": v1.0.0
|
|
135
136
|
|
|
136
|
-
# --------------------------------------------------------------------------
|
|
137
|
-
# GitHub Personal Access Token (required for private dependencies)
|
|
138
|
-
# Set this to the name of an environment variable containing your GitHub
|
|
139
|
-
# token. The token is used to authenticate when downloading dependencies.
|
|
140
|
-
# --------------------------------------------------------------------------
|
|
137
|
+
# # --------------------------------------------------------------------------
|
|
138
|
+
# # GitHub Personal Access Token (required for private dependencies)
|
|
139
|
+
# # Set this to the name of an environment variable containing your GitHub
|
|
140
|
+
# # token. The token is used to authenticate when downloading dependencies.
|
|
141
|
+
# # --------------------------------------------------------------------------
|
|
141
142
|
# githubTokenEnvVar: GITHUB_TOKEN
|
|
142
143
|
`;
|
|
143
144
|
const HELLO_WORLD_SKIR_CONTENT = `/// A point in 2D space.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project_initializer.js","sourceRoot":"","sources":["../src/project_initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAEpD,mCAAmC;IACnC,IAAI,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CACT,oFAAoF,CACrF,CAAC;QACF,OAAO;IACT,CAAC;IAED,uBAAuB;IACvB,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAEjE,qCAAqC;IACrC,MAAM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;CAOhC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skir",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "",
|
|
5
|
-
"homepage": "
|
|
5
|
+
"homepage": "http://skir.build",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/gepheum/skir/issues"
|
|
8
8
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"skir-dart-gen": "^1.0.3",
|
|
47
47
|
"skir-internal": "^0.1.0",
|
|
48
48
|
"skir-java-gen": "^1.0.4",
|
|
49
|
-
"skir-kotlin-gen": "^1.0.
|
|
49
|
+
"skir-kotlin-gen": "^1.0.5",
|
|
50
50
|
"skir-python-gen": "^1.0.3",
|
|
51
51
|
"skir-typescript-gen": "^1.0.5",
|
|
52
52
|
"watcher": "^2.3.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@typescript-eslint/parser": "^8.50.1",
|
|
62
62
|
"buckwheat": "^1.1.2",
|
|
63
63
|
"eslint": "^9.39.2",
|
|
64
|
-
"mocha": "^11.
|
|
64
|
+
"mocha": "^11.3.0",
|
|
65
65
|
"prettier": "^3.2.4",
|
|
66
66
|
"prettier-plugin-organize-imports": "^4.2.0",
|
|
67
67
|
"ts-node": "^10.9.2",
|
|
@@ -50,6 +50,7 @@ export function initializeProject(rootDir: string): void {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
console.log(`Done. Please edit: ${rewritePathForRendering(skirYmlPath)}`);
|
|
53
|
+
console.log("To generate code, run: npx skir gen [--watch]");
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const SKIR_YML_CONTENT = `# Configuration file for Skir code generator
|
|
@@ -132,26 +133,26 @@ generators:
|
|
|
132
133
|
# # To install runtime dependencies: npm i skir-client
|
|
133
134
|
# # --------------------------------------------------------------------------
|
|
134
135
|
# - mod: skir-typescript-gen
|
|
135
|
-
# outDir: ./
|
|
136
|
+
# outDir: ./skirout
|
|
136
137
|
# config:
|
|
137
138
|
# # Use ".js" for ES modules, "" for CommonJS
|
|
138
139
|
# importPathExtension: ".js"
|
|
139
140
|
|
|
140
|
-
# --------------------------------------------------------------------------
|
|
141
|
-
# External Skir dependencies hosted on GitHub
|
|
142
|
-
# To use an external repository, specify the GitHub repository identifier
|
|
143
|
-
# in the format "@owner/repository-name" and the release tag version.
|
|
144
|
-
# --------------------------------------------------------------------------
|
|
141
|
+
# # --------------------------------------------------------------------------
|
|
142
|
+
# # External Skir dependencies hosted on GitHub
|
|
143
|
+
# # To use an external repository, specify the GitHub repository identifier
|
|
144
|
+
# # in the format "@owner/repository-name" and the release tag version.
|
|
145
|
+
# # --------------------------------------------------------------------------
|
|
145
146
|
# dependencies:
|
|
146
147
|
# # Add a dependency to:
|
|
147
148
|
# # https://github.com/gepheum/fantasy-game-skir-example/tree/v1.0.0
|
|
148
149
|
# "@gepheum/fantasy-game-skir-example": v1.0.0
|
|
149
150
|
|
|
150
|
-
# --------------------------------------------------------------------------
|
|
151
|
-
# GitHub Personal Access Token (required for private dependencies)
|
|
152
|
-
# Set this to the name of an environment variable containing your GitHub
|
|
153
|
-
# token. The token is used to authenticate when downloading dependencies.
|
|
154
|
-
# --------------------------------------------------------------------------
|
|
151
|
+
# # --------------------------------------------------------------------------
|
|
152
|
+
# # GitHub Personal Access Token (required for private dependencies)
|
|
153
|
+
# # Set this to the name of an environment variable containing your GitHub
|
|
154
|
+
# # token. The token is used to authenticate when downloading dependencies.
|
|
155
|
+
# # --------------------------------------------------------------------------
|
|
155
156
|
# githubTokenEnvVar: GITHUB_TOKEN
|
|
156
157
|
`;
|
|
157
158
|
|