Skip to content

Commit

Permalink
Merge pull request #45952 from nextcloud/fix/noid/spdxLicenseIdentifier
Browse files Browse the repository at this point in the history
Fix license information extracted from built assets
  • Loading branch information
AndyScherzinger authored Jun 18, 2024
2 parents a358717 + ef8937d commit ee6ddb9
Show file tree
Hide file tree
Showing 89 changed files with 3,515 additions and 3,098 deletions.
4 changes: 2 additions & 2 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ Files: apps/dav/tests/misc/caldav-search-limit-timerange-1.ics apps/dav/tests/mi
Copyright: 2023 Nextcloud GmbH and Nextcloud contributors
License: AGPL-3.0-or-later

Files: apps/cloud_federation_api/l10n/*.js apps/cloud_federation_api/l10n/*.json apps/contactsinteraction/l10n/*.js apps/contactsinteraction/l10n/*.json apps/dashboard/l10n/*.js apps/dashboard/l10n/*.json apps/files_reminders/l10n/*.js apps/files_reminders/l10n/*.json apps/lookup_server_connector/l10n/*.js apps/lookup_server_connector/l10n/*.json apps/oauth2 apps/sharebymail/l10n/*.js apps/oauth2 apps/sharebymail/l10n/*.json apps/theming/l10n/*.js apps/theming/l10n/*.json apps/twofactor_backupcodes/l10n/*.js apps/twofactor_backupcodes/l10n/*.json apps/user_status/l10n/*.js apps/user_status/l10n/*.json apps/weather_status/l10n/*.js apps/weather_status/l10n/*.json apps/workflowengine/l10n/*.js apps/workflowengine/l10n/*.json
Files: apps/cloud_federation_api/l10n/*.js apps/cloud_federation_api/l10n/*.json apps/contactsinteraction/l10n/*.js apps/contactsinteraction/l10n/*.json apps/dashboard/l10n/*.js apps/dashboard/l10n/*.json apps/files_reminders/l10n/*.js apps/files_reminders/l10n/*.json apps/lookup_server_connector/l10n/*.js apps/lookup_server_connector/l10n/*.json apps/sharebymail/l10n/*.js apps/oauth2/l10n/*.js apps/oauth2/l10n/*.json apps/sharebymail/l10n/*.json apps/theming/l10n/*.js apps/theming/l10n/*.json apps/twofactor_backupcodes/l10n/*.js apps/twofactor_backupcodes/l10n/*.json apps/user_status/l10n/*.js apps/user_status/l10n/*.json apps/weather_status/l10n/*.js apps/weather_status/l10n/*.json apps/workflowengine/l10n/*.js apps/workflowengine/l10n/*.json
Copyright: 2016-2024 Nextcloud translators
License: AGPL-3.0-or-later

Files: .gitattributes composer.json composer.lock .github/CODEOWNERS __tests__/tsconfig.json tsconfig.json build/integration/composer.* build/integration/data/*.png vendor-bin/*/composer.json vendor-bin/*/composer.lock apps/*/composer/composer.json apps/*/composer/composer.lock apps/*/composer/composer/installed.json
Files: composer.json composer.lock .github/CODEOWNERS __tests__/tsconfig.json tsconfig.json build/integration/composer.* vendor-bin/*/composer.json vendor-bin/*/composer.lock apps/*/composer/composer.json apps/*/composer/composer.lock apps/*/composer/composer/installed.json
Copyright: 2011-2016 ownCloud, Inc., 2016-2024 Nextcloud GmbH and Nextcloud contributors
License: AGPL-3.0-only OR AGPL-3.0-or-later

Expand Down
39 changes: 22 additions & 17 deletions build/WebpackSPDXPlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict'

/**
* Party inspired by https://github.com/FormidableLabs/webpack-stats-plugin
Expand All @@ -13,6 +13,7 @@ const path = require('node:path')
const webpack = require('webpack')

class WebpackSPDXPlugin {

#options

/**
Expand All @@ -24,16 +25,16 @@ class WebpackSPDXPlugin {
}

apply(compiler) {
compiler.hooks.thisCompilation.tap("spdx-plugin", (compilation) => {
compiler.hooks.thisCompilation.tap('spdx-plugin', (compilation) => {
// `processAssets` is one of the last hooks before frozen assets.
// We choose `PROCESS_ASSETS_STAGE_REPORT` which is the last possible
// stage after which to emit.
compilation.hooks.processAssets.tapPromise(
{
name: "spdx-plugin",
stage: compilation.constructor.PROCESS_ASSETS_STAGE_REPORT
name: 'spdx-plugin',
stage: compilation.constructor.PROCESS_ASSETS_STAGE_REPORT,
},
() => this.emitLicenses(compilation)
() => this.emitLicenses(compilation),
)
})
}
Expand Down Expand Up @@ -64,13 +65,11 @@ class WebpackSPDXPlugin {
}

/**
*
* @param {webpack.Compilation} compilation
* @param {*} callback
* @returns
* Emit licenses found in compilation to '.license' files
* @param {webpack.Compilation} compilation Webpack compilation object
* @param {*} callback Callback for old webpack versions
*/
async emitLicenses(compilation, callback) {
const moduleNames = (module) => module.modules?.map(moduleNames) ?? [module.name]
const logger = compilation.getLogger('spdx-plugin')
// cache the node packages
const packageInformation = new Map()
Expand All @@ -93,7 +92,7 @@ class WebpackSPDXPlugin {
/** @type {Set<webpack.Module>} */
const modules = new Set()
/**
* @param {webpack.Module} module
* @param {webpack.Module} module
*/
const addModule = (module) => {
if (module && !modules.has(module)) {
Expand Down Expand Up @@ -161,7 +160,7 @@ class WebpackSPDXPlugin {
// Get the information from the package
const { author: packageAuthor, name, version, license: packageLicense, licenses } = JSON.parse(await fs.readFile(pkg))
// Handle legacy packages
let license = !packageLicense && licenses
let license = !packageLicense && licenses
? licenses.map((entry) => entry.type ?? entry).join(' OR ')
: packageLicense
if (license?.includes(' ') && !license?.startsWith('(')) {
Expand Down Expand Up @@ -196,10 +195,15 @@ class WebpackSPDXPlugin {
}
licenses.add(license || 'unknown')
authors.add(pkg.author)
output += `\n- ${pkg.name}\n\t- version: ${pkg.version}\n\t- license: ${license}`
output += `- ${pkg.name}\n\t- version: ${pkg.version}\n\t- license: ${license}\n`
}
output = `\n\n${output}`
for (const author of [...authors].sort()) {
output = `SPDX-FileCopyrightText: ${author}\n${output}`
}
for (const license of [...licenses].sort()) {
output = `SPDX-License-Identifier: ${license}\n${output}`
}
output += `\n\nSPDX-License-Identifier: ${[...licenses].sort().join(' AND ')}\n`
output += [...authors].sort().map((author) => `SPDX-FileCopyrightText: ${author}`).join('\n');

compilation.emitAsset(
asset.split('?', 2)[0] + '.license',
Expand All @@ -208,9 +212,10 @@ class WebpackSPDXPlugin {
}

if (callback) {
return void callback()
return callback()
}
}

}

module.exports = WebpackSPDXPlugin;
module.exports = WebpackSPDXPlugin
26 changes: 14 additions & 12 deletions dist/1110-1110.js.license
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
This file is generated from multiple sources. Included packages:
SPDX-License-Identifier: MIT
SPDX-License-Identifier: ISC
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: inherits developers
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: @nextcloud/dialogs developers


This file is generated from multiple sources. Included packages:
- @nextcloud/dialogs
- version: 5.3.1
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -99,14 +112,3 @@ This file is generated from multiple sources. Included packages:
- which-typed-array
- version: 1.1.14
- license: MIT

SPDX-License-Identifier: GPL-3.0-or-later AND ISC AND MIT
SPDX-FileCopyrightText: @nextcloud/dialogs developers
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: inherits developers
26 changes: 14 additions & 12 deletions dist/1439-1439.js.license
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
This file is generated from multiple sources. Included packages:
SPDX-License-Identifier: MIT
SPDX-License-Identifier: ISC
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: inherits developers
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Austin Andrews


This file is generated from multiple sources. Included packages:
- @mdi/js
- version: 7.4.47
- license: Apache-2.0
Expand Down Expand Up @@ -102,14 +115,3 @@ This file is generated from multiple sources. Included packages:
- which-typed-array
- version: 1.1.14
- license: MIT

SPDX-License-Identifier: Apache-2.0 AND ISC AND MIT
SPDX-FileCopyrightText: Austin Andrews
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: inherits developers
45 changes: 25 additions & 20 deletions dist/1521-1521.js.license
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
This file is generated from multiple sources. Included packages:
SPDX-License-Identifier: MIT
SPDX-License-Identifier: ISC
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
SPDX-FileCopyrightText: inherits developers
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: Tobias Koppers @sokra
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <[email protected]> (https://cure53.de/)
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: Austin Andrews
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>


This file is generated from multiple sources. Included packages:
- @mdi/js
- version: 7.4.47
- license: Apache-2.0
Expand All @@ -17,7 +40,7 @@ This file is generated from multiple sources. Included packages:
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.11.2
- license: AGPL-3.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 10.9.0
- license: MIT
Expand Down Expand Up @@ -141,21 +164,3 @@ This file is generated from multiple sources. Included packages:
- nextcloud
- version: 1.0.0
- license: AGPL-3.0-or-later

SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0) AND AGPL-3.0 AND AGPL-3.0-or-later AND Apache-2.0 AND GPL-3.0-or-later AND ISC AND MIT
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
SPDX-FileCopyrightText: Austin Andrews
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <[email protected]> (https://cure53.de/)
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Tobias Koppers @sokra
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: inherits developers
65 changes: 35 additions & 30 deletions dist/1642-1642.js.license
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
This file is generated from multiple sources. Included packages:
SPDX-License-Identifier: MIT
SPDX-License-Identifier: ISC
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-License-Identifier: BSD-3-Clause
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
SPDX-FileCopyrightText: inherits developers
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: debounce developers
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: Tobias Koppers @sokra
SPDX-FileCopyrightText: T. Jameson Little <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: John-David Dalton <[email protected]> (http://allyoucanleet.com/)
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <[email protected]> (https://cure53.de/)
SPDX-FileCopyrightText: Denis Pushkarev
SPDX-FileCopyrightText: David Clark
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
SPDX-FileCopyrightText: Andris Reinman


This file is generated from multiple sources. Included packages:
- @nextcloud/auth
- version: 2.3.0
- license: GPL-3.0-or-later
Expand All @@ -8,7 +40,7 @@ This file is generated from multiple sources. Included packages:
- license: GPL-3.0-or-later
- @nextcloud/axios
- version: 2.4.0
- license: GPL-3.0
- license: GPL-3.0-or-later
- semver
- version: 7.6.2
- license: ISC
Expand All @@ -35,7 +67,7 @@ This file is generated from multiple sources. Included packages:
- license: MIT
- @nextcloud/vue
- version: 8.11.2
- license: AGPL-3.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 10.9.0
- license: MIT
Expand Down Expand Up @@ -186,30 +218,3 @@ This file is generated from multiple sources. Included packages:
- nextcloud
- version: 1.0.0
- license: AGPL-3.0-or-later

SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0) AND AGPL-3.0 AND AGPL-3.0-or-later AND BSD-3-Clause AND GPL-3.0 AND GPL-3.0-or-later AND ISC AND MIT
SPDX-FileCopyrightText: Andris Reinman
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: David Clark
SPDX-FileCopyrightText: Denis Pushkarev
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <[email protected]> (https://cure53.de/)
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: John-David Dalton <[email protected]> (http://allyoucanleet.com/)
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: T. Jameson Little <[email protected]>
SPDX-FileCopyrightText: Tobias Koppers @sokra
SPDX-FileCopyrightText: assert developers
SPDX-FileCopyrightText: debounce developers
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: inherits developers
Loading

0 comments on commit ee6ddb9

Please sign in to comment.