MCPcopy
hub / github.com/t3-oss/create-t3-app / addPackageDependency

Function addPackageDependency

cli/src/utils/addPackageDependency.ts:11–36  ·  view source on GitHub ↗
(opts: {
  dependencies: AvailableDependencies[];
  devMode: boolean;
  projectDir: string;
})

Source from the content-addressed store, hash-verified

9} from "~/installers/dependencyVersionMap.js";
10
11export const addPackageDependency = (opts: {
12 dependencies: AvailableDependencies[];
13 devMode: boolean;
14 projectDir: string;
15}) => {
16 const { dependencies, devMode, projectDir } = opts;
17
18 const pkgJson = fs.readJSONSync(
19 path.join(projectDir, "package.json")
20 ) as PackageJson;
21
22 dependencies.forEach((pkgName) => {
23 const version = dependencyVersionMap[pkgName];
24
25 if (devMode && pkgJson.devDependencies) {
26 pkgJson.devDependencies[pkgName] = version;
27 } else if (pkgJson.dependencies) {
28 pkgJson.dependencies[pkgName] = version;
29 }
30 });
31 const sortedPkgJson = sortPackageJson(pkgJson);
32
33 fs.writeJSONSync(path.join(projectDir, "package.json"), sortedPkgJson, {
34 spaces: 2,
35 });
36};

Callers 8

trpcInstallerFunction · 0.85
dynamicEslintInstallerFunction · 0.85
prismaInstallerFunction · 0.85
tailwindInstallerFunction · 0.85
drizzleInstallerFunction · 0.85
betterAuthInstallerFunction · 0.85
nextAuthInstallerFunction · 0.85
biomeInstallerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected