* Fix our golden standard tests (broken by new assemblies kcl-samples) * Finally use the right combination of env vars * Fix the manifest * Continue to fix multiple file kcl-samples * Fix loading in desktop app * Type narrow for tsc * fmt --------- Co-authored-by: Frank Noirot <frank@kittycad.io>
34 lines
903 B
TypeScript
34 lines
903 B
TypeScript
import { KCL_SAMPLES_MANIFEST_URLS } from './constants'
|
|
import { isDesktop } from './isDesktop'
|
|
|
|
export type KclSamplesManifestItem = {
|
|
file: string
|
|
pathFromProjectDirectoryToFirstFile: string
|
|
multipleFiles: boolean
|
|
title: string
|
|
description: string
|
|
}
|
|
|
|
export async function getKclSamplesManifest() {
|
|
let response = await fetch(KCL_SAMPLES_MANIFEST_URLS.remote)
|
|
if (!response.ok) {
|
|
console.warn(
|
|
'Failed to fetch latest remote KCL samples manifest, falling back to local:',
|
|
response.statusText
|
|
)
|
|
response = await fetch(
|
|
(isDesktop() ? '.' : '') + KCL_SAMPLES_MANIFEST_URLS.localFallback
|
|
)
|
|
if (!response.ok) {
|
|
console.error(
|
|
'Failed to fetch fallback KCL samples manifest:',
|
|
response.statusText
|
|
)
|
|
return []
|
|
}
|
|
}
|
|
return response.json().then((manifest) => {
|
|
return manifest as KclSamplesManifestItem[]
|
|
})
|
|
}
|