@jtoar/redwood-issues
Advanced tools
Comparing version 0.0.5 to 0.0.6
import * as dntShim from "./_dnt.shims.js"; | ||
import $ from "./deps/deno.land/x/dax@0.35.0/mod.js"; | ||
import { $ } from "./deps.js"; | ||
import { findUp } from "./deps/deno.land/x/find_up_deno@0.1.2/mod.js"; | ||
@@ -4,0 +4,0 @@ // ─── Fs ────────────────────────────────────────────────────────────────────── |
#!/usr/bin/env node | ||
import "./_dnt.polyfills.js"; | ||
import * as dntShim from "./_dnt.shims.js"; | ||
import { exists, getDataFromRedwoodProjectPathRef, getProgressBar, getRedwoodProjectPathRef, SERVER_URL, } from "./lib.js"; | ||
export async function main() { | ||
const progressBar = getProgressBar("Creating a gist with your Redwood project files...", 3); | ||
let redwoodProjectPathRef; | ||
try { | ||
redwoodProjectPathRef = await getRedwoodProjectPathRef(); | ||
import { parse } from "./deps/deno.land/std@0.203.0/flags/mod.js"; | ||
import { createGistCommand } from "./create_gist_command.js"; | ||
import { findInNodeModulesCommand } from "./find_in_node_modules_command.js"; | ||
const commands = { | ||
"create-gist": createGistCommand, | ||
"find-in-node-modules": findInNodeModulesCommand, | ||
}; | ||
function printHelp() { | ||
console.log(`Available commands: ${Object.keys(commands).join(", ")}`); | ||
} | ||
function main() { | ||
const args = parse(dntShim.Deno.args, { | ||
boolean: ["dev"], | ||
}); | ||
if (args.dev) { | ||
console.log("Running in dev mode"); | ||
dntShim.Deno.chdir("./fixtures/main"); | ||
} | ||
catch (e) { | ||
console.error(e.message); | ||
dntShim.Deno.exit(1); | ||
let positionals = args._; | ||
let command; | ||
for (const positional of positionals) { | ||
if (typeof positional !== "string") { | ||
continue; | ||
} | ||
if (Object.keys(commands).includes(positional)) { | ||
command = positional; | ||
positionals = positionals.filter((p) => p !== positional); | ||
break; | ||
} | ||
} | ||
progressBar.increment(); | ||
const data = await getDataFromRedwoodProjectPathRef(redwoodProjectPathRef); | ||
progressBar.increment(); | ||
const body = JSON.stringify(Object.entries(data).filter(exists).reduce((body, [file, { contents }]) => { | ||
body[file] = contents; | ||
return body; | ||
}, {})); | ||
const serverRes = await fetch(SERVER_URL, { | ||
method: "POST", | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
body, | ||
}); | ||
const { url } = await serverRes.json(); | ||
progressBar.finish(); | ||
console.log(`Created a gist with ${Object.keys(data).length} file(s) at ${url}`); | ||
if (!command) { | ||
printHelp(); | ||
dntShim.Deno.exit(0); | ||
} | ||
commands[command](positionals); | ||
} | ||
if ((import.meta.url === ("file:///" + process.argv[1].replace(/\\/g, "/")).replace(/\/{3,}/, "///"))) { | ||
await main(); | ||
} | ||
main(); |
@@ -6,3 +6,3 @@ { | ||
"name": "@jtoar/redwood-issues", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Tooling for Redwood issues", | ||
@@ -9,0 +9,0 @@ "dependencies": { |
861645
121
18340