Skip to content

Commit

Permalink
Merge branch 'main' into johnd/style-updates-2
Browse files Browse the repository at this point in the history
  • Loading branch information
donjo committed May 20, 2024
2 parents c97c50c + a8e7cd6 commit 8398113
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 35 deletions.
2 changes: 1 addition & 1 deletion api/src/api/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ pub async fn delete_handler(req: Request<Body>) -> ApiResult<Response<Body>> {

let orama_client = req.data::<Option<OramaClient>>().unwrap();
if let Some(orama_client) = orama_client {
orama_client.delete_package(&scope, &package).await?;
orama_client.delete_package(&scope, &package);
}

let res = Response::builder()
Expand Down
49 changes: 28 additions & 21 deletions api/src/orama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl OramaClient {

#[instrument(name = "OramaClient::upsert_package", skip(self))]
pub fn upsert_package(&self, package: &Package, meta: &PackageVersionMeta) {
if package.version_count == 0 {
return;
}
let id = format!("@{}/{}", package.scope, package.name);
let score = package
.latest_version
Expand Down Expand Up @@ -87,27 +90,31 @@ impl OramaClient {
);
}

#[instrument(name = "OramaClient::delete_package", skip(self), err)]
pub async fn delete_package(
&self,
scope: &ScopeName,
package: &PackageName,
) -> Result<(), anyhow::Error> {
#[instrument(name = "OramaClient::delete_package", skip(self))]
pub fn delete_package(&self, scope: &ScopeName, package: &PackageName) {
let id = format!("@{scope}/{package}");
let res = self
.request(
&format!("/webhooks/{}/notify", self.index_id),
serde_json::json!({ "remove": [id] }),
)
.await?;
let status = res.status();
if status.is_success() {
Ok(())
} else {
let response = res.text().await?;
Err(anyhow::anyhow!(
"failed to deploy changes (status {status}): {response}"
))
}
let body = serde_json::json!({ "remove": [id] });
let span = Span::current();
let client = self.clone();
let path = format!("/webhooks/{}/notify", self.index_id);
tokio::spawn(
async move {
let res = match client.request(&path, body).await {
Ok(res) => res,
Err(err) => {
error!("failed to OramaClient::delete_package: {err}");
return;
}
};
let status = res.status();
if !status.is_success() {
let response = res.text().await.unwrap_or_default();
error!(
"failed to OramaClient::delete_package for {id} (status {status}): {response}"
);
}
}
.instrument(span),
);
}
}
2 changes: 1 addition & 1 deletion api/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ pub mod tests {
)
.await;
assert_eq!(task.status, PublishingTaskStatus::Failure, "{task:#?}");
assert_eq!(task.error.unwrap().code, "jsrMissingConstraint");
assert_eq!(task.error.unwrap().code, "missingConstraint");
}

#[tokio::test]
Expand Down
4 changes: 2 additions & 2 deletions api/src/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ impl PublishError {
PublishError::NpmTarballError(_) => Some("npmTarballError"),
PublishError::InvalidJsrSpecifier(_) => Some("invalidJsrSpecifier"),
PublishError::InvalidNpmSpecifier(_) => Some("invalidNpmSpecifier"),
PublishError::JsrMissingConstraint(_) => Some("jsrMissingConstraint"),
PublishError::NpmMissingConstraint(_) => Some("npmMissingConstraint"),
PublishError::JsrMissingConstraint(_) => Some("missingConstraint"),
PublishError::NpmMissingConstraint(_) => Some("missingConstraint"),
PublishError::InvalidJsrScopedPackageName(_, _) => {
Some("invalidJsrScopedPackageName")
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/docs/writing-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ There are two important pieces to documentation:
of the package - it acts as an overview or summary for all symbols in the
module

> Also see this blog post on
> [how to write docs for your package](https://deno.com/blog/document-javascript-package).
## Symbol documentation

To add documentation for a symbol, add a JSDoc comment above the symbol:
Expand Down
2 changes: 1 addition & 1 deletion frontend/routes/package/(_islands)/BreadcrumbsSticky.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function BreadcrumbsSticky(
return (
<div
ref={ref}
class={`-section-x-inset-xl top-0 sticky bg-white z-10 -my-3 py-3 ${
class={`-section-x-inset-xl top-0 sticky bg-white z-20 -my-3 py-3 ${
sticky.value
? "border-b border-jsr-cyan-100 shadow-[0px_2px_4px_0px_rgba(209,235,253,0.40)]"
: ""
Expand Down
3 changes: 2 additions & 1 deletion frontend/routes/packages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default function PackageListPage({

<div className="mt-2 flex flex-wrap items-start justify-between px-2">
<span className="text-sm text-gray-400 block">
Changes made in the last 15 minutes may not be visible yet.
Changes made in the last 15 minutes may not be visible yet. Packages
with no published versions are not shown.
</span>
<div class="flex items-center gap-1">
<span className="text-sm text-gray-500">powered by</span>
Expand Down
18 changes: 10 additions & 8 deletions tools/orama_package_reindex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ while (true) {
}
}

const entries: OramaPackageHit[] = packages.map((entry) => ({
scope: entry.scope,
name: entry.name,
description: entry.description,
runtimeCompat: entry.runtimeCompat,
score: entry.score,
id: `@${entry.scope}/${entry.name}`,
}));
const entries: OramaPackageHit[] = packages
.filter((entry) => entry.versionCount > 0)
.map((entry) => ({
scope: entry.scope,
name: entry.name,
description: entry.description,
runtimeCompat: entry.runtimeCompat,
score: entry.score,
id: `@${entry.scope}/${entry.name}`,
}));

const res2 = await fetch(`${ORAMA_URL}/${index}/notify`, {
method: "POST",
Expand Down

0 comments on commit 8398113

Please sign in to comment.