Socket
Socket
Sign inDemoInstall

@ts-bridge/cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-bridge/cli - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

10

CHANGELOG.md

@@ -10,2 +10,9 @@ # Changelog

## [0.4.3]
### Fixed
- Clean dist folders of referenced projects if `clean` is enabled ([#46](https://github.com/ts-bridge/ts-bridge/pull/46))
- Forward verbose option to build function when building for Node 16 ([#45](https://github.com/ts-bridge/ts-bridge/pull/45))
## [0.4.2]

@@ -113,3 +120,4 @@

[Unreleased]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.2...HEAD
[Unreleased]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.3...HEAD
[0.4.3]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.2...@ts-bridge/cli@0.4.3
[0.4.2]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.1...@ts-bridge/cli@0.4.2

@@ -116,0 +124,0 @@ [0.4.1]: https://github.com/ts-bridge/ts-bridge/compare/@ts-bridge/cli@0.4.0...@ts-bridge/cli@0.4.1

@@ -73,2 +73,3 @@ import type { CompilerHost, CompilerOptions, ParsedCommandLine, Program, ProjectReference, System } from 'typescript';

shims: boolean;
clean?: boolean;
};

@@ -75,0 +76,0 @@ /**

27

dist/build.js

@@ -80,2 +80,17 @@ import chalk from 'chalk';

/**
* Clean the output directory before building the project.
*
* @param project - The path to the project's `tsconfig.json` file.
* @param options - The compiler options to use.
* @param clean - Whether to clean the output directory before building.
* @param verbose - Whether to enable verbose logging.
*/
function cleanOutputDirectory(project, options, clean = false, verbose) {
const baseDirectory = dirname(project);
if (clean && options.outDir) {
verbose && info(`Cleaning output directory "${options.outDir}".`);
removeDirectory(options.outDir, baseDirectory);
}
}
/**
* Handle the `build` command. This is intended to be called by the CLI.

@@ -90,5 +105,3 @@ *

const baseDirectory = dirname(project);
if (clean && baseOptions.outDir) {
removeDirectory(baseOptions.outDir, baseDirectory);
}
cleanOutputDirectory(project, baseOptions, clean, verbose);
const files = getFiles(customFiles, tsConfig.fileNames);

@@ -119,2 +132,3 @@ const initialHost = getInitialCompilerHost({

shims,
clean,
};

@@ -218,3 +232,3 @@ const buildFunction = getBuildFunction(tsConfig, references);

task: () => {
build({ program, type: 'module', system, shims });
build({ program, type: 'module', system, shims, verbose });
},

@@ -226,3 +240,3 @@ },

task: () => {
build({ program, type: 'commonjs', system, shims });
build({ program, type: 'commonjs', system, shims, verbose });
},

@@ -240,3 +254,3 @@ },

export function buildProjectReferences(options) {
const { program, tsConfig, format, system, baseDirectory, verbose, shims } = options;
const { program, tsConfig, format, system, baseDirectory, verbose, shims, clean, } = options;
const resolvedProjectReferences = getDefinedArray(program.getResolvedProjectReferences());

@@ -249,2 +263,3 @@ const sortedProjectReferences = getResolvedProjectReferences(baseDirectory, resolvedProjectReferences);

const baseChildOptions = getBaseCompilerOptions(dirname(sourceFile.fileName), childOptions);
cleanOutputDirectory(sourceFile.fileName, baseChildOptions, clean, verbose);
const compilerOptions = getCompilerOptions(baseChildOptions);

@@ -251,0 +266,0 @@ const host = createProjectReferencesCompilerHost(format, compilerOptions, getDefinedArray(references), system);

@@ -379,4 +379,17 @@ import { getFixture, noOp, parseJson } from '@ts-bridge/test-utils';

});
it('removes the output directory of all referenced projects if `clean` is enabled', () => {
const path = getFixture('project-references-node-16');
const dist = join(path, 'dist');
compile(getFixture('project-references-node-16'), ['commonjs', 'module'], {
references: true,
clean: true,
});
expect(vi.mocked(removeDirectory)).toHaveBeenCalledWith(dist, path);
expect(vi.mocked(removeDirectory)).toHaveBeenCalledWith(join(path, 'packages/project-1/dist'), join(path, 'packages/project-1'));
expect(vi.mocked(removeDirectory)).toHaveBeenCalledWith(join(path, 'packages/project-2/dist'), join(path, 'packages/project-2'));
expect(vi.mocked(removeDirectory)).toHaveBeenCalledWith(join(path, 'packages/project-3/dist'), join(path, 'packages/project-3'));
});
});
it('removes the output directory if `clean` is enabled', () => {
const log = vi.spyOn(console, 'log').mockImplementation(noOp);
const path = getFixture('node-16');

@@ -386,4 +399,6 @@ const dist = join(path, 'dist');

clean: true,
verbose: true,
});
expect(vi.mocked(removeDirectory)).toHaveBeenCalledWith(dist, path);
expect(log).toHaveBeenCalledWith(expect.stringContaining('Cleaning output directory'));
});

@@ -390,0 +405,0 @@ it('throws an error if the project fails to initialise', () => {

@@ -22,106 +22,3 @@ import type { CompilerOptions, System } from 'typescript';

*/
export declare function getBaseCompilerOptions(basePath: string, baseOptions: CompilerOptions): {
emitDeclarationOnly: boolean;
declarationDir: string;
outDir: string;
allowImportingTsExtensions?: boolean | undefined;
allowJs?: boolean | undefined;
allowArbitraryExtensions?: boolean | undefined;
allowSyntheticDefaultImports?: boolean | undefined;
allowUmdGlobalAccess?: boolean | undefined;
allowUnreachableCode?: boolean | undefined;
allowUnusedLabels?: boolean | undefined;
alwaysStrict?: boolean | undefined;
baseUrl?: string | undefined;
charset?: string | undefined;
checkJs?: boolean | undefined;
customConditions?: string[] | undefined;
declaration?: boolean | undefined;
declarationMap?: boolean | undefined;
disableSizeLimit?: boolean | undefined;
disableSourceOfProjectReferenceRedirect?: boolean | undefined;
disableSolutionSearching?: boolean | undefined;
disableReferencedProjectLoad?: boolean | undefined;
downlevelIteration?: boolean | undefined;
emitBOM?: boolean | undefined;
emitDecoratorMetadata?: boolean | undefined;
exactOptionalPropertyTypes?: boolean | undefined;
experimentalDecorators?: boolean | undefined;
forceConsistentCasingInFileNames?: boolean | undefined;
ignoreDeprecations?: string | undefined;
importHelpers?: boolean | undefined;
importsNotUsedAsValues?: typescript.ImportsNotUsedAsValues | undefined;
inlineSourceMap?: boolean | undefined;
inlineSources?: boolean | undefined;
isolatedModules?: boolean | undefined;
jsx?: typescript.JsxEmit | undefined;
keyofStringsOnly?: boolean | undefined;
lib?: string[] | undefined;
locale?: string | undefined;
mapRoot?: string | undefined;
maxNodeModuleJsDepth?: number | undefined;
module?: typescript.ModuleKind | undefined;
moduleResolution?: typescript.ModuleResolutionKind | undefined;
moduleSuffixes?: string[] | undefined;
moduleDetection?: typescript.ModuleDetectionKind | undefined;
newLine?: typescript.NewLineKind | undefined;
noEmit?: boolean | undefined;
noEmitHelpers?: boolean | undefined;
noEmitOnError?: boolean | undefined;
noErrorTruncation?: boolean | undefined;
noFallthroughCasesInSwitch?: boolean | undefined;
noImplicitAny?: boolean | undefined;
noImplicitReturns?: boolean | undefined;
noImplicitThis?: boolean | undefined;
noStrictGenericChecks?: boolean | undefined;
noUnusedLocals?: boolean | undefined;
noUnusedParameters?: boolean | undefined;
noImplicitUseStrict?: boolean | undefined;
noPropertyAccessFromIndexSignature?: boolean | undefined;
assumeChangesOnlyAffectDirectDependencies?: boolean | undefined;
noLib?: boolean | undefined;
noResolve?: boolean | undefined;
noUncheckedIndexedAccess?: boolean | undefined;
out?: string | undefined;
outFile?: string | undefined;
paths?: typescript.MapLike<string[]> | undefined;
preserveConstEnums?: boolean | undefined;
noImplicitOverride?: boolean | undefined;
preserveSymlinks?: boolean | undefined;
preserveValueImports?: boolean | undefined;
project?: string | undefined;
reactNamespace?: string | undefined;
jsxFactory?: string | undefined;
jsxFragmentFactory?: string | undefined;
jsxImportSource?: string | undefined;
composite?: boolean | undefined;
incremental?: boolean | undefined;
tsBuildInfoFile?: string | undefined;
removeComments?: boolean | undefined;
resolvePackageJsonExports?: boolean | undefined;
resolvePackageJsonImports?: boolean | undefined;
rootDir?: string | undefined;
rootDirs?: string[] | undefined;
skipLibCheck?: boolean | undefined;
skipDefaultLibCheck?: boolean | undefined;
sourceMap?: boolean | undefined;
sourceRoot?: string | undefined;
strict?: boolean | undefined;
strictFunctionTypes?: boolean | undefined;
strictBindCallApply?: boolean | undefined;
strictNullChecks?: boolean | undefined;
strictPropertyInitialization?: boolean | undefined;
stripInternal?: boolean | undefined;
suppressExcessPropertyErrors?: boolean | undefined;
suppressImplicitAnyIndexErrors?: boolean | undefined;
target?: typescript.ScriptTarget | undefined;
traceResolution?: boolean | undefined;
useUnknownInCatchVariables?: boolean | undefined;
resolveJsonModule?: boolean | undefined;
types?: string[] | undefined;
typeRoots?: string[] | undefined;
verbatimModuleSyntax?: boolean | undefined;
esModuleInterop?: boolean | undefined;
useDefineForClassFields?: boolean | undefined;
};
export declare function getBaseCompilerOptions(basePath: string, baseOptions: CompilerOptions): CompilerOptions;
/**

@@ -128,0 +25,0 @@ * Get the compiler options for the specified path and build type. It merges the

{
"name": "@ts-bridge/cli",
"version": "0.4.2",
"version": "0.4.3",
"description": "Bridge the gap between ES modules and CommonJS modules with an easy-to-use alternative to `tsc`.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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