MCPcopy Create free account
hub / github.com/cloudflare/templates / depsUpdate

Function depsUpdate

cli/src/depsUpdate.ts:22–120  ·  view source on GitHub ↗
({
	githubToken,
	githubActor,
}: DepsUpdateConfig)

Source from the content-addressed store, hash-verified

20};
21
22export async function depsUpdate({
23 githubToken,
24 githubActor,
25}: DepsUpdateConfig) {
26 const packages = getPackages();
27 const firstPartyUpdates = new Map<string, DepUpdateInfo>();
28 const thirdPartyMajorUpdates = new Map<string, DepUpdateInfo>();
29
30 for (const pkg of packages) {
31 for (const dependencies of [
32 pkg.dependencies || {},
33 pkg.devDependencies || {},
34 ]) {
35 for (const [depName, info] of Object.entries(dependencies)) {
36 if (!info.resolved) {
37 // it's a local dependency, like the CLI -- not an NPM package
38 continue;
39 }
40 const latestVersion = await getLatestPackageVersion(depName);
41 if (latestVersion !== info.version) {
42 const is1stParty =
43 depName.startsWith("@cloudflare/") || depName === "wrangler";
44
45 if (is1stParty) {
46 const update = firstPartyUpdates.get(depName) ?? {
47 packages: {},
48 latestVersion,
49 };
50 Object.assign(update.packages, {
51 [pkg.name]: info.version,
52 });
53 firstPartyUpdates.set(depName, update);
54 } else {
55 const [currentMajorVersion] = info.version.split(".");
56 const [latestMajorVersion] = latestVersion.split(".");
57 if (Number(currentMajorVersion) < Number(latestMajorVersion)) {
58 const update = thirdPartyMajorUpdates.get(depName) ?? {
59 packages: {},
60 latestVersion,
61 };
62 Object.assign(update.packages, {
63 [pkg.name]: info.version,
64 });
65 thirdPartyMajorUpdates.set(depName, update);
66 }
67 }
68 }
69 }
70 }
71 }
72
73 subprocess.execSync(`git config --global user.name "${githubActor}"`);
74 subprocess.execSync(
75 `git config --global user.email "${githubActor}@users.noreply.github.com"`,
76 );
77
78 const updateConfigs: PerformUpdatesConfig[] = [
79 {

Callers 1

index.tsFile · 0.90

Calls 7

getLatestPackageVersionFunction · 0.90
convertToSafeBranchNameFunction · 0.90
convertToMarkdownTableFunction · 0.90
getPackagesFunction · 0.85
performUpdatesFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected