Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(scripts): remove deprecated exec abstractions #25569

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
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
23 changes: 0 additions & 23 deletions scripts/exec-sync.js

This file was deleted.

53 changes: 0 additions & 53 deletions scripts/exec.js

This file was deleted.

6 changes: 4 additions & 2 deletions scripts/lint-staged/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const { promisify } = require('util');
const child_process = require('child_process');
const { rollup: lernaAliases } = require('lerna-alias');
const { default: PQueue } = require('p-queue');
const exec = require('../exec');
const exec = promisify(child_process.exec);

const eslintForPackageScript = path.join(__dirname, 'eslint-for-package.js');

Expand Down Expand Up @@ -60,7 +62,7 @@ async function runEslintOnFilesGroupedPerPackage() {
Object.entries(filesGroupedByPackage).map(([packagePath, files]) => async () => {
// This script handles running eslint on ONLY the appropriate files for each package.
// See its comments for more details.
return exec(`node ${eslintForPackageScript} ${files.join(' ')}`, undefined, packagePath, process).catch(() => {
return exec(`node ${eslintForPackageScript} ${files.join(' ')}`, { cwd: packagePath }).catch(() => {
// The subprocess should already have handled logging. Just mark that there was an error.
hasError = true;
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/local-codepen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const WebpackDevServer = require('webpack-dev-server');
const path = require('path');
const fs = require('fs');
const yargs = require('yargs');
const execSync = require('./exec-sync');
const { execSync } = require('child_process');
const { findGitRoot } = require('./monorepo/index');
const chalk = require('chalk');

Expand All @@ -19,7 +19,7 @@ if (fs.existsSync(configPath)) {
try {
console.log("Attempting to npm link globally installed ngrok so it can be require'd");
// This will probably install ngrok globally if it's not already present
execSync('npm link ngrok@3', undefined, gitRoot);
execSync('npm link ngrok@3', { cwd: gitRoot, stdio: 'inherit' });
// @ts-expect-error - no types for ngrok
ngrok = require('ngrok');
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasks/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { webpackCliTask, argv, logger } from 'just-scripts';
import * as path from 'path';
import * as fs from 'fs';
import execSync from '../exec-sync';
import { execSync } from 'child_process';
import { getJustArgv } from './argv';

export function webpack() {
Expand Down Expand Up @@ -48,7 +48,7 @@ export function webpackDevServer(

process.env.cached = String(args.cached);

execSync(cmd);
execSync(cmd, { stdio: 'inherit' });
}
};
}
23 changes: 13 additions & 10 deletions scripts/token-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import path from 'path';
import * as fs from 'fs-extra';
import * as _ from 'lodash';
import * as yargs from 'yargs';
import { execSync } from 'child_process';

import { findGitRoot } from './monorepo';
import execSync from './exec-sync';
import { createTempDir } from './projects-test';

const themes = ['light', 'dark', 'teamsDark', 'highContrast'] as const;
Expand Down Expand Up @@ -34,6 +34,8 @@ function getGeneratedFiles(tmpDir: string) {
function runPipeline(theme: typeof themes[number], pipelineDir: string, outDir: string) {
console.log(`Running pipeline for ${theme} theme`);

console.log(`Generate tokens for theme`);

// https://github.com/microsoft/fluentui-token-pipeline
execSync(
[
Expand All @@ -44,8 +46,7 @@ function runPipeline(theme: typeof themes[number], pipelineDir: string, outDir:
`--in src/${_.kebabCase(theme)}.json`,
`--out ${outDir}/${theme}`,
].join(' '),
`Generate tokens for theme:${theme}`,
pipelineDir,
{ cwd: pipelineDir },
);
}

Expand All @@ -59,14 +60,15 @@ function setupDesignTokensRepo(options: { argv: typeof argv }) {
return { pipelineDir, tmpDir };
}

console.log('Clone design tokens repo');
// clone repo, install deps
execSync(
'git clone --depth 1 https://github.com/microsoft/fluentui-design-tokens.git',
'Clone design tokens repo',
tmpDir,
);
execSync('git clone --depth 1 https://github.com/microsoft/fluentui-design-tokens.git', {
cwd: tmpDir,
stdio: 'inherit',
});
const pipelineDir = path.join(tmpDir, 'fluentui-design-tokens');
execSync('npm install', 'Install dependencies', pipelineDir);
console.log('Install dependencies');
execSync('npm install', { cwd: pipelineDir, stdio: 'inherit' });

return { pipelineDir, tmpDir };
}
Expand All @@ -83,7 +85,8 @@ const tokenPipeline = () => {
fs.copySync(file.src, file.dest, { overwrite: true });
});

execSync(`npx prettier --write ${path.join(repoRoot, 'packages/react-components/react-theme/src')}`, 'Prettier');
console.log('Format');
execSync(`npx prettier --write ${path.join(repoRoot, 'packages/react-components/react-theme/src')}`);
};

tokenPipeline();