milkio 0.0.14 → 0.0.15

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/c.ts CHANGED
@@ -29,6 +29,7 @@ const commands = {
29
29
  async EAR(commandBase64ed: string) {
30
30
  try { await $`clear` } catch (e) {}
31
31
  const command = Buffer.from(commandBase64ed, 'base64').toString('utf-8')
32
+ console.log('\x1B[2m%s\x1B[0m', `$ ${command}`)
32
33
  await $`${{ raw: command }}`
33
34
  process.on('SIGINT', () => {}) // prevent users from exiting by pressing ctrl + c
34
35
  while (true) await new Promise((resolve) => process.stdin.on('keypress', resolve))
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.14",
5
+ "version": "0.0.15",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
@@ -12,7 +12,7 @@ export default async () => {
12
12
  const paths = Object.keys(schema.default.apiMethodsSchema)
13
13
 
14
14
  console.log('')
15
- console.time(`🧊 Cookbook Stage`)
15
+ console.time(`🌟 Cookbook Stage`)
16
16
 
17
17
  const cookbook: Cookbook = {}
18
18
  for (const path of paths) {
@@ -234,10 +234,10 @@ export default async () => {
234
234
  })
235
235
  )
236
236
 
237
- console.timeEnd(`🧊 Cookbook Stage`)
237
+ console.timeEnd(`🌟 Cookbook Stage`)
238
238
  console.log(``)
239
239
 
240
- console.time(`🧊 Client Stage`)
240
+ console.time(`🌟 Client Stage`)
241
241
  await $`bun run ./node_modules/typescript/bin/tsc --outDir "./packages/client/project"`.quiet()
242
242
  await Bun.build({
243
243
  entrypoints: ["./packages/client/index.ts"],
@@ -245,7 +245,7 @@ export default async () => {
245
245
  target: 'browser',
246
246
  minify: true
247
247
  })
248
- console.timeEnd(`🧊 Client Stage`)
248
+ console.timeEnd(`🌟 Client Stage`)
249
249
  console.log(``)
250
250
 
251
251
  if (!existsSync(join(cwd(), "milkio.toml"))) return
@@ -254,8 +254,8 @@ export default async () => {
254
254
  let i = 0
255
255
  for (const command of milkioConfig.generate.significant) {
256
256
  ++i
257
- console.time(`🧊 Insignificant Stage (LINE ${i})`)
257
+ console.time(`🌟 Insignificant Stage (LINE ${i})`)
258
258
  await $`${{ raw: command }}`
259
- console.timeEnd(`🧊 Insignificant Stage (LINE ${i})`)
259
+ console.timeEnd(`🌟 Insignificant Stage (LINE ${i})`)
260
260
  }
261
261
  }
@@ -50,7 +50,7 @@ export default async () => {
50
50
  const appFiles = await Array.fromAsync(glob.scan({ cwd: join(cwd(), "src", "apps") }))
51
51
 
52
52
 
53
- console.time(`🧊 File Stage`)
53
+ console.time(`🌟 File Stage`)
54
54
 
55
55
 
56
56
  for (const path of appFiles) {
@@ -154,13 +154,13 @@ export default {
154
154
  `.trim()
155
155
  await writeFile(join(cwd(), "generated", "raw", "api-validator.ts"), ejs.render(apiValidatorTemplate, templateVars))
156
156
 
157
- console.timeEnd(`🧊 File Stage`)
157
+ console.timeEnd(`🌟 File Stage`)
158
158
  console.log(``)
159
159
 
160
160
  // typia
161
- console.time(`🧊 Typia Stage`)
161
+ console.time(`🌟 Typia Stage`)
162
162
  await $`bun run ./node_modules/typia/lib/executable/typia.js generate --input generated/raw --output generated/products --project tsconfig.json`
163
- console.timeEnd(`🧊 Typia Stage`)
163
+ console.timeEnd(`🌟 Typia Stage`)
164
164
  console.log(``)
165
165
 
166
166
  if (!existsSync(join(cwd(), "milkio.toml"))) return
@@ -169,8 +169,8 @@ export default {
169
169
  let i = 0
170
170
  for (const command of milkioConfig.generate.significant) {
171
171
  ++i
172
- console.time(`🧊 Significant Stage (LINE ${i})`)
172
+ console.time(`🌟 Significant Stage (LINE ${i})`)
173
173
  await $`${{ raw: command }}`
174
- console.timeEnd(`🧊 Significant Stage (LINE ${i})`)
174
+ console.timeEnd(`🌟 Significant Stage (LINE ${i})`)
175
175
  }
176
176
  }
package/templates/api.ts CHANGED
@@ -5,45 +5,41 @@ await createTemplate(async (tools) => {
5
5
  return {
6
6
  path: join(tools.directory, `${tools.hyphen(tools.name)}.ts`),
7
7
  content: `
8
- import { defineApi, defineApiTest } from "milkio";
8
+ import { defineApi, defineApiTest } from "milkio"
9
9
 
10
10
  /**
11
- * ${tools.hyphen(tools.name)}
11
+ * ${tools.name} ${tools.src()}
12
12
  */
13
13
  export const api = defineApi({
14
14
  meta: {
15
- //
15
+ // your meta..
16
16
  },
17
17
  async action(
18
18
  params: {
19
- //
19
+ // your params..
20
20
  },
21
21
  context
22
22
  ) {
23
- const message = \`hello world!\`;
23
+ const message = \`hello world!\`
24
24
 
25
- // ..
25
+ // your code..
26
26
 
27
27
  return {
28
28
  say: message
29
- };
29
+ }
30
30
  }
31
- });
31
+ })
32
32
 
33
33
  export const test = defineApiTest(api, [
34
34
  {
35
35
  name: "Basic",
36
36
  handler: async (test) => {
37
- const result = await test.execute({
38
- //
39
- });
40
-
41
- // ..
37
+ const result = await test.execute(await test.randParams())
42
38
 
43
- if (!result.success) return test.reject(\`The result was not success\`);
39
+ if (!result.success) return test.reject(\`The result was not success\`)
44
40
  }
45
41
  }
46
- ]);
42
+ ])
47
43
  `.trim()
48
44
  }
49
45
  })
@@ -4,6 +4,7 @@ import { camel, hump, hyphen } from "@poech/camel-hump-under"
4
4
  export type CreateTemplateTools = {
5
5
  name: string;
6
6
  directory: string;
7
+ src: () => string;
7
8
  camel: (str: string) => string;
8
9
  hump: (str: string) => string;
9
10
  hyphen: (str: string) => string;
@@ -23,6 +24,15 @@ export async function createTemplate(fn: CreateTemplateFn) {
23
24
  const tools = {
24
25
  name: argv[2],
25
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
+ },
26
36
  camel: (str: string) => camel(str).replaceAll("-", "").replaceAll("_", ""),
27
37
  hump: (str: string) => hump(str).replaceAll("-", "").replaceAll("_", ""),
28
38
  hyphen: (str: string) => hyphen(str).replaceAll("_", "")