From 025144daa6158db48e388caf92677ca1d07ba4a5 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 10 Nov 2010 16:09:20 -0800 Subject: [PATCH] Improving the packaging command Adding a parameter to define the location of the created file Corrected the destination folder for themes --HG-- branch : nuget --- .../Commands/PackagingCommands.cs | 17 ++++++++--------- .../Services/PackageBuilder.cs | 3 ++- .../Services/PackageExpander.cs | 6 ++---- .../Services/PackagingSourceManager.cs | 3 ++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Commands/PackagingCommands.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Commands/PackagingCommands.cs index 369e314be..ba55715c8 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Commands/PackagingCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Commands/PackagingCommands.cs @@ -21,26 +21,25 @@ namespace Orchard.Packaging.Commands { [OrchardSwitch] public string Version { get; set; } - - [CommandHelp("package create \r\n\t" + "Create a package for the module . The default filename is Orchard....nupkg.")] + + [CommandHelp("package create \r\n\t" + "Create a package for the module . The default filename is Orchard....nupkg.")] [CommandName("package create")] - public void CreatePackage(string moduleName) { - var packageData = _packageManager.Harvest(moduleName); + public void CreatePackage(string extensionName, string path) { + var packageData = _packageManager.Harvest(extensionName); if (packageData == null) { - Context.Output.WriteLine(T("Module \"{0}\" does not exist in this Orchard installation.", moduleName)); + Context.Output.WriteLine(T("Module or Theme \"{0}\" does not exist in this Orchard installation.", extensionName)); return; } // append "Orchard.[ExtensionType]" to prevent conflicts with other packages (e.g, TinyMce, jQuery, ...) var filename = string.Format("Orchard.{0}.{1}.{2}.nupkg", packageData.ExtensionType, packageData.ExtensionName, packageData.ExtensionVersion); - var packagePath = Path.Combine(GetSolutionFolder(), CreatePackagePath); - if(!Directory.Exists(packagePath)) { - Directory.CreateDirectory(packagePath); + if ( !Directory.Exists(path) ) { + Directory.CreateDirectory(path); } // packages are created in a specific folder otherwise they are in /bin, which crashed the current shell - filename = Path.Combine(packagePath, filename); + filename = Path.Combine(path, filename); using ( var stream = File.Create(filename) ) { packageData.PackageStream.CopyTo(stream); diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs index 1b1827180..669ee22b0 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs @@ -143,11 +143,12 @@ namespace Orchard.Packaging.Services { context.SourceFolder = webSiteFolder; if (moduleType == "Theme") { context.SourcePath = "~/Themes/" + moduleName + "/"; + context.TargetPath = "\\Content\\Themes\\" + moduleName + "\\"; } else { context.SourcePath = "~/Modules/" + moduleName + "/"; + context.TargetPath = "\\Content\\Modules\\" + moduleName + "\\"; } - context.TargetPath = "\\Content\\Modules\\" + moduleName + "\\"; } private static bool LoadProject(CreateContext context, string relativePath) { diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageExpander.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageExpander.cs index 229dd0563..28236d170 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageExpander.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageExpander.cs @@ -25,9 +25,7 @@ namespace Orchard.Packaging.Services { var logger = new NugetLogger(_notifier); // instantiates the appropriate package repository - var packageRepository = Uri.IsWellFormedUriString(location, UriKind.Absolute) - ? new DataServicePackageRepository(new Uri(location)) - : new LocalPackageRepository(location) as IPackageRepository; + var packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource("Default", location)); // gets an IPackage instance from the repository var packageVersion = String.IsNullOrEmpty(version) ? null : new Version(version); @@ -50,7 +48,7 @@ namespace Orchard.Packaging.Services { new LocalPackageRepository(packagesPath), // source repository for the package to install new DefaultPackagePathResolver(location), new FileBasedProjectSystem(projectPath) { Logger = logger }, // the location of the project (where to copy the content files) - new LocalPackageRepository(packagesPath) // the location of the uncompressed package, used to check if the package is already installed + new LocalPackageRepository(projectPath) ) {Logger = logger}; // add the package to the project diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs index 6af0b8633..7c42b937a 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackagingSourceManager.cs @@ -29,7 +29,8 @@ namespace Orchard.Packaging.Services { } public void AddSource(string feedTitle, string feedUrl) { - _packagingSourceRecordRepository.Create(new PackagingSource {FeedTitle = feedTitle, FeedUrl = feedUrl}); + var packagingSource = new PackagingSource {FeedTitle = feedTitle, FeedUrl = feedUrl}; + _packagingSourceRecordRepository.Create(packagingSource); } public void RemoveSource(int id) {