UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

25 lines (24 loc) 739 B
import { Effect, HTTPClient, Platform, Schema } from "../../../effect.js"; class NpmVersion extends Schema.Class("NpmVersion")({ version: Schema.String }) { } class GetVersionFromNPM extends Effect.Service()( "studiocms/sdk/effect/GetVersionFromNPM", { effect: Effect.gen(function* () { const client = yield* HTTPClient; const get = (pkg, ver = "latest") => Effect.gen(function* () { const response = yield* client.get(`https://registry.npmjs.org/${pkg}/${ver}`).pipe(Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(NpmVersion))); return response.version; }); return { get }; }), dependencies: [HTTPClient.Default] } ) { } export { GetVersionFromNPM, NpmVersion };