Skip to content

Commit

Permalink
[code-infra] Move typescript-to-proptypes to internal-scripts package (
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Feb 20, 2024
1 parent 9e2daa4 commit 47e1cf9
Show file tree
Hide file tree
Showing 108 changed files with 166 additions and 169 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ jobs:
echo "no changes"
fi
- run:
name: typescript-to-proptypes
name: internal-scripts
command: |
# latest commit
LATEST_COMMIT=$(git rev-parse HEAD)
# latest commit where packages/typescript-to-proptypes was changed
FOLDER_COMMIT=$(git log -1 --format=format:%H --full-diff packages/typescript-to-proptypes)
# latest commit where internal-scripts was changed
FOLDER_COMMIT=$(git log -1 --format=format:%H --full-diff packages-internal/scripts)
if [ $FOLDER_COMMIT = $LATEST_COMMIT ]; then
echo "changes, let's run the tests"
pnpm --filter typescript-to-proptypes test
pnpm --filter @mui/internal-scripts test
else
echo "no changes"
fi
Expand Down
4 changes: 2 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"packages/mui-types",
"packages/mui-utils",
"packages/docs-utils",
"packages/typescript-to-proptypes"
"packages-internal/scripts"
],
"publishDirectory": {
"@mui/base": "packages/mui-base/build",
Expand All @@ -40,7 +40,7 @@
"@mui/types": "packages/mui-types/build",
"@mui/utils": "packages/mui-utils/build",
"@mui-internal/docs-utils": "packages/docs-utils",
"@mui-internal/typescript-to-proptypes": "packages/typescript-to-proptypes"
"@mui/internal-scripts": "packages-internal/scripts"
},
"sandboxes": [
"/examples/material-ui-cra-ts",
Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/packages/zero-runtime/tests/fixtures/
/packages/zero-next-plugin/loader.js
# Ignore fixtures
/packages/typescript-to-proptypes/test/*/*
/packages-internal/scripts/typescript-to-proptypes/test/*/*
/test/bundling/fixtures/**/*.fixture.js
# just an import that reports eslint errors depending on whether the fixture (which is not checked in) exists
/test/bundling/fixtures/create-react-app/src/index.js
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ module.exports = {
},
},
{
files: ['packages/typescript-to-proptypes/src/**/*.ts'],
files: ['packages-internal/scripts/typescript-to-proptypes/src/**/*.ts'],
rules: {
// Working with flags is common in TypeScript compiler
'no-bitwise': 'off',
Expand Down
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ module.exports = function getBabelConfig(api) {
alias: {
...defaultAlias,
modules: './modules',
'typescript-to-proptypes': './packages/typescript-to-proptypes/src',
},
root: ['./'],
},
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@
"devDependencies": {
"@babel/plugin-transform-react-constant-elements": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@mui/internal-scripts": "workspace:^",
"@mui-internal/docs-utils": "workspace:^",
"@mui-internal/test-utils": "workspace:^",
"@mui-internal/typescript-to-proptypes": "workspace:^",
"@types/autosuggest-highlight": "^3.2.3",
"@types/chai": "^4.3.11",
"@types/css-mediaquery": "^0.1.4",
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const prettier = require('prettier');
const {
getPropTypesFromFile,
injectPropTypesInFile,
} = require('@mui-internal/typescript-to-proptypes');
} = require('@mui/internal-scripts/typescript-to-proptypes');
const {
createTypeScriptProjectBuilder,
} = require('@mui-internal/api-docs-builder/utils/createTypeScriptProject');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@
"@babel/preset-typescript": "^7.23.3",
"@babel/register": "^7.23.7",
"@mnajdova/enzyme-adapter-react-18": "^0.2.0",
"@mui/internal-scripts": "workspace:^",
"@mui-internal/api-docs-builder": "workspace:^",
"@mui-internal/api-docs-builder-core": "workspace:^",
"@mui-internal/docs-utils": "workspace:^",
"@mui-internal/test-utils": "workspace:^",
"@mui-internal/typescript-to-proptypes": "workspace:^",
"@mui/joy": "workspace:*",
"@mui/material": "workspace:^",
"@mui/utils": "workspace:^",
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions packages-internal/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 1.0.0

Initial release as an npm package.
The package contains the typescript-to-proptypes module.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{
"name": "@mui-internal/typescript-to-proptypes",
"version": "1.0.3",
"name": "@mui/internal-scripts",
"version": "1.0.0",
"author": "MUI Team",
"description": "Generate proptypes from TypeScript declarations. This is a fork of the typescript-to-proptypes package adapted for MUI needs. This is an internal package not meant for general use.",
"description": "Utilities supporting MUI libraries build and docs generation. This is an internal package not meant for general use.",
"main": "build/index.js",
"exports": {
".": "./build/index.js"
"./typescript-to-proptypes": {
"default": "./build/typescript-to-proptypes/index.js",
"types": "./build/typescript-to-proptypes/index.d.ts"
}
},
"types": "./build/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/mui/material-ui.git",
"directory": "packages/typescript-to-proptypes"
"directory": "packages-internal/scripts"
},
"license": "MIT",
"scripts": {
"prebuild": "rimraf ./build",
"build": "tsc -b tsconfig.build.json",
"build": "tsc --build tsconfig.json",
"release:publish": "pnpm publish --tag latest",
"release:publish:dry-run": "pnpm publish --tag latest --registry=\"http://localhost:4873/\"",
"test": "cd ../../ && cross-env NODE_ENV=test mocha --config packages/typescript-to-proptypes/.mocharc.js 'packages/typescript-to-proptypes/**/*.test.ts'",
"typescript": "tsc -b tsconfig.json"
"test": "cd ../../ && cross-env NODE_ENV=test mocha --config packages-internal/scripts/typescript-to-proptypes/test/.mocharc.js 'packages-internal/scripts/typescript-to-proptypes/**/*.test.ts'",
"typescript": "tsc --build tsconfig.typecheck.json"
},
"dependencies": {
"@babel/core": "^7.23.9",
Expand Down
17 changes: 17 additions & 0 deletions packages-internal/scripts/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2020",
"moduleResolution": "node",
"module": "commonjs",
"types": ["node"],

"strict": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"composite": true,

"esModuleInterop": true,
"isolatedModules": true
}
}
5 changes: 5 additions & 0 deletions packages-internal/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files": [],
"include": [],
"references": [{ "path": "./typescript-to-proptypes" }]
}
11 changes: 11 additions & 0 deletions packages-internal/scripts/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDir": "../..",
"types": ["node", "mocha"],
"noEmit": true
},
"include": ["./**/*.ts"],
"exclude": ["./build", "./node_modules"],
"references": [{ "path": "../../packages/docs-utils/tsconfig.build.json" }]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extension: ['js', 'ts', 'tsx'],
ignore: ['**/node_modules/**'],
require: [require.resolve('./test/testSetup')],
require: [require.resolve('./testSetup')],
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const options: TestOptions = {
}
return true;
},
},
} as TestOptions['parser'],
injector: {
includeJSDoc: false,
comment: 'Proptypes generated automatically',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TestOptions } from '../types';
const options: TestOptions = {
parser: {
checkDeclarations: true,
},
} as TestOptions['parser'],
};

export default options;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const options: TestOptions = {
},
parser: {
checkDeclarations: true,
},
} as TestOptions['parser'],
};

export default options;
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import * as ts from 'typescript';
import { expect } from 'chai';
import glob from 'fast-glob';
import prettier from 'prettier';
import {
TypeScriptProject,
createTypeScriptProjectBuilder,
} from '@mui-internal/api-docs-builder/utils/createTypeScriptProject';
import { TypeScriptProject, createTypeScriptProjectBuilder } from '@mui-internal/docs-utils';
import { generatePropTypes } from '../src/generatePropTypes';
import { injectPropTypesInFile } from '../src/injectPropTypesInFile';
import { getPropTypesFromFile } from '../src/getPropTypesFromFile';
Expand Down Expand Up @@ -42,7 +39,7 @@ describe('typescript-to-proptypes', () => {
const buildProject = createTypeScriptProjectBuilder({
test: {
rootPath: path.join(__dirname, '..'),
tsConfigPath: 'tsconfig.json',
tsConfigPath: 'tsconfig.test.json',
},
});

Expand Down Expand Up @@ -72,7 +69,7 @@ describe('typescript-to-proptypes', () => {

const components = getPropTypesFromFile({ filePath: inputPath, project, ...options.parser });

let inputSource = null;
let inputSource: string | null = null;
if (inputPath.endsWith('.d.ts')) {
try {
inputSource = fs.readFileSync(inputJS, 'utf8');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "../build/typescript-to-proptypes",
"tsBuildInfoFile": "../build/typescript-to-proptypes/.tsbuildinfo"
},
"include": ["./src/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"isolatedModules": true
},
"include": ["./src/*.ts", "./test/*.ts"],
"references": [{ "path": "../docs-utils/tsconfig.build.json" }]
"references": [{ "path": "../../docs-utils/tsconfig.build.json" }]
}
2 changes: 1 addition & 1 deletion packages/docs-utils/src/getPropsFromComponentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function getPropsFromVariableDeclaration({
const propsType = type.aliasTypeArguments[0];
if (propsType === undefined) {
throw new TypeError(
'Unable to find symbol for `props`. This is a bug in @mui-internal/typescript-to-proptypes.',
'Unable to find symbol for `props`. This is a bug in typescript-to-proptypes.',
);
}
return parsePropsType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"@mui/zero-tag-processor/*": ["./zero-tag-processor/src/*"],
"@mui/zero-vite-plugin": ["./zero-vite-plugin/src"],
"@mui/zero-vite-plugin/*": ["./zero-vite-plugin/src/*"],
"typescript-to-proptypes": ["./typescript-to-proptypes/src"]
"@mui/internal-scripts/typescript-to-proptypes": [
"../packages-internal/scripts/typescript-to-proptypes/src"
]
}
},
"exclude": ["**/node_modules/"]
Expand Down
18 changes: 0 additions & 18 deletions packages/typescript-to-proptypes/CHANGELOG.md

This file was deleted.

21 changes: 0 additions & 21 deletions packages/typescript-to-proptypes/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions packages/typescript-to-proptypes/tsconfig.build.json

This file was deleted.

Loading

0 comments on commit 47e1cf9

Please sign in to comment.