Added CLI
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
import * as $_apps_layout from "./routes/(apps)/_layout.tsx";
|
import * as $_apps_layout from "./routes/(apps)/_layout.tsx";
|
||||||
import * as $_apps_mobility_index from "./routes/(apps)/mobility/index.tsx";
|
import * as $_apps_mobility_index from "./routes/(apps)/mobility/index.tsx";
|
||||||
import * as $_apps_mobility_partials_index from "./routes/(apps)/mobility/partials/index.tsx";
|
import * as $_apps_mobility_partials_index from "./routes/(apps)/mobility/partials/index.tsx";
|
||||||
import * as $_apps_notes_api_example from "./routes/(apps)/notes/api/example.ts";
|
|
||||||
import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx";
|
import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx";
|
||||||
import * as $_apps_notes_partials_admin_courses from "./routes/(apps)/notes/partials/(admin)/courses.tsx";
|
import * as $_apps_notes_partials_admin_courses from "./routes/(apps)/notes/partials/(admin)/courses.tsx";
|
||||||
import * as $_apps_notes_partials_admin_students from "./routes/(apps)/notes/partials/(admin)/students.tsx";
|
import * as $_apps_notes_partials_admin_students from "./routes/(apps)/notes/partials/(admin)/students.tsx";
|
||||||
@@ -29,7 +28,6 @@ const manifest = {
|
|||||||
"./routes/(apps)/mobility/index.tsx": $_apps_mobility_index,
|
"./routes/(apps)/mobility/index.tsx": $_apps_mobility_index,
|
||||||
"./routes/(apps)/mobility/partials/index.tsx":
|
"./routes/(apps)/mobility/partials/index.tsx":
|
||||||
$_apps_mobility_partials_index,
|
$_apps_mobility_partials_index,
|
||||||
"./routes/(apps)/notes/api/example.ts": $_apps_notes_api_example,
|
|
||||||
"./routes/(apps)/notes/index.tsx": $_apps_notes_index,
|
"./routes/(apps)/notes/index.tsx": $_apps_notes_index,
|
||||||
"./routes/(apps)/notes/partials/(admin)/courses.tsx":
|
"./routes/(apps)/notes/partials/(admin)/courses.tsx":
|
||||||
$_apps_notes_partials_admin_courses,
|
$_apps_notes_partials_admin_courses,
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Handlers } from "$fresh/server.ts";
|
|
||||||
|
|
||||||
export const handler: Handlers = {
|
|
||||||
async GET(request, context) {
|
|
||||||
return new Response({
|
|
||||||
test: await request.json(),
|
|
||||||
context,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
+29
-14
@@ -1,4 +1,9 @@
|
|||||||
export async function createModule(name: string): Promise<void> {
|
export async function createModule(name: string): Promise<void> {
|
||||||
|
if (!name.match(/^[a-zA-Z0-9](?:(?:\-(?!\-))?[a-zA-Z0-9]*)*[a-zA-Z0-9]$/)) {
|
||||||
|
console.error("Module names must be in kebab case.");
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Checking for module ${name}...`);
|
console.log(`Checking for module ${name}...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -12,9 +17,10 @@ export async function createModule(name: string): Promise<void> {
|
|||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const capitalizedName = `${name[0].toUpperCase()}${
|
const capitalizedName = name.match(/(^\w)|(\-\w)/g)!.reduce(
|
||||||
name.substring(1).toLowerCase()
|
(word, pattern) => word.replace(pattern, pattern.at(-1)!.toUpperCase()),
|
||||||
}`;
|
name,
|
||||||
|
);
|
||||||
|
|
||||||
Promise.allSettled([
|
Promise.allSettled([
|
||||||
createDir(`routes/(apps)/${name}/(_props)`),
|
createDir(`routes/(apps)/${name}/(_props)`),
|
||||||
@@ -106,20 +112,29 @@ function getPropsContent(name: string) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApiExampleContent(name: string) {
|
function getApiExampleContent(_name: string) {
|
||||||
return `
|
return `
|
||||||
import { AppProperties } from "$root/defaults/interfaces.ts";
|
import { Handlers } from "$fresh/server.ts";
|
||||||
|
|
||||||
const properties: AppProperties = {
|
export const handler: Handlers = {
|
||||||
name: "${name}",
|
async POST(request, context) {
|
||||||
icon: "school",
|
if (request.headers.get("content-type") != "application/json") {
|
||||||
pages: {
|
return new Response(null, {
|
||||||
index: "Homepage",
|
status: 400
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseBody = {
|
||||||
|
requestBody: await request.json(),
|
||||||
|
context,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(responseBody), {
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
adminOnly: [],
|
|
||||||
hint: "PolyMPR module",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default properties;
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ export async function listModules(): Promise<void> {
|
|||||||
console.log(path.name);
|
console.log(path.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user