mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 18:47:30 +00:00
Reorganize templates into dir structure matching 'dotnet new' templates
This commit is contained in:
@@ -11,24 +11,10 @@ import * as targz from 'tar.gz';
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', '.csproj', '.html', '.js', '.json', '.jsx', '.md', '.nuspec', '.ts', '.tsx'];
|
||||
|
||||
const dotNetPackages = {
|
||||
builtIn: 'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
||||
extra: 'Microsoft.AspNetCore.SpaTemplates'
|
||||
};
|
||||
|
||||
interface TemplateConfig {
|
||||
dir: string;
|
||||
dotNetPackageId: string;
|
||||
}
|
||||
|
||||
const templates: { [key: string]: TemplateConfig } = {
|
||||
'angular': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/AngularSpa/' },
|
||||
'aurelia': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/AureliaSpa/' },
|
||||
'knockout': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/KnockoutSpa/' },
|
||||
'react-redux': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactReduxSpa/' },
|
||||
'react': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactSpa/' },
|
||||
'vue': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/VueSpa/' }
|
||||
};
|
||||
const dotNetPackages = [
|
||||
'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
||||
'Microsoft.AspNetCore.SpaTemplates'
|
||||
];
|
||||
|
||||
function isTextFile(filename: string): boolean {
|
||||
return textFileExtensions.indexOf(path.extname(filename).toLowerCase()) >= 0
|
||||
@@ -117,18 +103,18 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
||||
{ from: /\btemplate_gitignore$/, to: '.gitignore' }
|
||||
];
|
||||
const contentReplacements = [];
|
||||
_.forEach(templates, (templateConfig, templateName) => {
|
||||
// Only include templates matching the output package ID
|
||||
if (templateConfig.dotNetPackageId !== packageId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageSourceRootDir = path.join('../', packageId);
|
||||
const templatesInPackage = fs.readdirSync(path.join(packageSourceRootDir, 'Content'));
|
||||
|
||||
_.forEach(templatesInPackage, templateName => {
|
||||
const templateSourceDir = path.join(packageSourceRootDir, 'Content', templateName);
|
||||
const templateOutputDir = path.join(outputRoot, 'Content', templateName);
|
||||
writeTemplate(templateConfig.dir, templateOutputDir, contentReplacements, filenameReplacements);
|
||||
writeTemplate(templateSourceDir, templateOutputDir, contentReplacements, filenameReplacements);
|
||||
});
|
||||
|
||||
// Create the .nuspec file
|
||||
const nuspecContentTemplate = fs.readFileSync(`./src/dotnetnew/${ packageId }.nuspec`);
|
||||
const nuspecContentTemplate = fs.readFileSync(path.join(packageSourceRootDir, `${ packageId }.nuspec`));
|
||||
writeFileEnsuringDirExists(outputRoot,
|
||||
`${ packageId }.nuspec`,
|
||||
applyContentReplacements(nuspecContentTemplate, [
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Microsoft.AspNetCore.SpaTemplates</id>
|
||||
<version>1.0.{buildnumber}</version>
|
||||
<description>Single Page Application templates for ASP.NET Core</description>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
<projectUrl>https://github.com/aspnet/javascriptservices</projectUrl>
|
||||
<licenseUrl>https://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</licenseUrl>
|
||||
<copyright>Copyright © Microsoft Corporation</copyright>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<packageTypes>
|
||||
<packageType name="Template" />
|
||||
</packageTypes>
|
||||
</metadata>
|
||||
</package>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Microsoft.DotNet.Web.Spa.ProjectTemplates</id>
|
||||
<version>1.0.{buildnumber}</version>
|
||||
<description>Single Page Application templates for ASP.NET Core</description>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
<projectUrl>https://github.com/aspnet/javascriptservices</projectUrl>
|
||||
<licenseUrl>https://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</licenseUrl>
|
||||
<copyright>Copyright © Microsoft Corporation</copyright>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<packageTypes>
|
||||
<packageType name="Template" />
|
||||
</packageTypes>
|
||||
</metadata>
|
||||
</package>
|
||||
Reference in New Issue
Block a user