Skip to content

Commit

Permalink
revert: "feat(project): add ability to specifically decide whether to…
Browse files Browse the repository at this point in the history
… use license headers or not"

This reverts commit 7b0e80f.
  • Loading branch information
AdmiringWorm committed Jul 26, 2020
1 parent f4949de commit 12aef7f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 77 deletions.
36 changes: 0 additions & 36 deletions __tests__/project/indexTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
}
`
);
});
Expand Down
1 change: 0 additions & 1 deletion defaultConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 0 additions & 6 deletions src/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class ProjectGenerator extends BaseGenerator {
PromptNames.RepositoryOwner,
PromptNames.Description,
PromptNames.LicenseType,
PromptNames.UseLicenseHeaders,
PromptNames.EnableWyam,
PromptNames.UnitTestLibrary,
PromptNames.UseTabs,
Expand All @@ -63,11 +62,6 @@ export default class ProjectGenerator extends BaseGenerator {
* the user specified directory.
*/
public writing() {
const licenseType = this.getValue<string>(PromptNames.LicenseType);
if (licenseType === "Unlicense" || licenseType === "WTFPL") {
this.setValue(PromptNames.UseLicenseHeaders, false);
}

const sourceDir = this.getValue<string>(PromptNames.SourceDir, "./src");
if (!sourceDir) {
throw Error("Unable to get the current source directory to use");
Expand Down
Empty file.
Empty file.
23 changes: 10 additions & 13 deletions src/project/templates/headers/csheader.tmpl
Original file line number Diff line number Diff line change
@@ -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 -%>
15 changes: 6 additions & 9 deletions src/project/templates/headers/stylecopheader.tmpl
Original file line number Diff line number Diff line change
@@ -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 + ' ';
}
}
%>
Expand Down
1 change: 0 additions & 1 deletion src/utils/constants/prompt-names.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ export const enum PromptNames {
ShortDescription = "shortDescription",
SourceDir = "sourceDir",
UnitTestLibrary = "unitTestLibrary",
UseLicenseHeaders = "useLicenseHeaders",
UseTabs = "useTabs",
}
11 changes: 0 additions & 11 deletions src/utils/generator-prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 12aef7f

Please sign in to comment.