-
Notifications
You must be signed in to change notification settings - Fork 12
Add flag #93
Add flag #93
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import { AppContext } from "../util/app-context" | ||
import kleur from "kleur" | ||
import { z } from "zod" | ||
import { AppContext } from "../util/app-context" | ||
import { getDevServerAxios } from "./dev/get-dev-server-axios" | ||
import { uploadExamplesFromDirectory } from "./dev/upload-examples-from-directory" | ||
import { startFsWatcher } from "./dev/start-fs-watcher" | ||
import kleur from "kleur" | ||
import { AxiosInstance } from "axios" | ||
import { uploadExamplesFromDirectory } from "./dev/upload-examples-from-directory" | ||
|
||
export const devServerUpload = async (ctx: AppContext, args: any) => { | ||
const params = z | ||
.object({ | ||
dir: z.string().optional().default(ctx.cwd), | ||
port: z.coerce.number().optional().nullable().default(null), | ||
watch: z.boolean().optional().default(false), | ||
no_cleanup: z.boolean().optional().default(true), | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not default to true |
||
.parse(args) | ||
|
||
ctx.args.no_cleanup = params.no_cleanup | ||
|
||
let serverUrl = `http://localhost:${params.port ?? 3020}` | ||
let devServerAxios = getDevServerAxios({ serverUrl }) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ export const soupifyAndUploadExampleFile = async ( | |
exampleFileName: string | ||
devServerAxios: AxiosInstance | ||
}, | ||
ctx: { runtime: "node" | "bun" } | ||
ctx: { | ||
runtime: "node" | "bun", | ||
args: { no_cleanup: boolean } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. args is too generic. Rename to cliArgs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also use camelCase since thats the convention from other |
||
} | ||
) => { | ||
try { | ||
const startTime = Date.now() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,26 @@ export const uploadExamplesFromDirectory = async ( | |
devServerAxios, | ||
}: { | ||
cwd: string | ||
devServerAxios: AxiosInstance | ||
devServerAxios: AxiosInstance, | ||
}, | ||
ctx: { runtime: "node" | "bun" } | ||
ctx: { | ||
runtime: "node" | "bun", | ||
args: { no_cleanup: boolean } | ||
} | ||
) => { | ||
const examplesDir = joinPath(cwd, "examples") | ||
const exampleFileNames = await readdir(examplesDir).catch((e) => { | ||
console.log(kleur.red(`Error reading examples directory: "${examplesDir}"`)) | ||
throw e | ||
}) | ||
|
||
const no_cleanup = ctx.args.no_cleanup | ||
|
||
// Mark all examples as being "reloaded" in the database | ||
await markAllExamplesLoading({ devServerAxios }) | ||
|
||
for (const exampleFileName of exampleFileNames) { | ||
if (exampleFileName.endsWith(".__tmp_entrypoint.tsx")) continue | ||
if (exampleFileName.endsWith(".__tmp_entrypoint.tsx") && !no_cleanup) continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should revert, doesnt make sense, the idea with this loop is to ignore entrypoint files, doesnt make sense to have the cleanup flag change that behavior |
||
if (!exampleFileName.endsWith(".tsx")) continue | ||
await soupifyAndUploadExampleFile( | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import kleur from "kleur" | ||
import { z } from "zod" | ||
import { AppContext } from "../../util/app-context" | ||
import * as Path from "path" | ||
import * as fs from "fs/promises" | ||
import $ from "dax-sh" | ||
import { existsSync, readFileSync } from "fs" | ||
import * as fs from "fs/promises" | ||
import { unlink } from "fs/promises" | ||
import kleur from "kleur" | ||
import { getAllPackageFiles } from "lib/util/get-all-package-files" | ||
import * as Path from "path" | ||
import prompts from "prompts" | ||
import { getGeneratedReadme } from "../init/get-generated-readme" | ||
import semver from "semver" | ||
import { z } from "zod" | ||
import { soupify } from "../../soupify" | ||
import { AppContext } from "../../util/app-context" | ||
import { inferExportNameFromSource } from "../dev/infer-export-name-from-source" | ||
import $ from "dax-sh" | ||
import semver from "semver" | ||
import { unlink } from "fs/promises" | ||
import esbuild from "esbuild" | ||
import { getGeneratedReadme } from "../init/get-generated-readme" | ||
|
||
export const publish = async (ctx: AppContext, args: any) => { | ||
const params = z | ||
.object({ | ||
increment: z.boolean().optional(), | ||
patch: z.boolean().optional(), | ||
lock: z.boolean().optional(), | ||
no_cleanup: z.boolean().optional().default(true), | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not be on this command. Only put on "tsci dev" command |
||
.parse(args) | ||
|
||
|
@@ -269,6 +269,7 @@ export const publish = async (ctx: AppContext, args: any) => { | |
{ | ||
filePath, | ||
exportName, | ||
no_cleanup: params.no_cleanup, | ||
}, | ||
ctx | ||
).catch((e) => e) | ||
|
@@ -298,11 +299,10 @@ export const publish = async (ctx: AppContext, args: any) => { | |
`${name.replace(/\//g, "-")}-${version}.tgz` | ||
) | ||
await fs.mkdir(Path.dirname(tmpTarballPath), { recursive: true }) | ||
const npm_pack_outputs = await $`cd ${ | ||
ctx.cwd | ||
} && npm pack --json --pack-destination ${Path.dirname( | ||
tmpTarballPath | ||
)}`.json() | ||
const npm_pack_outputs = await $`cd ${ctx.cwd | ||
} && npm pack --json --pack-destination ${Path.dirname( | ||
tmpTarballPath | ||
)}`.json() | ||
|
||
if (!existsSync(tmpTarballPath)) { | ||
console.log(kleur.red(`Couldn't find tarball at ${tmpTarballPath}`)) | ||
|
@@ -319,7 +319,9 @@ export const publish = async (ctx: AppContext, args: any) => { | |
}) | ||
|
||
// Clean up .tscircuit/tmp | ||
await unlink(tmpTarballPath) | ||
if (!params.no_cleanup) { | ||
await unlink(tmpTarballPath) | ||
} | ||
|
||
// 8. Lock/set release to latest version | ||
await ctx.axios.post("/package_releases/update", { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { AppContext } from "../util/app-context" | ||
import { z } from "zod" | ||
import * as Path from "path" | ||
import { unlink } from "node:fs/promises" | ||
import { soupify } from "lib/soupify" | ||
import * as fs from "fs" | ||
import { | ||
stringifyGerberCommandLayers, | ||
convertSoupToGerberCommands, | ||
convertSoupToPickAndPlaceCsv, | ||
convertSoupToPickAndPlaceCsv | ||
} from "@tscircuit/builder" | ||
import kleur from "kleur" | ||
import archiver from "archiver" | ||
import { soupify } from "lib/soupify" | ||
import { AppContext } from "../util/app-context" | ||
|
||
export const exportPnpCsvToBuffer = async ( | ||
params: { | ||
example_file_path: string | ||
export_name?: string | ||
no_cleanup: boolean | ||
}, | ||
ctx: AppContext | ||
) => { | ||
|
@@ -24,6 +18,7 @@ export const exportPnpCsvToBuffer = async ( | |
{ | ||
filePath: params.example_file_path, | ||
exportName: params.export_name, | ||
no_cleanup: params.no_cleanup, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesnt match naming convention |
||
ctx | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { Command } from "commander" | ||
import packageJson from "../package.json" | ||
import { AppContext } from "./util/app-context" | ||
import * as CMDFN from "lib/cmd-fns" | ||
import { AppContext } from "./util/app-context" | ||
|
||
export const getProgram = (ctx: AppContext) => { | ||
const cmd = new Command("tsci").description( | ||
|
@@ -13,6 +12,7 @@ export const getProgram = (ctx: AppContext) => { | |
.description("Run development server in current directory") | ||
.option("--cwd <cwd>", "Current working directory") | ||
.option("--port <port>", "Port to run dev server on") | ||
.option("--no-cleanup", "Don't delete the temporary directory", true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not default to true |
||
.action((args) => CMDFN.dev(ctx, args)) | ||
|
||
cmd | ||
|
@@ -313,11 +313,13 @@ export const getProgram = (ctx: AppContext) => { | |
) | ||
.option("-w, --watch", "Watch for changes") | ||
.option("-p, --port", "Port dev server is running on (default: 3020)") | ||
.option("--no-cleanup", "Don't delete the temporary directory", true) | ||
.action((args) => CMDFN.devServerUpload(ctx, args)) | ||
|
||
devServerCmd | ||
.command("fulfill-export-requests") | ||
.action((args) => CMDFN.devServerFulfillExportRequests(ctx, args)) | ||
.option("--no-cleanup", "Don't delete the temporary directory", true) | ||
.action(() => CMDFN.devServerFulfillExportRequests(ctx)) | ||
|
||
cmd | ||
.command("open") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should revert, no reason to change this file afaik