@daml-tools/daml-lint 0.3.4

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 ADDED
@@ -0,0 +1,11 @@
1
+ # @daml-tools/daml-lint
2
+
3
+ npm distribution package for the `daml-lint` CLI.
4
+
5
+ ```sh
6
+ npm install --save-dev @daml-tools/daml-lint
7
+ npx daml-lint ./daml
8
+ ```
9
+
10
+ The package installs a small JavaScript launcher plus an optional native
11
+ platform package for the current operating system and CPU.
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { existsSync } = require("node:fs");
5
+ const path = require("node:path");
6
+ const { spawnSync } = require("node:child_process");
7
+
8
+ const platformPackages = {
9
+ "darwin:arm64": {
10
+ name: "@daml-tools/daml-lint-darwin-arm64",
11
+ binary: ["bin", "daml-lint"],
12
+ },
13
+ "linux:x64": {
14
+ name: "@daml-tools/daml-lint-linux-x64",
15
+ binary: ["bin", "daml-lint"],
16
+ },
17
+ "win32:x64": {
18
+ name: "@daml-tools/daml-lint-win32-x64",
19
+ binary: ["bin", "daml-lint.exe"],
20
+ },
21
+ };
22
+
23
+ const platformKey = `${process.platform}:${process.arch}`;
24
+ const platformPackage = platformPackages[platformKey];
25
+
26
+ if (!platformPackage) {
27
+ console.error(
28
+ `daml-lint is not distributed for ${process.platform}/${process.arch}. ` +
29
+ "Supported npm platforms are linux/x64, darwin/arm64, and win32/x64.",
30
+ );
31
+ process.exit(1);
32
+ }
33
+
34
+ let binaryPath;
35
+
36
+ try {
37
+ const packageJsonPath = require.resolve(`${platformPackage.name}/package.json`);
38
+ binaryPath = path.join(path.dirname(packageJsonPath), ...platformPackage.binary);
39
+ } catch {
40
+ console.error(
41
+ `The native package ${platformPackage.name} is not installed. ` +
42
+ "Reinstall @daml-tools/daml-lint with optional dependencies enabled.",
43
+ );
44
+ process.exit(1);
45
+ }
46
+
47
+ if (!existsSync(binaryPath)) {
48
+ console.error(`The native daml-lint binary is missing from ${platformPackage.name}.`);
49
+ process.exit(1);
50
+ }
51
+
52
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
53
+ stdio: "inherit",
54
+ windowsHide: false,
55
+ });
56
+
57
+ if (result.error) {
58
+ console.error(`Failed to start daml-lint: ${result.error.message}`);
59
+ process.exit(1);
60
+ }
61
+
62
+ if (result.signal) {
63
+ if (process.platform !== "win32") {
64
+ process.kill(process.pid, result.signal);
65
+ }
66
+ process.exit(1);
67
+ }
68
+
69
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@daml-tools/daml-lint",
3
+ "version": "0.3.4",
4
+ "description": "npm-distributed daml-lint CLI",
5
+ "license": "AGPL-3.0-only",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/stevennevins/daml-tools.git",
9
+ "directory": "crates/daml-lint/npm/cli"
10
+ },
11
+ "bin": {
12
+ "daml-lint": "./bin/daml-lint.cjs"
13
+ },
14
+ "files": [
15
+ "bin",
16
+ "README.md"
17
+ ],
18
+ "optionalDependencies": {
19
+ "@daml-tools/daml-lint-darwin-arm64": "0.3.4",
20
+ "@daml-tools/daml-lint-linux-x64": "0.3.4",
21
+ "@daml-tools/daml-lint-win32-x64": "0.3.4"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "engines": {
27
+ "node": ">=18"
28
+ }
29
+ }