Skip to content

Commit

Permalink
chore(scripts-tasks): remove not needed api-extractor task logs (#27094)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell authored Mar 30, 2023
1 parent 7dc0392 commit bad91e9
Showing 1 changed file with 1 addition and 67 deletions.
68 changes: 1 addition & 67 deletions scripts/tasks/src/api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ interface ApiExtractorCliRunCommandArgs {

export function apiExtractor(): TaskFunction {
const { configs, configsToExecute } = getConfig();
const messages = {
const messages: Record<keyof typeof compilerMessages, string[]> = {
TS7016: [] as string[],
TS2305: [] as string[],
};
let configDebug: Parameters<NonNullable<ApiExtractorOptions['onConfigLoaded']>>[0] | null = null;

const args: ReturnType<typeof getJustArgv> & Partial<ApiExtractorCliRunCommandArgs> = getJustArgv();
const { isUsingTsSolutionConfigs, packageJson, tsConfig } = getTsPathAliasesConfig();
Expand All @@ -70,8 +69,6 @@ export function apiExtractor(): TaskFunction {
*/
const isLocalBuild = args.local ?? !(process.env.TF_BUILD || isCI);

console.log({ isLocalBuild });

const tasks = configsToExecute.map(([configPath, configName]) => {
const taskName = `api-extractor:${configName}`;

Expand Down Expand Up @@ -120,8 +117,6 @@ export function apiExtractor(): TaskFunction {

// NOTE: internally just-tasks calls `options.onConfigLoaded?.(rawConfig);` so we need to mutate object properties (js passes objects by reference)
config.compiler = compilerConfig;

configDebug = config;
}

function messageCallback(message: Parameters<NonNullable<ApiExtractorOptions['messageCallback']>>[0]) {
Expand Down Expand Up @@ -150,25 +145,6 @@ export function apiExtractor(): TaskFunction {
return;
}

// Log on CI processed configs for better troubleshooting for https://github.com/microsoft/fluentui/issues/25766
// if (process.env.TF_BUILD) {
logger.info('❌ api-extractor FAIL debug:', {
configsToExecute,
extractorOptions: JSON.stringify(configDebug, null, 2),
});
// }

if (messages.TS2305.length) {
const errTitle = [
chalk.bgRed.white.bold(`api-extractor | API VIOLATION:`),
chalk.red(` Your package public API uses \`@internal\` marked API's from following packages:`),
'\n',
].join('');
const logErr = formatApiViolationMessage(messages.TS2305);

logger.error(errTitle, logErr, '\n');
}

if (messages.TS7016.length) {
const errTitle = [
chalk.bgRed.white.bold(`api-extractor | MISSING DEPENDENCY TYPE DECLARATIONS:`),
Expand Down Expand Up @@ -208,48 +184,6 @@ function getConfig() {
return { configsToExecute, configs };
}

/**
*
* @example
*
* ```
(TS2305) Module '"@fluentui/react-shared-contexts"' has no exported member 'ThemeContextValue_unstable'.
(TS2305) Module '"@fluentui/react-shared-contexts"' has no exported member 'TooltipVisibilityContextValue_unstable'.
↓ ↓ ↓
@fluentui/react-shared-contexts:
- TooltipVisibilityContextValue_unstable
- ThemeContextValue_unstable
```
*/
function formatApiViolationMessage(messages: string[]) {
const regexPkg = /'"(@fluentui\/[a-z-]+)"'/i;
const exportedTokenRegex = /'([a-z-_]+)'/i;

const byPackage = messages.reduce((acc, curr) => {
const [, packageName] = regexPkg.exec(curr) ?? [];
const [, exportedToken] = exportedTokenRegex.exec(curr) ?? [];
if (acc[packageName]) {
acc[packageName].add(exportedToken);
return acc;
}
acc[packageName] = new Set([exportedToken]);
return acc;
}, {} as Record<string, Set<string>>);

return Object.entries(byPackage)
.map(([packageName, tokens]) => {
return [
chalk.red.underline(packageName) + ':',
Array.from(tokens)
.map(token => chalk.italic.red(' - ' + token))
.join('\n'),
].join('\n');
})
.join('\n');
}

/**
*
* @example
Expand Down

0 comments on commit bad91e9

Please sign in to comment.