everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
38 lines (36 loc) • 1.37 kB
JavaScript
import { listFiles, readText } from "../fs.mjs";
import { Effect } from "effect";
//#region src/services/scaffold/upgrade-audit/checks/imports.ts
const IMPORT_REWRITES = [
["from \"@/auth\"", "from \"@/app\""],
["from '@/auth'", "from '@/app'"],
["from \"@/lib/auth-utils\"", "from \"@/lib/auth\""],
["from '@/lib/auth-utils'", "from '@/lib/auth'"],
["from \"@/lib/use-api-client\"", "from \"@/app\""],
["from '@/lib/use-api-client'", "from '@/app'"],
["from \"@/lib/api-client\"", "from \"@/app\""],
["from '@/lib/api-client'", "from '@/app'"],
["from \"everything-dev/dist/", "from \"everything-dev/"],
["from 'everything-dev/dist/", "from 'everything-dev/"]
];
const scanImports = (projectDir) => Effect.gen(function* () {
const files = (yield* listFiles(projectDir, [
"ui/src/**/*.{ts,tsx}",
"api/src/**/*.ts",
"plugins/*/src/**/*.{ts,tsx}"
])).filter((file) => !file.endsWith(".gen.ts") && !file.endsWith(".test.ts"));
const sources = /* @__PURE__ */ new Map();
for (const file of files) sources.set(file, yield* readText(projectDir, file));
return IMPORT_REWRITES.map(([from, to]) => {
const matched = [];
for (const [file, source] of sources) if (source.includes(from)) matched.push(file);
return {
from,
to,
files: matched
};
});
});
//#endregion
export { IMPORT_REWRITES, scanImports };
//# sourceMappingURL=imports.mjs.map