@venizia/ardor 0.4.6-1 → 0.4.7-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 (55) hide show
  1. package/README.md +18 -0
  2. package/dist/ardor.d.ts +3 -0
  3. package/dist/ardor.d.ts.map +1 -0
  4. package/dist/ardor.js +11 -0
  5. package/dist/ardor.js.map +1 -0
  6. package/dist/codemod/bin.d.ts +3 -0
  7. package/dist/codemod/bin.d.ts.map +1 -0
  8. package/dist/codemod/bin.js +24 -0
  9. package/dist/codemod/bin.js.map +1 -0
  10. package/dist/codemod/cli.d.ts +13 -0
  11. package/dist/codemod/cli.d.ts.map +1 -0
  12. package/dist/codemod/cli.js +155 -0
  13. package/dist/codemod/cli.js.map +1 -0
  14. package/dist/codemod/files.d.ts +25 -0
  15. package/dist/codemod/files.d.ts.map +1 -0
  16. package/dist/codemod/files.js +97 -0
  17. package/dist/codemod/files.js.map +1 -0
  18. package/dist/codemod/logger.d.ts +42 -0
  19. package/dist/codemod/logger.d.ts.map +1 -0
  20. package/dist/codemod/logger.js +382 -0
  21. package/dist/codemod/logger.js.map +1 -0
  22. package/dist/codemod/migrate.d.ts +23 -0
  23. package/dist/codemod/migrate.d.ts.map +1 -0
  24. package/dist/codemod/migrate.js +22 -0
  25. package/dist/codemod/migrate.js.map +1 -0
  26. package/dist/codemod/renames.d.ts +60 -0
  27. package/dist/codemod/renames.d.ts.map +1 -0
  28. package/dist/codemod/renames.js +114 -0
  29. package/dist/codemod/renames.js.map +1 -0
  30. package/dist/codemod/transform.d.ts +51 -0
  31. package/dist/codemod/transform.d.ts.map +1 -0
  32. package/dist/codemod/transform.js +384 -0
  33. package/dist/codemod/transform.js.map +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/presets/app/files/src/application.test.ts +4 -2
  39. package/dist/presets/app/files/src/configurations/admin.configuration.ts +2 -2
  40. package/dist/presets/app/preset.json +14 -14
  41. package/dist/presets/lib/preset.json +9 -9
  42. package/dist/testing.d.ts.map +1 -1
  43. package/dist/testing.js +14 -7
  44. package/dist/testing.js.map +1 -1
  45. package/dist/vite/plugin.d.ts.map +1 -1
  46. package/dist/vite/plugin.js +5 -4
  47. package/dist/vite/plugin.js.map +1 -1
  48. package/dist/vite/sources.d.ts.map +1 -1
  49. package/dist/vite/sources.js +2 -3
  50. package/dist/vite/sources.js.map +1 -1
  51. package/package.json +25 -18
  52. package/dist/vite/quiet-logger.d.ts +0 -3
  53. package/dist/vite/quiet-logger.d.ts.map +0 -1
  54. package/dist/vite/quiet-logger.js +0 -36
  55. package/dist/vite/quiet-logger.js.map +0 -1
package/README.md CHANGED
@@ -13,6 +13,24 @@ control comes from `@venizia/ignis-inversion`, and the data layer speaks the que
13
13
  bun add @venizia/ardor @venizia/ignis-inversion @venizia/ignis-filter @venizia/ignis-kernel @venizia/ignis-helpers reflect-metadata
