@c9up/ream 0.2.25 → 0.2.26

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 (78) hide show
  1. package/README.md +2 -0
  2. package/dist/Codemods.d.ts +12 -0
  3. package/dist/Codemods.d.ts.map +1 -1
  4. package/dist/Codemods.js +114 -23
  5. package/dist/Codemods.js.map +1 -1
  6. package/dist/console/Kernel.d.ts.map +1 -1
  7. package/dist/console/Kernel.js +20 -1
  8. package/dist/console/Kernel.js.map +1 -1
  9. package/dist/console/cliui.d.ts +9 -245
  10. package/dist/console/cliui.d.ts.map +1 -1
  11. package/dist/console/cliui.js +9 -583
  12. package/dist/console/cliui.js.map +1 -1
  13. package/dist/console/make/commands.d.ts +19 -0
  14. package/dist/console/make/commands.d.ts.map +1 -0
  15. package/dist/console/make/commands.js +252 -0
  16. package/dist/console/make/commands.js.map +1 -0
  17. package/dist/console/make/eject.d.ts +28 -0
  18. package/dist/console/make/eject.d.ts.map +1 -0
  19. package/dist/console/make/eject.js +161 -0
  20. package/dist/console/make/eject.js.map +1 -0
  21. package/dist/console/make/flush.d.ts +51 -0
  22. package/dist/console/make/flush.d.ts.map +1 -0
  23. package/dist/console/make/flush.js +93 -0
  24. package/dist/console/make/flush.js.map +1 -0
  25. package/dist/console/make/generators.d.ts +36 -0
  26. package/dist/console/make/generators.d.ts.map +1 -0
  27. package/dist/console/make/generators.js +148 -0
  28. package/dist/console/make/generators.js.map +1 -0
  29. package/dist/console/make/naming.d.ts +32 -0
  30. package/dist/console/make/naming.d.ts.map +1 -0
  31. package/dist/console/make/naming.js +82 -0
  32. package/dist/console/make/naming.js.map +1 -0
  33. package/dist/console/make/resolve.d.ts +46 -0
  34. package/dist/console/make/resolve.d.ts.map +1 -0
  35. package/dist/console/make/resolve.js +113 -0
  36. package/dist/console/make/resolve.js.map +1 -0
  37. package/dist/console/ui.d.ts +9 -15
  38. package/dist/console/ui.d.ts.map +1 -1
  39. package/dist/console/ui.js +11 -24
  40. package/dist/console/ui.js.map +1 -1
  41. package/dist/index.d.ts +3 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +4 -2
  44. package/dist/index.js.map +1 -1
  45. package/dist/stubs/index.d.ts +11 -0
  46. package/dist/stubs/index.d.ts.map +1 -0
  47. package/dist/stubs/index.js +12 -0
  48. package/dist/stubs/index.js.map +1 -0
  49. package/dist/stubs/template.d.ts +63 -0
  50. package/dist/stubs/template.d.ts.map +1 -0
  51. package/dist/stubs/template.js +209 -0
  52. package/dist/stubs/template.js.map +1 -0
  53. package/events.win32-x64-msvc.node +0 -0
  54. package/index.win32-x64-msvc.node +0 -0
  55. package/package.json +7 -1
  56. package/scheduler.win32-x64-msvc.node +0 -0
  57. package/src/Codemods.ts +153 -29
  58. package/src/console/Kernel.ts +21 -1
  59. package/src/console/cliui.ts +44 -754
  60. package/src/console/make/commands.ts +270 -0
  61. package/src/console/make/eject.ts +163 -0
  62. package/src/console/make/flush.ts +125 -0
  63. package/src/console/make/generators.ts +176 -0
  64. package/src/console/make/naming.ts +85 -0
  65. package/src/console/make/resolve.ts +134 -0
  66. package/src/console/ui.ts +12 -24
  67. package/src/index.ts +17 -3
  68. package/src/stubs/index.ts +14 -0
  69. package/src/stubs/template.ts +262 -0
  70. package/stubs/make/command.stub +29 -0
  71. package/stubs/make/controller.stub +30 -0
  72. package/stubs/make/entity.stub +11 -0
  73. package/stubs/make/event.stub +13 -0
  74. package/stubs/make/listener.stub +13 -0
  75. package/stubs/make/middleware.stub +16 -0
  76. package/stubs/make/provider.stub +26 -0
  77. package/stubs/make/service.stub +27 -0
  78. package/stubs/make/validator.stub +10 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * What each `make:` command generates.
