Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

update-ts-references

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

update-ts-references - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

2

package.json
{
"name": "update-ts-references",
"version": "3.1.0",
"version": "3.2.0",
"description": "Updates TypeScript references automatically while using workspaces",

@@ -5,0 +5,0 @@ "bin": "src/index.js",

@@ -23,3 +23,3 @@ [![Test](https://github.com/eBayClassifiedsGroup/update-ts-references/actions/workflows/node.js.yml/badge.svg)](https://github.com/eBayClassifiedsGroup/update-ts-references/actions/workflows/node.js.yml)

--createTsConfig Create default TS configs for packages where the main entry in the package.json have a ts|tsx extension (Note: respects the --configName parameter)
-createPathMappings Create paths mappings under compilerOptions for a better IDE support. It respects the rootDir if no rootDir available it falls back to "src"
--createPathMappings Create paths mappings under compilerOptions for a better IDE support. It respects the rootDir if no rootDir available it falls back to "src"
--cwd Set working directory. Default: /Users/john-doe/projects/my-project

@@ -72,3 +72,3 @@ --verbose Show verbose output. Default: false

## using --createPathMappings
will create path mappings under `compilerOptions` for a better IDE support. It respects the `rootDir` if no `rootDir` available it falls back to `src`
will create path mappings under `compilerOptions` for a better IDE support. It assumes the source files are under `src`.

@@ -75,0 +75,0 @@ ```json

@@ -164,3 +164,3 @@ const glob = require('glob');

path: reference.path.split(path.sep).join(path.posix.sep),
folder: reference.folder.split(path.sep).join(path.posix.sep),
folder: reference.folder?.split(path.sep).join(path.posix.sep),
});

@@ -170,3 +170,4 @@

configName,
win32OrPosixReferences,
references,
paths,
check,

@@ -176,3 +177,2 @@ createPathMappings = false,

) => {
const references = (win32OrPosixReferences || []).map(ensurePosixPathStyle);
const tsconfigFilePath = path.join(packageDir, configName);

@@ -201,8 +201,5 @@

const compilerOptions = config?.compilerOptions ?? {};
if (createPathMappings)
if (createPathMappings && paths && Object.keys(paths).length > 0)
assign(compilerOptions, {
paths: references.reduce((paths, ref) => ({
...paths,
[`${ref.name}`]: [`${ref.folder}/${config.compilerOptions?.rootDir ?? 'src'}`]
}), {})
paths
})

@@ -226,2 +223,9 @@

function getPathsFromReferences(references) {
return references.reduce((paths, ref) => ({
...paths,
[`${ref.name}`]: [`${ref.folder}/src`]
}), {});
}
const execute = async ({

@@ -294,4 +298,4 @@ cwd, createTsConfig,

const rootReferences = [];
let rootReferences = [];
let rootPaths = [];
packagesMap.forEach((packageEntry, packageName) => {

@@ -306,3 +310,3 @@ const detectedConfig = detectTSConfig(packageEntry.packageDir, configName, packageEntry.hasTsEntry && createTsConfig, cwd)

});
const references = getReferencesFromDependencies(
const references = (getReferencesFromDependencies(
configName,

@@ -313,9 +317,15 @@ packageEntry,

verbose
);
) || []).map(ensurePosixPathStyle);
const paths = getPathsFromReferences(references)
if (verbose) {
console.log(`references of ${packageName}`, references);
console.log(`paths of ${packageName}`, paths);
}
changesCount += updateTsConfig(
detectedConfig,
references,
paths,
check,

@@ -328,7 +338,16 @@ createPathMappings,

console.log(`NO ${configName === TSCONFIG_JSON ? configName : `${configName} nor ${TSCONFIG_JSON}`} for ${packageName}`);
rootPaths.push({
name: packageName,
path: path.relative(cwd, packageEntry.packageDir),
folder: path.relative(cwd, packageEntry.packageDir),
});
}
});
rootReferences = (rootReferences || []).map(ensurePosixPathStyle);
rootPaths = getPathsFromReferences((rootPaths || []).map(ensurePosixPathStyle))
if (verbose) {
console.log('rootReferences', rootReferences);
console.log('rootPaths', rootPaths);
}

@@ -338,3 +357,4 @@ changesCount += updateTsConfig(

rootReferences,
check, false, {packageDir: cwd}
rootPaths,
check, createPathMappings, {packageDir: cwd}
);

@@ -341,0 +361,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc