我成功地将ng-packagr打包到了npm模块中
其工作正常。问题是,我似乎无法从根文件夹下的任何文件夹导入。那是
import com.liferay.portlet.journal.service.JournalArticleServiceUtil
import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil
import com.liferay.portlet.journal.model.JournalArticle
/**
* Delete past versions of articles with too many versions.
*/
/**
* Configuration.
*/
MAX_NUMBER_OF_VERSIONS = 100
DELETIONS_LIMIT=-1 // Only delete this number of versions, in total. Useful for tests. -1 = no limit
CHUNK=10 // In order to avoid memory load, everything is performed chunk by chunk, with this size.
sites = [20182, 21987]
/**
* Main.
*/
sites.each {
println "\n# Site " + it
deletePastVersionsOfArticlesWithTooManyVersions(it)
}
/**
* Delete past versions of articles with too many versions in the given site.
*/
def deletePastVersionsOfArticlesWithTooManyVersions(groupId) {
List<JournalArticle> articlesWithTooManyVersions = findArticlesWithTooManyVersions(groupId);
println "\nDeleting all past versions of " + articlesWithTooManyVersions.size() + " articles with too many versions"
articlesWithTooManyVersions.each {
deletePastVersions(groupId, it);
}
}
/**
* Returns the list of articles with to many versions in the given site, as a List<JournalArticle>
*/
def findArticlesWithTooManyVersions(groupId) {
List<JournalArticle> result = new ArrayList<JournalArticle>()
int count = JournalArticleLocalServiceUtil.getArticlesCount(groupId)
for (int start=0; start<count; start+=CHUNK) {
List<JournalArticle> versions = JournalArticleLocalServiceUtil.getArticles(groupId, start, start+CHUNK, null)
println "Page start:" + start + " size:" + versions.size()
// Process this page
versions.each { version ->
// Ignore documents that are in the recycle bin.
if (version.isInTrash()) {
return // Equivalent of continue for closures.
}
// We only need to process each Web Content once, but we get one JournalArticle per version.
// The trick here is to only process the JournalArticle if it is the latest version, as each Web Content has exactly one latest version.
if(JournalArticleLocalServiceUtil.isLatestVersion(groupId,version.getArticleId(), version.getVersion())){
println "Checking article " + version.getArticleId()
numberOfVersions = JournalArticleServiceUtil.getArticlesCountByArticleId(groupId, version.getArticleId());
if(numberOfVersions > MAX_NUMBER_OF_VERSIONS) {
println "JournalArticle " + version.getArticleId() + " has more than " + MAX_NUMBER_OF_VERSIONS + " versions."
result.add(version);
}
}
}
}
return result
}
/**
* Delete all past versions of the given article.
*/
def deletePastVersions(groupId, article) {
int count = JournalArticleLocalServiceUtil.getArticlesCount(groupId, article.getArticleId())
int numberOfNecessaryIterations = 1 + count/(CHUNK-1) // Plus 1 for the remainder. Minus 1 to account for the worse case where the latest version appears in all chunks.
println "Deleting " + (count - 1) + " versions of article " + article.getArticleId() + " in " + numberOfNecessaryIterations + " iterations."
for (int iteration=0; iteration<=numberOfNecessaryIterations; iteration++) {
// Paging is refreshed after deletion so we must always get the first elements.
List<JournalArticle> versions = JournalArticleServiceUtil.getArticlesByArticleId(groupId, article.getArticleId(), 0, CHUNK, null)
println "Iteration " + iteration + " Deleting " + versions.size() + " past versions of article " + article.getArticleId() // Actually one less if this chunk contains the latest version.
for(version in versions) {
if(JournalArticleLocalServiceUtil.isLatestVersion(groupId, version.getArticleId(), version.getVersion())) {
println "Skipping the latest version." // The latest version must NOT be deleted.
continue; // Proceed to the next version of this chunk.
}
// Delete this version
println "Deleting article " + version.getArticleId() + " version " + version.getVersion() + " " + new Date()
if (DELETIONS_LIMIT!=0) {
DELETIONS_LIMIT--
JournalArticleLocalServiceUtil.deleteArticle(groupId, version.getArticleId(), version.getVersion(), null,null)
println "Deletion performed"
}
if (DELETIONS_LIMIT==0){
return // Exit the method
}
}
}
}
引发错误
未找到模块:错误无法解析“我的组件/按钮”
但是
import { ButtonModule } from "my-components/button/";
工作正常。请我想念什么?任何帮助将不胜感激。