14
14
  ```
15
15
 
16
+ ## The `Ardor` namespace
17
+
18
+ `Ardor` gathers every React hook of the react and admin packages under one name: `Ardor.useRepository(...)`, `Ardor.useTranslate()`. It is the same function as the bare `useRepository`, the Rules of Hooks check the call, and a bundler keeps only the hooks you use, so it adds no bytes to an app.
19
+
20
+ ```tsx
21
+ import { Ardor } from '@venizia/ardor';
22
+
23
+ export const Orders = () => {
24
+ const repository = Ardor.useRepository({ key: 'repositories.Orders' });
25
+
26
+ return <div>{String(repository)}</div>;
27
+ };
28
+ ```
29
+
30
+ ## Moving to the new names
31
+
32
+ `bun run ardor codemod namespace src` lists the removed bare names that have a replacement (`getRuntimeConfig` to `RuntimeConfig.get`, `isDefined` to `ValueUtility.isDefined`, `NullableType` to `undefined | null | void`, `Logger.getInstance({ scope })` to `LoggerFactory.getLogger([scope])`, ...) and the removed names with none, and writes nothing; `--write` applies it, `--check` fails while any is left, and `--hooks` also moves hooks imported from `@venizia/ardor` to `Ardor.useX`. It needs the `typescript` package.
33
+
16
34
  ## Quick start
17
35
 
18
36
  ```typescript
