@codegraft/codemod 0.1.0-beta.7 → 0.1.0-beta.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.
- package/dist/codemod.d.ts +2 -9
- package/dist/codemod.d.ts.map +1 -1
- package/dist/codemod.js +4 -6
- package/dist/codemod.js.map +1 -1
- package/package.json +3 -3
package/dist/codemod.d.ts
CHANGED
|
@@ -9,12 +9,6 @@ export interface CodemodConfig {
|
|
|
9
9
|
* optimisation — files that never mention it are returned untouched without being parsed.
|
|
10
10
|
*/
|
|
11
11
|
namespace?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Opt into indentation-aware insertion: code recorded by `replaceWith`/`append`/`insertBefore`/…
|
|
14
|
-
* is re-indented to the file's detected indent unit and line ending, instead of landing at
|
|
15
|
-
* column 0. Off by default — without it, inserted whitespace clean-up is left to Prettier.
|
|
16
|
-
*/
|
|
17
|
-
format?: boolean;
|
|
18
12
|
}
|
|
19
13
|
/**
|
|
20
14
|
* Authoring handle for a codemod. `forTarget` builds a transformer for one target; `codegraft run`
|
|
@@ -26,11 +20,10 @@ export interface CodemodConfig {
|
|
|
26
20
|
export declare class Codemod<Ctx extends Record<string, unknown> = Record<string, unknown>, G extends GrammarId = GrammarId> {
|
|
27
21
|
readonly fn: CodemodFn<Ctx, G>;
|
|
28
22
|
readonly namespace: string | undefined;
|
|
29
|
-
|
|
30
|
-
constructor(fn: CodemodFn<Ctx, G>, namespace?: string, format?: boolean);
|
|
23
|
+
constructor(fn: CodemodFn<Ctx, G>, namespace?: string);
|
|
31
24
|
/** Interpreted mode: build a ready transformer for `target`. A grammar-annotated codemod only
|
|
32
25
|
* accepts its own bare grammar; a {@link ZoneSplitter} is always allowed (its grammars aren't
|
|
33
|
-
* statically known). */
|
|
26
|
+
* statically known). Formatting is applied on every `transform`, tunable via its `FormatOptions`. */
|
|
34
27
|
forTarget(target: G | ZoneSplitter): Promise<Transformer<Ctx>>;
|
|
35
28
|
}
|
|
36
29
|
/**
|
package/dist/codemod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod.d.ts","sourceRoot":"","sources":["../src/codemod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGvF;oGACoG;AACpG,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAC5F,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,OAAO,EAAE,GAAG,KACT,IAAI,CAAA;AAET,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"codemod.d.ts","sourceRoot":"","sources":["../src/codemod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGvF;oGACoG;AACpG,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAC5F,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,OAAO,EAAE,GAAG,KACT,IAAI,CAAA;AAET,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,OAAO,CAClB,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,CAAC,SAAS,SAAS,GAAG,SAAS;IAE/B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;gBAE1B,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM;IAKrD;;0GAEsG;IACtG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAG/D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,EAC1H,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,GACpB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;AAClB,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,EAC1H,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,GACpB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA"}
|
package/dist/codemod.js
CHANGED
|
@@ -9,22 +9,20 @@ import { createCodemodTransformer } from '@codegraft/core';
|
|
|
9
9
|
export class Codemod {
|
|
10
10
|
fn;
|
|
11
11
|
namespace;
|
|
12
|
-
|
|
13
|
-
constructor(fn, namespace, format = false) {
|
|
12
|
+
constructor(fn, namespace) {
|
|
14
13
|
this.fn = fn;
|
|
15
14
|
this.namespace = namespace;
|
|
16
|
-
this.format = format;
|
|
17
15
|
}
|
|
18
16
|
/** Interpreted mode: build a ready transformer for `target`. A grammar-annotated codemod only
|
|
19
17
|
* accepts its own bare grammar; a {@link ZoneSplitter} is always allowed (its grammars aren't
|
|
20
|
-
* statically known). */
|
|
18
|
+
* statically known). Formatting is applied on every `transform`, tunable via its `FormatOptions`. */
|
|
21
19
|
forTarget(target) {
|
|
22
|
-
return createCodemodTransformer(target, this.fn, { namespace: this.namespace
|
|
20
|
+
return createCodemodTransformer(target, this.fn, { namespace: this.namespace }).init();
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
export function defineCodemod(configOrFn, maybeFn) {
|
|
26
24
|
const fn = maybeFn ?? configOrFn;
|
|
27
25
|
const config = maybeFn ? configOrFn : undefined;
|
|
28
|
-
return new Codemod(fn, config?.namespace
|
|
26
|
+
return new Codemod(fn, config?.namespace);
|
|
29
27
|
}
|
|
30
28
|
//# sourceMappingURL=codemod.js.map
|
package/dist/codemod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod.js","sourceRoot":"","sources":["../src/codemod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"codemod.js","sourceRoot":"","sources":["../src/codemod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAkB1D;;;;;;GAMG;AACH,MAAM,OAAO,OAAO;IAIT,EAAE,CAAmB;IACrB,SAAS,CAAoB;IAEtC,YAAY,EAAqB,EAAE,SAAkB;QACnD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED;;0GAEsG;IACtG,SAAS,CAAC,MAAwB;QAChC,OAAO,wBAAwB,CAAS,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAChG,CAAC;CACF;AAeD,MAAM,UAAU,aAAa,CAC3B,UAA6C,EAC7C,OAA2B;IAE3B,MAAM,EAAE,GAAG,OAAO,IAAK,UAAgC,CAAA;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAE,UAA4B,CAAC,CAAC,CAAC,SAAS,CAAA;IAClE,OAAO,IAAI,OAAO,CAAS,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codegraft/codemod",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.9",
|
|
4
4
|
"description": "Authoring API for Codegraft codemods: defineCodemod and a jscodeshift-style collection over the CST.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"node": ">=22.13"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@codegraft/core": "0.1.0-beta.
|
|
28
|
+
"@codegraft/core": "0.1.0-beta.9"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@codegraft/vue": "0.1.0-beta.
|
|
31
|
+
"@codegraft/vue": "0.1.0-beta.9"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc -b"
|