codemod 2.0.0-alpha.1 → 2.0.0-alpha.2

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 (89) hide show
  1. package/README.md +57 -2
  2. package/codemod +17 -30
  3. package/package.json +78 -10
  4. package/register.d.mts +11 -0
  5. package/register.mjs +60 -0
  6. package/runtime/addon.mjs +59 -0
  7. package/runtime/ast-grep.mjs +93 -0
  8. package/runtime/context.mjs +77 -0
  9. package/runtime/hooks.mjs +9 -0
  10. package/runtime/host.d.mts +120 -0
  11. package/runtime/host.mjs +390 -0
  12. package/runtime/llm.mjs +11 -0
  13. package/runtime/metrics.mjs +45 -0
  14. package/runtime/modules.mjs +19 -0
  15. package/runtime/orchestrator.mjs +657 -0
  16. package/runtime/runtime.mjs +48 -0
  17. package/runtime/workflow.mjs +135 -0
  18. package/testing/index.d.mts +203 -0
  19. package/testing/index.mjs +638 -0
  20. package/types/index.d.ts +8 -0
  21. package/types/langs/angular.d.ts +5 -0
  22. package/types/langs/c.d.ts +5 -0
  23. package/types/langs/c_sharp.d.ts +5 -0
  24. package/types/langs/cpp.d.ts +5 -0
  25. package/types/langs/css.d.ts +5 -0
  26. package/types/langs/elixir.d.ts +5 -0
  27. package/types/langs/go.d.ts +5 -0
  28. package/types/langs/html.d.ts +5 -0
  29. package/types/langs/java.d.ts +5 -0
  30. package/types/langs/javascript.d.ts +5 -0
  31. package/types/langs/json.d.ts +5 -0
  32. package/types/langs/kotlin.d.ts +5 -0
  33. package/types/langs/php.d.ts +5 -0
  34. package/types/langs/python.d.ts +5 -0
  35. package/types/langs/ruby.d.ts +5 -0
  36. package/types/langs/rust.d.ts +5 -0
  37. package/types/langs/scala.d.ts +5 -0
  38. package/types/langs/toml.d.ts +5 -0
  39. package/types/langs/tsx.d.ts +5 -0
  40. package/types/langs/typescript.d.ts +5 -0
  41. package/types/langs/xml.d.ts +5 -0
  42. package/types/langs/yaml.d.ts +5 -0
  43. package/types/llm.d.ts +6 -0
  44. package/types/llrt/abort.d.ts +69 -0
  45. package/types/llrt/assert.d.ts +39 -0
  46. package/types/llrt/async_hooks.d.ts +210 -0
  47. package/types/llrt/buffer.d.ts +1186 -0
  48. package/types/llrt/child_process.d.ts +447 -0
  49. package/types/llrt/console.d.ts +210 -0
  50. package/types/llrt/crypto.d.ts +854 -0
  51. package/types/llrt/dgram.d.ts +381 -0
  52. package/types/llrt/dns.d.ts +124 -0
  53. package/types/llrt/dom-events.d.ts +51 -0
  54. package/types/llrt/events.d.ts +245 -0
  55. package/types/llrt/exceptions.d.ts +26 -0
  56. package/types/llrt/fetch.d.ts +332 -0
  57. package/types/llrt/fs/promises.d.ts +554 -0
  58. package/types/llrt/fs.d.ts +360 -0
  59. package/types/llrt/globals.d.ts +23 -0
  60. package/types/llrt/https.d.ts +27 -0
  61. package/types/llrt/index.d.ts +33 -0
  62. package/types/llrt/module.d.ts +285 -0
  63. package/types/llrt/navigator.d.ts +9 -0
  64. package/types/llrt/net.d.ts +488 -0
  65. package/types/llrt/os.d.ts +293 -0
  66. package/types/llrt/path.d.ts +150 -0
  67. package/types/llrt/perf_hooks.d.ts +23 -0
  68. package/types/llrt/process.d.ts +502 -0
  69. package/types/llrt/stream/web.d.ts +526 -0
  70. package/types/llrt/stream.d.ts +366 -0
  71. package/types/llrt/string_decoder.d.ts +63 -0
  72. package/types/llrt/timers.d.ts +72 -0
  73. package/types/llrt/timezone.d.ts +101 -0
  74. package/types/llrt/tty.d.ts +11 -0
  75. package/types/llrt/url.d.ts +774 -0
  76. package/types/llrt/util.d.ts +240 -0
  77. package/types/llrt/zlib.d.ts +177 -0
  78. package/types/main.d.ts +5 -0
  79. package/types/metrics.d.ts +5 -0
  80. package/types/modules/ast-grep.d.ts +634 -0
  81. package/types/modules/langs.d.ts +87 -0
  82. package/types/modules/llm.d.ts +23 -0
  83. package/types/modules/metrics.d.ts +107 -0
  84. package/types/modules/runtime.d.ts +66 -0
  85. package/types/modules/workflow.d.ts +750 -0
  86. package/types/runtime.d.ts +6 -0
  87. package/types/workflow.d.ts +5 -0
  88. package/vite.d.mts +24 -0
  89. package/vite.mjs +26 -0
