From 661e668ca2c695d1020115fff4b52d647c407def Mon Sep 17 00:00:00 2001 From: Mark Hillebrand Date: Wed, 19 Dec 2018 10:30:43 +0100 Subject: [PATCH] .editorconfig: added --- .editorconfig | 23 +++++++++ .gitattributes | 1 + BuildTestConfig.cmd | 28 +++++------ RunTests.cmd | 10 ++-- ci/version.js | 120 ++++++++++++++++++++++---------------------- jsdoc-conf.json | 64 +++++++++++------------ tsconfig.json | 16 +++--- tslint.json | 2 +- 8 files changed, 144 insertions(+), 120 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..61c12226 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*.{js,ts}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +charset = utf-8 +insert_final_newline = true + +[*.{cmd,json,md,txt,yml}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +charset = utf-8 +insert_final_newline = true + +[*.sh] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +charset = utf-8 +insert_final_newline = true +end_of_line = lf diff --git a/.gitattributes b/.gitattributes index c8986de0..99876862 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +.editorconfig text .gitattributes text .gitignore text .npmignore text diff --git a/BuildTestConfig.cmd b/BuildTestConfig.cmd index db6541ef..ac70fc96 100644 --- a/BuildTestConfig.cmd +++ b/BuildTestConfig.cmd @@ -10,32 +10,32 @@ if "%~1" equ "-h" goto :Usage set TEST_SETTING_FILE_DIR=%~dp0\secrets if NOT EXIST "%TEST_SETTING_FILE_DIR%" ( - md "%TEST_SETTING_FILE_DIR%" || ( - echo Error creating directory %TEST_SETTING_FILE_DIR% - exit /b 1 - ) + md "%TEST_SETTING_FILE_DIR%" || ( + echo Error creating directory %TEST_SETTING_FILE_DIR% + exit /b 1 + ) ) - + set TEST_SETTING_FILE_NAME=%TEST_SETTING_FILE_DIR%\TestConfiguration.ts if EXIST "%TEST_SETTING_FILE_NAME%" ( - echo Clearing values from settings file. - echo. > "%TEST_SETTING_FILE_NAME%" || ( - echo Error creating file %TEST_SETTING_FILE_NAME% - exit /b 1 - ) + echo Clearing values from settings file. + echo. > "%TEST_SETTING_FILE_NAME%" || ( + echo Error creating file %TEST_SETTING_FILE_NAME% + exit /b 1 + ) ) @echo import { Settings } from "../tests/Settings" > "%TEST_SETTING_FILE_NAME%" :NextArg if "%~1" == "" ( - goto :eof + goto :eof ) for /f "tokens=1,2 delims=:" %%I in ("%~1") do ( - echo Setting Settings.%%I = "%%J" - echo Settings.%%I = "%%J"; >> "%TEST_SETTING_FILE_NAME%" + echo Setting Settings.%%I = "%%J" + echo Settings.%%I = "%%J"; >> "%TEST_SETTING_FILE_NAME%" ) shift @@ -46,7 +46,7 @@ exit /b 0 :Usage @echo off echo. -echo Usage: %~n0 ^:^ +echo Usage: %~n0 ^:^ echo. echo Writes any ^:^ pair to the test settings file for JavaScript bindings tests. echo. diff --git a/RunTests.cmd b/RunTests.cmd index 5cb1d4ac..0000eb72 100644 --- a/RunTests.cmd +++ b/RunTests.cmd @@ -14,10 +14,10 @@ set TEST_SETTING_FILE_EXISTED=0 if EXIST "%TEST_SETTING_FILE_NAME%" set TEST_SETTING_FILE_EXISTED=1 if "%~1" NEQ "" ( - call "%~dp0BuildTestConfig.cmd" %* || ( - echo Error creating test config. - exit /b 1 - ) + call "%~dp0BuildTestConfig.cmd" %* || ( + echo Error creating test config. + exit /b 1 + ) ) else if %TEST_SETTING_FILE_EXISTED% EQU 0 ( echo Warning: No test config and no parameters specified. This will probably fail. 1>&2 ) @@ -28,7 +28,7 @@ call npm run test set NPM_ERROR=%ERRORLEVEL% if %TEST_SETTING_FILE_EXISTED% EQU 0 ( - del "%TEST_SETTING_FILE_NAME%" + del "%TEST_SETTING_FILE_NAME%" ) popd diff --git a/ci/version.js b/ci/version.js index 3ab6c56c..3d17c388 100644 --- a/ci/version.js +++ b/ci/version.js @@ -4,80 +4,80 @@ // (function () { - 'use strict'; - var semver = require("semver"); - var exec = require("child_process").exec; + 'use strict'; + var semver = require("semver"); + var exec = require("child_process").exec; - if (!process.env.npm_package_version) { - throw "npm_package_version not set; run this via 'npm run'" - } + if (!process.env.npm_package_version) { + throw "npm_package_version not set; run this via 'npm run'" + } - var givenVersion = process.env.npm_package_version; + var givenVersion = process.env.npm_package_version; - if (!semver.valid(givenVersion)) { - throw "Invalid version " + givenVersion; - } + if (!semver.valid(givenVersion)) { + throw "Invalid version " + givenVersion; + } - var baseVersion = semver.major(givenVersion) + "." + semver.minor(givenVersion) + "." + semver.patch(givenVersion); - var prerelease = semver.prerelease(givenVersion) || [] + var baseVersion = semver.major(givenVersion) + "." + semver.minor(givenVersion) + "." + semver.patch(givenVersion); + var prerelease = semver.prerelease(givenVersion) || [] - var buildId = process.env.BUILD_BUILDID || "1" + var buildId = process.env.BUILD_BUILDID || "1" - var buildType = "dev" - var inAzureDevOps = false + var buildType = "dev" + var inAzureDevOps = false - if (process.env.SYSTEM_COLLECTIONID === "19422243-19b9-4d85-9ca6-bc961861d287" && - process.env.SYSTEM_DEFINITIONID === "7863") { + if (process.env.SYSTEM_COLLECTIONID === "19422243-19b9-4d85-9ca6-bc961861d287" && + process.env.SYSTEM_DEFINITIONID === "7863") { - inAzureDevOps = true + inAzureDevOps = true - if (process.env.BUILD_SOURCEBRANCH.match("^refs/heads/release/")) { - buildType = "prod" - } else if (process.env.BUILD_SOURCEBRANCH === "refs/heads/master" && - (process.env.BUILD_REASON === "Schedule" || - process.env.BUILD_REASON === "Manual")) { - buildType = "int" + if (process.env.BUILD_SOURCEBRANCH.match("^refs/heads/release/")) { + buildType = "prod" + } else if (process.env.BUILD_SOURCEBRANCH === "refs/heads/master" && + (process.env.BUILD_REASON === "Schedule" || + process.env.BUILD_REASON === "Manual")) { + buildType = "int" + } } - } - // Check our version constraints - if (buildType === "prod") { - // Full version give in package.json - if (prerelease.length != 0 && - (prerelease.length != 2 || - !prerelease[0].match("^(?:alpha|beta|rc)$") || - prerelease[1] < 1)) { - throw "For prod build types, version must have no pre-release tag, or alpha / beta / rc with a positive number." + // Check our version constraints + if (buildType === "prod") { + // Full version give in package.json + if (prerelease.length != 0 && + (prerelease.length != 2 || + !prerelease[0].match("^(?:alpha|beta|rc)$") || + prerelease[1] < 1)) { + throw "For prod build types, version must have no pre-release tag, or alpha / beta / rc with a positive number." + } + } else if (prerelease.length != 3 || + (prerelease[0] !== "alpha" || prerelease[1] !== 0 || prerelease[2] !== 1)) { + throw "For non-prod build types, checked-in version must end in -alpha.0.1" } - } else if (prerelease.length != 3 || - (prerelease[0] !== "alpha" || prerelease[1] !== 0 || prerelease[2] !== 1)) { - throw "For non-prod build types, checked-in version must end in -alpha.0.1" - } - var versionToUse + var versionToUse - if (buildType === "dev") { - versionToUse = baseVersion + "-alpha.0." + buildId - } else if (buildType === "int") { - versionToUse = baseVersion + "-beta.0." + buildId - } else if (buildType === "prod") { - versionToUse = givenVersion - } else { - throw "Internal error. Unexpected build type: " + buildType - } + if (buildType === "dev") { + versionToUse = baseVersion + "-alpha.0." + buildId + } else if (buildType === "int") { + versionToUse = baseVersion + "-beta.0." + buildId + } else if (buildType === "prod") { + versionToUse = givenVersion + } else { + throw "Internal error. Unexpected build type: " + buildType + } - if (inAzureDevOps) { - console.log("##vso[task.setvariable variable=SPEECHSDK_SEMVER2NOMETA]" + versionToUse); - } + if (inAzureDevOps) { + console.log("##vso[task.setvariable variable=SPEECHSDK_SEMVER2NOMETA]" + versionToUse); + } - if (givenVersion !== versionToUse) { - console.log("Setting version to " + versionToUse); - exec("npm version --no-git-tag-version " + versionToUse, { cwd: __dirname + "/.." }, - function (error) { - if (error) { - throw error; - } - } - ); - } + if (givenVersion !== versionToUse) { + console.log("Setting version to " + versionToUse); + exec("npm version --no-git-tag-version " + versionToUse, { cwd: __dirname + "/.." }, + function (error) { + if (error) { + throw error; + } + } + ); + } }()); diff --git a/jsdoc-conf.json b/jsdoc-conf.json index 42857c84..cec47a5c 100644 --- a/jsdoc-conf.json +++ b/jsdoc-conf.json @@ -1,35 +1,35 @@ { - "templates": { - "applicationName": "Microsoft Cognitive Services Speech SDK", - "disqus": "", - "googleAnalytics": "", - "openGraph": { - "title": "", - "type": "website", - "image": "", - "site_name": "", - "url": "" - } - }, - "meta": { - "title": "Microsoft Cognitive Services Speech SDK", - "description": "Microsoft Cognitive Services Speech SDK", - "keyword": "" - }, - "linenums": true, - "source": { - "include": [ - "./distrib/src/sdk" - ], - "includePattern": ".+\\.js(doc)?$", - "excludePattern": "(^|\\/|\\\\)_" - }, - "opts": { - "encoding": "utf8", - "recurse": true, - "private": false, - "lenient": true, - "destination": "./outjs", - "template": "templates/default" + "templates": { + "applicationName": "Microsoft Cognitive Services Speech SDK", + "disqus": "", + "googleAnalytics": "", + "openGraph": { + "title": "", + "type": "website", + "image": "", + "site_name": "", + "url": "" } + }, + "meta": { + "title": "Microsoft Cognitive Services Speech SDK", + "description": "Microsoft Cognitive Services Speech SDK", + "keyword": "" + }, + "linenums": true, + "source": { + "include": [ + "./distrib/src/sdk" + ], + "includePattern": ".+\\.js(doc)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "opts": { + "encoding": "utf8", + "recurse": true, + "private": false, + "lenient": true, + "destination": "./outjs", + "template": "templates/default" + } } diff --git a/tsconfig.json b/tsconfig.json index afc86a08..0e374817 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,11 @@ { "compilerOptions": { - "module": "commonjs", - "preserveConstEnums": true, - "sourceMap": true, - "target": "ES5", - "declaration": true, - "noImplicitAny": true, - "removeComments": false + "module": "commonjs", + "preserveConstEnums": true, + "sourceMap": true, + "target": "ES5", + "declaration": true, + "noImplicitAny": true, + "removeComments": false } -} \ No newline at end of file +} diff --git a/tslint.json b/tslint.json index e25906af..603a46cd 100644 --- a/tslint.json +++ b/tslint.json @@ -48,4 +48,4 @@ "secrets/*.ts" ] } -} \ No newline at end of file +}