sensez 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.
Files changed (2) hide show
  1. package/bin/sense.js +68 -0
  2. package/package.json +31 -0
package/bin/sense.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createRequire } from "node:module";
4
+ import { spawn } from "node:child_process";
5
+
6
+ const require = createRequire(import.meta.url);
7
+
8
+ const target = platformTarget(process.platform, process.arch);
9
+ if (!target) {
10
+ fail(`unsupported platform: ${process.platform} ${process.arch}`);
11
+ }
12
+
13
+ const binaryPath = resolveBinary(target);
14
+ await run(binaryPath, process.argv.slice(2));
15
+
16
+ function platformTarget(platform, arch) {
17
+ if (platform === "darwin") {
18
+ if (arch === "arm64") {
19
+ return { packageName: "sensez-darwin-arm64", binary: "bin/sense" };
20
+ }
21
+ if (arch === "x64") {
22
+ return { packageName: "sensez-darwin-x64", binary: "bin/sense" };
23
+ }
24
+ }
25
+ if (platform === "linux") {
26
+ if (arch === "arm64") {
27
+ return { packageName: "sensez-linux-arm64-gnu", binary: "bin/sense" };
28
+ }
29
+ if (arch === "x64") {
30
+ return { packageName: "sensez-linux-x64-gnu", binary: "bin/sense" };
31
+ }
32
+ }
33
+ if (platform === "win32" && arch === "x64") {
34
+ return { packageName: "sensez-win32-x64-msvc", binary: "bin/sense.exe" };
35
+ }
36
+ return null;
37
+ }
38
+
39
+ function resolveBinary(target) {
40
+ try {
41
+ return require.resolve(`${target.packageName}/${target.binary}`);
42
+ } catch {
43
+ fail(
44
+ `missing native package ${target.packageName}; reinstall sensez with optional dependencies enabled`,
45
+ );
46
+ }
47
+ }
48
+
49
+ function run(binaryPath, args) {
50
+ return new Promise((resolve, reject) => {
51
+ const child = spawn(binaryPath, args, { stdio: "inherit" });
52
+ child.on("error", reject);
53
+ child.on("exit", (code, signal) => {
54
+ if (signal) {
55
+ reject(new Error(`sense exited with signal ${signal}`));
56
+ return;
57
+ }
58
+ resolve(code ?? 1);
59
+ });
60
+ }).then((code) => {
61
+ process.exitCode = code;
62
+ });
63
+ }
64
+
65
+ function fail(message) {
66
+ console.error(`sensez npm launcher: ${message}`);
67
+ process.exit(1);
68
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "sensez",
3
+ "version": "0.1.0",
4
+ "description": "Sensez CLI launcher for structural maintainability checks",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/popov95s/sensez.git",
10
+ "directory": "npm"
11
+ },
12
+ "bin": {
13
+ "sense": "bin/sense.js"
14
+ },
15
+ "files": [
16
+ "bin"
17
+ ],
18
+ "optionalDependencies": {
19
+ "sensez-darwin-arm64": "0.1.0",
20
+ "sensez-darwin-x64": "0.1.0",
21
+ "sensez-linux-arm64-gnu": "0.1.0",
22
+ "sensez-linux-x64-gnu": "0.1.0",
23
+ "sensez-win32-x64-msvc": "0.1.0"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ }
31
+ }