diff --git a/.changeset/changeset.cjs b/.changeset/changeset.cjs index 7d0cfd454244..115be0682036 100644 --- a/.changeset/changeset.cjs +++ b/.changeset/changeset.cjs @@ -1,10 +1,17 @@ const { getPackagesSync } = require("@manypkg/get-packages"); +const dependents_graph = require("@changesets/get-dependents-graph"); + const gh = require("@changesets/get-github-info"); const { existsSync, readFileSync, writeFileSync } = require("fs"); const { join } = require("path"); const { getInfo, getInfoFromPullRequest } = gh; -const { packages, rootDir } = getPackagesSync(process.cwd()); +const pkg_data = getPackagesSync(process.cwd()); +const { packages, rootDir } = pkg_data; +const dependents = dependents_graph.getDependentsGraph({ + packages, + root: pkg_data.rootPackage +}); /** * @typedef {{packageJson: {name: string, python?: boolean}, dir: string}} Package @@ -34,6 +41,10 @@ function find_packages_dirs(package_name) { return package_dirs; } +let lines = { + _handled: [] +}; + const changelogFunctions = { /** * @@ -76,7 +87,53 @@ const changelogFunctions = { * @param {any} dependency The dependency that has been updated * @returns {string} The formatted dependency */ - (dependency) => ` - ${dependency.name}@${dependency.newVersion}` + (dependency) => { + const updates = dependents.get(dependency.name); + + if (updates && updates.length > 0) { + updates.forEach((update) => { + if (!lines[update]) { + lines[update] = { + dirs: find_packages_dirs(update), + current_changelog: "", + feat: [], + fix: [], + highlight: [], + previous_version: packages.find( + (p) => p.packageJson.name === update + ).packageJson.version, + dependencies: [] + }; + + const changelog_path = join( + //@ts-ignore + lines[update].dirs[1] || lines[update].dirs[0], + "CHANGELOG.md" + ); + + if (existsSync(changelog_path)) { + //@ts-ignore + lines[update].current_changelog = readFileSync( + changelog_path, + "utf-8" + ) + .replace(`# ${update}`, "") + .trim(); + } + } + lines[update].dependencies.push( + ` - ${dependency.name}@${dependency.newVersion}` + ); + }); + } + + return ` - ${dependency.name}@${dependency.newVersion}`; + } + ); + + writeFileSync( + join(rootDir, ".changeset", "_changelog.json"), + JSON.stringify(lines, null, 2) ); return [changesetLink, ...updatedDepenenciesList].join("\n"); @@ -151,11 +208,14 @@ const changelogFunctions = { }; })(); + const user_link = /\[(@[^]+)\]/.exec(links.user); const users = usersFromSummary && usersFromSummary.length ? usersFromSummary .map((userFromSummary) => `@${userFromSummary}`) .join(", ") + : user_link + ? user_link[1] : links.user; const prefix = [ @@ -174,16 +234,6 @@ const changelogFunctions = { /** * @type { ChangesetMeta & { _handled: string[] } }} */ - let lines; - if (existsSync(join(rootDir, ".changeset", "_changelog.json"))) { - lines = JSON.parse( - readFileSync(join(rootDir, ".changeset", "_changelog.json"), "utf-8") - ); - } else { - lines = { - _handled: [] - }; - } if (lines._handled.includes(changeset.id)) { return "done"; @@ -191,14 +241,19 @@ const changelogFunctions = { lines._handled.push(changeset.id); changeset.releases.forEach((release) => { - if (!lines[release.name]) + if (!lines[release.name]) { lines[release.name] = { dirs: find_packages_dirs(release.name), current_changelog: "", feat: [], fix: [], - highlight: [] + highlight: [], + previous_version: packages.find( + (p) => p.packageJson.name === release.name + ).packageJson.version, + dependencies: [] }; + } const changelog_path = join( //@ts-ignore diff --git a/.changeset/fix_changelogs.cjs b/.changeset/fix_changelogs.cjs index 202ce30462a0..344f0631d524 100644 --- a/.changeset/fix_changelogs.cjs +++ b/.changeset/fix_changelogs.cjs @@ -44,19 +44,46 @@ function run() { }, /** @type {{[key:string] : PackageMeta}} */ ({})); for (const pkg_name in packages) { - const { dirs, highlight, feat, fix, current_changelog } = + const { dirs, highlight, feat, fix, current_changelog, dependencies } = /**@type {ChangesetMeta} */ (packages[pkg_name]); + if (pkg_name === "@gradio/lite") { + const target = all_packages.gradio.packageJson.version.split("."); + + const current_version = packages[pkg_name].previous_version.split("."); + + if (!packages.gradio) { + const patch = parseInt(current_version[2]) + 1; + const new_version = [target[0], target[1], patch]; + all_packages[pkg_name].packageJson.version = new_version.join("."); + } else { + if (parseInt(target[1]) > parseInt(current_version[1])) { + all_packages[pkg_name].packageJson.version = target.join("."); + } else if (parseInt(target[1]) === parseInt(current_version[1])) { + const patch = parseInt(current_version[2]) + 1; + const new_version = [target[0], target[1], patch]; + all_packages[pkg_name].packageJson.version = new_version.join("."); + } + } + + writeFileSync( + join(all_packages[pkg_name].dir, "package.json"), + JSON.stringify(all_packages[pkg_name].packageJson, null, "\t") + ); + } + const { version, python } = all_packages[pkg_name].packageJson; - const highlights = highlight.map((h) => `${h.summary}`); - const features = feat.map((f) => `- ${f.summary}`); - const fixes = fix.map((f) => `- ${f.summary}`); + const highlights = highlight?.map((h) => `${h.summary}`) || []; + const features = feat?.map((f) => `- ${f.summary}`) || []; + const fixes = fix?.map((f) => `- ${f.summary}`) || []; + const deps = Array.from(new Set(dependencies?.map((d) => d.trim()))) || []; const release_notes = /** @type {[string[], string][]} */ ([ [highlights, "### Highlights"], [features, "### Features"], - [fixes, "### Fixes"] + [fixes, "### Fixes"], + [deps, "### Dependency updates"] ]) .filter(([s], i) => s.length > 0) .map(([lines, title]) => { diff --git a/.changeset/tender-women-tie.md b/.changeset/tender-women-tie.md new file mode 100644 index 000000000000..a81e6975735e --- /dev/null +++ b/.changeset/tender-women-tie.md @@ -0,0 +1,5 @@ +--- +"@gradio/lite": patch +--- + +feat:Lite version diff --git a/js/lite/package.json b/js/lite/package.json index 77c3c81589a1..b0a6f99d1f8d 100644 --- a/js/lite/package.json +++ b/js/lite/package.json @@ -12,6 +12,9 @@ "scripts": { "build": "pnpm --filter @gradio/app build:lite" }, + "dependencies": { + "gradio": "workspace:^" + }, "devDependencies": { "@gradio/app": "workspace:^", "@gradio/wasm": "workspace:^", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e780d3aa167..2b9ebc5a2fe2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1109,6 +1109,10 @@ importers: version: link:../utils js/lite: + dependencies: + gradio: + specifier: workspace:^ + version: link:../../gradio devDependencies: '@gradio/app': specifier: workspace:^ @@ -1116,9 +1120,6 @@ importers: '@gradio/wasm': specifier: workspace:^ version: link:../wasm - gradio: - specifier: workspace:^ - version: link:../../gradio js/markdown: dependencies: