mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
cloudflare update assets dir
This commit is contained in:
@@ -172,25 +172,29 @@ async function action(options: { template?: string; dir?: string; integration?:
|
|||||||
const ctx = { template, dir: downloadOpts.dir };
|
const ctx = { template, dir: downloadOpts.dir };
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// @todo: only while in PR
|
||||||
|
const ref = "feat/cli-starters";
|
||||||
|
//const ref = `v${version}`;
|
||||||
|
|
||||||
const prefix =
|
const prefix =
|
||||||
template.ref === true
|
template.ref === true
|
||||||
? `#v${version}`
|
? `#${ref}`
|
||||||
: typeof template.ref === "string"
|
: typeof template.ref === "string"
|
||||||
? `#${template.ref}`
|
? `#${template.ref}`
|
||||||
: "";
|
: "";
|
||||||
const url = `${template.path}${prefix}`;
|
const url = `${template.path}${prefix}`;
|
||||||
|
|
||||||
console.log("url", url);
|
//console.log("url", url);
|
||||||
const s = $p.spinner();
|
const s = $p.spinner();
|
||||||
s.start("Downloading template...");
|
s.start("Downloading template...");
|
||||||
const result = await downloadTemplate(url, {
|
const result = await downloadTemplate(url, {
|
||||||
dir: ctx.dir,
|
dir: ctx.dir,
|
||||||
force: downloadOpts.clean ? "clean" : true
|
force: downloadOpts.clean ? "clean" : true
|
||||||
});
|
});
|
||||||
console.log("result", result);
|
//console.log("result", result);
|
||||||
|
|
||||||
s.stop("Template downloaded.");
|
s.stop("Template downloaded.");
|
||||||
await updateBkndPackages({ dir: ctx.dir });
|
await updateBkndPackages(ctx.dir);
|
||||||
|
|
||||||
if (template.preinstall) {
|
if (template.preinstall) {
|
||||||
await template.preinstall(ctx);
|
await template.preinstall(ctx);
|
||||||
|
|||||||
@@ -65,11 +65,18 @@ export async function replacePackageJsonVersions(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateBkndPackages(opts?: { dir?: string }) {
|
export async function updateBkndPackages(dir?: string, map?: Record<string, string>) {
|
||||||
await replacePackageJsonVersions(async (pkg) => {
|
const versions = {
|
||||||
if (pkg === "bknd") {
|
bknd: "^" + (await getVersion("bknd")),
|
||||||
return "^" + (await getVersion(pkg));
|
...(map ?? {})
|
||||||
|
};
|
||||||
|
await replacePackageJsonVersions(
|
||||||
|
async (pkg) => {
|
||||||
|
if (pkg in versions) {
|
||||||
|
return versions[pkg];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}, opts);
|
},
|
||||||
|
{ dir }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,18 @@ export const cloudflare = {
|
|||||||
path: "gh:bknd-io/bknd/examples/cloudflare-worker",
|
path: "gh:bknd-io/bknd/examples/cloudflare-worker",
|
||||||
ref: true,
|
ref: true,
|
||||||
setup: async (ctx) => {
|
setup: async (ctx) => {
|
||||||
|
// overwrite assets directory
|
||||||
|
await overrideJson(
|
||||||
|
"wrangler.json",
|
||||||
|
(json) => ({
|
||||||
|
...json,
|
||||||
|
assets: {
|
||||||
|
directory: "node_modules/bknd/dist/static"
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
{ dir: ctx.dir }
|
||||||
|
);
|
||||||
|
|
||||||
const db = await $p.select({
|
const db = await $p.select({
|
||||||
message: "What database do you want to use?",
|
message: "What database do you want to use?",
|
||||||
options: [
|
options: [
|
||||||
|
|||||||
Reference in New Issue
Block a user