forked from mantinedev/mantine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: build all scripts cannot running
- Loading branch information
1 parent
2574e79
commit 37279d9
Showing
17 changed files
with
80 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,6 @@ lib/ | |
cjs/ | ||
esm/ | ||
docs/.docgen/ | ||
|
||
# typescript | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,7 @@ | ||
import { spawn } from 'child_process'; | ||
import execa from 'execa'; | ||
|
||
export default async function generateDts(packagePath: string) { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('yarn', ['tsc', '--emitDeclarationOnly'], { | ||
cwd: packagePath, | ||
}); | ||
|
||
child.on('close', (code) => { | ||
if (code !== 0) reject(code); | ||
else resolve(code); | ||
}); | ||
|
||
child.on('exit', (code) => { | ||
if (code !== 0) reject(code); | ||
else resolve(code); | ||
}); | ||
|
||
child.on('error', (err) => { | ||
reject(err); | ||
}); | ||
await execa('yarn', ['tsc', '--build'], { | ||
cwd: packagePath, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,53 @@ | ||
/* eslint-disable no-param-reassign, no-restricted-syntax, no-continue, no-await-in-loop */ | ||
import { getPackagesList, Package } from './get-packages-list'; | ||
|
||
export async function getPackageBuildOrder( | ||
packages: Package[], | ||
pkg: Package, | ||
order: Record<string, number> = {} | ||
) { | ||
const { name } = pkg.packageJson; | ||
|
||
if (name in order) return; | ||
if (pkg.packageJson.private) { | ||
order[name] = -1; | ||
return; | ||
} | ||
|
||
packages = packages || []; | ||
|
||
const dependencies = Object.keys({ | ||
...pkg.packageJson.peerDependencies, | ||
...pkg.packageJson.dependencies, | ||
}) | ||
.filter((dependency) => dependency.includes('@mantine/')) | ||
.map((dependency) => packages.find((pkgItem) => pkgItem.packageJson.name === dependency)); | ||
|
||
if (dependencies.length === 0) { | ||
order[name] = 0; | ||
return; | ||
} | ||
|
||
await Promise.all( | ||
dependencies.map((dependency) => getPackageBuildOrder(packages, dependency, order)) | ||
); | ||
|
||
order[name] = | ||
1 + Math.max(...dependencies.map((dependency) => order[dependency.packageJson.name])); | ||
} | ||
|
||
export async function getPackagesBuildOrder( | ||
packages?: Package[], | ||
order: Record<string, number> = {} | ||
) { | ||
const data = packages || (await getPackagesList()); | ||
|
||
for (const item of data) { | ||
const { name } = item.packageJson; | ||
|
||
if (name in order) { | ||
continue; | ||
} | ||
|
||
if (item.packageJson.private) { | ||
order[name] = -1; | ||
continue; | ||
} | ||
|
||
const dependencies = Object.keys({ | ||
...item.packageJson.dependencies, | ||
...item.packageJson.peerDependencies, | ||
}) | ||
.filter((dependency) => dependency.includes('@mantine/')) | ||
.map((dependency) => data.find((dataItem) => dataItem.packageJson.name === dependency)); | ||
|
||
if (dependencies.length === 0) { | ||
order[name] = 0; | ||
continue; | ||
} | ||
|
||
await getPackagesBuildOrder(dependencies, order); | ||
order[name] = | ||
1 + Math.max(...dependencies.map((dependency) => order[dependency.packageJson.name])); | ||
packages = packages || (await getPackagesList()); | ||
|
||
for (const pkg of packages) { | ||
await getPackageBuildOrder(packages, pkg, order); | ||
} | ||
|
||
return Object.keys(order) | ||
.filter((p) => order[p] !== -1) | ||
.sort((a, b) => order[a] - order[b]) | ||
.map((p) => data.find((dataItem) => dataItem.packageJson.name === p)); | ||
.map((p) => packages.find((dataItem) => dataItem.packageJson.name === p)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters