milkio 0.0.33 → 0.0.34

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.0.33",
5
+ "version": "0.0.34",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
package/templates/api.ts DELETED
@@ -1,45 +0,0 @@
1
- import { createTemplate } from "../utils/create-template"
2
- import { join } from "path"
3
-
4
- await createTemplate(async (tools) => {
5
- return {
6
- path: join(tools.directory, `${tools.hyphen(tools.name)}.ts`),
7
- content: `
8
- import { defineApi, defineApiTest } from "milkio"
9
-
10
- /**
11
- * ${tools.name}
12
- */
13
- export const api = defineApi({
14
- meta: {
15
- // your meta..
16
- },
17
- async action(
18
- params: {
19
- // your params..
20
- },
21
- context
22
- ) {
23
- const message = \`hello world!\`
24
-
25
- // your code..
26
-
27
- return {
28
- say: message
29
- }
30
- }
31
- })
32
-
33
- export const test = defineApiTest(api, [
34
- {
35
- name: "Basic",
36
- handler: async (test) => {
37
- const result = await test.execute(await test.randParams())
38
-
39
- if (!result.success) return test.reject(\`The result was not success\`)
40
- }
41
- }
42
- ])
43
- `.trim()
44
- }
45
- })
@@ -1,42 +0,0 @@
1
- import { argv } from "node:process"
2
- import { camel, hump, hyphen } from "@poech/camel-hump-under"
3
-
4
- export type CreateTemplateTools = {
5
- name: string;
6
- directory: string;
7
- src: () => string;
8
- camel: (str: string) => string;
9
- hump: (str: string) => string;
10
- hyphen: (str: string) => string;
11
- };
12
-
13
- export type CreateTemplateFn = (tools: CreateTemplateTools) =>
14
- | {
15
- path: string;
16
- content: string;
17
- }
18
- | Promise<{
19
- path: string;
20
- content: string;
21
- }>;
22
-
23
- export async function createTemplate(fn: CreateTemplateFn) {
24
- const tools = {
25
- name: argv[2],
26
- directory: argv[3],
27
- src: () => {
28
- const patharr = argv[3].split("/")
29
- const i = patharr.length - patharr.findIndex((str: string) => str.startsWith("src")) - 1
30
- let path = ''
31
- for (let j = 0; j < i; j++) {
32
- path += "../"
33
- }
34
- return path
35
- },
36
- camel: (str: string) => camel(str).replaceAll("-", "").replaceAll("_", ""),
37
- hump: (str: string) => hump(str).replaceAll("-", "").replaceAll("_", ""),
38
- hyphen: (str: string) => hyphen(str).replaceAll("_", "")
39
- }
40
- const file = await fn(tools)
41
- await Bun.write(file.path, file.content)
42
- }