@tscircuit/cli 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev-server-api/routes/api/dev_package_examples/create.ts +9 -2
- package/dev-server-api/routes/api/dev_package_examples/get.ts +1 -0
- package/dev-server-api/routes/api/dev_package_examples/update.ts +4 -1
- package/dev-server-api/src/db/create-schema.ts +1 -0
- package/dev-server-api/src/db/get-db.ts +1 -0
- package/dev-server-frontend/src/ExampleContentView.tsx +9 -0
- package/dist/cli.js +81 -63
- package/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +10 -2
- package/lib/cmd-fns/dev/start-watcher.ts +1 -0
- package/lib/soupify.ts +7 -4
- package/package.json +1 -1
|
@@ -21,18 +21,26 @@ export const soupifyAndUploadExampleFile = async ({
|
|
|
21
21
|
const exportName = inferExportNameFromSource(exampleContent)
|
|
22
22
|
|
|
23
23
|
console.log(kleur.gray(`[soupifying] ${exampleFileName}...`))
|
|
24
|
-
const soup = await soupify({
|
|
24
|
+
const { soup, error } = await soupify({
|
|
25
25
|
filePath: examplePath,
|
|
26
26
|
exportName,
|
|
27
27
|
})
|
|
28
|
+
.then((soup) => ({ soup, error: null }))
|
|
29
|
+
.catch((e) => ({ error: e, soup: undefined }))
|
|
30
|
+
|
|
31
|
+
if (error) {
|
|
32
|
+
console.log(kleur.red(`[ error ] couldn't soupify ${exampleFileName}`))
|
|
33
|
+
console.log(error.toString())
|
|
34
|
+
}
|
|
28
35
|
console.log(kleur.gray(`[uploading ] ${exampleFileName}...`))
|
|
29
36
|
await devServerAxios.post("/api/dev_package_examples/create", {
|
|
30
37
|
tscircuit_soup: soup,
|
|
38
|
+
error: error?.toString() || null,
|
|
31
39
|
file_path: examplePath,
|
|
32
40
|
export_name: exportName,
|
|
33
41
|
})
|
|
34
42
|
console.log(kleur.gray(`[ done ] ${exampleFileName}!`))
|
|
35
43
|
} catch (e: any) {
|
|
36
|
-
console.log(kleur.red(e.toString()))
|
|
44
|
+
console.log(kleur.red(`[ error ] ${e.toString()}`))
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -20,6 +20,7 @@ export const startWatcher = async ({
|
|
|
20
20
|
should_run: true,
|
|
21
21
|
}
|
|
22
22
|
watcher.on("change", async (path) => {
|
|
23
|
+
if (path.endsWith(".__tmp_entrypoint.tsx")) return
|
|
23
24
|
console.log(`File ${path} has been changed`)
|
|
24
25
|
// TODO analyze to determine which examples were impacted
|
|
25
26
|
upload_queue_state.dirty = true
|
package/lib/soupify.ts
CHANGED
|
@@ -44,7 +44,10 @@ console.log(JSON.stringify(elements))
|
|
|
44
44
|
`.trim()
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
const processResult = await $`
|
|
47
|
+
const processResult = await $`npx tsx ${tmpFilePath}`
|
|
48
|
+
.stdout("piped")
|
|
49
|
+
.stderr("piped")
|
|
50
|
+
.noThrow()
|
|
48
51
|
|
|
49
52
|
const rawSoup = processResult.stdout
|
|
50
53
|
const errText = processResult.stderr
|
|
@@ -56,7 +59,7 @@ console.log(JSON.stringify(elements))
|
|
|
56
59
|
|
|
57
60
|
if (soup.COMPILE_ERROR) {
|
|
58
61
|
// console.log(kleur.red(`Failed to compile ${filePath}`))
|
|
59
|
-
|
|
62
|
+
console.log(kleur.red(soup.COMPILE_ERROR))
|
|
60
63
|
throw new Error(soup.COMPILE_ERROR)
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -64,8 +67,8 @@ console.log(JSON.stringify(elements))
|
|
|
64
67
|
} catch (e: any) {
|
|
65
68
|
// console.log(kleur.red(`Failed to parse result of soupify: ${e.toString()}`))
|
|
66
69
|
const t = Date.now()
|
|
67
|
-
console.log(`
|
|
70
|
+
console.log(`Dumping raw output to .tscircuit/err-${t}.log`)
|
|
68
71
|
writeFileSync(`.tscircuit/err-${t}.log`, rawSoup + "\n\n" + errText)
|
|
69
|
-
throw
|
|
72
|
+
throw new Error(errText)
|
|
70
73
|
}
|
|
71
74
|
}
|