@zitadel/server 0.1.0-alpha.9 → 0.1.0
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/bin/binary.d.ts +18 -0
- package/bin/binary.js +89 -0
- package/bin/zitadel-server.js +7 -58
- package/package.json +29 -6
package/bin/binary.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface SupportedPlatform {
|
|
2
|
+
platform: string;
|
|
3
|
+
arch: string;
|
|
4
|
+
packageName: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const supportedPlatforms: readonly SupportedPlatform[];
|
|
8
|
+
|
|
9
|
+
/** The platform package that ships the server binary for a platform. Throws when there is none. */
|
|
10
|
+
export function platformPackageName(platform?: string, arch?: string): string;
|
|
11
|
+
|
|
12
|
+
/** Where the server binary for a platform is. The platform package must be installed; the file need not exist. */
|
|
13
|
+
export function serverBinaryPath(platform?: string, arch?: string): string;
|
|
14
|
+
|
|
15
|
+
/** The server binary for a platform, ready to run: it must exist, and is made executable. */
|
|
16
|
+
export function resolveServerBinary(platform?: string, arch?: string): string;
|
|
17
|
+
|
|
18
|
+
export function ensureExecutable(binaryPath: string, platform?: string): void;
|
package/bin/binary.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { chmodSync, existsSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The platforms the server binary is published for, and the package that holds
|
|
9
|
+
* each. This is the one list in the repository of which platform maps to which
|
|
10
|
+
* package: the wrapper and the CLI both resolve the binary from here, and tests
|
|
11
|
+
* check it against this package's `optionalDependencies` and the release
|
|
12
|
+
* manifest so the three cannot drift apart.
|
|
13
|
+
*/
|
|
14
|
+
export const supportedPlatforms = [
|
|
15
|
+
{ platform: "darwin", arch: "arm64", packageName: "@zitadel/server-darwin-arm64" },
|
|
16
|
+
{ platform: "darwin", arch: "x64", packageName: "@zitadel/server-darwin-x64" },
|
|
17
|
+
{ platform: "linux", arch: "arm64", packageName: "@zitadel/server-linux-arm64" },
|
|
18
|
+
{ platform: "linux", arch: "x64", packageName: "@zitadel/server-linux-x64" },
|
|
19
|
+
{ platform: "win32", arch: "x64", packageName: "@zitadel/server-win32-x64" },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/** The package that holds the server binary for a platform. Throws where there is none. */
|
|
23
|
+
export function platformPackageName(platform = process.platform, arch = process.arch) {
|
|
24
|
+
const match = supportedPlatforms.find((candidate) => {
|
|
25
|
+
return candidate.platform === platform && candidate.arch === arch;
|
|
26
|
+
});
|
|
27
|
+
if (!match) {
|
|
28
|
+
const supported = supportedPlatforms
|
|
29
|
+
.map((candidate) => `${candidate.platform}/${candidate.arch}`)
|
|
30
|
+
.join(", ");
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Unsupported platform for @zitadel/server: ${platform}/${arch}. Supported: ${supported}.`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return match.packageName;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Where the `nextgen` server binary for a platform is, without looking at the
|
|
40
|
+
* file: the platform package must be installed, but the binary need not be built.
|
|
41
|
+
* The platform package is an optional dependency of this package, so it is
|
|
42
|
+
* resolved from here, where a strict package manager exposes it, and not from
|
|
43
|
+
* the caller.
|
|
44
|
+
*/
|
|
45
|
+
export function serverBinaryPath(platform = process.platform, arch = process.arch) {
|
|
46
|
+
const packageName = platformPackageName(platform, arch);
|
|
47
|
+
let manifestPath;
|
|
48
|
+
try {
|
|
49
|
+
manifestPath = require.resolve(`${packageName}/package.json`);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Missing ${packageName}. Reinstall @zitadel/server so npm can install the optional platform package.`,
|
|
53
|
+
{ cause: error },
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return join(dirname(manifestPath), "bin", platform === "win32" ? "nextgen.exe" : "nextgen");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The server binary for a platform, ready to run: it must exist, and is made executable. */
|
|
60
|
+
export function resolveServerBinary(platform = process.platform, arch = process.arch) {
|
|
61
|
+
const binaryPath = serverBinaryPath(platform, arch);
|
|
62
|
+
if (!existsSync(binaryPath)) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Missing Zitadel server binary at ${binaryPath}. Reinstall ${platformPackageName(platform, arch)}.`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
ensureExecutable(binaryPath, platform);
|
|
68
|
+
return binaryPath;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Makes the binary executable. Packing a tarball can drop the executable bit, so
|
|
73
|
+
* it is restored here rather than trusted. Windows has no such bit.
|
|
74
|
+
*/
|
|
75
|
+
export function ensureExecutable(binaryPath, platform = process.platform) {
|
|
76
|
+
if (platform === "win32") {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
chmodSync(binaryPath, 0o755);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Zitadel server binary at ${binaryPath} is not executable and could not be fixed.`,
|
|
84
|
+
{
|
|
85
|
+
cause: error,
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
package/bin/zitadel-server.js
CHANGED
|
@@ -1,66 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
|
-
import { chmodSync, existsSync } from "node:fs";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
import { dirname, join } from "node:path";
|
|
6
3
|
import { fileURLToPath } from "node:url";
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
import { resolveServerBinary } from "./binary.js";
|
|
9
6
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
export function platformPackageName(platform = process.platform, arch = process.arch) {
|
|
19
|
-
const match = supportedPlatforms.find((candidate) => {
|
|
20
|
-
return candidate.platform === platform && candidate.arch === arch;
|
|
21
|
-
});
|
|
22
|
-
if (!match) {
|
|
23
|
-
const supported = supportedPlatforms
|
|
24
|
-
.map((candidate) => `${candidate.platform}/${candidate.arch}`)
|
|
25
|
-
.join(", ");
|
|
26
|
-
throw new Error(`Unsupported platform for @zitadel/server: ${platform}/${arch}. Supported: ${supported}.`);
|
|
27
|
-
}
|
|
28
|
-
return match.packageName;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function resolveServerBinary(platform = process.platform, arch = process.arch) {
|
|
32
|
-
const packageName = platformPackageName(platform, arch);
|
|
33
|
-
let manifestPath;
|
|
34
|
-
try {
|
|
35
|
-
manifestPath = require.resolve(`${packageName}/package.json`);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Missing ${packageName}. Reinstall @zitadel/server so npm can install the optional platform package.`,
|
|
39
|
-
{ cause: error },
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const binaryName = platform === "win32" ? "nextgen.exe" : "nextgen";
|
|
44
|
-
const binaryPath = join(dirname(manifestPath), "bin", binaryName);
|
|
45
|
-
if (!existsSync(binaryPath)) {
|
|
46
|
-
throw new Error(`Missing Zitadel server binary at ${binaryPath}. Reinstall ${packageName}.`);
|
|
47
|
-
}
|
|
48
|
-
ensureExecutable(binaryPath, platform);
|
|
49
|
-
return binaryPath;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function ensureExecutable(binaryPath, platform = process.platform) {
|
|
53
|
-
if (platform === "win32") {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
chmodSync(binaryPath, 0o755);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
throw new Error(`Zitadel server binary at ${binaryPath} is not executable and could not be fixed.`, {
|
|
60
|
-
cause: error,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
7
|
+
export {
|
|
8
|
+
ensureExecutable,
|
|
9
|
+
platformPackageName,
|
|
10
|
+
resolveServerBinary,
|
|
11
|
+
supportedPlatforms,
|
|
12
|
+
} from "./binary.js";
|
|
64
13
|
|
|
65
14
|
export async function main(args = process.argv.slice(2)) {
|
|
66
15
|
const binaryPath = resolveServerBinary();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zitadel/server",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Zitadel server binary launcher.",
|
|
5
5
|
"homepage": "https://github.com/zitadel/nextgen#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
"bin": {
|
|
17
17
|
"zitadel-server": "./bin/zitadel-server.js"
|
|
18
18
|
},
|
|
19
|
+
"exports": {
|
|
20
|
+
"./binary": {
|
|
21
|
+
"types": "./bin/binary.d.ts",
|
|
22
|
+
"default": "./bin/binary.js"
|
|
23
|
+
},
|
|
24
|
+
"./bin/zitadel-server.js": "./bin/zitadel-server.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
19
27
|
"files": [
|
|
20
28
|
"bin"
|
|
21
29
|
],
|
|
@@ -23,10 +31,25 @@
|
|
|
23
31
|
"access": "public"
|
|
24
32
|
},
|
|
25
33
|
"optionalDependencies": {
|
|
26
|
-
"@zitadel/server-darwin-arm64": "0.1.0
|
|
27
|
-
"@zitadel/server-darwin-x64": "0.1.0
|
|
28
|
-
"@zitadel/server-linux-arm64": "0.1.0
|
|
29
|
-
"@zitadel/server-
|
|
30
|
-
"@zitadel/server-
|
|
34
|
+
"@zitadel/server-darwin-arm64": "0.1.0",
|
|
35
|
+
"@zitadel/server-darwin-x64": "0.1.0",
|
|
36
|
+
"@zitadel/server-linux-arm64": "0.1.0",
|
|
37
|
+
"@zitadel/server-linux-x64": "0.1.0",
|
|
38
|
+
"@zitadel/server-win32-x64": "0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"openapi": "cd ../.. && node scripts/lint-openapi.mjs",
|
|
42
|
+
"format": "cd ../.. && node scripts/go-format-check.mjs",
|
|
43
|
+
"generate": "cd ../.. && node scripts/task-guard.mjs --mutex generated-sources -- node scripts/go-generate.mjs",
|
|
44
|
+
"clean-generated": "cd ../.. && node scripts/task-guard.mjs --mutex generated-sources -- node scripts/clean-generated.mjs",
|
|
45
|
+
"check-generate": "cd ../.. && node scripts/task-guard.mjs --mutex generated-sources -- node scripts/check-go-generate.mjs",
|
|
46
|
+
"check-generate-pruned": "cd ../.. && node scripts/task-guard.mjs --mutex generated-sources -- node scripts/check-go-generate.mjs --prune",
|
|
47
|
+
"vet": "cd ../.. && go vet ./...",
|
|
48
|
+
"lint": "cd ../.. && node scripts/go-lint.mjs",
|
|
49
|
+
"test": "cd ../.. && go test -v -timeout 10m ./...",
|
|
50
|
+
"test-postgres": "cd ../.. && go test -v -count=1 -tags postgres_integration -timeout 10m ./...",
|
|
51
|
+
"test-spanner": "cd ../.. && go test -v -count=1 -tags spanner_integration -timeout 10m -p 1 ./...",
|
|
52
|
+
"test-sqlite": "cd ../.. && go test -v -count=1 -tags sqlite_integration -timeout 5m ./...",
|
|
53
|
+
"build": "cd ../.. && node scripts/server-build.mjs"
|
|
31
54
|
}
|
|
32
55
|
}
|