@guardian-network/policy-cli 0.3.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 +32 -0
- package/dist/package.json +83 -0
- package/dist/src/compiler-module/handler/compile-command.helper.d.ts +3 -0
- package/dist/src/compiler-module/handler/compile-command.helper.d.ts.map +1 -0
- package/dist/src/compiler-module/handler/compile-command.helper.js +47 -0
- package/dist/src/compiler-module/handler/compile-command.helper.js.map +1 -0
- package/dist/src/compiler-module/handler/index.d.ts +2 -0
- package/dist/src/compiler-module/handler/index.d.ts.map +1 -0
- package/dist/src/compiler-module/handler/index.js +6 -0
- package/dist/src/compiler-module/handler/index.js.map +1 -0
- package/dist/src/compiler-module/handler/utils.helper.d.ts +2 -0
- package/dist/src/compiler-module/handler/utils.helper.d.ts.map +1 -0
- package/dist/src/compiler-module/handler/utils.helper.js +11 -0
- package/dist/src/compiler-module/handler/utils.helper.js.map +1 -0
- package/dist/src/compiler-module/index.d.ts +2 -0
- package/dist/src/compiler-module/index.d.ts.map +1 -0
- package/dist/src/compiler-module/index.js +6 -0
- package/dist/src/compiler-module/index.js.map +1 -0
- package/dist/src/compiler-module/options/index.d.ts +2 -0
- package/dist/src/compiler-module/options/index.d.ts.map +1 -0
- package/dist/src/compiler-module/options/index.js +18 -0
- package/dist/src/compiler-module/options/index.js.map +1 -0
- package/dist/src/compiler-module/options/options.d.ts +6 -0
- package/dist/src/compiler-module/options/options.d.ts.map +1 -0
- package/dist/src/compiler-module/options/options.js +24 -0
- package/dist/src/compiler-module/options/options.js.map +1 -0
- package/dist/src/compiler-module/options/types.d.ts +12 -0
- package/dist/src/compiler-module/options/types.d.ts.map +1 -0
- package/dist/src/compiler-module/options/types.js +3 -0
- package/dist/src/compiler-module/options/types.js.map +1 -0
- package/dist/src/constants/commands.d.ts +2 -0
- package/dist/src/constants/commands.d.ts.map +1 -0
- package/dist/src/constants/commands.js +5 -0
- package/dist/src/constants/commands.js.map +1 -0
- package/dist/src/constants/index.d.ts +2 -0
- package/dist/src/constants/index.d.ts.map +1 -0
- package/dist/src/constants/index.js +18 -0
- package/dist/src/constants/index.js.map +1 -0
- package/dist/src/errors/cli-errors.d.ts +4 -0
- package/dist/src/errors/cli-errors.d.ts.map +1 -0
- package/dist/src/errors/cli-errors.js +11 -0
- package/dist/src/errors/cli-errors.js.map +1 -0
- package/dist/src/errors/index.d.ts +2 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +18 -0
- package/dist/src/errors/index.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +83 -0
- package/src/compiler-module/handler/compile-command.helper.ts +64 -0
- package/src/compiler-module/handler/index.ts +1 -0
- package/src/compiler-module/handler/utils.helper.ts +9 -0
- package/src/compiler-module/index.ts +1 -0
- package/src/compiler-module/options/index.ts +1 -0
- package/src/compiler-module/options/options.ts +24 -0
- package/src/compiler-module/options/types.ts +11 -0
- package/src/constants/commands.ts +1 -0
- package/src/constants/index.ts +1 -0
- package/src/errors/cli-errors.ts +7 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# CLI for Policy SDK
|
|
2
|
+
Policy SDK has a bunch of tools and subsystems. Some of them are exposed as a command line utilites.
|
|
3
|
+
|
|
4
|
+
------------
|
|
5
|
+
|
|
6
|
+
## LacLang compiler
|
|
7
|
+
The compiler of Lacero Policy Markup language (LacLang).
|
|
8
|
+
Can be invoked via `compile` command.
|
|
9
|
+
Has options:
|
|
10
|
+
* `-p` or `--sourcePath` \
|
|
11
|
+
Defines path to LacLang (`.lac`) sources. __Mandatory option__.
|
|
12
|
+
|
|
13
|
+
* `-w` or ` --write` \
|
|
14
|
+
Defines path to output file (`.json`). Otherwise the result will be printed to *stdout*.
|
|
15
|
+
|
|
16
|
+
* `--type-onchain` \
|
|
17
|
+
Checks typings against onchain declarations. Works only if `--rpc` provided or `$RPC` environment variable set.
|
|
18
|
+
|
|
19
|
+
* `--type-dsl` \
|
|
20
|
+
Checks typings against dsl declarations. Works only if `--rpc` provided or `$RPC` environment variable set.
|
|
21
|
+
|
|
22
|
+
* `--rpc` \
|
|
23
|
+
Defines `JSON-RPC URL` of the provider to the target blockchain.
|
|
24
|
+
Can be substituted with `$RPC` environment variable.
|
|
25
|
+
|
|
26
|
+
Usage example:
|
|
27
|
+
|
|
28
|
+
As a project:
|
|
29
|
+
> pnpm cli compile --sourcePath ./dsl-sources-sample/DummyValid.lac
|
|
30
|
+
|
|
31
|
+
As a package:
|
|
32
|
+
> npx @guardian-network/policy-cli compile --sourcePath ./dsl-sources-sample/DummyValid.lac
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guardian-network/policy-cli",
|
|
3
|
+
"author": "vpriadko@lacero.io, v.grabovski@lacero.io",
|
|
4
|
+
"description": "CLI for Policy SDK",
|
|
5
|
+
"version": "0.3.1",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.20.4"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"policy-cli": "./dist/src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://npmjs.org",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "pnpm format:all:fix && tsc -p tsconfig-prod.json && pnpm copy-dts",
|
|
24
|
+
"check": "pnpm lint:ts && pnpm check:ts",
|
|
25
|
+
"check:ts": "tsc -p tsconfig-prod.json --noEmit",
|
|
26
|
+
"check:ts:dev": "tsc -p tsconfig.json --noEmit",
|
|
27
|
+
"clean": "pnpm remove:dist",
|
|
28
|
+
"cli": "ts-node ./src/index.ts",
|
|
29
|
+
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist",
|
|
30
|
+
"format:all:fix": "pnpm format:ts:fix",
|
|
31
|
+
"format:ts:fix": "prettier -w -c \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
32
|
+
"lint:ts": "eslint",
|
|
33
|
+
"lint:ts:fix": "eslint --fix",
|
|
34
|
+
"publish-package": "pnpm publish --no-git-checks",
|
|
35
|
+
"remove:dist": "npx rimraf dist",
|
|
36
|
+
"test": "mocha",
|
|
37
|
+
"tests:coverage:ts": "nyc pnpm test",
|
|
38
|
+
"version": "pnpm version"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"cli",
|
|
42
|
+
"policy",
|
|
43
|
+
"laclang",
|
|
44
|
+
"sdk",
|
|
45
|
+
"blockchain"
|
|
46
|
+
],
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
49
|
+
"@eslint/js": "^9.13.0",
|
|
50
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
51
|
+
"@types/chai": "4.3.3",
|
|
52
|
+
"@types/mocha": "^10.0.9",
|
|
53
|
+
"@types/node": "^22.8.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.8.0",
|
|
56
|
+
"chai": "^4.5.0",
|
|
57
|
+
"copyfiles": "^2.4.1",
|
|
58
|
+
"dotenv": "^16.4.5",
|
|
59
|
+
"eslint": "^9.11.1",
|
|
60
|
+
"eslint-config-prettier": "^9.1.0",
|
|
61
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
62
|
+
"eslint-plugin-import": "^2.31.0",
|
|
63
|
+
"eslint-plugin-mocha": "^10.5.0",
|
|
64
|
+
"eslint-plugin-n": "^17.10.3",
|
|
65
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
66
|
+
"eslint-plugin-promise": "^7.1.0",
|
|
67
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
68
|
+
"globals": "^15.11.0",
|
|
69
|
+
"mocha": "^10.8.2",
|
|
70
|
+
"nyc": "^18.0.0",
|
|
71
|
+
"prettier": "^3.3.3",
|
|
72
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
73
|
+
"rimraf": "^6.0.1",
|
|
74
|
+
"ts-node": "^10.9.2"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@guardian-network/policy-compiler": "workspace:*",
|
|
78
|
+
"@guardian-network/shared": "workspace:*",
|
|
79
|
+
"commander": "^12.1.0",
|
|
80
|
+
"ethers": "^6.16.0",
|
|
81
|
+
"typescript": "^5.6.2"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-command.helper.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/handler/compile-command.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkDpC,eAAO,MAAM,cAAc,YAAa,OAAO,YAW9C,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileCommand = void 0;
|
|
4
|
+
const policy_compiler_1 = require("@guardian-network/policy-compiler");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const errors_1 = require("../../errors");
|
|
8
|
+
const options_1 = require("../options");
|
|
9
|
+
const utils_helper_1 = require("./utils.helper");
|
|
10
|
+
const retrieveCompilerOptions = (options) => {
|
|
11
|
+
let config = {};
|
|
12
|
+
const { typeDsl, typeOnchain, rpc } = options;
|
|
13
|
+
if (!!typeOnchain || !!typeDsl) {
|
|
14
|
+
const rpcEndpoint = rpc || process.env.RPC;
|
|
15
|
+
if (!rpcEndpoint)
|
|
16
|
+
throw new errors_1.NoRpcUrlConfiguredError();
|
|
17
|
+
config = {
|
|
18
|
+
checkTypesAgainstOnchainDescriptors: !!typeOnchain,
|
|
19
|
+
checkTypesAgainstDslDeclarations: !!typeDsl,
|
|
20
|
+
provider: new ethers_1.JsonRpcProvider(rpcEndpoint),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return config;
|
|
24
|
+
};
|
|
25
|
+
const compile = async (options) => {
|
|
26
|
+
const compilerOptions = retrieveCompilerOptions(options);
|
|
27
|
+
const compiler = await policy_compiler_1.LacLangCompiler.fromFile(options.sourcePath, compilerOptions);
|
|
28
|
+
const compilationOutput = await compiler.compile();
|
|
29
|
+
if (!!options.write) {
|
|
30
|
+
(0, utils_helper_1.writeJsonToFile)(options.write, compilationOutput);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log(`Compilation result: \r\n ${JSON.stringify(compilationOutput, null, 2)}`);
|
|
34
|
+
};
|
|
35
|
+
const compileCommand = (program) => {
|
|
36
|
+
program
|
|
37
|
+
.command(constants_1.COMPILE)
|
|
38
|
+
.requiredOption(...options_1.sourcePathOptions)
|
|
39
|
+
.option(...options_1.typeOnchainOption)
|
|
40
|
+
.option(...options_1.typeDslOption)
|
|
41
|
+
.option(...options_1.rpcEndpointOption)
|
|
42
|
+
.option(...options_1.writeCompilationResultOption)
|
|
43
|
+
.action(compile);
|
|
44
|
+
return program;
|
|
45
|
+
};
|
|
46
|
+
exports.compileCommand = compileCommand;
|
|
47
|
+
//# sourceMappingURL=compile-command.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-command.helper.js","sourceRoot":"","sources":["../../../../src/compiler-module/handler/compile-command.helper.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAGpE,mCAAyC;AACzC,+CAA0C;AAC1C,yCAAuD;AACvD,wCAMoB;AAEpB,iDAAiD;AAEjD,MAAM,uBAAuB,GAAG,CAAC,OAA0B,EAAE,EAAE;IAC7D,IAAI,MAAM,GAA2B,EAAE,CAAC;IACxC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAE9C,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAC3C,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,gCAAuB,EAAE,CAAC;QAEtD,MAAM,GAAG;YACP,mCAAmC,EAAE,CAAC,CAAC,WAAW;YAClD,gCAAgC,EAAE,CAAC,CAAC,OAAO;YAC3C,QAAQ,EAAE,IAAI,wBAAe,CAAC,WAAW,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,KAAK,EAAE,OAA0B,EAAE,EAAE;IACnD,MAAM,eAAe,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAc,MAAM,iCAAe,CAAC,QAAQ,CACxD,OAAO,CAAC,UAAU,EAClB,eAAe,CAChB,CAAC;IACF,MAAM,iBAAiB,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEnD,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpB,IAAA,8BAAe,EAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAClD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CACT,4BAA4B,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CACzE,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IACjD,OAAO;SACJ,OAAO,CAAC,mBAAO,CAAC;SAChB,cAAc,CAAC,GAAG,2BAAiB,CAAC;SACpC,MAAM,CAAC,GAAG,2BAAiB,CAAC;SAC5B,MAAM,CAAC,GAAG,uBAAa,CAAC;SACxB,MAAM,CAAC,GAAG,2BAAiB,CAAC;SAC5B,MAAM,CAAC,GAAG,sCAA4B,CAAC;SACvC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileCommand = void 0;
|
|
4
|
+
var compile_command_helper_1 = require("./compile-command.helper");
|
|
5
|
+
Object.defineProperty(exports, "compileCommand", { enumerable: true, get: function () { return compile_command_helper_1.compileCommand; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/compiler-module/handler/index.ts"],"names":[],"mappings":";;;AAAA,mEAA0D;AAAjD,wHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.helper.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/handler/utils.helper.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,aAAc,MAAM,QAAQ,MAAM,KAAG,IAKhE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeJsonToFile = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const writeJsonToFile = (filePath, data) => {
|
|
6
|
+
const jsonData = JSON.stringify(data, null, 2);
|
|
7
|
+
(0, node_fs_1.writeFileSync)(filePath, jsonData, { flag: 'w' });
|
|
8
|
+
console.log(`Compilation result is successfully written to "${filePath}"`);
|
|
9
|
+
};
|
|
10
|
+
exports.writeJsonToFile = writeJsonToFile;
|
|
11
|
+
//# sourceMappingURL=utils.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.helper.js","sourceRoot":"","sources":["../../../../src/compiler-module/handler/utils.helper.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AAEjC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAQ,EAAE;IACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAE/C,IAAA,uBAAa,EAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,kDAAkD,QAAQ,GAAG,CAAC,CAAC;AAC7E,CAAC,CAAC;AALW,QAAA,eAAe,mBAK1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compiler-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileCommand = void 0;
|
|
4
|
+
var handler_1 = require("./handler");
|
|
5
|
+
Object.defineProperty(exports, "compileCommand", { enumerable: true, get: function () { return handler_1.compileCommand; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compiler-module/index.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./options"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/compiler-module/options/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const typeOnchainOption: [string, string];
|
|
2
|
+
export declare const typeDslOption: [string, string];
|
|
3
|
+
export declare const rpcEndpointOption: [string, string];
|
|
4
|
+
export declare const writeCompilationResultOption: [string, string];
|
|
5
|
+
export declare const sourcePathOptions: [string, string];
|
|
6
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/options/options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAG9C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAG1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAG9C,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,CAAC,MAAM,EAAE,MAAM,CAGzD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAG9C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourcePathOptions = exports.writeCompilationResultOption = exports.rpcEndpointOption = exports.typeDslOption = exports.typeOnchainOption = void 0;
|
|
4
|
+
exports.typeOnchainOption = [
|
|
5
|
+
'--type-onchain',
|
|
6
|
+
'[OPTIONAL] Triggers types checking via onchain artifacts description, equivalent to checkTypesAgainstOnchain = true',
|
|
7
|
+
];
|
|
8
|
+
exports.typeDslOption = [
|
|
9
|
+
'--type-dsl',
|
|
10
|
+
'[OPTIONAL] Triggers types checking via dsl definitions, equivalent to checkTypesAgainstDeclaration = true',
|
|
11
|
+
];
|
|
12
|
+
exports.rpcEndpointOption = [
|
|
13
|
+
'--rpc <URL>',
|
|
14
|
+
'[OPTIONAL, if --type-*] JSON RPC URL is required for type checking communication. Otherwise the value from $RPC env variable is consumed',
|
|
15
|
+
];
|
|
16
|
+
exports.writeCompilationResultOption = [
|
|
17
|
+
'-w, --write <outputPath>',
|
|
18
|
+
'[OPTIONAL] Writes compilation output as JSON to dedicated file',
|
|
19
|
+
];
|
|
20
|
+
exports.sourcePathOptions = [
|
|
21
|
+
'-p, --sourcePath <lacFilePath>',
|
|
22
|
+
'Path to LacLang (*.lac) sources',
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/compiler-module/options/options.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAqB;IACjD,gBAAgB;IAChB,qHAAqH;CACtH,CAAC;AAEW,QAAA,aAAa,GAAqB;IAC7C,YAAY;IACZ,2GAA2G;CAC5G,CAAC;AAEW,QAAA,iBAAiB,GAAqB;IACjD,aAAa;IACb,0IAA0I;CAC3I,CAAC;AAEW,QAAA,4BAA4B,GAAqB;IAC5D,0BAA0B;IAC1B,gEAAgE;CACjE,CAAC;AAEW,QAAA,iBAAiB,GAAqB;IACjD,gCAAgC;IAChC,iCAAiC;CAClC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CompileOptionsBase = {
|
|
2
|
+
typeDsl: string;
|
|
3
|
+
typeOnchain: string;
|
|
4
|
+
rpc: string;
|
|
5
|
+
write: string;
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
};
|
|
8
|
+
export type CliCompileOptions = Partial<CompileOptionsBase> & {
|
|
9
|
+
sourcePath: string;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/compiler-module/options/types.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/compiler-module/options/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/constants/commands.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/constants/commands.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./commands"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/cli-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;;CAMjD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoRpcUrlConfiguredError = void 0;
|
|
4
|
+
class NoRpcUrlConfiguredError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
const msg = `Need to provide JSON RPC URL to use typing validations`;
|
|
7
|
+
super(msg);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.NoRpcUrlConfiguredError = NoRpcUrlConfiguredError;
|
|
11
|
+
//# sourceMappingURL=cli-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-errors.js","sourceRoot":"","sources":["../../../src/errors/cli-errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAChD;QACE,MAAM,GAAG,GAAG,wDAAwD,CAAC;QAErE,KAAK,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;CACF;AAND,0DAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli-errors"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const dotenv_1 = require("dotenv");
|
|
5
|
+
const package_json_1 = require("../package.json");
|
|
6
|
+
const compiler_module_1 = require("./compiler-module");
|
|
7
|
+
(0, dotenv_1.config)();
|
|
8
|
+
const program = new commander_1.Command();
|
|
9
|
+
program
|
|
10
|
+
.name('Guardian-network Policy CLI')
|
|
11
|
+
.description('CLI tools for a LacLang Policy composition language')
|
|
12
|
+
.version(package_json_1.version);
|
|
13
|
+
(0, compiler_module_1.compileCommand)(program);
|
|
14
|
+
program.parse();
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAIA,yCAAoC;AACpC,mCAAgC;AAChC,kDAA0C;AAC1C,uDAAmD;AAEnD,IAAA,eAAM,GAAE,CAAC;AAET,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,6BAA6B,CAAC;KACnC,WAAW,CAAC,qDAAqD,CAAC;KAClE,OAAO,CAAC,sBAAO,CAAC,CAAC;AAEpB,IAAA,gCAAc,EAAC,OAAO,CAAC,CAAC;AAExB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guardian-network/policy-cli",
|
|
3
|
+
"author": "vpriadko@lacero.io, v.grabovski@lacero.io",
|
|
4
|
+
"description": "CLI for Policy SDK",
|
|
5
|
+
"version": "0.3.2",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.20.4"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"policy-cli": "./dist/src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"cli",
|
|
24
|
+
"policy",
|
|
25
|
+
"laclang",
|
|
26
|
+
"sdk",
|
|
27
|
+
"blockchain"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
31
|
+
"@eslint/js": "^9.13.0",
|
|
32
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
33
|
+
"@types/chai": "4.3.3",
|
|
34
|
+
"@types/mocha": "^10.0.9",
|
|
35
|
+
"@types/node": "^22.8.0",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
|
37
|
+
"@typescript-eslint/parser": "^8.8.0",
|
|
38
|
+
"chai": "^4.5.0",
|
|
39
|
+
"copyfiles": "^2.4.1",
|
|
40
|
+
"dotenv": "^16.4.5",
|
|
41
|
+
"eslint": "^9.11.1",
|
|
42
|
+
"eslint-config-prettier": "^9.1.0",
|
|
43
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
44
|
+
"eslint-plugin-import": "^2.31.0",
|
|
45
|
+
"eslint-plugin-mocha": "^10.5.0",
|
|
46
|
+
"eslint-plugin-n": "^17.10.3",
|
|
47
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
48
|
+
"eslint-plugin-promise": "^7.1.0",
|
|
49
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
50
|
+
"globals": "^15.11.0",
|
|
51
|
+
"mocha": "^10.8.2",
|
|
52
|
+
"nyc": "^18.0.0",
|
|
53
|
+
"prettier": "^3.3.3",
|
|
54
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
55
|
+
"rimraf": "^6.0.1",
|
|
56
|
+
"ts-node": "^10.9.2"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"commander": "^12.1.0",
|
|
60
|
+
"ethers": "^6.16.0",
|
|
61
|
+
"typescript": "^5.6.2",
|
|
62
|
+
"@guardian-network/policy-compiler": "0.3.2",
|
|
63
|
+
"@guardian-network/shared": "0.3.2"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "pnpm format:all:fix && tsc -p tsconfig-prod.json && pnpm copy-dts",
|
|
67
|
+
"check": "pnpm lint:ts && pnpm check:ts",
|
|
68
|
+
"check:ts": "tsc -p tsconfig-prod.json --noEmit",
|
|
69
|
+
"check:ts:dev": "tsc -p tsconfig.json --noEmit",
|
|
70
|
+
"clean": "pnpm remove:dist",
|
|
71
|
+
"cli": "ts-node ./src/index.ts",
|
|
72
|
+
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist",
|
|
73
|
+
"format:all:fix": "pnpm format:ts:fix",
|
|
74
|
+
"format:ts:fix": "prettier -w -c \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
75
|
+
"lint:ts": "eslint",
|
|
76
|
+
"lint:ts:fix": "eslint --fix",
|
|
77
|
+
"publish-package": "pnpm publish --no-git-checks",
|
|
78
|
+
"remove:dist": "npx rimraf dist",
|
|
79
|
+
"test": "mocha",
|
|
80
|
+
"tests:coverage:ts": "nyc pnpm test",
|
|
81
|
+
"version": "pnpm version"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LacLangCompiler } from '@guardian-network/policy-compiler';
|
|
2
|
+
import { ICompiler, LacLangCompilerOptions } from '@guardian-network/shared';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { JsonRpcProvider } from 'ethers';
|
|
5
|
+
import { COMPILE } from '../../constants';
|
|
6
|
+
import { NoRpcUrlConfiguredError } from '../../errors';
|
|
7
|
+
import {
|
|
8
|
+
rpcEndpointOption,
|
|
9
|
+
sourcePathOptions,
|
|
10
|
+
typeDslOption,
|
|
11
|
+
typeOnchainOption,
|
|
12
|
+
writeCompilationResultOption,
|
|
13
|
+
} from '../options';
|
|
14
|
+
import { CliCompileOptions } from '../options/types';
|
|
15
|
+
import { writeJsonToFile } from './utils.helper';
|
|
16
|
+
|
|
17
|
+
const retrieveCompilerOptions = (options: CliCompileOptions) => {
|
|
18
|
+
let config: LacLangCompilerOptions = {};
|
|
19
|
+
const { typeDsl, typeOnchain, rpc } = options;
|
|
20
|
+
|
|
21
|
+
if (!!typeOnchain || !!typeDsl) {
|
|
22
|
+
const rpcEndpoint = rpc || process.env.RPC;
|
|
23
|
+
if (!rpcEndpoint) throw new NoRpcUrlConfiguredError();
|
|
24
|
+
|
|
25
|
+
config = {
|
|
26
|
+
checkTypesAgainstOnchainDescriptors: !!typeOnchain,
|
|
27
|
+
checkTypesAgainstDslDeclarations: !!typeDsl,
|
|
28
|
+
provider: new JsonRpcProvider(rpcEndpoint),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return config;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const compile = async (options: CliCompileOptions) => {
|
|
36
|
+
const compilerOptions = retrieveCompilerOptions(options);
|
|
37
|
+
const compiler: ICompiler = await LacLangCompiler.fromFile(
|
|
38
|
+
options.sourcePath,
|
|
39
|
+
compilerOptions,
|
|
40
|
+
);
|
|
41
|
+
const compilationOutput = await compiler.compile();
|
|
42
|
+
|
|
43
|
+
if (!!options.write) {
|
|
44
|
+
writeJsonToFile(options.write, compilationOutput);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log(
|
|
49
|
+
`Compilation result: \r\n ${JSON.stringify(compilationOutput, null, 2)}`,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const compileCommand = (program: Command) => {
|
|
54
|
+
program
|
|
55
|
+
.command(COMPILE)
|
|
56
|
+
.requiredOption(...sourcePathOptions)
|
|
57
|
+
.option(...typeOnchainOption)
|
|
58
|
+
.option(...typeDslOption)
|
|
59
|
+
.option(...rpcEndpointOption)
|
|
60
|
+
.option(...writeCompilationResultOption)
|
|
61
|
+
.action(compile);
|
|
62
|
+
|
|
63
|
+
return program;
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compileCommand } from './compile-command.helper';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-nodejs-modules
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
export const writeJsonToFile = (filePath: string, data: object): void => {
|
|
5
|
+
const jsonData = JSON.stringify(data, null, 2);
|
|
6
|
+
|
|
7
|
+
writeFileSync(filePath, jsonData, { flag: 'w' });
|
|
8
|
+
console.log(`Compilation result is successfully written to "${filePath}"`);
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compileCommand } from './handler';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './options';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const typeOnchainOption: [string, string] = [
|
|
2
|
+
'--type-onchain',
|
|
3
|
+
'[OPTIONAL] Triggers types checking via onchain artifacts description, equivalent to checkTypesAgainstOnchain = true',
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
export const typeDslOption: [string, string] = [
|
|
7
|
+
'--type-dsl',
|
|
8
|
+
'[OPTIONAL] Triggers types checking via dsl definitions, equivalent to checkTypesAgainstDeclaration = true',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const rpcEndpointOption: [string, string] = [
|
|
12
|
+
'--rpc <URL>',
|
|
13
|
+
'[OPTIONAL, if --type-*] JSON RPC URL is required for type checking communication. Otherwise the value from $RPC env variable is consumed',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export const writeCompilationResultOption: [string, string] = [
|
|
17
|
+
'-w, --write <outputPath>',
|
|
18
|
+
'[OPTIONAL] Writes compilation output as JSON to dedicated file',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export const sourcePathOptions: [string, string] = [
|
|
22
|
+
'-p, --sourcePath <lacFilePath>',
|
|
23
|
+
'Path to LacLang (*.lac) sources',
|
|
24
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const COMPILE = 'compile';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './commands';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cli-errors';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// note: the hashbang is required when 'node --harmony' is applied (which is support for es6);
|
|
2
|
+
// otherwise it is redundant
|
|
3
|
+
/* #!/usr/bin/env node */
|
|
4
|
+
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { config } from 'dotenv';
|
|
7
|
+
import { version } from '../package.json';
|
|
8
|
+
import { compileCommand } from './compiler-module';
|
|
9
|
+
|
|
10
|
+
config();
|
|
11
|
+
|
|
12
|
+
const program = new Command();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.name('Guardian-network Policy CLI')
|
|
16
|
+
.description('CLI tools for a LacLang Policy composition language')
|
|
17
|
+
.version(version);
|
|
18
|
+
|
|
19
|
+
compileCommand(program);
|
|
20
|
+
|
|
21
|
+
program.parse();
|