mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Improving the packaging command
Adding a <path> parameter to define the location of the created file Corrected the destination folder for themes --HG-- branch : nuget
This commit is contained in:
@@ -22,25 +22,24 @@ namespace Orchard.Packaging.Commands {
|
||||
[OrchardSwitch]
|
||||
public string Version { get; set; }
|
||||
|
||||
[CommandHelp("package create <moduleName>\r\n\t" + "Create a package for the module <moduleName>. The default filename is Orchard.<extension>.<moduleName>.<moduleVersion>.nupkg.")]
|
||||
[CommandHelp("package create <extensionName> <path> \r\n\t" + "Create a package for the module <moduleName>. The default filename is Orchard.<extension>.<extensionName>.<moduleVersion>.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);
|
||||
|
@@ -143,12 +143,13 @@ 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 + "\\";
|
||||
}
|
||||
}
|
||||
|
||||
private static bool LoadProject(CreateContext context, string relativePath) {
|
||||
string virtualPath = context.SourcePath + relativePath;
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user