diff --git a/packages/cli/package.json b/packages/cli/package.json index 6d97a2d3..62a04ce6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -84,6 +84,7 @@ "tsup": "^8.1.0", "type-fest": "^4.20.0", "typescript": "^5.4.5", - "vite-tsconfig-paths": "^4.3.2" + "vite-tsconfig-paths": "^4.3.2", + "vue-metamorph": "^3.1.9" } } diff --git a/packages/cli/src/utils/transformers/new.ts b/packages/cli/src/utils/transformers/new.ts new file mode 100644 index 00000000..fa18d664 --- /dev/null +++ b/packages/cli/src/utils/transformers/new.ts @@ -0,0 +1,108 @@ +import { transform as metaTransform } from 'vue-metamorph' +import type { AST, CodemodPlugin } from 'vue-metamorph' +import type * as z from 'zod' +import { splitClassName } from './transform-css-vars' +import type { Config } from '@/src/utils/get-config' +import type { registryBaseColorSchema } from '@/src/utils/registry/schema' + +export interface TransformOpts { + filename: string + raw: string + config: Config + baseColor?: z.infer +} + +function transformTwPrefix(config: Config): CodemodPlugin { + return { + type: 'codemod', + name: 'change string literals to hello, world', + + // eslint-disable-next-line unused-imports/no-unused-vars + transform({ scriptASTs, sfcAST, styleASTs, filename, utils: { traverseScriptAST, traverseTemplateAST } }) { + // codemod plugins self-report the number of transforms it made + // this is only used to print the stats in CLI output + let transformCount = 0 + + // scriptASTs is an array of Program ASTs + // in a js/ts file, this array will only have one item + // in a vue file, this array will have one item for each