From 7c4a71b679453af716fdb4fb96425dca1e712188 Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Thu, 9 Dec 2021 13:44:42 +0100
Subject: [PATCH] feat!: remove node v12 and node v15 support (#12658)

BREAKING CHANGE: remove node v12 and v15 support
---
 .../github/__snapshots__/index.spec.ts.snap   |  8 +++++
 lib/platform/github/index.spec.ts             | 24 ++++++++++++++
 lib/util/cache/package/decorator.spec.ts      | 32 +++++++++++++++++++
 lib/util/cache/package/decorator.ts           |  1 +
 package.json                                  |  4 +--
 tsconfig.json                                 |  5 +--
 tsconfig.strict.json                          |  2 +-
 7 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap
index 339ec34173..d6715d11e3 100644
--- a/lib/platform/github/__snapshots__/index.spec.ts.snap
+++ b/lib/platform/github/__snapshots__/index.spec.ts.snap
@@ -7156,6 +7156,14 @@ Array [
 ]
 `;
 
+exports[`platform/github/index initPlatform() should support custom endpoint without version 1`] = `
+Object {
+  "endpoint": "https://ghe.renovatebot.com/",
+  "gitAuthor": "undefined <user@domain.com>",
+  "renovateUsername": "renovate-bot",
+}
+`;
+
 exports[`platform/github/index initPlatform() should support default endpoint no email access 1`] = `
 Object {
   "endpoint": "https://api.github.com/",
diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts
index 97fd3541e2..ebb9ef0581 100644
--- a/lib/platform/github/index.spec.ts
+++ b/lib/platform/github/index.spec.ts
@@ -132,6 +132,30 @@ describe('platform/github/index', () => {
       ).toMatchSnapshot();
       expect(httpMock.getTrace()).toMatchSnapshot();
     });
+
+    it('should support custom endpoint without version', async () => {
+      httpMock
+        .scope('https://ghe.renovatebot.com')
+        .head('/')
+        .reply(200)
+
+        .get('/user')
+        .reply(200, {
+          login: 'renovate-bot',
+        })
+        .get('/user/emails')
+        .reply(200, [
+          {
+            email: 'user@domain.com',
+          },
+        ]);
+      expect(
+        await github.initPlatform({
+          endpoint: 'https://ghe.renovatebot.com',
+          token: '123test',
+        })
+      ).toMatchSnapshot();
+    });
   });
 
   describe('getRepos', () => {
diff --git a/lib/util/cache/package/decorator.spec.ts b/lib/util/cache/package/decorator.spec.ts
index 8aa008b09c..69b024c5f4 100644
--- a/lib/util/cache/package/decorator.spec.ts
+++ b/lib/util/cache/package/decorator.spec.ts
@@ -33,6 +33,25 @@ describe('util/cache/package/decorator', () => {
     expect(spy).toHaveBeenCalledTimes(1);
   });
 
+  it('Do not cache', async () => {
+    class MyClass {
+      @cache({ namespace: 'namespace', key: 'key', cacheable: () => false })
+      public async getString(
+        cacheKey: string,
+        test: string | null
+      ): Promise<string | null> {
+        await spy();
+        return test;
+      }
+    }
+    const myClass = new MyClass();
+    expect(await myClass.getString('null', null)).toBeNull();
+    expect(await myClass.getString('null', null)).toBeNull();
+    expect(await myClass.getString('test', 'test')).toBe('test');
+    expect(await myClass.getString('test', 'test')).toBe('test');
+    expect(spy).toHaveBeenCalledTimes(4);
+  });
+
   it('Do cache null', async () => {
     class MyClass {
       @cache({ namespace: 'namespace', key: (cacheKey, test) => cacheKey })
@@ -88,4 +107,17 @@ describe('util/cache/package/decorator', () => {
     expect(await myClass.getNumber(getReleasesConfig)).toBeDefined();
     expect(spy).toHaveBeenCalledTimes(1);
   });
+
+  it('works', async () => {
+    class MyClass {
+      public async getNumber(): Promise<number> {
+        await spy();
+        return Math.random();
+      }
+    }
+    const decorator = cache({ namespace: 'namespace', key: 'key' });
+    const getNumber = decorator(MyClass.prototype, 'getNumber', undefined);
+
+    expect(await getNumber.value()).toBeNumber();
+  });
 });
diff --git a/lib/util/cache/package/decorator.ts b/lib/util/cache/package/decorator.ts
index a0d8e0d0ef..7094e725a5 100644
--- a/lib/util/cache/package/decorator.ts
+++ b/lib/util/cache/package/decorator.ts
@@ -34,6 +34,7 @@ function decorate<T>(fn: Handler<T>): Decorator<T> {
   const result: Decorator<T> = (
     target,
     key,
+    /* TODO: Can descriptor be undefined ? */
     descriptor = Object.getOwnPropertyDescriptor(target, key) ?? {
       enumerable: true,
       configurable: true,
diff --git a/package.json b/package.json
index 0866d7f354..90074825c2 100644
--- a/package.json
+++ b/package.json
@@ -118,12 +118,12 @@
   },
   "homepage": "https://renovatebot.com",
   "engines": {
-    "node": "^12.22.0 || >=14.15.0",
+    "node": "^14.15.0 || >=16.13.0",
     "yarn": "^1.17.0"
   },
   "engines-next": {
     "description": "Versions other than the below are deprecated and a warning will be logged",
-    "node": ">=14.15.0"
+    "node": "^14.15.0 || >=16.13.0"
   },
   "dependencies": {
     "@aws-sdk/client-ec2": "3.35.0",
diff --git a/tsconfig.json b/tsconfig.json
index 042da7b89c..81382ed8bd 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,7 +4,8 @@
     "noImplicitAny": false /* required for js files */,
     "strictNullChecks": false /* required for js files */,
     "outDir": "./dist",
-    "target": "es2018",
+    /* https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping */
+    "target": "es2020",
     "module": "commonjs",
     "sourceMap": true,
     "allowSyntheticDefaultImports": true,
@@ -14,7 +15,7 @@
     "noImplicitOverride": true,
     "experimentalDecorators": true,
     "useUnknownInCatchVariables": false /* we aren't prepared for enabling this by default since ts 4.4*/,
-    "lib": ["es2018"],
+    "lib": ["es2020"],
     "types": ["node", "jest", "jest-extended", "expect-more-jest"],
     "allowJs": true,
     "checkJs": true
diff --git a/tsconfig.strict.json b/tsconfig.strict.json
index d2bb5af542..004501067f 100644
--- a/tsconfig.strict.json
+++ b/tsconfig.strict.json
@@ -3,7 +3,7 @@
   "compilerOptions": {
     "strictNullChecks": true,
     "noImplicitAny": true,
-    "lib": ["es2019"]
+    "lib": ["es2020"]
   },
   "include": [
     "lib/config/app-strings.ts",
-- 
GitLab