3
+ *
4
+ * One table rather than ten near-identical commands: every generator is a
5
+ * name, a stub and the variables that stub reads. The differences that matter
6
+ * — which suffix a class carries, whether the name is snake_cased for the file
7
+ * — live here, in one place, instead of being spread across ten files that
8
+ * drift.
9
+ *
10
+ * The DESTINATION is not here. It is in the stub's own front matter, so an
11
+ * application that publishes `stubs/make/controller.stub` can move the file as
12
+ * well as change its contents.
13
+ */
14
+ import type { StubState } from '../../stubs/template.js';
15
+ /** Extra input a generator takes beyond the name. */
16
+ export interface GeneratorInput {
17
+ /** `app/<module>/…` — where a module-scoped file lands. */
18
+ module?: string;
19
+ /** `make:middleware --stack server|router|named`. */
20
+ stack?: string;
21
+ /** `make:listener --event OrderShipped`. */
22
+ event?: string;
23
+ }
24
+ export interface Generator {
25
+ /** The stub, under `stubs/make/`. */
26
+ kind: string;
27
+ commandName: string;
28
+ description: string;
29
+ /** Does it take `--module`? */
30
+ moduleScoped: boolean;
31
+ /** The variables its stub reads. */
32
+ state(name: string, input: GeneratorInput): StubState;
33
+ }
34
+ export declare const GENERATORS: readonly Generator[];
35
+ export declare function generatorFor(kind: string): Generator | undefined;
36
+ //# sourceMappingURL=generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../../src/console/make/generators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGxD,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,SAAS;IACxB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,YAAY,EAAE,OAAO,CAAA;IACrB,oCAAoC;IACpC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,SAAS,CAAA;CACtD;AAOD,eAAO,MAAM,UAAU,EAAE,SAAS,SAAS,EAgI1C,CAAA;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEhE"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * What each `make:` command generates.
3
+ *
4
+ * One table rather than ten near-identical commands: every generator is a
5
+ * name, a stub and the variables that stub reads. The differences that matter
6
+ * — which suffix a class carries, whether the name is snake_cased for the file
7
+ * — live here, in one place, instead of being spread across ten files that
8
+ * drift.
9
+ *
10
+ * The DESTINATION is not here. It is in the stub's own front matter, so an
11
+ * application that publishes `stubs/make/controller.stub` can move the file as
12
+ * well as change its contents.
13
+ */
14
+ import { ensureSuffix, stripSuffixInsensitive, toPascalCase, toSnakeCase } from './naming.js';
15
+ /** The shared trio every stub may read. */
16
+ function base(name, className, module) {
17
+ return { className, module, name };
18
+ }
19
+ export const GENERATORS = [
20
+ {
21
+ kind: 'controller',
22
+ commandName: 'make:controller',
23
+ description: 'Generate an HTTP controller',
24
+ moduleScoped: true,
25
+ state: (name, input) => base(name, ensureSuffix(name, 'Controller'), input.module ?? 'controllers'),
26
+ },
27
+ {
28
+ kind: 'service',
29
+ commandName: 'make:service',
30
+ description: 'Generate a service class',
31
+ moduleScoped: true,
32
+ state: (name, input) => base(name, ensureSuffix(name, 'Service'), input.module ?? 'services'),
33
+ },
34
+ {
35
+ kind: 'entity',
36
+ commandName: 'make:entity',
37
+ description: 'Generate an Atlas entity',
38
+ moduleScoped: true,
39
+ state: (name, input) => ({
40
+ // No suffix: an entity is `User`, not `UserEntity`.
41
+ ...base(name, toPascalCase(name), input.module ?? 'entities'),
42
+ tableName: `${toSnakeCase(name)}s`,
43
+ }),
44
+ },
45
+ {
46
+ kind: 'validator',
47
+ commandName: 'make:validator',
48
+ description: 'Generate a Rune validator',
49
+ moduleScoped: true,
50
+ state: (name, input) => base(name, ensureSuffix(name, 'Validator'), input.module ?? 'validators'),
51
+ },
52
+ {
53
+ kind: 'provider',
54
+ commandName: 'make:provider',
55
+ description: 'Generate a service provider',
56
+ moduleScoped: false,
57
+ state: (name) => base(name, ensureSuffix(name, 'Provider'), ''),
58
+ },
59
+ {
60
+ kind: 'command',
61
+ commandName: 'make:command',
62
+ description: 'Generate a console command',
63
+ moduleScoped: false,
64
+ state: (name) => {
65
+ // `app:provision` is the command NAME; the class and the file come from
66
+ // its last segment, or the published stub would generate a command
67
+ // unreachable under the name it was asked for.
68
+ const segments = name.split(':');
69
+ const last = segments[segments.length - 1] ?? name;
70
+ return {
71
+ className: toPascalCase(toSnakeCase(last)),
72
+ fileName: toSnakeCase(last),
73
+ name,
74
+ };
75
+ },
76
+ },
77
+ {
78
+ kind: 'middleware',
79
+ commandName: 'make:middleware',
80
+ description: 'Generate an HTTP middleware',
81
+ moduleScoped: false,
82
+ state: (name, input) => {
83
+ const fileName = toSnakeCase(stripSuffixInsensitive(name, 'middleware'));
84
+ const stack = input.stack ?? 'router';
85
+ const importer = `() => import('#middleware/${fileName}_middleware.js')`;
86
+ // The line the user pastes into their kernel — different per stack, and
87
+ // wrong in a way that is hard to spot if it is guessed.
88
+ const registration = stack === 'server'
89
+ ? `server.use([${importer}])`
90
+ : stack === 'named'
91
+ ? `router.named({ ${fileName}: ${importer} })`
92
+ : `router.use([${importer}])`;
93
+ return {
94
+ className: `${toPascalCase(fileName)}Middleware`,
95
+ fileName,
96
+ name,
97
+ registration,
98
+ stack,
99
+ };
100
+ },
101
+ },
102
+ {
103
+ kind: 'event',
104
+ commandName: 'make:event',
105
+ description: 'Generate an event class',
106
+ moduleScoped: false,
107
+ state: (name) => {
108
+ const fileName = toSnakeCase(name);
109
+ return { className: toPascalCase(fileName), fileName, name };
110
+ },
111
+ },
112
+ {
113
+ kind: 'listener',
114
+ commandName: 'make:listener',
115
+ description: 'Generate an event listener',
116
+ moduleScoped: false,
117
+ state: (name, input) => {
118
+ const fileName = toSnakeCase(name);
119
+ const className = toPascalCase(fileName);
120
+ if (input.event === undefined) {
121
+ // Without `--event` there is nothing to type the handler with, and
122
+ // inventing an import would point at a file that does not exist.
123
+ return {
124
+ className,
125
+ fileName,
126
+ name,
127
+ importLine: '',
128
+ eventType: 'unknown',
129
+ registration: `emitter.on(SomeEvent, ${className})`,
130
+ };
131
+ }
132
+ const eventFile = toSnakeCase(input.event);
133
+ const eventClass = toPascalCase(eventFile);
134
+ return {
135
+ className,
136
+ fileName,
137
+ name,
138
+ importLine: `import type ${eventClass} from '#app/events/${eventFile}.js'\n\n`,
139
+ eventType: eventClass,
140
+ registration: `emitter.on(${eventClass}, ${className})`,
141
+ };
142
+ },
143
+ },
144
+ ];
145
+ export function generatorFor(kind) {
146
+ return GENERATORS.find((generator) => generator.kind === kind);
147
+ }
148
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../src/console/make/generators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAuB7F,2CAA2C;AAC3C,SAAS,IAAI,CAAC,IAAY,EAAE,SAAiB,EAAE,MAAc;IAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAyB;IAC9C;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,6BAA6B;QAC1C,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACrB,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,aAAa,CAAC;KAC9E;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,0BAA0B;QACvC,YAAY,EAAE,IAAI;QAClB,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generator they replace, case for case: a rename here
5
+ * changes what `make:controller user` produces, so the rules are written out
6
+ * rather than approximated.
7
+ */
8
+ /** Add the suffix unless the name already carries it. */
9
+ export declare function ensureSuffix(name: string, suffix: string): string;
10
+ /** `user_profile` / `user-profile` / `user profile` → `UserProfile`. */
11
+ export declare function toPascalCase(name: string): string;
12
+ /**
13
+ * `UserProfile` → `user_profile`, `HTTPServer` → `http_server`.
14
+ *
15
+ * The acronym case is why this is not a one-line regex: an underscore goes
16
+ * before a capital that FOLLOWS a lowercase, or that follows a capital and is
17
+ * followed by a lowercase — which is where `HTTPServer` splits.
18
+ */
19
+ export declare function toSnakeCase(name: string): string;
20
+ /** Drop a trailing `Middleware` / `middleware` / `_middleware`, whatever the case. */
21
+ export declare function stripSuffixInsensitive(name: string, suffix: string): string;
22
+ /** Longer than this is not a name, it is a paste accident. */
23
+ export declare const MAX_NAME_LENGTH = 128;
24
+ /**
25
+ * Is this a name a generator may build a path from?
26
+ *
27
+ * Refused rather than sanitised: a name with a separator in it is either a
28
+ * mistake or an attempt to write outside the project, and quietly rewriting it
29
+ * would produce a file somewhere the user did not ask for.
30
+ */
31
+ export declare function nameProblem(name: string): string | undefined;
32
+ //# sourceMappingURL=naming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../src/console/make/naming.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBhD;AAED,sFAAsF;AACtF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAO3E;AAED,8DAA8D;AAC9D,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS5D"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The naming conventions the generators follow.
3
+ *
4
+ * Ported from the Rust generator they replace, case for case: a rename here
5
+ * changes what `make:controller user` produces, so the rules are written out
6
+ * rather than approximated.
7
+ */
8
+ /** Add the suffix unless the name already carries it. */
9
+ export function ensureSuffix(name, suffix) {
10
+ return name.endsWith(suffix) ? name : `${name}${suffix}`;
11
+ }
12
+ /** `user_profile` / `user-profile` / `user profile` → `UserProfile`. */
13
+ export function toPascalCase(name) {
14
+ return name
15
+ .split(/[_\-\s]/)
16
+ .filter((part) => part !== '')
17
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
18
+ .join('');
19
+ }
20
+ /**
21
+ * `UserProfile` → `user_profile`, `HTTPServer` → `http_server`.
22
+ *
23
+ * The acronym case is why this is not a one-line regex: an underscore goes
24
+ * before a capital that FOLLOWS a lowercase, or that follows a capital and is
25
+ * followed by a lowercase — which is where `HTTPServer` splits.
26
+ */
27
+ export function toSnakeCase(name) {
28
+ const chars = [...name];
29
+ let out = '';
30
+ for (const [index, char] of chars.entries()) {
31
+ if (char.toUpperCase() === char && char.toLowerCase() !== char) {
32
+ const previous = chars[index - 1];
33
+ const next = chars[index + 1];
34
+ const previousLower = previous !== undefined &&
35
+ previous === previous.toLowerCase() &&
36
+ previous !== previous.toUpperCase();
37
+ const nextLower = next !== undefined && next === next.toLowerCase() && next !== next.toUpperCase();
38
+ const previousUpper = previous !== undefined &&
39
+ previous === previous.toUpperCase() &&
40
+ previous !== previous.toLowerCase();
41
+ if (index > 0 && (previousLower || (nextLower && previousUpper)))
42
+ out += '_';
43
+ out += char.toLowerCase();
44
+ continue;
45
+ }
46
+ out += char;
47
+ }
48
+ return out;
49
+ }
50
+ /** Drop a trailing `Middleware` / `middleware` / `_middleware`, whatever the case. */
51
+ export function stripSuffixInsensitive(name, suffix) {
52
+ const lower = name.toLowerCase();
53
+ const suffixLower = suffix.toLowerCase();
54
+ if (lower.length > suffixLower.length && lower.endsWith(suffixLower)) {
55
+ return name.slice(0, name.length - suffix.length).replace(/[_-]+$/, '');
56
+ }
57
+ return name;
58
+ }
59
+ /** Longer than this is not a name, it is a paste accident. */
60
+ export const MAX_NAME_LENGTH = 128;
61
+ /**
62
+ * Is this a name a generator may build a path from?
63
+ *
64
+ * Refused rather than sanitised: a name with a separator in it is either a
65
+ * mistake or an attempt to write outside the project, and quietly rewriting it
66
+ * would produce a file somewhere the user did not ask for.
67
+ */
68
+ export function nameProblem(name) {
69
+ if (name.trim() === '')
70
+ return 'the name is empty';
71
+ if (name.length > MAX_NAME_LENGTH)
72
+ return `the name is longer than ${MAX_NAME_LENGTH} characters`;
73
+ if (/[/\\]/.test(name))
74
+ return 'a name may not contain a path separator';
75
+ if (name.includes('..'))
76
+ return 'a name may not contain ".."';
77
+ if (!/^[A-Za-z][A-Za-z0-9_\-:]*$/.test(name)) {
78
+ return 'a name starts with a letter and holds letters, digits, "_", "-" or ":"';
79
+ }
80
+ return undefined;
81
+ }
82
+ //# sourceMappingURL=naming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../src/console/make/naming.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yDAAyD;AACzD,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,EAAE,CAAA;AAC1D,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI;SACR,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,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ub, rendering it, and knowing where it goes.
3
+ *
4
+ * A stub is addressed the way `codemods.makeUsingStub` addresses one — a
5
+ * package's `stubsRoot` plus a path inside it, `make/controller.stub` — so a
6
+ * generator and a package's `configure()` hook read the same file through the
7
+ * same rule. The application's own copy under `stubs/` wins over the shipped
8
+ * one, which is what `ream eject` is for.
9
+ */
10
+ import { type StubState } from '../../stubs/template.js';
11
+ /** Where an application keeps its own copies — Adonis' `stubs/` root. */
12
+ export declare const PUBLISHED_ROOT = "stubs";
13
+ /** The stubs this package ships. */
14
+ export declare const REAM_STUBS_ROOT: string;
15
+ export interface RenderedStub {
16
+ /** Relative to the project root, as the stub's front matter declares it. */
17
+ path: string;
18
+ contents: string;
19
+ /** Did the application's own copy win? */
20
+ published: boolean;
21
+ }
22
+ /**
23
+ * A stub path that could escape its root never reaches the filesystem.
24
+ *
25
+ * `eject` takes one from the command line, so this is the boundary: no
26
+ * absolute path, no `..`, and a `.stub` file at the end of it.
27
+ */
28
+ export declare function isSafeStubPath(stubPath: string): boolean;
29
+ /** Where the application's copy of `stubPath` would live. */
30
+ export declare function publishedPath(stubPath: string, cwd: string): string | undefined;
31
+ /** Read `stubPath` — the application's copy when there is one. */
32
+ export declare function readStub(stubsRoot: string, stubPath: string, cwd: string): {
33
+ source: string;
34
+ published: boolean;
35
+ };
36
+ /** Split `---\nto: …\n---\n<body>`; the front matter names the destination. */
37
+ export declare function splitFrontMatter(template: string): {
38
+ to?: string;
39
+ body: string;
40
+ };
41
+ export declare function renderStub(stubsRoot: string, stubPath: string, state: StubState, cwd: string, fallbackPath?: string): RenderedStub;
42
+ /** `make/controller.stub` — the stub a generator of that kind reads. */
43
+ export declare function stubPathFor(kind: string): string;
44
+ /** Render one of this package's own generator stubs. */
45
+ export declare function renderStubFor(kind: string, state: StubState, cwd: string): RenderedStub;
46
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/console/make/resolve.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GAAG,YAAY,CAEvF"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Finding a stub, rendering it, and knowing where it goes.
3
+ *
4
+ * A stub is addressed the way `codemods.makeUsingStub` addresses one — a
5
+ * package's `stubsRoot` plus a path inside it, `make/controller.stub` — so a
6
+ * generator and a package's `configure()` hook read the same file through the
7
+ * same rule. The application's own copy under `stubs/` wins over the shipped
8
+ * one, which is what `ream eject` is for.
9
+ */
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import { render } from '../../stubs/template.js';
13
+ /** Where an application keeps its own copies — Adonis' `stubs/` root. */
14
+ export const PUBLISHED_ROOT = 'stubs';
15
+ /** The stubs this package ships. */
16
+ export const REAM_STUBS_ROOT = path.join(import.meta.dirname, '..', '..', '..', 'stubs');
17
+ /**
18
+ * A stub path that could escape its root never reaches the filesystem.
19
+ *
20
+ * `eject` takes one from the command line, so this is the boundary: no
21
+ * absolute path, no `..`, and a `.stub` file at the end of it.
22
+ */
23
+ export function isSafeStubPath(stubPath) {
24
+ if (stubPath === '' || stubPath.length > 256)
25
+ return false;
26
+ if (path.isAbsolute(stubPath))
27
+ return false;
28
+ const segments = stubPath.split(/[/\\]/);
29
+ if (segments.includes('..') || segments.includes(''))
30
+ return false;
31
+ return segments.every((segment) => /^[\w.-]+$/.test(segment));
32
+ }
33
+ /** Where the application's copy of `stubPath` would live. */
34
+ export function publishedPath(stubPath, cwd) {
35
+ if (!isSafeStubPath(stubPath))
36
+ return undefined;
37
+ return path.join(cwd, PUBLISHED_ROOT, stubPath);
38
+ }
39
+ /** Read `stubPath` — the application's copy when there is one. */
40
+ export function readStub(stubsRoot, stubPath, cwd) {
41
+ const published = publishedPath(stubPath, cwd);
42
+ if (published !== undefined && fs.existsSync(published)) {
43
+ return { source: fs.readFileSync(published, 'utf8'), published: true };
44
+ }
45
+ if (!isSafeStubPath(stubPath)) {
46
+ throw new Error(`[make] unusable stub path: ${stubPath}`);
47
+ }
48
+ const shipped = path.join(stubsRoot, stubPath);
49
+ if (!fs.existsSync(shipped)) {
50
+ throw new Error(`[make] no stub at "${stubPath}" (looked in ${stubsRoot})`);
51
+ }
52
+ return { source: fs.readFileSync(shipped, 'utf8'), published: false };
53
+ }
54
+ /** Split `---\nto: …\n---\n<body>`; the front matter names the destination. */
55
+ export function splitFrontMatter(template) {
56
+ const trimmed = template.replace(/^[\r\n]+/, '');
57
+ if (!trimmed.startsWith('---'))
58
+ return { body: template };
59
+ const after = trimmed.slice(3).replace(/^\r?\n/, '');
60
+ const end = after.indexOf('\n---');
61
+ if (end === -1) {
62
+ throw new Error('[make] a stub opened its front matter with `---` and never closed it');
63
+ }
64
+ const block = after.slice(0, end);
65
+ const body = after.slice(end + 4).replace(/^\r?\n/, '');
66
+ let to;
67
+ for (const rawLine of block.split('\n')) {
68
+ const line = rawLine.trim();
69
+ if (line === '' || line.startsWith('#'))
70
+ continue;
71
+ const at = line.indexOf(':');
72
+ if (at === -1)
73
+ throw new Error(`[make] unreadable stub front-matter line: \`${line}\``);
74
+ if (line.slice(0, at).trim() === 'to')
75
+ to = line.slice(at + 1).trim();
76
+ }
77
+ return to === undefined ? { body } : { to, body };
78
+ }
79
+ /**
80
+ * The destination a stub declares, checked.
81
+ *
82
+ * Absolute paths and `..` are refused rather than normalised: a published stub
83
+ * is a file in the project, and a generator is not a way to write outside it.
84
+ */
85
+ function assertInsideProject(destination) {
86
+ if (destination === '')
87
+ throw new Error('[make] the stub declares an empty destination');
88
+ if (path.isAbsolute(destination)) {
89
+ throw new Error(`[make] a stub may not write to an absolute path: ${destination}`);
90
+ }
91
+ if (destination.split(/[/\\]/).includes('..')) {
92
+ throw new Error(`[make] a stub may not write outside the project: ${destination}`);
93
+ }
94
+ }
95
+ export function renderStub(stubsRoot, stubPath, state, cwd, fallbackPath) {
96
+ const { source, published } = readStub(stubsRoot, stubPath, cwd);
97
+ const { to, body } = splitFrontMatter(source);
98
+ const destination = to === undefined ? fallbackPath : render(to, state);
99
+ if (destination === undefined) {
100
+ throw new Error(`[make] the stub at "${stubPath}" declares no destination — add a \`to:\` front-matter line.`);
101
+ }
102
+ assertInsideProject(destination);
103
+ return { path: destination, contents: render(body, state), published };
104
+ }
105
+ /** `make/controller.stub` — the stub a generator of that kind reads. */
106
+ export function stubPathFor(kind) {
107
+ return `make/${kind}.stub`;
108
+ }
109
+ /** Render one of this package's own generator stubs. */
110
+ export function renderStubFor(kind, state, cwd) {
111
+ return renderStub(REAM_STUBS_ROOT, stubPathFor(kind), state, cwd);
112
+ }
113
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/console/make/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,MAAM,EAAkB,MAAM,yBAAyB,CAAA;AAEhE,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAA;AAErC,oCAAoC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAUxF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,QAAQ,KAAK,EAAE,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAA;IAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IAC3C,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxC,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,KAAK,CAAA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,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;AACxE,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,IAAI,OAAO,CAAA;AAC5B,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAgB,EAAE,GAAW;IACvE,OAAO,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;AACnE,CAAC"}
@@ -1,20 +1,14 @@
1
1
  /**
2
- * Console UI — `this.logger` and `this.prompt` on every command (Console parity).
2
+ * The one colour helper the Kernel's help and the prompts use.
3
3
  *
4
- * Kept dependency-free: the framework ships no colour or prompt library, and
5
- * pulling one in for the CLI surface alone is not worth the install weight.
4
+ * It is a thin call into `@c9up/lumen` rather than a second palette: two
5
+ * tables of escape codes in one package is how `[ warn ]` ends up yellow in
6
+ * one command and plain in another.
7
+ *
8
+ * The environment is read on EVERY call, not cached, because a command can be
9
+ * run in-process with the environment changed around it — which is exactly
10
+ * what the tests covering `FORCE_COLOR` do.
6
11
  */
