Socket
Socket
Sign inDemoInstall

ts-patch

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-patch - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

18

bin/cli.js

@@ -17,3 +17,7 @@ #!/usr/bin/env node

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -57,3 +61,3 @@ if (k2 === undefined) k2 = k;

check: {
short: 'c', caption: "Check patch status (use with " + chalk_1.default.cyanBright('--dir') + " to specify TS package location)"
short: 'c', caption: "Check patch status (use with ".concat(chalk_1.default.cyanBright('--dir'), " to specify TS package location)")
},

@@ -80,3 +84,3 @@ patch: {

var dots = chalk_1.default.grey('.'.repeat(COL_WIDTH - (0, strip_ansi_1.default)(leftCol).length));
return leftCol + " " + dots + " " + caption;
return "".concat(leftCol, " ").concat(dots, " ").concat(caption);
};

@@ -99,4 +103,4 @@ var menuText = LINE_INDENT + chalk_1.default.bold.blue('ts-patch [command] ') + chalk_1.default.blue('<options>') + '\r\n' + LINE_INDENT +

return formatLine([
short && "" + chalk_1.default.cyanBright('-' + short),
long && "" + chalk_1.default.cyanBright("" + (inverse ? '--no-' : '--') + long)
short && "".concat(chalk_1.default.cyanBright('-' + short)),
long && "".concat(chalk_1.default.cyanBright("".concat(inverse ? '--no-' : '--').concat(long)))
], caption, paramCaption);

@@ -152,3 +156,3 @@ })

chalk_1.default.bold.blue('ts-patch: ') + system_1.tspPackageJSON.version + '\r\n' +
chalk_1.default.bold.blue('typescript: ') + tsVersion + chalk_1.default.gray(" [" + packageDir + "]"), system_1.Log.system);
chalk_1.default.bold.blue('typescript: ') + tsVersion + chalk_1.default.gray(" [".concat(packageDir, "]")), system_1.Log.system);
case 'install':

@@ -172,3 +176,3 @@ return actions.install();

'!',
chalk_1.default.bold.yellow(e.name && (e.name !== 'Error') ? "[" + e.name + "]: " : 'Error: ') + chalk_1.default.red(e.message)
chalk_1.default.bold.yellow(e.name && (e.name !== 'Error') ? "[".concat(e.name, "]: ") : 'Error: ') + chalk_1.default.red(e.message)
], system_1.Log.system);

@@ -175,0 +179,0 @@ }

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

