From 12aef7f190902c852f9461910c416216e88e1a20 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Sun, 26 Jul 2020 06:14:03 +0200 Subject: [PATCH] revert: "feat(project): add ability to specifically decide whether to use license headers or not" This reverts commit 7b0e80fbd6798ca6b5e993d0f6c76da982a53333. --- __tests__/project/indexTests.ts | 36 ------------------- defaultConfigs.ts | 1 - src/project/index.ts | 6 ---- src/project/templates/headers/Unlicense.tmpl | 0 src/project/templates/headers/WTFPL.tmpl | 0 src/project/templates/headers/csheader.tmpl | 23 ++++++------ .../templates/headers/stylecopheader.tmpl | 15 ++++---- src/utils/constants/prompt-names.d.ts | 1 - src/utils/generator-prompts.ts | 11 ------ 9 files changed, 16 insertions(+), 77 deletions(-) create mode 100644 src/project/templates/headers/Unlicense.tmpl create mode 100644 src/project/templates/headers/WTFPL.tmpl diff --git a/__tests__/project/indexTests.ts b/__tests__/project/indexTests.ts index ea9c3c38..ba511f7e 100644 --- a/__tests__/project/indexTests.ts +++ b/__tests__/project/indexTests.ts @@ -823,42 +823,6 @@ describe("generator:project", () => { { } } -` - ); - }); - }); - - describe("License Disabled", () => { - let workDir = ""; - beforeAll(() => { - return helpers - .run(generatorDir) - .withPrompts( - getPromptConfig({ - description: "Cake addin generation test", - enableWyam: false, - useLicenseHeaders: false, - }) - ) - .withOptions({ - "skip-dotnet": true, - "start-year": 2018, - }) - .inTmpDir((dir) => (workDir = dir)); - }); - - it("should not generate license headers when disabled", () => { - assert.equalsFileContent( - path.join(workDir, "src", "Cake.TestApp", "TestAppSettings.cs"), - `namespace Cake.TestApp -{ - using System; - using Cake.Core.Tooling; - - public sealed class TestAppSettings : ToolSettings - { - } -} ` ); }); diff --git a/defaultConfigs.ts b/defaultConfigs.ts index c84453a8..17f4a174 100644 --- a/defaultConfigs.ts +++ b/defaultConfigs.ts @@ -11,7 +11,6 @@ defaultConfig[PromptNames.Description] = "My Awesome Test Description"; defaultConfig[PromptNames.ShortDescription] = defaultConfig[PromptNames.Description]; defaultConfig[PromptNames.LicenseType] = "MIT"; -defaultConfig[PromptNames.UseLicenseHeaders] = true; defaultConfig[PromptNames.EmailAddress] = "test@app.com"; defaultConfig[PromptNames.SourceDir] = "./src"; defaultConfig[PromptNames.ScriptName] = "recipe.cake"; diff --git a/src/project/index.ts b/src/project/index.ts index c1b31cbe..c06fd030 100644 --- a/src/project/index.ts +++ b/src/project/index.ts @@ -39,7 +39,6 @@ export default class ProjectGenerator extends BaseGenerator { PromptNames.RepositoryOwner, PromptNames.Description, PromptNames.LicenseType, - PromptNames.UseLicenseHeaders, PromptNames.EnableWyam, PromptNames.UnitTestLibrary, PromptNames.UseTabs, @@ -63,11 +62,6 @@ export default class ProjectGenerator extends BaseGenerator { * the user specified directory. */ public writing() { - const licenseType = this.getValue(PromptNames.LicenseType); - if (licenseType === "Unlicense" || licenseType === "WTFPL") { - this.setValue(PromptNames.UseLicenseHeaders, false); - } - const sourceDir = this.getValue(PromptNames.SourceDir, "./src"); if (!sourceDir) { throw Error("Unable to get the current source directory to use"); diff --git a/src/project/templates/headers/Unlicense.tmpl b/src/project/templates/headers/Unlicense.tmpl new file mode 100644 index 00000000..e69de29b diff --git a/src/project/templates/headers/WTFPL.tmpl b/src/project/templates/headers/WTFPL.tmpl new file mode 100644 index 00000000..e69de29b diff --git a/src/project/templates/headers/csheader.tmpl b/src/project/templates/headers/csheader.tmpl index 427577a3..1861f094 100644 --- a/src/project/templates/headers/csheader.tmpl +++ b/src/project/templates/headers/csheader.tmpl @@ -1,18 +1,15 @@ <% - let text = ""; - if (useLicenseHeaders) { - text = include(licenseType + ".tmpl").split('\n').map(s => { - if (!s || s.trim() == "") { - return " *"; - } - else { - return " * " + s; - } - }).join('\n').replace(/[\* \n\r]*$/, ''); - - if (text && text !== " *") { - text = "/*\n" + text + "\n */\n\n"; + var text = include(licenseType + ".tmpl").split('\n').map(s => { + if (!s || s.trim() == "") { + return " *"; + } + else { + return " * " + s; } + }).join('\n').replace(/[\* \n\r]*$/, ''); + + if (text && text !== " *") { + text = "/*\n" + text + "\n */\n\n"; } -%> <%- text -%> diff --git a/src/project/templates/headers/stylecopheader.tmpl b/src/project/templates/headers/stylecopheader.tmpl index 46ac2af8..1d89094e 100644 --- a/src/project/templates/headers/stylecopheader.tmpl +++ b/src/project/templates/headers/stylecopheader.tmpl @@ -1,14 +1,11 @@ <% - let text = ""; - if (useLicenseHeaders) { - text = include(licenseType + ".tmpl", { startYear: "{year}", author: "{companyName}" }).trimEnd(); - var replacements = '\t'; + var text = include(licenseType + ".tmpl", { startYear: "{year}", author: "{companyName}" }).trimEnd(); + var replacements = '\t'; - if (!useTabs) { - replacements = ''; - for (let i = 0; i < indentSize; i++) { - replacements = replacements + ' '; - } + if (!useTabs) { + replacements = ''; + for (let i = 0; i < indentSize; i++) { + replacements = replacements + ' '; } } %> diff --git a/src/utils/constants/prompt-names.d.ts b/src/utils/constants/prompt-names.d.ts index 54a4ce2c..7beda19d 100644 --- a/src/utils/constants/prompt-names.d.ts +++ b/src/utils/constants/prompt-names.d.ts @@ -36,6 +36,5 @@ export const enum PromptNames { ShortDescription = "shortDescription", SourceDir = "sourceDir", UnitTestLibrary = "unitTestLibrary", - UseLicenseHeaders = "useLicenseHeaders", UseTabs = "useTabs", } diff --git a/src/utils/generator-prompts.ts b/src/utils/generator-prompts.ts index 63621b3d..b892c6fc 100644 --- a/src/utils/generator-prompts.ts +++ b/src/utils/generator-prompts.ts @@ -161,17 +161,6 @@ export abstract class GeneratorPrompts { name: PromptNames.LicenseType, validate: new NotEmptyValidator("license").validate, }, - { - default: true, - description: - "Wether to generate source files with a license header or not.", - inputType: InputType.Confirm, - isCommon: false, - message: "Do you want to use license header for source files? ", - name: PromptNames.UseLicenseHeaders, - when: (answers) => - answers.licenseType !== "Unlicense" && answers.licenseType !== "WTFPL", - }, { inputType: InputType.Text, isCommon: false,