7
- declare const CODES: {
8
- readonly reset: "\u001B[0m";
9
- readonly dim: "\u001B[2m";
10
- readonly red: "\u001B[31m";
11
- readonly green: "\u001B[32m";
12
- readonly yellow: "\u001B[33m";
13
- readonly blue: "\u001B[34m";
14
- readonly magenta: "\u001B[35m";
15
- readonly cyan: "\u001B[36m";
16
- };
17
- export type Colour = keyof Omit<typeof CODES, 'reset'>;
12
+ export type Colour = 'dim' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan';
18
13
  export declare function colourise(text: string, colour: Colour, stream?: NodeJS.WriteStream): string;
19
- export {};
20
14
  //# sourceMappingURL=ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/console/ui.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,QAAA,MAAM,KAAK;;;;;;;;;CASD,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,KAAK,EAAE,OAAO,CAAC,CAAA;AAEtD,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,WAAoB,GAClC,MAAM,CAGR"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/console/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAA;AAErF,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,WAAoB,GAClC,MAAM,CAGR"}
@@ -1,31 +1,18 @@
1
1
  /**
2
- * Console UI — `this.logger` and `this.prompt` on every command (Console parity).
2
+ * The one colour helper the Kernel's help and the prompts use.
3
3
  *
4
- * Kept dependency-free: the framework ships no colour or prompt library, and
5
- * pulling one in for the CLI surface alone is not worth the install weight.
4
+ * It is a thin call into `@c9up/lumen` rather than a second palette: two
5
+ * tables of escape codes in one package is how `[ warn ]` ends up yellow in
6
+ * one command and plain in another.
7
+ *
8
+ * The environment is read on EVERY call, not cached, because a command can be
9
+ * run in-process with the environment changed around it — which is exactly
10
+ * what the tests covering `FORCE_COLOR` do.
6
11
  */