### [2.0.2](https://github.com/nonara/ts-patch/compare/v2.0.1...v2.0.2) (2022-08-10)
### Changes
* Upgraded dependencies ([a878131](https://github.com/nonara/ts-patch/commit/a87813190eb31b918574509e4dfe4ef3b427b212))
### [2.0.1](https://github.com/nonara/ts-patch/compare/v1.4.5...v2.0.1) (2021-11-01)

@@ -7,0 +14,0 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -19,3 +19,3 @@ import { TSModule } from './file-utils';

*/
export declare const setOptions: (opts?: Partial<TSPOptions> | undefined) => TSPOptions;
export declare const setOptions: (opts?: Partial<TSPOptions>) => TSPOptions;
/**

@@ -22,0 +22,0 @@ * Patch TypeScript modules

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -76,3 +80,3 @@ if (k2 === undefined) k2 = k;

catch (e) {
throw new system_1.BackupError(tsModule.filename, "Couldn't create backup directory. " + e.message);
throw new system_1.BackupError(tsModule.filename, "Couldn't create backup directory. ".concat(e.message));
}

@@ -101,6 +105,6 @@ if (shell.cp(tsModule.file, backupDir) && shell.error())

if (copyOrMove(file, tsPackage.libDir) && shell.error())
throw new system_1.RestoreError(filename, "Couldn't restore file - " + shell.error());
throw new system_1.RestoreError(filename, "Couldn't restore file - ".concat(shell.error()));
if (filename === 'typescript.js')
if (copyOrMove(path.join(dir, 'typescript.d.ts'), tsPackage.libDir) && shell.error())
throw new system_1.RestoreError(filename, "Couldn't restore file - " + shell.error());
throw new system_1.RestoreError(filename, "Couldn't restore file - ".concat(shell.error()));
/* Verify restored file */

@@ -114,3 +118,3 @@ var restoredModule = (0, file_utils_1.getTSModule)(currentModule.file);

if ((fs.readdirSync(backupDir).length < 1) && shell.rm('-rf', backupDir) && shell.error())
(0, system_1.Log)(['!', "Error deleting backup directory" + chalk_1.default.grey("[" + backupDir + "]")], system_1.Log.verbose);
(0, system_1.Log)(['!', "Error deleting backup directory" + chalk_1.default.grey("[".concat(backupDir, "]"))], system_1.Log.verbose);
}

@@ -154,3 +158,3 @@ // endregion

var _a = (0, file_utils_1.getTSPackage)(dir), libDir = _a.libDir, packageDir = _a.packageDir, version = _a.version;
(0, system_1.Log)("Checking TypeScript " + chalk_1.default.blueBright("v" + version) + " installation in " + chalk_1.default.blueBright(packageDir) + "\r\n");
(0, system_1.Log)("Checking TypeScript ".concat(chalk_1.default.blueBright("v".concat(version)), " installation in ").concat(chalk_1.default.blueBright(packageDir), "\r\n"));
var modules = parseFiles(fileOrFilesOrGlob, libDir);

@@ -162,9 +166,9 @@ for (var _i = 0, modules_1 = modules; _i < modules_1.length; _i++) {

(0, system_1.Log)(['+',
chalk_1.default.blueBright(filename) + " is patched with ts-patch version " +
(chalk_1.default[outOfDate ? 'redBright' : 'blueBright'](patchVersion) + " " + (outOfDate ? '(out of date)' : ''))
"".concat(chalk_1.default.blueBright(filename), " is patched with ts-patch version ") +
"".concat(chalk_1.default[outOfDate ? 'redBright' : 'blueBright'](patchVersion), " ").concat(outOfDate ? '(out of date)' : '')
]);
else if (canPatch)
(0, system_1.Log)(['-', chalk_1.default.blueBright(filename) + " is not patched."]);
(0, system_1.Log)(['-', "".concat(chalk_1.default.blueBright(filename), " is not patched.")]);
else
(0, system_1.Log)(['-', chalk_1.default.red(chalk_1.default.redBright(filename) + " is not patched and cannot be patched!")]);
(0, system_1.Log)(['-', chalk_1.default.red("".concat(chalk_1.default.redBright(filename), " is not patched and cannot be patched!"))]);
(0, system_1.Log)('', system_1.Log.verbose);

@@ -186,3 +190,3 @@ }

(0, system_1.Log)(['!',
"File" + (modules.length - 1 ? 's' : '') + " already patched with the latest version. For details, run: " +
"File".concat(modules.length - 1 ? 's' : '', " already patched with the latest version. For details, run: ") +
chalk_1.default.bgBlackBright('ts-patch check')

@@ -196,3 +200,3 @@ ]);

var file = m.file, filename = m.filename;
(0, system_1.Log)(['~', "Patching " + chalk_1.default.blueBright(filename) + " in " + chalk_1.default.blueBright(path.dirname(file))], system_1.Log.verbose);
(0, system_1.Log)(['~', "Patching ".concat(chalk_1.default.blueBright(filename), " in ").concat(chalk_1.default.blueBright(path.dirname(file)))], system_1.Log.verbose);
// If already patched, load backup module source. Otherwise, backup un-patched

@@ -206,3 +210,3 @@ if (m.patchVersion)

tsPackage.config.modules[filename] = fs.statSync(file).mtimeMs;
(0, system_1.Log)(['+', chalk_1.default.green("Successfully patched " + chalk_1.default.bold.yellow(filename) + ".\r\n")], system_1.Log.verbose);
(0, system_1.Log)(['+', chalk_1.default.green("Successfully patched ".concat(chalk_1.default.bold.yellow(filename), ".\r\n"))], system_1.Log.verbose);
}

@@ -213,3 +217,3 @@ tsPackage.config.save();

"Some files can't be patched! Try updating to a newer version of ts-patch. The following files are unable to be " +
("patched. [" + modules.unPatchable.map(function (f) { return f.filename; }).join(', ') + "]")
"patched. [".concat(modules.unPatchable.map(function (f) { return f.filename; }).join(', '), "]")
]);

@@ -228,3 +232,3 @@ return false;

if (modules.patched.length < 1) {
(0, system_1.Log)(['!', "File" + (modules.length - 1 ? 's' : '') + " not patched. For details, run: " + chalk_1.default.bgBlackBright('ts-patch check')]);
(0, system_1.Log)(['!', "File".concat(modules.length - 1 ? 's' : '', " not patched. For details, run: ") + chalk_1.default.bgBlackBright('ts-patch check')]);
return false;

@@ -237,7 +241,7 @@ }

var file = tsModule.file, filename = tsModule.filename;
(0, system_1.Log)(['~', "Restoring " + chalk_1.default.blueBright(filename) + " in " + chalk_1.default.blueBright(path.dirname(file))], system_1.Log.verbose);
(0, system_1.Log)(['~', "Restoring ".concat(chalk_1.default.blueBright(filename), " in ").concat(chalk_1.default.blueBright(path.dirname(file)))], system_1.Log.verbose);
try {
restore(tsModule, tsPackage);
delete tsPackage.config.modules[filename];
(0, system_1.Log)(['+', chalk_1.default.green("Successfully restored " + chalk_1.default.bold.yellow(filename) + ".\r\n")], system_1.Log.verbose);
(0, system_1.Log)(['+', chalk_1.default.green("Successfully restored ".concat(chalk_1.default.bold.yellow(filename), ".\r\n"))], system_1.Log.verbose);
}

@@ -264,3 +268,3 @@ catch (e) {

(0, system_1.Log)('');
throw new system_1.RestoreError("[" + Object.keys(errors).join(', ') + "]", 'Try reinstalling typescript.' +
throw new system_1.RestoreError("[".concat(Object.keys(errors).join(', '), "]"), 'Try reinstalling typescript.' +
(!verbose ? ' (Or, run uninstall again with --verbose for specific error detail)' : ''));

@@ -267,0 +271,0 @@ }

@@ -53,3 +53,3 @@ "use strict";

if (path_1.default.extname(file) !== '.js')
file = path_1.default.join(path_1.default.dirname(file), path_1.default.basename(file, path_1.default.extname(file)) + ".js");
file = path_1.default.join(path_1.default.dirname(file), "".concat(path_1.default.basename(file, path_1.default.extname(file)), ".js"));
return file;

@@ -73,3 +73,3 @@ };

if (!fs_1.default.existsSync(dir))
throw new system_1.PackageError(dir + " is not a valid directory");
throw new system_1.PackageError("".concat(dir, " is not a valid directory"));
var possiblePackageDirs = [dir, function () { return path_1.default.dirname(resolve_1.default.sync("typescript/package.json", { basedir: dir })); }];

@@ -93,3 +93,3 @@ var _loop_1 = function (d) {

catch (e) {
throw new system_1.PackageError("Could not parse json data in " + packageFile);
throw new system_1.PackageError("Could not parse json data in ".concat(packageFile));
}

@@ -109,3 +109,3 @@ })(), name = _b.name, version = _b.version;

}
throw new system_1.PackageError("Could not find typescript package from " + dir);
throw new system_1.PackageError("Could not find typescript package from ".concat(dir));
}

@@ -119,3 +119,3 @@ exports.getTSPackage = getTSPackage;

if (!fs_1.default.existsSync(file))
throw new system_1.FileNotFound("Could not find file " + file + ".");
throw new system_1.FileNotFound("Could not find file ".concat(file, "."));
var filename = path_1.default.basename(file);

@@ -122,0 +122,0 @@ var dir = path_1.default.dirname(file);

@@ -22,3 +22,3 @@ "use strict";

* ********************************************************************************************************************/
var getHeader = function () { return "/// tsp: " + system_1.tspPackageJSON.version + "\n\n"; };
var getHeader = function () { return "/// tsp: ".concat(system_1.tspPackageJSON.version, "\n\n"); };
/**

@@ -29,3 +29,3 @@ * Generate insertion code for module-patch

return jsPatchSrc +
("\nObject.assign(tsp, { isTSC: " + isTSC + ", tspVersion: '" + system_1.tspPackageJSON.version + "' });\n\n");
"\nObject.assign(tsp, { isTSC: ".concat(isTSC, ", tspVersion: '").concat(system_1.tspPackageJSON.version, "' });\n\n");
};

@@ -39,7 +39,7 @@ /**

if (!fs_1.default.existsSync(file))
throw new system_1.FileNotFound("Could not find module " + filename + " in " + (dir + path_1.default.sep));
throw new system_1.FileNotFound("Could not find module ".concat(filename, " in ").concat(dir + path_1.default.sep));
if (patchVersion && !outOfDate)
throw new system_1.PatchError("Module " + filename + " is already up-to-date with local version - v" + patchVersion);
throw new system_1.PatchError("Module ".concat(filename, " is already up-to-date with local version - v").concat(patchVersion));
if (!canPatch)
throw new system_1.PatchError("Module " + filename + " cannot be patched! No instance of TypeScript found.");
throw new system_1.PatchError("Module ".concat(filename, " cannot be patched! No instance of TypeScript found."));
}

@@ -57,3 +57,3 @@ if (tsPackage) {

if (funcPos < 0)
throw new Error("Bad TS Code. Could not find function emitFilesAndReportErrors in " + tsModule.filename);
throw new Error("Bad TS Code. Could not find function emitFilesAndReportErrors in ".concat(tsModule.filename));
var startCode = src.substr(0, funcPos);

@@ -71,3 +71,3 @@ var restCode = src.substr(funcPos);

restCode.substr(0, emitPos) +
("\nts.diagnosticMap.set(program, " + diagnosticsArrName + ");\n") +
"\nts.diagnosticMap.set(program, ".concat(diagnosticsArrName, ");\n") +
restCode.substr(emitPos);

@@ -74,0 +74,0 @@ };

@@ -95,3 +95,3 @@ "use strict";

function RestoreError(filename, message) {
var _this = _super.call(this, "Error restoring: " + filename + (message ? ' - ' + message : '')) || this;
var _this = _super.call(this, "Error restoring: ".concat(filename).concat(message ? ' - ' + message : '')) || this;
_this.filename = filename;

@@ -107,3 +107,3 @@ _this.name = 'RestoreError';

function BackupError(filename, message) {
var _this = _super.call(this, "Error backing up " + filename + (message ? ' - ' + message : '')) || this;
var _this = _super.call(this, "Error backing up ".concat(filename).concat(message ? ' - ' + message : '')) || this;
_this.filename = filename;

@@ -119,3 +119,3 @@ _this.name = 'BackupError';

function FileWriteError(filename, message) {
var _this = _super.call(this, "Error while trying to write to " + filename + (message ? ": " + message : '')) || this;
var _this = _super.call(this, "Error while trying to write to ".concat(filename).concat(message ? ": ".concat(message) : '')) || this;
_this.filename = filename;

@@ -122,0 +122,0 @@ return _this;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -22,3 +22,3 @@ "use strict";

/* Handle Icon */
var printIcon = function (icon) { return chalk_1.default.bold.cyanBright("[" + icon + "] "); };
var printIcon = function (icon) { return chalk_1.default.bold.cyanBright("[".concat(icon, "] ")); };
var icon = '';

