@tuyau/core 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # AdonisJS package starter kit
2
+
3
+ > A boilerplate for creating AdonisJS packages
4
+
5
+ This repo provides you with a starting point for creating AdonisJS packages. Of course, you can create a package from scratch with your folder structure and workflow. However, using this starter kit can speed up the process, as you have fewer decisions to make.
6
+
7
+ ## Setup
8
+
9
+ - Clone the repo on your computer, or use `giget` to download this repo without the Git history.
10
+ ```sh
11
+ npx giget@latest gh:adonisjs/pkg-starter-kit
12
+ ```
13
+ - Install dependencies.
14
+ - Update the `package.json` file and define the `name`, `description`, `keywords`, and `author` properties.
15
+ - The repo is configured with an MIT license. Feel free to change that if you are not publishing under the MIT license.
16
+
17
+ ## Folder structure
18
+
19
+ The starter kit mimics the folder structure of the official packages. Feel free to rename files and folders as per your requirements.
20
+
21
+ ```
22
+ ├── providers
23
+ ├── src
24
+ ├── bin
25
+ ├── stubs
26
+ ├── configure.ts
27
+ ├── index.ts
28
+ ├── LICENSE.md
29
+ ├── package.json
30
+ ├── README.md
31
+ ├── tsconfig.json
32
+ ├── tsnode.esm.js
33
+ ```
34
+
35
+ - The `configure.ts` file exports the `configure` hook to configure the package using the `node ace configure` command.
36
+ - The `index.ts` file is the main entry point of the package.
37
+ - The `tsnode.esm.js` file runs TypeScript code using TS-Node + SWC. Please read the code comment in this file to learn more.
38
+ - The `bin` directory contains the entry point file to run Japa tests.
39
+ - Learn more about [the `providers` directory](./providers/README.md).
40
+ - Learn more about [the `src` directory](./src/README.md).
41
+ - Learn more about [the `stubs` directory](./stubs/README.md).
42
+
43
+ ### File system naming convention
44
+
45
+ We use `snake_case` naming conventions for the file system. The rule is enforced using ESLint. However, turn off the rule and use your preferred naming conventions.
46
+
47
+ ## Peer dependencies
48
+
49
+ The starter kit has a peer dependency on `@adonisjs/core@6`. Since you are creating a package for AdonisJS, you must make it against a specific version of the framework core.
50
+
51
+ If your package needs Lucid to be functional, you may install `@adonisjs/lucid` as a development dependency and add it to the list of `peerDependencies`.
52
+
53
+ As a rule of thumb, packages installed in the user application should be part of the `peerDependencies` of your package and not the main dependency.
54
+
55
+ For example, if you install `@adonisjs/core` as a main dependency, then essentially, you are importing a separate copy of `@adonisjs/core` and not sharing the one from the user application. Here is a great article explaining [peer dependencies](https://blog.bitsrc.io/understanding-peer-dependencies-in-javascript-dbdb4ab5a7be).
56
+
57
+ ## Published files
58
+
59
+ Instead of publishing your repo's source code to npm, you must cherry-pick files and folders to publish only the required files.
60
+
61
+ The cherry-picking uses the `files` property inside the `package.json` file. By default, we publish the following files and folders.
62
+
63
+ ```json
64
+ {
65
+ "files": ["build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js"]
66
+ }
67
+ ```
68
+
69
+ If you create additional folders or files, mention them inside the `files` array.
70
+
71
+ ## Exports
72
+
73
+ [Node.js Subpath exports](https://nodejs.org/api/packages.html#subpath-exports) allows you to define the exports of your package regardless of the folder structure. This starter kit defines the following exports.
74
+
75
+ ```json
76
+ {
77
+ "exports": {
78
+ ".": "./build/index.js",
79
+ "./types": "./build/src/types.js"
80
+ }
81
+ }
82
+ ```
83
+
84
+ - The dot `.` export is the main export.
85
+ - The `./types` exports all the types defined inside the `./build/src/types.js` file (the compiled output).
86
+
87
+ Feel free to change the exports as per your requirements.
88
+
89
+ ## Testing
90
+
91
+ We configure the [Japa test runner](https://japa.dev/) with this starter kit. Japa is used in AdonisJS applications as well. Just run one of the following commands to execute tests.
92
+
93
+ - `npm run test`: This command will first lint the code using ESlint and then run tests and report the test coverage using [c8](https://github.com/bcoe/c8).
94
+ - `npm run quick:test`: Runs only the tests without linting or coverage reporting.
95
+
96
+ The starter kit also has a Github workflow file to run tests using Github Actions. The tests are executed against `Node.js 20.x` and `Node.js 21.x` versions on both Linux and Windows. Feel free to edit the workflow file in the `.github/workflows` directory.
97
+
98
+ ## TypeScript workflow
99
+
100
+ - The starter kit uses [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for compiling the TypeScript to JavaScript when publishing the package.
101
+ - [TS-Node](https://typestrong.org/ts-node/) and [SWC](https://swc.rs/) are used to run tests without compiling the source code.
102
+ - The `tsconfig.json` file is extended from [`@adonisjs/tsconfig`](https://github.com/adonisjs/tooling-config/tree/main/packages/typescript-config) and uses the `NodeNext` module system. Meaning the packages are written using ES modules.
103
+ - You can perform type checking without compiling the source code using the `npm run type check` script.
104
+
105
+ Feel free to explore the `tsconfig.json` file for all the configured options.
106
+
107
+ ## ESLint and Prettier setup
108
+
109
+ The starter kit configures ESLint and Prettier. Both configurations are stored within the `package.json` file and use our [shared config](https://github.com/adonisjs/tooling-config/tree/main/packages). Feel free to change the configuration, use custom plugins, or remove both tools altogether.
110
+
111
+ ## Using Stale bot
112
+
113
+ The [Stale bot](https://github.com/apps/stale) is a Github application that automatically marks issues and PRs as stale and closes after a specific duration of inactivity.
114
+
115
+ Feel free to delete the `.github/stale.yml` and `.github/lock.yml` files if you decide not to use the Stale bot.
@@ -0,0 +1 @@
1
+ {"commands":[{"commandName":"tuyau:generate","description":"Tuyau generator command","help":"","namespace":"tuyau","aliases":[],"flags":[],"args":[],"options":{"startApp":true},"filePath":"generate.js","absoluteFilePath":"/home/julien/code/adonis/tuyau/packages/core/build/commands/generate.js"}],"version":1}
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ import { CommandOptions } from '@adonisjs/core/types/ace';
3
+
4
+ declare class CodegenTypes extends BaseCommand {
5
+ #private;
6
+ static commandName: string;
7
+ static description: string;
8
+ static options: CommandOptions;
9
+ /**
10
+ * Execute command
11
+ */
12
+ run(): Promise<void>;
13
+ }
14
+
15
+ export { CodegenTypes as default };
@@ -0,0 +1,216 @@
1
+ // commands/generate.ts
2
+ import { Project, QuoteKind } from "ts-morph";
3
+ import { BaseCommand } from "@adonisjs/core/ace";
4
+
5
+ // src/codegen/api_types_generator.ts
6
+ import { Node } from "ts-morph";
7
+ import { fileURLToPath } from "node:url";
8
+ import { dirname, relative } from "node:path";
9
+ import { existsSync, mkdirSync } from "node:fs";
10
+ import { parseBindingReference } from "@adonisjs/core/helpers";
11
+ var ApiTypesGenerator = class {
12
+ #appRoot;
13
+ #logger;
14
+ #project;
15
+ #config;
16
+ #routes;
17
+ #destination;
18
+ constructor(options) {
19
+ this.#config = options.config;
20
+ this.#routes = options.routes;
21
+ this.#logger = options.logger;
22
+ this.#project = options.project;
23
+ this.#appRoot = options.appRoot;
24
+ this.#prepareDestination();
25
+ }
26
+ #getDestinationDirectory() {
27
+ return dirname(this.#destination.pathname);
28
+ }
29
+ /**
30
+ * Create the destination directory if it does not exists
31
+ */
32
+ #prepareDestination() {
33
+ this.#destination = new URL("./.adonisjs/types/api.d.ts", this.#appRoot);
34
+ const directory = this.#getDestinationDirectory();
35
+ if (!existsSync(directory)) {
36
+ mkdirSync(directory, { recursive: true });
37
+ }
38
+ }
39
+ /**
40
+ * Extract class and method of the route handler
41
+ */
42
+ #extractClassHandlerData(file, routeHandler) {
43
+ const classDef = file.getClasses().find((c) => c.isDefaultExport());
44
+ if (!classDef)
45
+ return;
46
+ const method = classDef.getMethod(routeHandler.method);
47
+ if (!method)
48
+ return;
49
+ const body = method.getBody();
50
+ if (!body)
51
+ return;
52
+ return { method, body };
53
+ }
54
+ /**
55
+ * We have multiple ways to get the request payload :
56
+ * - First we check if a FormRequest is used
57
+ * - Other we check if we have a Single Action Controller
58
+ * - Otherwise, we check if a request.validateUsing is used
59
+ *
60
+ * This method will returns the path to the schema file
61
+ */
62
+ #extractRequest(handlerData) {
63
+ const validateUsingCallNode = handlerData.method.forEachDescendant((node) => {
64
+ if (!Node.isCallExpression(node))
65
+ return false;
66
+ if (node.getExpression().getText().includes("validateUsing")) {
67
+ return node;
68
+ }
69
+ return false;
70
+ });
71
+ if (validateUsingCallNode) {
72
+ const schema = validateUsingCallNode.getArguments()[0];
73
+ if (!Node.isIdentifier(schema))
74
+ return;
75
+ const importPath = schema.getImplementations()[0].getSourceFile().getFilePath();
76
+ const relativeImportPath = relative(this.#getDestinationDirectory(), importPath);
77
+ return `InferInput<typeof import('${relativeImportPath}')['${schema.getText()}']>`;
78
+ }
79
+ return void 0;
80
+ }
81
+ /**
82
+ * Generate the final interface containing all routes, request, and response
83
+ */
84
+ #generateFinalInterface(types, indent = " ") {
85
+ let interfaceContent = "";
86
+ Object.entries(types).forEach(([key, value]) => {
87
+ if (typeof value === "object") {
88
+ interfaceContent += `${indent}'${key}': {
89
+ `;
90
+ interfaceContent += this.#generateFinalInterface(value, indent + " ");
91
+ interfaceContent += `${indent}};
92
+ `;
93
+ } else {
94
+ interfaceContent += `${indent}'${key}': ${value};
95
+ `;
96
+ }
97
+ });
98
+ return interfaceContent;
99
+ }
100
+ /**
101
+ * Write the final interface containing all routes, request, and response
102
+ * in a routes.d.ts file
103
+ */
104
+ async #writeFinalInterface(types) {
105
+ const file = this.#project.createSourceFile(fileURLToPath(this.#destination), "", {
106
+ overwrite: true
107
+ });
108
+ if (!file)
109
+ throw new Error("Unable to create the api.d.ts file");
110
+ file?.removeText();
111
+ file.insertText(0, (writer) => {
112
+ writer.writeLine(
113
+ `import type { MakeOptional, Serialize, Simplify, ConvertReturnTypeToRecordStatusResponse } from '@tuyau/utils/types'`
114
+ ).writeLine(`import type { InferInput } from '@vinejs/vine/types'`).newLine().writeLine(`export interface AdonisApi {`).write(this.#generateFinalInterface(types, " ")).writeLine(`}`);
115
+ });
116
+ await file.save();
117
+ }
118
+ /**
119
+ * Filter routes to generate based on the ignoreRoutes config
120
+ */
121
+ #filterRoutesToGenerate(routes) {
122
+ return routes.filter((route) => {
123
+ if (!this.#config.codegen?.ignoreRoutes)
124
+ return true;
125
+ if (typeof this.#config.codegen?.ignoreRoutes === "function") {
126
+ return !this.#config.codegen.ignoreRoutes(route);
127
+ }
128
+ for (const ignore of this.#config.codegen.ignoreRoutes) {
129
+ if (typeof ignore === "string" && route.pattern === ignore)
130
+ return false;
131
+ if (ignore instanceof RegExp && ignore.test(route.pattern))
132
+ return false;
133
+ }
134
+ return true;
135
+ });
136
+ }
137
+ async generate() {
138
+ const types = {};
139
+ const sourcesFiles = this.#project.getSourceFiles();
140
+ const routes = this.#filterRoutesToGenerate(this.#routes);
141
+ for (const route of routes) {
142
+ if (typeof route.handler === "function")
143
+ continue;
144
+ const routeHandler = await parseBindingReference(route.handler.reference);
145
+ const file = sourcesFiles.find(
146
+ (sf) => sf.getFilePath().endsWith(`${routeHandler.moduleNameOrPath.replace("#", "")}.ts`)
147
+ );
148
+ if (!file) {
149
+ this.#logger.warning(`Unable to find the controller file for ${route.pattern}`);
150
+ continue;
151
+ }
152
+ this.#logger.info(`Generating types for ${route.pattern}`);
153
+ const handlerData = this.#extractClassHandlerData(file, routeHandler);
154
+ if (!handlerData) {
155
+ this.#logger.warning(`Unable to find the controller method for ${route.pattern}`);
156
+ continue;
157
+ }
158
+ const schemaImport = this.#extractRequest(handlerData);
159
+ const methods = route.methods.map((method) => method.toLowerCase()).filter((method) => method !== "head");
160
+ const segments = route.pattern.split("/").filter(Boolean);
161
+ let currentLevel = types;
162
+ const relativePath = relative(this.#getDestinationDirectory(), file.getFilePath());
163
+ segments.forEach((segment, i) => {
164
+ if (!currentLevel[segment]) {
165
+ currentLevel[segment] = {};
166
+ }
167
+ currentLevel = currentLevel[segment];
168
+ if (i === segments.length - 1) {
169
+ for (const method of methods) {
170
+ currentLevel[method] = {
171
+ request: schemaImport ? `MakeOptional<${schemaImport}>` : "unknown",
172
+ response: `Simplify<Serialize<ConvertReturnTypeToRecordStatusResponse<Awaited<ReturnType<typeof import('${relativePath}').default['prototype']['${routeHandler.method}']>>>>>`
173
+ };
174
+ }
175
+ }
176
+ });
177
+ }
178
+ await this.#writeFinalInterface(types);
179
+ }
180
+ };
181
+
182
+ // commands/generate.ts
183
+ var CodegenTypes = class extends BaseCommand {
184
+ static commandName = "tuyau:generate";
185
+ static description = "Tuyau generator command";
186
+ static options = { startApp: true };
187
+ /**
188
+ * Get routes from the router instance
189
+ */
190
+ async #getRoutes() {
191
+ const router = await this.app.container.make("router");
192
+ router.commit();
193
+ return router.toJSON().root;
194
+ }
195
+ /**
196
+ * Execute command
197
+ */
198
+ async run() {
199
+ const project = new Project({
200
+ tsConfigFilePath: new URL("./tsconfig.json", this.app.appRoot).pathname,
201
+ manipulationSettings: { quoteKind: QuoteKind.Single }
202
+ });
203
+ const apiTypesGenerator = new ApiTypesGenerator({
204
+ project,
205
+ appRoot: this.app.appRoot,
206
+ routes: await this.#getRoutes(),
207
+ config: this.app.config.get("tuyau"),
208
+ logger: this.logger
209
+ });
210
+ await apiTypesGenerator.generate();
211
+ this.logger.success("Types generated successfully");
212
+ }
213
+ };
214
+ export {
215
+ CodegenTypes as default
216
+ };
@@ -0,0 +1,4 @@
1
+ import { CommandMetaData, Command } from '@adonisjs/ace/types';
2
+
3
+ export function getMetaData(): Promise<CommandMetaData[]>
4
+ export function getCommand(metaData: CommandMetaData): Promise<Command | null>
@@ -0,0 +1,36 @@
1
+ import { readFile } from 'node:fs/promises'
2
+
3
+ /**
4
+ * In-memory cache of commands after they have been loaded
5
+ */
6
+ let commandsMetaData
7
+
8
+ /**
9
+ * Reads the commands from the "./commands.json" file. Since, the commands.json
10
+ * file is generated automatically, we do not have to validate its contents
11
+ */
12
+ export async function getMetaData() {
13
+ if (commandsMetaData) {
14
+ return commandsMetaData
15
+ }
16
+
17
+ const commandsIndex = await readFile(new URL('./commands.json', import.meta.url), 'utf-8')
18
+ commandsMetaData = JSON.parse(commandsIndex).commands
19
+
20
+ return commandsMetaData
21
+ }
22
+
23
+ /**
24
+ * Imports the command by lookingup its path from the commands
25
+ * metadata
26
+ */
27
+ export async function getCommand(metaData) {
28
+ const commands = await getMetaData()
29
+ const command = commands.find(({ commandName }) => metaData.commandName === commandName)
30
+ if (!command) {
31
+ return null
32
+ }
33
+
34
+ const { default: commandConstructor } = await import(new URL(command.filePath, import.meta.url).href)
35
+ return commandConstructor
36
+ }
@@ -0,0 +1,9 @@
1
+ import ConfigureCommand from '@adonisjs/core/commands/configure';
2
+ import { TuyauConfig } from './src/types.js';
3
+ import '@adonisjs/core/types/http';
4
+
5
+ declare function configure(command: ConfigureCommand): Promise<void>;
6
+
7
+ declare function defineConfig(options: TuyauConfig): TuyauConfig;
8
+
9
+ export { configure, defineConfig };
package/build/index.js ADDED
@@ -0,0 +1,22 @@
1
+ // stubs/main.ts
2
+ import { getDirname } from "@adonisjs/core/helpers";
3
+ var stubsRoot = getDirname(import.meta.url);
4
+
5
+ // configure.ts
6
+ async function configure(command) {
7
+ const codemods = await command.createCodemods();
8
+ await codemods.updateRcFile((rcFile) => {
9
+ rcFile.addCommand("@tuyau/core/commands");
10
+ rcFile.addProvider("@tuyau/core/tuyau_provider");
11
+ });
12
+ await codemods.makeUsingStub(stubsRoot, "config/tuyau.stub", {});
13
+ }
14
+
15
+ // src/define_config.ts
16
+ function defineConfig(options) {
17
+ return options;
18
+ }
19
+ export {
20
+ configure,
21
+ defineConfig
22
+ };
@@ -0,0 +1,190 @@
1
+ import { ApplicationService } from '@adonisjs/core/types';
2
+
3
+ /**
4
+ * Extending the HTTP response interface to include status and response
5
+ * in the return type.
6
+ *
7
+ * This is ONLY type information and the properties will not be available
8
+ * at runtime. This is needed to infer the correct response type
9
+ */
10
+ declare module '@adonisjs/core/http' {
11
+ interface Response {
12
+ continue(): {
13
+ __status: 100;
14
+ };
15
+ switchingProtocols(etag?: boolean): {
16
+ __status: 101;
17
+ };
18
+ ok<T>(body: T, etag?: boolean): {
19
+ __response: T;
20
+ __status: 200;
21
+ };
22
+ created<T>(body?: T, etag?: boolean): {
23
+ __response: T;
24
+ __status: 201;
25
+ };
26
+ accepted<T>(body: T, etag?: boolean): {
27
+ __response: T;
28
+ __status: 202;
29
+ };
30
+ nonAuthoritativeInformation<T>(body?: T, etag?: boolean): {
31
+ __response: T;
32
+ __status: 203;
33
+ };
34
+ noContent<T>(body?: T, etag?: boolean): {
35
+ __response: T;
36
+ __status: 204;
37
+ };
38
+ resetContent<T>(body?: T, etag?: boolean): {
39
+ __response: T;
40
+ __status: 205;
41
+ };
42
+ partialContent<T>(body: T, etag?: boolean): {
43
+ __response: T;
44
+ __status: 206;
45
+ };
46
+ multipleChoices<T>(body?: T, etag?: boolean): {
47
+ __response: T;
48
+ __status: 300;
49
+ };
50
+ movedPermanently<T>(body?: T, etag?: boolean): {
51
+ __response: T;
52
+ __status: 301;
53
+ };
54
+ movedTemporarily<T>(body?: T, etag?: boolean): {
55
+ __response: T;
56
+ __status: 302;
57
+ };
58
+ seeOther<T>(body?: T, etag?: boolean): {
59
+ __response: T;
60
+ __status: 303;
61
+ };
62
+ notModified<T>(body?: T, etag?: boolean): {
63
+ __response: T;
64
+ __status: 304;
65
+ };
66
+ useProxy<T>(body?: T, etag?: boolean): {
67
+ __response: T;
68
+ __status: 305;
69
+ };
70
+ temporaryRedirect<T>(body?: T, etag?: boolean): {
71
+ __response: T;
72
+ __status: 307;
73
+ };
74
+ badRequest<T>(body?: T, etag?: boolean): {
75
+ __response: T;
76
+ __status: 400;
77
+ };
78
+ unauthorized<T>(body?: T, etag?: boolean): {
79
+ __response: T;
80
+ __status: 401;
81
+ };
82
+ paymentRequired<T>(body?: T, etag?: boolean): {
83
+ __response: T;
84
+ __status: 402;
85
+ };
86
+ forbidden<T>(body?: T, etag?: boolean): {
87
+ __response: T;
88
+ __status: 403;
89
+ };
90
+ notFound<T>(body?: T, etag?: boolean): {
91
+ __response: T;
92
+ __status: 404;
93
+ };
94
+ methodNotAllowed<T>(body?: T, etag?: boolean): {
95
+ __response: T;
96
+ __status: 405;
97
+ };
98
+ notAcceptable<T>(body?: T, etag?: boolean): {
99
+ __response: T;
100
+ __status: 406;
101
+ };
102
+ proxyAuthenticationRequired<T>(body?: T, etag?: boolean): {
103
+ __response: T;
104
+ __status: 407;
105
+ };
106
+ requestTimeout<T>(body?: T, etag?: boolean): {
107
+ __response: T;
108
+ __status: 408;
109
+ };
110
+ conflict<T>(body?: T, etag?: boolean): {
111
+ __response: T;
112
+ __status: 409;
113
+ };
114
+ gone<T>(body?: T, etag?: boolean): {
115
+ __response: T;
116
+ __status: 410;
117
+ };
118
+ lengthRequired<T>(body?: T, etag?: boolean): {
119
+ __response: T;
120
+ __status: 411;
121
+ };
122
+ preconditionFailed<T>(body?: T, etag?: boolean): {
123
+ __response: T;
124
+ __status: 412;
125
+ };
126
+ requestEntityTooLarge<T>(body?: T, etag?: boolean): {
127
+ __response: T;
128
+ __status: 413;
129
+ };
130
+ requestUriTooLong<T>(body?: T, etag?: boolean): {
131
+ __response: T;
132
+ __status: 414;
133
+ };
134
+ unsupportedMediaType<T>(body?: T, etag?: boolean): {
135
+ __response: T;
136
+ __status: 415;
137
+ };
138
+ requestedRangeNotSatisfiable<T>(body?: T, etag?: boolean): {
139
+ __response: T;
140
+ __status: 416;
141
+ };
142
+ expectationFailed<T>(body?: T, etag?: boolean): {
143
+ __response: T;
144
+ __status: 417;
145
+ };
146
+ unprocessableEntity<T>(body?: T, etag?: boolean): {
147
+ __response: T;
148
+ __status: 422;
149
+ };
150
+ tooManyRequests<T>(body?: T, etag?: boolean): {
151
+ __response: T;
152
+ __status: 429;
153
+ };
154
+ internalServerError<T>(body?: T, etag?: boolean): {
155
+ __response: T;
156
+ __status: 500;
157
+ };
158
+ notImplemented<T>(body?: T, etag?: boolean): {
159
+ __response: T;
160
+ __status: 501;
161
+ };
162
+ badGateway<T>(body?: T, etag?: boolean): {
163
+ __response: T;
164
+ __status: 502;
165
+ };
166
+ serviceUnavailable<T>(body?: T, etag?: boolean): {
167
+ __response: T;
168
+ __status: 503;
169
+ };
170
+ gatewayTimeout<T>(body?: T, etag?: boolean): {
171
+ __response: T;
172
+ __status: 504;
173
+ };
174
+ httpVersionNotSupported<T>(body?: T, etag?: boolean): {
175
+ __response: T;
176
+ __status: 505;
177
+ };
178
+ json<T>(body: T, generateEtag?: boolean): {
179
+ __response: T;
180
+ __status: 200;
181
+ };
182
+ }
183
+ }
184
+ declare class TuyauProvider {
185
+ protected app: ApplicationService;
186
+ constructor(app: ApplicationService);
187
+ register(): Promise<void>;
188
+ }
189
+
190
+ export { TuyauProvider as default };
@@ -0,0 +1,11 @@
1
+ // providers/tuyau_provider.ts
2
+ var TuyauProvider = class {
3
+ constructor(app) {
4
+ this.app = app;
5
+ }
6
+ async register() {
7
+ }
8
+ };
9
+ export {
10
+ TuyauProvider as default
11
+ };
@@ -0,0 +1,12 @@
1
+ import { RouteJSON } from '@adonisjs/core/types/http';
2
+
3
+ interface TuyauConfig {
4
+ codegen?: {
5
+ /**
6
+ * List of routes to ignore during code generation
7
+ */
8
+ ignoreRoutes?: Array<string | RegExp> | ((route: RouteJSON) => boolean);
9
+ };
10
+ }
11
+
12
+ export type { TuyauConfig };
File without changes
@@ -0,0 +1,15 @@
1
+ {{{
2
+ exports({ to: app.configPath('tuyau.ts') })
3
+ }}}
4
+ import { defineConfig } from '@tuyau/core'
5
+
6
+ const tuyauConfig = defineConfig({
7
+ codegen: {
8
+ /**
9
+ * List of routes to ignore during code generation
10
+ */
11
+ ignoreRoutes: []
12
+ }
13
+ })
14
+
15
+ export default tuyauConfig
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@tuyau/core",
3
+ "type": "module",
4
+ "version": "0.0.4",
5
+ "description": "",
6
+ "author": "",
7
+ "license": "MIT",
8
+ "keywords": [],
9
+ "exports": {
10
+ ".": "./build/index.js",
11
+ "./types": "./build/src/types.js",
12
+ "./commands": "./build/commands/main.js",
13
+ "./tuyau_provider": "./build/providers/tuyau_provider.js"
14
+ },
15
+ "files": [
16
+ "build"
17
+ ],
18
+ "engines": {
19
+ "node": ">=20.6.0"
20
+ },
21
+ "scripts": {
22
+ "clean": "del-cli build",
23
+ "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
24
+ "typecheck": "tsc --noEmit",
25
+ "format": "prettier --write .",
26
+ "quick:test": "node --import=./tsnode.esm.js --enable-source-maps bin/test.ts",
27
+ "test": "c8 npm run quick:test",
28
+ "index:commands": "adonis-kit index build/commands",
29
+ "prebuild": "npm run clean",
30
+ "build": "pnpm clean && tsup-node && pnpm copy:templates && pnpm index:commands",
31
+ "release": "pnpm build && pnpm release-it",
32
+ "version": "npm run build",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "peerDependencies": {
36
+ "@adonisjs/core": "^6.2.0"
37
+ },
38
+ "dependencies": {
39
+ "ts-morph": "^22.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@adonisjs/assembler": "^7.4.0",
43
+ "@adonisjs/core": "^6.5.0",
44
+ "@julr/tooling-configs": "^2.2.0",
45
+ "@poppinss/cliui": "^6.4.1",
46
+ "@poppinss/matchit": "^3.1.2",
47
+ "@tuyau/client": "workspace:*",
48
+ "@tuyau/utils": "workspace:*",
49
+ "@types/node": "^20.12.7"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "tag": "latest"
54
+ },
55
+ "c8": {
56
+ "reporter": [
57
+ "text",
58
+ "html"
59
+ ],
60
+ "exclude": [
61
+ "tests/**"
62
+ ]
63
+ },
64
+ "release-it": {
65
+ "git": {
66
+ "commitMessage": "chore(release): @tuyau/core@${version}",
67
+ "tagAnnotation": "release ${version}",
68
+ "tagName": "@tuyau/core@${version}"
69
+ },
70
+ "github": {
71
+ "release": true,
72
+ "releaseName": "@tuyau/core@${version}",
73
+ "web": true
74
+ }
75
+ },
76
+ "tsup": {
77
+ "entry": [
78
+ "./index.ts",
79
+ "./src/types.ts",
80
+ "./commands/generate.ts",
81
+ "./providers/tuyau_provider.ts"
82
+ ],
83
+ "outDir": "./build",
84
+ "clean": false,
85
+ "format": "esm",
86
+ "dts": true,
87
+ "target": "esnext"
88
+ }
89
+ }