@tscircuit/cli 0.0.394 → 0.1.2
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/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-pver-release.yml +25 -0
- package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
- package/LICENSE +21 -0
- package/README.md +33 -36
- package/biome.json +9 -9
- package/bun.lockb +0 -0
- package/cli/CliContext.ts +8 -0
- package/cli/auth/login/register.ts +73 -0
- package/cli/auth/logout/register.ts +11 -0
- package/cli/auth/register.ts +5 -0
- package/cli/clone/register.ts +99 -0
- package/cli/config/print/register.ts +12 -0
- package/cli/config/register.ts +5 -0
- package/cli/dev/register.ts +111 -0
- package/cli/main.ts +33 -0
- package/dist/main.js +537 -0
- package/docs/file-server-api-usage.md +57 -0
- package/docs/run-frame-usage.md +14 -0
- package/example-dir/manual-edits.json +1 -0
- package/example-dir/snippet.d.ts +13 -0
- package/example-dir/snippet.tsx +20 -0
- package/example-dir/types.d.ts +11 -0
- package/lib/cli-config/TypedConfigStore.ts +50 -0
- package/lib/cli-config/index.ts +16 -0
- package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
- package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
- package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
- package/lib/index.ts +2 -0
- package/lib/project-config/index.ts +5 -0
- package/lib/registry-api/endpoint-types.ts +20 -0
- package/lib/registry-api/get-ky.ts +30 -0
- package/lib/server/EventsWatcher.ts +75 -0
- package/lib/server/createServer.ts +62 -0
- package/lib/site/getIndex.ts +18 -0
- package/package.json +27 -144
- package/tsconfig.json +25 -22
- package/.github/workflows/formatbot.yml +0 -63
- package/.github/workflows/release.yml +0 -40
- package/.github/workflows/test.yml +0 -32
- package/.github/workflows/windows-tests.yml +0 -32
- package/.prettierrc +0 -1
- package/DEVELOPMENT.md +0 -7
- package/api/README.md +0 -3
- package/api/db/generic-json-level.ts +0 -123
- package/api/db/get-db.ts +0 -26
- package/api/db/schema.ts +0 -65
- package/api/db/zod-level-db.ts +0 -148
- package/api/index.ts +0 -4
- package/api/lib/middlewares/with-db.ts +0 -18
- package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
- package/api/lib/middlewares/with-error-response.ts +0 -37
- package/api/lib/with-winter-spec.ts +0 -9
- package/api/lib/zod/export_parameters.ts +0 -25
- package/api/routes/api/db/download.ts +0 -25
- package/api/routes/api/dev_package_examples/create.ts +0 -43
- package/api/routes/api/dev_package_examples/get.ts +0 -46
- package/api/routes/api/dev_package_examples/list.ts +0 -36
- package/api/routes/api/dev_package_examples/update.ts +0 -59
- package/api/routes/api/dev_server/reset.ts +0 -13
- package/api/routes/api/export_files/create.ts +0 -27
- package/api/routes/api/export_files/download.ts +0 -25
- package/api/routes/api/export_requests/create.ts +0 -30
- package/api/routes/api/export_requests/get.ts +0 -43
- package/api/routes/api/export_requests/list.ts +0 -26
- package/api/routes/api/export_requests/update.ts +0 -34
- package/api/routes/api/health.ts +0 -11
- package/api/routes/api/package_info/create.ts +0 -26
- package/api/routes/api/package_info/get.ts +0 -16
- package/api/routes/health.ts +0 -11
- package/api/routes/index.ts +0 -16
- package/api/server.ts +0 -20
- package/api/static-routes.ts +0 -24
- package/api/tests/fixtures/get-test-server.ts +0 -31
- package/api/tests/fixtures/start-server.ts +0 -41
- package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
- package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
- package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
- package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
- package/api/tests/routes/export_files/create.test.ts +0 -18
- package/api/tests/routes/export_files/download.test.ts +0 -29
- package/api/tests/routes/export_requests/create.test.ts +0 -24
- package/api/tests/routes/export_requests/get.test.ts +0 -41
- package/api/tests/routes/export_requests/list.test.ts +0 -35
- package/api/tests/routes/export_requests/update.test.ts +0 -50
- package/api/tests/routes/health.test.ts +0 -10
- package/bunfig.toml +0 -2
- package/cli/cli.ts +0 -13
- package/cli/lib/cmd-fns/add.ts +0 -34
- package/cli/lib/cmd-fns/auth-login.ts +0 -59
- package/cli/lib/cmd-fns/auth-logout.ts +0 -7
- package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
- package/cli/lib/cmd-fns/config-clear.ts +0 -5
- package/cli/lib/cmd-fns/config-print-config.ts +0 -6
- package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
- package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
- package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
- package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
- package/cli/lib/cmd-fns/config-set-session.ts +0 -7
- package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
- package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
- package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
- package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
- package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
- package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
- package/cli/lib/cmd-fns/dev/index.ts +0 -168
- package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
- package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
- package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
- package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
- package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
- package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
- package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
- package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
- package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
- package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
- package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
- package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
- package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
- package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
- package/cli/lib/cmd-fns/go.ts +0 -14
- package/cli/lib/cmd-fns/index.ts +0 -46
- package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
- package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
- package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
- package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
- package/cli/lib/cmd-fns/init/index.ts +0 -193
- package/cli/lib/cmd-fns/install.ts +0 -34
- package/cli/lib/cmd-fns/lint.ts +0 -43
- package/cli/lib/cmd-fns/open.ts +0 -19
- package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
- package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
- package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
- package/cli/lib/cmd-fns/package-files-create.ts +0 -31
- package/cli/lib/cmd-fns/package-files-download.ts +0 -29
- package/cli/lib/cmd-fns/package-files-get.ts +0 -3
- package/cli/lib/cmd-fns/package-files-list.ts +0 -28
- package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
- package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
- package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
- package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
- package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
- package/cli/lib/cmd-fns/packages-create.ts +0 -16
- package/cli/lib/cmd-fns/packages-get.ts +0 -16
- package/cli/lib/cmd-fns/packages-list.ts +0 -16
- package/cli/lib/cmd-fns/publish/index.ts +0 -336
- package/cli/lib/cmd-fns/remove.ts +0 -31
- package/cli/lib/cmd-fns/render.ts +0 -45
- package/cli/lib/cmd-fns/soupify.ts +0 -31
- package/cli/lib/cmd-fns/uninstall.ts +0 -31
- package/cli/lib/cmd-fns/version.ts +0 -38
- package/cli/lib/create-config-manager.ts +0 -97
- package/cli/lib/export-fns/export-bom-csv.ts +0 -32
- package/cli/lib/export-fns/export-gerbers.ts +0 -108
- package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
- package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
- package/cli/lib/get-program.ts +0 -387
- package/cli/lib/param-handlers/index.ts +0 -21
- package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
- package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
- package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
- package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
- package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
- package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
- package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
- package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
- package/cli/lib/param-handlers/param-handler-type.ts +0 -7
- package/cli/lib/posthog.ts +0 -23
- package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
- package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
- package/cli/lib/soupify/index.ts +0 -1
- package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
- package/cli/lib/soupify/soupify-with-core.ts +0 -74
- package/cli/lib/soupify/soupify.ts +0 -6
- package/cli/lib/util/app-context.ts +0 -17
- package/cli/lib/util/create-context-and-run-program.ts +0 -168
- package/cli/lib/util/get-all-package-files.ts +0 -66
- package/cli/lib/util/lint-project.ts +0 -137
- package/cli/tests/export-gerber-keyboard.test.ts +0 -16
- package/cli/tests/export-gerber.test.ts +0 -49
- package/cli/tests/export-kicad-pcb.test.ts +0 -23
- package/cli/tests/export-pnp-csv.test.ts +0 -24
- package/cli/tests/fixtures/preload.ts +0 -54
- package/cli/tests/init.test.ts +0 -9
- package/cli/tests/open.test.ts +0 -9
- package/cli/tests/soupify-builder.test.ts +0 -9
- package/cli/tests/soupify-core.test.ts +0 -9
- package/dist/cli.js +0 -3676
- package/docs/EDIT_EVENT_PIPELINE.md +0 -34
- package/example-project/README.md +0 -18
- package/example-project/examples/basic-capacitor.tsx +0 -5
- package/example-project/examples/basic-chip.tsx +0 -26
- package/example-project/examples/basic-resistor.tsx +0 -3
- package/example-project/examples/macrokeypad.tsx +0 -59
- package/example-project/index.ts +0 -1
- package/example-project/package.json +0 -5
- package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
- package/example-project/src/Key.tsx +0 -46
- package/example-project/src/Keyswitch.tsx +0 -26
- package/example-project/src/KeyswitchSocket.tsx +0 -56
- package/example-project/src/MyCircuit.tsx +0 -38
- package/example-project/src/manual-edits.ts +0 -93
- package/frontend/README.md +0 -3
- package/frontend/bun.lockb +0 -0
- package/frontend/components/command-k.tsx +0 -86
- package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
- package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
- package/frontend/components/global-context-providers.tsx +0 -11
- package/frontend/components/select-example-search.tsx +0 -118
- package/frontend/components/ui/alert-dialog.tsx +0 -139
- package/frontend/components/ui/alert.tsx +0 -59
- package/frontend/components/ui/breadcrumb.tsx +0 -115
- package/frontend/components/ui/button.tsx +0 -57
- package/frontend/components/ui/card.tsx +0 -76
- package/frontend/components/ui/command.tsx +0 -153
- package/frontend/components/ui/context-menu.tsx +0 -202
- package/frontend/components/ui/dialog.tsx +0 -120
- package/frontend/components/ui/menubar.tsx +0 -238
- package/frontend/components/ui/navigation-menu.tsx +0 -128
- package/frontend/components/ui/popover.tsx +0 -31
- package/frontend/components/ui/select.tsx +0 -162
- package/frontend/components/ui/tabs.tsx +0 -53
- package/frontend/components/ui/toggle-group.tsx +0 -59
- package/frontend/components/ui/toggle.tsx +0 -43
- package/frontend/components/ui/tooltip.tsx +0 -28
- package/frontend/components.json +0 -17
- package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
- package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
- package/frontend/hooks/use-dev-package-examples.tsx +0 -18
- package/frontend/hooks/use-global-store.ts +0 -42
- package/frontend/index.css +0 -76
- package/frontend/index.html +0 -13
- package/frontend/lib/utils.ts +0 -6
- package/frontend/main.tsx +0 -13
- package/frontend/tailwind.config.js +0 -74
- package/frontend/views/App.tsx +0 -22
- package/frontend/views/Header.tsx +0 -55
- package/frontend/views/HeaderMenu.tsx +0 -326
- package/frontend/views/MainContentView.tsx +0 -172
- package/frontend/vite-env.d.ts +0 -1
- package/frontend/vite.config.ts +0 -50
- package/renovate.json +0 -16
- package/scripts/build-cli.ts +0 -12
- package/tsup.config.ts +0 -7
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { z } from "zod"
|
|
2
|
-
import { exportPnpCsvToBuffer } from "../export-fns/export-pnp-csv"
|
|
3
|
-
import { AppContext } from "../util/app-context"
|
|
4
|
-
import fs from "fs/promises"
|
|
5
|
-
import kleur from "kleur"
|
|
6
|
-
|
|
7
|
-
export const exportPnpCsv = async (ctx: AppContext, args: any) => {
|
|
8
|
-
const params = z
|
|
9
|
-
.object({
|
|
10
|
-
file: z.string().optional(),
|
|
11
|
-
input: z.string().optional(),
|
|
12
|
-
export: z.string().optional(),
|
|
13
|
-
outputfile: z.string().optional().default("pnp.csv"),
|
|
14
|
-
})
|
|
15
|
-
.refine((data) => data.file || data.input, {
|
|
16
|
-
message: "Either 'file' or 'input' must be provided",
|
|
17
|
-
})
|
|
18
|
-
.parse(args)
|
|
19
|
-
|
|
20
|
-
const inputFile = params.input || params.file
|
|
21
|
-
|
|
22
|
-
const pnpCsvBuffer = await exportPnpCsvToBuffer(
|
|
23
|
-
{
|
|
24
|
-
example_file_path: inputFile!,
|
|
25
|
-
export_name: params.export,
|
|
26
|
-
},
|
|
27
|
-
ctx,
|
|
28
|
-
)
|
|
29
|
-
console.log(kleur.gray(`[writing to ${params.outputfile}]...`))
|
|
30
|
-
await fs.writeFile(params.outputfile, pnpCsvBuffer)
|
|
31
|
-
console.log(kleur.green(`Pnp CSV file exported to ${params.outputfile}`))
|
|
32
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import path from "path"
|
|
2
|
-
import fs from "fs/promises"
|
|
3
|
-
import { AppContext } from "../util/app-context"
|
|
4
|
-
import { convertEasyEdaJsonToVariousFormats } from "easyeda"
|
|
5
|
-
|
|
6
|
-
export const genJlcpcbComponent = async (
|
|
7
|
-
ctx: AppContext,
|
|
8
|
-
{ partNumberOrUrl }: { partNumberOrUrl: string },
|
|
9
|
-
): Promise<void> => {
|
|
10
|
-
try {
|
|
11
|
-
const resolvedPartNumber = resolvePartNumber(partNumberOrUrl)
|
|
12
|
-
const outputDir = path.resolve(ctx.cwd, "gen")
|
|
13
|
-
const outputFile = path.join(outputDir, `${resolvedPartNumber}.tsx`)
|
|
14
|
-
|
|
15
|
-
await fs.mkdir(outputDir, { recursive: true })
|
|
16
|
-
|
|
17
|
-
await convertEasyEdaJsonToVariousFormats({
|
|
18
|
-
jlcpcbPartNumberOrFilepath: resolvedPartNumber,
|
|
19
|
-
outputFilename: outputFile,
|
|
20
|
-
formatType: "tsx",
|
|
21
|
-
})
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.error(
|
|
24
|
-
`Error generating JLCPCB component:`,
|
|
25
|
-
(error as Error).message,
|
|
26
|
-
)
|
|
27
|
-
throw error
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const PART_NUMBER_PREFIX = "C"
|
|
32
|
-
|
|
33
|
-
const resolvePartNumber = (partNumberOrUrl: string): string => {
|
|
34
|
-
if (
|
|
35
|
-
partNumberOrUrl.startsWith("http://") ||
|
|
36
|
-
partNumberOrUrl.startsWith("https://")
|
|
37
|
-
) {
|
|
38
|
-
const partNumber = extractPartNumberFromUrl(partNumberOrUrl)
|
|
39
|
-
|
|
40
|
-
if (!partNumber) {
|
|
41
|
-
throw new Error("Could not extract a valid part number from URL")
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return partNumber
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!isValidPartNumber(partNumberOrUrl)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Invalid part number: Must start with '${PART_NUMBER_PREFIX}'`,
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return partNumberOrUrl.toUpperCase()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const extractPartNumberFromUrl = (url: string): string | null => {
|
|
57
|
-
const partNumber = url.split("/").at(-1)
|
|
58
|
-
return partNumber && isValidPartNumber(partNumber)
|
|
59
|
-
? partNumber.toUpperCase()
|
|
60
|
-
: null
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const isValidPartNumber = (partNumber: string): boolean =>
|
|
64
|
-
partNumber.toUpperCase().startsWith(PART_NUMBER_PREFIX)
|
package/cli/lib/cmd-fns/go.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import type { AppContext } from "cli/lib/util/app-context"
|
|
3
|
-
import open from "open"
|
|
4
|
-
|
|
5
|
-
export const goCmd = async (ctx: AppContext, args: any) => {
|
|
6
|
-
const tutorialUrl = "https://docs.tscircuit.com/quickstart"
|
|
7
|
-
|
|
8
|
-
console.log(
|
|
9
|
-
kleur.cyan(
|
|
10
|
-
"Opening the TSCircuit Getting Started tutorial in your browser...",
|
|
11
|
-
),
|
|
12
|
-
)
|
|
13
|
-
await open(tutorialUrl)
|
|
14
|
-
}
|
package/cli/lib/cmd-fns/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export { configRevealLocation } from "./config-reveal-location"
|
|
2
|
-
export { configSetRegistry } from "./config-set-registry"
|
|
3
|
-
export { configSetSession } from "./config-set-session"
|
|
4
|
-
export { configSetRuntime } from "./config-set-runtime"
|
|
5
|
-
export { configSetLogRequests } from "./config-set-log-requests"
|
|
6
|
-
export { configPrintConfig } from "./config-print-config"
|
|
7
|
-
export { authLogin } from "./auth-login"
|
|
8
|
-
export { authLogout } from "./auth-logout"
|
|
9
|
-
export { authSessionsCreate } from "./auth-sessions-create"
|
|
10
|
-
export { authSessionsList } from "./auth-sessions-list"
|
|
11
|
-
export { authSessionsGet } from "./auth-sessions-get"
|
|
12
|
-
export { packagesList } from "./packages-list"
|
|
13
|
-
export { packagesGet } from "./packages-get"
|
|
14
|
-
export { packagesCreate } from "./packages-create"
|
|
15
|
-
export { packageFilesUploadDirectory } from "./package-files-upload-directory"
|
|
16
|
-
export { packageReleasesList } from "./package-releases-list"
|
|
17
|
-
export { packageReleasesGet } from "./package-releases-get"
|
|
18
|
-
export { packageReleasesCreate } from "./package-releases-create"
|
|
19
|
-
export { packageReleasesUpdate } from "./package-releases-update"
|
|
20
|
-
export { packageFilesList } from "./package-files-list"
|
|
21
|
-
export { packageFilesGet } from "./package-files-get"
|
|
22
|
-
export { packageFilesDownload } from "./package-files-download"
|
|
23
|
-
export { packageFilesCreate } from "./package-files-create"
|
|
24
|
-
export { packageExamplesList } from "./package-examples-list"
|
|
25
|
-
export { packageExamplesGet } from "./package-examples-get"
|
|
26
|
-
export { packageExamplesCreate } from "./package-examples-create"
|
|
27
|
-
export { publish } from "./publish"
|
|
28
|
-
export { soupifyCmd as soupify } from "./soupify"
|
|
29
|
-
export { devCmd as dev } from "./dev"
|
|
30
|
-
export { initCmd as init } from "./init"
|
|
31
|
-
export { addCmd as add } from "./add"
|
|
32
|
-
export { goCmd as go } from "./go"
|
|
33
|
-
export { removeCmd as remove } from "./remove"
|
|
34
|
-
export { installCmd as install } from "./install"
|
|
35
|
-
export { uninstallCmd as uninstall } from "./uninstall"
|
|
36
|
-
export { devServerUpload } from "./dev-server-upload"
|
|
37
|
-
export { configClear } from "./config-clear"
|
|
38
|
-
export { openCmd as open } from "./open"
|
|
39
|
-
export { versionCmd as version } from "./version"
|
|
40
|
-
export { exportGerbersCmd as exportGerbers } from "./export-gerbers"
|
|
41
|
-
export { exportPnpCsv } from "./export-pnp-csv"
|
|
42
|
-
export { exportKicadPcb } from "./export-kicad-pcb"
|
|
43
|
-
export { devServerFulfillExportRequests } from "./dev-server-fulfill-export-requests"
|
|
44
|
-
export { lintCmd as lint } from "./lint"
|
|
45
|
-
export { renderCmd as render } from "./render"
|
|
46
|
-
export { genJlcpcbComponent } from "./gen-jlcpcb-component"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { existsSync, writeFileSync } from "fs"
|
|
2
|
-
import kleur from "kleur"
|
|
3
|
-
import * as Path from "path/posix"
|
|
4
|
-
import { getGeneratedNpmrc } from "./get-generated-npmrc"
|
|
5
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
6
|
-
|
|
7
|
-
export const createOrModifyNpmrc = async (
|
|
8
|
-
{ quiet = true }: { quiet?: boolean },
|
|
9
|
-
ctx: AppContext,
|
|
10
|
-
) => {
|
|
11
|
-
const npmrcPath = Path.join(ctx.cwd, ".npmrc")
|
|
12
|
-
|
|
13
|
-
if (existsSync(npmrcPath)) {
|
|
14
|
-
// TODO check that @tsci registry is correctly set
|
|
15
|
-
if (!quiet) {
|
|
16
|
-
console.log(kleur.yellow("npmrc already exists, not doing anything"))
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
writeFileSync(npmrcPath, getGeneratedNpmrc(ctx))
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const getGeneratedReadme = ({
|
|
2
|
-
name,
|
|
3
|
-
shouldHaveProjectGeneratedNotice = false,
|
|
4
|
-
}: {
|
|
5
|
-
name: string
|
|
6
|
-
shouldHaveProjectGeneratedNotice?: boolean
|
|
7
|
-
}) => {
|
|
8
|
-
return `
|
|
9
|
-
# ${name.split("/").pop()?.split(".").pop()}
|
|
10
|
-
|
|
11
|
-
[
|
|
13
|
-
.replace("/", ".")})](https://registry.tscircuit.com/${name
|
|
14
|
-
.replace("@tsci/", "")
|
|
15
|
-
.replace(".", "/")})
|
|
16
|
-
|
|
17
|
-
${
|
|
18
|
-
shouldHaveProjectGeneratedNotice
|
|
19
|
-
? `\n\n> This project was generated using [tsci](https://github.com/tscircuit/tscircuit)\n`
|
|
20
|
-
: ""
|
|
21
|
-
}
|
|
22
|
-
To develop and view the examples, run \`tsci dev\` and open [http://127.0.0.1:3020](http://127.0.0.1:3020) in your browser.
|
|
23
|
-
|
|
24
|
-
## Developing
|
|
25
|
-
|
|
26
|
-
You should install an editor like [VS Code](https://code.visualstudio.com/) with a typescript extension. Many web developers already have this.
|
|
27
|
-
|
|
28
|
-
Usually, you'll want to develop some named circuits inside of the \`lib\` directory,
|
|
29
|
-
export them in the \`index.ts\` file, then show how to use them in the \`examples\` directory.
|
|
30
|
-
|
|
31
|
-
Any file in \`examples\` will be automatically loaded and appear in the browser preview when you run \`tsci dev\`. It auto-reloads when you make changes, no need to reload the page or re-run the command.
|
|
32
|
-
|
|
33
|
-
> [!TIP] Make sure to replace this README with some details about your project and how to use it.
|
|
34
|
-
|
|
35
|
-
## Publishing
|
|
36
|
-
|
|
37
|
-
After you're satisfied with your project, publish it on the [tscircuit registry](https://registry.tscircuit.com) with \`tsci publish\`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`.trim()
|
|
41
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const getGeneratedTsconfig = () =>
|
|
2
|
-
`
|
|
3
|
-
|
|
4
|
-
{
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
// Enable latest features
|
|
7
|
-
"lib": ["ESNext"],
|
|
8
|
-
"target": "ESNext",
|
|
9
|
-
"module": "ESNext",
|
|
10
|
-
"moduleDetection": "force",
|
|
11
|
-
"jsx": "react-jsx",
|
|
12
|
-
"allowJs": true,
|
|
13
|
-
"types": ["@tscircuit/react-fiber"],
|
|
14
|
-
"baseUrl": ".",
|
|
15
|
-
|
|
16
|
-
// Bundler mode
|
|
17
|
-
"moduleResolution": "bundler",
|
|
18
|
-
"allowImportingTsExtensions": true,
|
|
19
|
-
"verbatimModuleSyntax": true,
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
|
|
22
|
-
// Best practices
|
|
23
|
-
"strict": true,
|
|
24
|
-
"skipLibCheck": true,
|
|
25
|
-
"noFallthroughCasesInSwitch": true,
|
|
26
|
-
|
|
27
|
-
// Some stricter flags (disabled by default)
|
|
28
|
-
"noUnusedLocals": false,
|
|
29
|
-
"noUnusedParameters": false,
|
|
30
|
-
"noPropertyAccessFromIndexSignature": false
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
`.trim()
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import {
|
|
4
|
-
readFileSync,
|
|
5
|
-
writeFileSync,
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
writeFile,
|
|
9
|
-
appendFileSync,
|
|
10
|
-
} from "fs"
|
|
11
|
-
import * as Path from "node:path/posix"
|
|
12
|
-
import $ from "dax-sh"
|
|
13
|
-
import { getGeneratedReadme } from "./get-generated-readme"
|
|
14
|
-
import { getGeneratedTsconfig } from "./get-generated-tsconfig"
|
|
15
|
-
import { getGeneratedNpmrc } from "./get-generated-npmrc"
|
|
16
|
-
import { createOrModifyNpmrc } from "./create-or-modify-npmrc"
|
|
17
|
-
import prompts from "prompts"
|
|
18
|
-
|
|
19
|
-
export const initCmd = async (ctx: AppContext, args: any) => {
|
|
20
|
-
const params = z
|
|
21
|
-
.object({
|
|
22
|
-
name: z.string().optional(),
|
|
23
|
-
dir: z.string().optional(),
|
|
24
|
-
runtime: z.enum(["bun", "node"]).optional(),
|
|
25
|
-
})
|
|
26
|
-
.parse(args)
|
|
27
|
-
|
|
28
|
-
if (params.name && !params.dir) {
|
|
29
|
-
params.dir = `./${params.name.split("/").pop()}`
|
|
30
|
-
} else if (!params.dir) {
|
|
31
|
-
params.dir = `.`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!params.name) {
|
|
35
|
-
try {
|
|
36
|
-
const myAccount = await ctx.axios
|
|
37
|
-
.get("/accounts/get")
|
|
38
|
-
.then((r) => r.data.account)
|
|
39
|
-
let subName = Path.basename(params.dir)
|
|
40
|
-
if (subName === ".") {
|
|
41
|
-
subName = Path.basename(Path.resolve(params.dir))
|
|
42
|
-
}
|
|
43
|
-
params.name = `@tsci/${myAccount.github_username}.${subName}`
|
|
44
|
-
} catch (e: any) {
|
|
45
|
-
const { github_username, package_name } = await prompts([
|
|
46
|
-
{ type: "text", name: "github_username", message: "GitHub username" },
|
|
47
|
-
{ type: "text", name: "package_name", message: "Package name" },
|
|
48
|
-
])
|
|
49
|
-
params.name = `@tsci/${github_username}.${package_name}`
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let runtime = params.runtime ?? ctx.runtime
|
|
54
|
-
if (!runtime) {
|
|
55
|
-
const bunExists = $.commandExistsSync("bun")
|
|
56
|
-
|
|
57
|
-
if (bunExists) {
|
|
58
|
-
runtime = "bun"
|
|
59
|
-
} else {
|
|
60
|
-
runtime = "node"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const pkm = runtime === "bun" ? "bun" : "npm"
|
|
65
|
-
const runner = runtime === "bun" ? "bun" : "tsx"
|
|
66
|
-
|
|
67
|
-
const packageJsonExists = existsSync(Path.join(params.dir, "package.json"))
|
|
68
|
-
const dirExists = existsSync(params.dir)
|
|
69
|
-
|
|
70
|
-
if (!dirExists) {
|
|
71
|
-
console.log(`Creating directory ${params.dir}`)
|
|
72
|
-
mkdirSync(params.dir, { recursive: true })
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
process.chdir(params.dir)
|
|
76
|
-
if (!packageJsonExists) {
|
|
77
|
-
console.log(`Initializing ${pkm} project...`)
|
|
78
|
-
await $`${pkm} init -y`
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (runtime !== "bun") {
|
|
82
|
-
console.log(`Setting up project for typescript...`)
|
|
83
|
-
await $`${pkm} add -D typescript tsx`
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// TODO just allow adding "tscircuit" in the future
|
|
87
|
-
await $`${pkm} add -D tscircuit`
|
|
88
|
-
|
|
89
|
-
console.log("Changing package name...")
|
|
90
|
-
// Change package.json "name" to params.name
|
|
91
|
-
const packageJson = JSON.parse(readFileSync("package.json", "utf-8"))
|
|
92
|
-
packageJson.name = params.name
|
|
93
|
-
writeFileSync("package.json", JSON.stringify(packageJson, null, 2))
|
|
94
|
-
|
|
95
|
-
console.log('Changing adding "start" and "dev" scripts...')
|
|
96
|
-
packageJson.scripts ??= {}
|
|
97
|
-
packageJson.scripts.start = "npm run dev"
|
|
98
|
-
packageJson.scripts.dev = "tsci dev"
|
|
99
|
-
packageJson.scripts.build = "tsup ./index.ts --sourcemap --dts"
|
|
100
|
-
writeFileSync("package.json", JSON.stringify(packageJson, null, 2))
|
|
101
|
-
|
|
102
|
-
console.log('Making package type: "module"...')
|
|
103
|
-
packageJson.type = "module"
|
|
104
|
-
writeFileSync("package.json", JSON.stringify(packageJson, null, 2))
|
|
105
|
-
|
|
106
|
-
console.log(`Adding ".tscircuit" to .gitignore`)
|
|
107
|
-
appendFileSync(
|
|
108
|
-
".gitignore",
|
|
109
|
-
"\n.tscircuit\n*.__tmp_entrypoint.tsx\ndist\nnode_modules\n",
|
|
110
|
-
{
|
|
111
|
-
encoding: "utf-8",
|
|
112
|
-
flag: "a+",
|
|
113
|
-
},
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
console.log("Add .npmrc with tscircuit registry...")
|
|
117
|
-
await createOrModifyNpmrc({ quiet: false }, ctx)
|
|
118
|
-
|
|
119
|
-
console.log("Creating lib and examples directories...")
|
|
120
|
-
mkdirSync("examples", { recursive: true })
|
|
121
|
-
mkdirSync("lib", { recursive: true })
|
|
122
|
-
|
|
123
|
-
writeFileSync(
|
|
124
|
-
Path.join("lib", "MyCircuit.manual-edits.ts"),
|
|
125
|
-
`
|
|
126
|
-
/**
|
|
127
|
-
* DO NOT EDIT THIS FILE DIRECTLY!
|
|
128
|
-
*
|
|
129
|
-
* This file is automatically edited when running \`tsci dev\` and dragging things
|
|
130
|
-
* around. \`tsci dev\` searches for a file named "*.manual-edits.ts" and edits
|
|
131
|
-
* it when you e.g. move a footprint. If there are multiple files, it'll try
|
|
132
|
-
* to pick one based on context or ask.
|
|
133
|
-
*
|
|
134
|
-
* If you're not running \`tsci dev\`, you can safely edit this file.
|
|
135
|
-
*/
|
|
136
|
-
export default {
|
|
137
|
-
// Generated when this file is created, this unique identifier is used to help
|
|
138
|
-
// determine which file to edit when there are many *.manual-edits.ts files
|
|
139
|
-
manual_edit_id: "abcdef",
|
|
140
|
-
|
|
141
|
-
// Manual pcb placements, added when you drag a footprint
|
|
142
|
-
pcb_placements: [],
|
|
143
|
-
}
|
|
144
|
-
`.trim(),
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
writeFileSync(
|
|
148
|
-
Path.join("lib", "MyCircuit.tsx"),
|
|
149
|
-
`
|
|
150
|
-
import { layout } from "tscircuit"
|
|
151
|
-
import manual_edits from "./MyCircuit.manual-edits"
|
|
152
|
-
|
|
153
|
-
export const MyCircuit = () => (
|
|
154
|
-
<group layout={layout().manualEdits(manual_edits)}>
|
|
155
|
-
<resistor
|
|
156
|
-
resistance="10kohm"
|
|
157
|
-
name="R1"
|
|
158
|
-
footprint="0805"
|
|
159
|
-
/>
|
|
160
|
-
</group>
|
|
161
|
-
)
|
|
162
|
-
`.trim(),
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
writeFileSync("index.ts", `export * from "./lib/MyCircuit"`)
|
|
166
|
-
|
|
167
|
-
writeFileSync(
|
|
168
|
-
Path.join("examples", "MyExample.tsx"),
|
|
169
|
-
`
|
|
170
|
-
import { MyCircuit } from "lib/MyCircuit"
|
|
171
|
-
|
|
172
|
-
export const MyExample = () => (
|
|
173
|
-
<board width="40mm" height="40mm" pcbCenterX={0} pcbCenterY={0}>
|
|
174
|
-
<MyCircuit />
|
|
175
|
-
</board>
|
|
176
|
-
)
|
|
177
|
-
`.trim(),
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
// Override the README file
|
|
181
|
-
writeFileSync(
|
|
182
|
-
"README.md",
|
|
183
|
-
getGeneratedReadme({
|
|
184
|
-
name: params.name!,
|
|
185
|
-
shouldHaveProjectGeneratedNotice: true,
|
|
186
|
-
}),
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
// Open tsconfig.json and modify it to import the tscircuit types
|
|
190
|
-
writeFileSync("tsconfig.json", getGeneratedTsconfig())
|
|
191
|
-
|
|
192
|
-
console.log("Done! Run `tsci dev` to start developing!")
|
|
193
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
import { createOrModifyNpmrc } from "./init/create-or-modify-npmrc"
|
|
5
|
-
import $ from "dax-sh"
|
|
6
|
-
|
|
7
|
-
export const installCmd = async (ctx: AppContext, args: any) => {
|
|
8
|
-
const params = z
|
|
9
|
-
.object({
|
|
10
|
-
packages: z.array(z.string()),
|
|
11
|
-
flags: z
|
|
12
|
-
.object({ dev: z.boolean().optional().default(false) })
|
|
13
|
-
.optional()
|
|
14
|
-
.default({}),
|
|
15
|
-
})
|
|
16
|
-
.parse(args)
|
|
17
|
-
|
|
18
|
-
params.packages = params.packages.map((p) => p.replace(/^@/, ""))
|
|
19
|
-
|
|
20
|
-
await createOrModifyNpmrc({ quiet: true }, ctx)
|
|
21
|
-
|
|
22
|
-
$.cd(ctx.cwd)
|
|
23
|
-
|
|
24
|
-
const flagsString = params.flags.dev ? "--dev" : ""
|
|
25
|
-
|
|
26
|
-
const cmd = `npm install ${flagsString} ${params.packages
|
|
27
|
-
.map((p) => `@tsci/${p.replace(/\//, ".")}`)
|
|
28
|
-
.join(" ")}`
|
|
29
|
-
console.log(kleur.gray(`> ${cmd}`))
|
|
30
|
-
|
|
31
|
-
await $`npm install ${flagsString} ${params.packages
|
|
32
|
-
.map((p) => `@tsci/${p.replace(/\//, ".")}`)
|
|
33
|
-
.join(" ")}`
|
|
34
|
-
}
|
package/cli/lib/cmd-fns/lint.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import kleur from "kleur"
|
|
4
|
-
import { lintProject } from "../util/lint-project"
|
|
5
|
-
|
|
6
|
-
export const lintCmd = async (ctx: AppContext, args: any) => {
|
|
7
|
-
const params = z
|
|
8
|
-
.object({
|
|
9
|
-
fix: z.boolean().optional().default(false),
|
|
10
|
-
})
|
|
11
|
-
.parse(args)
|
|
12
|
-
|
|
13
|
-
const { cwd } = ctx
|
|
14
|
-
const { fix } = params
|
|
15
|
-
|
|
16
|
-
console.log(kleur.blue("Running tscircuit linter..."))
|
|
17
|
-
|
|
18
|
-
const results = lintProject(cwd, fix)
|
|
19
|
-
|
|
20
|
-
let errorCount = 0
|
|
21
|
-
for (const result of results) {
|
|
22
|
-
if (result.messages.length > 0) {
|
|
23
|
-
console.log(kleur.yellow(`\nFile: ${result.filePath}`))
|
|
24
|
-
for (const message of result.messages) {
|
|
25
|
-
console.log(
|
|
26
|
-
` Line ${message.line}, Column ${message.column}: ${message.message}`,
|
|
27
|
-
)
|
|
28
|
-
errorCount++
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (errorCount > 0) {
|
|
34
|
-
console.log(
|
|
35
|
-
kleur.yellow(
|
|
36
|
-
`\nFound ${errorCount} issue${errorCount === 1 ? "" : "s"} in your tscircuit code.`,
|
|
37
|
-
),
|
|
38
|
-
)
|
|
39
|
-
process.exit(1)
|
|
40
|
-
} else {
|
|
41
|
-
console.log(kleur.green("\nNo tscircuit-specific issues found!"))
|
|
42
|
-
}
|
|
43
|
-
}
|
package/cli/lib/cmd-fns/open.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "fs"
|
|
2
|
-
import kleur from "kleur"
|
|
3
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
4
|
-
import * as Path from "path/posix"
|
|
5
|
-
import open from "open"
|
|
6
|
-
|
|
7
|
-
export const openCmd = async (ctx: AppContext, args: any) => {
|
|
8
|
-
const packageJsonPath = Path.join(ctx.cwd, "package.json")
|
|
9
|
-
if (!existsSync(packageJsonPath)) {
|
|
10
|
-
console.log(kleur.red("No package.json found in current directory"))
|
|
11
|
-
process.exit(1)
|
|
12
|
-
}
|
|
13
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"))
|
|
14
|
-
|
|
15
|
-
const registryUrl = `${ctx.registry_url}/${packageJson.name.replace("@", "")}`
|
|
16
|
-
|
|
17
|
-
console.log(`Opening ${registryUrl} in your browser...`)
|
|
18
|
-
await open(registryUrl)
|
|
19
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { soupify } from "cli/lib/soupify"
|
|
2
|
-
import { AppContext } from "../util/app-context"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
import fs from "fs"
|
|
5
|
-
|
|
6
|
-
export const packageExamplesCreate = async (ctx: AppContext, args: any) => {
|
|
7
|
-
const params = z
|
|
8
|
-
.object({
|
|
9
|
-
packageNameWithVersion: z.string(),
|
|
10
|
-
file: z.string(),
|
|
11
|
-
export: z.string().optional().default("default"),
|
|
12
|
-
})
|
|
13
|
-
.parse(args)
|
|
14
|
-
|
|
15
|
-
const tscircuit_soup = await soupify(
|
|
16
|
-
{
|
|
17
|
-
filePath: params.file,
|
|
18
|
-
exportName: params.export,
|
|
19
|
-
},
|
|
20
|
-
ctx,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const fileContent = await fs.promises.readFile(params.file, "utf8")
|
|
24
|
-
|
|
25
|
-
const package_example = await ctx.axios
|
|
26
|
-
.post("/package_examples/create", {
|
|
27
|
-
package_name_with_version: params.packageNameWithVersion,
|
|
28
|
-
file_path: params.file,
|
|
29
|
-
export_name: params.export,
|
|
30
|
-
source_content: fileContent,
|
|
31
|
-
tscircuit_soup,
|
|
32
|
-
})
|
|
33
|
-
.then((r) => r.data.package_example)
|
|
34
|
-
|
|
35
|
-
console.log(package_example)
|
|
36
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
|
|
4
|
-
export const packageExamplesGet = async (ctx: AppContext, args: any) => {
|
|
5
|
-
const params = z
|
|
6
|
-
.object({
|
|
7
|
-
packageExampleId: z.string().uuid(),
|
|
8
|
-
})
|
|
9
|
-
.parse(args)
|
|
10
|
-
|
|
11
|
-
const { packageExampleId: package_example_id } = params
|
|
12
|
-
|
|
13
|
-
const package_example = await ctx.axios
|
|
14
|
-
.post("/package_examples/get", {
|
|
15
|
-
package_example_id,
|
|
16
|
-
})
|
|
17
|
-
.then((r) => r.data.package_example)
|
|
18
|
-
|
|
19
|
-
console.log(package_example)
|
|
20
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
|
|
4
|
-
export const packageExamplesList = async (ctx: AppContext, args: any) => {
|
|
5
|
-
const params = z
|
|
6
|
-
.object({
|
|
7
|
-
packageNameWithVersion: z.string(),
|
|
8
|
-
})
|
|
9
|
-
.parse(args)
|
|
10
|
-
|
|
11
|
-
const package_examples = await ctx.axios
|
|
12
|
-
.post("/package_examples/list", {
|
|
13
|
-
package_name_with_version: params.packageNameWithVersion,
|
|
14
|
-
})
|
|
15
|
-
.then((r) => r.data.package_examples)
|
|
16
|
-
|
|
17
|
-
console.log(package_examples)
|
|
18
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import * as fs from "fs/promises"
|
|
4
|
-
import kleur from "kleur"
|
|
5
|
-
|
|
6
|
-
export const packageFilesCreate = async (ctx: AppContext, args: any) => {
|
|
7
|
-
const params = z
|
|
8
|
-
.object({
|
|
9
|
-
file: z.string(),
|
|
10
|
-
packageReleaseId: z.string().optional(),
|
|
11
|
-
packageNameWithVersion: z.string().optional(),
|
|
12
|
-
})
|
|
13
|
-
.parse(args)
|
|
14
|
-
|
|
15
|
-
const { file, packageNameWithVersion, packageReleaseId } = params
|
|
16
|
-
|
|
17
|
-
const fileContent = await fs.readFile(file)
|
|
18
|
-
|
|
19
|
-
const package_file = await ctx.axios
|
|
20
|
-
.post("/package_files/create", {
|
|
21
|
-
file_path: file,
|
|
22
|
-
content_text: fileContent.toString(),
|
|
23
|
-
package_name_with_version: packageNameWithVersion,
|
|
24
|
-
package_release_id: packageReleaseId,
|
|
25
|
-
})
|
|
26
|
-
.then((r) => r.data.package_file)
|
|
27
|
-
|
|
28
|
-
console.log(
|
|
29
|
-
`Package file created ${kleur.gray(package_file.package_file_id)}`,
|
|
30
|
-
)
|
|
31
|
-
}
|