@@ -0,0 +1,3 @@
1
+ export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, } from '@venizia/ardor-admin';
2
+ export { useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useInjectable, useInjectableContainer, useProvider, useRepository, useService, useSizer, useWindowDimensions, } from '@venizia/ardor-react';
3
+ //# sourceMappingURL=ardor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ardor.d.ts","sourceRoot":"","sources":["../src/ardor.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,MAAM,sBAAsB,CAAC"}
package/dist/ardor.js ADDED
@@ -0,0 +1,11 @@
1
+ // Every ARDOR hook, gathered for `export * as Ardor` in index.ts: one name, `Ardor.useRepository(...)`,
2
+ // the way `React.useState` is one. Each member is the very function the react or admin package
3
+ // exports. The React Rules of Hooks recognise a call through a PascalCase identifier, so
4
+ // `Ardor.useX()` is checked like `useX()`. It sits in `@venizia/ardor` because react cannot import
5
+ // admin; the two packages keep their own top-level exports.
6
+ //
7
+ // A module namespace, not an object literal: a bundler resolves `Ardor.useRepository` to that one
8
+ // hook and drops the rest, where an object that lists them all would pull every hook in.
9
+ export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, } from '@venizia/ardor-admin';
10
+ export { useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useInjectable, useInjectableContainer, useProvider, useRepository, useService, useSizer, useWindowDimensions, } from '@venizia/ardor-react';
11
+ //# sourceMappingURL=ardor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ardor.js","sourceRoot":"","sources":["../src/ardor.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,+FAA+F;AAC/F,yFAAyF;AACzF,mGAAmG;AACnG,4DAA4D;AAC5D,EAAE;AACF,kGAAkG;AAClG,yFAAyF;AACzF,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/codemod/bin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import { NamespaceCommand } from './cli.js';
3
+ const USAGE = `Usage: ardor <command>
4
+
5
+ Commands:
6
+ codemod namespace move the deprecated bare names to the class members that replace them
7
+
8
+ Run "ardor codemod namespace --help" for the options.`;
9
+ /** The `ardor` bin of `@venizia/ardor`: `ardor codemod namespace [paths...] [--write | --check]`. */
10
+ const main = async () => {
11
+ const [command, name, ...rest] = process.argv.slice(2);
12
+ if (command === 'codemod' && name === 'namespace') {
13
+ return NamespaceCommand.run({ root: process.cwd(), args: rest });
14
+ }
15
+ if (command === undefined || command === '--help' || command === '-h') {
16
+ console.log(USAGE);
17
+ return 0;
18
+ }
19
+ console.error(`ardor: unknown command "${[command, name].filter(Boolean).join(' ')}"\n${USAGE}`);
20
+ return 2;
21
+ };
22
+ const result = await main();
23
+ process.exitCode = result;
24
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/codemod/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,KAAK,GAAG;;;;;sDAKwC,CAAC;AAEvD,qGAAqG;AACrG,MAAM,IAAI,GAAG,KAAK,IAAqB,EAAE;IACvC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEvD,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QAClD,OAAO,gBAAgB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;IAEjG,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;AAC5B,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** `ardor codemod namespace`: a dry run unless `--write`; `--check` is the dry run that fails on work left. */
2
+ export declare class NamespaceCommand {
3
+ static readonly USAGE = "Usage: ardor codemod namespace [paths...] [--hooks] [--write | --check]\n\nMoves the names removed from @venizia/ardor to what replaces them:\n\n isDefined, isString, isNumber, isObject, isValidDate ValueUtility.<name>\n isBrowser BrowserUtility.isBrowser\n toDataUrl FileUtility.toDataUrl\n getRuntimeConfig RuntimeConfig.get\n createAppDispatch, createAppSelectors DispatchHooks.create, SelectorHooks.create\n resolveApplicationProviders ApplicationProviders.resolve\n hasPendingFeatureMessages, loadFeatureMessages Features.hasPendingMessages, Features.loadMessages\n NumberIdType, StringIdType, NullableType number, string, undefined | null | void\n BaseHelper, LogLevels, ILogger, TLogLevel the same names from @venizia/ignis-helpers/core\n Logger.getInstance({ scope }), new Logger({ scope }) LoggerFactory.getLogger([scope]) (enableDebug is dropped, with a note)\n Logger (a type) ILogger\n\nRemoved with nothing to write in their place, so only listed with their line: isEditableTarget,\nTDataCount, ISyncFC, App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,\nthe enableDebug prop of ArdorApplication (pass logger instead), and a Logger use with no one-line form.\n\nIt rewrites a name imported from @venizia/ardor, @venizia/ardor-kernel, @venizia/ardor-react or\n@venizia/ardor-admin, its uses, and the import. It reads syntax only: a name the file also declares\nitself, a re-export by name and a class name already taken are listed with their line and left for you.\n\n --hooks also move a hook imported from @venizia/ardor to the Ardor namespace (useRepository()\n becomes Ardor.useRepository()). A hook imported from @venizia/ardor-react or\n @venizia/ardor-admin is never touched: those packages cannot import Ardor.\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local\nchanges (changed, staged or untracked): commit or stash it first, so git can undo the codemod.\nRun your formatter afterwards: the new names are appended to the import they join.";
4
+ /** Runs the command and returns the exit code; prints to the console. */
5
+ static run(opts: {
6
+ root: string;
7
+ args: string[];
8
+ }): Promise<number>;
9
+ private static loadTypeScript;
10
+ private static sweep;
11
+ private static report;
12
+ }
13
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/codemod/cli.ts"],"names":[],"mappings":"AAkEA,+GAA+G;AAC/G,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,+jFAAS;IAE9B,yEAAyE;WAC5D,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;mBAiDpD,cAAc;IAYnC,OAAO,CAAC,MAAM,CAAC,KAAK;IA6CpB,OAAO,CAAC,MAAM,CAAC,MAAM;CA0CtB"}
@@ -0,0 +1,155 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { relative, resolve } from 'node:path';
3
+ import { CodemodFiles } from './files.js';
4
+ import { Migration } from './migrate.js';
5
+ const USAGE = `Usage: ardor codemod namespace [paths...] [--hooks] [--write | --check]
6
+
7
+ Moves the names removed from @venizia/ardor to what replaces them:
8
+
9
+ isDefined, isString, isNumber, isObject, isValidDate ValueUtility.<name>
10
+ isBrowser BrowserUtility.isBrowser
11
+ toDataUrl FileUtility.toDataUrl
12
+ getRuntimeConfig RuntimeConfig.get
13
+ createAppDispatch, createAppSelectors DispatchHooks.create, SelectorHooks.create
14
+ resolveApplicationProviders ApplicationProviders.resolve
15
+ hasPendingFeatureMessages, loadFeatureMessages Features.hasPendingMessages, Features.loadMessages
16
+ NumberIdType, StringIdType, NullableType number, string, undefined | null | void
17
+ BaseHelper, LogLevels, ILogger, TLogLevel the same names from @venizia/ignis-helpers/core
18
+ Logger.getInstance({ scope }), new Logger({ scope }) LoggerFactory.getLogger([scope]) (enableDebug is dropped, with a note)
19
+ Logger (a type) ILogger
20
+
21
+ Removed with nothing to write in their place, so only listed with their line: isEditableTarget,
22
+ TDataCount, ISyncFC, App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,
23
+ the enableDebug prop of ArdorApplication (pass logger instead), and a Logger use with no one-line form.
24
+
25
+ It rewrites a name imported from @venizia/ardor, @venizia/ardor-kernel, @venizia/ardor-react or
26
+ @venizia/ardor-admin, its uses, and the import. It reads syntax only: a name the file also declares
27
+ itself, a re-export by name and a class name already taken are listed with their line and left for you.
28
+
29
+ --hooks also move a hook imported from @venizia/ardor to the Ardor namespace (useRepository()
30
+ becomes Ardor.useRepository()). A hook imported from @venizia/ardor-react or
31
+ @venizia/ardor-admin is never touched: those packages cannot import Ardor.
32
+ --write write the changed files (without it, nothing is written)
33
+ --check dry run that exits 1 when anything would change or is left (for CI)
34
+ --help print this text and exit
35
+
36
+ With no flag it lists what would change and writes nothing. Inside a git repository it reads the
37
+ files git knows (tracked, or untracked and not ignored), and --write refuses a file with local
38
+ changes (changed, staged or untracked): commit or stash it first, so git can undo the codemod.
39
+ Run your formatter afterwards: the new names are appended to the import they join.`;
40
+ /** A usage error: nothing was read or written. */
41
+ const USAGE_ERROR_CODE = 2;
42
+ class CodemodFlags {
43
+ static { this.WRITE = '--write'; }
44
+ static { this.CHECK = '--check'; }
45
+ static { this.HOOKS = '--hooks'; }
46
+ static { this.HELP = '--help'; }
47
+ static { this.HELP_SHORT = '-h'; }
48
+ static { this.SCHEME_SET = new Set([
49
+ this.WRITE,
50
+ this.CHECK,
51
+ this.HOOKS,
52
+ this.HELP,
53
+ this.HELP_SHORT,
54
+ ]); }
55
+ static isValid(value) {
56
+ return this.SCHEME_SET.has(value);
57
+ }
58
+ }
59
+ /** `ardor codemod namespace`: a dry run unless `--write`; `--check` is the dry run that fails on work left. */
60
+ export class NamespaceCommand {
61
+ static { this.USAGE = USAGE; }
62
+ /** Runs the command and returns the exit code; prints to the console. */
63
+ static async run(opts) {
64
+ const { root, args } = opts;
65
+ if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {
66
+ console.log(USAGE);
67
+ return 0;
68
+ }
69
+ const unknown = args.filter((argument) => argument.startsWith('-') && !CodemodFlags.isValid(argument));
70
+ if (unknown.length > 0) {
71
+ console.error(`ardor codemod: unknown option ${unknown.map((flag) => `"${flag}"`).join(', ')}\n${USAGE}`);
72
+ return USAGE_ERROR_CODE;
73
+ }
74
+ const isWrite = args.includes(CodemodFlags.WRITE);
75
+ const isCheck = args.includes(CodemodFlags.CHECK);
76
+ if (isWrite && isCheck) {
77
+ console.error(`ardor codemod: ${CodemodFlags.WRITE} and ${CodemodFlags.CHECK} contradict each other\n${USAGE}`);
78
+ return USAGE_ERROR_CODE;
79
+ }
80
+ const ts = await NamespaceCommand.loadTypeScript();
81
+ if (!ts) {
82
+ console.error('ardor codemod: the "typescript" package is not installed here. Install it (it is a dev dependency of any TypeScript project) and run again.');
83
+ return USAGE_ERROR_CODE;
84
+ }
85
+ const paths = args.filter((argument) => !argument.startsWith('-'));
86
+ const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));
87
+ const hooks = args.includes(CodemodFlags.HOOKS);
88
+ return NamespaceCommand.sweep({ root, ts, targets, hooks, isWrite, isCheck });
89
+ }
90
+ static async loadTypeScript() {
91
+ try {
92
+ const loaded = await import('typescript');
93
+ // TypeScript is CommonJS: Node puts the module on `default`, a bundler may not.
94
+ return loaded.default ?? loaded;
95
+ // eslint-disable-next-line venizia/no-silent-catch -- no `typescript` installed is an answer, not a failure: the caller prints how to install it
96
+ }
97
+ catch {
98
+ return undefined;
99
+ }
100
+ }
101
+ static sweep(opts) {
102
+ const { root, ts, targets, hooks, isWrite, isCheck } = opts;
103
+ const files = [...new Set(targets.flatMap((target) => CodemodFiles.collect({ target })))];
104
+ const dirty = isWrite
105
+ ? new Set(targets.flatMap((target) => [...(CodemodFiles.dirty({ target }) ?? [])]))
106
+ : new Set();
107
+ const changes = [];
108
+ const refused = [];
109
+ const left = [];
110
+ const notes = [];
111
+ for (const path of files) {
112
+ const text = readFileSync(path, 'utf8');
113
+ const result = Migration.run({ ts, fileName: path, text, hooks });
114
+ for (const finding of result.findings) {
115
+ (finding.kind === 'note' ? notes : left).push({ path, finding });
116
+ }
117
+ if (result.text === text) {
118
+ continue;
119
+ }
120
+ if (isWrite && dirty.has(path)) {
121
+ refused.push(path);
122
+ continue;
123
+ }
124
+ changes.push({ path, renamed: result.renamed });
125
+ if (isWrite) {
126
+ writeFileSync(path, result.text);
127
+ }
128
+ }
129
+ return NamespaceCommand.report({ root, isWrite, isCheck, changes, refused, left, notes });
130
+ }
131
+ static report(opts) {
132
+ const { root, isWrite, isCheck, changes, refused, left, notes } = opts;
133
+ const verb = isWrite ? 'changed' : 'would change';
134
+ const show = (path) => relative(root, path) || path;
135
+ for (const change of changes) {
136
+ console.log(`${verb} ${show(change.path)} (${change.renamed} use${change.renamed === 1 ? '' : 's'})`);
137
+ }
138
+ for (const path of refused) {
139
+ console.error(`refused ${show(path)}: it has local changes; commit or stash it first`);
140
+ }
141
+ // A note is a change made on purpose that is worth knowing; it is not work left, so --check ignores it.
142
+ for (const { path, finding } of notes) {
143
+ console.log(`note ${show(path)}:${finding.line} ${finding.name}: ${finding.reason}`);
144
+ }
145
+ for (const { path, finding } of left) {
146
+ console.error(`left ${show(path)}:${finding.line} ${finding.name}: ${finding.reason}`);
147
+ }
148
+ console.log(`${changes.length} file${changes.length === 1 ? '' : 's'} ${verb}, ${left.length} left for you${isWrite || changes.length === 0 ? '' : '. Run again with --write to apply.'}`);
149
+ if (refused.length > 0) {
150
+ return 1;
151
+ }
152
+ return isCheck && (changes.length > 0 || left.length > 0) ? 1 : 0;
153
+ }
154
+ }
155
+ //# sourceMappingURL=cli.js.map
@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M,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,CAAC,GAAG,CACT,GAAG,OAAO,CAAC,MAAM,QAAQ,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,gBAAgB,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC,EAAE,CAC9K,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The source files a codemod may touch. Inside a git repository the list comes from git, so a
3
+ * `.gitignore`d folder (a worktree, a build output) is never entered; outside git the walk skips
4
+ * `node_modules`, `dist`, `build` and every dot-directory.
5
+ */
6
+ export declare class CodemodFiles {
7
+ static isSource(opts: {
8
+ name: string;
9
+ }): boolean;
10
+ /** Every source file under `target`; a file target is returned as it is. */
11
+ static collect(opts: {
12
+ target: string;
13
+ }): string[];
14
+ /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository. */
15
+ private static fromGit;
16
+ private static fromWalk;
17
+ /**
18
+ * The files under `target` a write could not be undone with git: changed, staged or untracked.
19
+ * `undefined` outside a repository or without git, where there is nothing to check.
20
+ */
21
+ static dirty(opts: {
22
+ target: string;
23
+ }): Set<string> | undefined;
24
+ }
25
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/codemod/files.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAIhD,4EAA4E;IAC5E,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAUlD,gGAAgG;IAChG,OAAO,CAAC,MAAM,CAAC,OAAO;IA4BtB,OAAO,CAAC,MAAM,CAAC,QAAQ;IAkBvB;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;CAiChE"}
@@ -0,0 +1,97 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { existsSync, readdirSync, statSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ const SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);
5
+ const SOURCE_PATTERN = /\.(?:ts|tsx|mts|cts)$/;
6
+ const DECLARATION_PATTERN = /\.d\.(?:ts|mts|cts)$/;
7
+ /**
8
+ * The source files a codemod may touch. Inside a git repository the list comes from git, so a
9
+ * `.gitignore`d folder (a worktree, a build output) is never entered; outside git the walk skips
10
+ * `node_modules`, `dist`, `build` and every dot-directory.
11
+ */
12
+ export class CodemodFiles {
13
+ static isSource(opts) {
14
+ return SOURCE_PATTERN.test(opts.name) && !DECLARATION_PATTERN.test(opts.name);
15
+ }
16
+ /** Every source file under `target`; a file target is returned as it is. */
17
+ static collect(opts) {
18
+ const { target } = opts;
19
+ if (statSync(target).isFile()) {
20
+ return [target];
21
+ }
22
+ return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });
23
+ }
24
+ /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository. */
25
+ static fromGit(opts) {
26
+ const { target } = opts;
27
+ let output;
28
+ try {
29
+ output = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], {
30
+ cwd: target,
31
+ encoding: 'utf8',
32
+ maxBuffer: 256 * 1024 * 1024,
33
+ stdio: ['ignore', 'pipe', 'ignore'],
34
+ });
35
+ // eslint-disable-next-line venizia/no-silent-catch -- not a git repository (or no git) is an answer: the caller walks the folder instead
36
+ }
37
+ catch {
38
+ return undefined;
39
+ }
40
+ return output
41
+ .split('\0')
42
+ .filter((path) => path !== '' && CodemodFiles.isSource({ name: path }))
43
+ .filter((path) => !path.split('/').some((segment) => SKIPPED_DIRECTORIES.has(segment)))
44
+ .map((path) => join(target, path))
45
+ .filter((path) => existsSync(path) && statSync(path).isFile());
46
+ }
47
+ static fromWalk(opts) {
48
+ const files = [];
49
+ for (const entry of readdirSync(opts.target, { withFileTypes: true })) {
50
+ const path = join(opts.target, entry.name);
51
+ if (entry.isDirectory()) {
52
+ if (!SKIPPED_DIRECTORIES.has(entry.name) && !entry.name.startsWith('.')) {
53
+ files.push(...CodemodFiles.fromWalk({ target: path }));
54
+ }
55
+ }
56
+ else if (entry.isFile() && CodemodFiles.isSource({ name: entry.name })) {
57
+ files.push(path);
58
+ }
59
+ }
60
+ return files;
61
+ }
62
+ /**
63
+ * The files under `target` a write could not be undone with git: changed, staged or untracked.
64
+ * `undefined` outside a repository or without git, where there is nothing to check.
65
+ */
66
+ static dirty(opts) {
67
+ const { target } = opts;
68
+ const cwd = statSync(target).isFile() ? dirname(target) : target;
69
+ const queries = [
70
+ ['ls-files', '--modified', '--others', '--exclude-standard', '-z'],
71
+ ['diff', '--cached', '--name-only', '--relative', '-z'],
72
+ ];
73
+ const paths = new Set();
74
+ for (const query of queries) {
75
+ let output;
76
+ try {
77
+ output = execFileSync('git', query, {
78
+ cwd,
79
+ encoding: 'utf8',
80
+ maxBuffer: 256 * 1024 * 1024,
81
+ stdio: ['ignore', 'pipe', 'ignore'],
82
+ });
83
+ // eslint-disable-next-line venizia/no-silent-catch -- git cannot answer for this folder: the caller treats the file as unknown to git
84
+ }
85
+ catch {
86
+ return undefined;
87
+ }
88
+ for (const path of output.split('\0')) {
89
+ if (path !== '') {
90
+ paths.add(join(cwd, path));
91
+ }
92
+ }
93
+ }
94
+ return paths;
95
+ }
96
+ }
97
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/codemod/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,IAAsB;QACpC,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,CAAC;IAED,4EAA4E;IAC5E,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,gGAAgG;IACxF,MAAM,CAAC,OAAO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c,CAAC;YAEnB,IAAI,CAAC;gBACH,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE;oBAClC,GAAG;oBACH,QAAQ,EAAE,MAAM;oBAChB,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;oBAC5B,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;iBACpC,CAAC,CAAC;gBACH,sIAAsI;YACxI,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;oBAChB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ import type { IFinding, TTypeScript } from './transform.js';
2
+ export interface ILoggerResult {
3
+ text: string;
4
+ /** Call sites and annotations rewritten, and imports moved. */
5
+ renamed: number;
6
+ /** What was left, and what was changed on purpose. */
7
+ findings: IFinding[];
8
+ }
9
+ /**
10
+ * Moves a project off the kernel logger, which IGNIS's `ILogger` replaces:
11
+ *
12
+ * - `BaseHelper`, `LogLevels`, `ILogger` and `TLogLevel` keep their names, so only the import moves
13
+ * to `@venizia/ignis-helpers/core`.
14
+ * - `Logger.getInstance({ scope })` and `new Logger({ scope })` become
15
+ * `LoggerFactory.getLogger([scope])`. IGNIS's console logger has its own debug gate (off unless
16
+ * `DEBUG` is set, and always off in a browser), so an `enableDebug` option is dropped and noted.
17
+ * - `Logger` as a type becomes `ILogger`.
18
+ * - The `enableDebug` prop of `ArdorApplication` is removed (pass `logger`): listed.
19
+ *
20
+ * Any other use of `Logger` (a subclass, `instanceof`, a spread argument) is listed and `Logger` stays
21
+ * imported, so the file shows exactly where to look.
22
+ */
23
+ export declare class LoggerTransform {
24
+ static run(opts: {
25
+ ts: TTypeScript;
26
+ fileName: string;
27
+ text: string;
28
+ }): ILoggerResult;
29
+ private static collectImports;
30
+ /** `<ArdorApplication enableDebug />`: the prop is gone, the logger is passed instead. */
31
+ private static findEnableDebugProp;
32
+ /** The uses of `Logger`. `isFullyMoved` is true when none is left, so its import can go. */
33
+ private static rewriteLogger;
34
+ /** The top-level names the file already owns, other than the IGNIS ones it imports and the ARDOR ones being moved. */
35
+ private static takenNames;
36
+ /** `name` when the file does not own it, else `Ignis<name>`. */
37
+ private static freeName;
38
+ /** The ARDOR import lines without the moved names, and `@venizia/ignis-helpers/core` with them. */
39
+ private static importEdits;
40
+ private static apply;
41
+ }
42
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/codemod/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAgBD;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,aAAa;IA8EpF,OAAO,CAAC,MAAM,CAAC,cAAc;IAqC7B,0FAA0F;IAC1F,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA0ClC,4FAA4F;IAC5F,OAAO,CAAC,MAAM,CAAC,aAAa;IA4I5B,sHAAsH;IACtH,OAAO,CAAC,MAAM,CAAC,UAAU;IAuDzB,gEAAgE;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,mGAAmG;IACnG,OAAO,CAAC,MAAM,CAAC,WAAW;IA2H1B,OAAO,CAAC,MAAM,CAAC,KAAK;CAWrB"}