7
12
  import { stdout } from 'node:process';
8
- /** Colour is opt-out via NO_COLOR and skipped when piped to a file. */
9
- function supportsColour(stream) {
10
- if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== '')
11
- return false;
12
- if (process.env.FORCE_COLOR !== undefined && process.env.FORCE_COLOR !== '')
13
- return true;
14
- return Boolean(stream.isTTY);
15
- }
16
- const CODES = {
17
- reset: '\u001B[0m',
18
- dim: '\u001B[2m',
19
- red: '\u001B[31m',
20
- green: '\u001B[32m',
21
- yellow: '\u001B[33m',
22
- blue: '\u001B[34m',
23
- magenta: '\u001B[35m',
24
- cyan: '\u001B[36m',
25
- };
13
+ import { ansiColors, silentColors, supportsColor } from '@c9up/lumen';
26
14
  export function colourise(text, colour, stream = stdout) {
27
- if (!supportsColour(stream))
28
- return text;
29
- return `${CODES[colour]}${text}${CODES.reset}`;
15
+ const colors = supportsColor(stream) ? ansiColors() : silentColors();
16
+ return colors[colour](text);
30
17
  }
31
18
  //# sourceMappingURL=ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/console/ui.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,uEAAuE;AACvE,SAAS,cAAc,CAAC,MAA0B;IAChD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IACnF,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE;QAAE,OAAO,IAAI,CAAA;IACxF,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,YAAY;IACrB,IAAI,EAAE,YAAY;CACV,CAAA;AAIV,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,MAAc,EACd,SAA6B,MAAM;IAEnC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACxC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;AAChD,CAAC"}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/console/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAe,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIlF,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,MAAc,EACd,SAA6B,MAAM;IAEnC,MAAM,MAAM,GAAW,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -95,8 +95,8 @@ export { errors } from './errors/aggregate.js';
