config checking
This commit is contained in:
parent
acda59303d
commit
2757998675
1
.gitingore
Normal file
1
.gitingore
Normal file
@ -0,0 +1 @@
|
|||||||
|
deno.lock
|
137
checker.tsx
137
checker.tsx
@ -115,9 +115,12 @@ export async function Install(file:string, overrideName?:string, handler?:(conte
|
|||||||
|
|
||||||
export async function Check()
|
export async function Check()
|
||||||
{
|
{
|
||||||
|
let [config, imports] = await HuntConfig();
|
||||||
|
console.log(`Checking directory "${Root}"`);
|
||||||
|
console.log("Found", config, imports);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
let [config, imports] = await HuntConfig();
|
|
||||||
//console.log(config, imports);
|
//console.log(config, imports);
|
||||||
if(!config.path)
|
if(!config.path)
|
||||||
{
|
{
|
||||||
@ -181,63 +184,25 @@ export async function Check()
|
|||||||
await bake(imports);
|
await bake(imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!importMap[">able/app.tsx"])
|
const tasks:Record<string, string> = {
|
||||||
{
|
"check": `deno run -A --no-lock ${RootHost}cli.tsx check`,
|
||||||
if(confirm(`🤔 OPTIONAL: Your import map does not override the default/empty FRONT-END app with the specifier ">able/app.tsx". Create this file and add the specifier?`))
|
"local": `deno run -A --no-lock ${RootHost}cli.tsx local`,
|
||||||
{
|
"debug": `deno run -A --no-lock ${RootHost}cli.tsx debug`,
|
||||||
importMap[">able/app.tsx"] = `./app.tsx`;
|
"serve": `deno run -A --no-lock ${RootHost}cli.tsx serve`,
|
||||||
await bake(imports);
|
"cloud": `deno run -A --no-lock ${RootHost}cli.tsx cloud`
|
||||||
await Install("app.tsx");
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const app = await import(importMap[">able/app.tsx"]);
|
|
||||||
// @ts-ignore
|
|
||||||
const result = app.default().$$typeof;
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
console.log(e);
|
|
||||||
if(confirm(`🚧 Your FRONT-END app ("${importMap[">able/app.tsx"]}") does not export a default function that returns VDOM nodes. Replace it?`))
|
|
||||||
{
|
|
||||||
await Install("app.tsx", importMap[">able/app.tsx"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw("⛔ Your FRONT-END app has incorrect export types.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!importMap[">able/api.tsx"])
|
const confTasks = (config.json.tasks || {}) as Record<string, string>;
|
||||||
|
for(const key in tasks)
|
||||||
{
|
{
|
||||||
if(confirm(`🤔 OPTIONAL: Your import map does not override the default/empty BACK-END api with the specifier ">able/api.tsx". Create this file and add the specifier?`))
|
if(tasks[key] !== confTasks[key])
|
||||||
{
|
{
|
||||||
importMap[">able/api.tsx"] = "./api.tsx";
|
if(confirm(`🤔 OPTIONAL: The tasks defined in your config contain missing or modified values. Update tasks?`))
|
||||||
await bake(imports);
|
|
||||||
await Install("api.tsx");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const api = await import(importMap[">able/api.tsx"]);
|
|
||||||
const result = api.default(new Request(new URL("https://fake-deno-testing-domain.com/")));
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
if(confirm(`🚧 Your starter backend app ("${importMap[">able/api.tsx"]}") does not export a default function that accepts a Request. Replace it?`))
|
|
||||||
{
|
{
|
||||||
await Install("api.tsx", importMap[">able/api.tsx"]);
|
config.json.tasks = {...confTasks, ...tasks};
|
||||||
}
|
await bake(config);
|
||||||
else
|
|
||||||
{
|
|
||||||
throw("⛔ Starter backend app has incorrect export types.");
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +232,70 @@ export async function Check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!importMap[">able/app.tsx"])
|
||||||
|
{
|
||||||
|
if(confirm(`🤔 OPTIONAL: Your import map does not override the default/empty FRONT-END app with the specifier ">able/app.tsx". Create this file and add the specifier?`))
|
||||||
|
{
|
||||||
|
importMap[">able/app.tsx"] = `./app.tsx`;
|
||||||
|
await bake(imports);
|
||||||
|
await Install("app.tsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const app = await import(importMap[">able/app.tsx"]);
|
||||||
|
// @ts-ignore
|
||||||
|
const result = app.default().$$typeof;
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
console.log(e);
|
||||||
|
if(confirm(`🚧 Your FRONT-END app ("${importMap[">able/app.tsx"]}") does not export a default function that returns VDOM nodes. Replace it?`))
|
||||||
|
{
|
||||||
|
await Install("app.tsx", importMap[">able/app.tsx"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw("⛔ Your FRONT-END app has incorrect export types.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!importMap[">able/api.tsx"])
|
||||||
|
{
|
||||||
|
if(confirm(`🤔 OPTIONAL: Your import map does not override the default/empty BACK-END api with the specifier ">able/api.tsx". Create this file and add the specifier?`))
|
||||||
|
{
|
||||||
|
importMap[">able/api.tsx"] = "./api.tsx";
|
||||||
|
await bake(imports);
|
||||||
|
await Install("api.tsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const api = await import(importMap[">able/api.tsx"]);
|
||||||
|
const result = api.default(new Request(new URL("https://fake-deno-testing-domain.com/")));
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
if(confirm(`🚧 Your starter backend app ("${importMap[">able/api.tsx"]}") does not export a default function that accepts a Request. Replace it?`))
|
||||||
|
{
|
||||||
|
await Install("api.tsx", importMap[">able/api.tsx"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw("⛔ Starter backend app has incorrect export types.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
@ -277,5 +306,3 @@ export async function Check()
|
|||||||
console.log(`🚗 Good to go!`);
|
console.log(`🚗 Good to go!`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Check();
|
|
23
cli.tsx
23
cli.tsx
@ -35,7 +35,6 @@ const collect =async(inKey:string, inArg:Record<string, string>, inEnv:Record<st
|
|||||||
return scanUser;
|
return scanUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export async function SubProcess(args:string[])
|
export async function SubProcess(args:string[])
|
||||||
{
|
{
|
||||||
const command = new Deno.Command(
|
const command = new Deno.Command(
|
||||||
@ -61,6 +60,8 @@ export async function SubProcess(args:string[])
|
|||||||
// manually close stdin
|
// manually close stdin
|
||||||
child.stdin.close();
|
child.stdin.close();
|
||||||
const status = await child.status;
|
const status = await child.status;
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arg._.length)
|
if(arg._.length)
|
||||||
@ -70,15 +71,29 @@ if(arg._.length)
|
|||||||
|
|
||||||
switch(arg._[0])
|
switch(arg._[0])
|
||||||
{
|
{
|
||||||
case "work" :
|
case "check" :
|
||||||
|
case "setup" :
|
||||||
|
{
|
||||||
|
await Check();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "local" :
|
||||||
{
|
{
|
||||||
await SubProcess(["run", `--config=${config.path}`, RootHost+"run.tsx", "--dev", ...Deno.args]);
|
await SubProcess(["run", `--config=${config.path}`, RootHost+"run.tsx", "--dev", ...Deno.args]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "host" :
|
case "debug" :
|
||||||
|
{
|
||||||
|
await SubProcess(["run", `--config=${config.path}`, `--inspect-brk`, RootHost+"run.tsx", "--dev", ...Deno.args]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "serve" :
|
||||||
{
|
{
|
||||||
await SubProcess(["run", `--config=${config.path}`, RootHost+"run.tsx", ...Deno.args]);
|
await SubProcess(["run", `--config=${config.path}`, RootHost+"run.tsx", ...Deno.args]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "push" :
|
case "cloud" :
|
||||||
{
|
{
|
||||||
let useToken = await collect("DENO_DEPLOY_TOKEN", arg, env);
|
let useToken = await collect("DENO_DEPLOY_TOKEN", arg, env);
|
||||||
let useProject = await collect("DENO_DEPLOY_PROJECT", arg, env);
|
let useProject = await collect("DENO_DEPLOY_PROJECT", arg, env);
|
||||||
|
@ -2,9 +2,16 @@
|
|||||||
"imports": {
|
"imports": {
|
||||||
"react": "https://esm.sh/preact@10.16.0/compat",
|
"react": "https://esm.sh/preact@10.16.0/compat",
|
||||||
"react/": "https://esm.sh/preact@10.16.0/compat/",
|
"react/": "https://esm.sh/preact@10.16.0/compat/",
|
||||||
">able/": "file:///C:/Web%20Projects/able-baker/",
|
">able/": "http://localhost:4507/",
|
||||||
">able/app.tsx": "./app.tsx"
|
">able/app.tsx": "./app.tsx"
|
||||||
},
|
},
|
||||||
|
"tasks": {
|
||||||
|
"check": "deno run -A --no-lock http://localhost:4507/cli.tsx check",
|
||||||
|
"local": "deno run -A --no-lock http://localhost:4507/cli.tsx local",
|
||||||
|
"debug": "deno run -A --no-lock http://localhost:4507/cli.tsx debug",
|
||||||
|
"serve": "deno run -A --no-lock http://localhost:4507/cli.tsx serve",
|
||||||
|
"cloud": "deno run -A --no-lock http://localhost:4507/cli.tsx cloud"
|
||||||
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "react",
|
"jsxImportSource": "react",
|
||||||
|
@ -17,16 +17,6 @@ const ImportMapReload =async()=>
|
|||||||
|
|
||||||
if(imports)
|
if(imports)
|
||||||
{
|
{
|
||||||
if(imports["react"])
|
|
||||||
{
|
|
||||||
console.log(`"react" specifier not defined in import map`);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(!imports["react/"])
|
|
||||||
{
|
|
||||||
imports["react/"] = imports["react"]+"/";
|
|
||||||
}
|
|
||||||
|
|
||||||
ImportMapProxies = {};
|
ImportMapProxies = {};
|
||||||
Object.entries(imports).forEach(([key, value])=>
|
Object.entries(imports).forEach(([key, value])=>
|
||||||
{
|
{
|
||||||
|
7
sub.tsx
7
sub.tsx
@ -1,7 +0,0 @@
|
|||||||
import { parse } from "https://deno.land/std@0.194.0/flags/mod.ts";
|
|
||||||
|
|
||||||
let arg = parse(Deno.args);
|
|
||||||
|
|
||||||
console.log(arg);
|
|
||||||
|
|
||||||
console.log(Deno.env.get("super"))
|
|
37
sup.tsx
37
sup.tsx
@ -1,37 +0,0 @@
|
|||||||
import * as Env from "https://deno.land/std@0.194.0/dotenv/mod.ts";
|
|
||||||
import * as Arg from "https://deno.land/std@0.194.0/flags/mod.ts";
|
|
||||||
|
|
||||||
let arg = Arg.parse(Deno.args);
|
|
||||||
let env = await Env.load();
|
|
||||||
|
|
||||||
Deno.env.set("super", "its super");
|
|
||||||
|
|
||||||
export async function SubProcess(args:string[])
|
|
||||||
{
|
|
||||||
const command = new Deno.Command(
|
|
||||||
`deno`,
|
|
||||||
{
|
|
||||||
args,
|
|
||||||
stdin: "piped",
|
|
||||||
stdout: "piped"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const child = command.spawn();
|
|
||||||
|
|
||||||
// open a file and pipe the subprocess output to it.
|
|
||||||
const writableStream = new WritableStream({
|
|
||||||
write(chunk: Uint8Array): Promise<void> {
|
|
||||||
Deno.stdout.write(chunk);
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
child.stdout.pipeTo(writableStream);
|
|
||||||
|
|
||||||
// manually close stdin
|
|
||||||
child.stdin.close();
|
|
||||||
const status = await child.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SubProcess(["run", "-A", "sub.tsx", "keyword!", "--passed=yep"]);
|
|
Loading…
Reference in New Issue
Block a user