aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/turbo-codemod/templates/transformer.hbs
blob: 593490a8c20e2cb4403d49de8ccde89333a7bd46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { TransformerArgs } from "../types";
import { TransformerResults } from "../runner";
import getTransformerHelpers from "../utils/getTransformerHelpers";

// transformer details
const TRANSFORMER = "{{ name }}";
const DESCRIPTION = "{{ description }}";
const INTRODUCED_IN = "{{ introducedIn }}";

export function transformer({
  root,
  options,
}: TransformerArgs): TransformerResults {
  const { log, runner } = getTransformerHelpers({
    transformer: TRANSFORMER,
    rootPath: root,
    options,
  });

  log.info("Short description about {{ name }}")

  /*
    Make changes to required files, and track each modified file with:

    runner.modifyFile({
      filePath: packageJsonPath,   // absolute path to file
      after: transformedFile,      // file after modifications have been made
    });

    This automatically handles all cases of print / dry etc.
  */

  return runner.finish();
}

const transformerMeta = {
  name: `${TRANSFORMER}: ${DESCRIPTION}`,
  value: TRANSFORMER,
  introducedIn: INTRODUCED_IN,
  transformer,
};

export default transformerMeta;