-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(third-party): add handling of Angular CLI schematics, and rework registry subset #169
Changes from 1 commit
e2f1eaf
15d5ea3
4ef4e09
a51921f
ba3a4d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,9 @@ export default function formatPkg(pkg) { | |
|
||
const owner = getOwner(repository, lastPublisher, author); // always favor the repository owner | ||
const badPackage = isBadPackage(owner); | ||
const keywords = getKeywords(cleaned); | ||
const registrySubsets = getRegistrySubsets(cleaned, pkg); | ||
const __keywords = getKeywords(cleaned); | ||
const keywords = [...__keywords, ...registrySubsets]; // concat with the subset for backward compat | ||
|
||
const dependencies = cleaned.dependencies || {}; | ||
const devDependencies = cleaned.devDependencies || {}; | ||
|
@@ -86,6 +88,7 @@ export default function formatPkg(pkg) { | |
homepage: getHomePage(cleaned.homepage, cleaned.repository), | ||
license, | ||
keywords, | ||
registrySubsets, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we only have an array of keywords for now and not actual metadata then let's just call it "computedKeywords". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically they are more like identifiers than keywords There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Subset is how we see one usecase for this feature today. If someone reads the registry it must be clear what those are, so I guess computedKeywords is what this data is: a list of keywords we compute |
||
created: Date.parse(cleaned.created), | ||
modified: Date.parse(cleaned.modified), | ||
lastPublisher, | ||
|
@@ -209,31 +212,41 @@ function getVersions(cleaned) { | |
return {}; | ||
} | ||
|
||
const forcedKeywords = { | ||
'babel-plugin': ({ name }) => | ||
name.startsWith('@babel/plugin') || name.startsWith('babel-plugin-'), | ||
'vue-cli-plugin': ({ name }) => | ||
/^(@vue\/|vue-|@[\w-]+\/vue-)cli-plugin-/.test(name), | ||
}; | ||
const registrySubsetRules = [ | ||
{ | ||
name: 'babel-plugin', | ||
matcher: ({ name }) => | ||
name.startsWith('@babel/plugin') || name.startsWith('babel-plugin-'), | ||
}, | ||
{ | ||
name: 'vue-cli-plugin', | ||
matcher: ({ name }) => /^(@vue\/|vue-|@[\w-]+\/vue-)cli-plugin-/.test(name), | ||
}, | ||
{ | ||
name: 'angular-cli-schematic', | ||
matcher: (_, { schematics = '' }) => schematics.length > 0, | ||
}, | ||
]; | ||
|
||
function getRegistrySubsets(cleaned, original) { | ||
const registrySubsets = registrySubsetRules.reduce( | ||
(acc, { name, matcher }) => | ||
matcher(cleaned, original) ? [...acc, name] : acc, | ||
[] | ||
); | ||
return registrySubsets; | ||
} | ||
|
||
function getKeywords(cleaned) { | ||
// Forced keywords | ||
const keywords = []; | ||
for (const keyword in forcedKeywords) { | ||
if (forcedKeywords[keyword](cleaned)) { | ||
keywords.push(keyword); | ||
} | ||
} | ||
|
||
if (cleaned.keywords) { | ||
if (Array.isArray(cleaned.keywords)) { | ||
return [...cleaned.keywords, ...keywords]; | ||
return [...cleaned.keywords]; | ||
} | ||
if (typeof cleaned.keywords === 'string') { | ||
return [cleaned.keywords, ...keywords]; | ||
return [cleaned.keywords]; | ||
} | ||
} | ||
return [...keywords]; | ||
return []; | ||
} | ||
|
||
function getGitHubRepoInfo({ repository, gitHead = 'master' }) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just
...getKeywords(cleaned)
to avoid the __ and temp variable