Skip to content

Commit

Permalink
fixup! chore: use new performant 'type-check' for tools tagged libaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell committed May 27, 2024
1 parent 136f5d8 commit 7b97f95
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
3 changes: 0 additions & 3 deletions tools/workspace-plugin/just.config.ts

This file was deleted.

6 changes: 2 additions & 4 deletions tools/workspace-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"generators": "./generators.json",
"scripts": {
"test": "nx run @fluentui/workspace-plugin:test",
"type-check": "just-scripts type-check",
"type-check": "node ./scripts/type-check",
"lint": "eslint --ext .ts,.js,.json ."
},
"dependencies": {
"@nx/devkit": "^17.3.2"
},
"devDependencies": {
"@fluentui/scripts-tasks": "*"
}
"devDependencies": {}
}
61 changes: 61 additions & 0 deletions tools/workspace-plugin/scripts/type-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// @ts-check

import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import { promisify } from 'node:util';
import { exec } from 'node:child_process';
import { exit } from 'node:process';

const asyncExec = promisify(exec);

main().catch(err => {
console.error(err);
exit(1);
});

/**
* Copied from ${@link 'file://./../../../scripts/tasks/src/type-check.ts'}
*/
async function main() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json'), 'utf-8'));

const tsConfigsRefs = getTsConfigs(rootConfig, { spec: false, e2e: false });

const asyncQueue = [];

for (const ref of tsConfigsRefs) {
const program = `tsc -p ${ref} --pretty --noEmit --baseUrl .`;
asyncQueue.push(asyncExec(program));
}

return Promise.all(asyncQueue).catch(err => {
console.error(err.stdout);
exit(1);
});
}

/**
* @param {{references?: Array<{ path: string }>;}} solutionConfig
* @param {{ spec: boolean, e2e: boolean }} exclude
*/
function getTsConfigs(solutionConfig, exclude) {
const refs = solutionConfig.references ?? [];
/** @type {string[]} */
const refsPaths = [];

for (const ref of refs) {
if (exclude.spec && ref.path.includes('spec')) {
continue;
}
if (exclude.e2e && ref.path.includes('cy')) {
continue;
}

refsPaths.push(ref.path);
}

return refsPaths;
}

0 comments on commit 7b97f95

Please sign in to comment.