cli #6
							
								
								
									
										1
									
								
								.gitingore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitingore
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
deno.lock
 | 
			
		||||
							
								
								
									
										139
									
								
								checker.tsx
									
									
									
									
									
								
							
							
						
						
									
										139
									
								
								checker.tsx
									
									
									
									
									
								
							@ -115,9 +115,12 @@ export async function Install(file:string, overrideName?:string, handler?:(conte
 | 
			
		||||
 | 
			
		||||
export async function Check()
 | 
			
		||||
{
 | 
			
		||||
    let [config, imports] = await HuntConfig();
 | 
			
		||||
    console.log(`Checking directory "${Root}"`);
 | 
			
		||||
    console.log("Found", config, imports);
 | 
			
		||||
    try
 | 
			
		||||
    {
 | 
			
		||||
        let [config, imports] = await HuntConfig();
 | 
			
		||||
        
 | 
			
		||||
        //console.log(config, imports);
 | 
			
		||||
        if(!config.path)
 | 
			
		||||
        {
 | 
			
		||||
@ -181,63 +184,25 @@ export async function Check()
 | 
			
		||||
                await bake(imports); 
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            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.");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            const tasks:Record<string, string> = {
 | 
			
		||||
                "check": `deno run -A --no-lock ${RootHost}cli.tsx check`,
 | 
			
		||||
                "local": `deno run -A --no-lock ${RootHost}cli.tsx local`,
 | 
			
		||||
                "debug": `deno run -A --no-lock ${RootHost}cli.tsx debug`,
 | 
			
		||||
                "serve": `deno run -A --no-lock ${RootHost}cli.tsx serve`,
 | 
			
		||||
                "cloud": `deno run -A --no-lock ${RootHost}cli.tsx cloud`        
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            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";
 | 
			
		||||
                    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?`))
 | 
			
		||||
                    if(confirm(`🤔 OPTIONAL: The tasks defined in your config contain missing or modified values. Update tasks?`))
 | 
			
		||||
                    {
 | 
			
		||||
                        await Install("api.tsx", importMap[">able/api.tsx"]);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        throw("⛔ Starter backend app has incorrect export types.");
 | 
			
		||||
                        config.json.tasks = {...confTasks, ...tasks};
 | 
			
		||||
                        await bake(config);
 | 
			
		||||
                    }
 | 
			
		||||
                    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)
 | 
			
		||||
@ -276,6 +305,4 @@ export async function Check()
 | 
			
		||||
    }
 | 
			
		||||
    console.log(`🚗 Good to go!`);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Check();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								cli.tsx
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								cli.tsx
									
									
									
									
									
								
							@ -35,7 +35,6 @@ const collect =async(inKey:string, inArg:Record<string, string>, inEnv:Record<st
 | 
			
		||||
    return scanUser;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export async function SubProcess(args:string[])
 | 
			
		||||
{
 | 
			
		||||
    const command = new Deno.Command(
 | 
			
		||||
@ -61,24 +60,40 @@ export async function SubProcess(args:string[])
 | 
			
		||||
    // manually close stdin
 | 
			
		||||
    child.stdin.close();
 | 
			
		||||
    const status = await child.status;    
 | 
			
		||||
    
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if(arg._.length)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    const [config, imports] = await HuntConfig();
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    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]);
 | 
			
		||||
            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]);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "push" :
 | 
			
		||||
        case "cloud" :
 | 
			
		||||
        {
 | 
			
		||||
            let useToken = await collect("DENO_DEPLOY_TOKEN", arg, env);
 | 
			
		||||
            let useProject = await collect("DENO_DEPLOY_PROJECT", arg, env);
 | 
			
		||||
 | 
			
		||||
@ -2,9 +2,16 @@
 | 
			
		||||
	"imports": {
 | 
			
		||||
		"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"
 | 
			
		||||
	},
 | 
			
		||||
	"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": {
 | 
			
		||||
		"jsx": "react-jsx",
 | 
			
		||||
		"jsxImportSource": "react",
 | 
			
		||||
 | 
			
		||||
@ -17,16 +17,6 @@ const ImportMapReload =async()=>
 | 
			
		||||
 | 
			
		||||
    if(imports)
 | 
			
		||||
    {
 | 
			
		||||
        if(imports["react"])
 | 
			
		||||
        {
 | 
			
		||||
            console.log(`"react" specifier not defined in import map`);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        else if(!imports["react/"])
 | 
			
		||||
        {
 | 
			
		||||
            imports["react/"] = imports["react"]+"/";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ImportMapProxies = {};
 | 
			
		||||
        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