zero-swift 0.4.1 → 0.4.3
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/bin.js +35 -16
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Cli, z } from "incur";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "zero-swift",
|
|
12
|
-
version: "0.4.
|
|
12
|
+
version: "0.4.3",
|
|
13
13
|
description: "Generates the Swift row types and schema of a Zero app for the Zero Swift client.",
|
|
14
14
|
license: "Apache-2.0",
|
|
15
15
|
repository: {
|
|
@@ -906,6 +906,8 @@ function writeOutput(fail, output, contents, check2, cwd) {
|
|
|
906
906
|
}
|
|
907
907
|
return { path, written: current !== contents };
|
|
908
908
|
}
|
|
909
|
+
var camelOption = /^--(schemaFile|schemaName|typePrefix)(=|$)/;
|
|
910
|
+
var upperCase = /[A-Z]/g;
|
|
909
911
|
function legacyArgv(argv) {
|
|
910
912
|
if (argv[0] !== "codegen") return [...argv];
|
|
911
913
|
const out = [];
|
|
@@ -917,6 +919,10 @@ function legacyArgv(argv) {
|
|
|
917
919
|
i++;
|
|
918
920
|
} else if (token.startsWith("--schema=")) {
|
|
919
921
|
out.push("--schema-file", token.slice("--schema=".length));
|
|
922
|
+
} else if (camelOption.test(token)) {
|
|
923
|
+
const [name, ...value] = token.split("=");
|
|
924
|
+
const kebab = name.replace(upperCase, (c) => `-${c.toLowerCase()}`);
|
|
925
|
+
out.push([kebab, ...value].join("="));
|
|
920
926
|
} else {
|
|
921
927
|
out.push(token);
|
|
922
928
|
}
|
|
@@ -930,25 +936,36 @@ var cli = Cli.create("zero-swift", {
|
|
|
930
936
|
}).command("codegen", {
|
|
931
937
|
description: "Generate the Swift row types, schema, and query builder from the app's TypeScript schema. Options override zero-swift.json, which is read when present. See swift/Sources/Zero/Zero.docc/GettingStarted.md in github.com/wevm/zero.",
|
|
932
938
|
options: z.object({
|
|
933
|
-
config: z.string().optional().describe("Config file (default zero-swift.json, when present)"),
|
|
934
|
-
|
|
935
|
-
export: z.string().optional().describe("Export of the module that holds the schema (default schema)"),
|
|
936
|
-
out: z.string().optional().describe("Swift file to write (default Schema.swift)"),
|
|
937
|
-
|
|
938
|
-
zql: z.string().optional().describe("Name of the generated query builder global (default zql)"),
|
|
939
|
-
|
|
940
|
-
access: z.enum(["public", "internal"]).optional().describe("Access level of the generated code (default public)"),
|
|
939
|
+
"config": z.string().optional().describe("Config file (default zero-swift.json, when present)"),
|
|
940
|
+
"schema-file": z.string().optional().describe("TS schema module (default schema.ts)"),
|
|
941
|
+
"export": z.string().optional().describe("Export of the module that holds the schema (default schema)"),
|
|
942
|
+
"out": z.string().optional().describe("Swift file to write (default Schema.swift)"),
|
|
943
|
+
"schema-name": z.string().optional().describe("Name of the generated ZeroSchema static (default app)"),
|
|
944
|
+
"zql": z.string().optional().describe("Name of the generated query builder global (default zql)"),
|
|
945
|
+
"type-prefix": z.string().optional().describe("Prefix for every generated type name (default none)"),
|
|
946
|
+
"access": z.enum(["public", "internal"]).optional().describe("Access level of the generated code (default public)"),
|
|
941
947
|
check
|
|
942
948
|
}),
|
|
943
|
-
// incur 0.7.1 prints example
|
|
944
|
-
// shows
|
|
945
|
-
examples: [
|
|
946
|
-
|
|
949
|
+
// incur 0.7.1 prints a boolean example option as `--check true`, so the
|
|
950
|
+
// hint shows a bare `--check` instead.
|
|
951
|
+
examples: [
|
|
952
|
+
{ description: "Generate from zero-swift.json" },
|
|
953
|
+
{
|
|
954
|
+
options: {
|
|
955
|
+
"schema-file": "shared/schema.ts",
|
|
956
|
+
"out": "Sources/App/Schema.swift"
|
|
957
|
+
},
|
|
958
|
+
description: "Generate without a config file"
|
|
959
|
+
}
|
|
960
|
+
],
|
|
961
|
+
hint: "In CI, zero-swift codegen --check fails when the output is stale.",
|
|
947
962
|
run: (c) => reporting(c.error, async () => {
|
|
948
963
|
const cwd = process.cwd();
|
|
949
964
|
const {
|
|
950
|
-
config: configOption,
|
|
951
|
-
schemaFile,
|
|
965
|
+
"config": configOption,
|
|
966
|
+
"schema-file": schemaFile,
|
|
967
|
+
"schema-name": schemaName,
|
|
968
|
+
"type-prefix": typePrefix,
|
|
952
969
|
out,
|
|
953
970
|
check: check2,
|
|
954
971
|
...overrides
|
|
@@ -965,7 +982,9 @@ var cli = Cli.create("zero-swift", {
|
|
|
965
982
|
const config = {
|
|
966
983
|
...fileConfig,
|
|
967
984
|
...Object.fromEntries(
|
|
968
|
-
Object.entries(overrides
|
|
985
|
+
Object.entries({ ...overrides, schemaName, typePrefix }).filter(
|
|
986
|
+
([, v]) => v !== void 0
|
|
987
|
+
)
|
|
969
988
|
),
|
|
970
989
|
...schemaFile ? { schema: schemaFile } : {},
|
|
971
990
|
...out ? { output: out } : {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zero-swift",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Generates the Swift row types and schema of a Zero app for the Zero Swift client.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"oxfmt": "^0.74.0",
|
|
26
26
|
"vitest": "^5.0.0",
|
|
27
27
|
"@rocicorp/zero": "1.12.0",
|
|
28
|
-
"
|
|
28
|
+
"zql": "0.0.0",
|
|
29
29
|
"zero-types": "0.0.0",
|
|
30
|
-
"
|
|
30
|
+
"zero-schema": "0.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@rocicorp/zero": ">=1.11.0"
|