mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 23:26:16 +08:00
[*] Fix: Resolve Windows regression caused by upgrading glob (#6227)
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
**/dist/**
|
**/dist/**
|
||||||
**/build/**
|
**/build/**
|
||||||
**/npm/**
|
**/npm/**
|
||||||
|
!scripts/npm/**
|
||||||
**/.output/**
|
**/.output/**
|
||||||
**/.browser-profiles/**
|
**/.browser-profiles/**
|
||||||
**/__tests__/integration/fixtures/**
|
**/__tests__/integration/fixtures/**
|
||||||
|
@ -17,8 +17,8 @@ import {selectAll} from '../keyboardShortcuts/index.mjs';
|
|||||||
function findAsset(pattern) {
|
function findAsset(pattern) {
|
||||||
const prefix = 'packages/lexical-playground/build';
|
const prefix = 'packages/lexical-playground/build';
|
||||||
const resolvedPattern = `${prefix}/assets/${pattern}`;
|
const resolvedPattern = `${prefix}/assets/${pattern}`;
|
||||||
for (const fn of glob.sync(resolvedPattern)) {
|
for (const fn of glob.sync(resolvedPattern, {windowsPathsNoEscape: true})) {
|
||||||
return fn.slice(prefix.length);
|
return fn.replaceAll('\\', '/').slice(prefix.length);
|
||||||
}
|
}
|
||||||
throw new Error(`Missing asset at ${resolvedPattern}`);
|
throw new Error(`Missing asset at ${resolvedPattern}`);
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,13 @@ module.exports = async function (context, options) {
|
|||||||
loadContent: () => {
|
loadContent: () => {
|
||||||
fs.mkdirSync(options.targetDir, {recursive: true});
|
fs.mkdirSync(options.targetDir, {recursive: true});
|
||||||
const oldTargets = new Set(
|
const oldTargets = new Set(
|
||||||
glob.sync(path.resolve(options.targetDir, '*.md')),
|
glob.sync(path.resolve(options.targetDir, '*.md'), {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
for (const srcPath of glob.sync(`${options.baseDir}/*/README.md`)) {
|
for (const srcPath of glob.sync(`${options.baseDir}/*/README.md`, {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
})) {
|
||||||
const jsonPath = path.resolve(path.dirname(srcPath), 'package.json');
|
const jsonPath = path.resolve(path.dirname(srcPath), 'package.json');
|
||||||
if (!fs.existsSync(jsonPath)) {
|
if (!fs.existsSync(jsonPath)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -27,5 +27,7 @@ describe('prepare-release tests', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
['examples', 'scripts/__tests__/integration/fixtures']
|
['examples', 'scripts/__tests__/integration/fixtures']
|
||||||
.flatMap((packagesDir) => glob.sync(`${packagesDir}/*/package.json`))
|
.flatMap((packagesDir) =>
|
||||||
|
glob.sync(`${packagesDir}/*/package.json`, {windowsPathsNoEscape: true}),
|
||||||
|
)
|
||||||
.forEach((exampleJsonPath) => describeExample(exampleJsonPath));
|
.forEach((exampleJsonPath) => describeExample(exampleJsonPath));
|
||||||
|
@ -38,7 +38,11 @@ describe('public package.json audits (`npm run update-packages` to fix most issu
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
it('has *.flow types', () => {
|
it('has *.flow types', () => {
|
||||||
expect(glob.sync(pkg.resolve('flow', '*.flow'))).not.toEqual([]);
|
expect(
|
||||||
|
glob.sync(pkg.resolve('flow', '*.flow'), {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
}),
|
||||||
|
).not.toEqual([]);
|
||||||
});
|
});
|
||||||
it('uses the expected directory/npm naming convention', () => {
|
it('uses the expected directory/npm naming convention', () => {
|
||||||
expect(npmName.replace(/^@/, '').replace('/', '-')).toBe(
|
expect(npmName.replace(/^@/, '').replace('/', '-')).toBe(
|
||||||
@ -118,7 +122,11 @@ describe('www public package audits (`npm run update-packages` to fix most issue
|
|||||||
const wwwEntrypoint = `${npmToWwwName(npmName)}.js`;
|
const wwwEntrypoint = `${npmToWwwName(npmName)}.js`;
|
||||||
describe(npmName, () => {
|
describe(npmName, () => {
|
||||||
it('has *.flow types', () => {
|
it('has *.flow types', () => {
|
||||||
expect(glob.sync(pkg.resolve('flow', '*.flow'))).not.toEqual([]);
|
expect(
|
||||||
|
glob.sync(pkg.resolve('flow', '*.flow'), {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
}),
|
||||||
|
).not.toEqual([]);
|
||||||
});
|
});
|
||||||
// Only worry about the entrypoint stub if it has a single module export
|
// Only worry about the entrypoint stub if it has a single module export
|
||||||
if (pkg.getExportedNpmModuleNames().every((name) => name === npmName)) {
|
if (pkg.getExportedNpmModuleNames().every((name) => name === npmName)) {
|
||||||
|
@ -31,7 +31,9 @@ function preparePackage(pkg) {
|
|||||||
fs.removeSync(pkg.resolve('npm'));
|
fs.removeSync(pkg.resolve('npm'));
|
||||||
fs.ensureDirSync(pkg.resolve('npm'));
|
fs.ensureDirSync(pkg.resolve('npm'));
|
||||||
fs.copySync(pkg.resolve('dist'), pkg.resolve('npm'));
|
fs.copySync(pkg.resolve('dist'), pkg.resolve('npm'));
|
||||||
const flowSources = glob.sync(pkg.resolve('flow', '*.flow'));
|
const flowSources = glob.sync(pkg.resolve('flow', '*.flow'), {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
});
|
||||||
if (flowSources.length === 0) {
|
if (flowSources.length === 0) {
|
||||||
console.error(
|
console.error(
|
||||||
`Missing Flow type definitions for package ${pkg.getDirectoryName()}`,
|
`Missing Flow type definitions for package ${pkg.getDirectoryName()}`,
|
||||||
|
@ -19,7 +19,10 @@ async function main() {
|
|||||||
throw new Error('USAGE: node ./scripts/override-react --version=beta');
|
throw new Error('USAGE: node ./scripts/override-react --version=beta');
|
||||||
}
|
}
|
||||||
const packages = ['react', 'react-dom'];
|
const packages = ['react', 'react-dom'];
|
||||||
['package.json', ...glob.sync('./packages/*/package.json')].forEach((fn) => {
|
[
|
||||||
|
'package.json',
|
||||||
|
...glob.sync('./packages/*/package.json', {windowsPathsNoEscape: true}),
|
||||||
|
].forEach((fn) => {
|
||||||
const json = fs.readJsonSync(fn);
|
const json = fs.readJsonSync(fn);
|
||||||
const isRoot = fn === 'package.json';
|
const isRoot = fn === 'package.json';
|
||||||
let didUpdate = isRoot;
|
let didUpdate = isRoot;
|
||||||
|
@ -129,5 +129,6 @@ exports.packagesManager = new PackagesManager(
|
|||||||
path.dirname(path.dirname(__dirname)),
|
path.dirname(path.dirname(__dirname)),
|
||||||
'packages/*/package.json',
|
'packages/*/package.json',
|
||||||
),
|
),
|
||||||
|
{windowsPathsNoEscape: true},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -60,6 +60,7 @@ async function updateTsconfig({
|
|||||||
testPaths.push([`${pkg.getNpmName()}/src`, [resolveRelative('src')]]);
|
testPaths.push([`${pkg.getNpmName()}/src`, [resolveRelative('src')]]);
|
||||||
for (const fn of glob.sync(
|
for (const fn of glob.sync(
|
||||||
pkg.resolve('src', '__tests__', 'utils', '*.{ts,tsx,mjs,jsx}'),
|
pkg.resolve('src', '__tests__', 'utils', '*.{ts,tsx,mjs,jsx}'),
|
||||||
|
{windowsPathsNoEscape: true},
|
||||||
)) {
|
)) {
|
||||||
testPaths.push([
|
testPaths.push([
|
||||||
`${pkg.getNpmName()}/src/__tests__/utils`,
|
`${pkg.getNpmName()}/src/__tests__/utils`,
|
||||||
|
@ -29,7 +29,7 @@ const diagnosticsHost = {
|
|||||||
*/
|
*/
|
||||||
function validateTscTypes() {
|
function validateTscTypes() {
|
||||||
const dtsFilesPattern = './.ts-temp/packages/{lexical,lexical-*}/**/*.d.ts';
|
const dtsFilesPattern = './.ts-temp/packages/{lexical,lexical-*}/**/*.d.ts';
|
||||||
const dtsFiles = glob.sync(dtsFilesPattern);
|
const dtsFiles = glob.sync(dtsFilesPattern, {windowsPathsNoEscape: true});
|
||||||
if (dtsFiles.length === 0) {
|
if (dtsFiles.length === 0) {
|
||||||
console.error(
|
console.error(
|
||||||
`Missing ${dtsFilesPattern}, \`npm run build-prod\` or \`npm run build-release\` first`,
|
`Missing ${dtsFilesPattern}, \`npm run build-prod\` or \`npm run build-release\` first`,
|
||||||
|
@ -22,7 +22,9 @@ const transformFlowFileContents = require('./transformFlowFileContents');
|
|||||||
// for each package so they can easily be copied to www.
|
// for each package so they can easily be copied to www.
|
||||||
async function rewriteImports() {
|
async function rewriteImports() {
|
||||||
for (const pkg of packagesManager.getPackages()) {
|
for (const pkg of packagesManager.getPackages()) {
|
||||||
for (const flowFile of glob.sync(pkg.resolve('flow', '*.flow'))) {
|
for (const flowFile of glob.sync(pkg.resolve('flow', '*.flow'), {
|
||||||
|
windowsPathsNoEscape: true,
|
||||||
|
})) {
|
||||||
const data = fs.readFileSync(flowFile, 'utf8');
|
const data = fs.readFileSync(flowFile, 'utf8');
|
||||||
const result = await transformFlowFileContents(data);
|
const result = await transformFlowFileContents(data);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
Reference in New Issue
Block a user