@rnx-kit/tools-node
Advanced tools
Comparing version 1.3.1 to 2.0.0
@@ -1,7 +0,6 @@ | ||
export { createDirectory, findFirstFileExists, isDirectory, isFile, statSync, } from "./fs"; | ||
export type { FileModuleRef, PackageModuleRef } from "./module"; | ||
export { getPackageModuleRefFromModulePath, isFileModuleRef, isPackageModuleRef, parseModuleRef, } from "./module"; | ||
export type { FileModuleRef, PackageModuleRef } from "./module"; | ||
export { findPackage, findPackageDependencyDir, findPackageDir, getMangledPackageName, isPackageManifest, parsePackageRef, readPackage, writePackage, } from "./package"; | ||
export type { FindPackageDependencyOptions, PackageManifest, PackagePerson, PackageRef, } from "./package"; | ||
export { escapePath, normalizePath } from "./path"; | ||
export { findPackage, findPackageDependencyDir, findPackageDir, parsePackageRef, readPackage, writePackage, } from "./package"; | ||
export { normalizePath } from "./path"; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizePath = exports.escapePath = exports.writePackage = exports.readPackage = exports.parsePackageRef = exports.isPackageManifest = exports.getMangledPackageName = exports.findPackageDir = exports.findPackageDependencyDir = exports.findPackage = exports.parseModuleRef = exports.isPackageModuleRef = exports.isFileModuleRef = exports.getPackageModuleRefFromModulePath = exports.statSync = exports.isFile = exports.isDirectory = exports.findFirstFileExists = exports.createDirectory = void 0; | ||
var fs_1 = require("./fs"); | ||
Object.defineProperty(exports, "createDirectory", { enumerable: true, get: function () { return fs_1.createDirectory; } }); | ||
Object.defineProperty(exports, "findFirstFileExists", { enumerable: true, get: function () { return fs_1.findFirstFileExists; } }); | ||
Object.defineProperty(exports, "isDirectory", { enumerable: true, get: function () { return fs_1.isDirectory; } }); | ||
Object.defineProperty(exports, "isFile", { enumerable: true, get: function () { return fs_1.isFile; } }); | ||
Object.defineProperty(exports, "statSync", { enumerable: true, get: function () { return fs_1.statSync; } }); | ||
exports.normalizePath = exports.writePackage = exports.readPackage = exports.parsePackageRef = exports.findPackageDir = exports.findPackageDependencyDir = exports.findPackage = exports.parseModuleRef = exports.isPackageModuleRef = exports.isFileModuleRef = exports.getPackageModuleRefFromModulePath = void 0; | ||
var module_1 = require("./module"); | ||
@@ -19,4 +13,2 @@ Object.defineProperty(exports, "getPackageModuleRefFromModulePath", { enumerable: true, get: function () { return module_1.getPackageModuleRefFromModulePath; } }); | ||
Object.defineProperty(exports, "findPackageDir", { enumerable: true, get: function () { return package_1.findPackageDir; } }); | ||
Object.defineProperty(exports, "getMangledPackageName", { enumerable: true, get: function () { return package_1.getMangledPackageName; } }); | ||
Object.defineProperty(exports, "isPackageManifest", { enumerable: true, get: function () { return package_1.isPackageManifest; } }); | ||
Object.defineProperty(exports, "parsePackageRef", { enumerable: true, get: function () { return package_1.parsePackageRef; } }); | ||
@@ -26,4 +18,3 @@ Object.defineProperty(exports, "readPackage", { enumerable: true, get: function () { return package_1.readPackage; } }); | ||
var path_1 = require("./path"); | ||
Object.defineProperty(exports, "escapePath", { enumerable: true, get: function () { return path_1.escapePath; } }); | ||
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return path_1.normalizePath; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ import type { PackageRef } from "./package"; | ||
*/ | ||
export declare type PackageModuleRef = PackageRef & { | ||
export type PackageModuleRef = PackageRef & { | ||
path?: string; | ||
@@ -15,3 +15,3 @@ }; | ||
*/ | ||
export declare type FileModuleRef = { | ||
export type FileModuleRef = { | ||
path: string; | ||
@@ -18,0 +18,0 @@ }; |
@@ -24,3 +24,3 @@ "use strict"; | ||
const indexPath = ref.name.indexOf("/"); | ||
if (indexPath > -1) { | ||
if (indexPath >= 0) { | ||
const p = ref.name.substring(indexPath + 1); | ||
@@ -27,0 +27,0 @@ if (p) { |
/** | ||
* Components of a package reference. | ||
*/ | ||
export declare type PackageRef = { | ||
export type PackageRef = { | ||
scope?: string; | ||
@@ -17,12 +17,5 @@ name: string; | ||
/** | ||
* Get the mangled name for a package reference. | ||
* | ||
* @param ref Package reference | ||
* @returns Mangled name | ||
*/ | ||
export declare function getMangledPackageName(ref: PackageRef): string; | ||
/** | ||
* Schema for a reference to a person in `package.json`. | ||
*/ | ||
export declare type PackagePerson = string | { | ||
export type PackagePerson = string | { | ||
name: string; | ||
@@ -35,3 +28,3 @@ email?: string; | ||
*/ | ||
export declare type PackageManifest = { | ||
export type PackageManifest = { | ||
name: string; | ||
@@ -51,9 +44,2 @@ version: string; | ||
/** | ||
* Determine if the given object is a `package.json` manifest. | ||
* | ||
* @param manifest Object to evaluate | ||
* @returns `true` if the object is a manifest | ||
*/ | ||
export declare function isPackageManifest(manifest: unknown): manifest is PackageManifest; | ||
/** | ||
* Read a `package.json` manifest from a file. | ||
@@ -98,3 +84,3 @@ * | ||
*/ | ||
export declare type FindPackageDependencyOptions = { | ||
export type FindPackageDependencyOptions = { | ||
/** | ||
@@ -101,0 +87,0 @@ * Optional starting directory for the search. Defaults to `process.cwd()`. |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findPackageDependencyDir = exports.findPackageDir = exports.findPackage = exports.writePackage = exports.readPackage = exports.isPackageManifest = exports.getMangledPackageName = exports.parsePackageRef = void 0; | ||
exports.findPackageDependencyDir = exports.findPackageDir = exports.findPackage = exports.writePackage = exports.readPackage = exports.parsePackageRef = void 0; | ||
const properties_1 = require("@rnx-kit/tools-language/properties"); | ||
@@ -68,28 +68,2 @@ const find_up_1 = __importDefault(require("find-up")); | ||
/** | ||
* Get the mangled name for a package reference. | ||
* | ||
* @param ref Package reference | ||
* @returns Mangled name | ||
*/ | ||
function getMangledPackageName(ref) { | ||
if (ref.scope) { | ||
return ref.scope.slice(1) + "__" + ref.name; | ||
} | ||
return ref.name; | ||
} | ||
exports.getMangledPackageName = getMangledPackageName; | ||
/** | ||
* Determine if the given object is a `package.json` manifest. | ||
* | ||
* @param manifest Object to evaluate | ||
* @returns `true` if the object is a manifest | ||
*/ | ||
function isPackageManifest(manifest) { | ||
return (typeof manifest === "object" && | ||
manifest !== null && | ||
"name" in manifest && | ||
"version" in manifest); | ||
} | ||
exports.isPackageManifest = isPackageManifest; | ||
/** | ||
* Resolve a package path to a file reference by appending `package.json`, if needed. | ||
@@ -96,0 +70,0 @@ * |
/** | ||
* Escape a path by replacing each backslash ('\\') with a double-backslash ("\\\\"). | ||
* | ||
* @param p Path to escape | ||
* @returns Escaped path | ||
*/ | ||
export declare function escapePath(p: string): string; | ||
/** | ||
* Normalize the separators in a path, converting each backslash ('\\') to a foreward | ||
@@ -10,0 +3,0 @@ * slash ('/'). |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizePath = exports.escapePath = void 0; | ||
exports.normalizePath = void 0; | ||
/** | ||
* Escape a path by replacing each backslash ('\\') with a double-backslash ("\\\\"). | ||
* | ||
* @param p Path to escape | ||
* @returns Escaped path | ||
*/ | ||
function escapePath(p) { | ||
return p.replace(/\\/g, "\\\\"); | ||
} | ||
exports.escapePath = escapePath; | ||
/** | ||
* Normalize the separators in a path, converting each backslash ('\\') to a foreward | ||
@@ -16,0 +6,0 @@ * slash ('/'). |
{ | ||
"name": "@rnx-kit/tools-node", | ||
"version": "1.3.1", | ||
"version": "2.0.0", | ||
"description": "A collection of supplemental NodeJS functions and types", | ||
@@ -9,10 +9,8 @@ "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/tools-node#readme", | ||
"lib/*", | ||
"fs.js", | ||
"fs.d.ts", | ||
"module.d.ts", | ||
"module.js", | ||
"module.d.ts", | ||
"package.d.ts", | ||
"package.js", | ||
"package.d.ts", | ||
"path.js", | ||
"path.d.ts" | ||
"path.d.ts", | ||
"path.js" | ||
], | ||
@@ -34,3 +32,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@rnx-kit/tools-language": "^1.2.6", | ||
"@rnx-kit/tools-language": "^2.0.0", | ||
"find-up": "^5.0.0", | ||
@@ -43,5 +41,7 @@ "pkg-dir": "^5.0.0", | ||
"@types/node": "^16.0.0", | ||
"jest": "^27.0.0", | ||
"jest-extended": "^2.0.0", | ||
"temp-dir": "^2.0.0" | ||
"eslint": "^8.0.0", | ||
"jest": "^29.0.0", | ||
"prettier": "^2.8.0", | ||
"temp-dir": "^2.0.0", | ||
"typescript": "^5.0.0" | ||
}, | ||
@@ -52,7 +52,4 @@ "eslintConfig": { | ||
"jest": { | ||
"preset": "@rnx-kit/scripts", | ||
"setupFilesAfterEnv": [ | ||
"jest-extended/all" | ||
] | ||
"preset": "@rnx-kit/scripts" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
<!--remove-block start--> | ||
# @rnx-kit/tools-node | ||
@@ -8,4 +6,2 @@ | ||
<!--remove-block end--> | ||
`@rnx-kit/tools-node` is a collection of supplemental NodeJS functions and | ||
@@ -38,24 +34,16 @@ types. | ||
| Category | Function | Description | | ||
| -------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | | ||
| fs | `createDirectory(p)` | Create a directory, and all missing parent directories. | | ||
| fs | `findFirstFileExists(rootDir, ...relativeFiles)` | Combine the root directory with each relative file, testing whether or not the file exists. Stop and return as soon as a file is found. | | ||
| fs | `isDirectory(p)` | Determine if the target path refers to a directory. | | ||
| fs | `isFile(p)` | Determine if the target path refers to a file. | | ||
| fs | `statSync(p)` | Get stats (detailed information) for the target path. | | ||
| module | `getPackageModuleRefFromModulePath(modulePath)` | Convert a module path to a package module reference. | | ||
| module | `isFileModuleRef(r)` | Is the module reference relative to a file location? | | ||
| module | `isPackageModuleRef(r)` | Is the module reference a package module reference? | | ||
| module | `parseModuleRef(r)` | Parse a module reference into either a package module reference or a file module reference. | | ||
| package | `findPackage(startDir)` | Find the nearest `package.json` manifest file. Search upward through all parent directories. | | ||
| package | `findPackageDependencyDir(ref, options)` | Find the package dependency's directory, starting from the given directory and moving outward, through all parent directories. | | ||
| package | `findPackageDir(startDir)` | Find the parent directory of the nearest `package.json` manifest file. Search upward through all parent directories. | | ||
| package | `getMangledPackageName(ref)` | Get the mangled name for a package reference. | | ||
| package | `isPackageManifest(manifest)` | Determine if the given object is a `package.json` manifest. | | ||
| package | `parsePackageRef(r)` | Parse a package reference string. An example reference is the `name` property found in `package.json`. | | ||
| package | `readPackage(pkgPath)` | Read a `package.json` manifest from a file. | | ||
| package | `writePackage(pkgPath, manifest, space)` | Write a `package.json` manifest to a file. | | ||
| path | `escapePath(p)` | Escape a path by replacing each backslash ('\\') with a double-backslash ("\\\\"). | | ||
| path | `normalizePath(p)` | Normalize the separators in a path, converting each backslash ('\\') to a foreward slash ('/'). | | ||
| Category | Function | Description | | ||
| -------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | ||
| module | `getPackageModuleRefFromModulePath(modulePath)` | Convert a module path to a package module reference. | | ||
| module | `isFileModuleRef(r)` | Is the module reference relative to a file location? | | ||
| module | `isPackageModuleRef(r)` | Is the module reference a package module reference? | | ||
| module | `parseModuleRef(r)` | Parse a module reference into either a package module reference or a file module reference. | | ||
| package | `findPackage(startDir)` | Find the nearest `package.json` manifest file. Search upward through all parent directories. | | ||
| package | `findPackageDependencyDir(ref, options)` | Find the package dependency's directory, starting from the given directory and moving outward, through all parent directories. | | ||
| package | `findPackageDir(startDir)` | Find the parent directory of the nearest `package.json` manifest file. Search upward through all parent directories. | | ||
| package | `parsePackageRef(r)` | Parse a package reference string. An example reference is the `name` property found in `package.json`. | | ||
| package | `readPackage(pkgPath)` | Read a `package.json` manifest from a file. | | ||
| package | `writePackage(pkgPath, manifest, space)` | Write a `package.json` manifest to a file. | | ||
| path | `normalizePath(p)` | Normalize the separators in a path, converting each backslash ('\\') to a foreward slash ('/'). | | ||
<!-- @rnx-kit/api end --> |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
31932
7
24
435
48
+ Added@rnx-kit/tools-language@2.0.1(transitive)
- Removed@rnx-kit/tools-language@1.4.2(transitive)