@c9up/ream 0.2.8 → 0.2.9

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 (51) hide show
  1. package/dist/Ignitor.d.ts.map +1 -1
  2. package/dist/Ignitor.js +51 -3
  3. package/dist/Ignitor.js.map +1 -1
  4. package/dist/commands/Migrate.d.ts +9 -0
  5. package/dist/commands/Migrate.d.ts.map +1 -0
  6. package/dist/commands/Migrate.js +16 -0
  7. package/dist/commands/Migrate.js.map +1 -0
  8. package/dist/commands/MigrateBase.d.ts +27 -0
  9. package/dist/commands/MigrateBase.d.ts.map +1 -0
  10. package/dist/commands/MigrateBase.js +77 -0
  11. package/dist/commands/MigrateBase.js.map +1 -0
  12. package/dist/commands/MigrateRollback.d.ts +9 -0
  13. package/dist/commands/MigrateRollback.d.ts.map +1 -0
  14. package/dist/commands/MigrateRollback.js +16 -0
  15. package/dist/commands/MigrateRollback.js.map +1 -0
  16. package/dist/commands/MigrateStatus.d.ts +9 -0
  17. package/dist/commands/MigrateStatus.d.ts.map +1 -0
  18. package/dist/commands/MigrateStatus.js +19 -0
  19. package/dist/commands/MigrateStatus.js.map +1 -0
  20. package/dist/commands/ScheduleList.d.ts +18 -0
  21. package/dist/commands/ScheduleList.d.ts.map +1 -0
  22. package/dist/commands/ScheduleList.js +55 -0
  23. package/dist/commands/ScheduleList.js.map +1 -0
  24. package/dist/commands/ScheduleRun.d.ts +19 -0
  25. package/dist/commands/ScheduleRun.d.ts.map +1 -0
  26. package/dist/commands/ScheduleRun.js +61 -0
  27. package/dist/commands/ScheduleRun.js.map +1 -0
  28. package/dist/commands/index.d.ts +15 -0
  29. package/dist/commands/index.d.ts.map +1 -0
  30. package/dist/commands/index.js +63 -0
  31. package/dist/commands/index.js.map +1 -0
  32. package/dist/commands/scheduler_resolver.d.ts +12 -0
  33. package/dist/commands/scheduler_resolver.d.ts.map +1 -0
  34. package/dist/commands/scheduler_resolver.js +19 -0
  35. package/dist/commands/scheduler_resolver.js.map +1 -0
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +1 -1
  38. package/events.win32-x64-msvc.node +0 -0
  39. package/index.win32-x64-msvc.node +0 -0
  40. package/package.json +5 -1
  41. package/scheduler.win32-x64-msvc.node +0 -0
  42. package/src/Ignitor.ts +51 -3
  43. package/src/commands/Migrate.ts +18 -0
  44. package/src/commands/MigrateBase.ts +81 -0
  45. package/src/commands/MigrateRollback.ts +18 -0
  46. package/src/commands/MigrateStatus.ts +22 -0
  47. package/src/commands/ScheduleList.ts +66 -0
  48. package/src/commands/ScheduleRun.ts +65 -0
  49. package/src/commands/index.ts +73 -0
  50. package/src/commands/scheduler_resolver.ts +23 -0
  51. package/src/index.ts +1 -1
@@ -0,0 +1,73 @@
1
+ /**
2
+ * `@c9up/ream/commands` — the commands the framework itself ships.
3
+ *
4
+ * The shape AdonisJS uses for `@adonisjs/core/commands`: a module answering
5
+ * `getMetaData()` then `getCommand()`, so listing a command does not import it.
6
+ *
7
+ * The kernel registers this loader on its own rather than waiting for an entry
8
+ * in `reamrc.commands` — the deviation from AdonisJS, where the starter kit
9
+ * lists it. These commands were part of the `ream` binary before they were
10
+ * classes, and an application that upgrades must not silently lose them.
11
+ */
12
+
13
+ import type { CommandClass, SerializedCommand } from '../console/types.js'
14
+
15
+ interface Entry {
16
+ commandName: string
17
+ description: string
18
+ load: () => Promise<{ default: CommandClass }>
19
+ }
20
+
21
+ const COMMANDS: readonly Entry[] = [
22
+ // The registry commands first: a data package registers its runner, and
23
+ // these drive whatever registered — they name no store.
24
+ {
25
+ commandName: 'migrate',
26
+ description: 'Run pending migrations for every registered migration source',
27
+ load: () => import('./Migrate.js'),
28
+ },
29
+ {
30
+ commandName: 'migrate:rollback',
31
+ description: 'Roll back the last batch for every registered migration source',
32
+ load: () => import('./MigrateRollback.js'),
33
+ },
34
+ {
35
+ commandName: 'migrate:status',
36
+ description: 'Show applied and pending migrations for every source',
37
+ load: () => import('./MigrateStatus.js'),
38
+ },
39
+ {
40
+ commandName: 'schedule:list',
41
+ description: 'List every registered scheduled task, its next run and its stats',
42
+ load: () => import('./ScheduleList.js'),
43
+ },
44
+ {
45
+ commandName: 'schedule:run',
46
+ description: 'Run a registered scheduled task once, now (bypasses the lock)',
47
+ load: () => import('./ScheduleRun.js'),
48
+ },
49
+ ]
50
+
51
+ /** `migrate:status` → `migrate`; a name without a colon has no namespace. */
52
+ function namespaceOf(commandName: string): string | null {
53
+ const colon = commandName.indexOf(':')
54
+ return colon === -1 ? null : commandName.slice(0, colon)
55
+ }
56
+
57
+ export async function getMetaData(): Promise<SerializedCommand[]> {
58
+ return COMMANDS.map((entry) => ({
59
+ commandName: entry.commandName,
60
+ namespace: namespaceOf(entry.commandName),
61
+ description: entry.description,
62
+ aliases: [],
63
+ options: { startApp: true },
64
+ args: [],
65
+ flags: [],
66
+ }))
67
+ }
68
+
69
+ export async function getCommand(metadata: SerializedCommand): Promise<CommandClass | null> {
70
+ const entry = COMMANDS.find((command) => command.commandName === metadata.commandName)
71
+ if (!entry) return null
72
+ return (await entry.load()).default
73
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Resolve the scheduler for the `schedule:*` commands.
3
+ *
4
+ * Shared because the failure is the same one on both, and it is a
5
+ * configuration mistake rather than a crash: the provider is simply not in the
6
+ * list, and the message has to say so — a container error mentioning an
7
+ * unbound `scheduler` binding tells an operator nothing.
8
+ */
9
+
10
+ import type { BaseCommand } from '../console/BaseCommand.js'
11
+ import type { Scheduler } from '../scheduler/Scheduler.js'
12
+
13
+ export async function resolveScheduler(command: BaseCommand): Promise<Scheduler | undefined> {
14
+ try {
15
+ return await command.app.container.resolve<Scheduler>('scheduler')
16
+ } catch {
17
+ command.logger.error(
18
+ 'No ScheduleProvider is registered. Add ScheduleProvider to the providers list in reamrc.ts.',
19
+ )
20
+ command.exitCode = 2
21
+ return undefined
22
+ }
23
+ }
package/src/index.ts CHANGED
@@ -371,4 +371,4 @@ export {
371
371
  StatsTracker,
372
372
  } from './scheduler/index.js'
373
373
 
374
- export const VERSION = '0.2.8'
374
+ export const VERSION = '0.2.9'