initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
9
github/codeql-action-v2/node_modules/code-excerpt/dist/index.d.ts
generated
vendored
Normal file
9
github/codeql-action-v2/node_modules/code-excerpt/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
interface Options {
|
||||
around?: number;
|
||||
}
|
||||
export interface CodeExcerpt {
|
||||
line: number;
|
||||
value: string;
|
||||
}
|
||||
declare const codeExcerpt: (source: string, line: number, options?: Options) => CodeExcerpt[] | undefined;
|
||||
export default codeExcerpt;
|
||||
27
github/codeql-action-v2/node_modules/code-excerpt/dist/index.js
generated
vendored
Normal file
27
github/codeql-action-v2/node_modules/code-excerpt/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import tabsToSpaces from 'convert-to-spaces';
|
||||
const generateLineNumbers = (line, around) => {
|
||||
const lineNumbers = [];
|
||||
const min = line - around;
|
||||
const max = line + around;
|
||||
for (let lineNumber = min; lineNumber <= max; lineNumber++) {
|
||||
lineNumbers.push(lineNumber);
|
||||
}
|
||||
return lineNumbers;
|
||||
};
|
||||
const codeExcerpt = (source, line, options = {}) => {
|
||||
var _a;
|
||||
if (typeof source !== 'string') {
|
||||
throw new TypeError('Source code is missing.');
|
||||
}
|
||||
if (!line || line < 1) {
|
||||
throw new TypeError('Line number must start from `1`.');
|
||||
}
|
||||
const lines = tabsToSpaces(source).split(/\r?\n/);
|
||||
if (line > lines.length) {
|
||||
return;
|
||||
}
|
||||
return generateLineNumbers(line, (_a = options.around) !== null && _a !== void 0 ? _a : 3)
|
||||
.filter(line => lines[line - 1] !== undefined)
|
||||
.map(line => ({ line, value: lines[line - 1] }));
|
||||
};
|
||||
export default codeExcerpt;
|
||||
21
github/codeql-action-v2/node_modules/code-excerpt/license
generated
vendored
Normal file
21
github/codeql-action-v2/node_modules/code-excerpt/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Vadim Demedes <vdemedes@gmail.com> (github.com/vadimdemedes)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
43
github/codeql-action-v2/node_modules/code-excerpt/package.json
generated
vendored
Normal file
43
github/codeql-action-v2/node_modules/code-excerpt/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "code-excerpt",
|
||||
"version": "4.0.0",
|
||||
"description": "Extract code excerpts",
|
||||
"license": "MIT",
|
||||
"repository": "vadimdemedes/code-excerpt",
|
||||
"author": {
|
||||
"name": "vdemedes",
|
||||
"email": "vdemedes@gmail.com",
|
||||
"url": "github.com/vadimdemedes"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"prepare": "npm run build",
|
||||
"pretest": "npm run build",
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"convert-to-spaces": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sindresorhus/tsconfig": "^2.0.0",
|
||||
"@vdemedes/prettier-config": "^2.0.1",
|
||||
"ava": "^4.0.1",
|
||||
"prettier": "^2.5.1",
|
||||
"typescript": "^4.5.5",
|
||||
"xo": "^0.47.0"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true
|
||||
},
|
||||
"prettier": "@vdemedes/prettier-config"
|
||||
}
|
||||
65
github/codeql-action-v2/node_modules/code-excerpt/readme.md
generated
vendored
Normal file
65
github/codeql-action-v2/node_modules/code-excerpt/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# code-excerpt 
|
||||
|
||||
> Extract code excerpts
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save code-excerpt
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import codeExcerpt from 'code-excerpt';
|
||||
|
||||
const source = `
|
||||
'use strict';
|
||||
|
||||
function someFunc() {}
|
||||
|
||||
module.exports = () => {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
const c = 3;
|
||||
|
||||
someFunc();
|
||||
};
|
||||
`.trim();
|
||||
|
||||
const excerpt = codeExcerpt(source, 5);
|
||||
//=> [
|
||||
// {line: 2, value: ''},
|
||||
// {line: 3, value: 'function someFunc() {}'},
|
||||
// {line: 4, value: ''},
|
||||
// {line: 5, value: 'module.exports = () => {'},
|
||||
// {line: 6, value: ' const a = 1;'},
|
||||
// {line: 7, value: ' const b = 2;'},
|
||||
// {line: 8, value: ' const c = 3;'}
|
||||
// ]
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### codeExcerpt(source, line, [options])
|
||||
|
||||
#### source
|
||||
|
||||
Type: `string`
|
||||
|
||||
Source code.
|
||||
|
||||
#### line
|
||||
|
||||
Type: `number`
|
||||
|
||||
Line number to extract excerpt for.
|
||||
|
||||
#### options
|
||||
|
||||
##### around
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `3`
|
||||
|
||||
Number of surrounding lines to extract.
|
||||
Loading…
Add table
Add a link
Reference in a new issue