mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
added aws lambda adapter + improvements to handle concurrency
This commit is contained in:
36
app/src/cli/commands/copy-assets.ts
Normal file
36
app/src/cli/commands/copy-assets.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { getRelativeDistPath } from "cli/utils/sys";
|
||||
import type { CliCommand } from "../types";
|
||||
import { Option } from "commander";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import c from "picocolors";
|
||||
|
||||
export const copyAssets: CliCommand = (program) => {
|
||||
program
|
||||
.command("copy-assets")
|
||||
.description("copy static assets")
|
||||
.addOption(new Option("-o --out <directory>", "directory to copy to"))
|
||||
.addOption(new Option("-c --clean", "clean the output directory"))
|
||||
.action(action);
|
||||
};
|
||||
|
||||
async function action(options: { out?: string; clean?: boolean }) {
|
||||
const out = options.out ?? "static";
|
||||
|
||||
// clean "out" directory
|
||||
if (options.clean) {
|
||||
await fs.rm(out, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
// recursively copy from src/assets to out using node fs
|
||||
const from = path.resolve(getRelativeDistPath(), "static");
|
||||
await fs.cp(from, out, { recursive: true });
|
||||
|
||||
// in out, move ".vite/manifest.json" to "manifest.json"
|
||||
await fs.rename(path.resolve(out, ".vite/manifest.json"), path.resolve(out, "manifest.json"));
|
||||
|
||||
// delete ".vite" directory in out
|
||||
await fs.rm(path.resolve(out, ".vite"), { recursive: true });
|
||||
|
||||
console.log(c.green(`Assets copied to: ${c.bold(out)}`));
|
||||
}
|
||||
@@ -4,3 +4,4 @@ export { run } from "./run";
|
||||
export { debug } from "./debug";
|
||||
export { user } from "./user";
|
||||
export { create } from "./create";
|
||||
export { copyAssets } from "./copy-assets";
|
||||
|
||||
Reference in New Issue
Block a user