From 2446dd155f328f260a941d86f7ea54ad4a2d7aca Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Mon, 13 May 2024 18:28:11 +0200 Subject: [PATCH] wip --- .github/workflows/verify.yml | 4 ++-- .../cli/launch-providence-with-extend-docs.js | 18 ++++++++++-------- .../helpers/normalize-source-paths.js | 1 + .../src/program/analyzers/match-paths.js | 1 - .../src/program/analyzers/match-subclasses.js | 4 ++-- .../src/program/utils/optimised-glob.js | 9 +++++++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 20f37f66f3..1ef6eba060 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -7,7 +7,7 @@ jobs: name: Verify changes runs-on: ubuntu-latest steps: - # - uses: google/wireit@setup-github-actions-caching/v1 + - uses: google/wireit@setup-github-actions-caching/v1 - uses: actions/checkout@v4 - name: Sanity check @@ -56,7 +56,7 @@ jobs: node-version: [18.x] os: [windows-latest] steps: - # - uses: google/wireit@setup-github-actions-caching/v1 + - uses: google/wireit@setup-github-actions-caching/v1 - uses: actions/checkout@v4 - name: Setup Node ${{ matrix.node-version }} diff --git a/packages-node/providence-analytics/src/cli/launch-providence-with-extend-docs.js b/packages-node/providence-analytics/src/cli/launch-providence-with-extend-docs.js index 0ab4faa9a0..1b7a0cf2ee 100644 --- a/packages-node/providence-analytics/src/cli/launch-providence-with-extend-docs.js +++ b/packages-node/providence-analytics/src/cli/launch-providence-with-extend-docs.js @@ -1,13 +1,15 @@ /* eslint-disable import/no-extraneous-dependencies */ -import path from 'path'; import { performance } from 'perf_hooks'; -import { _providenceModule } from '../program/providence.js'; -import { QueryService } from '../program/core/QueryService.js'; +import path from 'path'; + import { InputDataService } from '../program/core/InputDataService.js'; -import { LogService } from '../program/core/LogService.js'; -import { flatten } from './cli-helpers.js'; import MatchPathsAnalyzer from '../program/analyzers/match-paths.js'; +import { toPosixPath } from '../program/utils/to-posix-path.js'; +import { QueryService } from '../program/core/QueryService.js'; +import { _providenceModule } from '../program/providence.js'; +import { LogService } from '../program/core/LogService.js'; import { fsAdapter } from '../program/utils/fs-adapter.js'; +import { flatten } from './cli-helpers.js'; /** * @typedef {import('../../types/index.js').PathFromSystemRoot} PathFromSystemRoot @@ -27,10 +29,10 @@ import { fsAdapter } from '../program/utils/fs-adapter.js'; */ export async function getExtendDocsResults({ referenceProjectPaths, - prefixCfg, + allowlistReference, extensions, + prefixCfg, allowlist, - allowlistReference, cwd, }) { const monoPkgs = await InputDataService.getMonoRepoPackages(cwd); @@ -71,7 +73,7 @@ export async function getExtendDocsResults({ const normalizedP = `./${p}`; if (pathStr.startsWith(normalizedP)) { const localPath = pathStr.replace(normalizedP, ''); // 'lea-tabs.js' - result = path.join(name, localPath); // 'lea-tabs/lea-tabs.js' + result = toPosixPath(path.join(name, localPath)); // 'lea-tabs/lea-tabs.js' return true; } return false; diff --git a/packages-node/providence-analytics/src/program/analyzers/helpers/normalize-source-paths.js b/packages-node/providence-analytics/src/program/analyzers/helpers/normalize-source-paths.js index 751fae4aef..28f711acbb 100644 --- a/packages-node/providence-analytics/src/program/analyzers/helpers/normalize-source-paths.js +++ b/packages-node/providence-analytics/src/program/analyzers/helpers/normalize-source-paths.js @@ -1,5 +1,6 @@ /* eslint-disable no-param-reassign */ import path from 'path'; + import { isRelativeSourcePath } from '../../utils/relative-source-path.js'; import { resolveImportPath } from '../../utils/resolve-import-path.js'; import { toPosixPath } from '../../utils/to-posix-path.js'; diff --git a/packages-node/providence-analytics/src/program/analyzers/match-paths.js b/packages-node/providence-analytics/src/program/analyzers/match-paths.js index 6adb5824fe..7ca1bdd1d1 100644 --- a/packages-node/providence-analytics/src/program/analyzers/match-paths.js +++ b/packages-node/providence-analytics/src/program/analyzers/match-paths.js @@ -109,7 +109,6 @@ function getClosestToRootTargetPath(targetPaths, targetExportsResult) { } /** - * * @param {FindExportsAnalyzerResult} targetExportsResult * @param {FindExportsAnalyzerResult} refFindExportsResult * @param {string} targetMatchedFile file where `toClass` from match-subclasses is defined diff --git a/packages-node/providence-analytics/src/program/analyzers/match-subclasses.js b/packages-node/providence-analytics/src/program/analyzers/match-subclasses.js index edd717f854..519ab39c00 100644 --- a/packages-node/providence-analytics/src/program/analyzers/match-subclasses.js +++ b/packages-node/providence-analytics/src/program/analyzers/match-subclasses.js @@ -1,5 +1,5 @@ /* eslint-disable no-continue */ -import pathLib from 'path'; +import path from 'path'; /* eslint-disable no-shadow, no-param-reassign */ import FindClassesAnalyzer from './find-classes.js'; import FindExportsAnalyzer from './find-exports.js'; @@ -126,7 +126,7 @@ async function matchSubclassesPostprocess( const importProjectPath = cfg.targetProjectPath; for (const { result, file } of targetClassesAnalyzerResult.queryOutput) { const importerFilePath = /** @type {PathFromSystemRoot} */ ( - pathLib.resolve(importProjectPath, file) + path.resolve(importProjectPath, file) ); for (const classEntryResult of result) { /** diff --git a/packages-node/providence-analytics/src/program/utils/optimised-glob.js b/packages-node/providence-analytics/src/program/utils/optimised-glob.js index 0629bcf697..c8930ead4f 100644 --- a/packages-node/providence-analytics/src/program/utils/optimised-glob.js +++ b/packages-node/providence-analytics/src/program/utils/optimised-glob.js @@ -3,6 +3,8 @@ import nodeFs from 'fs'; import path from 'path'; +import { toPosixPath } from './to-posix-path.js'; + const [nodeMajor] = process.versions.node.split('.').map(Number); if (nodeMajor < 18) { @@ -211,7 +213,7 @@ export async function optimisedGlob(globOrGlobs, providedOptions = {}) { // Search for the "deepest" starting point in the filesystem that we can use to search the fs const startPath = getStartPath(globNormalized); - const fullStartPath = path.posix.join(options.cwd, startPath); + const fullStartPath = path.join(options.cwd, startPath); try { const allDirentsRelativeToStartPath = await getAllFilesFromStartPath(fullStartPath, { @@ -220,7 +222,10 @@ export async function optimisedGlob(globOrGlobs, providedOptions = {}) { const allDirEntsRelativeToCwd = allDirentsRelativeToStartPath.map(dirent => ({ // @ts-expect-error - relativeToCwdPath: path.posix.join(dirent.path, dirent.name).replace(`${options.cwd}/`, ''), + relativeToCwdPath: toPosixPath(path.join(dirent.path, dirent.name)).replace( + `${options.cwd}/`, + '', + ), dirent, }));