From d5252c13d9cde65be168d8d8177b4ced9c59b1fb Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Mon, 24 May 2021 14:51:34 -0700 Subject: [PATCH 01/10] Add dependency finder package --- client/lib/plans/features-list.js | 2 +- package-map.json | 90 +++++ packages/dependency-finder/.eslintrc.cjs | 10 + packages/dependency-finder/package.json | 32 ++ packages/dependency-finder/src/index.ts | 88 +++++ .../src/lib/entrypoints/additional.ts | 12 + .../src/lib/entrypoints/jest.ts | 23 ++ .../src/lib/entrypoints/packagejson.ts | 30 ++ .../src/lib/find-dependencies.ts | 104 +++++ .../dependency-finder/src/lib/find-missing.ts | 53 +++ packages/dependency-finder/tsconfig.json | 37 ++ yarn.lock | 371 ++++++++++++++++-- 12 files changed, 816 insertions(+), 36 deletions(-) create mode 100644 package-map.json create mode 100644 packages/dependency-finder/.eslintrc.cjs create mode 100644 packages/dependency-finder/package.json create mode 100644 packages/dependency-finder/src/index.ts create mode 100644 packages/dependency-finder/src/lib/entrypoints/additional.ts create mode 100644 packages/dependency-finder/src/lib/entrypoints/jest.ts create mode 100644 packages/dependency-finder/src/lib/entrypoints/packagejson.ts create mode 100644 packages/dependency-finder/src/lib/find-dependencies.ts create mode 100644 packages/dependency-finder/src/lib/find-missing.ts create mode 100644 packages/dependency-finder/tsconfig.json diff --git a/client/lib/plans/features-list.js b/client/lib/plans/features-list.js index dbb8ae4f332db..1316fb431a925 100644 --- a/client/lib/plans/features-list.js +++ b/client/lib/plans/features-list.js @@ -42,7 +42,7 @@ import { FEATURE_BLANK, FEATURE_BLOG_DOMAIN, FEATURE_BUSINESS_ONBOARDING, - FEATURE_CLOUDFLARE_ANALYTICS, + FEATURE_CLOUDFLARE_ANALYTICS, FEATURE_COLLECT_PAYMENTS_V2, FEATURE_COMMUNITY_SUPPORT, FEATURE_CRM_LEADS_AND_FUNNEL, diff --git a/package-map.json b/package-map.json new file mode 100644 index 0000000000000..5ceb52e528b4d --- /dev/null +++ b/package-map.json @@ -0,0 +1,90 @@ +[ + { "path": "packages/accessible-focus" }, + { "path": "packages/accessible-focus" }, + { "path": "packages/babel-plugin-i18n-calypso" }, + { "path": "packages/babel-plugin-transform-wpcalypso-async" }, + { "path": "packages/browser-data-collector" }, + { "path": "packages/calypso-analytics" }, + { "path": "packages/calypso-build" }, + { "path": "packages/calypso-codemods" }, + { "path": "packages/calypso-color-schemes" }, + { "path": "packages/calypso-config" }, + { "path": "packages/calypso-doctor" }, + { "path": "packages/calypso-polyfills" }, + { "path": "packages/calypso-stripe" }, + { "path": "packages/components" }, + { "path": "packages/composite-checkout" }, + { "path": "packages/create-calypso-config" }, + { "path": "packages/data-stores" }, + { "path": "packages/dependency-finder" }, + { "path": "packages/domain-picker" }, + { "path": "packages/effective-module-tree" }, + { "path": "packages/eslint-plugin-wpcalypso" }, + { "path": "packages/explat-client-react-helpers" }, + { "path": "packages/explat-client" }, + { "path": "packages/format-currency" }, + { "path": "packages/i18n-calypso-cli" }, + { "path": "packages/i18n-calypso" }, + { "path": "packages/i18n-utils" }, + { "path": "packages/js-utils" }, + { "path": "packages/language-picker" }, + { "path": "packages/languages" }, + { "path": "packages/launch" }, + { "path": "packages/load-script" }, + { "path": "packages/material-design-icons" }, + { "path": "packages/onboarding" }, + { "path": "packages/page-pattern-modal" }, + { "path": "packages/photon" }, + { "path": "packages/plans-grid" }, + { "path": "packages/popup-monitor" }, + { "path": "packages/request-external-access" }, + { "path": "packages/retarget-open-prs" }, + { "path": "packages/search" }, + { "path": "packages/shopping-cart" }, + { "path": "packages/social-previews" }, + { "path": "packages/spec-junit-reporter" }, + { "path": "packages/spec-xunit-reporter" }, + { "path": "packages/state-utils" }, + { "path": "packages/tree-select" }, + { "path": "packages/typography" }, + { "path": "packages/viewport-react" }, + { "path": "packages/viewport" }, + { "path": "packages/webpack-config-flag-plugin" }, + { "path": "packages/webpack-extensive-lodash-replacement-plugin" }, + { "path": "packages/webpack-inline-constant-exports-plugin" }, + { "path": "packages/webpack-rtl-plugin" }, + { "path": "packages/whats-new" }, + { "path": "packages/wp-babel-makepot" }, + { "path": "packages/wpcom-checkout" }, + { "path": "packages/wpcom-proxy-request" }, + { "path": "packages/wpcom.js" }, + { + "path": "apps/editing-toolkit", + "additionalEntryPoints": [ + "apps/editing-toolkit/editing-toolkit-plugin/block-inserter-modifications/contextual-tips.js", + "apps/editing-toolkit/editing-toolkit-plugin/block-patterns/index.ts", + "apps/editing-toolkit/editing-toolkit-plugin/common/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/common/data-stores/index.ts", + "apps/editing-toolkit/editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js", + "apps/editing-toolkit/editing-toolkit-plugin/dotcom-fse/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/editor-site-launch/focused-launch.ts", + "apps/editing-toolkit/editing-toolkit-plugin/editor-site-launch/gutenboarding-launch.ts", + "apps/editing-toolkit/editing-toolkit-plugin/editor-site-launch/launch-button.ts", + "apps/editing-toolkit/editing-toolkit-plugin/event-countdown-block/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/global-styles/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/jetpack-timeline/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/newspack-blocks/blog-posts-block-editor.js", + "apps/editing-toolkit/editing-toolkit-plugin/newspack-blocks/blog-posts-block-view.js", + "apps/editing-toolkit/editing-toolkit-plugin/newspack-blocks/carousel-block-editor.js", + "apps/editing-toolkit/editing-toolkit-plugin/newspack-blocks/carousel-block-view.js", + "apps/editing-toolkit/editing-toolkit-plugin/posts-list-block.js", + "apps/editing-toolkit/editing-toolkit-plugin/starter-page-templates/index.tsx", + "apps/editing-toolkit/editing-toolkit-plugin/whats-new/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/wpcom-block-editor-nav-sidebar/index.ts", + "apps/editing-toolkit/editing-toolkit-plugin/wpcom-block-editor-nux/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/error-reporting/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/posts-list-block/index.js", + "apps/editing-toolkit/editing-toolkit-plugin/**/*.php" + ] + } +] diff --git a/packages/dependency-finder/.eslintrc.cjs b/packages/dependency-finder/.eslintrc.cjs new file mode 100644 index 0000000000000..338ea4d437be0 --- /dev/null +++ b/packages/dependency-finder/.eslintrc.cjs @@ -0,0 +1,10 @@ +module.exports = { + env: { + node: true, + }, + rules: { + // This is a node.js project, it is ok to import node modules + 'import/no-nodejs-modules': 'off', + 'no-console': 'off', + }, +}; diff --git a/packages/dependency-finder/package.json b/packages/dependency-finder/package.json new file mode 100644 index 0000000000000..437229923c349 --- /dev/null +++ b/packages/dependency-finder/package.json @@ -0,0 +1,32 @@ +{ + "name": "@automattic/dependency-finder", + "version": "0.1.0", + "description": "Generate the list of dependencies of a set of files, recursively", + "main": "index.ts", + "author": "Automattic Inc.", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/Automattic/wp-calypso.git", + "directory": "packages/dependency-finder" + }, + "keywords": [ + "dependencies", + "node_modules" + ], + "license": "GPL-2.0-or-later", + "dependencies": { + "dependency-tree": "^8.1.0", + "globby": "^11.0.3", + "jest-config": "^26.6.3", + "read-pkg": "^6.0.0", + "read-pkg-up": "^8.0.0", + "tslib": "^2.2.0" + }, + "scripts": { + "clean": "tsc --build ./tsconfig.json --clean && npx rimraf dist", + "build": "tsc --build ./tsconfig.json", + "prepack": "yarn run clean && yarn run build", + "watch": "tsc --build ./tsconfig.json --watch" + } +} diff --git a/packages/dependency-finder/src/index.ts b/packages/dependency-finder/src/index.ts new file mode 100644 index 0000000000000..1af5a4443619b --- /dev/null +++ b/packages/dependency-finder/src/index.ts @@ -0,0 +1,88 @@ +/** + * External dependencies + */ +import path from 'path'; +import fs from 'fs'; +import { fileURLToPath } from 'url'; +import childProcess from 'child_process'; +import { promisify } from 'util'; + +const exec = promisify( childProcess.exec ); + +/** + * Internal dependencies + */ +import { findDependencies } from './lib/find-dependencies.js'; + +const packageMapPath = path.join( + path.dirname( fileURLToPath( import.meta.url ) ), + '../../../../package-map.json' +); + +type PackageMapEntry = { + path: string; + additionalEntryPoints: Array< string > | undefined; +}; +type PackageMap = Array< PackageMapEntry >; +const packageMap: PackageMap = JSON.parse( fs.readFileSync( packageMapPath, 'utf8' ) ); + +function getMonorepoPackages() { + const packages = fs.readdirSync( 'packages', { withFileTypes: true } ); + return packages + .filter( ( entry ) => entry.isDirectory() ) + .map( ( entry ) => path.resolve( 'packages', entry.name ) ); +} +const monorepoPackages = getMonorepoPackages(); + +const findPackageDependencies = async ( { + path: pkgPath, + additionalEntryPoints, +}: PackageMapEntry ) => { + const absolutePkgPath = path.resolve( pkgPath ); + + const { missing, packages, modules } = await findDependencies( { + pkg: absolutePkgPath, + additionalEntryPoints, + monorepoPackages, + } ); + const { stdout } = await exec( + `find ${ absolutePkgPath } -type f -not \\( -path '*/node_modules/*' -o -path '*/.cache/*' -o -path '*/dist/*' \\)` + ); + const allFiles = stdout.trim().split( '\n' ); + + // Files which exist in the filesystem, but the dep finder did not parse. + // We exclude files which do not impact builds, such as ".txt" or ".md" files. + const unknownFiles = allFiles.filter( + ( file ) => ! modules.includes( file ) && ! [ '.md', '.txt' ].includes( path.extname( file ) ) + ); + + console.log( 'Package:' ); + console.log( ' ' + pkgPath ); + console.log( 'Missing files:' ); + console.log( missing.length ? missing.map( ( m ) => ' ' + m ).join( '\n' ) : ' -' ); + console.log( 'Packages:' ); + console.log( packages.length ? packages.map( ( m ) => ' ' + m ).join( '\n' ) : ' -' ); + console.log( 'Found files:' ); + console.log( modules.length ? modules.map( ( m ) => ' ' + m ).join( '\n' ) : ' -' ); + console.log( 'Unkown files:' ); + console.log( unknownFiles.length ? unknownFiles.map( ( m ) => ' ' + m ).join( '\n' ) : ' -' ); + console.log(); + console.log(); +}; + +const main = async () => { + const packageToParse = process.argv.slice( 2 )[ 0 ]; + // Allow parsing a single package. + if ( packageToParse ) { + const packageEntry = packageMap.find( ( { path } ) => path === packageToParse ); + if ( packageEntry ) { + findPackageDependencies( packageEntry ); + } + } else { + for ( const packageEntry of packageMap ) { + await findPackageDependencies( packageEntry ); + } + } +}; + +main().catch( console.error ); diff --git a/packages/dependency-finder/src/lib/entrypoints/additional.ts b/packages/dependency-finder/src/lib/entrypoints/additional.ts new file mode 100644 index 0000000000000..c9a0fa922d8f0 --- /dev/null +++ b/packages/dependency-finder/src/lib/entrypoints/additional.ts @@ -0,0 +1,12 @@ +/** + * External dependencies + */ +import globby from 'globby'; + +export const findAdditionalEntryPoints = async ( + additionalEntryPoints: string[] +): Promise< string[] > => { + return ( + await Promise.all( additionalEntryPoints.map( ( pattern ) => globby( pattern ) ) ) + ).flat(); +}; diff --git a/packages/dependency-finder/src/lib/entrypoints/jest.ts b/packages/dependency-finder/src/lib/entrypoints/jest.ts new file mode 100644 index 0000000000000..2489f9c164166 --- /dev/null +++ b/packages/dependency-finder/src/lib/entrypoints/jest.ts @@ -0,0 +1,23 @@ +/** + * External dependencies + */ +import path from 'path'; +import jestConfig from 'jest-config'; +import globby from 'globby'; + +export const findJestEntrypoints = async ( { + jestConfigPath, +}: { + jestConfigPath: string; +} ): Promise< string[] > => { + const config = await jestConfig.readConfig( + { + config: jestConfigPath, + _: [ '' ], + $0: '', + }, + path.dirname( jestConfigPath ) + ); + const tests = await globby( config.projectConfig.testMatch ); + return tests; +}; diff --git a/packages/dependency-finder/src/lib/entrypoints/packagejson.ts b/packages/dependency-finder/src/lib/entrypoints/packagejson.ts new file mode 100644 index 0000000000000..0bdc32043972d --- /dev/null +++ b/packages/dependency-finder/src/lib/entrypoints/packagejson.ts @@ -0,0 +1,30 @@ +/** + * External dependencies + */ +import { readPackageAsync } from 'read-pkg'; +import path from 'path'; +import fs from 'fs'; + +export const findPackageJsonEntrypoints = async ( { + pkgPath, +}: { + pkgPath: string; +} ): Promise< string[] > => { + const pkgJson = await readPackageAsync( { cwd: pkgPath } ); + + const main = pkgJson[ 'calypso:src' ] ?? pkgJson.main ?? 'index.js'; + const bin = pkgJson.bin ?? {}; + + const files = [ main, ...Object.values( bin ) ] + .filter( Boolean ) + .map( ( file ) => path.resolve( pkgPath, file ) ) + .filter( ( file ) => { + try { + fs.accessSync( file ); + return true; + } catch { + return false; + } + } ); + return files; +}; diff --git a/packages/dependency-finder/src/lib/find-dependencies.ts b/packages/dependency-finder/src/lib/find-dependencies.ts new file mode 100644 index 0000000000000..8884e9601e068 --- /dev/null +++ b/packages/dependency-finder/src/lib/find-dependencies.ts @@ -0,0 +1,104 @@ +/** + * External dependencies + */ +import dependencyTree from 'dependency-tree'; +import { readPackageUpSync } from 'read-pkg-up'; +import type { NormalizedReadResult } from 'read-pkg-up'; +import type { Tree } from 'dependency-tree'; +import path from 'path'; +import fs from 'fs'; + +import { findPackageJsonEntrypoints } from './entrypoints/packagejson.js'; +import { findJestEntrypoints } from './entrypoints/jest.js'; +import { findAdditionalEntryPoints } from './entrypoints/additional.js'; +import { findMissingPackages } from './find-missing.js'; + +export const findDependencies = async ( { + pkg, + monorepoPackages, + additionalEntryPoints = [], +}: { + pkg: string; + monorepoPackages: string[]; + additionalEntryPoints?: string[]; +} ): Promise< { + missing: string[]; + packages: string[]; + modules: string[]; +} > => { + let missing: string[] = []; + const visited: Tree = {}; + const packages: Set< string > = new Set(); + const modules: Set< string > = new Set(); + + const pkgJsonPath = path.resolve( pkg, 'package.json' ); + const entrypoints = await findPackageJsonEntrypoints( { pkgPath: pkg } ); + modules.add( pkgJsonPath ); + + const jestTests = await ( async () => { + try { + const jestConfigPath = path.join( pkg, 'jest.config.js' ); + fs.accessSync( jestConfigPath ); + modules.add( jestConfigPath ); + return findJestEntrypoints( { jestConfigPath } ); + } catch { + return []; + } + } )(); + + const tsConfig = ( () => { + try { + const tsConfigPath = path.join( pkg, 'tsconfig.json' ); + fs.accessSync( tsConfigPath ); + modules.add( tsConfigPath ); + return tsConfigPath; + } catch { + return null; + } + } )(); + + const absoluteAdditionalEntryPoints = await findAdditionalEntryPoints( additionalEntryPoints ); + + // Handles monorepo and npm results from parsed files. + const fileFilter = ( path: string ) => { + const isMonorepo = monorepoPackages.some( + ( monorepoPackage ) => ! path.startsWith( pkg ) && path.startsWith( monorepoPackage ) + ); + const isNodeModules = path.includes( 'node_modules' ); + + if ( isMonorepo || isNodeModules ) { + const { version, name } = ( readPackageUpSync( { + cwd: path, + } ) as NormalizedReadResult ).packageJson; + packages.add( `${ name }@${ version }` ); + return false; + } + + return true; + }; + + for ( const entrypoint of [ ...entrypoints, ...jestTests, ...absoluteAdditionalEntryPoints ] ) { + const tree = dependencyTree.toList( { + filename: entrypoint, + directory: path.dirname( entrypoint ), + tsConfig: tsConfig ?? undefined, + visited, + filter: fileFilter, + nonExistent: missing, + } ); + tree.forEach( ( module ) => modules.add( module ) ); + } + + // Handle missing files which do exist, but are weird enough for dependencyTree to miss. + const { foundPackages, resolvedFiles } = findMissingPackages( missing ); + resolvedFiles.forEach( fileFilter ); + missing = missing.filter( + ( missingModule ) => ! foundPackages.some( ( foundModule ) => foundModule === missingModule ) + ); + + return { + missing, + packages: Array.from( packages ).sort(), + modules: Array.from( modules ).sort(), + }; +}; diff --git a/packages/dependency-finder/src/lib/find-missing.ts b/packages/dependency-finder/src/lib/find-missing.ts new file mode 100644 index 0000000000000..f4a3fc6591a62 --- /dev/null +++ b/packages/dependency-finder/src/lib/find-missing.ts @@ -0,0 +1,53 @@ +/** + * External dependencies + */ +import { resolve, basename, dirname } from 'path'; +import { existsSync } from 'fs'; + +type FoundPackages = { + foundPackages: Array< string >; + resolvedFiles: Array< string >; +}; + +/** + * Resolves dependencies which dependency-tree has trouble finding. For example, + * it is unable to parse sass imports such as `~@wordpress/base-styles/mixins`. + * This format is accepted by webpack to resolve style imports from node_modules, + * but dependency-tree does not support it. In this case, we translate that to + * node_modules/@wordpress/base-styles/_mixins.scss, if it exists. + * + * @param missingDependencies An array of dependencies that dependencyTree couldn't find. + * @returns An array of absolute paths to the location of any dependencies that were found. + */ +export function findMissingPackages( missingDependencies: Array< string > ): FoundPackages { + return missingDependencies.reduce< FoundPackages >( + ( acc, file ) => { + if ( file.startsWith( '~' ) ) { + // Without the tilde. + const correctFile = file.substring( 1 ); + const dirName = dirname( correctFile ); + const fileName = basename( correctFile ); + + // Webpack can resolve a few variations of the file, so check them all. + const fileNameVariations = [ + fileName, + fileName + '.scss', + '_' + fileName, + '_' + fileName + '.scss', + ]; + + // Add the first variation which exists to the accumulator. + for ( const possibleFile of fileNameVariations ) { + const packagePath = resolve( 'node_modules', dirName, possibleFile ); + if ( existsSync( packagePath ) ) { + acc.resolvedFiles.push( packagePath ); + acc.foundPackages.push( file ); + break; + } + } + } + return acc; + }, + { foundPackages: [], resolvedFiles: [] } + ); +} diff --git a/packages/dependency-finder/tsconfig.json b/packages/dependency-finder/tsconfig.json new file mode 100644 index 0000000000000..5dc21c68f96fb --- /dev/null +++ b/packages/dependency-finder/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "target": "ES5", + "lib": [ "DOM", "DOM.Iterable", "ESNext" ], + "baseUrl": ".", + "module": "esnext", + "allowJs": false, + "jsx": "react", + "declaration": true, + "declarationDir": "dist/types", + "outDir": "dist/esm", + "rootDir": "src", + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "sourceMap": true, + + "noFallthroughCasesInSwitch": true, + + "moduleResolution": "node", + "esModuleInterop": true, + + "forceConsistentCasingInFileNames": true, + + "typeRoots": [ "../../node_modules/@types" ], + "types": [ "node" ], + + "noEmitHelpers": true, + "importHelpers": true, + + "composite": true + }, + "include": [ "src" ], + "exclude": [ "**/docs/*", "**/test/*" ] +} diff --git a/yarn.lock b/yarn.lock index 17dc128cddd31..7282bb48be66d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -351,10 +351,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.12.13", "@babel/parser@^7.14.1", "@babel/parser@^7.14.2", "@babel/parser@^7.4.3", "@babel/parser@^7.5.5", "@babel/parser@^7.7.0", "@babel/parser@^7.8.4", "@babel/parser@^7.9.0": - version "7.14.2" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.2.tgz#0c1680aa44ad4605b16cbdcc5c341a61bde9c746" - integrity sha512-IoVDIHpsgE/fu7eXBeRWt8zLbDrSvD7H1gpomOkPpBoEN8KCruCqSDdqo8dddwQQrui30KSvQBaMUOJiuFu6QQ== +"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.12.13", "@babel/parser@^7.14.1", "@babel/parser@^7.14.2", "@babel/parser@^7.4.3", "@babel/parser@^7.5.5", "@babel/parser@^7.7.0", "@babel/parser@^7.8.4", "@babel/parser@^7.9.0": + version "7.14.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.3.tgz#9b530eecb071fd0c93519df25c5ff9f14759f298" + integrity sha512-7MpZDIfI7sUC5zWo2+foJ50CSI5lcqDehZ0lVgIhSi4bFEk94fLAKlF3Q0nzSQQ+ca0lm+O6G9ztKVBeu8PMRQ== "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.13.12": version "7.13.12" @@ -4354,6 +4354,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b" integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw== +"@typescript-eslint/types@4.25.0": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.25.0.tgz#0e444a5c5e3c22d7ffa5e16e0e60510b3de5af87" + integrity sha512-+CNINNvl00OkW6wEsi32wU5MhHti2J25TJsJJqgQmJu3B3dYDBcmOxcE5w9cgoM13TrdE/5ND2HoEnBohasxRQ== + "@typescript-eslint/typescript-estree@4.23.0": version "4.23.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.23.0.tgz#0753b292097523852428a6f5a1aa8ccc1aae6cd9" @@ -4367,6 +4372,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@^4.8.2": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.25.0.tgz#942e4e25888736bff5b360d9b0b61e013d0cfa25" + integrity sha512-1B8U07TGNAFMxZbSpF6jqiDs1cVGO0izVkf18Q/SPcUAc9LhHxzvSowXDTvkHMWUVuPpagupaW63gB6ahTXVlg== + dependencies: + "@typescript-eslint/types" "4.25.0" + "@typescript-eslint/visitor-keys" "4.25.0" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@4.23.0": version "4.23.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.23.0.tgz#7215cc977bd3b4ef22467b9023594e32f9e4e455" @@ -4375,6 +4393,14 @@ "@typescript-eslint/types" "4.23.0" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.25.0": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.25.0.tgz#863e7ed23da4287c5b469b13223255d0fde6aaa7" + integrity sha512-AmkqV9dDJVKP/TcZrbf6s6i1zYXt5Hl8qOLrRDTFfRNae4+LB8A4N3i+FLZPW85zIxRy39BgeWOfMS3HoH5ngg== + dependencies: + "@typescript-eslint/types" "4.25.0" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" @@ -6314,6 +6340,11 @@ anymatch@^3.0.3, anymatch@^3.1.1, anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" +app-module-path@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/app-module-path/-/app-module-path-2.2.0.tgz#641aa55dfb7d6a6f0a8141c4b9c0aa50b6c24dd5" + integrity sha1-ZBqlXft9am8KgUHEucCqULbCTdU= + app-root-dir@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/app-root-dir/-/app-root-dir-1.0.2.tgz#38187ec2dea7577fff033ffcb12172692ff6e118" @@ -6606,6 +6637,11 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= +ast-module-types@^2.3.2, ast-module-types@^2.4.0, ast-module-types@^2.7.0, ast-module-types@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/ast-module-types/-/ast-module-types-2.7.1.tgz#3f7989ef8dfa1fdb82dfe0ab02bdfc7c77a57dd3" + integrity sha512-Rnnx/4Dus6fn7fTqdeLEAn5vUll5w7/vts0RN608yFa6si/rDOUonlIIiwugHBFWjylHjxm9owoSZn71KwG4gw== + ast-types-flow@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" @@ -9246,7 +9282,7 @@ commander@2.8.x: dependencies: graceful-readlink ">= 1.0.0" -commander@^2.11.0, commander@^2.15.1, commander@^2.19.0, commander@^2.20.0, commander@^2.9.0, commander@~2.20.3: +commander@^2.11.0, commander@^2.15.1, commander@^2.16.0, commander@^2.19.0, commander@^2.20.0, commander@^2.20.3, commander@^2.8.1, commander@^2.9.0, commander@~2.20.3: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -10586,6 +10622,13 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +decomment@^0.9.3: + version "0.9.4" + resolved "https://registry.yarnpkg.com/decomment/-/decomment-0.9.4.tgz#fa40335bd90e3826d5c1984276e390525ff856d5" + integrity sha512-8eNlhyI5cSU4UbBlrtagWpR03dqXcE5IR9zpe7PnO6UzReXDskucsD8usgrzUmQ6qJ3N82aws/p/mu/jqbURWw== + dependencies: + esprima "4.0.1" + decompress-response@^4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-4.2.1.tgz#414023cc7a302da25ce2ec82d0d5238ccafd8986" @@ -10806,6 +10849,17 @@ dependency-graph@^0.9.0: resolved "https://registry.yarnpkg.com/dependency-graph/-/dependency-graph-0.9.0.tgz#11aed7e203bc8b00f48356d92db27b265c445318" integrity sha512-9YLIBURXj4DJMFALxXw9K3Y3rwb5Fk0X5/8ipCzaN84+gKxoHK43tVKRNakCQbiEx07E8Uwhuq21BpUagFhZ8w== +dependency-tree@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/dependency-tree/-/dependency-tree-8.1.0.tgz#1b896a0418bd7ba3e6d55c39bb664452a001579f" + integrity sha512-YKFK+1KXJOqVpsW6MkrIl/DyiW+KVG25V8NfRs27ANe+oSeCkQx2ROW1mBpp1bcm++5zj3Xv8wyFxHgX6TbM1w== + dependencies: + commander "^2.20.3" + debug "^4.3.1" + filing-cabinet "^3.0.0" + precinct "^7.0.0" + typescript "^3.9.7" + deprecation@^2.0.0, deprecation@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -10887,6 +10941,83 @@ detect-port@^1.3.0: address "^1.0.1" debug "^2.6.0" +detective-amd@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/detective-amd/-/detective-amd-3.1.0.tgz#92daee3214a0ca4522646cf333cac90a3fca6373" + integrity sha512-G7wGWT6f0VErjUkE2utCm7IUshT7nBh7aBBH2VBOiY9Dqy2DMens5iiOvYCuhstoIxRKLrnOvVAz4/EyPIAjnw== + dependencies: + ast-module-types "^2.7.0" + escodegen "^2.0.0" + get-amd-module-type "^3.0.0" + node-source-walk "^4.0.0" + +detective-cjs@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/detective-cjs/-/detective-cjs-3.1.1.tgz#18da3e39a002d2098a1123d45ce1de1b0d9045a0" + integrity sha512-JQtNTBgFY6h8uT6pgph5QpV3IyxDv+z3qPk/FZRDT9TlFfm5dnRtpH39WtQEr1khqsUxVqXzKjZHpdoQvQbllg== + dependencies: + ast-module-types "^2.4.0" + node-source-walk "^4.0.0" + +detective-es6@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/detective-es6/-/detective-es6-2.2.0.tgz#8f2baba3f8cd90a5cfd748f5ac436f0158ed2585" + integrity sha512-fSpNY0SLER7/sVgQZ1NxJPwmc9uCTzNgdkQDhAaj8NPYwr7Qji9QBcmbNvtMCnuuOGMuKn3O7jv0An+/WRWJZQ== + dependencies: + node-source-walk "^4.0.0" + +detective-less@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/detective-less/-/detective-less-1.0.2.tgz#a68af9ca5f69d74b7d0aa190218b211d83b4f7e3" + integrity sha512-Rps1xDkEEBSq3kLdsdnHZL1x2S4NGDcbrjmd4q+PykK5aJwDdP5MBgrJw1Xo+kyUHuv3JEzPqxr+Dj9ryeDRTA== + dependencies: + debug "^4.0.0" + gonzales-pe "^4.2.3" + node-source-walk "^4.0.0" + +detective-postcss@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detective-postcss/-/detective-postcss-4.0.0.tgz#24e69b465e5fefe7a6afd05f7e894e34595dbf51" + integrity sha512-Fwc/g9VcrowODIAeKRWZfVA/EufxYL7XfuqJQFroBKGikKX83d2G7NFw6kDlSYGG3LNQIyVa+eWv1mqre+v4+A== + dependencies: + debug "^4.1.1" + is-url "^1.2.4" + postcss "^8.1.7" + postcss-values-parser "^2.0.1" + +detective-sass@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/detective-sass/-/detective-sass-3.0.1.tgz#496b819efd1f5c4dd3f0e19b43a8634bdd6927c4" + integrity sha512-oSbrBozRjJ+QFF4WJFbjPQKeakoaY1GiR380NPqwdbWYd5wfl5cLWv0l6LsJVqrgWfFN1bjFqSeo32Nxza8Lbw== + dependencies: + debug "^4.1.1" + gonzales-pe "^4.2.3" + node-source-walk "^4.0.0" + +detective-scss@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/detective-scss/-/detective-scss-2.0.1.tgz#06f8c21ae6dedad1fccc26d544892d968083eaf8" + integrity sha512-VveyXW4WQE04s05KlJ8K0bG34jtHQVgTc9InspqoQxvnelj/rdgSAy7i2DXAazyQNFKlWSWbS+Ro2DWKFOKTPQ== + dependencies: + debug "^4.1.1" + gonzales-pe "^4.2.3" + node-source-walk "^4.0.0" + +detective-stylus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/detective-stylus/-/detective-stylus-1.0.0.tgz#50aee7db8babb990381f010c63fabba5b58e54cd" + integrity sha1-UK7n24uruZA4HwEMY/q7pbWOVM0= + +detective-typescript@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/detective-typescript/-/detective-typescript-6.0.0.tgz#394062118d7c7da53425647ca41e0081169aa2b3" + integrity sha512-vTidcSDK3QostdbrH2Rwf9FhvrgJ4oIaVw5jbolgruTejexk6nNa9DShGpuS8CFVDb1IP86jct5BaZt1wSxpkA== + dependencies: + "@typescript-eslint/typescript-estree" "^4.8.2" + ast-module-types "^2.7.1" + node-source-walk "^4.2.0" + typescript "^3.9.7" + detective@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b" @@ -11544,7 +11675,7 @@ enhanced-resolve@^4.5.0: memory-fs "^0.5.0" tapable "^1.0.0" -enhanced-resolve@^5.8.0, enhanced-resolve@^5.8.2: +enhanced-resolve@^5.3.2, enhanced-resolve@^5.8.0, enhanced-resolve@^5.8.2: version "5.8.2" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz#15ddc779345cbb73e97c611cd00c01c1e7bf4d8b" integrity sha512-F27oB3WuHDzvR2DOGNTaYy0D5o0cnrv8TeI482VM4kYgQd/FT9lUQwuNsJ0oOHtBUq7eiW5ytqzp7nBFknL+GA== @@ -12280,16 +12411,16 @@ espree@^7.3.0, espree@^7.3.1: acorn-jsx "^5.3.1" eslint-visitor-keys "^1.3.0" +esprima@4.0.1, esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + esprima@^2.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" integrity sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE= -esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - esprima@~3.1.0: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" @@ -12969,6 +13100,25 @@ filesize@6.0.1, filesize@^6.0.1: resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.0.1.tgz#f850b509909c7c86f7e450ea19006c31c2ed3d2f" integrity sha512-u4AYWPgbI5GBhs6id1KdImZWn5yfyFrrQ8OWZdN7ZMfA8Bf4HcO0BGo9bmUIEV8yrp8I1xVfJ/dn90GtFNNJcg== +filing-cabinet@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/filing-cabinet/-/filing-cabinet-3.0.0.tgz#08f9ceec5134f4a662926dd45b8a26eca1b5f622" + integrity sha512-o8Qac5qxZ1uVidR4Sd7ZQbbqObFZlqXU4xu1suAYg9PQPcQFNTzOmxQa/MehIDMgIvXHTb42mWPNV9l3eHBPSw== + dependencies: + app-module-path "^2.2.0" + commander "^2.20.3" + debug "^4.3.1" + decomment "^0.9.3" + enhanced-resolve "^5.3.2" + is-relative-path "^1.0.2" + module-definition "^3.3.1" + module-lookup-amd "^7.0.0" + resolve "^1.19.0" + resolve-dependency-path "^2.0.0" + sass-lookup "^3.0.0" + stylus-lookup "^3.0.1" + typescript "^3.9.7" + fill-range@^2.1.0: version "2.2.4" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565" @@ -13589,6 +13739,14 @@ gensync@^1.0.0-beta.1, gensync@^1.0.0-beta.2: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== +get-amd-module-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-amd-module-type/-/get-amd-module-type-3.0.0.tgz#bb334662fa04427018c937774570de495845c288" + integrity sha512-99Q7COuACPfVt18zH9N4VAMyb81S6TUgJm2NgV6ERtkh9VIkAaByZkW530wl3lLN5KTtSrK9jVLxYsoP5hQKsw== + dependencies: + ast-module-types "^2.3.2" + node-source-walk "^4.0.0" + get-assigned-identifiers@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz#6dbf411de648cbaf8d9169ebb0d2d576191e2ff1" @@ -13618,6 +13776,11 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: has "^1.0.3" has-symbols "^1.0.1" +get-own-enumerable-property-symbols@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664" + integrity sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g== + get-pkg-repo@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" @@ -14005,10 +14168,10 @@ globby@^10.0.0, globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" -globby@^11.0.0, globby@^11.0.1, globby@^11.0.2: - version "11.0.2" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.2.tgz#1af538b766a3b540ebfb58a32b2e2d5897321d83" - integrity sha512-2ZThXDvvV8fYFRVIxnrMQBipZQDr7MxKAmQK1vujaj9/7eF0efG7BPUKJ7jP7G5SLF37xKDXvO4S/KKLj/Z0og== +globby@^11.0.0, globby@^11.0.1, globby@^11.0.2, globby@^11.0.3: + version "11.0.3" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.3.tgz#9b1f0cb523e171dd1ad8c7b2a9fb4b644b9593cb" + integrity sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg== dependencies: array-union "^2.1.0" dir-glob "^3.0.1" @@ -14059,7 +14222,7 @@ globjoin@^0.1.4: resolved "https://registry.yarnpkg.com/globjoin/-/globjoin-0.1.4.tgz#2f4494ac8919e3767c5cbb691e9f463324285d43" integrity sha1-L0SUrIkZ43Z8XLtpHp9GMyQoXUM= -gonzales-pe@^4.3.0: +gonzales-pe@^4.2.3, gonzales-pe@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/gonzales-pe/-/gonzales-pe-4.3.0.tgz#fe9dec5f3c557eead09ff868c65826be54d067b3" integrity sha512-otgSPpUmdWJ43VXyiNgEYE4luzHCL2pz4wQ0OnDluC6Eg4Ko3Vexy/SrSynglw/eR+OhkzmqFCZa/OFa/RgAOQ== @@ -14523,6 +14686,13 @@ hosted-git-info@^3.0.6: dependencies: lru-cache "^6.0.0" +hosted-git-info@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.2.tgz#5e425507eede4fea846b7262f0838456c4209961" + integrity sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg== + dependencies: + lru-cache "^6.0.0" + hpack.js@^2.1.6: version "2.1.6" resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" @@ -15797,11 +15967,21 @@ is-regex@^1.0.4, is-regex@^1.0.5, is-regex@^1.1.0, is-regex@^1.1.1, is-regex@^1. call-bind "^1.0.2" has-symbols "^1.0.2" +is-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" + integrity sha1-/S2INUXEa6xaYz57mgnof6LLUGk= + is-regexp@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-2.1.0.tgz#cd734a56864e23b956bf4e7c66c396a4c0b22c2d" integrity sha512-OZ4IlER3zmRIoB9AqNhEggVxqIH4ofDns5nRrPS6yQxXE1TPCUpFznBfRQmQa8uC+pXqjMnukiJBxCisIxiLGA== +is-relative-path@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-relative-path/-/is-relative-path-1.0.2.tgz#091b46a0d67c1ed0fe85f1f8cfdde006bb251d46" + integrity sha1-CRtGoNZ8HtD+hfH4z93gBrslHUY= + is-relative@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" @@ -15903,7 +16083,7 @@ is-url-superb@^4.0.0: resolved "https://registry.yarnpkg.com/is-url-superb/-/is-url-superb-4.0.0.tgz#b54d1d2499bb16792748ac967aa3ecb41a33a8c2" integrity sha512-GI+WjezhPPcbM+tqE9LnmsY5qqjwHzTvjJ36wxYX5ujNXefSUJ/T17r5bqDV8yLhcgB59KTPNOc9O9cmHTPWsA== -is-url@^1.2.2: +is-url@^1.2.2, is-url@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== @@ -18885,6 +19065,14 @@ modify-values@^1.0.0: resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== +module-definition@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/module-definition/-/module-definition-3.3.1.tgz#fedef71667713e36988b93d0626a4fe7b35aebfc" + integrity sha512-kLidGPwQ2yq484nSD+D3JoJp4Etc0Ox9P0L34Pu/cU4X4HcG7k7p62XI5BBuvURWMRX3RPyuhOcBHbKus+UH4A== + dependencies: + ast-module-types "^2.7.1" + node-source-walk "^4.0.0" + module-deps@^6.0.0: version "6.2.2" resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-6.2.2.tgz#d8a15c2265dfc119153c29bb47386987d0ee423b" @@ -18906,6 +19094,17 @@ module-deps@^6.0.0: through2 "^2.0.0" xtend "^4.0.0" +module-lookup-amd@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/module-lookup-amd/-/module-lookup-amd-7.0.1.tgz#d67c1a93f2ff8e38b8774b99a638e9a4395774b2" + integrity sha512-w9mCNlj0S8qviuHzpakaLVc+/7q50jl9a/kmJ/n8bmXQZgDPkQHnPBb8MUOYh3WpAYkXuNc2c+khsozhIp/amQ== + dependencies: + commander "^2.8.1" + debug "^4.1.0" + glob "^7.1.6" + requirejs "^2.3.5" + requirejs-config-file "^4.0.0" + moment-timezone-data-webpack-plugin@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/moment-timezone-data-webpack-plugin/-/moment-timezone-data-webpack-plugin-1.3.0.tgz#8d5b7ffe42f0506933195779063a74cfff11aab1" @@ -19351,6 +19550,13 @@ node-slack-upload@^1.2.1: request "^2.54.0" underscore.string "^3.0.3" +node-source-walk@^4.0.0, node-source-walk@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/node-source-walk/-/node-source-walk-4.2.0.tgz#c2efe731ea8ba9c03c562aa0a9d984e54f27bc2c" + integrity sha512-hPs/QMe6zS94f5+jG3kk9E7TNm4P2SulrKiLWMzKszBfNZvL/V6wseHlTd7IvfW0NZWqPtK3+9yYNr+3USGteA== + dependencies: + "@babel/parser" "^7.0.0" + node-uuid@~1.4.0: version "1.4.8" resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" @@ -19406,14 +19612,14 @@ normalize-package-data@^2.0.0, normalize-package-data@^2.3.0, normalize-package- semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-package-data@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.0.tgz#1f8a7c423b3d2e85eb36985eaf81de381d01301a" - integrity sha512-6lUjEI0d3v6kFrtgA/lOx4zHCWULXsFNIjHolnZCKCTLA6m/G625cdn3O7eNmT0iD3jfo6HZ9cdImGZwf21prw== +normalize-package-data@^3.0.0, normalize-package-data@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.2.tgz#cae5c410ae2434f9a6c1baa65d5bc3b9366c8699" + integrity sha512-6CdZocmfGaKnIHPVFhJJZ3GuR8SsLKvDANFp47Jmy51aKIr8akjAWTSxtpI+MBgBFdSMRyo4hMpDlT6dTffgZg== dependencies: - hosted-git-info "^3.0.6" - resolve "^1.17.0" - semver "^7.3.2" + hosted-git-info "^4.0.1" + resolve "^1.20.0" + semver "^7.3.4" validate-npm-package-license "^3.0.1" normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1: @@ -20363,14 +20569,14 @@ parse-json@^4.0.0: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" -parse-json@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.0.0.tgz#73e5114c986d143efa3712d4ea24db9a4266f60f" - integrity sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw== +parse-json@^5.0.0, parse-json@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== dependencies: "@babel/code-frame" "^7.0.0" error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" + json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" parse-ms@^1.0.0: @@ -21679,14 +21885,14 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.1 source-map "^0.6.1" supports-color "^6.1.0" -postcss@^8.2.10, postcss@^8.2.15, postcss@^8.2.2, postcss@^8.2.4: - version "8.2.15" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.15.tgz#9e66ccf07292817d226fc315cbbf9bc148fbca65" - integrity sha512-2zO3b26eJD/8rb106Qu2o7Qgg52ND5HPjcyQiK2B98O388h43A448LCslC0dI2P97wCAQRJsFvwTRcXxTKds+Q== +postcss@^8.1.7, postcss@^8.2.10, postcss@^8.2.15, postcss@^8.2.2, postcss@^8.2.4: + version "8.3.0" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.0.tgz#b1a713f6172ca427e3f05ef1303de8b65683325f" + integrity sha512-+ogXpdAjWGa+fdYY5BQ96V/6tAo+TdSSIMP5huJBIygdWwKtVoB5JWZ7yUd4xZ8r+8Kvvx4nyg/PQ071H4UtcQ== dependencies: colorette "^1.2.2" nanoid "^3.1.23" - source-map "^0.6.1" + source-map-js "^0.6.2" prebuild-install@^5.3.3: version "5.3.4" @@ -21709,6 +21915,25 @@ prebuild-install@^5.3.3: tunnel-agent "^0.6.0" which-pm-runs "^1.0.0" +precinct@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/precinct/-/precinct-7.1.0.tgz#a0311e0b59029647eaf57c2d30b8efa9c85d129a" + integrity sha512-I1RkW5PX51/q6Xl39//D7x9NgaKNGHpR5DCNaoxP/b2+KbzzXDNhauJUMV17KSYkJA41CSpwYUPRtRoNxbshWA== + dependencies: + commander "^2.20.3" + debug "^4.3.1" + detective-amd "^3.0.1" + detective-cjs "^3.1.1" + detective-es6 "^2.2.0" + detective-less "^1.0.2" + detective-postcss "^4.0.0" + detective-sass "^3.0.1" + detective-scss "^2.0.1" + detective-stylus "^1.0.0" + detective-typescript "^6.0.0" + module-definition "^3.3.1" + node-source-walk "^4.2.0" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -22900,6 +23125,15 @@ read-pkg-up@^7.0.0, read-pkg-up@^7.0.1: read-pkg "^5.2.0" type-fest "^0.8.1" +read-pkg-up@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-8.0.0.tgz#72f595b65e66110f43b052dd9af4de6b10534670" + integrity sha512-snVCqPczksT0HS2EC+SxUndvSzn6LRCwpfSvLrIfR5BKDQQZMaI6jPRC9dYvYFDRAuFEAnkwww8kBBNE/3VvzQ== + dependencies: + find-up "^5.0.0" + read-pkg "^6.0.0" + type-fest "^1.0.1" + read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -22946,6 +23180,16 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" +read-pkg@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-6.0.0.tgz#a67a7d6a1c2b0c3cd6aa2ea521f40c458a4a504c" + integrity sha512-X1Fu3dPuk/8ZLsMhEj5f4wFAF0DWoK7qhGJvgaijocXxBmSToKfbFtqbxMO7bVjNA1dmE5huAzjXj/ey86iw9Q== + dependencies: + "@types/normalize-package-data" "^2.4.0" + normalize-package-data "^3.0.2" + parse-json "^5.2.0" + type-fest "^1.0.1" + read@1, read@~1.0.1: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" @@ -24170,6 +24414,19 @@ requireindex@~1.1.0: resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162" integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI= +requirejs-config-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/requirejs-config-file/-/requirejs-config-file-4.0.0.tgz#4244da5dd1f59874038cc1091d078d620abb6ebc" + integrity sha512-jnIre8cbWOyvr8a5F2KuqBnY+SDA4NXr/hzEZJG79Mxm2WiFQz2dzhC8ibtPJS7zkmBEl1mxSwp5HhC1W4qpxw== + dependencies: + esprima "^4.0.0" + stringify-object "^3.2.1" + +requirejs@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.6.tgz#e5093d9601c2829251258c0b9445d4d19fa9e7c9" + integrity sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg== + requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -24201,6 +24458,11 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" +resolve-dependency-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-dependency-path/-/resolve-dependency-path-2.0.0.tgz#11700e340717b865d216c66cabeb4a2a3c696736" + integrity sha512-DIgu+0Dv+6v2XwRaNWnumKu7GPufBBOr5I1gRPJHkvghrfCGOooJODFvgFimX/KRxk9j0whD2MnKHzM1jYvk9w== + resolve-dir@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-0.1.1.tgz#b219259a5602fac5c5c496ad894a6e8cc430261e" @@ -24247,7 +24509,7 @@ resolve@1.1.7, resolve@~1.1.0: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= -resolve@^1.1.4, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.4.0, resolve@^1.8.1, resolve@^1.9.0: +resolve@^1.1.4, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.3.2, resolve@^1.4.0, resolve@^1.8.1, resolve@^1.9.0: version "1.20.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -24549,6 +24811,13 @@ sass-loader@^11.1.1: klona "^2.0.4" neo-async "^2.6.2" +sass-lookup@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/sass-lookup/-/sass-lookup-3.0.0.tgz#3b395fa40569738ce857bc258e04df2617c48cac" + integrity sha512-TTsus8CfFRn1N44bvdEai1no6PqdmDiQUiqW5DlpmtT+tYnIt1tXtDIph5KA1efC+LmioJXSnCtUVpcK9gaKIg== + dependencies: + commander "^2.16.0" + sass@^1.26.11, sass@^1.32.13: version "1.32.13" resolved "https://registry.yarnpkg.com/sass/-/sass-1.32.13.tgz#8d29c849e625a415bce71609c7cf95e15f74ed00" @@ -25209,6 +25478,11 @@ source-list-map@^2.0.0, source-list-map@^2.0.1: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== +source-map-js@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e" + integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug== + source-map-loader@^0.2.4: version "0.2.4" resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-0.2.4.tgz#c18b0dc6e23bf66f6792437557c569a11e072271" @@ -25715,6 +25989,15 @@ stringify-entities@^2.0.0: is-decimal "^1.0.2" is-hexadecimal "^1.0.0" +stringify-object@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/stringify-object/-/stringify-object-3.3.0.tgz#703065aefca19300d3ce88af4f5b3956d7556629" + integrity sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw== + dependencies: + get-own-enumerable-property-symbols "^3.0.0" + is-obj "^1.0.1" + is-regexp "^1.0.0" + strip-ansi@5.2.0, strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" @@ -25945,6 +26228,14 @@ stylelint@^13.7.0, stylelint@^13.8.0: v8-compile-cache "^2.2.0" write-file-atomic "^3.0.3" +stylus-lookup@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/stylus-lookup/-/stylus-lookup-3.0.2.tgz#c9eca3ff799691020f30b382260a67355fefdddd" + integrity sha512-oEQGHSjg/AMaWlKe7gqsnYzan8DLcGIHe0dUaFkucZZ14z4zjENRlQMCHT4FNsiWnJf17YN9OvrCfCoi7VvOyg== + dependencies: + commander "^2.8.1" + debug "^4.1.0" + subarg@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" @@ -26971,6 +27262,11 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== +type-fest@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.0.2.tgz#3f9c39982859f385c77c38b7e5f1432b8a3661c6" + integrity sha512-a720oz3Kjbp3ll0zkeN9qjRhO7I34MKMhPGQiQJAmaZQZQ1lo+NWThK322f7sXV+kTg9B1Ybt16KgBXWgteT8w== + type-is@~1.6.17, type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" @@ -27020,6 +27316,11 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" +typescript@^3.9.7: + version "3.9.9" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.9.tgz#e69905c54bc0681d0518bd4d587cc6f2d0b1a674" + integrity sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w== + typescript@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" From 7deaff1e861091f3d9d5a44454a45efbe6615854 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Mon, 24 May 2021 18:27:42 -0700 Subject: [PATCH 02/10] Add ETK dependency on what's new --- apps/editing-toolkit/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/editing-toolkit/package.json b/apps/editing-toolkit/package.json index d42bd6be4cf95..0d8a056b0eaa5 100644 --- a/apps/editing-toolkit/package.json +++ b/apps/editing-toolkit/package.json @@ -102,6 +102,7 @@ "@automattic/page-pattern-modal": "^1.0.0-alpha.0", "@automattic/plans-grid": "^1.0.0-alpha.0", "@automattic/typography": "^1.0.0", + "@automattic/whats-new": "^1.0.0", "@babel/core": "^7.14.0", "@wordpress/a11y": "^2.15.3", "@wordpress/api-fetch": "^4.0.0", From 6e85f9b4e490602cfd53996196ad6519ad4a1d83 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Mon, 24 May 2021 18:28:13 -0700 Subject: [PATCH 03/10] ETK: only match local test files --- apps/editing-toolkit/jest.config.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/editing-toolkit/jest.config.js b/apps/editing-toolkit/jest.config.js index fc1c36e081552..8afe08af9912d 100644 --- a/apps/editing-toolkit/jest.config.js +++ b/apps/editing-toolkit/jest.config.js @@ -16,14 +16,10 @@ const defaults = require( '@wordpress/scripts/config/jest-unit.config.js' ); const path = require( 'path' ); -// Basically, CWD, so 'apps/editing-toolkit'. -// Without this, it tries to use 'apps/editing-toolkit/bin' -const pluginRoot = path.resolve( './' ); - const config = { ...defaults, rootDir: path.normalize( '../../' ), // To detect wp-calypso root node_modules - testMatch: [ `${ pluginRoot }/**/?(*.)test.[jt]s?(x)` ], + testMatch: [ `${ __dirname }/**/?(*.)test.[jt]s?(x)` ], transform: { '^.+\\.[jt]sx?$': path.join( __dirname, 'bin', 'babel-transform' ) }, setupFilesAfterEnv: [ ...( defaults.setupFilesAfterEnv || [] ), // extend if present From b2ded6ab83529809c76b845a18d68254b6932cd7 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Mon, 24 May 2021 18:28:51 -0700 Subject: [PATCH 04/10] Parse JS dependencies correctly To correctly parse JS dependencies, we need to: 1. Pass a long enough directory path so that enhanced-resolve can find the root node_modules 2. Pass the webpack config --- .../src/lib/entrypoints/additional.ts | 7 ++++--- .../dependency-finder/src/lib/find-dependencies.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/dependency-finder/src/lib/entrypoints/additional.ts b/packages/dependency-finder/src/lib/entrypoints/additional.ts index c9a0fa922d8f0..8fc259072c949 100644 --- a/packages/dependency-finder/src/lib/entrypoints/additional.ts +++ b/packages/dependency-finder/src/lib/entrypoints/additional.ts @@ -2,11 +2,12 @@ * External dependencies */ import globby from 'globby'; +import { resolve } from 'path'; export const findAdditionalEntryPoints = async ( additionalEntryPoints: string[] ): Promise< string[] > => { - return ( - await Promise.all( additionalEntryPoints.map( ( pattern ) => globby( pattern ) ) ) - ).flat(); + return ( await Promise.all( additionalEntryPoints.map( ( pattern ) => globby( pattern ) ) ) ) + .flat() + .map( ( entry ) => resolve( entry ) ); }; diff --git a/packages/dependency-finder/src/lib/find-dependencies.ts b/packages/dependency-finder/src/lib/find-dependencies.ts index 8884e9601e068..0afe385944bcb 100644 --- a/packages/dependency-finder/src/lib/find-dependencies.ts +++ b/packages/dependency-finder/src/lib/find-dependencies.ts @@ -57,6 +57,17 @@ export const findDependencies = async ( { } } )(); + const webpackConfig = ( () => { + try { + const webpackPath = path.join( pkg, 'webpack.config.js' ); + fs.accessSync( webpackPath ); + modules.add( webpackPath ); + return webpackPath; + } catch { + return null; + } + } )(); + const absoluteAdditionalEntryPoints = await findAdditionalEntryPoints( additionalEntryPoints ); // Handles monorepo and npm results from parsed files. @@ -77,10 +88,13 @@ export const findDependencies = async ( { return true; }; + // Entrypoints need to be absolute paths at this point so that the webpack resolver + // knows to parse up the filesystem further. (Otherwise, it stops short before reaching the root node_modules.) for ( const entrypoint of [ ...entrypoints, ...jestTests, ...absoluteAdditionalEntryPoints ] ) { const tree = dependencyTree.toList( { filename: entrypoint, directory: path.dirname( entrypoint ), + webpackConfig: webpackConfig ?? undefined, tsConfig: tsConfig ?? undefined, visited, filter: fileFilter, From 362bf2ed68cc2dbefe7d4f8a69c97c30efe8fec4 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 13:11:21 -0700 Subject: [PATCH 05/10] Read changed files from TeamCity --- .teamcity/settings.kts | 2 +- package-map.json | 1 + packages/dependency-finder/package.json | 3 +- packages/dependency-finder/src/index.ts | 94 ++++++++++++++++++++++--- 4 files changed, 89 insertions(+), 11 deletions(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index ed95a4b1c9489..d405b1e8a6877 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -313,7 +313,7 @@ object SmartBuildLauncher : BuildType({ bashNodeScript { name = "Launch relevant builds" scriptContent = """ - node ./packages/dependency-finder/dist/esm/index.js + node ./packages/dependency-finder/dist/esm/index.js --changedFiles %teamcity.build.changedFiles.file% """ } } diff --git a/package-map.json b/package-map.json index 5ceb52e528b4d..7eef562babde4 100644 --- a/package-map.json +++ b/package-map.json @@ -60,6 +60,7 @@ { "path": "packages/wpcom.js" }, { "path": "apps/editing-toolkit", + "buildIds": [ "calypso_WPComPlugins_EditorToolKit" ], "additionalEntryPoints": [ "apps/editing-toolkit/editing-toolkit-plugin/block-inserter-modifications/contextual-tips.js", "apps/editing-toolkit/editing-toolkit-plugin/block-patterns/index.ts", diff --git a/packages/dependency-finder/package.json b/packages/dependency-finder/package.json index 437229923c349..14c6df2150be7 100644 --- a/packages/dependency-finder/package.json +++ b/packages/dependency-finder/package.json @@ -21,7 +21,8 @@ "jest-config": "^26.6.3", "read-pkg": "^6.0.0", "read-pkg-up": "^8.0.0", - "tslib": "^2.2.0" + "tslib": "^2.2.0", + "yargs": "^17.0.1" }, "scripts": { "clean": "tsc --build ./tsconfig.json --clean && npx rimraf dist", diff --git a/packages/dependency-finder/src/index.ts b/packages/dependency-finder/src/index.ts index 1af5a4443619b..682c708c7f8d7 100644 --- a/packages/dependency-finder/src/index.ts +++ b/packages/dependency-finder/src/index.ts @@ -3,9 +3,22 @@ */ import path from 'path'; import fs from 'fs'; +import { readFile } from 'fs/promises'; import { fileURLToPath } from 'url'; import childProcess from 'child_process'; import { promisify } from 'util'; +import yargs from 'yargs'; + +const args = yargs( process.argv.slice( 2 ) ) + .usage( 'Usage: $0' ) + .option( 'changedFiles', { + describe: 'A path to the list of VCS changed files', + type: 'string', + } ) + .option( 'package', { + describe: 'The package to process from package-map.json', + type: 'string', + } ).argv; const exec = promisify( childProcess.exec ); @@ -22,9 +35,9 @@ const packageMapPath = path.join( type PackageMapEntry = { path: string; additionalEntryPoints: Array< string > | undefined; + buildIds: Array< string > | undefined; }; type PackageMap = Array< PackageMapEntry >; -const packageMap: PackageMap = JSON.parse( fs.readFileSync( packageMapPath, 'utf8' ) ); function getMonorepoPackages() { const packages = fs.readdirSync( 'packages', { withFileTypes: true } ); @@ -34,10 +47,13 @@ function getMonorepoPackages() { } const monorepoPackages = getMonorepoPackages(); -const findPackageDependencies = async ( { - path: pkgPath, - additionalEntryPoints, -}: PackageMapEntry ) => { +type Project = { + matchingFiles: Array< string >; + buildIds: Array< string > | undefined; +}; + +const findPackageDependencies = async ( entry: PackageMapEntry ): Promise< Project > => { + const { path: pkgPath, additionalEntryPoints } = entry; const absolutePkgPath = path.resolve( pkgPath ); const { missing, packages, modules } = await findDependencies( { @@ -68,15 +84,75 @@ const findPackageDependencies = async ( { console.log( unknownFiles.length ? unknownFiles.map( ( m ) => ' ' + m ).join( '\n' ) : ' -' ); console.log(); console.log(); + return { + ...entry, + matchingFiles: modules, + }; }; +/** + * Given a list of currently modified files, returns the CI jobs which need to be + * launched. + * + * TODO: improve algorithmic complexity. Currently O(modifiedFiles * projects * matchingFiles). + * + * @param projects The list of projects. + * @param modifiedFiles The list of currently modified files. + * @returns A Set of CI Job IDs to launch. + */ +// TODO: make sure project files are relative to repo root. +function findMatchingBuilds( projects: Project[], modifiedFiles: VCSFileChange[] ) { + return modifiedFiles.reduce< Set< string > >( ( acc, modifiedFile ) => { + const matchingProject = projects.find( ( proj ) => + proj.matchingFiles.some( ( file ) => file === modifiedFile.path ) + ); + if ( matchingProject?.buildIds ) { + matchingProject.buildIds.forEach( ( id ) => acc.add( id ) ); + } + return acc; + }, new Set() ); +} + +// :: +// see https://plugins.jetbrains.com/docs/teamcity/risk-tests-reordering-in-custom-test-runner.html +type VCSFileChange = { + path: string; + changeType: + | 'CHANGED' + | 'ADDED' + | 'REMOVED' + | 'NOT_CHANGED' + | 'DIRECTORY_CHANGED' + | 'DIRECTORY_ADDED' + | 'DIRECTORY_REMOVED'; + revision: string; +}; +async function readTeamCityMatchedFiles( filePath: string ) { + const rawContents = await readFile( filePath, 'utf8' ); + return rawContents.split( '\n' ).map( ( entry ) => { + const [ path, changeType, revision ] = entry.split( ':' ); + return { + path, + changeType, + revision, + } as VCSFileChange; + } ); +} + const main = async () => { - const packageToParse = process.argv.slice( 2 )[ 0 ]; + const packageMap: PackageMap = JSON.parse( await readFile( packageMapPath, 'utf8' ) ); + if ( args.changedFiles ) { + const changedFiles = await readTeamCityMatchedFiles( args.changedFiles ); + console.log( changedFiles ); + return; + } + // Allow parsing a single package. - if ( packageToParse ) { - const packageEntry = packageMap.find( ( { path } ) => path === packageToParse ); + if ( args.package ) { + const packageEntry = packageMap.find( ( { path } ) => path === args.package ); if ( packageEntry ) { - findPackageDependencies( packageEntry ); + const project = await findPackageDependencies( packageEntry ); + findMatchingBuilds( [ project ], [] ); } } else { for ( const packageEntry of packageMap ) { From b699920e4deff9d312f7227717254e34039c3a37 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 13:19:19 -0700 Subject: [PATCH 06/10] Use system for variable --- .teamcity/settings.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index d405b1e8a6877..e60fc1c3d6b27 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -313,7 +313,7 @@ object SmartBuildLauncher : BuildType({ bashNodeScript { name = "Launch relevant builds" scriptContent = """ - node ./packages/dependency-finder/dist/esm/index.js --changedFiles %teamcity.build.changedFiles.file% + node ./packages/dependency-finder/dist/esm/index.js --changedFiles %system.teamcity.build.changedFiles.file% """ } } From 84831c95cf648a86443ce3e91e8ee7f288b6b309 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 13:39:40 -0700 Subject: [PATCH 07/10] Do not include empty paths --- packages/dependency-finder/src/index.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/dependency-finder/src/index.ts b/packages/dependency-finder/src/index.ts index 682c708c7f8d7..19abc33323b74 100644 --- a/packages/dependency-finder/src/index.ts +++ b/packages/dependency-finder/src/index.ts @@ -2,8 +2,7 @@ * External dependencies */ import path from 'path'; -import fs from 'fs'; -import { readFile } from 'fs/promises'; +import { readFile, readdir } from 'fs/promises'; import { fileURLToPath } from 'url'; import childProcess from 'child_process'; import { promisify } from 'util'; @@ -39,8 +38,8 @@ type PackageMapEntry = { }; type PackageMap = Array< PackageMapEntry >; -function getMonorepoPackages() { - const packages = fs.readdirSync( 'packages', { withFileTypes: true } ); +async function getMonorepoPackages() { + const packages = await readdir( 'packages', { withFileTypes: true } ); return packages .filter( ( entry ) => entry.isDirectory() ) .map( ( entry ) => path.resolve( 'packages', entry.name ) ); @@ -129,14 +128,13 @@ type VCSFileChange = { }; async function readTeamCityMatchedFiles( filePath: string ) { const rawContents = await readFile( filePath, 'utf8' ); - return rawContents.split( '\n' ).map( ( entry ) => { + return rawContents.split( '\n' ).reduce< VCSFileChange[] >( ( acc, entry ) => { const [ path, changeType, revision ] = entry.split( ':' ); - return { - path, - changeType, - revision, - } as VCSFileChange; - } ); + if ( path && changeType && revision ) { + acc.push( { path, changeType, revision } as VCSFileChange ); + } + return acc; + }, [] ); } const main = async () => { From 2b2127f6053d4ff5d79378ebc9fcfbff17739557 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 13:50:17 -0700 Subject: [PATCH 08/10] Integrate build matcher --- packages/dependency-finder/src/index.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/dependency-finder/src/index.ts b/packages/dependency-finder/src/index.ts index 19abc33323b74..50d0cf8d3343d 100644 --- a/packages/dependency-finder/src/index.ts +++ b/packages/dependency-finder/src/index.ts @@ -38,13 +38,13 @@ type PackageMapEntry = { }; type PackageMap = Array< PackageMapEntry >; +// TODO: import from build-tools async function getMonorepoPackages() { const packages = await readdir( 'packages', { withFileTypes: true } ); return packages .filter( ( entry ) => entry.isDirectory() ) .map( ( entry ) => path.resolve( 'packages', entry.name ) ); } -const monorepoPackages = getMonorepoPackages(); type Project = { matchingFiles: Array< string >; @@ -58,7 +58,7 @@ const findPackageDependencies = async ( entry: PackageMapEntry ): Promise< Proje const { missing, packages, modules } = await findDependencies( { pkg: absolutePkgPath, additionalEntryPoints, - monorepoPackages, + monorepoPackages: await getMonorepoPackages(), } ); const { stdout } = await exec( `find ${ absolutePkgPath } -type f -not \\( -path '*/node_modules/*' -o -path '*/.cache/*' -o -path '*/dist/*' \\)` @@ -99,11 +99,12 @@ const findPackageDependencies = async ( entry: PackageMapEntry ): Promise< Proje * @param modifiedFiles The list of currently modified files. * @returns A Set of CI Job IDs to launch. */ -// TODO: make sure project files are relative to repo root. +// TODO: make sure project files are relative to repo root. Currently, modifiedFiles +// are relative to the repo root, but project files are absolute. function findMatchingBuilds( projects: Project[], modifiedFiles: VCSFileChange[] ) { return modifiedFiles.reduce< Set< string > >( ( acc, modifiedFile ) => { const matchingProject = projects.find( ( proj ) => - proj.matchingFiles.some( ( file ) => file === modifiedFile.path ) + proj.matchingFiles.some( ( file ) => file.includes( modifiedFile.path ) ) ); if ( matchingProject?.buildIds ) { matchingProject.buildIds.forEach( ( id ) => acc.add( id ) ); @@ -139,18 +140,18 @@ async function readTeamCityMatchedFiles( filePath: string ) { const main = async () => { const packageMap: PackageMap = JSON.parse( await readFile( packageMapPath, 'utf8' ) ); - if ( args.changedFiles ) { - const changedFiles = await readTeamCityMatchedFiles( args.changedFiles ); - console.log( changedFiles ); - return; - } + const changedFiles = args.changedFiles + ? await readTeamCityMatchedFiles( args.changedFiles ) + : null; - // Allow parsing a single package. if ( args.package ) { const packageEntry = packageMap.find( ( { path } ) => path === args.package ); if ( packageEntry ) { const project = await findPackageDependencies( packageEntry ); - findMatchingBuilds( [ project ], [] ); + if ( changedFiles ) { + const builds = await findMatchingBuilds( [ project ], changedFiles ); + builds.forEach( console.log ); + } } } else { for ( const packageEntry of packageMap ) { From 7bb1d8d112c9db010886511ee68fd76d0808e0b3 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 13:52:04 -0700 Subject: [PATCH 09/10] Add modified ETK build for testing --- .../editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/editing-toolkit/editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js b/apps/editing-toolkit/editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js index 6a200b5f19f0a..2138ea75b1758 100644 --- a/apps/editing-toolkit/editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js +++ b/apps/editing-toolkit/editing-toolkit-plugin/common/hide-plugin-buttons-mobile.js @@ -1,5 +1,4 @@ /** * Internal dependencies */ - import './hide-plugin-buttons-mobile.scss'; From 80aae68415ac7f44ffed2d186c6e901af7221fb0 Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 27 May 2021 14:00:36 -0700 Subject: [PATCH 10/10] Improve logging --- .teamcity/settings.kts | 2 +- packages/dependency-finder/src/index.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index e60fc1c3d6b27..9e43b3e323c69 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -313,7 +313,7 @@ object SmartBuildLauncher : BuildType({ bashNodeScript { name = "Launch relevant builds" scriptContent = """ - node ./packages/dependency-finder/dist/esm/index.js --changedFiles %system.teamcity.build.changedFiles.file% + node ./packages/dependency-finder/dist/esm/index.js --changedFiles %system.teamcity.build.changedFiles.file% --package apps/editing-toolkit """ } } diff --git a/packages/dependency-finder/src/index.ts b/packages/dependency-finder/src/index.ts index 50d0cf8d3343d..3583d3c16fda2 100644 --- a/packages/dependency-finder/src/index.ts +++ b/packages/dependency-finder/src/index.ts @@ -148,9 +148,12 @@ const main = async () => { const packageEntry = packageMap.find( ( { path } ) => path === args.package ); if ( packageEntry ) { const project = await findPackageDependencies( packageEntry ); + console.log( project ); + console.log( changedFiles ); if ( changedFiles ) { + console.log( 'Finding builds...' ); const builds = await findMatchingBuilds( [ project ], changedFiles ); - builds.forEach( console.log ); + console.log( Array.from( builds ) ); } } } else {