milkio 0.0.15 → 0.0.16

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/api-test/index.ts CHANGED
@@ -6,7 +6,6 @@ import { useLogger, type MilkioApp } from ".."
6
6
  export const executeApiTests = async <Path extends Array<keyof (typeof schema)["apiTestsSchema"]>>(app: MilkioApp, path: Path | string | true | 1 | undefined) => {
7
7
  console.log(`🥛 Milkio Api Testing..\n`)
8
8
 
9
- const logger = useLogger('global')
10
9
  let pathArr = [] as Array<string>
11
10
  if (!path || path === "1" || path === 1 || path === true) {
12
11
  pathArr = Object.keys(schema.apiTestsSchema) as unknown as Path
@@ -16,6 +15,9 @@ export const executeApiTests = async <Path extends Array<keyof (typeof schema)["
16
15
 
17
16
  const tests = []
18
17
  const startedAt = new Date().getTime()
18
+
19
+ const apiTestHooks = await import("../../../src/api-test.ts")
20
+ await apiTestHooks.default.onBootstrap()
19
21
 
20
22
  for (let path of pathArr) {
21
23
  if (path.startsWith("/")) path = path.slice(1) as Path[number]
@@ -38,6 +40,7 @@ export const executeApiTests = async <Path extends Array<keyof (typeof schema)["
38
40
  throw new Error("")
39
41
  }, cs.timeout ?? 8192)
40
42
  await cs.handler({
43
+ ...(await apiTestHooks.default.onBefore()) ?? {},
41
44
  log: (...args: Array<unknown>) => console.log(...args),
42
45
  // @ts-ignore
43
46
  execute: async (params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
package/c.ts CHANGED
@@ -30,6 +30,7 @@ const commands = {
30
30
  try { await $`clear` } catch (e) {}
31
31
  const command = Buffer.from(commandBase64ed, 'base64').toString('utf-8')
32
32
  console.log('\x1B[2m%s\x1B[0m', `$ ${command}`)
33
+ console.log(``)
33
34
  await $`${{ raw: command }}`
34
35
  process.on('SIGINT', () => {}) // prevent users from exiting by pressing ctrl + c
35
36
  while (true) await new Promise((resolve) => process.stdin.on('keypress', resolve))
@@ -1,6 +1,6 @@
1
- import { Logger } from ".."
2
1
  import { type Api, type ExecuteResult, type ExecuteOptions } from ".."
3
2
  import type schema from "../../../generated/api-schema"
3
+ import type apiTestHooks from "../../../src/api-test.ts"
4
4
 
5
5
  export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTestCases<ApiT>>) {
6
6
  return {
@@ -17,7 +17,7 @@ export type ApiTestCases<ApiT extends Api> = {
17
17
  randParams: () => Promise<Parameters<ApiT["action"]>[0]>;
18
18
  randOtherParams: <Path extends keyof (typeof schema)["apiMethodsTypeSchema"]>(path: Path) => Promise<Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]['api']['action']>[0]>;
19
19
  reject: (message?: string) => void;
20
- }) => Promise<void> | void;
20
+ } & Awaited<ReturnType<(typeof apiTestHooks)['onBefore']>>) => Promise<void> | void;
21
21
  name: string;
22
22
  timeout?: number;
23
23
  };
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.15",
5
+ "version": "0.0.16",
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
  }