diff options
| author | Christoph Schlosser <2466365+cschlosser@users.noreply.github.com> | 2020-10-04 13:38:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-04 13:38:20 +0200 |
| commit | 175bd0d5bb123a99f7de91d6045a0a25f670dd65 (patch) | |
| tree | b9bdf29f7a9af9b9d1cfceb55d1ace265176bc9e | |
| parent | 6a541f4882e62bd37c37bb20962414d5e31d79a4 (diff) | |
| download | doxdocgen-1.0.0.tar.gz | |
Release 1.0.0 (#180)1.0.0
* Reenable: Add env-var to replace env var in template strings (#175)
* Release 1.0.0
* Add ls output to travis package step to see size of vsix
| -rw-r--r-- | .travis.yml | 7 | ||||
| -rw-r--r-- | CHANGELOG.md | 10 | ||||
| -rw-r--r-- | package-lock.json | 15 | ||||
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | src/Lang/Cpp/CppDocGen.ts | 36 | ||||
| -rw-r--r-- | src/extension.ts | 4 | ||||
| -rw-r--r-- | src/test/CppTests/Config.test.ts | 20 |
7 files changed, 82 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml index 7383c37..9639923 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,9 @@ jobs: os: osx - stage: release script: - - npm install vsce@1.31.0 - - vsce package + - npm install vsce + - vsce package --no-yarn + - ls -alh os: linux deploy: - provider: releases @@ -53,7 +54,7 @@ jobs: on: tags: true - provider: script - script: vsce publish -p $VSMARKETPLACE_ACCESS_TOKEN + script: vsce publish --no-yarn -p $VSMARKETPLACE_ACCESS_TOKEN skip_cleanup: true on: tags: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e807ba..3f2cbe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## [1.0.0] + +### Revert + +- Revert reverting Replace environment variables in templated strings. If no environment variable can be found the name of the variable will be inserted (#110) + +### Other + +- vsce packaging is forcing yarn even if no yarn config exists. Override this behavior now to use npm. + ## [0.8.2] ### Other diff --git a/package-lock.json b/package-lock.json index 0c51d3d..066c545 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "doxdocgen", - "version": "0.8.2", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -406,6 +406,14 @@ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, + "env-var": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/env-var/-/env-var-4.1.0.tgz", + "integrity": "sha512-nPHfStlNHmQsxCmLe2Bjx+MARZ2/03/JkNpnDNSCW2uE/F1a59zePBf9Opj7Gp2d6EXowvYTl9nlL1V7ycVaIQ==", + "requires": { + "is-url": "~1.2.2" + } + }, "es-abstract": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz", @@ -812,6 +820,11 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, + "is-url": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", + "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==" + }, "is-wsl": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", diff --git a/package.json b/package.json index 14a61ce..b57cabe 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "doxdocgen", "displayName": "Doxygen Documentation Generator", "description": "Let me generate Doxygen documentation from your source code for you.", - "version": "0.8.2", + "version": "1.0.0", "publisher": "cschlosser", "engines": { "vscode": "^1.37.0" @@ -253,6 +253,7 @@ "test": "npm run compile && node ./node_modules/vscode/bin/test" }, "dependencies": { + "env-var": "^4.1.0", "moment": "^2.20.1", "opn": "^5.2.0" }, diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 1e73804..2795ec6 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -1,10 +1,10 @@ +import * as env from "env-var"; import * as moment from "moment"; -import { Position, Range, Selection, TextEditor, TextLine, WorkspaceEdit } from "vscode"; +import { Position, Range, Selection, TextEditor } from "vscode"; import { IDocGen } from "../../Common/IDocGen"; import { Config } from "../../Config"; import { CppArgument } from "./CppArgument"; import * as CppParser from "./CppParser"; -import { CppParseTree } from "./CppParseTree"; import { CppToken, CppTokenType } from "./CppToken"; export enum SpecialCase { @@ -144,9 +144,31 @@ export class CppDocGen implements IDocGen { return indentedString; } + protected getEnvVars(replace: string): string { + let replacement = replace; + const regex = /\$\{env\:([\w|\d|_]+)\}/m; + let match: RegExpExecArray; + + // tslint:disable-next-line:no-conditional-assignment + while ((match = regex.exec(replacement)) !== null) { + if (match.index === regex.lastIndex) { + regex.lastIndex++; + } + + const m = match[1]; + + const envVar: string = env.get(m, m).asString(); + + replacement = replacement.replace("${env:" + m + "}", envVar); + } + + return replacement; + } + protected getTemplatedString(replace: string, template: string, param: string): string { const replacedTemplate = template.replace(replace, param); - return this.getIndentedTemplate(replacedTemplate); + const replacedWithEnv = this.getEnvVars(replacedTemplate); + return this.getIndentedTemplate(replacedWithEnv); } protected getMultiTemplatedString(replace: string[], template: string, param: string[]): string { @@ -156,7 +178,7 @@ export class CppDocGen implements IDocGen { template = template.replace(replace[i], param[i]); } } - return template; + return this.getEnvVars(template); } protected getSmartText(): string { @@ -453,13 +475,15 @@ export class CppDocGen implements IDocGen { lines, this.cfg.typeTemplateReplace, this.cfg.Generic.returnTemplate, - returnParams + returnParams, ); } break; } case "custom": { - lines.push(...this.cfg.Generic.customTags); + this.cfg.Generic.customTags.forEach((elem) => { + lines.push(this.getEnvVars(elem)); + }); break; } default: { diff --git a/src/extension.ts b/src/extension.ts index ac80e03..e25e700 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,8 +5,8 @@ import * as vscode from "vscode"; import CodeParserController from "./CodeParserController"; enum Version { - CURRENT = "0.8.2", - PREVIOUS = "0.8.1", + CURRENT = "1.0.0", + PREVIOUS = "0.8.2", KEY = "doxdocgen_version", } diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts index 3915f11..d479d2d 100644 --- a/src/test/CppTests/Config.test.ts +++ b/src/test/CppTests/Config.test.ts @@ -227,4 +227,24 @@ suite("C++ - Configuration Tests", () => { assert.equal("/**\n * @note\n */", result); }); + test("Env variable", () => { + testSetup.cfg = new Config(); + testSetup.cfg.Generic.order = ["custom"]; + if (process.platform === "win32") { + testSetup.cfg.Generic.customTags = ["@author ${env:USERNAME}"]; + const res = testSetup.SetLine("void foo();").GetResult(); + // USERNAME env var is different for everybody + assert.notEqual("/**\n * @author USERNAME\n */", res); + } else { + testSetup.cfg.Generic.customTags = ["@author ${env:USER}"]; + const res = testSetup.SetLine("void foo();").GetResult(); + // USER env var is different for everybody + assert.notEqual("/**\n * @author USER\n */", res); + } + + testSetup.cfg.Generic.customTags = ["@author ${env:MY_VARIABLE}"]; + const result = testSetup.SetLine("void foo();").GetResult(); + assert.equal("/**\n * @author MY_VARIABLE\n */", result); + }); + }); |