Skip to content

Commit

Permalink
feat(scripts): enable strict checking for additional sub-folders(pack…
Browse files Browse the repository at this point in the history
…ages) (#24526)

* chore: move packages to single version policy from scripts

* feat(scripts): enable strict checking for dangerjs

* feat(scripts): enable strict checking for fluentui-publish

* feat(scripts): enable strict checking for github

* feat(scripts): enable strict checking for gulp

* feat(scripts): enable strict checking for prettier

* feat(scripts): enable strict checking for projects-test

* feat(scripts): enable strict checking for puppeteer

* feat(scripts): enable strict checking for updateReleaseNotes

* feat(scripts): improve PackageJson interface

* more scripts ts solution config registration

* chore(scripts): rename updateReleaseNotes to package valid casing

* feat(typings): add json-stable-stringify-without-jsonify declarations

* chore: move packages to single version policy from scripts and add types

* fix(eslint-plugin): properly resolve single-version policy dep issues in react-northstar packages

* generate changefiles

* fix(typings): make ignore-not-found-export-webpack-plugi types valid
  • Loading branch information
Hotell authored Sep 26, 2022
1 parent 9b4a6b4 commit f020ac1
Show file tree
Hide file tree
Showing 69 changed files with 508 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"protocol": "inspector",
"cwd": "${workspaceRoot}",
"args": [
"${workspaceRoot}/scripts/updateReleaseNotes/index.ts",
"${workspaceRoot}/scripts/update-release-notes/index.ts",
"--token",
// For local testing, generate a personal access token (https://github.com/settings/tokens)
// and replace "your token here" with the token. DO NOT COMMIT YOUR TOKEN!
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.release-vnext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
# TODO update release notes script for v9
# - script: |
# node -r ./scripts/ts-node-register ./scripts/updateReleaseNotes/index.ts --token=$(githubPAT) --apply --debug
# node -r ./scripts/ts-node-register ./scripts/update-release-notes/index.ts --token=$(githubPAT) --apply --debug
# displayName: 'Update github release notes'

# This would usually be run automatically (via a pipeline decorator from an extension), but the
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
# Run this near the end because it's more likely to fail than the artifact upload tasks, and its
# failure doesn't need to block anything else
- script: |
node -r ./scripts/ts-node-register ./scripts/updateReleaseNotes/index.ts --token=$(githubPAT) --apply --debug
node -r ./scripts/ts-node-register ./scripts/update-release-notes/index.ts --token=$(githubPAT) --apply --debug
displayName: 'Update github release notes'
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix(eslint-plugin): properly resolve single-version policy dep issues in react-northstar packages",
"packageName": "@fluentui/eslint-plugin",
"email": "martinhochel@microsoft.com",
"dependentChangeType": "none"
}
27 changes: 26 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
"@testing-library/user-event": "13.5.0",
"@tsconfig/node14": "1.0.3",
"@types/babel__helper-plugin-utils": "7.10.0",
"@types/chrome-remote-interface": "0.30.0",
"@types/circular-dependency-plugin": "5.0.5",
"@types/copy-webpack-plugin": "6.4.0",
"@types/dedent": "0.7.0",
"@types/doctrine": "0.0.5",
Expand All @@ -130,23 +132,33 @@
"@types/express": "4.17.2",
"@types/fs-extra": "8.0.1",
"@types/glob": "7.1.1",
"@types/gulp": "4.0.9",
"@types/gulp-babel": "6.1.30",
"@types/gulp-cache": "0.4.5",
"@types/gulp-remember": "0.0.31",
"@types/gulp-sourcemaps": "0.0.35",
"@types/gulp-util": "3.0.36",
"@types/jest": "26.0.24",
"@types/jest-axe": "3.5.3",
"@types/jju": "1.4.1",
"@types/json-schema": "^7.0.8",
"@types/loader-utils": "2.0.3",
"@types/markdown-table": "2.0.0",
"@types/node": "10.17.55",
"@types/node-fetch": "2.5.7",
"@types/prettier": "2.2.3",
"@types/progress": "2.0.5",
"@types/react": "17.0.44",
"@types/react-dom": "17.0.15",
"@types/react-is": "17.0.3",
"@types/react-test-renderer": "17.0.2",
"@types/request-promise-native": "1.0.18",
"@types/scheduler": "0.16.2",
"@types/semver": "^6.2.0",
"@types/tmp": "0.2.0",
"@types/webpack-dev-middleware": "4.1.0",
"@types/webpack-env": "1.16.0",
"@types/webpack-hot-middleware": "2.25.6",
"@types/yargs": "13.0.11",
"@types/yargs-unparser": "2.0.1",
"@typescript-eslint/eslint-plugin": "4.22.0",
Expand All @@ -161,8 +173,10 @@
"babel-plugin-tester": "10.1.0",
"beachball": "2.31.0",
"chalk": "4.1.0",
"chrome-remote-interface": "0.28.2",
"chromedriver": "104.0.0",
"ci-info": "3.2.0",
"circular-dependency-plugin": "5.2.2",
"clean-webpack-plugin": "4.0.0",
"cli-table3": "0.6.1",
"copy-webpack-plugin": "8.1.0",
Expand Down Expand Up @@ -193,12 +207,18 @@
"eslint-plugin-react": "7.26.0",
"eslint-plugin-react-hooks": "4.2.0",
"express": "4.17.1",
"extract-comments": "1.1.0",
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "6.1.0",
"fs-extra": "8.1.0",
"geckodriver": "3.0.2",
"glob": "7.2.0",
"gulp": "^4.0.2",
"gulp": "4.0.2",
"gulp-babel": "8.0.0",
"gulp-cache": "1.1.3",
"gulp-remember": "1.0.1",
"gulp-sourcemaps": "2.6.5",
"gulp-util": "3.0.8",
"gzip-size": "6.0.0",
"html-webpack-plugin": "5.1.0",
"ignore-not-found-export-webpack-plugin": "1.0.2",
Expand All @@ -212,11 +232,13 @@
"jest-watch-typeahead": "0.6.5",
"jju": "1.4.0",
"json-schema": "0.4.0",
"json-stable-stringify-without-jsonify": "1.0.1",
"just-scripts": "1.8.2",
"lage": "1.7.4",
"lerna": "^3.21.0",
"lint-staged": "10.2.10",
"loader-utils": "2.0.0",
"markdown-table": "2.0.0",
"memfs": "3.2.2",
"mini-css-extract-plugin": "2.6.1",
"node-fetch": "2.6.7",
Expand All @@ -227,13 +249,15 @@
"postcss-modules": "4.1.3",
"prettier": "2.2.1",
"pretty-bytes": "5.6.0",
"progress": "2.0.3",
"puppeteer": "14.4.0",
"raw-loader": "4.0.2",
"react": "17.0.2",
"react-app-polyfill": "2.0.0",
"react-dom": "17.0.2",
"react-is": "17.0.2",
"react-test-renderer": "17.0.2",
"request-promise-native": "1.0.9",
"sass": "1.49.11",
"sass-loader": "12.4.0",
"satisfied": "^1.1.1",
Expand All @@ -250,6 +274,7 @@
"tachometer": "0.7.0",
"terser": "5.14.2",
"terser-webpack-plugin": "5.3.1",
"through2": "4.0.2",
"tmp": "0.2.1",
"ts-jest": "26.5.6",
"ts-loader": "9.3.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/eslint-plugin/src/configs/react-northstar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { findGitRoot } = require('../utils/configHelpers');

const workspaceRoot = findGitRoot();

module.exports = {
extends: [
'airbnb',
Expand All @@ -23,7 +27,10 @@ module.exports = {
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*-test.ts*', '**/*.test.ts*', '*.config.js', 'gulpfile.ts', 'just.config.ts'] },
{
packageDir: ['.', workspaceRoot],
devDependencies: ['**/*-test.ts*', '**/*.test.ts*', '*.config.js', 'gulpfile.ts', 'just.config.ts'],
},
],

// False positive on arg types:
Expand Down
2 changes: 0 additions & 2 deletions packages/fluentui/accessibility/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/scripts": "^1.0.0",
"@types/gulp": "^4.0.6",
"gulp": "^4.0.2",
"lerna-alias": "^3.0.3-0"
},
"files": [
Expand Down
3 changes: 1 addition & 2 deletions packages/fluentui/circulars-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"@fluentui/react-northstar": "^0.64.0"
},
"devDependencies": {
"@fluentui/scripts": "^1.0.0",
"gulp": "^4.0.2"
"@fluentui/scripts": "^1.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 1 addition & 3 deletions packages/fluentui/docs-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/scripts": "^1.0.0",
"@types/gulp": "^4.0.6",
"gulp": "^4.0.2"
"@fluentui/scripts": "^1.0.0"
},
"files": [
"dist"
Expand Down
4 changes: 1 addition & 3 deletions packages/fluentui/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@
"@types/classnames": "^2.2.9",
"@types/color": "^3.0.0",
"@types/faker": "^4.1.3",
"@types/gulp": "^4.0.6",
"@types/react-custom-scrollbars": "^4.0.5",
"@types/react-router-dom": "^5.1.5",
"@types/react-virtualized": "^9.21.8",
"@types/react-window": "^1.8.2",
"gulp": "^4.0.2"
"@types/react-window": "^1.8.2"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions packages/fluentui/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/scripts": "^1.0.0",
"gulp": "^4.0.2"
"@fluentui/scripts": "^1.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions packages/fluentui/react-northstar-prototypes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"@types/faker": "^4.1.3",
"@types/react-custom-scrollbars": "^4.0.5",
"@types/react-virtualized": "^9.21.8",
"@types/react-window": "^1.8.2",
"gulp": "^4.0.2"
"@types/react-window": "^1.8.2"
},
"files": [
"dist"
Expand Down
2 changes: 0 additions & 2 deletions packages/fluentui/react-northstar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
"@fluentui/scripts": "^1.0.0",
"@types/classnames": "^2.2.9",
"@types/faker": "^4.1.3",
"@types/gulp": "^4.0.6",
"@types/simulant": "^0.2.0",
"csstype": "^3.0.2",
"faker": "^4.1.0",
"fela-tools": "^10.6.1",
"gulp": "^4.0.2",
"lerna-alias": "^3.0.3-0",
"qs": "^6.8.0",
"simulant": "^0.2.2"
Expand Down
11 changes: 6 additions & 5 deletions scripts/dangerjs/checkChangelog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { AddChange } from 'parse-diff';
import * as fs from 'fs';

import config from '../config';
import { DangerJS, StructuredDiff } from './types';
import { DangerJS } from './types';
import { DangerDSLType } from 'danger';

const CHANGELOG_FILE = 'packages/fluentui/CHANGELOG.md';
Expand Down Expand Up @@ -29,11 +30,11 @@ const getMalformedChangelogEntries = async (danger: DangerDSLType): Promise<stri
return addedLines.map(line => line.content).filter(content => content.startsWith('+-') && !validEntry.test(content));
};

const getAddedLinesFromChangelog = async (danger: DangerDSLType): Promise<{ content: string; ln: number }[]> => {
return danger.git.structuredDiffForFile(CHANGELOG_FILE).then((changelogDiff: StructuredDiff) => {
const getAddedLinesFromChangelog = async (danger: DangerDSLType): Promise<[] | AddChange[]> => {
return danger.git.structuredDiffForFile(CHANGELOG_FILE).then(changelogDiff => {
if (changelogDiff) {
return changelogDiff.chunks.reduce((acc, chunk) => {
const filteredLines = chunk.changes.filter(change => change.type === 'add');
return changelogDiff.chunks.reduce<AddChange[]>((acc, chunk) => {
const filteredLines = chunk.changes.filter(change => change.type === 'add') as AddChange[];
return acc.concat(filteredLines);
}, []);
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/dangerjs/checkStorybookVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export async function checkStorybookVersions({ danger, fail }: DangerJS) {
const rootPackageJson: PackageJson = fs.readJSONSync(config.paths.base(packageJsonFilename));
const webComponentsPackageJson: PackageJson = fs.readJSONSync(config.paths.base(webComponentsPackageJsonFilename));

const storybookReactVersion = rootPackageJson.devDependencies['@storybook/react'];
const storybookHtmlVersion = webComponentsPackageJson.devDependencies['@storybook/html'];
const storybookReactVersion = rootPackageJson.devDependencies?.['@storybook/react'];
const storybookHtmlVersion = webComponentsPackageJson.devDependencies?.['@storybook/html'];

if (!storybookHtmlVersion || rootPackageJson.devDependencies['@storybook/html']) {
if (!storybookHtmlVersion || rootPackageJson.devDependencies?.['@storybook/html']) {
// PLEASE READ THE FUNCTION COMMENT BEFORE MODIFYING OR REMOVING THIS CHECK!!!
fail(
`\`@storybook/html\` dependency must be specified in ONLY in \`${webComponentsPackageJsonFilename}\`, ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ const getRuntimeDependencies = (packageName: string) => {
throw new Error(error);
}

return output
return (output
.split('\n')
.map(line => line.match(dependencyRegex))
.filter(Boolean)
.map(match => match[1]);
.filter(Boolean) as RegExpMatchArray[]).map(match => match[1]);
};

export default getRuntimeDependencies;
7 changes: 7 additions & 0 deletions scripts/dangerjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.scripts.json",
"compilerOptions": {
"types": ["node"]
},
"include": ["**/*.ts"]
}
17 changes: 10 additions & 7 deletions scripts/fluentui-publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as path from 'path';
import * as fs from 'fs';
import { argv } from 'yargs';

import { findGitRoot } from '../monorepo/index';
import { findGitRoot, PackageJson } from '../monorepo';

export function fluentuiLernaPublish(bumpType, skipConfirm = false, npmTagForCanary = 'beta') {
function fluentuiLernaPublish(bumpType: 'patch' | 'minor' | 'canary', skipConfirm = false, npmTagForCanary = 'beta') {
const gitRoot = findGitRoot();
const fluentRoot = path.resolve(gitRoot, 'packages', 'fluentui');

Expand Down Expand Up @@ -91,7 +91,7 @@ const execCommandSync = (cwd: string, command: string, args: string[]) => {
return result.stdout;
};

export function fluentuiPostPublishValidation() {
function fluentuiPostPublishValidation() {
const gitRoot = findGitRoot();

const branch = execCommandSync(gitRoot, 'git', ['branch', '--show-current']);
Expand All @@ -112,19 +112,19 @@ export function fluentuiPostPublishValidation() {
}

// pack all public fluent ui packages, used by ci to store nightly built artifacts
export function packFluentTarballs() {
function packFluentTarballs() {
const gitRoot = findGitRoot();
const fluentRoot = path.resolve(findGitRoot(), 'packages', 'fluentui');

const TODAY = new Date().toISOString().split('T')[0]; // yyyy-mm-dd

const fluentPackages = JSON.parse(
const fluentPackages: Array<{ name: string; private?: boolean; location: string }> = JSON.parse(
execCommandSync(fluentRoot, '../../node_modules/.bin/lerna', ['ls', '--json']).toString(),
);
const fluentPackagesNames = fluentPackages.map(pkg => pkg.name);

const replaceDepVersionWithNightlyUrl = packageLocation => {
const packageJson = require(`${packageLocation}/package.json`);
const replaceDepVersionWithNightlyUrl = (packageLocation: string) => {
const packageJson: PackageJson = require(`${packageLocation}/package.json`);
packageJson.version = `0.0.0-nightly+${TODAY}`;
const dependencies = packageJson.dependencies || {};

Expand Down Expand Up @@ -161,6 +161,9 @@ export function packFluentTarballs() {
execCommandSync(gitRoot, 'git', ['checkout', '-f']);
}

/**
* publish CLI for @fluentui/react-northstar
*/
function run() {
const task = argv._[0];
const skipConfirm = !!argv['yes'];
Expand Down
7 changes: 7 additions & 0 deletions scripts/fluentui-publish/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.scripts.json",
"compilerOptions": {
"types": ["node"]
},
"include": ["**/*.ts"]
}
2 changes: 1 addition & 1 deletion scripts/github/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IRepoDetails } from './types';
import type { IRepoDetails } from './types';

export const fluentRepoDetails: IRepoDetails = {
owner: 'microsoft',
Expand Down
4 changes: 2 additions & 2 deletions scripts/github/pullRequests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Octokit } from '@octokit/rest';
import { IPullRequest, IRepoDetails } from './types';
import type { Octokit } from '@octokit/rest';
import type { IPullRequest, IRepoDetails } from './types';

export interface IGetPullRequestFromCommitParams {
github: Octokit;
Expand Down
7 changes: 7 additions & 0 deletions scripts/github/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.scripts.json",
"compilerOptions": {
"types": ["node"]
},
"include": ["**/*.ts"]
}
Loading

0 comments on commit f020ac1

Please sign in to comment.