@remix-run/cli 0.3.4 → 0.4.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.
Files changed (118) hide show
  1. package/README.md +105 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/app-root.d.ts +11 -0
  4. package/dist/lib/app-root.d.ts.map +1 -0
  5. package/dist/lib/app-root.js +38 -0
  6. package/dist/lib/bootstrap-project.js +2 -2
  7. package/dist/lib/cli-context.d.ts +6 -0
  8. package/dist/lib/cli-context.d.ts.map +1 -1
  9. package/dist/lib/cli-context.js +12 -1
  10. package/dist/lib/cli.d.ts +3 -2
  11. package/dist/lib/cli.d.ts.map +1 -1
  12. package/dist/lib/cli.js +42 -14
  13. package/dist/lib/commands/completion.js +4 -4
  14. package/dist/lib/commands/db.d.ts +4 -0
  15. package/dist/lib/commands/db.d.ts.map +1 -0
  16. package/dist/lib/commands/db.js +283 -0
  17. package/dist/lib/commands/doctor.d.ts +5 -0
  18. package/dist/lib/commands/doctor.d.ts.map +1 -1
  19. package/dist/lib/commands/doctor.js +26 -251
  20. package/dist/lib/commands/help.d.ts.map +1 -1
  21. package/dist/lib/commands/help.js +17 -9
  22. package/dist/lib/commands/new.js +6 -6
  23. package/dist/lib/commands/routes.js +6 -6
  24. package/dist/lib/commands/test.d.ts +20 -1
  25. package/dist/lib/commands/test.d.ts.map +1 -1
  26. package/dist/lib/commands/test.js +353 -10
  27. package/dist/lib/commands/version.js +3 -3
  28. package/dist/lib/completion.d.ts +1 -1
  29. package/dist/lib/completion.d.ts.map +1 -1
  30. package/dist/lib/completion.js +229 -6
  31. package/dist/lib/controller-files.d.ts +0 -8
  32. package/dist/lib/controller-files.d.ts.map +1 -1
  33. package/dist/lib/controller-files.js +0 -23
  34. package/dist/lib/controller-ownership.d.ts +4 -12
  35. package/dist/lib/controller-ownership.d.ts.map +1 -1
  36. package/dist/lib/controller-ownership.js +31 -127
  37. package/dist/lib/database-command.d.ts +20 -0
  38. package/dist/lib/database-command.d.ts.map +1 -0
  39. package/dist/lib/database-command.js +7 -0
  40. package/dist/lib/doctor/controller-findings.d.ts +2 -2
  41. package/dist/lib/doctor/controller-findings.d.ts.map +1 -1
  42. package/dist/lib/doctor/controller-findings.js +23 -39
  43. package/dist/lib/doctor/controllers.d.ts +1 -2
  44. package/dist/lib/doctor/controllers.d.ts.map +1 -1
  45. package/dist/lib/doctor/controllers.js +4 -7
  46. package/dist/lib/doctor/environment.js +2 -2
  47. package/dist/lib/doctor/fixes.js +1 -1
  48. package/dist/lib/doctor/project.d.ts.map +1 -1
  49. package/dist/lib/doctor/project.js +3 -212
  50. package/dist/lib/doctor/run.d.ts +9 -0
  51. package/dist/lib/doctor/run.d.ts.map +1 -0
  52. package/dist/lib/doctor/run.js +237 -0
  53. package/dist/lib/doctor/types.d.ts +2 -1
  54. package/dist/lib/doctor/types.d.ts.map +1 -1
  55. package/dist/lib/doctor/types.js +4 -1
  56. package/dist/lib/errors.d.ts +30 -0
  57. package/dist/lib/errors.d.ts.map +1 -1
  58. package/dist/lib/errors.js +55 -0
  59. package/dist/lib/help-text.js +1 -1
  60. package/dist/lib/parse-args.d.ts.map +1 -1
  61. package/dist/lib/parse-args.js +17 -4
  62. package/dist/lib/remix-config.d.ts +75 -0
  63. package/dist/lib/remix-config.d.ts.map +1 -0
  64. package/dist/lib/remix-config.js +411 -0
  65. package/dist/lib/reporter.js +1 -1
  66. package/dist/lib/route-map.js +13 -33
  67. package/package.json +13 -7
  68. package/schema/remix.json +242 -0
  69. package/src/lib/app-root.ts +46 -0
  70. package/src/lib/cli-context.ts +17 -0
  71. package/src/lib/cli.ts +41 -6
  72. package/src/lib/commands/db.ts +377 -0
  73. package/src/lib/commands/doctor.ts +27 -329
  74. package/src/lib/commands/help.ts +10 -1
  75. package/src/lib/commands/test.ts +453 -12
  76. package/src/lib/completion.ts +321 -6
  77. package/src/lib/controller-files.ts +0 -38
  78. package/src/lib/controller-ownership.ts +50 -203
  79. package/src/lib/database-command.ts +31 -0
  80. package/src/lib/doctor/controller-findings.ts +30 -47
  81. package/src/lib/doctor/controllers.ts +2 -6
  82. package/src/lib/doctor/project.ts +0 -236
  83. package/src/lib/doctor/run.ts +311 -0
  84. package/src/lib/doctor/types.ts +6 -5
  85. package/src/lib/errors.ts +65 -0
  86. package/src/lib/parse-args.ts +19 -3
  87. package/src/lib/remix-config.ts +639 -0
  88. package/src/lib/route-map.ts +11 -48
  89. package/template/.agents/skills/remix/SKILL.md +38 -27
  90. package/template/.agents/skills/remix/references/assets-and-browser-modules.md +53 -10
  91. package/template/.agents/skills/remix/references/auth-and-sessions.md +5 -5
  92. package/template/.agents/skills/remix/references/data-and-validation.md +15 -15
  93. package/template/.agents/skills/remix/references/hydration-frames-navigation.md +54 -8
  94. package/template/.agents/skills/remix/references/middleware-and-server.md +68 -6
  95. package/template/.agents/skills/remix/references/mixins-styling-events.md +2 -0
  96. package/template/.agents/skills/remix/references/routing-and-controllers.md +8 -8
  97. package/template/.agents/skills/remix/references/testing-patterns.md +19 -18
  98. package/template/AGENTS.md +6 -3
  99. package/template/README.md +6 -3
  100. package/template/app/actions/controller.tsx +1 -1
  101. package/template/app/{ui → actions}/document.tsx +7 -5
  102. package/template/app/{ui/scaffold-home-page.tsx → actions/home-page.tsx} +1 -2
  103. package/template/app/actions/public/entry.ts +48 -0
  104. package/template/app/{assets → actions/public}/prompt-button.tsx +29 -25
  105. package/template/app/assets.ts +15 -2
  106. package/template/hmr.ts +46 -0
  107. package/template/package.json +1 -0
  108. package/template/server.ts +8 -1
  109. package/template/tsconfig.json +1 -1
  110. package/dist/lib/doctor/controller-fix-plans.d.ts +0 -4
  111. package/dist/lib/doctor/controller-fix-plans.d.ts.map +0 -1
  112. package/dist/lib/doctor/controller-fix-plans.js +0 -119
  113. package/dist/lib/doctor/controller-placeholders.d.ts +0 -3
  114. package/dist/lib/doctor/controller-placeholders.d.ts.map +0 -1
  115. package/dist/lib/doctor/controller-placeholders.js +0 -52
  116. package/src/lib/doctor/controller-fix-plans.ts +0 -168
  117. package/src/lib/doctor/controller-placeholders.ts +0 -70
  118. package/template/app/assets/entry.ts +0 -17