95
95
  export type { AppContext, ConfigReader, ProviderContract } from './Provider.js';
96
96
  export { Provider } from './Provider.js';
97
97
  export type { AuthenticatorName, Authenticators, ContainerBinding, ContainerBindings, } from './types/index.js';
98
- export type { Codemods } from './Codemods.js';
99
- export { createCodemods } from './Codemods.js';
98
+ export { type Codemods, createCodemods, type GeneratedStub, type StubState, } from './Codemods.js';
99
+ export { compile as compileStub, escapeHtml, generate as generateStub, render as renderStub, type StubBlock, StubSyntaxError, type StubValue, type TemplateOptions, } from './stubs/template.js';
100
100
  export type { ErrorEmitter, ErrorEvent, ErrorSeverity } from './ErrorBoundary.js';
101
101
  export { ErrorBoundary } from './ErrorBoundary.js';
102
102
  export { didYouMean, findClosestMatches, levenshtein } from './errors/FuzzyMatcher.js';
@@ -121,5 +121,5 @@ export { BaseEvent, Emitter, type EmitterResolver, type ListenerClass, } from '.
121
121
  export { type BufferedEvent, type BufferedEventName, type EventFinder, EventsBuffer, } from './events/EventsBuffer.js';
122
122
  export type { ErrorReporter, LockBackend, LockBackendFactory, LockRedisClient, LockRedisResolver, RunTaskOutcome, ScheduleEvent, ScheduleEventSink, ScheduleInvocation, ScheduleMetadata, ScheduleProviderOptions, SchedulerConfig, SchedulerOptions, ScheduleTaskCompletedEvent, ScheduleTaskFailedEvent, ScheduleTaskSkippedEvent, ScheduleTaskStartedEvent, TaskInfo, TaskStats, } from './scheduler/index.js';
123
123
  export { defineSchedulerConfig, getScheduleMetadata, locks, MemoryLockBackend, RedisLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
124
- export declare const VERSION = "0.2.25";
124
+ export declare const VERSION = "0.2.26";
125
125
  //# sourceMappingURL=index.d.ts.map