@prism-js/prism 0.1.1-canary.1

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,2 @@
1
+ # Prism
2
+
package/bin/prism ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { env,platform, arch ,cwd } = process
4
+ const { spawnSync } = require("child_process");
5
+ const path = require("path");
6
+
7
+ const PLATFORMS = {
8
+ linux: {
9
+ x64: "@prism-js/cli-linux-x64/prism",
10
+ arm64: "@prism-js/cli-linux-arm64/prism",
11
+ }
12
+ };
13
+
14
+ const bin = env.PRISM_BINARY || PLATFORMS?.[platform]?.[arch]
15
+
16
+ let binPath;
17
+ if (bin.startsWith(".") || bin.startsWith("/") ) {
18
+ binPath = path.resolve(cwd(), bin);
19
+ } else {
20
+ binPath = require.resolve(bin);
21
+ }
22
+
23
+ if(binPath){
24
+ const result = spawnSync(binPath,process.argv.slice(2),{
25
+ shell: false,
26
+ stdio: "inherit",
27
+ env: {
28
+ ...env,
29
+ }
30
+ })
31
+
32
+ if (result.error) {
33
+ throw result.error;
34
+ }
35
+
36
+ process.exitCode = result.status;
37
+ }else{
38
+ console.error("[prism] Unsupported platform or architecture");
39
+ console.error(` platform: ${platform}`);
40
+ console.error(` arch: ${arch}`);
41
+
42
+ console.error("\nSupported combinations:");
43
+ for (const [p, archs] of Object.entries(PLATFORMS)) {
44
+ for (const a of Object.keys(archs)) {
45
+ console.error(` - ${p}/${a}`);
46
+ }
47
+ }
48
+
49
+ console.error(
50
+ "\nYou can override this by setting PRISM_BINARY to a custom executable path."
51
+ );
52
+
53
+ process.exitCode = 1;
54
+ }
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@prism-js/prism",
3
+ "version": "0.1.1-canary.1",
4
+ "bin": {
5
+ "prism": "./bin/prism"
6
+ },
7
+ "files": [
8
+ "bin",
9
+ "README.md",
10
+ "schema.json"
11
+ ],
12
+ "optionalDependencies": {
13
+ "@prism-js/cli-linux-x64": "0.1.1-canary.1"
14
+ }
15
+ }
package/schema.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Configuration",
4
+ "type": "object",
5
+ "properties": {
6
+ "$schema": {
7
+ "anyOf": [
8
+ {
9
+ "$ref": "#/$defs/Schema"
10
+ },
11
+ {
12
+ "type": "null"
13
+ }
14
+ ]
15
+ }
16
+ },
17
+ "additionalProperties": false,
18
+ "$defs": {
19
+ "Schema": {
20
+ "type": "string"
21
+ }
22
+ }
23
+ }