-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
online.ts
56 lines (53 loc) · 1.6 KB
/
online.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const base = `import { Denops, ensure, execute, is } from "../../deps.ts";
export async function main(denops: Denops): Promise<void> {
// ここにプラグインの処理を記載する
// console.log("Hello Denops!");
denops.dispatcher = {
async echo(text: unknown): Promise<unknown> {
ensure(text, is.String);
return await Promise.resolve(text);
},
};
await execute(
denops,
\`command! -nargs=1 HelloWorldEcho echomsg denops#request('\${denops.name}', 'echo', [<q-args>])\`,
);
}
`;
const deno = "{}";
const deps = `
export { type Denops } from "jsr:@denops/std";
export { execute } from "jsr:@denops/std/function";
export { ensure, is } from "jsr:@core/unknownutil";
`;
console.log("Create directory...");
Deno.mkdir("./denops/plugin", {
recursive: true
});
console.log("Copying templates...");
Deno.writeTextFile("./denops/plugin/main.ts", base);
Deno.writeTextFile("./deps.ts", deps);
Deno.writeTextFile("./deno.json", deno);
console.log("Execute `deno cache ./denops/plugin/main.ts`...");
const cache = new Deno.Command("deno", {
args: [
"cache",
"./denops/plugin/main.ts"
]
});
const { _, stdout, stderr } = await cache.output();
const decoder = new TextDecoder();
console.log(decoder.decode(stdout));
console.log(decoder.decode(stderr));
console.log("All done 🎉");
console.log(`Boiler plate structure is show below.
You edit to \`main.ts\` start develop to denops plugin.`);
console.log(`.
├── deno.json
├── deno.lock
├── denops
│ └── plugin
│ └── main.ts
└── deps.ts
`);
console.log("Happy hacking!✨");