Merge pull request #170 from crazy-max/eslint

dev: switch to eslint
This commit is contained in:
CrazyMax authored and GitHub committed 2022-03-21 11:01:12 +01:00
commit 70e1ff84cb
16 files changed
+10230 -32448

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
{
"env": {
"node": true,
"es2021": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest",
"prettier"
]
}
+6 -4
View File
@@ -6,6 +6,7 @@ import * as exec from '@actions/exec';
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');
test('loginStandard calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
@@ -15,9 +16,9 @@ test('loginStandard calls exec', async () => {
};
});
const username: string = 'dbowie';
const password: string = 'groundcontrol';
const registry: string = 'https://ghcr.io';
const username = 'dbowie';
const password = 'groundcontrol';
const registry = 'https://ghcr.io';
await loginStandard(registry, username, password);
@@ -29,6 +30,7 @@ test('loginStandard calls exec', async () => {
});
test('logout calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
@@ -38,7 +40,7 @@ test('logout calls exec', async () => {
};
});
const registry: string = 'https://ghcr.io';
const registry = 'https://ghcr.io';
await logout(registry);
+12 -13
View File
@@ -8,8 +8,7 @@ import * as stateHelper from '../src/state-helper';
import * as core from '@actions/core';
test('errors without username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy = jest.spyOn(core, 'setFailed');
@@ -18,21 +17,21 @@ test('errors without username and password', async () => {
});
test('successful with username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());
const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout: boolean = false;
const logout = false;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
@@ -43,25 +42,25 @@ test('successful with username and password', async () => {
});
test('calls docker login', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(jest.fn());
const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const registry: string = 'ghcr.io';
const registry = 'ghcr.io';
process.env[`INPUT_REGISTRY`] = registry;
const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout: boolean = true;
const logout = true;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
+5 -5
View File
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1.3-labs
# syntax=docker/dockerfile:1
ARG NODE_VERSION=12
ARG DOCKER_VERSION=20.10.10
ARG BUILDX_VERSION=0.7.0
ARG DOCKER_VERSION=20.10.13
ARG BUILDX_VERSION=0.8.1
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
@@ -57,10 +57,10 @@ RUN --mount=type=bind,target=.,rw \
FROM scratch AS format-update
COPY --from=format /out /
FROM deps AS format-validate
FROM deps AS lint
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run format-check
yarn run lint
FROM docker:${DOCKER_VERSION} as docker
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
Generated Vendored
+17 -32395
View File
File diff suppressed because it is too large. Load diff
Generated Vendored
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../webpack:/docker-login/node_modules/@actions/core/lib/command.js","../webpack:/docker-login/node_modules/@actions/core/lib/core.js","../webpack:/docker-login/node_modules/@actions/core/lib/file-command.js","../webpack:/docker-login/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/docker-login/node_modules/@actions/core/lib/utils.js","../webpack:/docker-login/node_modules/@actions/exec/lib/exec.js","../webpack:/docker-login/node_modules/@actions/exec/lib/toolrunner.js","../webpack:/docker-login/node_modules/@actions/http-client/auth.js","../webpack:/docker-login/node_modules/@actions/http-client/index.js","../webpack:/docker-login/node_modules/@actions/http-client/proxy.js","../webpack:/docker-login/node_modules/@actions/io/lib/io-util.js","../webpack:/docker-login/node_modules/@actions/io/lib/io.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/ECRPUBLIC.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/ECRPUBLICClient.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/BatchCheckLayerAvailabilityCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/BatchDeleteImageCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/CompleteLayerUploadCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/CreateRepositoryCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DeleteRepositoryCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DeleteRepositoryPolicyCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DescribeImageTagsCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DescribeImagesCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DescribeRegistriesCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/DescribeRepositoriesCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/GetAuthorizationTokenCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/GetRegistryCatalogDataCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/GetRepositoryCatalogDataCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/GetRepositoryPolicyCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/InitiateLayerUploadCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/ListTagsForResourceCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/PutImageCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/PutRegistryCatalogDataCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/PutRepositoryCatalogDataCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/SetRepositoryPolicyCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/TagResourceCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/UntagResourceCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/UploadLayerPartCommand.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/commands/index.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/endpoints.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/index.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/models/ECRPUBLICServiceException.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/models/index.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/models/models_0.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/DescribeImageTagsPaginator.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/DescribeImagesPaginator.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/DescribeRegistriesPaginator.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/DescribeRepositoriesPaginator.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/Interfaces.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/pagination/index.js","../webpack:/docker-login/node_modules/@aws-sdk/client-ecr-public/dist-cjs/protocols/Aws_json1_1.js","../Line truncated
Generated Vendored
+9467
View File
File diff suppressed because it is too large. Load diff
Generated Vendored
+1
View File
@@ -0,0 +1 @@
(()=>{var e={650:e=>{var r=Object.prototype.toString;var n=typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},284:(e,r,n)=>{e=n.nmd(e);var t=n(596).SourceMapConsumer;var o=n(17);var i;try{i=n(147);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(650);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var h=[];var d=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}function handlerExec(e){return function(r){for(var n=0;n<e.length;n++){var t=e[n](r);if(t){return t}}return null}}var m=handlerExec(h);h.push((function(e){e=e.trim();if(/^file:/.test(e)){e=e.replace(/file:\/\/\/(\w:)?/,(function(e,r){return r?"":"/"}))}if(e in p){return p[e]}var r="";try{if(!i){var n=new XMLHttpRequest;n.open("GET",e,false);n.send(null);if(n.readyState===4&&n.status===200){r=n.responseText}}else if(i.existsSync(e)){r=i.readFileSync(e,"utf8")}}catch(e){}return p[e]=r}));function supportRelativeURL(e,r){if(!e)return r;var n=o.dirname(e);var t=/^\w+:\/\/[^\/]*/.exec(n);var i=t?t[0]:"";var a=n.slice(i.length);if(i&&/^\/\w\:/.test(a)){i+="/";return i+o.resolve(n.slice(i.length),r).replace(/\\/g,"/")}return i+o.resolve(n.slice(i.length),r)}function retrieveSourceMapURL(e){var r;if(isInBrowser()){try{var n=new XMLHttpRequest;n.open("GET",e,false);n.send(null);r=n.readyState===4?n.responseText:null;var t=n.getResponseHeader("SourceMap")||n.getResponseHeader("X-SourceMap");if(t){return t}}catch(e){}}r=m(e);var o=/(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/gm;var i,a;while(a=o.exec(r))i=a;if(!i)return null;return i[1]}var v=handlerExec(d);d.push((function(e){var r=retrieveSourceMapURL(e);if(!r)return null;var n;if(g.test(r)){var t=r.slice(r.indexOf(",")+1);n=a(t,"base64").toString();r=e}else{r=supportRelativeURL(e,r);n=m(r)}if(!n){return null}return{url:r,map:n}}));function mapSourcePosition(e){var r=f[e.source];if(!r){var n=v(e.source);if(n){r=f[e.source]={url:n.url,map:new t(n.map)};if(r.map.sourcesContent){r.map.sources.forEach((function(e,n){var t=r.map.sourcesContent[n];if(t){var o=supportRelativeURL(r.url,e);p[o]=t}}))}}else{r=f[e.source]={url:null,map:null}}}if(r&&r.map&&typeof r.map.originalPositionFor==="function"){var o=r.map.originalPositionFor(e);if(o.source!==null){o.source=supportRelativeURL(r.url,o.source);return o}}return e}function mapEvalOrigin(e){var r=/^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(e);if(r){var n=mapSourcePosition({source:r[2],line:+r[3],column:r[4]-1});return"eval at "+r[1]+" ("+n.source+":"+n.line+":"+(n.column+1)+")"}r=/^eval at ([^(]+) \((.+)\)$/.exec(e);if(r){return"eval at "+r[1]+" ("+mapEvalOrigin(r[2])+")"}return e}function CallSiteToString(){var e;var r="";if(this.isNative()){r="native"}else{e=this.getScriptNameOrSourceURL();if(!e&&this.isEval()){r=this.getEvalOrigin();r+=", "}if(e){r+=e}else{r+="<anonymous>"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"<anonymous>")}}else if(u){o+="new "+(i||"<anonymous>")}else if(i){o+=i}elLine truncated
+3 -3
View File
@@ -7,7 +7,7 @@ group "pre-checkin" {
}
group "validate" {
targets = ["format-validate", "build-validate", "vendor-validate"]
targets = ["lint", "build-validate", "vendor-validate"]
}
target "build" {
@@ -28,9 +28,9 @@ target "format" {
output = ["."]
}
target "format-validate" {
target "lint" {
dockerfile = "dev.Dockerfile"
target = "format-validate"
target = "lint"
output = ["type=cacheonly"]
}
+1 -1
View File
@@ -6,5 +6,5 @@ module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: false
verbose: true
}
+12 -5
View File
@@ -3,11 +3,11 @@
"description": "GitHub Action to login against a Docker registry",
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
"test": "jest --coverage",
"pre-checkin": "yarn run format && yarn run build"
"all": "yarn run build && yarn run format && yarn test"
},
"repository": {
"type": "git",
@@ -37,11 +37,18 @@
},
"devDependencies": {
"@types/node": "^16.11.26",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"@vercel/ncc": "^0.33.3",
"dotenv": "^16.0.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.5.1",
"prettier": "^2.3.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.7.0",
"typescript": "^4.4.4"
}
}
+3 -3
View File
@@ -34,7 +34,7 @@ export const getAccountIDs = (registry: string): string[] => {
if (!matches) {
return [];
}
let accountIDs: Array<string> = [matches[2]];
const accountIDs: Array<string> = [matches[2]];
if (process.env.AWS_ACCOUNT_IDS) {
accountIDs.push(...process.env.AWS_ACCOUNT_IDS.split(','));
}
@@ -57,14 +57,14 @@ export const getRegistriesData = async (registry: string, username?: string, pas
authTokenRequest['registryIds'] = accountIDs;
}
let httpProxyAgent: any = null;
let httpProxyAgent;
const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || '';
if (httpProxy) {
core.debug(`Using http proxy ${httpProxy}`);
httpProxyAgent = new HttpProxyAgent(httpProxy);
}
let httpsProxyAgent: any = null;
let httpsProxyAgent;
const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || '';
if (httpsProxy) {
core.debug(`Using https proxy ${httpsProxy}`);
+1 -1
View File
@@ -27,7 +27,7 @@ export async function loginStandard(registry: string, username: string, password
throw new Error('Username and password required');
}
let loginArgs: Array<string> = ['login', '--password-stdin'];
const loginArgs: Array<string> = ['login', '--password-stdin'];
loginArgs.push('--username', username);
loginArgs.push(registry);
+1 -1
View File
@@ -9,7 +9,7 @@ export async function run(): Promise<void> {
stateHelper.setRegistry(input.registry);
stateHelper.setLogout(input.logout);
await docker.login(input.registry, input.username, input.password, input.ecr);
} catch (error: any) {
} catch (error) {
core.setFailed(error.message);
}
}
+9 -4
View File
@@ -1,14 +1,19 @@
{
"compilerOptions": {
"target": "esnext",
"target": "es6",
"module": "commonjs",
"newLine": "lf",
"outDir": "./lib",
"rootDir": "./src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"sourceMap": true
"useUnknownInCatchVariables": false,
},
"exclude": ["node_modules", "**/*.test.ts"]
"exclude": [
"node_modules",
"**/*.test.ts",
"jest.config.ts"
]
}
+668 -13
View File
File diff suppressed because it is too large. Load diff