-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into brace/refactor-merge-tool-results
- Loading branch information
Showing
8 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
"gen:supabase": "npx supabase gen types typescript --project-id 'xsqpnijvmbodcxyapnyq' --schema public > ./src/supabase.d.ts", | ||
"broken-links": "node ./scripts/check-broken-links.js", | ||
"check:broken-links": "yarn quarto && yarn broken-links", | ||
"check:broken-links:ci": "yarn quarto:vercel && yarn broken-links" | ||
"check:broken-links:ci": "yarn quarto:vercel && yarn broken-links", | ||
"validate": "tsx --experimental-wasm-modules -r dotenv/config ./scripts/validate_notebook.ts" | ||
}, | ||
"dependencies": { | ||
"@docusaurus/core": "2.4.3", | ||
|
@@ -70,8 +71,10 @@ | |
"rimraf": "^5.0.1", | ||
"supabase": "^1.148.6", | ||
"swc-loader": "^0.2.3", | ||
"tsx": "^3.12.3", | ||
"typedoc": "^0.24.4", | ||
"typedoc-plugin-markdown": "next", | ||
"typescript": "~5.1.6", | ||
"yaml-loader": "^0.8.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import * as fs from "node:fs/promises"; | ||
import * as ts from "typescript"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
|
||
export async function extract(filepath: string) { | ||
const cells = JSON.parse((await fs.readFile(filepath)).toString()).cells; | ||
const code = cells | ||
.map((cell: Record<string, any>) => { | ||
if (cell.cell_type === "code") { | ||
return cell.source.join(""); | ||
} | ||
return ""; | ||
}) | ||
.join("\n"); | ||
return code; | ||
} | ||
|
||
let [pathname, ...args] = process.argv.slice(2); | ||
|
||
if (!pathname) { | ||
throw new Error("No pathname provided."); | ||
} | ||
|
||
const run = async () => { | ||
if (pathname.startsWith("docs/core_docs/")) { | ||
pathname = "./" + pathname.slice("docs/core_docs/".length); | ||
} | ||
if (!pathname.endsWith(".ipynb")) { | ||
throw new Error("Only .ipynb files are supported."); | ||
} | ||
const filename = pathname | ||
.split("/") | ||
[pathname.split("/").length - 1].replace(".ipynb", ".mts"); | ||
const tempFilepath = `./tmp/${filename}`; | ||
try { | ||
const typescriptSource = await extract(pathname); | ||
try { | ||
await fs.access("./tmp", fs.constants.F_OK); | ||
} catch (err) { | ||
await fs.mkdir("./tmp"); | ||
} | ||
await fs.writeFile(tempFilepath, typescriptSource); | ||
const program = ts.createProgram([tempFilepath], { | ||
module: ts.ModuleKind.NodeNext, | ||
moduleResolution: ts.ModuleResolutionKind.NodeNext, | ||
target: ts.ScriptTarget.ES2021, | ||
alwaysStrict: true, | ||
skipLibCheck: true, | ||
}); | ||
const diagnostics = ts.getPreEmitDiagnostics(program); | ||
if (diagnostics.length === 0) { | ||
console.log("No type errors found."); | ||
} else { | ||
diagnostics.forEach((diagnostic) => { | ||
if (diagnostic.file) { | ||
const { line, character } = | ||
diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); | ||
const message = ts.flattenDiagnosticMessageText( | ||
diagnostic.messageText, | ||
"\n" | ||
); | ||
console.log( | ||
`${diagnostic.file.fileName} (${line + 1},${ | ||
character + 1 | ||
}): ${message}` | ||
); | ||
} else { | ||
console.log( | ||
ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") | ||
); | ||
} | ||
}); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} finally { | ||
try { | ||
await fs.rm(tempFilepath); | ||
} catch (e) { | ||
// Do nothing | ||
} | ||
} | ||
}; | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters