From d8bdf0010365ab34b8093d6db604285f3f8631e1 Mon Sep 17 00:00:00 2001 From: Eric Jizba Date: Fri, 19 Nov 2021 10:43:54 -0800 Subject: [PATCH] Port "Clean up licensing" to v3.x --- .eslintrc.json | 12 +++++++++++- package-lock.json | 17 +++++++++++++++++ package.json | 1 + src/Context.ts | 3 +++ src/FunctionInfo.ts | 3 +++ src/FunctionLoader.ts | 3 +++ src/GrpcService.ts | 3 +++ src/Worker.ts | 3 +++ src/WorkerChannel.ts | 3 +++ src/converters/BindingConverters.ts | 3 +++ src/converters/RpcConverters.ts | 3 +++ src/converters/RpcHttpConverters.ts | 3 +++ src/converters/index.ts | 3 +++ src/http/Request.ts | 3 ++- src/http/Response.ts | 5 +++-- src/nodejsWorker.ts | 3 +++ src/utils/InternalException.ts | 3 +++ src/utils/Logger.ts | 7 +++++-- test/BindingConvertersTests.ts | 3 +++ test/ContextTests.ts | 3 +++ test/FunctionInfoTests.ts | 3 +++ test/FunctionLoaderTests.ts | 3 +++ test/RpcConvertersTests.ts | 3 +++ test/RpcHttpConverters.ts | 3 +++ test/TestEventStream.ts | 3 +++ test/TypesTests.ts | 3 +++ test/WorkerChannelTests.ts | 3 +++ test/WorkerTests.ts | 3 +++ types/LICENSE | 21 +++++++++++++++++++++ types/index.d.ts | 3 +++ types/index.test.ts | 3 +++ 31 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 types/LICENSE diff --git a/.eslintrc.json b/.eslintrc.json index 326a551b..d4e1e164 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,8 @@ { "parser": "@typescript-eslint/parser", "plugins": [ - "@typescript-eslint" + "@typescript-eslint", + "header" ], "parserOptions": { "project": "tsconfig.json", @@ -14,6 +15,15 @@ "plugin:prettier/recommended" ], "rules": { + "header/header": [ + 2, + "line", + [ + " Copyright (c) .NET Foundation. All rights reserved.", + " Licensed under the MIT License." + ], + 2 + ], "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/explicit-module-boundary-types": "off", diff --git a/package-lock.json b/package-lock.json index 32683fe0..795af615 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "chalk": "^4.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.2", "jsdoc": "^3.6.3", @@ -1593,6 +1594,15 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true, + "peerDependencies": { + "eslint": ">=7.7.0" + } + }, "node_modules/eslint-plugin-prettier": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", @@ -5930,6 +5940,13 @@ "dev": true, "requires": {} }, + "eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true, + "requires": {} + }, "eslint-plugin-prettier": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", diff --git a/package.json b/package.json index 4ee53cf2..387447a3 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "eslint-config-prettier": "^8.3.0", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-prettier": "^4.0.0", "eslint": "^7.32.0", "husky": "^7.0.2", diff --git a/src/Context.ts b/src/Context.ts index bec7542d..da0db0e6 100644 --- a/src/Context.ts +++ b/src/Context.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { BindingDefinition, Context, diff --git a/src/FunctionInfo.ts b/src/FunctionInfo.ts index a8514dd9..91039314 100644 --- a/src/FunctionInfo.ts +++ b/src/FunctionInfo.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; import { toRpcHttp, toTypedData } from './converters'; diff --git a/src/FunctionLoader.ts b/src/FunctionLoader.ts index aefc6ab2..162c7989 100644 --- a/src/FunctionLoader.ts +++ b/src/FunctionLoader.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import * as url from 'url'; import { isFunction, isObject } from 'util'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; diff --git a/src/GrpcService.ts b/src/GrpcService.ts index 574acc7b..bac0e383 100644 --- a/src/GrpcService.ts +++ b/src/GrpcService.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import * as grpc from '@grpc/grpc-js'; import { ServiceClientConstructor } from '@grpc/grpc-js/build/src/make-client'; import * as grpcloader from '@grpc/proto-loader'; diff --git a/src/Worker.ts b/src/Worker.ts index 11234afc..006fc00a 100644 --- a/src/Worker.ts +++ b/src/Worker.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import * as parseArgs from 'minimist'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; import { FunctionLoader } from './FunctionLoader'; diff --git a/src/WorkerChannel.ts b/src/WorkerChannel.ts index d696b356..7af85acf 100644 --- a/src/WorkerChannel.ts +++ b/src/WorkerChannel.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { Context } from '@azure/functions'; import { format, isFunction } from 'util'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; diff --git a/src/converters/BindingConverters.ts b/src/converters/BindingConverters.ts index a072a4bb..d1cda035 100644 --- a/src/converters/BindingConverters.ts +++ b/src/converters/BindingConverters.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { BindingDefinition, ContextBindingData } from '@azure/functions'; import { AzureFunctionsRpcMessages as rpc } from '../../azure-functions-language-worker-protobuf/src/rpc'; import { FunctionInfo } from '../FunctionInfo'; diff --git a/src/converters/RpcConverters.ts b/src/converters/RpcConverters.ts index 6fe81eec..cec384d2 100644 --- a/src/converters/RpcConverters.ts +++ b/src/converters/RpcConverters.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { TraceContext } from '@azure/functions'; import { isLong } from 'long'; import { diff --git a/src/converters/RpcHttpConverters.ts b/src/converters/RpcHttpConverters.ts index 34b4e63e..9e805cf9 100644 --- a/src/converters/RpcHttpConverters.ts +++ b/src/converters/RpcHttpConverters.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { Cookie, HttpMethod } from '@azure/functions'; import { AzureFunctionsRpcMessages as rpc, diff --git a/src/converters/index.ts b/src/converters/index.ts index 8acfb808..93fc1318 100644 --- a/src/converters/index.ts +++ b/src/converters/index.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + export * from './BindingConverters'; export * from './RpcConverters'; export * from './RpcHttpConverters'; diff --git a/src/http/Request.ts b/src/http/Request.ts index dcfad39d..01341881 100644 --- a/src/http/Request.ts +++ b/src/http/Request.ts @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. +// Licensed under the MIT License. + import { HttpMethod, HttpRequest } from '@azure/functions'; export class RequestProperties implements HttpRequest { diff --git a/src/http/Response.ts b/src/http/Response.ts index f7685e9a..395117dc 100644 --- a/src/http/Response.ts +++ b/src/http/Response.ts @@ -1,7 +1,8 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { Cookie } from '@azure/functions'; -// Copyright (c) .NET Foundation. All rights thiserved. -// Licensed under the MIT License. See License.txt in the project root for license information. interface IResponse { statusCode?: string | number; headers: { diff --git a/src/nodejsWorker.ts b/src/nodejsWorker.ts index 5e1d39b9..c5299d2a 100644 --- a/src/nodejsWorker.ts +++ b/src/nodejsWorker.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + const logPrefix = 'LanguageWorkerConsoleLog'; const errorPrefix = logPrefix + '[error] '; const warnPrefix = logPrefix + '[warn] '; diff --git a/src/utils/InternalException.ts b/src/utils/InternalException.ts index 2a90fc45..49d9e0e1 100644 --- a/src/utils/InternalException.ts +++ b/src/utils/InternalException.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + export class InternalException extends Error { public isAzureFunctionsInternalException = true; } diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 9fdba91f..55f26e2e 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -1,6 +1,9 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + /** - * Use these methods only if you want to guarantee the messages reach the host despite potential performance impact. - Otherwise, please stick to utilizing the gRPC channel to propagate these messages with category: RpcLogCategory.System + * Use these methods only if you want to guarantee the messages reach the host despite potential performance impact. + * Otherwise, please stick to utilizing the gRPC channel to propagate these messages with category: RpcLogCategory.System **/ const logPrefix = 'LanguageWorkerConsoleLog'; diff --git a/test/BindingConvertersTests.ts b/test/BindingConvertersTests.ts index ac42711b..2af6bde5 100644 --- a/test/BindingConvertersTests.ts +++ b/test/BindingConvertersTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import { fromString } from 'long'; import 'mocha'; diff --git a/test/ContextTests.ts b/test/ContextTests.ts index 6400d777..503d1d6a 100644 --- a/test/ContextTests.ts +++ b/test/ContextTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { Context } from '@azure/functions'; import { expect } from 'chai'; import 'mocha'; diff --git a/test/FunctionInfoTests.ts b/test/FunctionInfoTests.ts index 031c4dcd..2b4af525 100644 --- a/test/FunctionInfoTests.ts +++ b/test/FunctionInfoTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import 'mocha'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; diff --git a/test/FunctionLoaderTests.ts b/test/FunctionLoaderTests.ts index 2f020d44..1f5c2586 100644 --- a/test/FunctionLoaderTests.ts +++ b/test/FunctionLoaderTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import 'mocha'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; import { FunctionLoader } from '../src/FunctionLoader'; diff --git a/test/RpcConvertersTests.ts b/test/RpcConvertersTests.ts index dfa36b35..e79ebfba 100644 --- a/test/RpcConvertersTests.ts +++ b/test/RpcConvertersTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import 'mocha'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; diff --git a/test/RpcHttpConverters.ts b/test/RpcHttpConverters.ts index 7d5ed4b1..d70a9bb9 100644 --- a/test/RpcHttpConverters.ts +++ b/test/RpcHttpConverters.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { Cookie } from '@azure/functions'; import { expect } from 'chai'; import 'mocha'; diff --git a/test/TestEventStream.ts b/test/TestEventStream.ts index ca78fdd0..6e9ebcfc 100644 --- a/test/TestEventStream.ts +++ b/test/TestEventStream.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { EventEmitter } from 'events'; import * as sinon from 'sinon'; import { AzureFunctionsRpcMessages as rpc } from '../azure-functions-language-worker-protobuf/src/rpc'; diff --git a/test/TypesTests.ts b/test/TypesTests.ts index a06577e9..7ff2cbeb 100644 --- a/test/TypesTests.ts +++ b/test/TypesTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import * as cp from 'child_process'; import 'mocha'; diff --git a/test/WorkerChannelTests.ts b/test/WorkerChannelTests.ts index de337302..21a137ca 100644 --- a/test/WorkerChannelTests.ts +++ b/test/WorkerChannelTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import 'mocha'; import * as sinon from 'sinon'; diff --git a/test/WorkerTests.ts b/test/WorkerTests.ts index 797f2775..a65cc721 100644 --- a/test/WorkerTests.ts +++ b/test/WorkerTests.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + import { expect } from 'chai'; import 'mocha'; import { startNodeWorker } from '../src/Worker'; diff --git a/types/LICENSE b/types/LICENSE new file mode 100644 index 00000000..a33fe1c5 --- /dev/null +++ b/types/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) .NET Foundation. All rights reserved. + + 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 diff --git a/types/index.d.ts b/types/index.d.ts index 6fc81f0d..f7592d5d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + declare module '@azure/functions' { /** * Interface for your Azure Function code. This function must be exported (via module.exports or exports) diff --git a/types/index.test.ts b/types/index.test.ts index ecfb35bd..81f9212c 100644 --- a/types/index.test.ts +++ b/types/index.test.ts @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. + // This file will be compiled by multiple versions of TypeScript as decribed in ./test/TypesTests.ts to verify there are no errors import { AzureFunction, Context, Cookie, HttpMethod, HttpRequest } from '@azure/functions';