@daml-tools/daml-fmt 0.2.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/README.md +11 -0
- package/bin/daml-fmt.cjs +69 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @daml-tools/daml-fmt
|
|
2
|
+
|
|
3
|
+
npm distribution package for the `daml-fmt` CLI.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install --save-dev @daml-tools/daml-fmt
|
|
7
|
+
npx daml-fmt --check ./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.
|
package/bin/daml-fmt.cjs
ADDED
|
@@ -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-fmt-darwin-arm64",
|
|
11
|
+
binary: ["bin", "daml-fmt"],
|
|
12
|
+
},
|
|
13
|
+
"linux:x64": {
|
|
14
|
+
name: "@daml-tools/daml-fmt-linux-x64",
|
|
15
|
+
binary: ["bin", "daml-fmt"],
|
|
16
|
+
},
|
|
17
|
+
"win32:x64": {
|
|
18
|
+
name: "@daml-tools/daml-fmt-win32-x64",
|
|
19
|
+
binary: ["bin", "daml-fmt.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-fmt 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-fmt with optional dependencies enabled.",
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!existsSync(binaryPath)) {
|
|
48
|
+
console.error(`The native daml-fmt 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-fmt: ${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-fmt",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "npm-distributed daml-fmt 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-fmt/npm/cli"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"daml-fmt": "./bin/daml-fmt.cjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@daml-tools/daml-fmt-darwin-arm64": "0.2.2",
|
|
20
|
+
"@daml-tools/daml-fmt-linux-x64": "0.2.2",
|
|
21
|
+
"@daml-tools/daml-fmt-win32-x64": "0.2.2"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
}
|
|
29
|
+
}
|