-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(scripts-generators): create manifest only from v8 monorepo packages within generate-package-manifest
#29579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,77 @@ | ||
| /** | ||
| * This is used solely for V8 release. | ||
| * @see {@link ../../azure-pipelines.release.yml} | ||
| * {@link file://./../../azure-pipelines.release.yml} | ||
| */ | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const fs = require('fs-extra'); | ||
Hotell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const { getAllPackageInfo, workspaceRoot } = require('@fluentui/scripts-monorepo'); | ||
| const semver = require('semver'); | ||
| const { getAllPackageInfo, findGitRoot } = require('@fluentui/scripts-monorepo'); | ||
|
|
||
| // Generate "manifest" file with package.jsons of all the monorepo packages (mainly for ODSP) | ||
| main('v8', path.join(workspaceRoot, 'package-manifest'), '@fluentui/react'); | ||
|
|
||
| /** | ||
| * Generate "manifest" JSON file with map of package.json of monorepo packages that belong under provided tag group | ||
| * @remarks This is mainly/only for ODSP | ||
| * @param {string} tag - based on this only project containing this tag will be processed | ||
| * @param {string} manifestRoot - directory path where it should be generated | ||
| * @param {string} rootPackage | ||
| */ | ||
| function main(tag, manifestRoot, rootPackage) { | ||
| const allPackageInfo = getAllPackageInfo(); | ||
|
|
||
| const filteredPackages = Object.entries(allPackageInfo).reduce((acc, curr) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: might be easier to call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you elaborate a bit more ? You mean using following ?
if that's the case I dont think its more readable/faster than reduce |
||
| const projectJsonPath = path.join(curr[1].packagePath, 'project.json'); | ||
| /** @type {import('@nx/devkit').ProjectConfiguration} */ | ||
| const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf-8')); | ||
| const { tags = [], projectType } = projectJson; | ||
|
|
||
| const ommittedPackagePaths = ['react-components', 'packages/fluentui', 'web-components', 'apps/']; | ||
| if (projectType === 'application') { | ||
| return acc; | ||
| } | ||
|
|
||
| const allPackageInfo = getAllPackageInfo(); | ||
| if (tags.length === 0) { | ||
| return acc; | ||
| } | ||
|
|
||
| // eslint-disable-next-line guard-for-in | ||
| for (const key in allPackageInfo) { | ||
| const normalizedPath = allPackageInfo[key]?.packagePath.split('\\').join('/'); | ||
| ommittedPackagePaths.forEach(omittedPath => { | ||
| if (normalizedPath.includes(omittedPath)) { | ||
| delete allPackageInfo[key]; | ||
| return; | ||
| if (tags.indexOf(tag) !== -1) { | ||
| acc[curr[0]] = curr[1]; | ||
| } | ||
| }); | ||
|
|
||
| return acc; | ||
| }, /** @type {typeof allPackageInfo} */ ({})); | ||
|
|
||
| const rootPackageVersion = filteredPackages[rootPackage].packageJson.version; | ||
| const packageInfoString = JSON.stringify(filteredPackages, null, 2); | ||
|
|
||
| const dests = [rootPackageVersion, path.join('latest', String(semver.major(rootPackageVersion)))]; | ||
|
|
||
| for (const dest of dests) { | ||
| const destFolder = path.join(manifestRoot, dest); | ||
| fs.mkdirSync(destFolder, { recursive: true }); | ||
| fs.writeFileSync(path.join(destFolder, 'package-manifest.json'), packageInfoString, 'utf8'); | ||
| } | ||
|
|
||
| console.log('Manifest generated:\n'); | ||
| console.log(getFileList(manifestRoot).join('\n')); | ||
| } | ||
| const fuirVersion = allPackageInfo['@fluentui/react'].packageJson.version; | ||
| const packageInfoString = JSON.stringify(allPackageInfo, null, 2); | ||
|
|
||
| const manifestRoot = path.join(findGitRoot(), 'package-manifest'); | ||
| const dests = [fuirVersion, path.join('latest', String(semver.major(fuirVersion)))]; | ||
| /** | ||
| * @param {string} dirName | ||
| */ | ||
| function getFileList(dirName) { | ||
| /** @type {string[]} */ | ||
Hotell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let files = []; | ||
| const items = fs.readdirSync(dirName, { withFileTypes: true }); | ||
|
|
||
| for (const item of items) { | ||
| if (item.isDirectory()) { | ||
| files = [...files, ...getFileList(`${dirName}/${item.name}`)]; | ||
| } else { | ||
| files.push(`${dirName}/${item.name}`); | ||
| } | ||
| } | ||
|
|
||
| for (const dest of dests) { | ||
| const destFolder = path.join(manifestRoot, dest); | ||
| fs.mkdirpSync(destFolder); | ||
| fs.writeFileSync(path.join(destFolder, 'package-manifest.json'), packageInfoString); | ||
| return files; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.