Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
Merged
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
34 changes: 1 addition & 33 deletions packages/cli/src/lib/commands/workspace-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,14 @@ function sortItems(items: Record<string, unknown> = {}) {
.reduce((acc, curr) => ({ ...acc, [curr]: items[curr] }), {})
}

export function sortTsConfigPaths(file) {
return {
...file,
compilerOptions: {
...file?.compilerOptions,
paths: sortItems(file?.compilerOptions?.paths),
},
}
}

export function sortWorkspaceProjects(file) {
return {
...file,
projects: sortItems(file?.projects),
}
}

export function sortPackageJson(file) {
return {
...file,
scripts: sortItems(file?.scripts),
...(file?.scripts ? { scripts: sortItems(file?.scripts) } : {}),
}
}

export async function workspaceLint({ dryRun, skipPackageJson }: { dryRun: boolean; skipPackageJson: boolean }) {
for (const file of projectFiles) {
const contents = await getFileContents(file)
if (contents && !dryRun) {
await writeJson(file, sortWorkspaceProjects(contents), { spaces: 2 })
execSync('prettier --write ' + file)
}
}

for (const file of tsconfigFiles) {
const contents = await getFileContents(file)
if (contents && !dryRun) {
await writeJson(file, sortTsConfigPaths(contents), { spaces: 2 })
execSync('prettier --write ' + file)
}
}
if (!skipPackageJson) {
const file = 'package.json'
const contents = await getFileContents(file)
Expand Down