lopata 0.12.0 → 0.13.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lopata",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,6 +21,15 @@ export function hasFlag(args: string[], name: string): boolean {
21
21
  return args.includes(name)
22
22
  }
23
23
 
24
+ /** Exit with an error if --remote is passed, suggesting the equivalent wrangler command. */
25
+ export function rejectRemoteFlag(args: string[]): void {
26
+ if (args.includes('--remote')) {
27
+ const wranglerCmd = `wrangler ${args.join(' ')}`
28
+ console.error(`Error: --remote is not supported by lopata. Lopata is a local-only runtime.\nDid you mean: ${wranglerCmd}`)
29
+ process.exit(1)
30
+ }
31
+ }
32
+
24
33
  /** Get positional args (everything that's not a flag or flag value). */
25
34
  export function positionalArgs(args: string[], flags: string[]): string[] {
26
35
  const result: string[] = []
package/src/cli.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { createContext, hasFlag } from './cli/context'
3
+ import { createContext, hasFlag, rejectRemoteFlag } from './cli/context'
4
4
 
5
5
  const ctx = createContext(process.argv)
6
6
  const args = ctx.args
@@ -19,6 +19,8 @@ for (let i = 0; i < args.length; i++) {
19
19
  const command = commandArgs[0]
20
20
  const subcommand = commandArgs[1]
21
21
 
22
+ rejectRemoteFlag(args)
23
+
22
24
  if (!command || hasFlag(args, '--help') || hasFlag(args, '-h')) {
23
25
  printHelp()
24
26
  process.exit(0)
package/src/d1-migrate.ts CHANGED
@@ -9,17 +9,15 @@
9
9
  */
10
10
 
11
11
  import { join, resolve } from 'node:path'
12
+ import { parseFlag, rejectRemoteFlag } from './cli/context'
12
13
  import { applyMigrations } from './cli/d1'
13
14
  import { autoLoadConfig, loadConfig } from './config'
14
15
 
15
- // Parse CLI flags
16
- function parseFlag(name: string): string | undefined {
17
- const idx = process.argv.indexOf(name)
18
- return idx !== -1 ? process.argv[idx + 1] : undefined
19
- }
16
+ const args = process.argv.slice(2)
17
+ rejectRemoteFlag(args)
20
18
 
21
- const configPath = parseFlag('--config') ?? parseFlag('-c')
22
- const envName = parseFlag('--env') ?? parseFlag('-e')
19
+ const configPath = parseFlag(args, '--config') ?? parseFlag(args, '-c')
20
+ const envName = parseFlag(args, '--env') ?? parseFlag(args, '-e')
23
21
  const baseDir = process.cwd()
24
22
 
25
23
  const config = configPath