package/src/lib/errors.ts CHANGED
@@ -28,6 +28,16 @@ export const CLI_ERROR_DEFINITIONS = {
28
28
  title: 'Could not determine an app name',
29
29
  fix: 'Pass --app-name or choose a target directory name that can become an app name.',
30
30
  },
31
+ dbConfigRequired: {
32
+ code: 'RMX_DB_CONFIG_REQUIRED',
33
+ title: 'Database configuration is required',
34
+ fix: 'Add a db configuration to remix.json.',
35
+ },
36
+ dbForceRequired: {
37
+ code: 'RMX_DB_FORCE_REQUIRED',
38
+ title: 'Destructive database command requires --force',
39
+ fix: 'Re-run with --force to confirm.',
40
+ },
31
41
  remixVersionUnavailable: {
32
42
  code: 'RMX_REMIX_VERSION_UNAVAILABLE',
33
43
  title: 'Could not determine the Remix version',
@@ -55,6 +65,16 @@ export const CLI_ERROR_DEFINITIONS = {
55
65
  title: 'Could not derive a valid package name',
56
66
  fix: 'Choose an app name that can be normalized into a valid npm package name.',
57
67
  },
68
+ invalidOptionValue: {
69
+ code: 'RMX_INVALID_OPTION_VALUE',
70
+ title: 'Invalid option value',
71
+ fix: 'Check the command help for the supported option syntax.',
72
+ },
73
+ invalidRemixConfig: {
74
+ code: 'RMX_INVALID_CONFIG',
75
+ title: 'Invalid Remix configuration',
76
+ fix: 'Correct the configuration file and try again.',
77
+ },
58
78
  missingOptionValue: {
59
79
  code: 'RMX_MISSING_OPTION_VALUE',
60
80
  title: 'Missing option value',
@@ -70,6 +90,11 @@ export const CLI_ERROR_DEFINITIONS = {
70
90
  title: 'Could not find a project root',
71
91
  fix: 'Run this command inside a Remix project.',
72
92
  },
93
+ remixConfigNotFound: {
94
+ code: 'RMX_CONFIG_NOT_FOUND',
95
+ title: 'Remix configuration not found',
96
+ fix: 'Check the --config path and try again.',
97
+ },
73
98
  remoteSkillDataMissing: {
74
99
  code: 'RMX_REMOTE_SKILL_DATA_MISSING',
75
100
  title: 'Could not find remote Remix skill data',
@@ -169,6 +194,20 @@ export function appNameUnavailable(targetDir?: string): UsageError {
169
194
  })
170
195
  }
171
196
 
197
+ export function dbConfigRequired(filePath: string): CliError {
198
+ return createCliError(CLI_ERROR_DEFINITIONS.dbConfigRequired, {
199
+ context: { filePath },
200
+ message: `Database configuration is missing from ${filePath}.`,
201
+ })
202
+ }
203
+
204
+ export function dbForceRequired(command: string): UsageError {
205
+ return createUsageError(CLI_ERROR_DEFINITIONS.dbForceRequired, {
206
+ context: { command },
207
+ message: `\`remix db ${command}\` destroys data in the current app database.`,
208
+ })
209
+ }
210
+
172
211
  export function remixVersionUnavailable(): CliError {
173
212
  return createCliError(CLI_ERROR_DEFINITIONS.remixVersionUnavailable, {
174
213
  message: 'Could not determine the current Remix version.',
@@ -201,6 +240,25 @@ export function invalidPackageName(input: string): UsageError {
201
240
  })
202
241
  }
203
242
 
243
+ export function invalidOptionValue(details: string): UsageError {
244
+ return createUsageError(CLI_ERROR_DEFINITIONS.invalidOptionValue, {
245
+ context: { details },
246
+ message: details,
247
+ })
248
+ }
249
+
250
+ export function invalidRemixConfig(
251
+ filePath: string,
252
+ details: string,
253
+ line: number,
254
+ column: number,
255
+ ): CliError {
256
+ return createCliError(CLI_ERROR_DEFINITIONS.invalidRemixConfig, {
257
+ context: { column, filePath, line },
258
+ message: `${filePath}:${line}:${column}: ${details}`,
259
+ })
260
+ }
261
+
204
262
  export function missingOptionValue(option: string): UsageError {
205
263
  return createUsageError(CLI_ERROR_DEFINITIONS.missingOptionValue, {
206
264
  context: { option },
@@ -221,6 +279,13 @@ export function projectRootNotFound(startDir?: string): CliError {
221
279
  })
222
280
  }
223
281
 
282
+ export function remixConfigNotFound(filePath: string): CliError {
283
+ return createCliError(CLI_ERROR_DEFINITIONS.remixConfigNotFound, {
284
+ context: { filePath },
285
+ message: `Could not find Remix configuration file: ${filePath}`,
286
+ })
287
+ }
288
+
224
289
  export function remoteSkillDataMissing(name: string): CliError {
225
290
  return createCliError(CLI_ERROR_DEFINITIONS.remoteSkillDataMissing, {
226
291
  context: { name },
@@ -49,17 +49,33 @@ export function parseArgs<const definitions extends ParseArgsOptionDefinitions>(
49
49
 
50
50
  for (let index = 0; index < argv.length; index++) {
51
51
  let arg = argv[index]!
52
- let resolved = specsByFlag.get(arg)
52
+ let equalsIndex = arg.indexOf('=')
53
+ let flag = equalsIndex === -1 ? arg : arg.slice(0, equalsIndex)
54
+ let inlineValue = equalsIndex === -1 ? undefined : arg.slice(equalsIndex + 1)
55
+ let resolved = specsByFlag.get(flag)
53
56
 
54
57
  if (resolved != null) {
55
58
  if (resolved.spec.type === 'boolean') {
59
+ if (inlineValue !== undefined) {
60
+ throw unknownArgument(arg)
61
+ }
62
+
56
63
  values[resolved.key] = true as ParsedArgsValues<definitions>[typeof resolved.key]
57
64
  continue
58
65
  }
59
66
 
67
+ if (inlineValue !== undefined) {
68
+ if (inlineValue.length === 0) {
69
+ throw missingOptionValue(flag)
70
+ }
71
+
72
+ values[resolved.key] = inlineValue as ParsedArgsValues<definitions>[typeof resolved.key]
73
+ continue
74
+ }
75
+
60
76
  let next = argv[index + 1]
61
- if (next == null || next.startsWith('-')) {
62
- throw missingOptionValue(arg)
77
+ if (next == null || next.length === 0 || next.startsWith('-')) {
78
+ throw missingOptionValue(flag)
63
79
  }
64
80
 
65
81
  values[resolved.key] = next as ParsedArgsValues<definitions>[typeof resolved.key]