@take-out/scripts 0.0.93 → 0.0.95

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.
@@ -2,10 +2,10 @@
2
2
  * ultra simple typed arg parsing
3
3
  *
4
4
  * @example
5
- * const { port, verbose, _ } = args`--port number --verbose boolean`
5
+ * const { port, verbose, rest } = args`--port number --verbose boolean`
6
6
  * // port: number | undefined
7
7
  * // verbose: boolean
8
- * // _: string[]
8
+ * // rest: string[] - positional args that don't match any flag
9
9
  */
10
10
 
11
11
  type ParseType<T extends string> = T extends 'number'
@@ -52,7 +52,7 @@ type ParseFlags<S extends string> =
52
52
  // flatten intersection into single object for nice hover display
53
53
  type Prettify<T> = { [K in keyof T]: T[K] } & {}
54
54
 
55
- type Args<S extends string> = Prettify<ParseFlags<S> & { _: string[] }>
55
+ export type Args<S extends string> = Prettify<ParseFlags<S> & { rest: string[] }>
56
56
 
57
57
  export function args<const S extends string>(spec: S): Args<S>
58
58
  export function args<const S extends string>(strings: TemplateStringsArray | S): Args<S> {
@@ -91,5 +91,5 @@ export function args<const S extends string>(strings: TemplateStringsArray | S):
91
91
  }
92
92
  }
93
93
 
94
- return { ...result, _: rest } as Args<S>
94
+ return { ...result, rest } as Args<S>
95
95
  }
@@ -9,9 +9,11 @@ export async function getTestEnv() {
9
9
  const zeroVersion = getZeroVersion()
10
10
  const dockerHost = getDockerHost()
11
11
  const devEnv = await loadEnv('development')
12
- const envPath = ['src/constants/env-server', 'src/server/env-server']
13
- .map((p) => join(process.cwd(), p))
14
- .find((p) => existsSync(p + '.ts')) || join(process.cwd(), 'src/constants/env-server')
12
+ const envPath =
13
+ ['src/constants/env-server', 'src/server/env-server']
14
+ .map((p) => join(process.cwd(), p))
15
+ .find((p) => existsSync(p + '.ts')) ||
16
+ join(process.cwd(), 'src/constants/env-server')
15
17
  const serverEnvFallback = await import(envPath)
16
18
 
17
19
  // ports come from VITE_PORT_* in .env.development (loaded by loadEnv)
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import fs from 'node:fs/promises'
4
- import path from 'node:path'
3
+ import { cmd } from './cmd'
5
4
 
6
5
  function getCurrentNodeVersion() {
7
6
  return process.version
8
7
  }
9
8
 
10
9
  async function getRequiredNodeVersion() {
10
+ const fs = await import('node:fs/promises')
11
+ const path = await import('node:path')
12
+
11
13
  // try .node-version file first
12
14
  try {
13
15
  const nodeVersionContent = await fs.readFile(
@@ -42,8 +44,10 @@ export async function checkNodeVersion() {
42
44
  }
43
45
 
44
46
  if (import.meta.main) {
45
- checkNodeVersion().catch((e: any) => {
46
- console.error(e.message)
47
- process.exit(1)
47
+ await cmd`verify node version matches project requirements`.run(async () => {
48
+ checkNodeVersion().catch((e: any) => {
49
+ console.error(e.message)
50
+ process.exit(1)
51
+ })
48
52
  })
49
53
  }