Skip to content

Commit

Permalink
Merge pull request #181 from VAlmea/spa-template-react
Browse files Browse the repository at this point in the history
Spa template react
  • Loading branch information
WillStrohl authored Feb 7, 2023
2 parents ce87d89 + 109ca4b commit eca1e51
Show file tree
Hide file tree
Showing 27 changed files with 1,431 additions and 31 deletions.
70 changes: 63 additions & 7 deletions generators/spa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ module.exports = class extends DnnGeneratorBase {
template
);

this.fs.copyTpl(
this.templatePath('common/Data/**'),
this.destinationPath(moduleName + '/Data/'),
template
);

this.fs.copyTpl(
this.templatePath('common/ViewModels/**'),
this.destinationPath(moduleName + '/ViewModels/'),
template
);

this.fs.copyTpl(
this.templatePath('common/Providers/**'),
this.destinationPath(moduleName + '/Providers/'),
template
);

// Do all templated copies
this.fs.copyTpl(
this.templatePath('../../common/src/**'),
Expand All @@ -205,6 +223,12 @@ module.exports = class extends DnnGeneratorBase {
this.destinationPath(moduleName + '/RouteConfig.cs'),
template
);

this.fs.copyTpl(
this.templatePath('common/Constants.cs'),
this.destinationPath(moduleName + '/Constants.cs'),
template
);

this.fs.copyTpl(
this.templatePath('common/manifest.dnn'),
Expand All @@ -213,8 +237,38 @@ module.exports = class extends DnnGeneratorBase {
);

this.fs.copyTpl(
this.templatePath('../../common/csproj/_Project.csproj'),
this.templatePath('common/symbols.dnn'),
this.destinationPath(moduleName + '/' + moduleName + '_Symbols.dnn'),
template
);

this.fs.copyTpl(
this.templatePath('common/License.txt'),
this.destinationPath(moduleName + '/License.txt'),
template
);

this.fs.copyTpl(
this.templatePath('common/ReleaseNotes.txt'),
this.destinationPath(moduleName + '/ReleaseNotes.txt'),
template
);

this.fs.copyTpl(
this.templatePath(spaType + '/common/Module.csproj'),
this.destinationPath(moduleName + '/' + moduleName + '.csproj'),
template
);

this.fs.copyTpl(
this.templatePath(spaType + '/common/Module.build'),
this.destinationPath(moduleName + '/Module.build'),
template
);

this.fs.copyTpl(
this.templatePath('common/Data/ModuleContext.cs'),
this.destinationPath(moduleName + '/Data/' + moduleName + 'Context.cs'),
template
);

Expand Down Expand Up @@ -258,7 +312,7 @@ module.exports = class extends DnnGeneratorBase {
'html-webpack-plugin': '^3.2.0',
// eslint-disable-next-line prettier/prettier
'marked': '^0.5.2',
'node-sass': '^4.11.0',
'node-sass': '^8.0.0',
'sass-loader': '^7.1.0',
'style-loader': '^0.23.1',
// eslint-disable-next-line prettier/prettier
Expand All @@ -268,10 +322,13 @@ module.exports = class extends DnnGeneratorBase {
'webpack-node-externals': '^1.7.2'
},
dependencies: {
'prop-types': '^15.6.2',
// eslint-disable-next-line prettier/prettier
'react': '^16.6.3',
'react-dom': '^16.6.3'
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
};

Expand All @@ -290,7 +347,6 @@ module.exports = class extends DnnGeneratorBase {
'eslint': '^5.8.0',
'eslint-loader': '^2.1.1',
'eslint-plugin-react': '^7.11.1',
'react-hot-loader': '^4.3.12'
};
} else {
this._writeTsConfig();
Expand Down
53 changes: 53 additions & 0 deletions generators/spa/templates/ReactJS/common/Module.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ModulePath><%= moduleName %></ModulePath>
<DNNFileName><%= moduleName %></DNNFileName>
<PackageName><%= fullNamespace %></PackageName>
<Extension>zip</Extension>
<BuildScriptsPath>$(MSBuildProjectDirectory)\..\..\Build</BuildScriptsPath>
<WebsitePath>$(MSBuildProjectDirectory)\..\..\Website</WebsitePath>
<WebsiteInstallPath>$(WebsitePath)\Install\Module</WebsiteInstallPath>
<FullModulePath>$(WebsitePath)\DesktopModules\$(ModulePath)</FullModulePath>
</PropertyGroup>
<Import Project="$(BuildScriptsPath)\ModulePackage.Targets" />
<Target Name="AfterBuild" DependsOnTargets="CopyBin;GetFiles;DebugProject;PackageModule">
</Target>
<Target Name="GetFiles">
<ItemGroup>
<Manifest Include="*.dnn;*.dnn5;*.dnn6" />
<TextFiles Include="*.txt" Exclude="releasenotes.txt;license.txt" />
<ResourceFiles Include="App_LocalResources/*.resx" />
<SourceFiles Include="dist/**" Exclude="providers/**;bin/**" />
<DataProvider Include="dist/Providers/DataProviders/SqlDataProvider/*.SqlDataProvider" />
<Resources Include="@(Manifest);@(TextFiles);@(ResourceFiles);@(DataProvider);@(SourceFiles)" />
</ItemGroup>
</Target>
<ItemGroup>
<SymbolsInclude Include="$(DNNFileName)_Symbols.dnn" />
<SymbolsInclude Include="License.txt" />
<SymbolsInclude Include="ReleaseNotes.txt" />
</ItemGroup>
<Target Name="CopyBin">
<ItemGroup>
<BinSourceInclude Include="$(MSBuildProjectDirectory)\bin\*.dll" Exclude="$(MSBuildProjectDirectory)\bin\DotNetNuke*;$(MSBuildProjectDirectory)\bin\Telerik*;$(MSBuildProjectDirectory)\bin\System.*;$(MSBuildProjectDirectory)\bin\Microsoft.*;$(MSBuildProjectDirectory)\bin\Newtonsoft.Json.*" />
<BinSourceInclude Include="$(MSBuildProjectDirectory)\bin\*.pdb" Exclude="$(MSBuildProjectDirectory)\bin\DotNetNuke*;$(MSBuildProjectDirectory)\bin\Telerik*;$(MSBuildProjectDirectory)\bin\System.*;$(MSBuildProjectDirectory)\bin\Microsoft.*;$(MSBuildProjectDirectory)\bin\Newtonsoft.Json.*" />
</ItemGroup>
<Copy SourceFiles="@(BinSourceInclude)" DestinationFolder="$(WebsitePath)\bin" />
</Target>
<Target Name="DebugProject" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Copy SourceFiles="@(Manifest)" DestinationFolder="$(FullModulePath)" />
<Copy SourceFiles="@(TextFiles)" DestinationFolder="$(FullModulePath)" />
<Copy SourceFiles="@(SourceFiles)" DestinationFolder="$(FullModulePath)\dist\%(RecursiveDir)" />
<Copy SourceFiles="@(ResourceFiles)" DestinationFolder="$(FullModulePath)\App_LocalResources" />
<Copy SourceFiles="@(DataProvider)" DestinationFolder="$(FullModulePath)\Providers\DataProviders\SqlDataProvider" />
</Target>
<Target Name="BuildReactClientApp">
<Message Text="Performing React build." Importance="high"></Message>
<CreateItem Include="$(FullModulePath)\Scripts\client-app\**;">
<Output TaskParameter="Include" ItemName="deleteReactFiles" />
</CreateItem>
<Delete ContinueOnError="true" Files="@(deleteReactFiles)"></Delete>
<Exec Condition="$(Configuration) == 'Debug'" Command="npm run build-client" />
<Exec Condition="$(Configuration) == 'Release'" Command="npm run build-client" />
</Target>
</Project>
160 changes: 160 additions & 0 deletions generators/spa/templates/ReactJS/common/Module.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{<%= guid %>}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace><%= fullNamespace %></RootNamespace>
<AssemblyName><%= fullNamespace %></AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir>
<RestorePackages>true</RestorePackages>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>12.0</OldToolsVersion>
<Use64BitIISExpress />
<UseGlobalApplicationHostFile />
<UpgradeBackupLocation />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\<%= fullNamespace %>.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\<%= fullNamespace %>.xml</DocumentationFile>
</PropertyGroup>
<Import Project="..\..\Build\SolutionReferences.targets" />
<ItemGroup>
<PackageReference Include="DotNetNuke.Core" Version="9.3.2" />
<PackageReference Include="DotNetNuke.Instrumentation" Version="9.3.2" />
<PackageReference Include="DotNetNuke.Web" Version="9.3.2" />
<PackageReference Include="DotNetNuke.Web.Client" Version="9.3.2" />
<PackageReference Include="DotNetNuke.Web.Deprecated" Version="9.3.2" />
<PackageReference Include="DotNetNuke.WebApi" Version="9.3.2" />
<PackageReference Include="EntityFramework" Version="6.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="App_LocalResources\Settings.resx" />
<Content Include="App_LocalResources\View.resx">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Providers\DataProviders\SqlDataProvider\00.00.01.SqlDataProvider" />
<Content Include="Providers\DataProviders\SqlDataProvider\Uninstall.SqlDataProvider" />
</ItemGroup>
<ItemGroup>
<Content Include="<%= moduleName %>.dnn" />
<Content Include="Module.build">
<SubType>Designer</SubType>
</Content>
<Content Include="<%= moduleName %>_Symbols.dnn">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<!-- <Compile Include="Components\DataProviderHelper.cs" />
<Compile Include="Components\FeatureController.cs" /> -->
<Content Include="src\app.jsx" />
<Content Include="src\components\Hello.jsx" />
<Content Include="src\Edit.html" />
<Content Include="src\edit.jsx" />
<Content Include="src\Resources\img\extension.png" />
<Content Include="src\Settings.html" />
<Content Include="src\settings.jsx" />
<Content Include="src\View.html" />
<Content Include="src\_templates\Markdown.html" />
<Content Include="src\License.md" />
<Content Include="src\ReleaseNotes.md" />
<Content Include="src\Resources\styles\module.scss" />
<Content Include="src\Resources\scripts\common.js" />
<Content Include="src\Resources\scripts\QuickSettings.js" />
<Content Include="src\Resources\scripts\useFetch.js" />
<!-- <Compile Include="Properties\AssemblyInfo.cs" /> -->
</ItemGroup>
<ItemGroup>
<Compile Include="Components\BaseClasses\ApiControllerBase.cs" />
<Compile Include="Controllers\ItemController.cs" />
<Compile Include="Controllers\SettingsController.cs" />
<Compile Include="RouteConfig.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Controllers\UserController.cs" />
<Compile Include="ViewModels\ItemViewModel.cs" />
<Compile Include="ViewModels\UserViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="Data\Item.cs" />
<Compile Include="Data\<%= moduleName %>Context.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\logo.png" />
<Content Include="License.txt" />
<Content Include="module.css" />
<Content Include="ReleaseNotes.txt" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v<%= msBuildVersion %>.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Import Project="Module.Build" />
<Target Name="BeforeBuild" DependsOnTargets="BuildReactClientApp">
</Target>
</Project>
10 changes: 4 additions & 6 deletions generators/spa/templates/ReactJS/jsx/src/app.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from "react";
import * as ReactDOM from "react-dom";
import Hello from "./components/Hello";
import Items from "./components/Items";

ReactDOM.render(
<div className="row">
<div className="col-xs-12">
<Hello name="I am a JSX react module" />
</div>
</div>,
<React.StrictMode>
<Items />
</React.StrictMode>,
document.getElementById("<%= namespace.toLowerCase() %><%= moduleName %>")
);
Loading

0 comments on commit eca1e51

Please sign in to comment.