@@ -0,0 +1,6 @@
1
+ // oxlint-disable triple-slash-reference
2
+ /// <reference path="modules/runtime.d.ts" />
3
+
4
+ // `codemod/runtime`: the same module as `codemod:runtime`, its older spelling.
5
+ export * from "codemod:runtime";
6
+ export { default } from "codemod:runtime";
@@ -0,0 +1,5 @@
1
+ // oxlint-disable triple-slash-reference
2
+ /// <reference path="modules/workflow.d.ts" />
3
+
4
+ // `codemod/workflow`: the same module as `codemod:workflow`, its older spelling.
5
+ export * from "codemod:workflow";
package/vite.d.mts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A Vite (and Vitest) plugin that resolves the older `codemod:*` spelling of
3
+ * the codemod modules (`codemod:workflow`) to the `codemod/*` exports. Code
4
+ * that imports `codemod/*` needs no plugin.
5
+ *
6
+ * ```ts
7
+ * // vitest.config.ts
8
+ * import { defineConfig } from "vitest/config";
9
+ * import codemod from "codemod/vite";
10
+ *
11
+ * export default defineConfig({ plugins: [codemod()] });
12
+ * ```
13
+ *
14
+ * @module
15
+ */
16
+
17
+ export interface CodemodVitePlugin {
18
+ name: "codemod";
19
+ enforce: "pre";
20
+ resolveId(id: string): string | null;
21
+ }
22
+
23
+ export function codemod(): CodemodVitePlugin;
24
+ export default codemod;
package/vite.mjs ADDED
@@ -0,0 +1,26 @@
1
+ // `codemod/vite`: a Vite (and Vitest) plugin for code written with the older
2
+ // `codemod:workflow`, `codemod:ast-grep`, ... spelling: it resolves those to
3
+ // this package's `codemod/*` exports. Code that imports `codemod/*` needs no
4
+ // plugin.
5
+ //
6
+ // // vitest.config.ts
7
+ // import { defineConfig } from "vitest/config";
8
+ // import codemod from "codemod/vite";
9
+ // export default defineConfig({ plugins: [codemod()] });
10
+
11
+ import { fileURLToPath } from "node:url";
12
+
13
+ import { resolveCodemodModule } from "./runtime/modules.mjs";
14
+
15
+ export function codemod() {
16
+ return {
17
+ name: "codemod",
18
+ enforce: "pre",
19
+ resolveId(id) {
20
+ const url = resolveCodemodModule(id);
21
+ return url ? fileURLToPath(url) : null;
22
+ },
23
+ };
24
+ }
25
+
26
+ export default codemod;