diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rs index 5c84f783753a0b47c29ea920e538343cad341775..85ab62af733799ae100cbc228263f47489c51aca 100644 --- a/crates/zed/src/menus.rs +++ b/crates/zed/src/menus.rs @@ -339,11 +339,7 @@ pub fn menus() -> Vec> { }, MenuItem::Action { name: "View Dependency Licenses", - action: Box::new(crate::OpenSoftwareLicenses), - }, - MenuItem::Action { - name: "View Theme Licenses", - action: Box::new(crate::OpenThemeLicenses), + action: Box::new(crate::OpenLicenses), }, MenuItem::Separator, MenuItem::Action { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d3e1d3d618147ae2b05290752e8cc05d7281552c..793172a1114a4d89f262ce8920aa8349f0b75ab1 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -57,8 +57,7 @@ actions!( DebugElements, OpenSettings, OpenLog, - OpenSoftwareLicenses, - OpenThemeLicenses, + OpenLicenses, OpenTelemetryLog, OpenKeymap, OpenDefaultSettings, @@ -180,32 +179,17 @@ pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { }); cx.add_action({ let app_state = app_state.clone(); - move |workspace: &mut Workspace, - _: &OpenSoftwareLicenses, - cx: &mut ViewContext| { + move |workspace: &mut Workspace, _: &OpenLicenses, cx: &mut ViewContext| { open_bundled_file( workspace, app_state.clone(), - "software_licenses.md", + "licenses.md", "Open Source License Attribution", "Markdown", cx, ); } }); - cx.add_action({ - let app_state = app_state.clone(); - move |workspace: &mut Workspace, _: &OpenThemeLicenses, cx: &mut ViewContext| { - open_bundled_file( - workspace, - app_state.clone(), - "theme_licenses.md", - "Theme License Attribution", - "Markdown", - cx, - ); - } - }); cx.add_action({ let app_state = app_state.clone(); move |workspace: &mut Workspace, _: &OpenTelemetryLog, cx: &mut ViewContext| { diff --git a/script/generate-licenses b/script/generate-licenses index f8a718bb1b00cdbb5b0c90cb65e4336b2ec24dc8..5147929cb8ed01240de6eeb7e783825a88520c03 100755 --- a/script/generate-licenses +++ b/script/generate-licenses @@ -2,20 +2,27 @@ set -e -[[ "$(cargo about --version)" == "cargo-about 0.5.2" ]] || cargo install cargo-about --locked --git https://github.com/zed-industries/cargo-about --branch error-code-on-warn +OUTPUT_FILE=$(pwd)/assets/licenses.md -echo "Generating cargo licenses" -cargo about generate --fail-on-missing-license -o assets/software_licenses.md -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md +> $OUTPUT_FILE -# cargo about automatically html-escapes all output, so we need to undo it here: -sed -i '' 's/"/"/g' assets/software_licenses.md -sed -i '' 's/'/'\''/g' assets/software_licenses.md # `'\''` ends the string, appends a single quote, and re-opens the string -sed -i '' 's/=/=/g' assets/software_licenses.md -sed -i '' 's/`/`/g' assets/software_licenses.md -sed -i '' 's/<//g' assets/software_licenses.md +echo -e "# ###### THEME LICENSES ######\n" >> $OUTPUT_FILE -# Now make theme licenses echo "Generating theme licenses" cd styles -npm run build-licenses \ No newline at end of file +npm run --silent build-licenses >> $OUTPUT_FILE +cd .. + +echo -e "# ###### CODE LICENSES ######\n" >> $OUTPUT_FILE + +[[ "$(cargo about --version)" == "cargo-about 0.5.2" ]] || cargo install cargo-about --locked --git https://github.com/zed-industries/cargo-about --branch error-code-on-warn + +echo "Generating cargo licenses" +cargo about generate --fail-on-missing-license -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md >> $OUTPUT_FILE + +sed -i '' 's/"/"/g' $OUTPUT_FILE +sed -i '' 's/'/'\''/g' $OUTPUT_FILE # The ` '\'' ` thing ends the string, appends a single quote, and re-opens the string +sed -i '' 's/=/=/g' $OUTPUT_FILE +sed -i '' 's/`/`/g' $OUTPUT_FILE +sed -i '' 's/<//g' $OUTPUT_FILE \ No newline at end of file diff --git a/script/licenses/template.hbs.md b/script/licenses/template.hbs.md index a51b714dae7edfa339acf6c0675d6cd1946ca1b1..a41aee8a4c4fc65877efa1a71750858bfa5864ae 100644 --- a/script/licenses/template.hbs.md +++ b/script/licenses/template.hbs.md @@ -1,20 +1,15 @@ -# Third Party Licenses - -This page lists the licenses of the projects used in Zed. - ## Overview of licenses: {{#each overview}} * {{name}} ({{count}}) {{/each}} -## All license texts: - +### All license texts: {{#each licenses}} -### {{name}} +#### {{name}} -#### Used by: +##### Used by: {{#each used_by}} * [{{crate.name}} {{crate.version}}]({{#if crate.repository}} {{crate.repository}} {{else}} https://crates.io/crates/{{crate.name}} {{/if}}) @@ -23,5 +18,4 @@ This page lists the licenses of the projects used in Zed. {{text}} -------------------------------------------------------------------------------- - {{/each}} \ No newline at end of file diff --git a/styles/src/buildLicenses.ts b/styles/src/buildLicenses.ts index 5cf1d02dbff87faf2e9dfbac2475d3eb19f7351a..e83496d91de465a845f61996fc61d60ae1d300d3 100644 --- a/styles/src/buildLicenses.ts +++ b/styles/src/buildLicenses.ts @@ -6,7 +6,7 @@ import { import { Meta } from "./themes/common/colorScheme"; import https from "https"; import crypto from "crypto"; -const license_file = `${__dirname}/../../assets/theme_licenses.md` + const accepted_licenses_file = `${__dirname}/../../script/licenses/zed-licenses.toml` // Use the cargo-about configuration file as the source of truth for supported licenses. @@ -62,14 +62,13 @@ function getLicenseText(schemeMeta: Meta[], callback: (meta: Meta, license_text: } } -function writeLicense(schemeMeta: Meta, text: String, stream: fs.WriteStream) { - stream.write(`# [${schemeMeta.name}](${schemeMeta.url})\n\n${text}\n******************************************************************************** \n`) +function writeLicense(schemeMeta: Meta, text: String) { + process.stdout.write(`## [${schemeMeta.name}](${schemeMeta.url})\n\n${text}\n********************************************************************************\n\n`) } const accepted_licenses = parseAcceptedToml(accepted_licenses_file); checkLicenses(schemeMeta, accepted_licenses) -const stream = fs.createWriteStream(license_file); getLicenseText(schemeMeta, (meta, text) => { - writeLicense(meta, text, stream) + writeLicense(meta, text) });