@@ -25,0 +25,0 @@ if (Array.isArray(msg)) {

@@ -25,3 +25,3 @@ export declare type TSPOptions = typeof defaultOptions & {

*/
export declare const parseOptions: (options?: Partial<TSPOptions> | undefined) => TSPOptions;
export declare const resetOptions: (options?: Partial<TSPOptions> | undefined) => TSPOptions;
export declare const parseOptions: (options?: Partial<TSPOptions>) => TSPOptions;
export declare const resetOptions: (options?: Partial<TSPOptions>) => TSPOptions;
{
"name": "ts-patch",
"version": "2.0.1",
"version": "2.0.2",
"description": "Patch typescript to support custom transformers in tsconfig.json",

@@ -29,9 +29,9 @@ "main": "./index.js",

"dependencies": {
"chalk": "^4.1.0",
"glob": "^7.1.7",
"chalk": "^4.1.2",
"glob": "^8.0.3",
"global-prefix": "^3.0.0",
"minimist": "^1.2.5",
"resolve": "^1.20.0",
"shelljs": "^0.8.4",
"strip-ansi": "^6.0.0"
"minimist": "^1.2.6",
"resolve": "^1.22.1",
"shelljs": "^0.8.5",
"strip-ansi": "^6.0.1"
},

@@ -46,3 +46,43 @@ "bin": {

"resources": "./resources"
},
"standard-version": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": true
},
{
"type": "docs",
"hidden": true
},
{
"type": "style",
"hidden": true
},
{
"type": "refactor",
"hidden": true
},
{
"type": "perf",
"hidden": true
},
{
"type": "test",
"hidden": true
},
{
"type": "change",
"section": "Changes"
}
]
}
}

@@ -398,6 +398,6 @@ "use strict";

if (!factory)
throw new Error("tsconfig.json > plugins: \"" + transform + "\" does not have an export \"" + importKey + "\": " +
throw new Error("tsconfig.json > plugins: \"".concat(transform, "\" does not have an export \"").concat(importKey, "\": ") +
require("util").inspect(factoryModule));
if (typeof factory !== "function") {
throw new Error("tsconfig.json > plugins: \"" + transform + "\" export \"" + importKey + "\" is not a plugin: " +
throw new Error("tsconfig.json > plugins: \"".concat(transform, "\" export \"").concat(importKey, "\" is not a plugin: ") +
require("util").inspect(factory));

@@ -439,3 +439,3 @@ }

if (!ls)
throw new Error("Plugin " + transform + " needs a LanguageService");
throw new Error("Plugin ".concat(transform, " needs a LanguageService"));
ret = factory(ls, cleanConfig);

@@ -467,3 +467,3 @@ break;

default:
throw new Error("Invalid plugin type found in tsconfig.json: '" + config.type + "'");
throw new Error("Invalid plugin type found in tsconfig.json: '".concat(config.type, "'"));
}

@@ -470,0 +470,0 @@ if (typeof ret === "function")

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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