Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Octo8080X committed Jan 7, 2024
1 parent 14efd40 commit cd22efa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
19 changes: 11 additions & 8 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { ensureDirSync } from "https://deno.land/[email protected]/fs/ensure_dir.ts";
import { existsSync } from "https://deno.land/[email protected]/fs/exists.ts";

const parsedArgs = parseArgs(Deno.args);
if(!parsedArgs["_"][0]) {
console.error("\u001b[31m[ERROR]:Please input resource name. ex cli.ts user\u001b[0m");
if (!parsedArgs["_"][0]) {
console.error(
"\u001b[31m[ERROR]:Please input resource name. ex cli.ts user\u001b[0m",
);
Deno.exit(1);
}

Expand All @@ -13,7 +15,7 @@ ensureDirSync(`./plantation/${parsedArgs["_"][0]}`);

// ./plantation/extra_load.tsx が存在しなければ作成する
if (!existsSync(`./plantation/extra_load.tsx`)) {
const souceText = "console.log('Load ./plantation!');\n"
const souceText = "console.log('Load ./plantation!');\n";

Deno.writeTextFileSync(
`./plantation/extra_load.ts`,
Expand All @@ -22,7 +24,6 @@ if (!existsSync(`./plantation/extra_load.tsx`)) {
console.info(`✅ Create File: ./plantation/extra_load.ts`);
}


const create = await fetch(
"https://deno.land/x/[email protected]/routesTemplate/create.tsx?source=",
);
Expand All @@ -35,7 +36,7 @@ console.info(`✅ Create File: ${createFilePath}`);
Deno.writeTextFileSync(
`./plantation/extra_load.ts`,
`(async () => await import('.${createFilePath}'));\n`,
{append: true}
{ append: true },
);

const login = await fetch(
Expand All @@ -51,7 +52,7 @@ console.info(`✅ Create File: ${loginFilePath}`);
Deno.writeTextFileSync(
`./plantation/extra_load.ts`,
`(async () => await import('.${loginFilePath}'));\n`,
{append: true}
{ append: true },
);
const logout = await fetch(
"https://raw.githubusercontent.com/Octo8080X/plantation/main/routesTemplate/logout.tsx",
Expand All @@ -66,7 +67,9 @@ console.info(`✅ Create File: ${logoutFilePath}`);
Deno.writeTextFileSync(
`./plantation/extra_load.ts`,
`(async () => await import('.${logoutFilePath}'));\n`,
{append: true}
{ append: true },
);

console.info(`Please add \`(async () => await import('./plantation/extra_loader.ts'));\` to your main.ts.`);
console.info(
`Please add \`(async () => await import('./plantation/extra_loader.ts'));\` to your main.ts.`,
);
4 changes: 1 addition & 3 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ export {
type WithCsrf,
} from "https://deno.land/x/[email protected]/mod.ts";
export { h, type JSX } from "https://esm.sh/[email protected]";
export {
setCookie,
} from "https://deno.land/[email protected]/http/cookie.ts";
export { setCookie } from "https://deno.land/[email protected]/http/cookie.ts";
3 changes: 1 addition & 2 deletions routesTemplate/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
} from "https://deno.land/x/plantation/templateDeps.ts";

export function getLogoutHandler(
{ auth, logoutAfterPath }:
PlantationInnerParams,
{ auth, logoutAfterPath }: PlantationInnerParams,
): Handlers<unknown, WithCsrf> {
return {
async POST(req: Request, ctx: FreshContext<WithCsrf>) {
Expand Down
10 changes: 2 additions & 8 deletions src/routes/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import {
FreshContext,
Handlers,
setCookie,
WithCsrf,
} from "../../deps.ts";
import { FreshContext, Handlers, setCookie, WithCsrf } from "../../deps.ts";
import { PlantationInnerParams } from "../../types.ts";

export function getLogoutHandler(
{ auth, logoutAfterPath }:
PlantationInnerParams,
{ auth, logoutAfterPath }: PlantationInnerParams,
): Handlers<unknown, WithCsrf> {
return {
async POST(req: Request, ctx: FreshContext<WithCsrf>) {
Expand Down

0 comments on commit cd22efa

Please sign in to comment.