Skip to content

Commit

Permalink
fix: recognize more Unity internal packages
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Dec 12, 2020
1 parent 2d48bbf commit 377de56
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 59 deletions.
2 changes: 1 addition & 1 deletion lib/cmd-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const _add = async function({ pkg, testables, force }) {
});
// add depsValid to pkgsInScope.
depsValid
.filter(x => !x.upstream && !x.module)
.filter(x => !x.upstream && !x.internal)
.map(x => x.name)
.forEach(name => pkgsInScope.push(name));
// print suggestion for depsInvalid
Expand Down
27 changes: 19 additions & 8 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const fetchPackageInfo = async function(name, registry) {
version,
upstream, // whether belongs to upstream registry
self, // whether is the source package
module, // whether is an unity module
internal, // whether is an internal package
reason // invalid reason of "version404", "package404"
}, ...
]
Expand All @@ -214,14 +214,12 @@ const fetchPackageDependencies = async function({ name, version, deep }) {
// create valid depedenency structure
const depObj = {
...entry,
module:
/com.unity.modules/i.test(entry.name) ||
entry.name == "com.unity.ugui",
internal: isInternalPackage(entry.name),
upstream: false,
self: entry.name == name,
reason: null
};
if (!depObj.module) {
if (!depObj.internal) {
// try fetching package info from cache
let { pkgInfo, upstream } = _.get(cachedPacakgeInfoDict, entry.name, {
pkgInfo: null,
Expand Down Expand Up @@ -287,9 +285,9 @@ const fetchPackageDependencies = async function({ name, version, deep }) {
depsValid.push(depObj);
log.verbose(
"dependency",
`${entry.name}@${entry.version} ${depObj.module ? "[module] " : ""}${
depObj.upstream ? "[upstream]" : ""
}`
`${entry.name}@${entry.version} ${
depObj.internal ? "[internal] " : ""
}${depObj.upstream ? "[upstream]" : ""}`
);
}
}
Expand Down Expand Up @@ -453,6 +451,18 @@ const parseEditorVersion = function(version) {
return result;
};

// Detect if the given package name is an internal package
const isInternalPackage = function(name) {
const internals = [
"com.unity.ugui",
"com.unity.2d.sprite",
"com.unity.2d.tilemap",
"com.unity.package-manager-ui",
"com.unity.ugui"
];
return /com.unity.modules/i.test(name) || internals.includes(name);
};

module.exports = {
cleanCache,
compareEditorVersion,
Expand All @@ -463,6 +473,7 @@ module.exports = {
getLatestVersion,
getNpmFetchOptions,
getUpmConfigDir,
isInternalPackage,
loadManifest,
loadUpmConfig,
parseEnv,
Expand Down
171 changes: 122 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 377de56

Please sign in to comment.