code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function _getUTF8Length(sText) {
var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
return replacedText.length + (replacedText.length != sText ? 3 : 0);
}
|
Get the type by string length
@private
@param {String} sText
@param {Number} nCorrectLevel
@return {Number} type
|
_getUTF8Length
|
javascript
|
bryanbraun/checkboxland
|
docs/demos/qr-code/qrcode.js
|
https://github.com/bryanbraun/checkboxland/blob/master/docs/demos/qr-code/qrcode.js
|
MIT
|
isValidPackageName = function(packageName) {
try {
return [validPackageName(packageName), null];
} catch (error) {
if (error instanceof ValidationError) return [false, error];
throw error;
}
}
|
Utils that shared both server and client.
|
isValidPackageName
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
isValidPackageName = function(packageName) {
try {
return [validPackageName(packageName), null];
} catch (error) {
if (error instanceof ValidationError) return [false, error];
throw error;
}
}
|
Utils that shared both server and client.
|
isValidPackageName
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
validPackageName = function(packageName) {
if (!packageName)
throw new ValidationError("package name should not be empty", "empty");
const maxLength = 214;
if (packageName.length > maxLength)
throw new ValidationError(
`package name length should be less or equal to ${maxLength}, but length is ${packageName.length}`,
"max-length-error"
);
const nameRe = /^[a-z0-9._-]+$/;
if (!nameRe.test(packageName))
throw new ValidationError(
"package name should contain only lowercase letters, digits, hyphens(-), underscores (_), and periods (.)",
"invalid-characters-error"
);
const items = packageName.split(".");
if (items.length < 3)
throw new ValidationError(
"package name should conform to reverse domain name notation with at least 3 components (tld.org-name.pkg-name)",
"invalid-scopes-error"
);
return true;
}
|
Utils that shared both server and client.
|
validPackageName
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
validPackageName = function(packageName) {
if (!packageName)
throw new ValidationError("package name should not be empty", "empty");
const maxLength = 214;
if (packageName.length > maxLength)
throw new ValidationError(
`package name length should be less or equal to ${maxLength}, but length is ${packageName.length}`,
"max-length-error"
);
const nameRe = /^[a-z0-9._-]+$/;
if (!nameRe.test(packageName))
throw new ValidationError(
"package name should contain only lowercase letters, digits, hyphens(-), underscores (_), and periods (.)",
"invalid-characters-error"
);
const items = packageName.split(".");
if (items.length < 3)
throw new ValidationError(
"package name should conform to reverse domain name notation with at least 3 components (tld.org-name.pkg-name)",
"invalid-scopes-error"
);
return true;
}
|
Utils that shared both server and client.
|
validPackageName
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
getCachedAvatarImageFilename = function(username, size) {
username = username.toLowerCase();
return `${username}-${size}x${size}.png`;
}
|
Get the cached avatar image filename
@param {string} username
@param {Number} size
|
getCachedAvatarImageFilename
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
getCachedAvatarImageFilename = function(username, size) {
username = username.toLowerCase();
return `${username}-${size}x${size}.png`;
}
|
Get the cached avatar image filename
@param {string} username
@param {Number} size
|
getCachedAvatarImageFilename
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
isPackageBlockedByScope = function(packageName, scope) {
if (scope.startsWith("^"))
return packageName.startsWith(scope.slice(1, scope.length));
else
return packageName == scope;
}
|
Return if the package name is blocked by the given block scope
@param {String} packageName
@param {String} scope
@returns {Boolean}
|
isPackageBlockedByScope
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
isPackageBlockedByScope = function(packageName, scope) {
if (scope.startsWith("^"))
return packageName.startsWith(scope.slice(1, scope.length));
else
return packageName == scope;
}
|
Return if the package name is blocked by the given block scope
@param {String} packageName
@param {String} scope
@returns {Boolean}
|
isPackageBlockedByScope
|
javascript
|
openupm/openupm
|
app/common/utils.js
|
https://github.com/openupm/openupm/blob/master/app/common/utils.js
|
BSD-3-Clause
|
aggregateExtraData = async function() {
logger.info("aggregateExtraData");
const packageNames = await loadPackageNames();
const aggData = {};
for (let packageName of packageNames) {
// Verify package
if (!packageExists(packageName)) {
logger.error({ pkg: packageName }, "package doesn't exist");
continue;
}
const data = {};
const stars = await PackageExtra.getStars(packageName);
data.stars = stars || 0;
const pstars = await PackageExtra.getParentStars(packageName);
data.pstars = pstars || undefined;
const unity = await PackageExtra.getUnityVersion(packageName);
data.unity = unity || "2018.1";
data.imageFilename =
(await PackageExtra.getCachedImageFilename(packageName)) || undefined;
const updatedTime = await PackageExtra.getUpdatedTime(packageName);
const pushedTime = await PackageExtra.getRepoPushedTime(packageName);
data.time = updatedTime || pushedTime || undefined;
const version = await PackageExtra.getVersion(packageName);
data.ver = version || undefined;
const repoUnavailable = await PackageExtra.getRepoUnavailable(packageName);
data.repoUnavailable = repoUnavailable || undefined;
data.dl30d = await PackageExtra.getMonthlyDownloads(packageName);
aggData[packageName] = data;
}
await PackageExtra.setAggregatedExtraData(aggData);
}
|
Aggregate extra data for all packages into redis.
|
aggregateExtraData
|
javascript
|
openupm/openupm
|
app/jobs/aggregatePackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/aggregatePackageExtra.js
|
BSD-3-Clause
|
aggregateExtraData = async function() {
logger.info("aggregateExtraData");
const packageNames = await loadPackageNames();
const aggData = {};
for (let packageName of packageNames) {
// Verify package
if (!packageExists(packageName)) {
logger.error({ pkg: packageName }, "package doesn't exist");
continue;
}
const data = {};
const stars = await PackageExtra.getStars(packageName);
data.stars = stars || 0;
const pstars = await PackageExtra.getParentStars(packageName);
data.pstars = pstars || undefined;
const unity = await PackageExtra.getUnityVersion(packageName);
data.unity = unity || "2018.1";
data.imageFilename =
(await PackageExtra.getCachedImageFilename(packageName)) || undefined;
const updatedTime = await PackageExtra.getUpdatedTime(packageName);
const pushedTime = await PackageExtra.getRepoPushedTime(packageName);
data.time = updatedTime || pushedTime || undefined;
const version = await PackageExtra.getVersion(packageName);
data.ver = version || undefined;
const repoUnavailable = await PackageExtra.getRepoUnavailable(packageName);
data.repoUnavailable = repoUnavailable || undefined;
data.dl30d = await PackageExtra.getMonthlyDownloads(packageName);
aggData[packageName] = data;
}
await PackageExtra.setAggregatedExtraData(aggData);
}
|
Aggregate extra data for all packages into redis.
|
aggregateExtraData
|
javascript
|
openupm/openupm
|
app/jobs/aggregatePackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/aggregatePackageExtra.js
|
BSD-3-Clause
|
getInvalidTags = function ({
remoteTags,
validTags,
gitTagIgnore,
gitTagPrefix,
minVersion
}) {
let tags = differenceBy(remoteTags, validTags, x => x.tag);
if (gitTagPrefix) {
tags = tags.filter(x => x.tag.startsWith(gitTagPrefix));
}
if (gitTagIgnore) {
const ignoreRe = new RegExp(gitTagIgnore, "i");
tags = tags.filter(x => !ignoreRe.test(x.tag));
}
if (minVersion) {
try {
tags = tags.filter(
x =>
compareVersions(
getVersionFromTag(x.tag),
getVersionFromTag(minVersion)
) >= 0
);
// eslint-disable-next-line no-empty
} catch (error) { }
}
return tags;
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
getInvalidTags
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
getInvalidTags = function ({
remoteTags,
validTags,
gitTagIgnore,
gitTagPrefix,
minVersion
}) {
let tags = differenceBy(remoteTags, validTags, x => x.tag);
if (gitTagPrefix) {
tags = tags.filter(x => x.tag.startsWith(gitTagPrefix));
}
if (gitTagIgnore) {
const ignoreRe = new RegExp(gitTagIgnore, "i");
tags = tags.filter(x => !ignoreRe.test(x.tag));
}
if (minVersion) {
try {
tags = tags.filter(
x =>
compareVersions(
getVersionFromTag(x.tag),
getVersionFromTag(minVersion)
) >= 0
);
// eslint-disable-next-line no-empty
} catch (error) { }
}
return tags;
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
getInvalidTags
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
updateReleaseRecords = async function (packageName, remoteTags) {
// Remove failed local releases that not listed in remoteTags
let releases = await Release.fetchAll(packageName);
for (const rel of releases) {
if (rel.state == ReleaseState.Failed) {
// Remove failed but disappeared release. It happens when
// the remote tag has been removed
// the remote tag has been re-tagged
if (!remoteTags.find(x => x.tag == rel.tag && x.commit == rel.commit)) {
logger.warn(
{
pkg: packageName,
rel: `${packageName}@${rel.version}`,
tag: rel.tag,
commit: rel.commit
},
"remove failed release that not listed in remoteTags"
);
await removeRelease(packageName, rel.version);
}
}
}
// Convert remoteTags to releases
releases = [];
for (const remoteTag of remoteTags) {
let version = getVersionFromTag(remoteTag.tag);
let release = await Release.fetchOne(packageName, version);
if (!release) {
let record = {
packageName,
version,
commit: remoteTag.commit,
tag: remoteTag.tag
};
release = await Release.save(record);
}
releases.push(release);
}
return releases;
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
updateReleaseRecords
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
updateReleaseRecords = async function (packageName, remoteTags) {
// Remove failed local releases that not listed in remoteTags
let releases = await Release.fetchAll(packageName);
for (const rel of releases) {
if (rel.state == ReleaseState.Failed) {
// Remove failed but disappeared release. It happens when
// the remote tag has been removed
// the remote tag has been re-tagged
if (!remoteTags.find(x => x.tag == rel.tag && x.commit == rel.commit)) {
logger.warn(
{
pkg: packageName,
rel: `${packageName}@${rel.version}`,
tag: rel.tag,
commit: rel.commit
},
"remove failed release that not listed in remoteTags"
);
await removeRelease(packageName, rel.version);
}
}
}
// Convert remoteTags to releases
releases = [];
for (const remoteTag of remoteTags) {
let version = getVersionFromTag(remoteTag.tag);
let release = await Release.fetchOne(packageName, version);
if (!release) {
let record = {
packageName,
version,
commit: remoteTag.commit,
tag: remoteTag.tag
};
release = await Release.save(record);
}
releases.push(release);
}
return releases;
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
updateReleaseRecords
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
addReleaseJobs = async function (releases) {
const jobConfig = config.jobs.buildRelease;
const queue = getQueue(jobConfig.queue);
let i = 0;
for (const rel of releases) {
const reason = ReleaseReason.get(rel.reason);
// Skip creating release job if release already succeeded or failed with an acceptable reason.
if (
rel.state == ReleaseState.Succeeded ||
(rel.state == ReleaseState.Failed && !RetryableReleaseReason.includes(reason))
)
continue;
let jobId = jobConfig.name + ":" + rel.packageName + ":" + rel.version;
// Add job
job = await addJob({
queue,
name: jobConfig.name,
data: { name: rel.packageName, version: rel.version },
opts: { jobId, delay: jobConfig.interval * i, timeout: jobConfig.timeout }
});
i++;
}
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
addReleaseJobs
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
addReleaseJobs = async function (releases) {
const jobConfig = config.jobs.buildRelease;
const queue = getQueue(jobConfig.queue);
let i = 0;
for (const rel of releases) {
const reason = ReleaseReason.get(rel.reason);
// Skip creating release job if release already succeeded or failed with an acceptable reason.
if (
rel.state == ReleaseState.Succeeded ||
(rel.state == ReleaseState.Failed && !RetryableReleaseReason.includes(reason))
)
continue;
let jobId = jobConfig.name + ":" + rel.packageName + ":" + rel.version;
// Add job
job = await addJob({
queue,
name: jobConfig.name,
data: { name: rel.packageName, version: rel.version },
opts: { jobId, delay: jobConfig.interval * i, timeout: jobConfig.timeout }
});
i++;
}
}
|
Return invalid tags. Tags have been ignored, without the given prefix, or filtered by
minVersion are not considered invalid.
|
addReleaseJobs
|
javascript
|
openupm/openupm
|
app/jobs/buildPackage.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/buildPackage.js
|
BSD-3-Clause
|
fetchBackerData = async function(force) {
logger.info("fetchBackerData");
const backers = yaml.safeLoad(await readFile(backersPath, "utf8"));
for (const backer of backers.items) {
if (backer.githubUser)
await cacheAvatarImageForGithubUser(backer.githubUser, force);
}
}
|
Fetch backer data
@param {Array} packageNames
@param {Boolean} force
|
fetchBackerData
|
javascript
|
openupm/openupm
|
app/jobs/fetchBackerData.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchBackerData.js
|
BSD-3-Clause
|
fetchBackerData = async function(force) {
logger.info("fetchBackerData");
const backers = yaml.safeLoad(await readFile(backersPath, "utf8"));
for (const backer of backers.items) {
if (backer.githubUser)
await cacheAvatarImageForGithubUser(backer.githubUser, force);
}
}
|
Fetch backer data
@param {Array} packageNames
@param {Boolean} force
|
fetchBackerData
|
javascript
|
openupm/openupm
|
app/jobs/fetchBackerData.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchBackerData.js
|
BSD-3-Clause
|
fetchExtraData = async function(packageNames, force) {
logger.info("fetchExtraData");
if (!packageNames) packageNames = [];
for (let packageName of packageNames) {
// Verify package
if (!packageExists(packageName)) {
logger.error({ pkg: packageName }, "package doesn't exist");
continue;
}
// Load package
const pkg = await loadPackage(packageName);
await _fetchPackageInfo(packageName);
await _fetchPackageScopes(packageName);
await _fetchRepoInfo(pkg.repo, packageName);
await _fetchReadme(pkg, packageName);
await _cacheImage(pkg, packageName, force);
await _cacheAvatarImage(pkg, packageName, force);
await _fetchPackageInstallCount(packageName);
}
}
|
Fetch package extra data into redis for given packageNames array.
@param {Array} packageNames
@param {Boolean} force
|
fetchExtraData
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
fetchExtraData = async function(packageNames, force) {
logger.info("fetchExtraData");
if (!packageNames) packageNames = [];
for (let packageName of packageNames) {
// Verify package
if (!packageExists(packageName)) {
logger.error({ pkg: packageName }, "package doesn't exist");
continue;
}
// Load package
const pkg = await loadPackage(packageName);
await _fetchPackageInfo(packageName);
await _fetchPackageScopes(packageName);
await _fetchRepoInfo(pkg.repo, packageName);
await _fetchReadme(pkg, packageName);
await _cacheImage(pkg, packageName, force);
await _cacheAvatarImage(pkg, packageName, force);
await _fetchPackageInstallCount(packageName);
}
}
|
Fetch package extra data into redis for given packageNames array.
@param {Array} packageNames
@param {Boolean} force
|
fetchExtraData
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
fetchPackageMeta = async function(packageName) {
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://package.openupm.com", packageName),
{
headers: { Accept: "application/json" },
cancelToken: source.token,
}
);
return resp.data;
}
|
Fetch package meta json.
@param {string} packageName
|
fetchPackageMeta
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
fetchPackageMeta = async function(packageName) {
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://package.openupm.com", packageName),
{
headers: { Accept: "application/json" },
cancelToken: source.token,
}
);
return resp.data;
}
|
Fetch package meta json.
@param {string} packageName
|
fetchPackageMeta
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
getLatestVersion = function(pkgMeta) {
if (pkgMeta["dist-tags"] && pkgMeta["dist-tags"]["latest"])
return pkgMeta["dist-tags"]["latest"];
else if (pkgMeta.versions)
return Object.keys(pkgMeta.versions).find(
(key) => pkgMeta.versions[key] == "latest"
);
}
|
Fetch package meta json.
@param {string} packageName
|
getLatestVersion
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
getLatestVersion = function(pkgMeta) {
if (pkgMeta["dist-tags"] && pkgMeta["dist-tags"]["latest"])
return pkgMeta["dist-tags"]["latest"];
else if (pkgMeta.versions)
return Object.keys(pkgMeta.versions).find(
(key) => pkgMeta.versions[key] == "latest"
);
}
|
Fetch package meta json.
@param {string} packageName
|
getLatestVersion
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageInfo = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageInfo");
try {
const pkgMeta = await fetchPackageMeta(packageName);
const version = pkgMeta["dist-tags"].latest;
const versionInfo = pkgMeta.versions[version];
// Save the unity version.
const unityVersion = /^[0-9]{4,4}\.[0-9]/i.test(versionInfo.unity)
? versionInfo.unity
: "";
await PackageExtra.setUnityVersion(packageName, unityVersion);
// Save the update time.
const timeStr = pkgMeta.time[version] || 0;
const time = new Date(timeStr).getTime();
await PackageExtra.setUpdatedTime(packageName, time);
// Save the package version.
await PackageExtra.setVersion(packageName, version);
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch package info error"
);
}
}
|
Fetch package info from the registry.
@param {string} packageName
|
_fetchPackageInfo
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageInfo = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageInfo");
try {
const pkgMeta = await fetchPackageMeta(packageName);
const version = pkgMeta["dist-tags"].latest;
const versionInfo = pkgMeta.versions[version];
// Save the unity version.
const unityVersion = /^[0-9]{4,4}\.[0-9]/i.test(versionInfo.unity)
? versionInfo.unity
: "";
await PackageExtra.setUnityVersion(packageName, unityVersion);
// Save the update time.
const timeStr = pkgMeta.time[version] || 0;
const time = new Date(timeStr).getTime();
await PackageExtra.setUpdatedTime(packageName, time);
// Save the package version.
await PackageExtra.setVersion(packageName, version);
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch package info error"
);
}
}
|
Fetch package info from the registry.
@param {string} packageName
|
_fetchPackageInfo
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageScopes = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageScopes");
// a list of pending {name, version}
const pendingList = [{ name: packageName, version: null }];
// a list of processed {name, version}
const processedList = [];
// a set of package names exists on the registry
const scopeSet = new Set();
// cached package meta: { name: meta }
const cachedPackageMetas = {};
while (pendingList.length > 0) {
const entry = pendingList.shift();
if (processedList.find((x) => x.name === entry.name) === undefined) {
// add entry to processed list
processedList.push(entry);
// skip unity module
if (/com.unity.modules/i.test(entry.name)) continue;
// fetch package meta from the cache
let pkgMeta = cachedPackageMetas[entry.name];
// fetch package meta from the registry
if (!pkgMeta) {
try {
pkgMeta = await fetchPackageMeta(entry.name);
cachedPackageMetas[entry.name] = pkgMeta;
} catch (err) {
if (!isErrorCode(err, 404)) {
logger.error(
httpErrorInfo(err, { pkg: packageName }),
"fetch package scopes error"
);
}
}
}
// skip unexisted package
if (!pkgMeta) continue;
// add to the scope list
scopeSet.add(entry.name);
// parse the latest version
if (!entry.version || entry.version == "latest")
entry.version = getLatestVersion(pkgMeta);
// fall back to latest version if version does not existed
const versions = Object.keys(pkgMeta.versions);
if (!versions.find((x) => x == entry.version))
entry.version = getLatestVersion(pkgMeta);
try {
// add dependencies to pending list
const deps = _.toPairs(
pkgMeta.versions[entry.version]["dependencies"]
).map((x) => {
return { name: x[0], version: x[1] };
});
deps.forEach((x) => pendingList.push(x));
} catch (err) {
logger.error(
httpErrorInfo(err, { pkg: packageName, dep: entry.name }),
"fetch package scopes error"
);
}
}
}
// Save to db.
const scopes = Array.from(scopeSet);
scopes.sort();
await PackageExtra.setScopes(packageName, scopes);
}
|
Fetch package scopes for dependencies.
@param {string} packageName
|
_fetchPackageScopes
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageScopes = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageScopes");
// a list of pending {name, version}
const pendingList = [{ name: packageName, version: null }];
// a list of processed {name, version}
const processedList = [];
// a set of package names exists on the registry
const scopeSet = new Set();
// cached package meta: { name: meta }
const cachedPackageMetas = {};
while (pendingList.length > 0) {
const entry = pendingList.shift();
if (processedList.find((x) => x.name === entry.name) === undefined) {
// add entry to processed list
processedList.push(entry);
// skip unity module
if (/com.unity.modules/i.test(entry.name)) continue;
// fetch package meta from the cache
let pkgMeta = cachedPackageMetas[entry.name];
// fetch package meta from the registry
if (!pkgMeta) {
try {
pkgMeta = await fetchPackageMeta(entry.name);
cachedPackageMetas[entry.name] = pkgMeta;
} catch (err) {
if (!isErrorCode(err, 404)) {
logger.error(
httpErrorInfo(err, { pkg: packageName }),
"fetch package scopes error"
);
}
}
}
// skip unexisted package
if (!pkgMeta) continue;
// add to the scope list
scopeSet.add(entry.name);
// parse the latest version
if (!entry.version || entry.version == "latest")
entry.version = getLatestVersion(pkgMeta);
// fall back to latest version if version does not existed
const versions = Object.keys(pkgMeta.versions);
if (!versions.find((x) => x == entry.version))
entry.version = getLatestVersion(pkgMeta);
try {
// add dependencies to pending list
const deps = _.toPairs(
pkgMeta.versions[entry.version]["dependencies"]
).map((x) => {
return { name: x[0], version: x[1] };
});
deps.forEach((x) => pendingList.push(x));
} catch (err) {
logger.error(
httpErrorInfo(err, { pkg: packageName, dep: entry.name }),
"fetch package scopes error"
);
}
}
}
// Save to db.
const scopes = Array.from(scopeSet);
scopes.sort();
await PackageExtra.setScopes(packageName, scopes);
}
|
Fetch package scopes for dependencies.
@param {string} packageName
|
_fetchPackageScopes
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchRepoInfo = async function(repo, packageName) {
logger.info({ pkg: packageName }, "_fetchRepoInfo");
try {
const headers = { Accept: "application/vnd.github.v3.json" };
const githubToken = getGithubToken();
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://api.github.com/repos/", repo),
{ headers, cancelToken: source.token }
);
const repoInfo = resp.data;
const stars = repoInfo.stargazers_count || 0;
await PackageExtra.setStars(packageName, stars);
if (repoInfo.parent) {
const pstars = repoInfo.parent.stargazers_count || 0;
await PackageExtra.setParentStars(packageName, pstars);
}
if (repoInfo.pushed_at) {
const time = new Date(repoInfo.pushed_at).getTime();
await PackageExtra.setRepoPushedTime(packageName, time);
}
if (repoInfo.updated_at) {
const time = new Date(repoInfo.updated_at).getTime();
await PackageExtra.setRepoUpdatedTime(packageName, time);
}
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch stars error"
);
}
}
|
Fetch repository information like stars and pushed time.
@param {object} repo
|
_fetchRepoInfo
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchRepoInfo = async function(repo, packageName) {
logger.info({ pkg: packageName }, "_fetchRepoInfo");
try {
const headers = { Accept: "application/vnd.github.v3.json" };
const githubToken = getGithubToken();
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://api.github.com/repos/", repo),
{ headers, cancelToken: source.token }
);
const repoInfo = resp.data;
const stars = repoInfo.stargazers_count || 0;
await PackageExtra.setStars(packageName, stars);
if (repoInfo.parent) {
const pstars = repoInfo.parent.stargazers_count || 0;
await PackageExtra.setParentStars(packageName, pstars);
}
if (repoInfo.pushed_at) {
const time = new Date(repoInfo.pushed_at).getTime();
await PackageExtra.setRepoPushedTime(packageName, time);
}
if (repoInfo.updated_at) {
const time = new Date(repoInfo.updated_at).getTime();
await PackageExtra.setRepoUpdatedTime(packageName, time);
}
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch stars error"
);
}
}
|
Fetch repository information like stars and pushed time.
@param {object} repo
|
_fetchRepoInfo
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_cacheImage = async function(pkg, packageName, force) {
logger.info({ pkg: packageName }, "_cacheImage");
try {
const query = await PackageExtra.getImageQueryForPackage(packageName);
if (!query) return;
// check cache
let imageEntry = await getImage(query);
if (!force && imageEntry && imageEntry.available) {
logger.info({ pkg: packageName }, "_cacheImage cache is available");
return;
}
// add image
const duration = config.packageExtra.image.duration;
await addImage({
...query,
duration,
force,
});
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"_cacheImage error"
);
}
}
|
Cache the image url
@param {object} pkg
@param {string} packageName
@param {Boolean} force
|
_cacheImage
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_cacheImage = async function(pkg, packageName, force) {
logger.info({ pkg: packageName }, "_cacheImage");
try {
const query = await PackageExtra.getImageQueryForPackage(packageName);
if (!query) return;
// check cache
let imageEntry = await getImage(query);
if (!force && imageEntry && imageEntry.available) {
logger.info({ pkg: packageName }, "_cacheImage cache is available");
return;
}
// add image
const duration = config.packageExtra.image.duration;
await addImage({
...query,
duration,
force,
});
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"_cacheImage error"
);
}
}
|
Cache the image url
@param {object} pkg
@param {string} packageName
@param {Boolean} force
|
_cacheImage
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_cacheAvatarImage = async function(pkg, packageName, force) {
logger.info({ pkg: packageName }, "_cacheAvatarImage");
if (pkg.owner) await cacheAvatarImageForGithubUser(pkg.owner, force);
if (pkg.parentOwner)
await cacheAvatarImageForGithubUser(pkg.parentOwner, force);
if (pkg.hunter) await cacheAvatarImageForGithubUser(pkg.hunter, force);
}
|
Cache the avatar image url
@param {object} pkg
@param {string} packageName
@param {Boolean} force
|
_cacheAvatarImage
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_cacheAvatarImage = async function(pkg, packageName, force) {
logger.info({ pkg: packageName }, "_cacheAvatarImage");
if (pkg.owner) await cacheAvatarImageForGithubUser(pkg.owner, force);
if (pkg.parentOwner)
await cacheAvatarImageForGithubUser(pkg.parentOwner, force);
if (pkg.hunter) await cacheAvatarImageForGithubUser(pkg.hunter, force);
}
|
Cache the avatar image url
@param {object} pkg
@param {string} packageName
@param {Boolean} force
|
_cacheAvatarImage
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
cacheAvatarImageForGithubUser = async function(username, force) {
for (const [sizeName, entry] of Object.entries(config.packageExtra.avatar)) {
logger.info(
{ username, width: entry.size, height: entry.size, sizeName },
"cacheAvatarImageForGithubUser"
);
try {
const query = await PackageExtra.getImageQueryForGithubUser(
username,
entry.size
);
if (!query) return;
// check cache
let imageEntry = await getImage(query);
if (!force && imageEntry && imageEntry.available) {
logger.info(
{ username, width: entry.size, height: entry.size, sizeName },
"cacheAvatarImageForGithubUser cache is available"
);
return;
}
// add image
const duration = entry.duration;
// override default image filename
const filename = getCachedAvatarImageFilename(username, entry.size);
await addImage({
...query,
duration,
filename,
force,
});
} catch (error) {
logger.error(
httpErrorInfo(error, { username }),
"cacheAvatarImageForGithubUser error"
);
}
}
}
|
Cache the avatar image url for the GitHub user
@param {string} username
@param {Boolean} force
|
cacheAvatarImageForGithubUser
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
cacheAvatarImageForGithubUser = async function(username, force) {
for (const [sizeName, entry] of Object.entries(config.packageExtra.avatar)) {
logger.info(
{ username, width: entry.size, height: entry.size, sizeName },
"cacheAvatarImageForGithubUser"
);
try {
const query = await PackageExtra.getImageQueryForGithubUser(
username,
entry.size
);
if (!query) return;
// check cache
let imageEntry = await getImage(query);
if (!force && imageEntry && imageEntry.available) {
logger.info(
{ username, width: entry.size, height: entry.size, sizeName },
"cacheAvatarImageForGithubUser cache is available"
);
return;
}
// add image
const duration = entry.duration;
// override default image filename
const filename = getCachedAvatarImageFilename(username, entry.size);
await addImage({
...query,
duration,
filename,
force,
});
} catch (error) {
logger.error(
httpErrorInfo(error, { username }),
"cacheAvatarImageForGithubUser error"
);
}
}
}
|
Cache the avatar image url for the GitHub user
@param {string} username
@param {Boolean} force
|
cacheAvatarImageForGithubUser
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchReadme = async function(pkg, packageName) {
logger.info({ pkg: packageName }, "_fetchReadme");
const langs = ["en-US", "zh-CN"];
for (const lang of langs) {
const readmePathPropKey = PackageExtra.getPropKeyForLang(
PackageExtra.propKeys.readme,
lang
);
const readmePath = pkg[readmePathPropKey];
if (readmePath)
await _fetchReadmeForLang(pkg, packageName, lang, readmePath);
}
}
|
Fetch repository readme.
@param {object} repo
|
_fetchReadme
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchReadme = async function(pkg, packageName) {
logger.info({ pkg: packageName }, "_fetchReadme");
const langs = ["en-US", "zh-CN"];
for (const lang of langs) {
const readmePathPropKey = PackageExtra.getPropKeyForLang(
PackageExtra.propKeys.readme,
lang
);
const readmePath = pkg[readmePathPropKey];
if (readmePath)
await _fetchReadmeForLang(pkg, packageName, lang, readmePath);
}
}
|
Fetch repository readme.
@param {object} repo
|
_fetchReadme
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchReadmeForLang = async function(pkg, packageName, lang, readmePath) {
logger.info({ pkg: packageName, lang, readmePath }, "_fetchReadmeForLang");
const pushedTime = await PackageExtra.getRepoPushedTime(packageName);
const readmeCacheKey = `v0:${readmePath}:${pushedTime}`;
const prevReadmeCacheKey = await PackageExtra.getReadmeCacheKey(
packageName,
lang
);
if (readmeCacheKey == prevReadmeCacheKey) {
logger.info(
{ pkg: packageName, lang, readmePath },
"skip _fetchReadmeForLang because the cache is available"
);
return;
}
try {
const [owner, name] = pkg.repo.split("/");
const data = await createGqlClient().request(gitFileContentGql, {
owner,
name,
tree: readmePath,
});
let text = "";
if (data.repository.tree && data.repository.tree.text)
text = data.repository.tree.text;
await PackageExtra.setReadme(packageName, text, lang);
const html = await renderMarkdownToHtml({ pkg, markdown: text });
await PackageExtra.setReadmeHtml(packageName, html, lang);
await PackageExtra.setReadmeCacheKey(packageName, lang, readmeCacheKey);
} catch (error) {
logger.error(
{ err: error, pkg: packageName, lang, readmePath },
"_fetchReadmeForLang"
);
}
}
|
Fetch repository readme.
@param {object} repo
|
_fetchReadmeForLang
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchReadmeForLang = async function(pkg, packageName, lang, readmePath) {
logger.info({ pkg: packageName, lang, readmePath }, "_fetchReadmeForLang");
const pushedTime = await PackageExtra.getRepoPushedTime(packageName);
const readmeCacheKey = `v0:${readmePath}:${pushedTime}`;
const prevReadmeCacheKey = await PackageExtra.getReadmeCacheKey(
packageName,
lang
);
if (readmeCacheKey == prevReadmeCacheKey) {
logger.info(
{ pkg: packageName, lang, readmePath },
"skip _fetchReadmeForLang because the cache is available"
);
return;
}
try {
const [owner, name] = pkg.repo.split("/");
const data = await createGqlClient().request(gitFileContentGql, {
owner,
name,
tree: readmePath,
});
let text = "";
if (data.repository.tree && data.repository.tree.text)
text = data.repository.tree.text;
await PackageExtra.setReadme(packageName, text, lang);
const html = await renderMarkdownToHtml({ pkg, markdown: text });
await PackageExtra.setReadmeHtml(packageName, html, lang);
await PackageExtra.setReadmeCacheKey(packageName, lang, readmeCacheKey);
} catch (error) {
logger.error(
{ err: error, pkg: packageName, lang, readmePath },
"_fetchReadmeForLang"
);
}
}
|
Fetch repository readme.
@param {object} repo
|
_fetchReadmeForLang
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
fetchPackageMonthlyInstallCount = async function(packageName) {
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin(
"https://package.openupm.com/downloads/point/last-month",
packageName
),
{
headers: { Accept: "application/json" },
cancelToken: source.token,
}
);
return resp.data;
}
|
Fetch package meta json.
@param {string} packageName
@returns {Number}
|
fetchPackageMonthlyInstallCount
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
fetchPackageMonthlyInstallCount = async function(packageName) {
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin(
"https://package.openupm.com/downloads/point/last-month",
packageName
),
{
headers: { Accept: "application/json" },
cancelToken: source.token,
}
);
return resp.data;
}
|
Fetch package meta json.
@param {string} packageName
@returns {Number}
|
fetchPackageMonthlyInstallCount
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageInstallCount = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageInstallCount");
try {
const result = await fetchPackageMonthlyInstallCount(packageName);
const count = result.downloads || 0;
await PackageExtra.setMonthlyDownloads(packageName, count);
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch package install count error"
);
}
}
|
Fetch package install count.
@param {string} packageName
|
_fetchPackageInstallCount
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchPackageInstallCount = async function(packageName) {
logger.info({ pkg: packageName }, "_fetchPackageInstallCount");
try {
const result = await fetchPackageMonthlyInstallCount(packageName);
const count = result.downloads || 0;
await PackageExtra.setMonthlyDownloads(packageName, count);
} catch (error) {
logger.error(
httpErrorInfo(error, { pkg: packageName }),
"fetch package install count error"
);
}
}
|
Fetch package install count.
@param {string} packageName
|
_fetchPackageInstallCount
|
javascript
|
openupm/openupm
|
app/jobs/fetchPackageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchPackageExtra.js
|
BSD-3-Clause
|
_fetchStars = async function(repo) {
try {
const headers = { Accept: "application/vnd.github.v3.json" };
const githubToken = getGithubToken();
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://api.github.com/repos/", repo),
{ headers, cancelToken: source.token }
);
const repoInfo = resp.data;
const stars = repoInfo.stargazers_count || 0;
await SiteInfo.setStars(stars);
} catch (error) {
logger.error(httpErrorInfo(error, {}), "fetch stars error");
}
}
|
Fetch repository stars.
@param {string} repo
|
_fetchStars
|
javascript
|
openupm/openupm
|
app/jobs/fetchSiteInfo.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchSiteInfo.js
|
BSD-3-Clause
|
_fetchStars = async function(repo) {
try {
const headers = { Accept: "application/vnd.github.v3.json" };
const githubToken = getGithubToken();
if (githubToken) headers.authorization = `Bearer ${githubToken}`;
let resp = null;
const source = CancelToken.source();
setTimeout(() => {
if (resp === null) source.cancel("ECONNTIMEOUT");
}, 10000);
resp = await AxiosService.create().get(
urljoin("https://api.github.com/repos/", repo),
{ headers, cancelToken: source.token }
);
const repoInfo = resp.data;
const stars = repoInfo.stargazers_count || 0;
await SiteInfo.setStars(stars);
} catch (error) {
logger.error(httpErrorInfo(error, {}), "fetch stars error");
}
}
|
Fetch repository stars.
@param {string} repo
|
_fetchStars
|
javascript
|
openupm/openupm
|
app/jobs/fetchSiteInfo.js
|
https://github.com/openupm/openupm/blob/master/app/jobs/fetchSiteInfo.js
|
BSD-3-Clause
|
getPropKeyForLang = function(propKey, lang) {
if (!lang || lang == "en-US") return propKey;
else if (lang == "zh-CN") return propKey + "_zhCN";
else throw new Error("Not implemented yet");
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getPropKeyForLang
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getPropKeyForLang = function(propKey, lang) {
if (!lang || lang == "en-US") return propKey;
else if (lang == "zh-CN") return propKey + "_zhCN";
else throw new Error("Not implemented yet");
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getPropKeyForLang
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setInvalidTags = async function(packageName, tags) {
const jsonText = JSON.stringify(tags, null, 0);
await setValue(packageName, propKeys.invalidTags, jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setInvalidTags
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setInvalidTags = async function(packageName, tags) {
const jsonText = JSON.stringify(tags, null, 0);
await setValue(packageName, propKeys.invalidTags, jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setInvalidTags
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getInvalidTags = async function(packageName) {
const jsonText = await getValue(packageName, propKeys.invalidTags);
return jsonText === null ? [] : JSON.parse(jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getInvalidTags
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getInvalidTags = async function(packageName) {
const jsonText = await getValue(packageName, propKeys.invalidTags);
return jsonText === null ? [] : JSON.parse(jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getInvalidTags
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setScopes = async function(packageName, scopes) {
const jsonText = JSON.stringify(scopes, null, 0);
await setValue(packageName, propKeys.scopes, jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setScopes
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setScopes = async function(packageName, scopes) {
const jsonText = JSON.stringify(scopes, null, 0);
await setValue(packageName, propKeys.scopes, jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setScopes
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getScopes = async function(packageName) {
const jsonText = await getValue(packageName, propKeys.scopes);
return jsonText === null ? [] : JSON.parse(jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getScopes
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getScopes = async function(packageName) {
const jsonText = await getValue(packageName, propKeys.scopes);
return jsonText === null ? [] : JSON.parse(jsonText);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getScopes
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setVersion = async function(packageName, version) {
await setValue(packageName, propKeys.version, version);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setVersion = async function(packageName, version) {
await setValue(packageName, propKeys.version, version);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getVersion = async function(packageName) {
const text = await getValue(packageName, propKeys.version);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getVersion = async function(packageName) {
const text = await getValue(packageName, propKeys.version);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setUnityVersion = async function(packageName, unityVersion) {
await setValue(packageName, propKeys.unityVersion, unityVersion);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setUnityVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setUnityVersion = async function(packageName, unityVersion) {
await setValue(packageName, propKeys.unityVersion, unityVersion);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setUnityVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getUnityVersion = async function(packageName) {
const text = await getValue(packageName, propKeys.unityVersion);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getUnityVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getUnityVersion = async function(packageName) {
const text = await getValue(packageName, propKeys.unityVersion);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getUnityVersion
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setStars = async function(packageName, stars) {
await setValue(packageName, propKeys.stars, stars);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setStars = async function(packageName, stars) {
await setValue(packageName, propKeys.stars, stars);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getStars = async function(packageName) {
const text = await getValue(packageName, propKeys.stars);
return parseInt(text);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getStars = async function(packageName) {
const text = await getValue(packageName, propKeys.stars);
return parseInt(text);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setParentStars = async function(packageName, stars) {
await setValue(packageName, propKeys.parentStars, stars);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setParentStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setParentStars = async function(packageName, stars) {
await setValue(packageName, propKeys.parentStars, stars);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setParentStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getParentStars = async function(packageName) {
const text = await getValue(packageName, propKeys.parentStars);
return parseInt(text);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getParentStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getParentStars = async function(packageName) {
const text = await getValue(packageName, propKeys.parentStars);
return parseInt(text);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getParentStars
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadme = async function(packageName, readme, lang) {
const key = getPropKeyForLang(propKeys.readme, lang);
await setValue(packageName, key, readme);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadme
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadme = async function(packageName, readme, lang) {
const key = getPropKeyForLang(propKeys.readme, lang);
await setValue(packageName, key, readme);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadme
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadme = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readme, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadme
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadme = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readme, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadme
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadmeCacheKey = async function(packageName, lang, cacheKey) {
const key = getPropKeyForLang(propKeys.readmeCacheKey, lang);
await setValue(packageName, key, cacheKey);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadmeCacheKey
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadmeCacheKey = async function(packageName, lang, cacheKey) {
const key = getPropKeyForLang(propKeys.readmeCacheKey, lang);
await setValue(packageName, key, cacheKey);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadmeCacheKey
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadmeCacheKey = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readmeCacheKey, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadmeCacheKey
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadmeCacheKey = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readmeCacheKey, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadmeCacheKey
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadmeHtml = async function(packageName, readmeHtml, lang) {
const key = getPropKeyForLang(propKeys.readmeHtml, lang);
await setValue(packageName, key, readmeHtml);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadmeHtml
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setReadmeHtml = async function(packageName, readmeHtml, lang) {
const key = getPropKeyForLang(propKeys.readmeHtml, lang);
await setValue(packageName, key, readmeHtml);
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
setReadmeHtml
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadmeHtml = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readmeHtml, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadmeHtml
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getReadmeHtml = async function(packageName, lang) {
const key = getPropKeyForLang(propKeys.readmeHtml, lang);
const text = await getValue(packageName, key);
return text;
}
|
Get the property key appended with a language code except en-US.
@param {String} propKey - the property key
@param {String} lang - the ISO 639-1 standard language code
@returns the property key for lang
|
getReadmeHtml
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getImageQueryForPackage = async function(packageName) {
// get the image url
const pkg = await loadPackage(packageName);
const imageUrl = pkg.image;
if (!imageUrl) return null;
const width = config.packageExtra.image.width;
const height = config.packageExtra.image.height;
const fit = pkg.imageFit == "contain" ? "contain" : "cover";
return { imageUrl, width, height, fit };
}
|
Get image query data for a package, return { imageUrl, width, height, fit }
@param {string} packageName
|
getImageQueryForPackage
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getImageQueryForPackage = async function(packageName) {
// get the image url
const pkg = await loadPackage(packageName);
const imageUrl = pkg.image;
if (!imageUrl) return null;
const width = config.packageExtra.image.width;
const height = config.packageExtra.image.height;
const fit = pkg.imageFit == "contain" ? "contain" : "cover";
return { imageUrl, width, height, fit };
}
|
Get image query data for a package, return { imageUrl, width, height, fit }
@param {string} packageName
|
getImageQueryForPackage
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getImageQueryForGithubUser = async function(username, size) {
// get the image url
const imageUrl = `https://github.com/${username}.png?size=${size}`;
return { imageUrl, width: size, height: size, fit: "cover" };
}
|
Get image query data for a GitHub user, return { imageUrl, width, height, fit }
@param {string} username
@param {Number} size
|
getImageQueryForGithubUser
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getImageQueryForGithubUser = async function(username, size) {
// get the image url
const imageUrl = `https://github.com/${username}.png?size=${size}`;
return { imageUrl, width: size, height: size, fit: "cover" };
}
|
Get image query data for a GitHub user, return { imageUrl, width, height, fit }
@param {string} username
@param {Number} size
|
getImageQueryForGithubUser
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getCachedImageFilename = async function(packageName) {
const imageQuery = await getImageQueryForPackage(packageName);
if (imageQuery) {
const imageData = await getImage(imageQuery);
if (imageData) return imageData.filename;
}
return null;
}
|
Get the cached image filename
@param {string} packageName
|
getCachedImageFilename
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getCachedImageFilename = async function(packageName) {
const imageQuery = await getImageQueryForPackage(packageName);
if (imageQuery) {
const imageData = await getImage(imageQuery);
if (imageData) return imageData.filename;
}
return null;
}
|
Get the cached image filename
@param {string} packageName
|
getCachedImageFilename
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setRepoPushedTime = async function(packageName, value) {
await setValue(packageName, propKeys.repoPushedTime, value);
}
|
Get the cached image filename
@param {string} packageName
|
setRepoPushedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setRepoPushedTime = async function(packageName, value) {
await setValue(packageName, propKeys.repoPushedTime, value);
}
|
Get the cached image filename
@param {string} packageName
|
setRepoPushedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getRepoPushedTime = async function(packageName) {
const value = await getValue(packageName, propKeys.repoPushedTime);
return parseInt(value) || 0;
}
|
Get the cached image filename
@param {string} packageName
|
getRepoPushedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getRepoPushedTime = async function(packageName) {
const value = await getValue(packageName, propKeys.repoPushedTime);
return parseInt(value) || 0;
}
|
Get the cached image filename
@param {string} packageName
|
getRepoPushedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setRepoUpdatedTime = async function(packageName, value) {
await setValue(packageName, propKeys.repoUpdatedTime, value);
}
|
Get the cached image filename
@param {string} packageName
|
setRepoUpdatedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setRepoUpdatedTime = async function(packageName, value) {
await setValue(packageName, propKeys.repoUpdatedTime, value);
}
|
Get the cached image filename
@param {string} packageName
|
setRepoUpdatedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getRepoUpdatedTime = async function(packageName) {
const value = await getValue(packageName, propKeys.repoUpdatedTime);
return parseInt(value) || 0;
}
|
Get the cached image filename
@param {string} packageName
|
getRepoUpdatedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
getRepoUpdatedTime = async function(packageName) {
const value = await getValue(packageName, propKeys.repoUpdatedTime);
return parseInt(value) || 0;
}
|
Get the cached image filename
@param {string} packageName
|
getRepoUpdatedTime
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
setRepoUnavailable = async function(packageName, value) {
await setValue(packageName, propKeys.repoUnavailable, value ? "1" : "0");
}
|
Get the cached image filename
@param {string} packageName
|
setRepoUnavailable
|
javascript
|
openupm/openupm
|
app/models/packageExtra.js
|
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
|
BSD-3-Clause
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.