commit 2dccb8116a4c8556b22aa6caf5e9121ae93d59f3 Author: Julien LEICHER Date: Wed Feb 8 17:58:47 2023 +0100 initial commit diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4b9fb22 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} \ No newline at end of file diff --git a/denogen/.vscode/settings.json b/denogen/.vscode/settings.json new file mode 100644 index 0000000..cbac569 --- /dev/null +++ b/denogen/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} diff --git a/denogen/deno.jsonc b/denogen/deno.jsonc new file mode 100644 index 0000000..3987ce7 --- /dev/null +++ b/denogen/deno.jsonc @@ -0,0 +1,8 @@ +{ + "imports": { + "ts_morph/": "https://deno.land/x/ts_morph/" + }, + "tasks": { + "dev": "deno run --watch main.ts" + } +} diff --git a/denogen/deno.lock b/denogen/deno.lock new file mode 100644 index 0000000..9508ab1 --- /dev/null +++ b/denogen/deno.lock @@ -0,0 +1,34 @@ +{ + "version": "2", + "remote": { + "https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", + "https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49", + "https://deno.land/std@0.140.0/fs/_util.ts": "0fb24eb4bfebc2c194fb1afdb42b9c3dda12e368f43e8f2321f84fc77d42cb0f", + "https://deno.land/std@0.140.0/fs/ensure_dir.ts": "9dc109c27df4098b9fc12d949612ae5c9c7169507660dcf9ad90631833209d9d", + "https://deno.land/std@0.140.0/fs/expand_glob.ts": "0c10130d67c9b02164b03df8e43c6d6defbf8e395cb69d09e84a8586e6d72ac3", + "https://deno.land/std@0.140.0/fs/walk.ts": "117403ccd21fd322febe56ba06053b1ad5064c802170f19b1ea43214088fe95f", + "https://deno.land/std@0.140.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3", + "https://deno.land/std@0.140.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09", + "https://deno.land/std@0.140.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b", + "https://deno.land/std@0.140.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633", + "https://deno.land/std@0.140.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee", + "https://deno.land/std@0.140.0/path/mod.ts": "d3e68d0abb393fb0bf94a6d07c46ec31dc755b544b13144dee931d8d5f06a52d", + "https://deno.land/std@0.140.0/path/posix.ts": "293cdaec3ecccec0a9cc2b534302dfe308adb6f10861fa183275d6695faace44", + "https://deno.land/std@0.140.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9", + "https://deno.land/std@0.140.0/path/win32.ts": "31811536855e19ba37a999cd8d1b62078235548d67902ece4aa6b814596dd757", + "https://deno.land/x/code_block_writer@11.0.3/mod.ts": "2c3448060e47c9d08604c8f40dee34343f553f33edcdfebbf648442be33205e5", + "https://deno.land/x/code_block_writer@11.0.3/utils/string_utils.ts": "60cb4ec8bd335bf241ef785ccec51e809d576ff8e8d29da43d2273b69ce2a6ff", + "https://deno.land/x/ts_morph@17.0.1/bootstrap/mod.ts": "b53aad517f106c4079971fcd4a81ab79fadc40b50061a3ab2b741a09119d51e9", + "https://deno.land/x/ts_morph@17.0.1/bootstrap/ts_morph_bootstrap.d.ts": "607e651c5ae5aa57c2ac4090759a6379e809c0cdc42114742ac67353b1a75038", + "https://deno.land/x/ts_morph@17.0.1/bootstrap/ts_morph_bootstrap.js": "91a954daa993c5acb3361aa5279394f81ea6fe18b3854345c86111b336491cfc", + "https://deno.land/x/ts_morph@17.0.1/common/DenoRuntime.ts": "537800e840d0994f9055164e11bf33eadf96419246af0d3c453793c3ae67bdb3", + "https://deno.land/x/ts_morph@17.0.1/common/mod.ts": "01985d2ee7da8d1caee318a9d07664774fbee4e31602bc2bb6bb62c3489555ed", + "https://deno.land/x/ts_morph@17.0.1/common/ts_morph_common.d.ts": "ee7767b0c68b23c65bb607c94b6cb3512e8237fbcb7d1d8383a33235cde2c068", + "https://deno.land/x/ts_morph@17.0.1/common/ts_morph_common.js": "49a79124b941ba2b35d81ac9eb90fc33c957b2640cdb97569c1941bac5a3bbdb", + "https://deno.land/x/ts_morph@17.0.1/common/typescript.d.ts": "57e52a0882af4e835473dda27e4316cc31149866970210f9f79b940e916b7838", + "https://deno.land/x/ts_morph@17.0.1/common/typescript.js": "5dd669eb199ee2a539924c63a92e23d95df43dfe2fbe3a9d68c871648be1ad5e", + "https://deno.land/x/ts_morph@17.0.1/mod.ts": "adba9b82f24865d15d2c78ef6074b9a7457011719056c9928c800f130a617c93", + "https://deno.land/x/ts_morph@17.0.1/ts_morph.d.ts": "a54b0c51b06d84defedf5fdd59c773d803808ae7c9678f7165f7a1a6dfa7f6a3", + "https://deno.land/x/ts_morph@17.0.1/ts_morph.js": "1bb80284b9e31a4c5c2078cd533fe9b12b4b2d710267055cb655225aa88fb2df" + } +} diff --git a/denogen/mod.ts b/denogen/mod.ts new file mode 100644 index 0000000..2f2fae2 --- /dev/null +++ b/denogen/mod.ts @@ -0,0 +1,23 @@ +import { Project, ResolutionHosts, ts } from "ts_morph/mod.ts"; + +export function generate(path: string) { + const project = new Project({ + resolutionHost: ResolutionHosts.deno, + }); + + const file = project.addSourceFileAtPath(path); + + const classes = file.getClasses(); + + const props = classes[0].getConstructors(); + + const ps = props[0].getParameters()[0]; + + console.log(classes[0].getProperties()[0].hasQuestionToken()); + + console.log(ps.isParameterProperty()); +} + +if (import.meta.main) { + generate("../myapp/todo.ts"); +} diff --git a/myapp/.vscode/settings.json b/myapp/.vscode/settings.json new file mode 100644 index 0000000..cbac569 --- /dev/null +++ b/myapp/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} diff --git a/myapp/deno.jsonc b/myapp/deno.jsonc new file mode 100644 index 0000000..84034a6 --- /dev/null +++ b/myapp/deno.jsonc @@ -0,0 +1,8 @@ +{ + "imports": { + "denogen/": "../denogen/" + }, + "tasks": { + "dev": "deno run --watch main.ts" + } +} diff --git a/myapp/gen.ts b/myapp/gen.ts new file mode 100644 index 0000000..4b0bece --- /dev/null +++ b/myapp/gen.ts @@ -0,0 +1,5 @@ +import { generate } from "denogen/mod.ts"; + +if (import.meta.main) { + generate("todo.ts"); +} diff --git a/myapp/main.ts b/myapp/main.ts new file mode 100644 index 0000000..e69de29 diff --git a/myapp/todo.ts b/myapp/todo.ts new file mode 100644 index 0000000..d68006e --- /dev/null +++ b/myapp/todo.ts @@ -0,0 +1,17 @@ +export class Todo { + something?: boolean; + + constructor(private readonly id: string, private content: string) {} + + // Update the todo's content. + setContent(content: string) { + this.content = content; + } +} + +/** + * @post /api/todos + */ +export function createTodo(content: string): Todo { + return new Todo(new Date().toISOString(), content); +}