Skip to content
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

[core] Minor setup cleanup #13467

Merged
merged 8 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/scripts/api/buildApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-await-in-loop */
import * as yargs from 'yargs';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import path from 'path';
import fs from 'fs';
import * as prettier from 'prettier';
Expand Down Expand Up @@ -144,7 +145,7 @@ async function run() {
});
}

yargs
yargs(hideBin(process.argv))
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved
.command({
command: '$0',
describe: 'generates API docs',
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/api/buildGridEventsDocumentation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ts from 'typescript';
import path from 'path';
import { renderMarkdown } from '@mui/monorepo/packages/markdown';
import { renderMarkdown } from '@mui/internal-markdown';
import {
DocumentedInterfaces,
getSymbolDescription,
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/api/buildInterfacesDocumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as ts from 'typescript';
import { EOL } from 'os';
import kebabCase from 'lodash/kebabCase';
import path from 'path';
import { renderMarkdown } from '@mui/monorepo/packages/markdown';
import { renderMarkdown } from '@mui/internal-markdown';
import {
getSymbolDescription,
getSymbolJSDocTags,
Expand Down
5 changes: 3 additions & 2 deletions docs/scripts/generateProptypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as yargs from 'yargs';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import * as path from 'path';
import * as fse from 'fs-extra';
import * as prettier from 'prettier';
Expand Down Expand Up @@ -199,7 +200,7 @@ async function run() {
}
}

yargs
yargs(hideBin(process.argv))
.command({
command: '$0',
describe: 'Generates Component.propTypes from TypeScript declarations',
Expand Down
6 changes: 1 addition & 5 deletions docs/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": [
"../../node_modules/@mui/monorepo/packages/api-docs-builder/react-docgen.d.ts",
"api/buildApi.ts",
"i18n.js"
],
"include": ["api/buildApi.ts", "i18n.js"],
"compilerOptions": {
"allowJs": true,
"isolatedModules": true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"@octokit/rest": "^20.1.1",
"@playwright/test": "^1.44.1",
"@testing-library/react": "^15.0.7",
"@types/babel__traverse": "^7.20.6",
"@types/babel__core": "^7.20.5",
"@types/chai": "^4.3.16",
"@types/chai-dom": "^1.11.3",
Expand Down
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
const baseline = require('@mui/monorepo/prettier.config');

module.exports = {
...baseline,
overrides: [
...baseline.overrides,
{
files: ['**/*.json'],
options: {
trailingComma: 'none',
},
},
],
};
module.exports = require('@mui/monorepo/prettier.config');
3 changes: 2 additions & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import glob from 'fast-glob';
import path from 'path';
import { promisify } from 'util';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { getWorkspaceRoot } from './utils.mjs';

const exec = promisify(childProcess.exec);
Expand Down Expand Up @@ -102,7 +103,7 @@ async function run(argv) {
}
}

yargs(process.argv.slice(2))
yargs(hideBin(process.argv))
.command({
command: '$0 <bundle>',
description: 'build package',
Expand Down
3 changes: 2 additions & 1 deletion scripts/buildApiDocs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { ProjectSettings, buildApi } from '@mui-internal/api-docs-builder';
import { projectPickersSettings } from './pickersSettings';
import { projectChartsSettings } from './chartsSettings';
Expand All @@ -19,7 +20,7 @@ async function run(argv: yargs.ArgumentsCamelCase<CommandOptions>) {
return buildApi(projectSettings, grep);
}

yargs(process.argv.slice(2))
yargs(hideBin(process.argv))
.command({
command: '$0',
describe: 'Generates API documentation for the MUI packages.',
Expand Down
22 changes: 13 additions & 9 deletions scripts/l10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import traverse from '@babel/traverse';
import * as prettier from 'prettier';
import * as babel from '@babel/core';
import * as babelTypes from '@babel/types';
import * as yargs from 'yargs';
import yargs, { ArgumentsCamelCase } from 'yargs';
import { hideBin } from 'yargs/helpers';
import { Octokit } from '@octokit/rest';
import { retry } from '@octokit/plugin-retry';
import localeNames from './localeNames';
Expand All @@ -14,6 +15,7 @@ import {
SOURCE_GITHUB_BRANCH as DOCS_SOURCE_GITHUB_BRANCH,
} from '../docs/constants';

// @ts-ignore
const MyOctokit = Octokit.plugin(retry);

const GIT_ORGANIZATION = 'mui';
Expand Down Expand Up @@ -190,7 +192,7 @@ function findLocales(localesDirectory: string, constantsPath: string) {
}

function extractAndReplaceTranslations(localePath: string) {
const translations = {};
const translations: Translations = {};
const file = fse.readFileSync(localePath, { encoding: 'utf-8' });
const { code } = babel.transformSync(file, {
plugins: [...BABEL_PLUGINS, plugin(translations)],
Expand Down Expand Up @@ -315,7 +317,7 @@ type DocumentationReportItem = {
};
const generateDocReport = async (
missingTranslations: MissingTranslations,
baseTranslationsNumber,
baseTranslationsNumber: TranslationsNumber,
) => {
const workspaceRoot = path.resolve(__dirname, '../');

Expand All @@ -331,7 +333,7 @@ const generateDocReport = async (
importName.length > 2
? `${importName.slice(0, 2).toLowerCase()}-${importName.slice(2).toUpperCase()}`
: importName;
const localeName = localeNames[languageTag];
const localeName = localeNames[languageTag as keyof typeof localeNames];

if (localeName === undefined) {
throw new Error(
Expand Down Expand Up @@ -362,7 +364,7 @@ const generateDocReport = async (
});
};

async function updateIssue(githubToken, newMessage) {
async function updateIssue(githubToken: string, newMessage: string) {
// Initialize the API client
const octokit = new MyOctokit({
auth: githubToken,
Expand Down Expand Up @@ -394,12 +396,14 @@ interface HandlerArgv {
githubToken?: string;
}

async function run(argv: yargs.ArgumentsCamelCase<HandlerArgv>) {
type TranslationsNumber = Record<string, number>;

async function run(argv: ArgumentsCamelCase<HandlerArgv>) {
const { report, githubToken } = argv;
const workspaceRoot = path.resolve(__dirname, '../');

const missingTranslations: Record<string, any> = {};
const baseTranslationsNumber: Record<string, number> = {};
const missingTranslations: MissingTranslations = {};
const baseTranslationsNumber: TranslationsNumber = {};

await Promise.all(
packagesWithL10n.map(async (packageInfo) => {
Expand Down Expand Up @@ -491,7 +495,7 @@ async function run(argv: yargs.ArgumentsCamelCase<HandlerArgv>) {
process.exit(0);
}

yargs
yargs(hideBin(process.argv))
.command({
command: '$0',
describe: 'Syncs translation files.',
Expand Down
1 change: 0 additions & 1 deletion scripts/prettier.mjs

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/releaseChangelog.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-restricted-syntax */
import { Octokit } from '@octokit/rest';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

const GIT_ORGANIZATION = 'mui';
const GIT_REPO = 'mui-x';
Expand Down Expand Up @@ -43,7 +44,7 @@ async function findLatestTaggedVersion(octokit) {
}

function resolvePackagesByLabels(labels) {
let resolvedPackages = [];
const resolvedPackages = [];
labels.forEach((label) => {
switch (label.name) {
case 'component: data grid':
Expand Down Expand Up @@ -323,7 +324,7 @@ ${logChangelogSection(otherCommits, '')}
console.log(changelog);
}

yargs(process.argv.slice(2))
yargs(hideBin(process.argv))
.command({
command: '$0',
description: 'Creates a changelog',
Expand Down
3 changes: 2 additions & 1 deletion scripts/releaseTag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fse from 'fs-extra';
import path from 'path';
import { promisify } from 'util';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { getWorkspaceRoot } from './utils.mjs';

/**
Expand Down Expand Up @@ -75,7 +76,7 @@ async function main(argv) {
);
}

yargs(process.argv.slice(2))
yargs(hideBin(process.argv))
.command({
command: '$0',
description: 'Tags the current release and pushes these changes to mui/mui-x.',
Expand Down
7 changes: 4 additions & 3 deletions scripts/treeDataFromFileTree.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { promises as fs, Stats } from 'fs';
import path from 'path';
import * as yargs from 'yargs';
import yargs, { ArgumentsCamelCase } from 'yargs';
import { hideBin } from 'yargs/helpers';

interface Node {
hierarchy: string[];
Expand Down Expand Up @@ -49,7 +50,7 @@ const getSubTree = async (nodePath: string, parentHierarchy: string[] = []) => {
return nodes;
};

const run = async (argv: yargs.ArgumentsCamelCase<{ path: string }>) => {
const run = async (argv: ArgumentsCamelCase<{ path: string }>) => {
const children = await fs.readdir(argv.path);

const nodes: Node[] = [];
Expand All @@ -68,7 +69,7 @@ const run = async (argv: yargs.ArgumentsCamelCase<{ path: string }>) => {
);
};

yargs
yargs(hideBin(process.argv))
.command({
command: '$0',
describe: 'Generate tree data rows from a folder.',
Expand Down
Loading