mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +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]
|
[OrchardSwitch]
|
||||||
public string Version { get; set; }
|
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")]
|
[CommandName("package create")]
|
||||||
public void CreatePackage(string moduleName) {
|
public void CreatePackage(string extensionName, string path) {
|
||||||
var packageData = _packageManager.Harvest(moduleName);
|
var packageData = _packageManager.Harvest(extensionName);
|
||||||
if (packageData == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// append "Orchard.[ExtensionType]" to prevent conflicts with other packages (e.g, TinyMce, jQuery, ...)
|
// 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 filename = string.Format("Orchard.{0}.{1}.{2}.nupkg", packageData.ExtensionType, packageData.ExtensionName, packageData.ExtensionVersion);
|
||||||
var packagePath = Path.Combine(GetSolutionFolder(), CreatePackagePath);
|
|
||||||
|
|
||||||
if(!Directory.Exists(packagePath)) {
|
if ( !Directory.Exists(path) ) {
|
||||||
Directory.CreateDirectory(packagePath);
|
Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// packages are created in a specific folder otherwise they are in /bin, which crashed the current shell
|
// 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) ) {
|
using ( var stream = File.Create(filename) ) {
|
||||||
packageData.PackageStream.CopyTo(stream);
|
packageData.PackageStream.CopyTo(stream);
|
||||||
|
@@ -143,12 +143,13 @@ namespace Orchard.Packaging.Services {
|
|||||||
context.SourceFolder = webSiteFolder;
|
context.SourceFolder = webSiteFolder;
|
||||||
if (moduleType == "Theme") {
|
if (moduleType == "Theme") {
|
||||||
context.SourcePath = "~/Themes/" + moduleName + "/";
|
context.SourcePath = "~/Themes/" + moduleName + "/";
|
||||||
|
context.TargetPath = "\\Content\\Themes\\" + moduleName + "\\";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.SourcePath = "~/Modules/" + moduleName + "/";
|
context.SourcePath = "~/Modules/" + moduleName + "/";
|
||||||
}
|
|
||||||
context.TargetPath = "\\Content\\Modules\\" + moduleName + "\\";
|
context.TargetPath = "\\Content\\Modules\\" + moduleName + "\\";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static bool LoadProject(CreateContext context, string relativePath) {
|
private static bool LoadProject(CreateContext context, string relativePath) {
|
||||||
string virtualPath = context.SourcePath + relativePath;
|
string virtualPath = context.SourcePath + relativePath;
|
||||||
|
@@ -25,9 +25,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
var logger = new NugetLogger(_notifier);
|
var logger = new NugetLogger(_notifier);
|
||||||
|
|
||||||
// instantiates the appropriate package repository
|
// instantiates the appropriate package repository
|
||||||
var packageRepository = Uri.IsWellFormedUriString(location, UriKind.Absolute)
|
var packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource("Default", location));
|
||||||
? new DataServicePackageRepository(new Uri(location))
|
|
||||||
: new LocalPackageRepository(location) as IPackageRepository;
|
|
||||||
|
|
||||||
// gets an IPackage instance from the repository
|
// gets an IPackage instance from the repository
|
||||||
var packageVersion = String.IsNullOrEmpty(version) ? null : new Version(version);
|
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 LocalPackageRepository(packagesPath), // source repository for the package to install
|
||||||
new DefaultPackagePathResolver(location),
|
new DefaultPackagePathResolver(location),
|
||||||
new FileBasedProjectSystem(projectPath) { Logger = logger }, // the location of the project (where to copy the content files)
|
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};
|
) {Logger = logger};
|
||||||
|
|
||||||
// add the package to the project
|
// add the package to the project
|
||||||
|
@@ -29,7 +29,8 @@ namespace Orchard.Packaging.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddSource(string feedTitle, string feedUrl) {
|
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) {
|
public void RemoveSource(int id) {
|
||||||
|
Reference in New Issue
Block a user