Socket
Socket
Sign inDemoInstall

@hyrious/dts

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyrious/dts - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

66

cli.js
#!/usr/bin/env node
// node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
function escapeStringRegexp(string) {
if (typeof string !== "string") {
throw new TypeError("Expected a string");
}
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}
// node_modules/.pnpm/clean-stack@5.2.0/node_modules/clean-stack/home-directory.js
import os from "node:os";
var getHomeDirectory = () => os.homedir().replace(/\\/g, "/");
var home_directory_default = getHomeDirectory;
// node_modules/.pnpm/clean-stack@5.2.0/node_modules/clean-stack/index.js
var extractPathRegex = /\s+at.*[(\s](.*)\)?/;
var pathRegex = /^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;
function cleanStack(stack, { pretty = false, basePath, pathFilter } = {}) {
const basePathRegex = basePath && new RegExp(`(file://)?${escapeStringRegexp(basePath.replace(/\\/g, "/"))}/?`, "g");
const homeDirectory = pretty ? home_directory_default() : "";
if (typeof stack !== "string") {
return void 0;
}
return stack.replace(/\\/g, "/").split("\n").filter((line) => {
const pathMatches = line.match(extractPathRegex);
if (pathMatches === null || !pathMatches[1]) {
return true;
}
const match = pathMatches[1];
if (match.includes(".app/Contents/Resources/electron.asar") || match.includes(".app/Contents/Resources/default_app.asar") || match.includes("node_modules/electron/dist/resources/electron.asar") || match.includes("node_modules/electron/dist/resources/default_app.asar")) {
return false;
}
return pathFilter ? !pathRegex.test(match) && pathFilter(match) : !pathRegex.test(match);
}).filter((line) => line.trim() !== "").map((line) => {
if (basePathRegex) {
line = line.replace(basePathRegex, "");
}
if (pretty) {
line = line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDirectory, "~")));
}
return line;
}).join("\n");
}
// src/cli.ts
import sade from "sade";
// node_modules/.pnpm/yoctocolors@2.0.2/node_modules/yoctocolors/index.js
// node_modules/.pnpm/yoctocolors@2.1.1/node_modules/yoctocolors/base.js
import tty from "node:tty";
var hasColors = tty.WriteStream.prototype.hasColors();
var hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
var format = (open, close) => {

@@ -84,7 +41,17 @@ if (!hasColors) {

// package.json
var version = "0.2.3";
var name = "@hyrious/dts";
var version = "0.2.4";
var description = "Invoke rollup-plugin-dts to generate bundled .d.ts file";
// src/cli.ts
function error_exit(err) {
console.error(cleanStack(err.stack, { pretty: true, basePath: process.cwd() }));
if (err.loc) {
console.warn(`Error parsing: ${err.loc.file}:${err.loc.line}:${err.loc.column}`);
}
if (err.frame) {
console.warn(err.message);
console.warn(err.frame);
} else {
console.error(err.message || err.stack || err + "");
}
process.exit(1);

@@ -103,5 +70,6 @@ }

}
sade("dts").version(version).describe("Invoke rollup-plugin-dts to generate bundled .d.ts file").command("build [index.ts]", "Build a .d.ts file from a .ts file", { default: true }).option("-o, --outfile", "Output file").option("-i, --include", "Force include a module in the bundle").option("-e, --exclude", "Force exclude a module from the bundle").option("-p, --patch", "Patch rollup-plugin-dts to handle `/// doc comments`").example("src/index.ts -o dist/index.d.ts").action(async (entry, options) => {
sade(name).version(version).describe(description).command("build [index.ts]", "Build a .d.ts file from a .ts file", { default: true }).option("-o, --outfile", "Output file").option("-i, --include", "Force include a module in the bundle").option("-e, --exclude", "Force exclude a module from the bundle").option("-p, --patch", "Patch rollup-plugin-dts to handle `/// doc comments`").example("src/index.ts -o dist/index.d.ts").action(async (entry, options) => {
entry ||= guess_entry(process.cwd());
const outfile = options.outfile && String(options.outfile) || entry.replace(/\.tsx?$/, ".d.ts");
entry = entry.replace(/[\\]/g, "/");
const outfile = options.outfile && String(options.outfile) || entry.replace(/\.tsx?$/, ".d.ts").replace(/\bsrc\//, "dist/");
const include = to_array(options.include);

@@ -108,0 +76,0 @@ const exclude = to_array(options.exclude);

import { RollupOutput } from 'rollup';
import { Options } from 'rollup-plugin-dts';
declare const version = "0.2.3";
declare const version = "0.2.4";

@@ -6,0 +6,0 @@ interface BuildOptions {

@@ -29,3 +29,3 @@ // src/index.ts

// package.json
var version = "0.2.3";
var version = "0.2.4";

@@ -80,7 +80,6 @@ // src/index.ts

skipLibCheck: true,
stripInternal: true,
preserveSymlinks: false
stripInternal: true
};
async function build(entry, outfile, options = {}) {
const compilerOptions = Object.assign({}, options.dts?.compilerOptions, default_compiler_options);
const compilerOptions = Object.assign({}, default_compiler_options, options.dts?.compilerOptions);
const include = options.include || [];

@@ -87,0 +86,0 @@ const exclude = options.exclude || [];

{
"name": "@hyrious/dts",
"type": "module",
"version": "0.2.3",
"version": "0.2.4",
"description": "Invoke rollup-plugin-dts to generate bundled .d.ts file",

@@ -27,14 +27,13 @@ "author": "hyrious <hyrious@outlook.com>",

"@rollup/plugin-json": "^6.1.0",
"rollup": "^4.17.2",
"rollup": "^4.19.1",
"rollup-plugin-dts": "^6.1.1",
"sade": "^1.8.1",
"typescript": "^5.4.5"
"typescript": "^5.5.4"
},
"devDependencies": {
"@hyrious/esbuild-dev": "^0.10.5",
"@types/node": "^20.12.12",
"clean-stack": "^5.2.0",
"esbuild": "^0.21.3",
"@hyrious/esbuild-dev": "^0.10.6",
"@types/node": "^20.14.12",
"esbuild": "^0.23.0",
"escalade": "^3.1.2",
"yoctocolors": "^2.0.2"
"yoctocolors": "^2.1.1"
},

@@ -41,0 +40,0 @@ "scripts": {

@@ -13,2 +13,6 @@ # @hyrious/dts

### 0.2.4
- Remove `preserveSymlinks` config, which seems work differently than setting it.
### 0.2.0

@@ -15,0 +19,0 @@

@@ -1,2 +0,1 @@

import cleanStack from 'clean-stack'
import sade from 'sade'

@@ -9,3 +8,3 @@ import { bgBlue, black } from 'yoctocolors'

import { version } from '../package.json'
import { name, version, description } from '../package.json'

@@ -17,4 +16,12 @@ // Sade Handler with 1 positional argument

function error_exit(err: Error): never {
console.error(cleanStack(err.stack, { pretty: true, basePath: process.cwd() }))
function error_exit(err: any): never {
if (err.loc) {
console.warn(`Error parsing: ${err.loc.file}:${err.loc.line}:${err.loc.column}`)
}
if (err.frame) {
console.warn(err.message)
console.warn(err.frame)
} else {
console.error(err.message || err.stack || err + '')
}
process.exit(1)

@@ -36,5 +43,5 @@ }

sade('dts')
sade(name)
.version(version)
.describe('Invoke rollup-plugin-dts to generate bundled .d.ts file')
.describe(description)

@@ -49,3 +56,6 @@ .command('build [index.ts]', 'Build a .d.ts file from a .ts file', { default: true })

entry ||= guess_entry(process.cwd())
const outfile = (options.outfile && String(options.outfile)) || entry.replace(/\.tsx?$/, '.d.ts')
entry = entry.replace(/[\\]/g, '/')
const outfile =
(options.outfile && String(options.outfile)) ||
entry.replace(/\.tsx?$/, '.d.ts').replace(/\bsrc\//, 'dist/')
const include = to_array(options.include)

@@ -52,0 +62,0 @@ const exclude = to_array(options.exclude)

@@ -69,3 +69,2 @@ import type ts from 'typescript'

stripInternal: true,
preserveSymlinks: false,
}

@@ -93,3 +92,3 @@

): Promise<BuildResult> {
const compilerOptions = Object.assign({}, options.dts?.compilerOptions, default_compiler_options)
const compilerOptions = Object.assign({}, default_compiler_options, options.dts?.compilerOptions)
const include = options.include || []

@@ -96,0 +95,0 @@ const exclude = options.exclude || []

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