@snyk/axi 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.
- package/README.md +44 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @snyk/axi
|
|
2
|
+
|
|
3
|
+
Lightweight npm wrapper around the [Snyk CLI](https://github.com/snyk/cli).
|
|
4
|
+
|
|
5
|
+
Automatically prepends `agent-scan` (configurable) to every invocation, then delegates to the `snyk` binary from the `snyk` npm package.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @snyk/axi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
# Equivalent to: snyk agent-scan --json
|
|
17
|
+
snyk-axi --json
|
|
18
|
+
|
|
19
|
+
# Equivalent to: snyk agent-scan /path/to/project
|
|
20
|
+
snyk-axi /path/to/project
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
1. Depends on the `snyk` npm package (which downloads the native CLI binary on install).
|
|
26
|
+
2. Resolves the `snyk` binary from `node_modules`.
|
|
27
|
+
3. Prepends configured arguments, appends user arguments, and executes.
|
|
28
|
+
|
|
29
|
+
## Customizing prepended args
|
|
30
|
+
|
|
31
|
+
Edit `PREPEND_ARGS` in `src/index.ts`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const PREPEND_ARGS: string[] = ['agent-scan'];
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Development
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install
|
|
41
|
+
npm run build
|
|
42
|
+
node bin/snyk-axi --help
|
|
43
|
+
```
|
|
44
|
+
# axi
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const child_process_1 = require("child_process");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
// Args to prepend before the user's arguments.
|
|
41
|
+
// Customize this array to inject subcommands or flags.
|
|
42
|
+
const PREPEND_ARGS = ['agent'];
|
|
43
|
+
function resolveSnykBinary() {
|
|
44
|
+
// Resolve the snyk binary from the 'snyk' npm dependency.
|
|
45
|
+
// The 'snyk' package registers bin/snyk which ends up in node_modules/.bin/
|
|
46
|
+
const snykPkgDir = path.dirname(require.resolve('snyk/package.json'));
|
|
47
|
+
const snykBin = path.join(snykPkgDir, 'bin', 'snyk');
|
|
48
|
+
if (!fs.existsSync(snykBin)) {
|
|
49
|
+
throw new Error(`Could not find snyk binary at ${snykBin}. ` +
|
|
50
|
+
'Make sure the "snyk" package is installed.');
|
|
51
|
+
}
|
|
52
|
+
return snykBin;
|
|
53
|
+
}
|
|
54
|
+
function main() {
|
|
55
|
+
const userArgs = process.argv.slice(2);
|
|
56
|
+
const allArgs = [...PREPEND_ARGS, ...userArgs];
|
|
57
|
+
const snykBin = resolveSnykBinary();
|
|
58
|
+
const result = (0, child_process_1.spawnSync)(process.execPath, [snykBin, ...allArgs], {
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: process.env,
|
|
61
|
+
});
|
|
62
|
+
if (result.error) {
|
|
63
|
+
console.error('Failed to execute snyk:', result.error.message);
|
|
64
|
+
process.exit(2);
|
|
65
|
+
}
|
|
66
|
+
process.exit(result.status ?? 1);
|
|
67
|
+
}
|
|
68
|
+
main();
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,iDAA0C;AAC1C,2CAA6B;AAC7B,uCAAyB;AAEzB,+CAA+C;AAC/C,uDAAuD;AACvD,MAAM,YAAY,GAAa,CAAC,OAAO,CAAC,CAA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
"version": "0.1.0",
|
|
4
|
+
"description": "Lightweight wrapper around the Snyk CLI",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "snyk.io",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/snyk/axi.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"snyk-axi": "dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=16"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"snyk": "1.1306.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"typescript": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"registry": "https://registry.npmjs.org/",
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|