Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
22
node_modules/cmake-js/LICENSE
generated
vendored
Normal file
22
node_modules/cmake-js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Gábor Mező aka unbornchikken
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
403
node_modules/cmake-js/README.md
generated
vendored
Normal file
403
node_modules/cmake-js/README.md
generated
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
# CMake.js (MIT)
|
||||
|
||||
[](https://github.com/cmake-js/cmake-js/actions/workflows/node.yaml)
|
||||
[](https://www.npmjs.com/package/cmake-js)
|
||||
|
||||
## About
|
||||
|
||||
CMake.js is a Node.js native addon build tool which works (almost) _exactly_ like [node-gyp](https://github.com/TooTallNate/node-gyp), but instead of [gyp](http://en.wikipedia.org/wiki/GYP_%28software%29), it is based on [CMake](http://cmake.org) build system. It's compatible with the following runtimes:
|
||||
|
||||
- Node.js 14.15+ since CMake.js v7.0.0 (for older runtimes please use an earlier version of CMake.js). Newer versions can produce builds targeting older runtimes
|
||||
- [NW.js](https://github.com/nwjs/nw.js): all CMake.js based native modules are compatible with NW.js out-of-the-box, there is no [nw-gyp like magic](https://github.com/nwjs/nw.js/wiki/Using-Node-modules#3rd-party-modules-with-cc-addons) required
|
||||
- [Electron](https://github.com/electron/electron): out-of-the-box build support, [no post build steps required](https://github.com/electron/electron/blob/main/docs/tutorial/using-native-node-modules.md)
|
||||
|
||||
If you use `node-api` for your module instead of `nan` it should be able to run on all the runtimes above without needing to be built separately for each.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install cmake-js
|
||||
```
|
||||
|
||||
**Help:**
|
||||
|
||||
```bash
|
||||
cmake-js --help
|
||||
```
|
||||
|
||||
```
|
||||
Usage: cmake-js [<command>] [options]
|
||||
|
||||
Commands:
|
||||
cmake-js install Install Node.js distribution files if needed
|
||||
cmake-js configure Configure CMake project
|
||||
cmake-js print-configure Print the configuration command
|
||||
cmake-js print-cmakejs-src Print the value of the CMAKE_JS_SRC variable
|
||||
cmake-js print-cmakejs-include Print the value of the CMAKE_JS_INC variable
|
||||
cmake-js print-cmakejs-lib Print the value of the CMAKE_JS_LIB variable
|
||||
cmake-js build Build the project (will configure first if
|
||||
required)
|
||||
cmake-js print-build Print the build command
|
||||
cmake-js clean Clean the project directory
|
||||
cmake-js print-clean Print the clean command
|
||||
cmake-js reconfigure Clean the project directory then configure the
|
||||
project
|
||||
cmake-js rebuild Clean the project directory then build the
|
||||
project
|
||||
cmake-js compile Build the project, and if build fails, try a
|
||||
full rebuild
|
||||
|
||||
Options:
|
||||
--version Show version number [boolean]
|
||||
-h, --help Show help [boolean]
|
||||
-l, --log-level set log level (silly, verbose, info, http, warn,
|
||||
error), default is info [string]
|
||||
-d, --directory specify CMake project's directory (where CMakeLists.txt
|
||||
located) [string]
|
||||
-D, --debug build debug configuration [boolean]
|
||||
-B, --config specify build configuration (Debug, RelWithDebInfo,
|
||||
Release), will ignore '--debug' if specified [string]
|
||||
-c, --cmake-path path of CMake executable [string]
|
||||
-m, --prefer-make use Unix Makefiles even if Ninja is available (Posix)
|
||||
[boolean]
|
||||
-x, --prefer-xcode use Xcode instead of Unix Makefiles [boolean]
|
||||
-g, --prefer-gnu use GNU compiler instead of default CMake compiler, if
|
||||
available (Posix) [boolean]
|
||||
-G, --generator use specified generator [string]
|
||||
-t, --toolset use specified toolset [string]
|
||||
-A, --platform use specified platform name [string]
|
||||
-T, --target only build the specified target [string]
|
||||
-C, --prefer-clang use Clang compiler instead of default CMake compiler,
|
||||
if available (Posix) [boolean]
|
||||
--cc use the specified C compiler [string]
|
||||
--cxx use the specified C++ compiler [string]
|
||||
-r, --runtime the runtime to use [string]
|
||||
-v, --runtime-version the runtime version to use [string]
|
||||
-a, --arch the architecture to build in [string]
|
||||
-p, --parallel the number of threads cmake can use [number]
|
||||
--CD Custom argument passed to CMake in format:
|
||||
-D<your-arg-here> [string]
|
||||
-i, --silent Prevents CMake.js to print to the stdio [boolean]
|
||||
-O, --out Specify the output directory to compile to, default is
|
||||
projectRoot/build [string]
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
|
||||
- [CMake](http://www.cmake.org/download/)
|
||||
- A proper C/C++ compiler toolchain of the given platform
|
||||
- **Windows**:
|
||||
- [Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/). If you installed nodejs with the installer, you can install these when prompted.
|
||||
- An alternate way is to install the [Chocolatey package manager](https://chocolatey.org/install), and run `choco install visualstudio2017-workload-vctools` in an Administrator Powershell
|
||||
- If you have multiple versions installed, you can select a specific version with `npm config set msvs_version 2017` (Note: this will also affect `node-gyp`)
|
||||
- **Unix/Posix**:
|
||||
- Clang or GCC
|
||||
- Ninja or Make (Ninja will be picked if both present)
|
||||
|
||||
## Usage
|
||||
|
||||
### General
|
||||
|
||||
It is advised to use Node-API for new projects instead of NAN. It provides ABI stability making usage simpler and reducing maintainance.
|
||||
|
||||
- Install cmake-js for your module `npm install --save cmake-js`
|
||||
- Put a CMakeLists.txt file into your module root with this minimal required content:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.15...3.31)
|
||||
project(your-addon-name-here)
|
||||
|
||||
add_compile_definitions(NAPI_VERSION=4)
|
||||
|
||||
file(GLOB SOURCE_FILES "your-source-files-location-here")
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB})
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
|
||||
|
||||
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
|
||||
# Generate node.lib
|
||||
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
||||
endif()
|
||||
```
|
||||
|
||||
- Add the following into your package.json scripts section:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"install": "cmake-js compile"
|
||||
}
|
||||
```
|
||||
|
||||
- Add the following into your package.json, using the same NAPI_VERSION value you provided to cmake
|
||||
|
||||
```json
|
||||
"binary": {
|
||||
"napi_versions": [7]
|
||||
},
|
||||
```
|
||||
|
||||
#### Commandline
|
||||
|
||||
With cmake-js installed as a depdendency or devDependency of your module, you can access run commands directly with:
|
||||
|
||||
```
|
||||
npx cmake-js --help
|
||||
# OR
|
||||
yarn cmake-js --help
|
||||
```
|
||||
|
||||
Please refer to the `--help` for the lists of available commands (they are like commands in `node-gyp`).
|
||||
|
||||
You can override the project default runtimes via `--runtime` and `--runtime-version`, such as: `--runtime=electron --runtime-version=0.26.0`. See below for more info on runtimes.
|
||||
|
||||
### CMake Specific
|
||||
|
||||
`CMAKE_JS_VERSION` variable will reflect the actual CMake.js version. So CMake.js based builds could be detected, eg.:
|
||||
|
||||
```cmake
|
||||
if (CMAKE_JS_VERSION)
|
||||
add_subdirectory(node_addon)
|
||||
else()
|
||||
add_subdirectory(other_subproject)
|
||||
endif()
|
||||
```
|
||||
|
||||
### NPM Config Integration
|
||||
|
||||
You can set npm configuration options for CMake.js.
|
||||
|
||||
For all users (global):
|
||||
|
||||
```
|
||||
npm config set cmake_<key> <value> --global
|
||||
```
|
||||
|
||||
For current user:
|
||||
|
||||
```
|
||||
npm config set cmake_<key> <value>
|
||||
```
|
||||
|
||||
CMake.js will set a variable named `"<key>"` to `<value>` (by using `-D<key>="<value>"` option). User settings will **overwrite** globals.
|
||||
|
||||
UPDATE:
|
||||
|
||||
You can set CMake.js command line arguments with npm config using the following pattern:
|
||||
|
||||
```
|
||||
npm config set cmake_js_G "Visual Studio 56 Win128"
|
||||
```
|
||||
|
||||
Which sets the CMake generator, basically defaults to:
|
||||
|
||||
```
|
||||
cmake-js -G "Visual Studio 56 Win128"
|
||||
```
|
||||
|
||||
#### Example:
|
||||
|
||||
Enter at command prompt:
|
||||
|
||||
```
|
||||
npm config set cmake_Foo="bar"
|
||||
```
|
||||
|
||||
Then write to your CMakeLists.txt the following:
|
||||
|
||||
```cmake
|
||||
message (STATUS ${Foo})
|
||||
```
|
||||
|
||||
This will print during configure:
|
||||
|
||||
```
|
||||
--- bar
|
||||
```
|
||||
|
||||
### Custom CMake options
|
||||
|
||||
You can add custom CMake options by beginning option name with `CD`.
|
||||
|
||||
#### Example
|
||||
|
||||
In command prompt:
|
||||
|
||||
```
|
||||
cmake-js compile --CDFOO="bar"
|
||||
```
|
||||
|
||||
Then in your CMakeLists.txt:
|
||||
|
||||
```cmake
|
||||
message (STATUS ${FOO})
|
||||
```
|
||||
|
||||
This will print during configure:
|
||||
|
||||
```
|
||||
--- bar
|
||||
```
|
||||
|
||||
### Runtimes
|
||||
|
||||
#### Important
|
||||
|
||||
It is important to understand that this setting is to be configured in the **application's root package.json file**. If you're creating a native module targeting nw.js for example, then **do not specify anything** in your module's package.json. It's the actual application's decision to specify its runtime, your module's just compatible anything that was mentioned in the [About chapter](#about). Actually defining `cmake-js` key in your module's package.json file may lead to an error. Why? If you set it up to use nw.js 0.12.1 for example, then when it gets compiled during development time (to run its unit tests for example) it's gonna be compiled against io.js 1.2 runtime. But if you're having io.js 34.0.1 at the command line then, which is binary incompatible with 1.2, then your unit tests will fail for sure. So it is advised to not use cmake-js target settings in your module's package.json, because that way CMake.js will use that you have, and your tests will pass.
|
||||
|
||||
#### Configuration
|
||||
|
||||
If any of the `runtime`, `runtimeVersion`, or `arch` configuration parameters is not explicitly configured, sensible defaults will be auto-detected based on the JavaScript environment where CMake.js runs within.
|
||||
|
||||
You can configure runtimes for compiling target for all depending CMake.js modules in an application. Define a `cmake-js` key in the application's root `package.json` file, eg.:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "ta-taram-taram",
|
||||
"description": "pa-param-pam-pam",
|
||||
"version": "1.0.0",
|
||||
"main": "app.js",
|
||||
"cmake-js": {
|
||||
"runtime": "node",
|
||||
"runtimeVersion": "0.12.0",
|
||||
"arch": "ia32"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Available settings:
|
||||
|
||||
- **runtime**: application's target runtime, possible values are:
|
||||
- `node`: Node.js
|
||||
- `nw`: nw.js
|
||||
- `electron`: Electron
|
||||
- **runtimeVersion**: version of the application's target runtime, for example: `0.12.1`
|
||||
- **arch**: architecture of application's target runtime (eg: `x64`, `ia32`, `arm64`, `arm`). _Notice: on non-Windows systems the C++ toolset's architecture's gonna be used despite this setting. If you don't specify this on Windows, then architecture of the main node runtime is gonna be used, so you have to choose a matching nw.js runtime._
|
||||
|
||||
#### Node-API and `node-addon-api`
|
||||
|
||||
[ABI-stable Node.js API
|
||||
(Node-API)](https://nodejs.org/api/n-api.html#n_api_node_api),
|
||||
which was previously known as N-API, supplies a set of C
|
||||
APIs that allow to compilation and loading of native modules by
|
||||
different versions of Node.js that support Node-API which includes
|
||||
all versions of Node.js v10.x and later.
|
||||
|
||||
To compile a native module that uses only the
|
||||
[plain `C` Node-API calls](https://nodejs.org/api/n-api.html#n_api_node_api),
|
||||
follow the directions for plain `node` native modules.
|
||||
|
||||
You must also add the following lines to your CMakeLists.txt, to allow for building on windows
|
||||
|
||||
```
|
||||
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
|
||||
# Generate node.lib
|
||||
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
||||
endif()
|
||||
```
|
||||
|
||||
To compile a native module that uses the header-only C++ wrapper
|
||||
classes provided by
|
||||
[`node-addon-api`](https://github.com/nodejs/node-addon-api),
|
||||
you need to make your package depend on it with:
|
||||
|
||||
npm install --save node-addon-api
|
||||
|
||||
cmake-js will then add it to the include search path automatically
|
||||
|
||||
You should add the following to your package.json, with the correct version number, so that cmake-js knows the module is node-api and that it can skip downloading the nodejs headers
|
||||
|
||||
```json
|
||||
"binary": {
|
||||
"napi_versions": [7]
|
||||
},
|
||||
```
|
||||
|
||||
#### Electron
|
||||
|
||||
On Windows, the [`win_delay_load_hook`](https://www.electronjs.org/docs/tutorial/using-native-node-modules#a-note-about-win_delay_load_hook) is required to be embedded in the module or it will fail to load in the render process.
|
||||
cmake-js will add the hook if the CMakeLists.txt contains the library `${CMAKE_JS_SRC}`.
|
||||
|
||||
Without the hook, the module can only be called from the render process using the Electron [remote](https://github.com/electron/electron/blob/master/docs/api/remote.md) module.
|
||||
|
||||
#### Runtime options in CMakeLists.txt
|
||||
|
||||
The actual node runtime parameters are detectable in CMakeLists.txt files, the following variables are set:
|
||||
|
||||
- **NODE_RUNTIME**: `"node"`, `"nw"`, `"electron"`
|
||||
- **NODE_RUNTIMEVERSION**: for example: `"0.12.1"`
|
||||
- **NODE_ARCH**: `"x64"`, `"ia32"`, `"arm64"`, `"arm"`
|
||||
|
||||
#### NW.js
|
||||
|
||||
To make compatible your NW.js application with any NAN CMake.js based modules, write the following to your application's package.json file (this is not neccessary for node-api modules):
|
||||
|
||||
```json
|
||||
{
|
||||
"cmake-js": {
|
||||
"runtime": "nw",
|
||||
"runtimeVersion": "nw.js-version-here",
|
||||
"arch": "whatever-setting-is-appropriate-for-your-application's-windows-build"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
That's it. There is nothing else to do either on the application's or on the module's side, CMake.js modules are compatible with NW.js out-of-the-box.
|
||||
|
||||
#### Heroku
|
||||
|
||||
[Heroku](https://heroku.com) uses the concept of a [buildpack](https://devcenter.heroku.com/articles/buildpacks) to define
|
||||
how an application should be prepared to run in a [dyno](https://devcenter.heroku.com/articles/dynos).
|
||||
The typical buildpack for note-based applications,
|
||||
[heroku/nodejs](https://github.com/heroku/heroku-buildpack-nodejs),
|
||||
provides an environment capable of running [node-gyp](https://github.com/TooTallNate/node-gyp),
|
||||
but not [CMake](http://cmake.org).
|
||||
|
||||
The least "painful" way of addressing this is to use heroku's multipack facility:
|
||||
|
||||
- Set the applications' buildpack to
|
||||
[https://github.com/heroku/heroku-buildpack-multi.git](https://github.com/heroku/heroku-buildpack-multi.git)
|
||||
|
||||
- In the root directory of the application,
|
||||
create a file called `.buildpacks` with these two lines:
|
||||
|
||||
https://github.com/brave/heroku-cmake-buildpack.git
|
||||
https://github.com/heroku/heroku-buildpack-nodejs.git
|
||||
|
||||
- Deploy the application to have the changes take effect
|
||||
|
||||
The `heroku-buildpack-multi` will run each buildpack in order allowing the node application to reference CMake in the Heroku
|
||||
build environment.
|
||||
|
||||
## Using external C/C++ libraries
|
||||
|
||||
Because you are using CMake, there are many ways to load libraries in your CMakeLists.txt.
|
||||
Various places on the internet and in the CMake docs will suggest various approaches you can take. Common ones are:
|
||||
* [conan](https://conan.io/) (This may not work properly currently; we hope to improve support in a future release)
|
||||
* [vcpkg](https://vcpkg.io/) (This may not work properly currently; we hope to improve support in a future release)
|
||||
* [hunter](https://github.com/cpp-pm/hunter)
|
||||
* [CMake ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html)
|
||||
* If on linux, using system libraries from the system package-manager
|
||||
* Importing as a git submodule
|
||||
|
||||
We aim to be agnostic about how to use CMake, so it should be possible to use whatever approach you desire.
|
||||
|
||||
## Real examples
|
||||
|
||||
- [@julusian/jpeg-turbo](https://github.com/julusian/node-jpeg-turbo) - A Node-API wrapping around libjpeg-turbo. cmake-js was a good fit here, as libjpeg-turbo provides cmake files that can be used, and would be hard to replicate correctly in node-gyp
|
||||
- [node-datachannel](https://github.com/murat-dogan/node-datachannel) - Easy to use WebRTC data channels and media transport
|
||||
- [aws-iot-device-sdk-v2](https://github.com/aws/aws-iot-device-sdk-js-v2) AWS IoT Device SDK for JavaScript v2
|
||||
|
||||
Open a PR to add your own project here.
|
||||
|
||||
## Changelog
|
||||
|
||||
View [changelog.md](changelog.md)
|
||||
|
||||
## Credits
|
||||
|
||||
https://github.com/cmake-js/cmake-js/graphs/contributors
|
||||
|
||||
Ty all!
|
||||
342
node_modules/cmake-js/bin/cmake-js
generated
vendored
Executable file
342
node_modules/cmake-js/bin/cmake-js
generated
vendored
Executable file
@@ -0,0 +1,342 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
const log = require('../lib/logger')
|
||||
const BuildSystem = require('../').BuildSystem
|
||||
const util = require('util')
|
||||
const version = require('../package').version
|
||||
const logLevels = ['silly', 'verbose', 'info', 'http', 'warn', 'error']
|
||||
|
||||
const npmConfigData = require('rc')('npm')
|
||||
for (const [key, value] of Object.entries(npmConfigData)) {
|
||||
if (key.startsWith('cmake_js_')) {
|
||||
const option = key.substr(9)
|
||||
if (option.length === 1) {
|
||||
process.argv.push('-' + option)
|
||||
} else {
|
||||
process.argv.push('--' + option)
|
||||
}
|
||||
if (value) {
|
||||
process.argv.push(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const yargs = require('yargs')
|
||||
.usage('CMake.js ' + version + '\n\nUsage: $0 [<command>] [options]')
|
||||
.version(version)
|
||||
.command('install', 'Install Node.js distribution files if needed')
|
||||
.command('configure', 'Configure CMake project')
|
||||
.command('print-configure', 'Print the configuration command')
|
||||
.command('print-cmakejs-src', 'Print the value of the CMAKE_JS_SRC variable')
|
||||
.command('print-cmakejs-include', 'Print the value of the CMAKE_JS_INC variable')
|
||||
.command('print-cmakejs-lib', 'Print the value of the CMAKE_JS_LIB variable')
|
||||
.command('build', 'Build the project (will configure first if required)')
|
||||
.command('print-build', 'Print the build command')
|
||||
.command('clean', 'Clean the project directory')
|
||||
.command('print-clean', 'Print the clean command')
|
||||
.command('reconfigure', 'Clean the project directory then configure the project')
|
||||
.command('rebuild', 'Clean the project directory then build the project')
|
||||
.command('compile', 'Build the project, and if build fails, try a full rebuild')
|
||||
.options({
|
||||
h: {
|
||||
alias: 'help',
|
||||
demand: false,
|
||||
describe: 'show this screen',
|
||||
type: 'boolean',
|
||||
},
|
||||
l: {
|
||||
alias: 'log-level',
|
||||
demand: false,
|
||||
describe: 'set log level (' + logLevels.join(', ') + '), default is info',
|
||||
type: 'string',
|
||||
},
|
||||
d: {
|
||||
alias: 'directory',
|
||||
demand: false,
|
||||
describe: "specify CMake project's directory (where CMakeLists.txt located)",
|
||||
type: 'string',
|
||||
},
|
||||
D: {
|
||||
alias: 'debug',
|
||||
demand: false,
|
||||
describe: 'build debug configuration',
|
||||
type: 'boolean',
|
||||
},
|
||||
B: {
|
||||
alias: 'config',
|
||||
demand: false,
|
||||
describe: "specify build configuration (Debug, RelWithDebInfo, Release), will ignore '--debug' if specified",
|
||||
type: 'string',
|
||||
},
|
||||
c: {
|
||||
alias: 'cmake-path',
|
||||
demand: false,
|
||||
describe: 'path of CMake executable',
|
||||
type: 'string',
|
||||
},
|
||||
m: {
|
||||
alias: 'prefer-make',
|
||||
demand: false,
|
||||
describe: 'use Unix Makefiles even if Ninja is available (Posix)',
|
||||
type: 'boolean',
|
||||
},
|
||||
x: {
|
||||
alias: 'prefer-xcode',
|
||||
demand: false,
|
||||
describe: 'use Xcode instead of Unix Makefiles',
|
||||
type: 'boolean',
|
||||
},
|
||||
g: {
|
||||
alias: 'prefer-gnu',
|
||||
demand: false,
|
||||
describe: 'use GNU compiler instead of default CMake compiler, if available (Posix)',
|
||||
type: 'boolean',
|
||||
},
|
||||
G: {
|
||||
alias: 'generator',
|
||||
demand: false,
|
||||
describe: 'use specified generator',
|
||||
type: 'string',
|
||||
},
|
||||
t: {
|
||||
alias: 'toolset',
|
||||
demand: false,
|
||||
describe: 'use specified toolset',
|
||||
type: 'string',
|
||||
},
|
||||
A: {
|
||||
alias: 'platform',
|
||||
demand: false,
|
||||
describe: 'use specified platform name',
|
||||
type: 'string',
|
||||
},
|
||||
T: {
|
||||
alias: 'target',
|
||||
demand: false,
|
||||
describe: 'only build the specified target',
|
||||
type: 'string',
|
||||
},
|
||||
C: {
|
||||
alias: 'prefer-clang',
|
||||
demand: false,
|
||||
describe: 'use Clang compiler instead of default CMake compiler, if available (Posix)',
|
||||
type: 'boolean',
|
||||
},
|
||||
cc: {
|
||||
demand: false,
|
||||
describe: 'use the specified C compiler',
|
||||
type: 'string',
|
||||
},
|
||||
cxx: {
|
||||
demand: false,
|
||||
describe: 'use the specified C++ compiler',
|
||||
type: 'string',
|
||||
},
|
||||
r: {
|
||||
alias: 'runtime',
|
||||
demand: false,
|
||||
describe: 'the runtime to use',
|
||||
type: 'string',
|
||||
},
|
||||
v: {
|
||||
alias: 'runtime-version',
|
||||
demand: false,
|
||||
describe: 'the runtime version to use',
|
||||
type: 'string',
|
||||
},
|
||||
a: {
|
||||
alias: 'arch',
|
||||
demand: false,
|
||||
describe: 'the architecture to build in',
|
||||
type: 'string',
|
||||
},
|
||||
p: {
|
||||
alias: 'parallel',
|
||||
demand: false,
|
||||
describe: 'the number of threads cmake can use',
|
||||
type: 'number',
|
||||
},
|
||||
CD: {
|
||||
demand: false,
|
||||
describe: 'Custom argument passed to CMake in format: -D<your-arg-here>',
|
||||
type: 'string',
|
||||
},
|
||||
i: {
|
||||
alias: 'silent',
|
||||
describe: 'Prevents CMake.js to print to the stdio',
|
||||
type: 'boolean',
|
||||
},
|
||||
O: {
|
||||
alias: 'out',
|
||||
describe: 'Specify the output directory to compile to, default is projectRoot/build',
|
||||
type: 'string',
|
||||
},
|
||||
})
|
||||
const argv = yargs.argv
|
||||
|
||||
// If help, then print and exit:
|
||||
|
||||
if (argv.h) {
|
||||
console.info(yargs.help())
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// Setup log level:
|
||||
|
||||
if (argv.l && logLevels.includes(argv.l)) {
|
||||
log.level = argv.l
|
||||
}
|
||||
|
||||
log.silly('CON', 'argv:')
|
||||
log.silly('CON', util.inspect(argv))
|
||||
|
||||
log.verbose('CON', 'Parsing arguments')
|
||||
|
||||
// Extract custom cMake options
|
||||
const customOptions = {}
|
||||
for (const arg of process.argv) {
|
||||
if (arg.startsWith('--CD')) {
|
||||
const separator = arg.indexOf('=')
|
||||
if (separator < 5) continue
|
||||
const key = arg.substring(4, separator)
|
||||
const value = arg.substring(separator + 1)
|
||||
if (!value) continue
|
||||
customOptions[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
const options = {
|
||||
directory: argv.directory || null,
|
||||
debug: argv.debug,
|
||||
cmakePath: argv.c || null,
|
||||
generator: argv.G,
|
||||
toolset: argv.t,
|
||||
platform: argv.A,
|
||||
target: argv.T,
|
||||
preferMake: argv.m,
|
||||
preferXcode: argv.x,
|
||||
preferGnu: argv.g,
|
||||
preferClang: argv.C,
|
||||
cCompilerPath: argv.cc,
|
||||
cppCompilerPath: argv.cxx,
|
||||
runtime: argv.r,
|
||||
runtimeVersion: argv.v,
|
||||
arch: argv.a,
|
||||
cMakeOptions: customOptions,
|
||||
silent: argv.i,
|
||||
out: argv.O,
|
||||
config: argv.B,
|
||||
parallel: argv.p,
|
||||
extraCMakeArgs: argv._.slice(1),
|
||||
}
|
||||
|
||||
log.verbose('CON', 'options:')
|
||||
log.verbose('CON', util.inspect(options))
|
||||
|
||||
const command = argv._[0] || 'build'
|
||||
|
||||
log.verbose('CON', 'Running command: ' + command)
|
||||
|
||||
const buildSystem = new BuildSystem(options)
|
||||
|
||||
function ifCommand(c, f) {
|
||||
if (c === command) {
|
||||
f()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function exitOnError(promise) {
|
||||
promise.catch(function () {
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
function install() {
|
||||
exitOnError(buildSystem.install())
|
||||
}
|
||||
function configure() {
|
||||
exitOnError(buildSystem.configure())
|
||||
}
|
||||
function printConfigure() {
|
||||
exitOnError(
|
||||
buildSystem.getConfigureCommand().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function printCmakeJsLib() {
|
||||
exitOnError(
|
||||
buildSystem.getCmakeJsLibString().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function printCmakeJsInclude() {
|
||||
exitOnError(
|
||||
buildSystem.getCmakeJsIncludeString().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function printCmakeJsSrc() {
|
||||
exitOnError(
|
||||
buildSystem.getCmakeJsSrcString().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function build() {
|
||||
exitOnError(buildSystem.build())
|
||||
}
|
||||
function printBuild() {
|
||||
exitOnError(
|
||||
buildSystem.getBuildCommand().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function clean() {
|
||||
exitOnError(buildSystem.clean())
|
||||
}
|
||||
function printClean() {
|
||||
exitOnError(
|
||||
buildSystem.getCleanCommand().then(function (command) {
|
||||
console.info(command)
|
||||
}),
|
||||
)
|
||||
}
|
||||
function reconfigure() {
|
||||
exitOnError(buildSystem.reconfigure())
|
||||
}
|
||||
function rebuild() {
|
||||
exitOnError(buildSystem.rebuild())
|
||||
}
|
||||
function compile() {
|
||||
exitOnError(buildSystem.compile())
|
||||
}
|
||||
|
||||
let done = ifCommand('install', install)
|
||||
done = done || ifCommand('configure', configure)
|
||||
done = done || ifCommand('print-configure', printConfigure)
|
||||
done = done || ifCommand('print-cmakejs-src', printCmakeJsSrc)
|
||||
done = done || ifCommand('print-cmakejs-include', printCmakeJsInclude)
|
||||
done = done || ifCommand('print-cmakejs-lib', printCmakeJsLib)
|
||||
done = done || ifCommand('build', build)
|
||||
done = done || ifCommand('print-build', printBuild)
|
||||
done = done || ifCommand('clean', clean)
|
||||
done = done || ifCommand('print-clean', printClean)
|
||||
done = done || ifCommand('reconfigure', reconfigure)
|
||||
done = done || ifCommand('rebuild', rebuild)
|
||||
done = done || ifCommand('compile', compile)
|
||||
|
||||
if (!done) {
|
||||
if (command) {
|
||||
log.error('COM', 'Unknown command: ' + command)
|
||||
process.exit(1)
|
||||
} else {
|
||||
build()
|
||||
}
|
||||
}
|
||||
239
node_modules/cmake-js/changelog.md
generated
vendored
Normal file
239
node_modules/cmake-js/changelog.md
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
# v8.0.0 - 27/01/26
|
||||
|
||||
- feat: require nodejs 20 or later
|
||||
- feat: update deprecated dependencies
|
||||
|
||||
# v7.4.0 - 14/11/25
|
||||
|
||||
- feat(windows): support msvc 2026 (Thanks to @Norgerkaj)
|
||||
|
||||
# v7.3.1 - 17/04/25
|
||||
|
||||
- fix(windows): support windows arm64 (Thanks to @jaycex)
|
||||
- fix(windows): support newer visual studio installations
|
||||
|
||||
# v7.3.0 - 15/01/24
|
||||
|
||||
- feat(windows): replace custom libnode.def generation with version from node-api-headers
|
||||
- fix: support for vs2015 with nodejs 18 and older (#317)
|
||||
- fix(windows): always remove Path if PATH is also defined (#319)
|
||||
- fix: Cmake arguments got converted to numbers (#314)
|
||||
- fix: update node-api-headers
|
||||
- chore: update dependencies
|
||||
|
||||
# v7.2.1 - 14/02/23
|
||||
|
||||
- fix: support Windows11SDK
|
||||
|
||||
# v7.2.0 - 12/02/23
|
||||
|
||||
- fix: `-DCMAKE_JS_VERSION=undefined` (#298)
|
||||
- fix: Only add build type to `CMAKE_LIBRARY_OUTPUT_DIRECTORY` if needed (#299)
|
||||
- feat: Forward extra arguments to CMake commands (#297)
|
||||
|
||||
# v7.1.1 - 15/12/22
|
||||
|
||||
- fix build errors on windows
|
||||
|
||||
# v7.1.0 - 14/12/22
|
||||
|
||||
- add commands for retrieving cmake-js include and lib directories
|
||||
- fix win delay hook issues with electron
|
||||
- fix missing js_native_api_symbols in windows node.lib
|
||||
|
||||
# v7.0.0 - 08/10/22
|
||||
|
||||
- update dependencies
|
||||
- replace some dependencies with modern language features
|
||||
- follow node-gyp behaviour for visual-studio version detection and selection
|
||||
- automatically locate node-addon-api and add to include paths
|
||||
- avoid downloads when building for node-api
|
||||
- encourage use of MT builds with MSVC, rather than MD
|
||||
|
||||
# v6.3.1 - 05/06/22
|
||||
|
||||
- add missing bluebird dependency
|
||||
- fix platform detection for visual studio 2019 and newer
|
||||
- fix platform detection for macos
|
||||
|
||||
# v6.3.0 - 26/11/21
|
||||
|
||||
- add offline mode: https://github.com/cmake-js/cmake-js/pull/260
|
||||
- handle missing buildSystem.log: https://github.com/cmake-js/cmake-js/pull/259
|
||||
- Add config flag: https://github.com/cmake-js/cmake-js/pull/251
|
||||
- Remove escaped quotes from windows registry queries: https://github.com/cmake-js/cmake-js/pull/250
|
||||
|
||||
# v6.2.1 - 20/07/21
|
||||
|
||||
- EOL hotfix (Thx Windows!)
|
||||
|
||||
# v6.2.0 - 19/07/21
|
||||
|
||||
- various fixes
|
||||
|
||||
# v6.1.0 - 27/02/20
|
||||
|
||||
- Add support for "-A/--platform" option to make target platform selectable for Visual Studio 2019 generator: https://github.com/cmake-js/cmake-js/pull/201
|
||||
|
||||
# v6.0.0 - 30/09/19
|
||||
|
||||
- Dropped compatibility of old Node.js runtimes (<10.0.0)
|
||||
- --cc and --cxx flags for overriding compiler detection: https://github.com/cmake-js/cmake-js/pull/191
|
||||
|
||||
# v5.3.2 - 21/08/19
|
||||
|
||||
- Visual Studio detection fixes
|
||||
|
||||
# v5.3.1 - 18/07/19
|
||||
|
||||
- VS 2019 Support fix: https://github.com/cmake-js/cmake-js/pull/187
|
||||
|
||||
# v5.3.0 - 09/07/19
|
||||
|
||||
- VS 2019 Support: https://github.com/cmake-js/cmake-js/pull/178/, https://github.com/cmake-js/cmake-js/pull/184/
|
||||
|
||||
# v5.2.1 - 10/04/19
|
||||
|
||||
- Win delay load hook: https://github.com/cmake-js/cmake-js/pull/165/
|
||||
|
||||
# v5.1.1 - 02/04/19
|
||||
|
||||
- CMake 3.14 support fixed - https://github.com/cmake-js/cmake-js/pull/161
|
||||
|
||||
# v5.1.0 - 14/02/19
|
||||
|
||||
- CMake 3.14 support - https://github.com/cmake-js/cmake-js/pull/159
|
||||
|
||||
# v5.0.1 - 24/01/19
|
||||
|
||||
- Linux line ending hotfix (I hate Windows!)
|
||||
|
||||
# v5.0.0 - 24/01/19
|
||||
|
||||
- [semver major] Add case sensitive NPM config integration https://github.com/cmake-js/cmake-js/pull/151
|
||||
- better npm config integration, all CMake.js commandline argument could be set by using npm config: https://github.com/cmake-js/cmake-js#npm-config-integration
|
||||
- support for Electron v4+ https://github.com/cmake-js/cmake-js/pull/152
|
||||
|
||||
# v4.0.1 - 03/10/18
|
||||
|
||||
- log argument hotfix https://github.com/cmake-js/cmake-js/pull/145
|
||||
|
||||
# v4.0.0 - 14/09/18
|
||||
|
||||
BREAKING CHANGES:
|
||||
|
||||
- -s/--std (along with -o/--prec11 option removed, you have to specify compiler standard in CMakeLists.txt files https://github.com/cmake-js/cmake-js/issues/72
|
||||
- Implicit -w compiler flag doesn't get added on OSX https://github.com/cmake-js/cmake-js/pull/133
|
||||
|
||||
# v3.7.3 - 16/05/18
|
||||
|
||||
- npm config hotfix https://github.com/cmake-js/cmake-js/pull/123
|
||||
|
||||
# v3.7.2 - 16/05/18
|
||||
|
||||
- do not use, breaks ES5 compatibility
|
||||
|
||||
# v3.7.1 - 07/05/18
|
||||
|
||||
- Linux line ending hotfix (wat)
|
||||
|
||||
# v3.7.0 - 07/05/18
|
||||
|
||||
- PR: replace unzip with unzipper https://github.com/cmake-js/cmake-js/pull/120
|
||||
- PR: replace npmconf with rc https://github.com/cmake-js/cmake-js/pull/119
|
||||
- PR: update to modern fs-extras https://github.com/cmake-js/cmake-js/pull/118
|
||||
- PR: Adds toolset command line flag https://github.com/cmake-js/cmake-js/pull/115
|
||||
|
||||
# v3.6.2 - 17/02/18
|
||||
|
||||
- use https distribution download urls
|
||||
- custom cmake options made case sensitive
|
||||
|
||||
# v3.6.1 - 11/01/18
|
||||
|
||||
- Detect 2017 Windows Build Tools
|
||||
|
||||
# v3.6.0 - 11/27/17
|
||||
|
||||
- "T" option for building specified target: https://github.com/cmake-js/cmake-js/pull/98
|
||||
|
||||
# v3.5.0 - 06/21/17
|
||||
|
||||
- Added Visual Studio 2017 compatibility: https://github.com/cmake-js/cmake-js/pull/78
|
||||
|
||||
# v3.4.1 - 02/4/17
|
||||
|
||||
- FIX: test output instead of guessing by platform: https://github.com/cmake-js/cmake-js/pull/77
|
||||
|
||||
# v3.4.0 - 01/12/17
|
||||
|
||||
- "G" option to set custom generators: https://github.com/cmake-js/cmake-js/pull/64
|
||||
|
||||
# v3.3.1 - 09/13/16
|
||||
|
||||
- fix of default parameters: https://github.com/cmake-js/cmake-js/pull/57
|
||||
|
||||
# v3.3.0 - 09/02/16
|
||||
|
||||
- silent option (https://github.com/cmake-js/cmake-js/pull/54)
|
||||
- out option (https://github.com/cmake-js/cmake-js/pull/53)
|
||||
|
||||
# v3.2.3 - 08/17/16
|
||||
|
||||
- Line endings
|
||||
|
||||
# v3.2.2 - 12/08/16
|
||||
|
||||
- Multi directory support for Windows/MSVC build
|
||||
|
||||
# v3.2.1 - 25/04/16
|
||||
|
||||
- Linux line ending hotfix
|
||||
|
||||
# v3.2.0 - 25/04/16
|
||||
|
||||
- Added NW.js 0.13+ compatibility
|
||||
- Node v0.10.x support fixed (https://github.com/cmake-js/cmake-js/pull/45, https://github.com/cmake-js/cmake-js/issues/50)
|
||||
- CMAKE_JS_VERSION defined (https://github.com/cmake-js/cmake-js/issues/48)
|
||||
|
||||
# v3.1.2 - 03/02/16
|
||||
|
||||
- Fixed cmake-js binary ES5 compatibility.
|
||||
|
||||
# v3.1.1 - 03/02/16
|
||||
|
||||
- Fixed line endings
|
||||
|
||||
# v3.1.0 - 03/02/16
|
||||
|
||||
- Custom CMake parameter support (https://github.com/gerhardberger)
|
||||
|
||||
# v3.0.0 - 20/11/15
|
||||
|
||||
- Visual C++ Build Tools support
|
||||
- std option introduced
|
||||
- better unit test coverage
|
||||
|
||||
# v2.1.0 - 29/10/15
|
||||
|
||||
- explicit options for use GNU or Clang compiler instead of CMake's default (see --help for details)
|
||||
|
||||
# v2.0.2 - 22/10/15
|
||||
|
||||
- Fix: print-\* commands report "undefined"
|
||||
|
||||
# v2.0.0 - 17/10/15
|
||||
|
||||
- Fix: distribution files only gets downloaded if needed (4.0.0+)
|
||||
- option to generate Xcode project (-x, --prefer-xcode) - by https://github.com/javedulu
|
||||
- compile command for fast module compilation during npm updates (instead of rebuild)
|
||||
- codebase switched to ECMAScript 2015
|
||||
|
||||
# v1.1.1 - 06/10/15
|
||||
|
||||
- Hotfix for build NW.js correctly.
|
||||
|
||||
# v1.1.0 - 05/10/15
|
||||
|
||||
- Node.js 4.0.0+ support
|
||||
- Downloads the small, header only tarball for Node.js 4+
|
||||
58
node_modules/cmake-js/lib/appCMakeJSConfig.js
generated
vendored
Normal file
58
node_modules/cmake-js/lib/appCMakeJSConfig.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
function getConfig(lookPath, log) {
|
||||
const pjsonPath = path.join(lookPath, 'package.json')
|
||||
log.silly('CFG', "Looking for package.json in: '" + pjsonPath + "'.")
|
||||
try {
|
||||
const json = require(pjsonPath)
|
||||
log.silly('CFG', 'Loaded:\n' + JSON.stringify(json))
|
||||
if (json && json['cmake-js'] && typeof json['cmake-js'] === 'object') {
|
||||
log.silly('CFG', 'Config found.')
|
||||
return json['cmake-js']
|
||||
} else {
|
||||
log.silly('CFG', 'Config not found.')
|
||||
return null
|
||||
}
|
||||
} catch (e) {
|
||||
log.silly('CFG', "'package.json' not found.")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (projectPath, log) {
|
||||
log.verbose('CFG', "Looking for application level CMake.js config in '" + projectPath + '.')
|
||||
let currPath = projectPath
|
||||
let lastConfig = null
|
||||
let currConfig
|
||||
for (;;) {
|
||||
currConfig = getConfig(currPath, log)
|
||||
if (currConfig) {
|
||||
lastConfig = currConfig
|
||||
}
|
||||
try {
|
||||
log.silly('CFG', 'Looking for parent path.')
|
||||
const lastPath = currPath
|
||||
currPath = path.normalize(path.join(currPath, '..'))
|
||||
if (lastPath === currPath) {
|
||||
currPath = null // root
|
||||
}
|
||||
if (currPath) {
|
||||
log.silly('CFG', "Parent path: '" + currPath + "'.")
|
||||
}
|
||||
} catch (e) {
|
||||
log.silly('CFG', 'Exception:\n' + e.stack)
|
||||
break
|
||||
}
|
||||
if (currPath === null) {
|
||||
log.silly('CFG', "Parent path with package.json file doesn't exists. Done.")
|
||||
break
|
||||
}
|
||||
}
|
||||
if (lastConfig) {
|
||||
log.verbose('CFG', 'Application level CMake.js config found:\n' + JSON.stringify(lastConfig))
|
||||
} else {
|
||||
log.verbose('CFG', "Application level CMake.js config doesn't exists.")
|
||||
}
|
||||
return lastConfig
|
||||
}
|
||||
123
node_modules/cmake-js/lib/buildSystem.js
generated
vendored
Normal file
123
node_modules/cmake-js/lib/buildSystem.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
'use strict'
|
||||
const CMake = require('./cMake')
|
||||
const Dist = require('./dist')
|
||||
const CMLog = require('./cmLog')
|
||||
const appCMakeJSConfig = require('./appCMakeJSConfig')
|
||||
const npmConfig = require('./npmConfig')
|
||||
const path = require('path')
|
||||
const Toolset = require('./toolset')
|
||||
|
||||
function isNodeApi(log, projectRoot) {
|
||||
try {
|
||||
const projectPkgJson = require(path.join(projectRoot, 'package.json'))
|
||||
// Make sure the property exists
|
||||
return !!projectPkgJson?.binary?.napi_versions
|
||||
} catch (e) {
|
||||
log.silly('CFG', "'package.json' not found.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class BuildSystem {
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.options.directory = path.resolve(this.options.directory || process.cwd())
|
||||
this.options.out = path.resolve(this.options.out || path.join(this.options.directory, 'build'))
|
||||
this.log = new CMLog(this.options)
|
||||
this.options.isNodeApi = isNodeApi(this.log, this.options.directory)
|
||||
const appConfig = appCMakeJSConfig(this.options.directory, this.log)
|
||||
const npmOptions = npmConfig(this.log)
|
||||
|
||||
if (npmOptions && typeof npmOptions === 'object' && Object.keys(npmOptions).length) {
|
||||
this.options.runtimeDirectory = npmOptions['nodedir']
|
||||
this.options.msvsVersion = npmOptions['msvs_version']
|
||||
}
|
||||
if (appConfig && typeof appConfig === 'object' && Object.keys(appConfig).length) {
|
||||
this.log.verbose('CFG', 'Applying CMake.js config from root package.json:')
|
||||
this.log.verbose('CFG', JSON.stringify(appConfig))
|
||||
// Applying applications's config, if there is no explicit runtime related options specified
|
||||
this.options.runtime = this.options.runtime || appConfig.runtime
|
||||
this.options.runtimeVersion = this.options.runtimeVersion || appConfig.runtimeVersion
|
||||
this.options.arch = this.options.arch || appConfig.arch
|
||||
}
|
||||
|
||||
this.log.verbose('CFG', 'Build system options:')
|
||||
this.log.verbose('CFG', JSON.stringify(this.options))
|
||||
this.cmake = new CMake(this.options)
|
||||
this.dist = new Dist(this.options)
|
||||
this.toolset = new Toolset(this.options)
|
||||
}
|
||||
async _ensureInstalled() {
|
||||
try {
|
||||
await this.toolset.initialize(true)
|
||||
if (!this.options.isNodeApi) {
|
||||
await this.dist.ensureDownloaded()
|
||||
}
|
||||
} catch (e) {
|
||||
this._showError(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
_showError(e) {
|
||||
if (this.log === undefined) {
|
||||
// handle internal errors (init failed)
|
||||
console.error('OMG', e.stack)
|
||||
return
|
||||
}
|
||||
if (this.log.level === 'verbose' || this.log.level === 'silly') {
|
||||
this.log.error('OMG', e.stack)
|
||||
} else {
|
||||
this.log.error('OMG', e.message)
|
||||
}
|
||||
}
|
||||
install() {
|
||||
return this._ensureInstalled()
|
||||
}
|
||||
async _invokeCMake(method) {
|
||||
try {
|
||||
await this._ensureInstalled()
|
||||
return await this.cmake[method]()
|
||||
} catch (e) {
|
||||
this._showError(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
getConfigureCommand() {
|
||||
return this._invokeCMake('getConfigureCommand')
|
||||
}
|
||||
getCmakeJsLibString() {
|
||||
return this._invokeCMake('getCmakeJsLibString')
|
||||
}
|
||||
getCmakeJsIncludeString() {
|
||||
return this._invokeCMake('getCmakeJsIncludeString')
|
||||
}
|
||||
getCmakeJsSrcString() {
|
||||
return this._invokeCMake('getCmakeJsSrcString')
|
||||
}
|
||||
configure() {
|
||||
return this._invokeCMake('configure')
|
||||
}
|
||||
getBuildCommand() {
|
||||
return this._invokeCMake('getBuildCommand')
|
||||
}
|
||||
build() {
|
||||
return this._invokeCMake('build')
|
||||
}
|
||||
getCleanCommand() {
|
||||
return this._invokeCMake('getCleanCommand')
|
||||
}
|
||||
clean() {
|
||||
return this._invokeCMake('clean')
|
||||
}
|
||||
reconfigure() {
|
||||
return this._invokeCMake('reconfigure')
|
||||
}
|
||||
rebuild() {
|
||||
return this._invokeCMake('rebuild')
|
||||
}
|
||||
compile() {
|
||||
return this._invokeCMake('compile')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BuildSystem
|
||||
362
node_modules/cmake-js/lib/cMake.js
generated
vendored
Normal file
362
node_modules/cmake-js/lib/cMake.js
generated
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
'use strict'
|
||||
const which = require('which')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const environment = require('./environment')
|
||||
const Dist = require('./dist')
|
||||
const CMLog = require('./cmLog')
|
||||
const TargetOptions = require('./targetOptions')
|
||||
const processHelpers = require('./processHelpers')
|
||||
const locateNAN = require('./locateNAN')
|
||||
const locateNodeApi = require('./locateNodeApi')
|
||||
const npmConfigData = require('rc')('npm')
|
||||
const Toolset = require('./toolset')
|
||||
const headers = require('node-api-headers')
|
||||
|
||||
class CMake {
|
||||
get path() {
|
||||
return this.options.cmakePath || 'cmake'
|
||||
}
|
||||
get isAvailable() {
|
||||
if (this._isAvailable === null) {
|
||||
this._isAvailable = CMake.isAvailable(this.options)
|
||||
}
|
||||
return this._isAvailable
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.log = new CMLog(this.options)
|
||||
this.dist = new Dist(this.options)
|
||||
this.projectRoot = path.resolve(this.options.directory || process.cwd())
|
||||
this.workDir = path.resolve(this.options.out || path.join(this.projectRoot, 'build'))
|
||||
this.config = this.options.config || (this.options.debug ? 'Debug' : 'Release')
|
||||
this.buildDir = path.join(this.workDir, this.config)
|
||||
this._isAvailable = null
|
||||
this.targetOptions = new TargetOptions(this.options)
|
||||
this.toolset = new Toolset(this.options)
|
||||
this.cMakeOptions = this.options.cMakeOptions || {}
|
||||
this.extraCMakeArgs = this.options.extraCMakeArgs || []
|
||||
this.silent = !!options.silent
|
||||
}
|
||||
static isAvailable(options) {
|
||||
options = options || {}
|
||||
try {
|
||||
if (options.cmakePath) {
|
||||
const stat = fs.lstatSync(options.cmakePath)
|
||||
return !stat.isDirectory()
|
||||
} else {
|
||||
which.sync('cmake')
|
||||
return true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
return false
|
||||
}
|
||||
static async getGenerators(options, log) {
|
||||
const arch = ' [arch]'
|
||||
options = options || {}
|
||||
const gens = []
|
||||
if (CMake.isAvailable(options)) {
|
||||
// try parsing machine-readable capabilities (available since CMake 3.7)
|
||||
try {
|
||||
const stdout = await processHelpers.execFile([options.cmakePath || 'cmake', '-E', 'capabilities'])
|
||||
const capabilities = JSON.parse(stdout)
|
||||
return capabilities.generators.map((x) => x.name)
|
||||
} catch (error) {
|
||||
if (log) {
|
||||
log.verbose('TOOL', 'Failed to query CMake capabilities (CMake is probably older than 3.7)')
|
||||
}
|
||||
}
|
||||
|
||||
// fall back to parsing help text
|
||||
const stdout = await processHelpers.execFile([options.cmakePath || 'cmake', '--help'])
|
||||
const hasCr = stdout.includes('\r\n')
|
||||
const output = hasCr ? stdout.split('\r\n') : stdout.split('\n')
|
||||
let on = false
|
||||
output.forEach(function (line, i) {
|
||||
if (on) {
|
||||
const parts = line.split('=')
|
||||
if (
|
||||
(parts.length === 2 && parts[0].trim()) ||
|
||||
(parts.length === 1 && i !== output.length - 1 && output[i + 1].trim()[0] === '=')
|
||||
) {
|
||||
let gen = parts[0].trim()
|
||||
if (gen.endsWith(arch)) {
|
||||
gen = gen.substr(0, gen.length - arch.length)
|
||||
}
|
||||
gens.push(gen)
|
||||
}
|
||||
}
|
||||
if (line.trim() === 'Generators') {
|
||||
on = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
throw new Error('CMake is not installed. Install CMake.')
|
||||
}
|
||||
return gens
|
||||
}
|
||||
verifyIfAvailable() {
|
||||
if (!this.isAvailable) {
|
||||
throw new Error(
|
||||
"CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org.",
|
||||
)
|
||||
}
|
||||
}
|
||||
async getConfigureCommand() {
|
||||
// Create command:
|
||||
let command = [this.path, this.projectRoot, '--no-warn-unused-cli']
|
||||
|
||||
const D = []
|
||||
|
||||
// CMake.js watermark
|
||||
D.push({ CMAKE_JS_VERSION: environment.cmakeJsVersion })
|
||||
|
||||
// Build configuration:
|
||||
D.push({ CMAKE_BUILD_TYPE: this.config })
|
||||
if (environment.isWin) {
|
||||
D.push({ CMAKE_RUNTIME_OUTPUT_DIRECTORY: this.workDir })
|
||||
} else if (this.workDir.endsWith(this.config)) {
|
||||
D.push({ CMAKE_LIBRARY_OUTPUT_DIRECTORY: this.workDir })
|
||||
} else {
|
||||
D.push({ CMAKE_LIBRARY_OUTPUT_DIRECTORY: this.buildDir })
|
||||
}
|
||||
|
||||
// In some configurations MD builds will crash upon attempting to free memory.
|
||||
// This tries to encourage MT builds which are larger but less likely to have this crash.
|
||||
D.push({ CMAKE_MSVC_RUNTIME_LIBRARY: 'MultiThreaded$<$<CONFIG:Debug>:Debug>' })
|
||||
|
||||
// Includes:
|
||||
const includesString = await this.getCmakeJsIncludeString()
|
||||
D.push({ CMAKE_JS_INC: includesString })
|
||||
|
||||
// Sources:
|
||||
const srcsString = this.getCmakeJsSrcString()
|
||||
D.push({ CMAKE_JS_SRC: srcsString })
|
||||
|
||||
// Runtime:
|
||||
D.push({ NODE_RUNTIME: this.targetOptions.runtime })
|
||||
D.push({ NODE_RUNTIMEVERSION: this.targetOptions.runtimeVersion })
|
||||
D.push({ NODE_ARCH: this.targetOptions.arch })
|
||||
|
||||
if (environment.isOSX) {
|
||||
if (this.targetOptions.arch) {
|
||||
let xcodeArch = this.targetOptions.arch
|
||||
if (xcodeArch === 'x64') xcodeArch = 'x86_64'
|
||||
D.push({ CMAKE_OSX_ARCHITECTURES: xcodeArch })
|
||||
}
|
||||
}
|
||||
|
||||
// Custom options
|
||||
for (const [key, value] of Object.entries(this.cMakeOptions)) {
|
||||
D.push({ [key]: value })
|
||||
}
|
||||
|
||||
// Toolset:
|
||||
await this.toolset.initialize(false)
|
||||
|
||||
const libsString = this.getCmakeJsLibString()
|
||||
D.push({ CMAKE_JS_LIB: libsString })
|
||||
|
||||
if (environment.isWin) {
|
||||
const nodeLibDefPath = this.getNodeLibDefPath()
|
||||
if (nodeLibDefPath) {
|
||||
const nodeLibPath = path.join(this.workDir, 'node.lib')
|
||||
D.push({ CMAKE_JS_NODELIB_DEF: nodeLibDefPath })
|
||||
D.push({ CMAKE_JS_NODELIB_TARGET: nodeLibPath })
|
||||
}
|
||||
}
|
||||
|
||||
if (this.toolset.generator) {
|
||||
command.push('-G', this.toolset.generator)
|
||||
}
|
||||
if (this.toolset.platform) {
|
||||
command.push('-A', this.toolset.platform)
|
||||
}
|
||||
if (this.toolset.toolset) {
|
||||
command.push('-T', this.toolset.toolset)
|
||||
}
|
||||
if (this.toolset.cppCompilerPath) {
|
||||
D.push({ CMAKE_CXX_COMPILER: this.toolset.cppCompilerPath })
|
||||
}
|
||||
if (this.toolset.cCompilerPath) {
|
||||
D.push({ CMAKE_C_COMPILER: this.toolset.cCompilerPath })
|
||||
}
|
||||
if (this.toolset.compilerFlags.length) {
|
||||
D.push({ CMAKE_CXX_FLAGS: this.toolset.compilerFlags.join(' ') })
|
||||
}
|
||||
if (this.toolset.linkerFlags.length) {
|
||||
D.push({ CMAKE_SHARED_LINKER_FLAGS: this.toolset.linkerFlags.join(' ') })
|
||||
}
|
||||
if (this.toolset.makePath) {
|
||||
D.push({ CMAKE_MAKE_PROGRAM: this.toolset.makePath })
|
||||
}
|
||||
|
||||
// Load NPM config
|
||||
for (const [key, value] of Object.entries(npmConfigData)) {
|
||||
if (key.startsWith('cmake_')) {
|
||||
const sk = key.substr(6)
|
||||
if (sk && value) {
|
||||
D.push({ [sk]: value })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command = command.concat(
|
||||
D.map(function (p) {
|
||||
return '-D' + Object.keys(p)[0] + '=' + Object.values(p)[0]
|
||||
}),
|
||||
)
|
||||
|
||||
return command.concat(this.extraCMakeArgs)
|
||||
}
|
||||
getCmakeJsLibString() {
|
||||
const libs = []
|
||||
if (environment.isWin) {
|
||||
const nodeLibDefPath = this.getNodeLibDefPath()
|
||||
if (nodeLibDefPath) {
|
||||
libs.push(path.join(this.workDir, 'node.lib'))
|
||||
} else {
|
||||
libs.push(...this.dist.winLibs)
|
||||
}
|
||||
}
|
||||
return libs.join(';')
|
||||
}
|
||||
async getCmakeJsIncludeString() {
|
||||
let incPaths = []
|
||||
if (!this.options.isNodeApi) {
|
||||
// Include and lib:
|
||||
if (this.dist.headerOnly) {
|
||||
incPaths = [path.join(this.dist.internalPath, '/include/node')]
|
||||
} else {
|
||||
const nodeH = path.join(this.dist.internalPath, '/src')
|
||||
const v8H = path.join(this.dist.internalPath, '/deps/v8/include')
|
||||
const uvH = path.join(this.dist.internalPath, '/deps/uv/include')
|
||||
incPaths = [nodeH, v8H, uvH]
|
||||
}
|
||||
|
||||
// NAN
|
||||
const nanH = await locateNAN(this.projectRoot)
|
||||
if (nanH) {
|
||||
incPaths.push(nanH)
|
||||
}
|
||||
} else {
|
||||
// Base headers
|
||||
const apiHeaders = require('node-api-headers')
|
||||
incPaths.push(apiHeaders.include_dir)
|
||||
|
||||
// Node-api
|
||||
const napiH = await locateNodeApi(this.projectRoot)
|
||||
if (napiH) {
|
||||
incPaths.push(napiH)
|
||||
}
|
||||
}
|
||||
|
||||
return incPaths.join(';')
|
||||
}
|
||||
getCmakeJsSrcString() {
|
||||
const srcPaths = []
|
||||
if (environment.isWin) {
|
||||
const delayHook = path.normalize(path.join(__dirname, 'cpp', 'win_delay_load_hook.cc'))
|
||||
|
||||
srcPaths.push(delayHook.replace(/\\/gm, '/'))
|
||||
}
|
||||
|
||||
return srcPaths.join(';')
|
||||
}
|
||||
getNodeLibDefPath() {
|
||||
return environment.isWin && this.options.isNodeApi ? headers.def_paths.node_api_def : undefined
|
||||
}
|
||||
async configure() {
|
||||
this.verifyIfAvailable()
|
||||
|
||||
this.log.info('CMD', 'CONFIGURE')
|
||||
const listPath = path.join(this.projectRoot, 'CMakeLists.txt')
|
||||
const command = await this.getConfigureCommand()
|
||||
|
||||
try {
|
||||
await fs.lstat(listPath)
|
||||
} catch (e) {
|
||||
throw new Error("'" + listPath + "' not found.")
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.ensureDir(this.workDir)
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
const cwd = process.cwd()
|
||||
process.chdir(this.workDir)
|
||||
try {
|
||||
await this._run(command)
|
||||
} finally {
|
||||
process.chdir(cwd)
|
||||
}
|
||||
}
|
||||
async ensureConfigured() {
|
||||
try {
|
||||
await fs.lstat(path.join(this.workDir, 'CMakeCache.txt'))
|
||||
} catch (e) {
|
||||
await this.configure()
|
||||
}
|
||||
}
|
||||
getBuildCommand() {
|
||||
const command = [this.path, '--build', this.workDir, '--config', this.config]
|
||||
if (this.options.target) {
|
||||
command.push('--target', this.options.target)
|
||||
}
|
||||
if (this.options.parallel) {
|
||||
command.push('--parallel', this.options.parallel)
|
||||
}
|
||||
return Promise.resolve(command.concat(this.extraCMakeArgs))
|
||||
}
|
||||
async build() {
|
||||
this.verifyIfAvailable()
|
||||
|
||||
await this.ensureConfigured()
|
||||
const buildCommand = await this.getBuildCommand()
|
||||
this.log.info('CMD', 'BUILD')
|
||||
await this._run(buildCommand)
|
||||
}
|
||||
getCleanCommand() {
|
||||
return [this.path, '-E', 'remove_directory', this.workDir].concat(this.extraCMakeArgs)
|
||||
}
|
||||
clean() {
|
||||
this.verifyIfAvailable()
|
||||
|
||||
this.log.info('CMD', 'CLEAN')
|
||||
return this._run(this.getCleanCommand())
|
||||
}
|
||||
async reconfigure() {
|
||||
this.extraCMakeArgs = []
|
||||
await this.clean()
|
||||
await this.configure()
|
||||
}
|
||||
async rebuild() {
|
||||
this.extraCMakeArgs = []
|
||||
await this.clean()
|
||||
await this.build()
|
||||
}
|
||||
async compile() {
|
||||
this.extraCMakeArgs = []
|
||||
try {
|
||||
await this.build()
|
||||
} catch (e) {
|
||||
this.log.info('REP', 'Build has been failed, trying to do a full rebuild.')
|
||||
await this.rebuild()
|
||||
}
|
||||
}
|
||||
_run(command) {
|
||||
this.log.info('RUN', command)
|
||||
return processHelpers.run(command, { silent: this.silent })
|
||||
}
|
||||
|
||||
async getGenerators() {
|
||||
return CMake.getGenerators(this.options, this.log)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CMake
|
||||
61
node_modules/cmake-js/lib/cmLog.js
generated
vendored
Normal file
61
node_modules/cmake-js/lib/cmLog.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
const log = require('./logger')
|
||||
|
||||
class CMLog {
|
||||
get level() {
|
||||
if (this.options.noLog) {
|
||||
return 'silly'
|
||||
} else {
|
||||
return log.level
|
||||
}
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.debug = require('debug')(this.options.logName || 'cmake-js')
|
||||
}
|
||||
silly(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.silly(cat, msg)
|
||||
}
|
||||
}
|
||||
verbose(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.verbose(cat, msg)
|
||||
}
|
||||
}
|
||||
info(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.info(cat, msg)
|
||||
}
|
||||
}
|
||||
warn(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.warn(cat, msg)
|
||||
}
|
||||
}
|
||||
http(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.http(cat, msg)
|
||||
}
|
||||
}
|
||||
error(cat, msg) {
|
||||
if (this.options.noLog) {
|
||||
this.debug(cat + ': ' + msg)
|
||||
} else {
|
||||
log.error(cat, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CMLog
|
||||
52
node_modules/cmake-js/lib/cpp/win_delay_load_hook.cc
generated
vendored
Normal file
52
node_modules/cmake-js/lib/cpp/win_delay_load_hook.cc
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* When this file is linked to a DLL, it sets up a delay-load hook that
|
||||
* intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe'
|
||||
* dynamically. Instead of trying to locate the .exe file it'll just return
|
||||
* a handle to the process image.
|
||||
*
|
||||
* This allows compiled addons to work when node.exe or iojs.exe is renamed.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <delayimp.h>
|
||||
#include <string.h>
|
||||
|
||||
static HMODULE node_dll = NULL;
|
||||
static HMODULE nw_dll = NULL;
|
||||
|
||||
static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
|
||||
if (event == dliNotePreGetProcAddress) {
|
||||
FARPROC ret = NULL;
|
||||
ret = GetProcAddress(node_dll, info->dlp.szProcName);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = GetProcAddress(nw_dll, info->dlp.szProcName);
|
||||
return ret;
|
||||
}
|
||||
if (event == dliStartProcessing) {
|
||||
node_dll = GetModuleHandleA("node.dll");
|
||||
nw_dll = GetModuleHandleA("nw.dll");
|
||||
return NULL;
|
||||
}
|
||||
if (event != dliNotePreLoadLibrary)
|
||||
return NULL;
|
||||
|
||||
if (_stricmp(info->szDll, "node.exe") != 0)
|
||||
return NULL;
|
||||
|
||||
// Fall back to the current process
|
||||
if(!node_dll) node_dll = GetModuleHandleA(NULL);
|
||||
|
||||
return (FARPROC) node_dll;
|
||||
}
|
||||
|
||||
decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;
|
||||
|
||||
#endif
|
||||
176
node_modules/cmake-js/lib/dist.js
generated
vendored
Normal file
176
node_modules/cmake-js/lib/dist.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
'use strict'
|
||||
const environment = require('./environment')
|
||||
const path = require('path')
|
||||
const urljoin = require('url-join')
|
||||
const fs = require('fs-extra')
|
||||
const CMLog = require('./cmLog')
|
||||
const TargetOptions = require('./targetOptions')
|
||||
const runtimePaths = require('./runtimePaths')
|
||||
const Downloader = require('./downloader')
|
||||
const os = require('os')
|
||||
|
||||
function testSum(sums, sum, fPath) {
|
||||
const serverSum = sums.find(function (s) {
|
||||
return s.getPath === fPath
|
||||
})
|
||||
if (serverSum && serverSum.sum === sum) {
|
||||
return
|
||||
}
|
||||
throw new Error("SHA sum of file '" + fPath + "' mismatch!")
|
||||
}
|
||||
|
||||
class Dist {
|
||||
get internalPath() {
|
||||
const cacheDirectory = '.cmake-js'
|
||||
const runtimeArchDirectory = this.targetOptions.runtime + '-' + this.targetOptions.arch
|
||||
const runtimeVersionDirectory = 'v' + this.targetOptions.runtimeVersion
|
||||
|
||||
return (
|
||||
this.options.runtimeDirectory ||
|
||||
path.join(os.homedir(), cacheDirectory, runtimeArchDirectory, runtimeVersionDirectory)
|
||||
)
|
||||
}
|
||||
get externalPath() {
|
||||
return runtimePaths.get(this.targetOptions).externalPath
|
||||
}
|
||||
get downloaded() {
|
||||
let headers = false
|
||||
let libs = true
|
||||
let stat = getStat(this.internalPath)
|
||||
if (stat.isDirectory()) {
|
||||
if (this.headerOnly) {
|
||||
stat = getStat(path.join(this.internalPath, 'include/node/node.h'))
|
||||
headers = stat.isFile()
|
||||
} else {
|
||||
stat = getStat(path.join(this.internalPath, 'src/node.h'))
|
||||
if (stat.isFile()) {
|
||||
stat = getStat(path.join(this.internalPath, 'deps/v8/include/v8.h'))
|
||||
headers = stat.isFile()
|
||||
}
|
||||
}
|
||||
if (environment.isWin) {
|
||||
for (const libPath of this.winLibs) {
|
||||
stat = getStat(libPath)
|
||||
libs = libs && stat.isFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
return headers && libs
|
||||
|
||||
function getStat(path) {
|
||||
try {
|
||||
return fs.statSync(path)
|
||||
} catch (e) {
|
||||
return {
|
||||
isFile: () => false,
|
||||
isDirectory: () => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get winLibs() {
|
||||
const libs = runtimePaths.get(this.targetOptions).winLibs
|
||||
const result = []
|
||||
for (const lib of libs) {
|
||||
result.push(path.join(this.internalPath, lib.dir, lib.name))
|
||||
}
|
||||
return result
|
||||
}
|
||||
get headerOnly() {
|
||||
return runtimePaths.get(this.targetOptions).headerOnly
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.log = new CMLog(this.options)
|
||||
this.targetOptions = new TargetOptions(this.options)
|
||||
this.downloader = new Downloader(this.options)
|
||||
}
|
||||
|
||||
async ensureDownloaded() {
|
||||
if (!this.downloaded) {
|
||||
await this.download()
|
||||
}
|
||||
}
|
||||
async download() {
|
||||
const log = this.log
|
||||
log.info('DIST', 'Downloading distribution files to: ' + this.internalPath)
|
||||
await fs.ensureDir(this.internalPath)
|
||||
const sums = await this._downloadShaSums()
|
||||
await Promise.all([this._downloadLibs(sums), this._downloadTar(sums)])
|
||||
}
|
||||
async _downloadShaSums() {
|
||||
if (this.targetOptions.runtime === 'node') {
|
||||
const sumUrl = urljoin(this.externalPath, 'SHASUMS256.txt')
|
||||
const log = this.log
|
||||
log.http('DIST', '\t- ' + sumUrl)
|
||||
return (await this.downloader.downloadString(sumUrl))
|
||||
.split('\n')
|
||||
.map(function (line) {
|
||||
const parts = line.split(/\s+/)
|
||||
return {
|
||||
getPath: parts[1],
|
||||
sum: parts[0],
|
||||
}
|
||||
})
|
||||
.filter(function (i) {
|
||||
return i.getPath && i.sum
|
||||
})
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
async _downloadTar(sums) {
|
||||
const log = this.log
|
||||
const self = this
|
||||
const tarLocalPath = runtimePaths.get(self.targetOptions).tarPath
|
||||
const tarUrl = urljoin(self.externalPath, tarLocalPath)
|
||||
log.http('DIST', '\t- ' + tarUrl)
|
||||
|
||||
const sum = await this.downloader.downloadTgz(tarUrl, {
|
||||
hash: sums ? 'sha256' : null,
|
||||
cwd: self.internalPath,
|
||||
strip: 1,
|
||||
filter: function (entryPath) {
|
||||
if (entryPath === self.internalPath) {
|
||||
return true
|
||||
}
|
||||
const ext = path.extname(entryPath)
|
||||
return ext && ext.toLowerCase() === '.h'
|
||||
},
|
||||
})
|
||||
|
||||
if (sums) {
|
||||
testSum(sums, sum, tarLocalPath)
|
||||
}
|
||||
}
|
||||
async _downloadLibs(sums) {
|
||||
const log = this.log
|
||||
const self = this
|
||||
if (!environment.isWin) {
|
||||
return
|
||||
}
|
||||
|
||||
const paths = runtimePaths.get(self.targetOptions)
|
||||
for (const dirs of paths.winLibs) {
|
||||
const subDir = dirs.dir
|
||||
const fn = dirs.name
|
||||
const fPath = subDir ? urljoin(subDir, fn) : fn
|
||||
const libUrl = urljoin(self.externalPath, fPath)
|
||||
log.http('DIST', '\t- ' + libUrl)
|
||||
|
||||
await fs.ensureDir(path.join(self.internalPath, subDir))
|
||||
|
||||
const sum = await this.downloader.downloadFile(libUrl, {
|
||||
path: path.join(self.internalPath, fPath),
|
||||
hash: sums ? 'sha256' : null,
|
||||
})
|
||||
|
||||
if (sums) {
|
||||
testSum(sums, sum, fPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Dist
|
||||
99
node_modules/cmake-js/lib/downloader.js
generated
vendored
Normal file
99
node_modules/cmake-js/lib/downloader.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
'use strict'
|
||||
const crypto = require('crypto')
|
||||
const { Readable } = require('node:stream')
|
||||
const zlib = require('zlib')
|
||||
const tar = require('tar')
|
||||
const fs = require('fs')
|
||||
const CMLog = require('./cmLog')
|
||||
|
||||
class Downloader {
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.log = new CMLog(this.options)
|
||||
}
|
||||
downloadToStream(url, stream, hash) {
|
||||
const self = this
|
||||
const shasum = hash ? crypto.createHash(hash) : null
|
||||
return new Promise(function (resolve, reject) {
|
||||
let length = 0
|
||||
let done = 0
|
||||
let lastPercent = 0
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText || 'Request failed')
|
||||
}
|
||||
length = parseInt(response.headers.get('content-length'))
|
||||
if (Number.isNaN(length)) {
|
||||
length = 0
|
||||
}
|
||||
|
||||
const readable = Readable.fromWeb(response.body)
|
||||
readable.on('data', function (chunk) {
|
||||
if (shasum) {
|
||||
shasum.update(chunk)
|
||||
}
|
||||
if (length) {
|
||||
done += chunk.length
|
||||
let percent = (done / length) * 100
|
||||
percent = Math.round(percent / 10) * 10 + 10
|
||||
if (percent > lastPercent) {
|
||||
self.log.verbose('DWNL', '\t' + lastPercent + '%')
|
||||
lastPercent = percent
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
readable.pipe(stream)
|
||||
readable.on('error', function (err) {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
reject(err)
|
||||
})
|
||||
|
||||
stream.once('error', function (err) {
|
||||
reject(err)
|
||||
})
|
||||
|
||||
stream.once('finish', function () {
|
||||
resolve(shasum ? shasum.digest('hex') : undefined)
|
||||
})
|
||||
})
|
||||
}
|
||||
async downloadString(url) {
|
||||
const response = await fetch(url)
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText || 'Request failed')
|
||||
}
|
||||
return response.text()
|
||||
}
|
||||
async downloadFile(url, options) {
|
||||
if (typeof options === 'string') {
|
||||
options.path = options
|
||||
}
|
||||
const result = fs.createWriteStream(options.path)
|
||||
const sum = await this.downloadToStream(url, result, options.hash)
|
||||
this.testSum(url, sum, options)
|
||||
return sum
|
||||
}
|
||||
async downloadTgz(url, options) {
|
||||
if (typeof options === 'string') {
|
||||
options.cwd = options
|
||||
}
|
||||
const gunzip = zlib.createGunzip()
|
||||
const extractor = tar.extract(options)
|
||||
gunzip.pipe(extractor)
|
||||
const sum = await this.downloadToStream(url, gunzip, options.hash)
|
||||
this.testSum(url, sum, options)
|
||||
return sum
|
||||
}
|
||||
testSum(url, sum, options) {
|
||||
if (options.hash && sum && options.sum && options.sum !== sum) {
|
||||
throw new Error(options.hash.toUpperCase() + " sum of download '" + url + "' mismatch!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Downloader
|
||||
97
node_modules/cmake-js/lib/environment.js
generated
vendored
Normal file
97
node_modules/cmake-js/lib/environment.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
'use strict'
|
||||
const os = require('os')
|
||||
const which = require('which')
|
||||
|
||||
const environment = (module.exports = {
|
||||
cmakeJsVersion: require('../package.json').version,
|
||||
platform: os.platform(),
|
||||
isWin: os.platform() === 'win32',
|
||||
isLinux: os.platform() === 'linux',
|
||||
isOSX: os.platform() === 'darwin',
|
||||
arch: os.arch(),
|
||||
isX86: os.arch() === 'ia32' || os.arch() === 'x86',
|
||||
isX64: os.arch() === 'x64',
|
||||
isArm: os.arch() === 'arm',
|
||||
isArm64: os.arch() === 'arm64',
|
||||
runtime: 'node',
|
||||
runtimeVersion: process.versions.node,
|
||||
})
|
||||
|
||||
Object.defineProperties(environment, {
|
||||
_isNinjaAvailable: {
|
||||
value: null,
|
||||
writable: true,
|
||||
},
|
||||
isNinjaAvailable: {
|
||||
get: function () {
|
||||
if (this._isNinjaAvailable === null) {
|
||||
this._isNinjaAvailable = false
|
||||
try {
|
||||
if (which.sync('ninja')) {
|
||||
this._isNinjaAvailable = true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return this._isNinjaAvailable
|
||||
},
|
||||
},
|
||||
_isMakeAvailable: {
|
||||
value: null,
|
||||
writable: true,
|
||||
},
|
||||
isMakeAvailable: {
|
||||
get: function () {
|
||||
if (this._isMakeAvailable === null) {
|
||||
this._isMakeAvailable = false
|
||||
try {
|
||||
if (which.sync('make')) {
|
||||
this._isMakeAvailable = true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return this._isMakeAvailable
|
||||
},
|
||||
},
|
||||
_isGPPAvailable: {
|
||||
value: null,
|
||||
writable: true,
|
||||
},
|
||||
isGPPAvailable: {
|
||||
get: function () {
|
||||
if (this._isGPPAvailable === null) {
|
||||
this._isGPPAvailable = false
|
||||
try {
|
||||
if (which.sync('g++')) {
|
||||
this._isGPPAvailable = true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return this._isGPPAvailable
|
||||
},
|
||||
},
|
||||
_isClangAvailable: {
|
||||
value: null,
|
||||
writable: true,
|
||||
},
|
||||
isClangAvailable: {
|
||||
get: function () {
|
||||
if (this._isClangAvailable === null) {
|
||||
this._isClangAvailable = false
|
||||
try {
|
||||
if (which.sync('clang++')) {
|
||||
this._isClangAvailable = true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
return this._isClangAvailable
|
||||
},
|
||||
},
|
||||
})
|
||||
250
node_modules/cmake-js/lib/import/Find-VisualStudio.cs
generated
vendored
Normal file
250
node_modules/cmake-js/lib/import/Find-VisualStudio.cs
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
// Copyright 2017 - Refael Ackermann
|
||||
// Distributed under MIT style license
|
||||
// See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
|
||||
|
||||
// Usage:
|
||||
// powershell -ExecutionPolicy Unrestricted -Command "Add-Type -Path Find-VisualStudio.cs; [VisualStudioConfiguration.Main]::PrintJson()"
|
||||
// This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VisualStudioConfiguration
|
||||
{
|
||||
[Flags]
|
||||
public enum InstanceState : uint
|
||||
{
|
||||
None = 0,
|
||||
Local = 1,
|
||||
Registered = 2,
|
||||
NoRebootRequired = 4,
|
||||
NoErrors = 8,
|
||||
Complete = 4294967295,
|
||||
}
|
||||
|
||||
[Guid("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface IEnumSetupInstances
|
||||
{
|
||||
|
||||
void Next([MarshalAs(UnmanagedType.U4), In] int celt,
|
||||
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface), Out] ISetupInstance[] rgelt,
|
||||
[MarshalAs(UnmanagedType.U4)] out int pceltFetched);
|
||||
|
||||
void Skip([MarshalAs(UnmanagedType.U4), In] int celt);
|
||||
|
||||
void Reset();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
IEnumSetupInstances Clone();
|
||||
}
|
||||
|
||||
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupConfiguration
|
||||
{
|
||||
}
|
||||
|
||||
[Guid("26AAB78C-4A60-49D6-AF3B-3C35BC93365D")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupConfiguration2 : ISetupConfiguration
|
||||
{
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
IEnumSetupInstances EnumInstances();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
ISetupInstance GetInstanceForCurrentProcess();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
ISetupInstance GetInstanceForPath([MarshalAs(UnmanagedType.LPWStr), In] string path);
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Interface)]
|
||||
IEnumSetupInstances EnumAllInstances();
|
||||
}
|
||||
|
||||
[Guid("B41463C3-8866-43B5-BC33-2B0676F7F42E")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupInstance
|
||||
{
|
||||
}
|
||||
|
||||
[Guid("89143C9A-05AF-49B0-B717-72E218A2185C")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupInstance2 : ISetupInstance
|
||||
{
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetInstanceId();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.Struct)]
|
||||
System.Runtime.InteropServices.ComTypes.FILETIME GetInstallDate();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetInstallationName();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetInstallationPath();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetInstallationVersion();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetDisplayName([MarshalAs(UnmanagedType.U4), In] int lcid);
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetDescription([MarshalAs(UnmanagedType.U4), In] int lcid);
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string ResolvePath([MarshalAs(UnmanagedType.LPWStr), In] string pwszRelativePath);
|
||||
|
||||
[return: MarshalAs(UnmanagedType.U4)]
|
||||
InstanceState GetState();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
|
||||
ISetupPackageReference[] GetPackages();
|
||||
|
||||
ISetupPackageReference GetProduct();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetProductPath();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.VariantBool)]
|
||||
bool IsLaunchable();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.VariantBool)]
|
||||
bool IsComplete();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
|
||||
ISetupPropertyStore GetProperties();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetEnginePath();
|
||||
}
|
||||
|
||||
[Guid("DA8D8A16-B2B6-4487-A2F1-594CCCCD6BF5")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupPackageReference
|
||||
{
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetId();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetVersion();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetChip();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetLanguage();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetBranch();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetType();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.BStr)]
|
||||
string GetUniqueId();
|
||||
|
||||
[return: MarshalAs(UnmanagedType.VariantBool)]
|
||||
bool GetIsExtension();
|
||||
}
|
||||
|
||||
[Guid("c601c175-a3be-44bc-91f6-4568d230fc83")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport]
|
||||
public interface ISetupPropertyStore
|
||||
{
|
||||
|
||||
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
|
||||
string[] GetNames();
|
||||
|
||||
object GetValue([MarshalAs(UnmanagedType.LPWStr), In] string pwszName);
|
||||
}
|
||||
|
||||
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
|
||||
[CoClass(typeof(SetupConfigurationClass))]
|
||||
[ComImport]
|
||||
public interface SetupConfiguration : ISetupConfiguration2, ISetupConfiguration
|
||||
{
|
||||
}
|
||||
|
||||
[Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D")]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
[ComImport]
|
||||
public class SetupConfigurationClass
|
||||
{
|
||||
}
|
||||
|
||||
public static class Main
|
||||
{
|
||||
public static void PrintJson()
|
||||
{
|
||||
ISetupConfiguration query = new SetupConfiguration();
|
||||
ISetupConfiguration2 query2 = (ISetupConfiguration2)query;
|
||||
IEnumSetupInstances e = query2.EnumAllInstances();
|
||||
|
||||
int pceltFetched;
|
||||
ISetupInstance2[] rgelt = new ISetupInstance2[1];
|
||||
List<string> instances = new List<string>();
|
||||
while (true)
|
||||
{
|
||||
e.Next(1, rgelt, out pceltFetched);
|
||||
if (pceltFetched <= 0)
|
||||
{
|
||||
Console.WriteLine(String.Format("[{0}]", string.Join(",", instances.ToArray())));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
instances.Add(InstanceJson(rgelt[0]));
|
||||
}
|
||||
catch (COMException)
|
||||
{
|
||||
// Ignore instances that can't be queried.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string JsonString(string s)
|
||||
{
|
||||
return "\"" + s.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
|
||||
}
|
||||
|
||||
private static string InstanceJson(ISetupInstance2 setupInstance2)
|
||||
{
|
||||
// Visual Studio component directory:
|
||||
// https://docs.microsoft.com/en-us/visualstudio/install/workload-and-component-ids
|
||||
|
||||
StringBuilder json = new StringBuilder();
|
||||
json.Append("{");
|
||||
|
||||
string path = JsonString(setupInstance2.GetInstallationPath());
|
||||
json.Append(String.Format("\"path\":{0},", path));
|
||||
|
||||
string version = JsonString(setupInstance2.GetInstallationVersion());
|
||||
json.Append(String.Format("\"version\":{0},", version));
|
||||
|
||||
List<string> packages = new List<string>();
|
||||
foreach (ISetupPackageReference package in setupInstance2.GetPackages())
|
||||
{
|
||||
string id = JsonString(package.GetId());
|
||||
packages.Add(id);
|
||||
}
|
||||
json.Append(String.Format("\"packages\":[{0}]", string.Join(",", packages.ToArray())));
|
||||
|
||||
json.Append("}");
|
||||
return json.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
node_modules/cmake-js/lib/import/LICENSE
generated
vendored
Normal file
24
node_modules/cmake-js/lib/import/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
6
node_modules/cmake-js/lib/import/README
generated
vendored
Normal file
6
node_modules/cmake-js/lib/import/README
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
This is a copy of some files from node-gyp, with some minor modifications.
|
||||
|
||||
Currently based on v10.0.1
|
||||
|
||||
node-gyp has a decent strategy for finding Visual Studio, and has a lot more developer time behind them to make a good and robust solution.
|
||||
We may as well benefit from their solution than reinvent it
|
||||
598
node_modules/cmake-js/lib/import/find-visualstudio.js
generated
vendored
Normal file
598
node_modules/cmake-js/lib/import/find-visualstudio.js
generated
vendored
Normal file
@@ -0,0 +1,598 @@
|
||||
'use strict'
|
||||
|
||||
const log = require('../logger')
|
||||
const { existsSync } = require('fs')
|
||||
const { win32: path } = require('path')
|
||||
const { regSearchKeys, execFile, logWithPrefix } = require('./util')
|
||||
const semver = require('semver')
|
||||
|
||||
class VisualStudioFinder {
|
||||
static findVisualStudio = (...args) => new VisualStudioFinder(...args).findVisualStudio()
|
||||
|
||||
log = logWithPrefix(log, 'find VS')
|
||||
|
||||
regSearchKeys = regSearchKeys
|
||||
|
||||
constructor(nodeSemver, configMsvsVersion) {
|
||||
this.nodeSemver = nodeSemver
|
||||
this.configMsvsVersion = configMsvsVersion
|
||||
this.errorLog = []
|
||||
this.validVersions = []
|
||||
}
|
||||
|
||||
// Logs a message at verbose level, but also saves it to be displayed later
|
||||
// at error level if an error occurs. This should help diagnose the problem.
|
||||
addLog(message) {
|
||||
this.log.verbose(message)
|
||||
this.errorLog.push(message)
|
||||
}
|
||||
|
||||
async findVisualStudio() {
|
||||
this.configVersionYear = null
|
||||
this.configPath = null
|
||||
if (this.configMsvsVersion) {
|
||||
this.addLog('msvs_version was set from command line or npm config')
|
||||
if (this.configMsvsVersion.match(/^\d{4}$/)) {
|
||||
this.configVersionYear = parseInt(this.configMsvsVersion, 10)
|
||||
this.addLog(`- looking for Visual Studio version ${this.configVersionYear}`)
|
||||
} else {
|
||||
this.configPath = path.resolve(this.configMsvsVersion)
|
||||
this.addLog(`- looking for Visual Studio installed in "${this.configPath}"`)
|
||||
}
|
||||
} else {
|
||||
this.addLog('msvs_version not set from command line or npm config')
|
||||
}
|
||||
|
||||
if (process.env.VCINSTALLDIR) {
|
||||
this.envVcInstallDir = path.resolve(process.env.VCINSTALLDIR, '..')
|
||||
this.addLog(
|
||||
'running in VS Command Prompt, installation path is:\n' +
|
||||
`"${this.envVcInstallDir}"\n- will only use this version`,
|
||||
)
|
||||
} else {
|
||||
this.addLog('VCINSTALLDIR not set, not running in VS Command Prompt')
|
||||
}
|
||||
|
||||
const checks = [
|
||||
() => this.findVisualStudio2019OrNewerFromSpecifiedLocation(),
|
||||
() => this.findVisualStudio2019OrNewerUsingSetupModule(),
|
||||
() => this.findVisualStudio2019OrNewer(),
|
||||
() => this.findVisualStudio2017FromSpecifiedLocation(),
|
||||
() => this.findVisualStudio2017UsingSetupModule(),
|
||||
() => this.findVisualStudio2017(),
|
||||
() => this.findVisualStudio2015(),
|
||||
() => this.findVisualStudio2013(),
|
||||
]
|
||||
|
||||
for (const check of checks) {
|
||||
const info = await check()
|
||||
if (info) {
|
||||
return this.succeed(info)
|
||||
}
|
||||
}
|
||||
|
||||
return this.fail()
|
||||
}
|
||||
|
||||
succeed(info) {
|
||||
this.log.info(
|
||||
`using VS${info.versionYear} (${info.version}) found at:` +
|
||||
`\n"${info.path}"` +
|
||||
'\nrun with --verbose for detailed information',
|
||||
)
|
||||
return info
|
||||
}
|
||||
|
||||
fail() {
|
||||
if (this.configMsvsVersion && this.envVcInstallDir) {
|
||||
this.errorLog.push('msvs_version does not match this VS Command Prompt or the', 'installation cannot be used.')
|
||||
} else if (this.configMsvsVersion) {
|
||||
// If msvs_version was specified but finding VS failed, print what would
|
||||
// have been accepted
|
||||
this.errorLog.push('')
|
||||
if (this.validVersions) {
|
||||
this.errorLog.push('valid versions for msvs_version:')
|
||||
this.validVersions.forEach((version) => {
|
||||
this.errorLog.push(`- "${version}"`)
|
||||
})
|
||||
} else {
|
||||
this.errorLog.push('no valid versions for msvs_version were found')
|
||||
}
|
||||
}
|
||||
|
||||
const errorLog = this.errorLog.join('\n')
|
||||
|
||||
// For Windows 80 col console, use up to the column before the one marked
|
||||
// with X (total 79 chars including logger prefix, 62 chars usable here):
|
||||
// X
|
||||
const infoLog = [
|
||||
'**************************************************************',
|
||||
'You need to install the latest version of Visual Studio',
|
||||
'including the "Desktop development with C++" workload.',
|
||||
'For more information consult the documentation at:',
|
||||
'https://github.com/nodejs/node-gyp#on-windows',
|
||||
'**************************************************************',
|
||||
].join('\n')
|
||||
|
||||
this.log.error(`\n${errorLog}\n\n${infoLog}\n`)
|
||||
throw new Error('Could not find any Visual Studio installation to use')
|
||||
}
|
||||
|
||||
async findVisualStudio2019OrNewerFromSpecifiedLocation() {
|
||||
return this.findVSFromSpecifiedLocation([2019, 2022, 2026])
|
||||
}
|
||||
|
||||
async findVisualStudio2017FromSpecifiedLocation() {
|
||||
if (semver.gte(this.nodeSemver, '22.0.0')) {
|
||||
this.addLog('not looking for VS2017 as it is only supported up to Node.js 21')
|
||||
return null
|
||||
}
|
||||
return this.findVSFromSpecifiedLocation([2017])
|
||||
}
|
||||
|
||||
async findVSFromSpecifiedLocation(supportedYears) {
|
||||
if (!this.envVcInstallDir) {
|
||||
return null
|
||||
}
|
||||
const info = {
|
||||
path: path.resolve(this.envVcInstallDir),
|
||||
// Assume the version specified by the user is correct.
|
||||
// Since Visual Studio 2015, the Developer Command Prompt sets the
|
||||
// VSCMD_VER environment variable which contains the version information
|
||||
// for Visual Studio.
|
||||
// https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022
|
||||
version: process.env.VSCMD_VER,
|
||||
packages: [
|
||||
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
|
||||
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
|
||||
// Assume MSBuild exists. It will be checked in processing.
|
||||
'Microsoft.VisualStudio.VC.MSBuild.Base',
|
||||
],
|
||||
}
|
||||
|
||||
// Is there a better way to get SDK information?
|
||||
const envWindowsSDKVersion = process.env.WindowsSDKVersion
|
||||
const sdkVersionMatched = envWindowsSDKVersion?.match(/^(\d+)\.(\d+)\.(\d+)\..*/)
|
||||
if (sdkVersionMatched) {
|
||||
info.packages.push(`Microsoft.VisualStudio.Component.Windows10SDK.${sdkVersionMatched[3]}.Desktop`)
|
||||
}
|
||||
// pass for further processing
|
||||
return this.processData([info], supportedYears)
|
||||
}
|
||||
|
||||
async findVisualStudio2019OrNewerUsingSetupModule() {
|
||||
return this.findNewVSUsingSetupModule([2019, 2022, 2026])
|
||||
}
|
||||
|
||||
async findVisualStudio2017UsingSetupModule() {
|
||||
if (semver.gte(this.nodeSemver, '22.0.0')) {
|
||||
this.addLog('not looking for VS2017 as it is only supported up to Node.js 21')
|
||||
return null
|
||||
}
|
||||
return this.findNewVSUsingSetupModule([2017])
|
||||
}
|
||||
|
||||
async findNewVSUsingSetupModule(supportedYears) {
|
||||
const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
|
||||
const vcInstallDir = this.envVcInstallDir
|
||||
|
||||
const checkModuleArgs = [
|
||||
'-NoProfile',
|
||||
'-Command',
|
||||
'&{@(Get-Module -ListAvailable -Name VSSetup).Version.ToString()}',
|
||||
]
|
||||
this.log.silly('Running', ps, checkModuleArgs)
|
||||
const [cErr] = await this.execFile(ps, checkModuleArgs)
|
||||
if (cErr) {
|
||||
this.addLog(
|
||||
'VSSetup module doesn\'t seem to exist. You can install it via: "Install-Module VSSetup -Scope CurrentUser"',
|
||||
)
|
||||
this.log.silly('VSSetup error = %j', cErr && (cErr.stack || cErr))
|
||||
return null
|
||||
}
|
||||
const filterArg = vcInstallDir !== undefined ? `| where {$_.InstallationPath -eq '${vcInstallDir}' }` : ''
|
||||
const psArgs = ['-NoProfile', '-Command', `&{Get-VSSetupInstance ${filterArg} | ConvertTo-Json -Depth 3}`]
|
||||
|
||||
this.log.silly('Running', ps, psArgs)
|
||||
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
|
||||
let parsedData = this.parseData(err, stdout, stderr)
|
||||
if (parsedData === null) {
|
||||
return null
|
||||
}
|
||||
this.log.silly('Parsed data', parsedData)
|
||||
if (!Array.isArray(parsedData)) {
|
||||
// if there are only 1 result, then Powershell will output non-array
|
||||
parsedData = [parsedData]
|
||||
}
|
||||
// normalize output
|
||||
parsedData = parsedData.map((info) => {
|
||||
info.path = info.InstallationPath
|
||||
info.version = `${info.InstallationVersion.Major}.${info.InstallationVersion.Minor}.${info.InstallationVersion.Build}.${info.InstallationVersion.Revision}`
|
||||
info.packages = info.Packages.map((p) => p.Id)
|
||||
return info
|
||||
})
|
||||
// pass for further processing
|
||||
return this.processData(parsedData, supportedYears)
|
||||
}
|
||||
|
||||
// Invoke the PowerShell script to get information about Visual Studio 2019
|
||||
// or newer installations
|
||||
async findVisualStudio2019OrNewer() {
|
||||
return this.findNewVS([2019, 2022, 2026])
|
||||
}
|
||||
|
||||
// Invoke the PowerShell script to get information about Visual Studio 2017
|
||||
async findVisualStudio2017() {
|
||||
if (semver.gte(this.nodeSemver, '22.0.0')) {
|
||||
this.addLog('not looking for VS2017 as it is only supported up to Node.js 21')
|
||||
return null
|
||||
}
|
||||
return this.findNewVS([2017])
|
||||
}
|
||||
|
||||
// Invoke the PowerShell script to get information about Visual Studio 2017
|
||||
// or newer installations
|
||||
async findNewVS(supportedYears) {
|
||||
const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
|
||||
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
|
||||
const psArgs = [
|
||||
'-ExecutionPolicy',
|
||||
'Unrestricted',
|
||||
'-NoProfile',
|
||||
'-Command',
|
||||
"&{Add-Type -Path '" + csFile + "';" + '[VisualStudioConfiguration.Main]::PrintJson()}',
|
||||
]
|
||||
|
||||
this.log.silly('Running', ps, psArgs)
|
||||
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
|
||||
const parsedData = this.parseData(err, stdout, stderr, { checkIsArray: true })
|
||||
if (parsedData === null) {
|
||||
return null
|
||||
}
|
||||
return this.processData(parsedData, supportedYears)
|
||||
}
|
||||
|
||||
// Parse the output of the PowerShell script, make sanity checks
|
||||
parseData(err, stdout, stderr, sanityCheckOptions) {
|
||||
const defaultOptions = {
|
||||
checkIsArray: false,
|
||||
}
|
||||
|
||||
// Merging provided options with the default options
|
||||
const sanityOptions = { ...defaultOptions, ...sanityCheckOptions }
|
||||
|
||||
this.log.silly('PS stderr = %j', stderr)
|
||||
|
||||
const failPowershell = (failureDetails) => {
|
||||
this.addLog(
|
||||
`could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details. \n
|
||||
Failure details: ${failureDetails}`,
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
if (err) {
|
||||
this.log.silly('PS err = %j', err && (err.stack || err))
|
||||
return failPowershell(`${err}`.substring(0, 40))
|
||||
}
|
||||
|
||||
let vsInfo
|
||||
try {
|
||||
vsInfo = JSON.parse(stdout)
|
||||
} catch (e) {
|
||||
this.log.silly('PS stdout = %j', stdout)
|
||||
this.log.silly(e)
|
||||
return failPowershell()
|
||||
}
|
||||
|
||||
if (sanityOptions.checkIsArray && !Array.isArray(vsInfo)) {
|
||||
this.log.silly('PS stdout = %j', stdout)
|
||||
return failPowershell('Expected array as output of the PS script')
|
||||
}
|
||||
return vsInfo
|
||||
}
|
||||
|
||||
// Process parsed data containing information about VS installations
|
||||
// Look for the required parts, extract and output them back
|
||||
processData(vsInfo, supportedYears) {
|
||||
vsInfo = vsInfo.map((info) => {
|
||||
this.log.silly(`processing installation: "${info.path}"`)
|
||||
info.path = path.resolve(info.path)
|
||||
const ret = this.getVersionInfo(info)
|
||||
ret.path = info.path
|
||||
ret.msBuild = this.getMSBuild(info, ret.versionYear)
|
||||
ret.toolset = this.getToolset(info, ret.versionYear)
|
||||
ret.sdk = this.getSDK(info)
|
||||
return ret
|
||||
})
|
||||
this.log.silly('vsInfo:', vsInfo)
|
||||
|
||||
// Remove future versions or errors parsing version number
|
||||
// Also remove any unsupported versions
|
||||
vsInfo = vsInfo.filter((info) => {
|
||||
if (info.versionYear && supportedYears.indexOf(info.versionYear) !== -1) {
|
||||
return true
|
||||
}
|
||||
this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`)
|
||||
return false
|
||||
})
|
||||
|
||||
// Sort to place newer versions first
|
||||
vsInfo.sort((a, b) => b.versionYear - a.versionYear)
|
||||
|
||||
for (let i = 0; i < vsInfo.length; ++i) {
|
||||
const info = vsInfo[i]
|
||||
this.addLog(`checking VS${info.versionYear} (${info.version}) found ` + `at:\n"${info.path}"`)
|
||||
|
||||
if (info.msBuild) {
|
||||
this.addLog('- found "Visual Studio C++ core features"')
|
||||
} else {
|
||||
this.addLog('- "Visual Studio C++ core features" missing')
|
||||
continue
|
||||
}
|
||||
|
||||
if (info.toolset) {
|
||||
this.addLog(`- found VC++ toolset: ${info.toolset}`)
|
||||
} else {
|
||||
this.addLog('- missing any VC++ toolset')
|
||||
continue
|
||||
}
|
||||
|
||||
if (info.sdk) {
|
||||
this.addLog(`- found Windows SDK: ${info.sdk}`)
|
||||
} else {
|
||||
this.addLog('- missing any Windows SDK')
|
||||
continue
|
||||
}
|
||||
|
||||
if (!this.checkConfigVersion(info.versionYear, info.path)) {
|
||||
continue
|
||||
}
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
this.addLog('could not find a version of Visual Studio 2017 or newer to use')
|
||||
return null
|
||||
}
|
||||
|
||||
// Helper - process version information
|
||||
getVersionInfo(info) {
|
||||
const match = /^(\d+)\.(\d+)(?:\..*)?/.exec(info.version)
|
||||
if (!match) {
|
||||
this.log.silly('- failed to parse version:', info.version)
|
||||
return {}
|
||||
}
|
||||
this.log.silly('- version match = %j', match)
|
||||
const ret = {
|
||||
version: info.version,
|
||||
versionMajor: parseInt(match[1], 10),
|
||||
versionMinor: parseInt(match[2], 10),
|
||||
}
|
||||
if (ret.versionMajor === 15) {
|
||||
ret.versionYear = 2017
|
||||
return ret
|
||||
}
|
||||
if (ret.versionMajor === 16) {
|
||||
ret.versionYear = 2019
|
||||
return ret
|
||||
}
|
||||
if (ret.versionMajor === 17) {
|
||||
ret.versionYear = 2022
|
||||
return ret
|
||||
}
|
||||
if (ret.versionMajor === 18) {
|
||||
ret.versionYear = 2026
|
||||
return ret
|
||||
}
|
||||
this.log.silly('- unsupported version:', ret.versionMajor)
|
||||
return {}
|
||||
}
|
||||
|
||||
msBuildPathExists(path) {
|
||||
return existsSync(path)
|
||||
}
|
||||
|
||||
// Helper - process MSBuild information
|
||||
getMSBuild(info, versionYear) {
|
||||
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
|
||||
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
|
||||
const msbuildPathArm64 = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'arm64', 'MSBuild.exe')
|
||||
if (info.packages.indexOf(pkg) !== -1) {
|
||||
this.log.silly('- found VC.MSBuild.Base')
|
||||
if (versionYear === 2017) {
|
||||
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
|
||||
}
|
||||
if (versionYear === 2019) {
|
||||
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
|
||||
return msbuildPathArm64
|
||||
} else {
|
||||
return msbuildPath
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Visual Studio 2022 doesn't have the MSBuild package.
|
||||
* Support for compiling _on_ ARM64 was added in MSVC 14.32.31326,
|
||||
* so let's leverage it if the user has an ARM64 device.
|
||||
*/
|
||||
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
|
||||
return msbuildPathArm64
|
||||
} else if (this.msBuildPathExists(msbuildPath)) {
|
||||
return msbuildPath
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Helper - process toolset information
|
||||
getToolset(info, versionYear) {
|
||||
const vcToolsArm64 = 'VC.Tools.ARM64'
|
||||
const pkgArm64 = `Microsoft.VisualStudio.Component.${vcToolsArm64}`
|
||||
const vcToolsX64 = 'VC.Tools.x86.x64'
|
||||
const pkgX64 = `Microsoft.VisualStudio.Component.${vcToolsX64}`
|
||||
const express = 'Microsoft.VisualStudio.WDExpress'
|
||||
|
||||
if (process.arch === 'arm64' && info.packages.includes(pkgArm64)) {
|
||||
this.log.silly(`- found ${vcToolsArm64}`)
|
||||
} else if (info.packages.includes(pkgX64)) {
|
||||
if (process.arch === 'arm64') {
|
||||
this.addLog(
|
||||
`- found ${vcToolsX64} on ARM64 platform. Expect less performance and/or link failure with ARM64 binary.`,
|
||||
)
|
||||
} else {
|
||||
this.log.silly(`- found ${vcToolsX64}`)
|
||||
}
|
||||
} else if (info.packages.includes(express)) {
|
||||
this.log.silly('- found Visual Studio Express (looking for toolset)')
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
||||
if (versionYear === 2017) {
|
||||
return 'v141'
|
||||
} else if (versionYear === 2019) {
|
||||
return 'v142'
|
||||
} else if (versionYear === 2022) {
|
||||
return 'v143'
|
||||
} else if (versionYear === 2026) {
|
||||
return 'v145'
|
||||
}
|
||||
this.log.silly('- invalid versionYear:', versionYear)
|
||||
return null
|
||||
}
|
||||
|
||||
// Helper - process Windows SDK information
|
||||
getSDK(info) {
|
||||
const win8SDK = 'Microsoft.VisualStudio.Component.Windows81SDK'
|
||||
const win10SDKPrefix = 'Microsoft.VisualStudio.Component.Windows10SDK.'
|
||||
const win11SDKPrefix = 'Microsoft.VisualStudio.Component.Windows11SDK.'
|
||||
|
||||
let Win10or11SDKVer = 0
|
||||
info.packages.forEach((pkg) => {
|
||||
if (!pkg.startsWith(win10SDKPrefix) && !pkg.startsWith(win11SDKPrefix)) {
|
||||
return
|
||||
}
|
||||
const parts = pkg.split('.')
|
||||
if (parts.length > 5 && parts[5] !== 'Desktop') {
|
||||
this.log.silly('- ignoring non-Desktop Win10/11SDK:', pkg)
|
||||
return
|
||||
}
|
||||
const foundSdkVer = parseInt(parts[4], 10)
|
||||
if (isNaN(foundSdkVer)) {
|
||||
// Microsoft.VisualStudio.Component.Windows10SDK.IpOverUsb
|
||||
this.log.silly('- failed to parse Win10/11SDK number:', pkg)
|
||||
return
|
||||
}
|
||||
this.log.silly('- found Win10/11SDK:', foundSdkVer)
|
||||
Win10or11SDKVer = Math.max(Win10or11SDKVer, foundSdkVer)
|
||||
})
|
||||
|
||||
if (Win10or11SDKVer !== 0) {
|
||||
return `10.0.${Win10or11SDKVer}.0`
|
||||
} else if (info.packages.indexOf(win8SDK) !== -1) {
|
||||
this.log.silly('- found Win8SDK')
|
||||
return '8.1'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Find an installation of Visual Studio 2015 to use
|
||||
async findVisualStudio2015() {
|
||||
if (semver.gte(this.nodeSemver, '19.0.0')) {
|
||||
this.addLog('not looking for VS2015 as it is only supported up to Node.js 18')
|
||||
return null
|
||||
}
|
||||
return this.findOldVS({
|
||||
version: '14.0',
|
||||
versionMajor: 14,
|
||||
versionMinor: 0,
|
||||
versionYear: 2015,
|
||||
toolset: 'v140',
|
||||
})
|
||||
}
|
||||
|
||||
// Find an installation of Visual Studio 2013 to use
|
||||
async findVisualStudio2013() {
|
||||
if (semver.gte(this.nodeSemver, '9.0.0')) {
|
||||
this.addLog('not looking for VS2013 as it is only supported up to Node.js 8')
|
||||
return null
|
||||
}
|
||||
return this.findOldVS({
|
||||
version: '12.0',
|
||||
versionMajor: 12,
|
||||
versionMinor: 0,
|
||||
versionYear: 2013,
|
||||
toolset: 'v120',
|
||||
})
|
||||
}
|
||||
|
||||
// Helper - common code for VS2013 and VS2015
|
||||
async findOldVS(info) {
|
||||
const regVC7 = [
|
||||
'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7',
|
||||
'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7',
|
||||
]
|
||||
const regMSBuild = 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions'
|
||||
|
||||
this.addLog(`looking for Visual Studio ${info.versionYear}`)
|
||||
try {
|
||||
let res = await this.regSearchKeys(regVC7, info.version, [])
|
||||
const vsPath = path.resolve(res, '..')
|
||||
this.addLog(`- found in "${vsPath}"`)
|
||||
const msBuildRegOpts = process.arch === 'ia32' ? [] : ['/reg:32']
|
||||
|
||||
try {
|
||||
res = await this.regSearchKeys([`${regMSBuild}\\${info.version}`], 'MSBuildToolsPath', msBuildRegOpts)
|
||||
} catch (err) {
|
||||
this.addLog('- could not find MSBuild in registry for this version')
|
||||
return null
|
||||
}
|
||||
|
||||
const msBuild = path.join(res, 'MSBuild.exe')
|
||||
this.addLog(`- MSBuild in "${msBuild}"`)
|
||||
|
||||
if (!this.checkConfigVersion(info.versionYear, vsPath)) {
|
||||
return null
|
||||
}
|
||||
|
||||
info.path = vsPath
|
||||
info.msBuild = msBuild
|
||||
info.sdk = null
|
||||
return info
|
||||
} catch (err) {
|
||||
this.addLog('- not found')
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// After finding a usable version of Visual Studio:
|
||||
// - add it to validVersions to be displayed at the end if a specific
|
||||
// version was requested and not found;
|
||||
// - check if this is the version that was requested.
|
||||
// - check if this matches the Visual Studio Command Prompt
|
||||
checkConfigVersion(versionYear, vsPath) {
|
||||
this.validVersions.push(versionYear)
|
||||
this.validVersions.push(vsPath)
|
||||
|
||||
if (this.configVersionYear && this.configVersionYear !== versionYear) {
|
||||
this.addLog('- msvs_version does not match this version')
|
||||
return false
|
||||
}
|
||||
if (this.configPath && path.relative(this.configPath, vsPath) !== '') {
|
||||
this.addLog('- msvs_version does not point to this installation')
|
||||
return false
|
||||
}
|
||||
if (this.envVcInstallDir && path.relative(this.envVcInstallDir, vsPath) !== '') {
|
||||
this.addLog('- does not match this Visual Studio Command Prompt')
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
async execFile(exec, args) {
|
||||
return await execFile(exec, args, { encoding: 'utf8' })
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VisualStudioFinder
|
||||
70
node_modules/cmake-js/lib/import/util.js
generated
vendored
Normal file
70
node_modules/cmake-js/lib/import/util.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict'
|
||||
|
||||
const log = require('../logger')
|
||||
const cp = require('child_process')
|
||||
const path = require('path')
|
||||
|
||||
const execFile = async (...args) =>
|
||||
new Promise((resolve) => {
|
||||
const child = cp.execFile(...args, (...a) => resolve(a))
|
||||
child.stdin.end()
|
||||
})
|
||||
|
||||
function logWithPrefix(log, prefix) {
|
||||
function setPrefix(logFunction) {
|
||||
return (...args) => logFunction.apply(null, [prefix, ...args]) // eslint-disable-line
|
||||
}
|
||||
return {
|
||||
silly: setPrefix(log.silly),
|
||||
verbose: setPrefix(log.verbose),
|
||||
info: setPrefix(log.info),
|
||||
warn: setPrefix(log.warn),
|
||||
error: setPrefix(log.error),
|
||||
}
|
||||
}
|
||||
|
||||
async function regGetValue(key, value, addOpts) {
|
||||
const outReValue = value.replace(/\W/g, '.')
|
||||
const outRe = new RegExp(`^\\s+${outReValue}\\s+REG_\\w+\\s+(\\S.*)$`, 'im')
|
||||
const reg = path.join(process.env.SystemRoot, 'System32', 'reg.exe')
|
||||
const regArgs = ['query', key, '/v', value].concat(addOpts)
|
||||
|
||||
log.silly('reg', 'running', reg, regArgs)
|
||||
const [err, stdout, stderr] = await execFile(reg, regArgs, { encoding: 'utf8' })
|
||||
|
||||
log.silly('reg', 'reg.exe stdout = %j', stdout)
|
||||
if (err || stderr.trim() !== '') {
|
||||
log.silly('reg', 'reg.exe err = %j', err && (err.stack || err))
|
||||
log.silly('reg', 'reg.exe stderr = %j', stderr)
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
throw new Error(stderr)
|
||||
}
|
||||
|
||||
const result = outRe.exec(stdout)
|
||||
if (!result) {
|
||||
log.silly('reg', 'error parsing stdout')
|
||||
throw new Error('Could not parse output of reg.exe')
|
||||
}
|
||||
|
||||
log.silly('reg', 'found: %j', result[1])
|
||||
return result[1]
|
||||
}
|
||||
|
||||
async function regSearchKeys(keys, value, addOpts) {
|
||||
for (const key of keys) {
|
||||
try {
|
||||
return await regGetValue(key, value, addOpts)
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
logWithPrefix: logWithPrefix,
|
||||
regGetValue: regGetValue,
|
||||
regSearchKeys: regSearchKeys,
|
||||
execFile: execFile,
|
||||
}
|
||||
12
node_modules/cmake-js/lib/index.js
generated
vendored
Normal file
12
node_modules/cmake-js/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
BuildSystem: require('./buildSystem'),
|
||||
CMLog: require('./cmLog'),
|
||||
environment: require('./environment'),
|
||||
TargetOptions: require('./targetOptions'),
|
||||
Dist: require('./dist'),
|
||||
CMake: require('./cMake'),
|
||||
downloader: require('./downloader'),
|
||||
Toolset: require('./toolset'),
|
||||
}
|
||||
63
node_modules/cmake-js/lib/locateNAN.js
generated
vendored
Normal file
63
node_modules/cmake-js/lib/locateNAN.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict'
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
const isNANModule = async function (dir) {
|
||||
const h = path.join(dir, 'nan.h')
|
||||
try {
|
||||
const stat = await fs.stat(h)
|
||||
return stat.isFile()
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function isNodeJSProject(dir) {
|
||||
const pjson = path.join(dir, 'package.json')
|
||||
const node_modules = path.join(dir, 'node_modules')
|
||||
try {
|
||||
let stat = await fs.stat(pjson)
|
||||
if (stat.isFile()) {
|
||||
return true
|
||||
}
|
||||
stat = await fs.stat(node_modules)
|
||||
if (stat.isDirectory()) {
|
||||
return true
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const locateNAN = (module.exports = async function (projectRoot) {
|
||||
if (locateNAN.__projectRoot) {
|
||||
// Override for unit tests
|
||||
projectRoot = locateNAN.__projectRoot
|
||||
}
|
||||
|
||||
let result = await isNodeJSProject(projectRoot)
|
||||
if (!result) {
|
||||
return null
|
||||
}
|
||||
|
||||
const nanModulePath = path.join(projectRoot, 'node_modules', 'nan')
|
||||
result = await isNANModule(nanModulePath)
|
||||
if (result) {
|
||||
return nanModulePath
|
||||
}
|
||||
|
||||
// Goto upper level:
|
||||
return await locateNAN(goUp(projectRoot))
|
||||
})
|
||||
|
||||
function goUp(dir) {
|
||||
const items = dir.split(path.sep)
|
||||
const scopeItem = items[items.length - 2]
|
||||
if (scopeItem && scopeItem[0] === '@') {
|
||||
// skip scope
|
||||
dir = path.join(dir, '..')
|
||||
}
|
||||
dir = path.join(dir, '..', '..')
|
||||
return path.normalize(dir)
|
||||
}
|
||||
18
node_modules/cmake-js/lib/locateNodeApi.js
generated
vendored
Normal file
18
node_modules/cmake-js/lib/locateNodeApi.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
const locateNodeApi = (module.exports = async function (projectRoot) {
|
||||
if (locateNodeApi.__projectRoot) {
|
||||
// Override for unit tests
|
||||
projectRoot = locateNodeApi.__projectRoot
|
||||
}
|
||||
|
||||
try {
|
||||
const tmpRequire = require('module').createRequire(path.join(projectRoot, 'package.json'))
|
||||
const inc = tmpRequire('node-addon-api')
|
||||
return inc.include.replace(/"/g, '')
|
||||
} catch (e) {
|
||||
// It most likely wasn't found
|
||||
return null
|
||||
}
|
||||
})
|
||||
59
node_modules/cmake-js/lib/logger.js
generated
vendored
Normal file
59
node_modules/cmake-js/lib/logger.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
const util = require('util')
|
||||
|
||||
const levels = {
|
||||
silly: -Infinity,
|
||||
verbose: 1000,
|
||||
info: 2000,
|
||||
http: 3000,
|
||||
warn: 4000,
|
||||
error: 5000,
|
||||
silent: Infinity,
|
||||
}
|
||||
|
||||
const colors = {
|
||||
silly: 'inverse',
|
||||
verbose: 'blue',
|
||||
info: 'green',
|
||||
http: 'green',
|
||||
warn: 'yellow',
|
||||
error: 'red',
|
||||
}
|
||||
|
||||
let currentLevel = levels.info
|
||||
|
||||
function log(level, prefix, message, ...args) {
|
||||
if (currentLevel <= levels[level]) {
|
||||
const stream = level === 'error' ? process.stderr : process.stdout
|
||||
const color = colors[level]
|
||||
let levelStr = level.toUpperCase()
|
||||
if (process.stdout.isTTY && util.styleText) {
|
||||
// util.styleText is available in Node.js >= 20.12.0
|
||||
levelStr = util.styleText(color, levelStr)
|
||||
if (prefix) prefix = util.styleText('magenta', prefix)
|
||||
}
|
||||
|
||||
const formattedMessage = util.format(message, ...args)
|
||||
const line = prefix
|
||||
? util.format('%s %s %s', levelStr, prefix, formattedMessage)
|
||||
: util.format('%s %s', levelStr, formattedMessage)
|
||||
|
||||
stream.write(line + '\n')
|
||||
}
|
||||
}
|
||||
|
||||
const logger = {
|
||||
get level() {
|
||||
return Object.keys(levels).find((key) => levels[key] === currentLevel)
|
||||
},
|
||||
set level(newLevel) {
|
||||
if (levels[newLevel] !== undefined) {
|
||||
currentLevel = levels[newLevel]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
for (const level of Object.keys(colors)) {
|
||||
logger[level] = (prefix, message, ...args) => log(level, prefix, message, ...args)
|
||||
}
|
||||
|
||||
module.exports = logger
|
||||
31
node_modules/cmake-js/lib/npmConfig.js
generated
vendored
Normal file
31
node_modules/cmake-js/lib/npmConfig.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict'
|
||||
|
||||
function getNpmConfig() {
|
||||
const npmOptions = {}
|
||||
const npmConfigPrefix = 'npm_config_'
|
||||
Object.keys(process.env).forEach(function (name) {
|
||||
if (name.indexOf(npmConfigPrefix) !== 0) {
|
||||
return
|
||||
}
|
||||
const value = process.env[name]
|
||||
name = name.substring(npmConfigPrefix.length)
|
||||
if (name) {
|
||||
npmOptions[name] = value
|
||||
}
|
||||
}, this)
|
||||
|
||||
return npmOptions
|
||||
}
|
||||
|
||||
module.exports = function (log) {
|
||||
log.verbose('CFG', 'Looking for NPM config.')
|
||||
const options = getNpmConfig()
|
||||
|
||||
if (options) {
|
||||
log.silly('CFG', 'NPM options:', options)
|
||||
} else {
|
||||
log.verbose('CFG', 'There are no NPM options available.')
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
53
node_modules/cmake-js/lib/processHelpers.js
generated
vendored
Normal file
53
node_modules/cmake-js/lib/processHelpers.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict'
|
||||
const spawn = require('child_process').spawn
|
||||
const execFile = require('child_process').execFile
|
||||
|
||||
const processHelpers = {
|
||||
run: function (command, options) {
|
||||
if (!options) options = {}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
const env = Object.assign({}, process.env)
|
||||
if (env.Path && env.PATH) {
|
||||
if (env.Path !== env.PATH) {
|
||||
env.PATH = env.Path + ';' + env.PATH
|
||||
}
|
||||
delete env.Path
|
||||
}
|
||||
const child = spawn(command[0], command.slice(1), {
|
||||
stdio: options.silent ? 'ignore' : 'inherit',
|
||||
env,
|
||||
})
|
||||
let ended = false
|
||||
child.on('error', function (e) {
|
||||
if (!ended) {
|
||||
reject(e)
|
||||
ended = true
|
||||
}
|
||||
})
|
||||
child.on('exit', function (code, signal) {
|
||||
if (!ended) {
|
||||
if (code === 0) {
|
||||
resolve()
|
||||
} else {
|
||||
reject(new Error('Process terminated: ' + code || signal))
|
||||
}
|
||||
ended = true
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
execFile: function (command) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
execFile(command[0], command.slice(1), function (err, stdout, stderr) {
|
||||
if (err) {
|
||||
reject(new Error(err.message + '\n' + (stdout || stderr)))
|
||||
} else {
|
||||
resolve(stdout)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = processHelpers
|
||||
95
node_modules/cmake-js/lib/runtimePaths.js
generated
vendored
Normal file
95
node_modules/cmake-js/lib/runtimePaths.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict'
|
||||
const assert = require('assert')
|
||||
const semver = require('semver')
|
||||
|
||||
const NODE_MIRROR = process.env.NVM_NODEJS_ORG_MIRROR || 'https://nodejs.org/dist'
|
||||
const ELECTRON_MIRROR = process.env.ELECTRON_MIRROR || 'https://artifacts.electronjs.org/headers/dist'
|
||||
|
||||
const runtimePaths = {
|
||||
node: function (targetOptions) {
|
||||
if (semver.lt(targetOptions.runtimeVersion, '4.0.0')) {
|
||||
return {
|
||||
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
|
||||
winLibs: [
|
||||
{
|
||||
dir: targetOptions.isX64 ? 'x64' : '',
|
||||
name: targetOptions.runtime + '.lib',
|
||||
},
|
||||
],
|
||||
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '.tar.gz',
|
||||
headerOnly: false,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
|
||||
winLibs: [
|
||||
{
|
||||
dir: targetOptions.isArm64 ? 'win-arm64' : targetOptions.isX64 ? 'win-x64' : 'win-x86',
|
||||
name: targetOptions.runtime + '.lib',
|
||||
},
|
||||
],
|
||||
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '-headers.tar.gz',
|
||||
headerOnly: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
nw: function (targetOptions) {
|
||||
if (semver.gte(targetOptions.runtimeVersion, '0.13.0')) {
|
||||
return {
|
||||
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
|
||||
winLibs: [
|
||||
{
|
||||
dir: targetOptions.isX64 ? 'x64' : '',
|
||||
name: targetOptions.runtime + '.lib',
|
||||
},
|
||||
{
|
||||
dir: targetOptions.isX64 ? 'x64' : '',
|
||||
name: 'node.lib',
|
||||
},
|
||||
],
|
||||
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
|
||||
headerOnly: false,
|
||||
}
|
||||
}
|
||||
return {
|
||||
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
|
||||
winLibs: [
|
||||
{
|
||||
dir: targetOptions.isX64 ? 'x64' : '',
|
||||
name: targetOptions.runtime + '.lib',
|
||||
},
|
||||
],
|
||||
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
|
||||
headerOnly: false,
|
||||
}
|
||||
},
|
||||
electron: function (targetOptions) {
|
||||
return {
|
||||
externalPath: ELECTRON_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
|
||||
winLibs: [
|
||||
{
|
||||
dir: targetOptions.isArm64 ? 'arm64' : targetOptions.isX64 ? 'x64' : '',
|
||||
name: 'node.lib',
|
||||
},
|
||||
],
|
||||
tarPath: 'node' + '-v' + targetOptions.runtimeVersion + '.tar.gz',
|
||||
headerOnly: semver.gte(targetOptions.runtimeVersion, '4.0.0-alpha'),
|
||||
}
|
||||
},
|
||||
get: function (targetOptions) {
|
||||
assert(targetOptions && typeof targetOptions === 'object')
|
||||
|
||||
const runtime = targetOptions.runtime
|
||||
const func = runtimePaths[runtime]
|
||||
let paths
|
||||
if (typeof func === 'function') {
|
||||
paths = func(targetOptions)
|
||||
if (paths && typeof paths === 'object') {
|
||||
return paths
|
||||
}
|
||||
}
|
||||
throw new Error('Unknown runtime: ' + runtime)
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = runtimePaths
|
||||
33
node_modules/cmake-js/lib/targetOptions.js
generated
vendored
Normal file
33
node_modules/cmake-js/lib/targetOptions.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
const environment = require('./environment')
|
||||
|
||||
class TargetOptions {
|
||||
get arch() {
|
||||
return this.options.arch || environment.arch
|
||||
}
|
||||
get isX86() {
|
||||
return this.arch === 'ia32' || this.arch === 'x86'
|
||||
}
|
||||
get isX64() {
|
||||
return this.arch === 'x64'
|
||||
}
|
||||
get isArm() {
|
||||
return this.arch === 'arm'
|
||||
}
|
||||
get isArm64() {
|
||||
return this.arch === 'arm64'
|
||||
}
|
||||
get runtime() {
|
||||
return this.options.runtime || environment.runtime
|
||||
}
|
||||
get runtimeVersion() {
|
||||
return this.options.runtimeVersion || environment.runtimeVersion
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TargetOptions
|
||||
224
node_modules/cmake-js/lib/toolset.js
generated
vendored
Normal file
224
node_modules/cmake-js/lib/toolset.js
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
'use strict'
|
||||
const TargetOptions = require('./targetOptions')
|
||||
const environment = require('./environment')
|
||||
const assert = require('assert')
|
||||
const CMLog = require('./cmLog')
|
||||
const { findVisualStudio } = environment.isWin ? require('./import/find-visualstudio') : {}
|
||||
|
||||
class Toolset {
|
||||
constructor(options) {
|
||||
this.options = options || {}
|
||||
this.targetOptions = new TargetOptions(this.options)
|
||||
this.generator = options.generator
|
||||
this.toolset = options.toolset
|
||||
this.platform = options.platform
|
||||
this.target = options.target
|
||||
this.cCompilerPath = options.cCompilerPath
|
||||
this.cppCompilerPath = options.cppCompilerPath
|
||||
this.compilerFlags = []
|
||||
this.linkerFlags = []
|
||||
this.makePath = null
|
||||
this.log = new CMLog(this.options)
|
||||
this._initialized = false
|
||||
}
|
||||
async initialize(install) {
|
||||
if (!this._initialized) {
|
||||
if (environment.isWin) {
|
||||
await this.initializeWin(install)
|
||||
} else {
|
||||
this.initializePosix(install)
|
||||
}
|
||||
this._initialized = true
|
||||
}
|
||||
}
|
||||
initializePosix(install) {
|
||||
if (!this.cCompilerPath || !this.cppCompilerPath) {
|
||||
// 1: Compiler
|
||||
if (!environment.isGPPAvailable && !environment.isClangAvailable) {
|
||||
if (environment.isOSX) {
|
||||
throw new Error(
|
||||
"C++ Compiler toolset is not available. Install Xcode Commandline Tools from Apple Dev Center, or install Clang with homebrew by invoking: 'brew install llvm --with-clang --with-asan'.",
|
||||
)
|
||||
} else {
|
||||
throw new Error(
|
||||
"C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.preferClang && environment.isClangAvailable) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using clang++ compiler, because preferClang option is set, and clang++ is available.')
|
||||
}
|
||||
this.cppCompilerPath = this.cppCompilerPath || 'clang++'
|
||||
this.cCompilerPath = this.cCompilerPath || 'clang'
|
||||
} else if (this.options.preferGnu && environment.isGPPAvailable) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using g++ compiler, because preferGnu option is set, and g++ is available.')
|
||||
}
|
||||
this.cppCompilerPath = this.cppCompilerPath || 'g++'
|
||||
this.cCompilerPath = this.cCompilerPath || 'gcc'
|
||||
}
|
||||
}
|
||||
// if it's already set because of options...
|
||||
if (this.generator) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using ' + this.generator + ' generator, as specified from commandline.')
|
||||
}
|
||||
}
|
||||
|
||||
// 2: Generator
|
||||
else if (environment.isOSX) {
|
||||
if (this.options.preferXcode) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using Xcode generator, because preferXcode option is set.')
|
||||
}
|
||||
this.generator = 'Xcode'
|
||||
} else if (this.options.preferMake && environment.isMakeAvailable) {
|
||||
if (install) {
|
||||
this.log.info(
|
||||
'TOOL',
|
||||
'Using Unix Makefiles generator, because preferMake option is set, and make is available.',
|
||||
)
|
||||
}
|
||||
this.generator = 'Unix Makefiles'
|
||||
} else if (environment.isNinjaAvailable) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using Ninja generator, because ninja is available.')
|
||||
}
|
||||
this.generator = 'Ninja'
|
||||
} else {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using Unix Makefiles generator.')
|
||||
}
|
||||
this.generator = 'Unix Makefiles'
|
||||
}
|
||||
} else {
|
||||
if (this.options.preferMake && environment.isMakeAvailable) {
|
||||
if (install) {
|
||||
this.log.info(
|
||||
'TOOL',
|
||||
'Using Unix Makefiles generator, because preferMake option is set, and make is available.',
|
||||
)
|
||||
}
|
||||
this.generator = 'Unix Makefiles'
|
||||
} else if (environment.isNinjaAvailable) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using Ninja generator, because ninja is available.')
|
||||
}
|
||||
this.generator = 'Ninja'
|
||||
} else {
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using Unix Makefiles generator.')
|
||||
}
|
||||
this.generator = 'Unix Makefiles'
|
||||
}
|
||||
}
|
||||
|
||||
// 3: Flags
|
||||
if (environment.isOSX) {
|
||||
if (install) {
|
||||
this.log.verbose('TOOL', 'Setting default OSX compiler flags.')
|
||||
}
|
||||
|
||||
this.compilerFlags.push('-D_DARWIN_USE_64_BIT_INODE=1')
|
||||
this.compilerFlags.push('-D_LARGEFILE_SOURCE')
|
||||
this.compilerFlags.push('-D_FILE_OFFSET_BITS=64')
|
||||
this.linkerFlags.push('-undefined dynamic_lookup')
|
||||
}
|
||||
|
||||
this.compilerFlags.push('-DBUILDING_NODE_EXTENSION')
|
||||
|
||||
// 4: Build target
|
||||
if (this.options.target) {
|
||||
this.log.info('TOOL', 'Building only the ' + this.options.target + ' target, as specified from the command line.')
|
||||
}
|
||||
}
|
||||
async initializeWin(install) {
|
||||
if (!this.generator) {
|
||||
const foundVsInfo = await this._getTopSupportedVisualStudioGenerator()
|
||||
if (foundVsInfo) {
|
||||
if (install) {
|
||||
this.log.info('TOOL', `Using ${foundVsInfo.generator} generator.`)
|
||||
}
|
||||
this.generator = foundVsInfo.generator
|
||||
|
||||
const isAboveVS16 = foundVsInfo.versionMajor >= 16
|
||||
|
||||
// The CMake Visual Studio Generator does not support the Win64 or ARM suffix on
|
||||
// the generator name. Instead the generator platform must be set explicitly via
|
||||
// the platform parameter
|
||||
if (!this.platform && isAboveVS16) {
|
||||
switch (this.targetOptions.arch) {
|
||||
case 'ia32':
|
||||
case 'x86':
|
||||
this.platform = 'Win32'
|
||||
break
|
||||
case 'x64':
|
||||
this.platform = 'x64'
|
||||
break
|
||||
case 'arm':
|
||||
this.platform = 'ARM'
|
||||
break
|
||||
case 'arm64':
|
||||
this.platform = 'ARM64'
|
||||
break
|
||||
default:
|
||||
this.log.warn('TOOL', 'Unknown NodeJS architecture: ' + this.targetOptions.arch)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error('There is no Visual C++ compiler installed. Install Visual C++ Build Toolset or Visual Studio.')
|
||||
}
|
||||
} else {
|
||||
// if it's already set because of options...
|
||||
if (install) {
|
||||
this.log.info('TOOL', 'Using ' + this.options.generator + ' generator, as specified from commandline.')
|
||||
}
|
||||
}
|
||||
|
||||
this.linkerFlags.push('/DELAYLOAD:NODE.EXE')
|
||||
|
||||
if (this.targetOptions.isX86) {
|
||||
if (install) {
|
||||
this.log.verbose('TOOL', 'Setting SAFESEH:NO linker flag.')
|
||||
}
|
||||
this.linkerFlags.push('/SAFESEH:NO')
|
||||
}
|
||||
}
|
||||
async _getTopSupportedVisualStudioGenerator() {
|
||||
const CMake = require('./cMake')
|
||||
assert(environment.isWin)
|
||||
|
||||
const selectedVs = await findVisualStudio(environment.runtimeVersion, this.options.msvsVersion)
|
||||
if (!selectedVs) return null
|
||||
|
||||
const list = await CMake.getGenerators(this.options, this.log)
|
||||
for (const gen of list) {
|
||||
const found = gen.startsWith(`Visual Studio ${selectedVs.versionMajor}`)
|
||||
if (!found) {
|
||||
continue
|
||||
}
|
||||
|
||||
// unlike previous versions "Visual Studio 16 2019" and onwards don't end with arch name
|
||||
const isAboveVS16 = selectedVs.versionMajor >= 16
|
||||
if (!isAboveVS16) {
|
||||
const is64Bit = gen.endsWith('Win64')
|
||||
if ((this.targetOptions.isX86 && is64Bit) || (this.targetOptions.isX64 && !is64Bit)) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...selectedVs,
|
||||
generator: gen,
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing matched
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Toolset
|
||||
1
node_modules/cmake-js/node_modules/.bin/node-which
generated
vendored
Symbolic link
1
node_modules/cmake-js/node_modules/.bin/node-which
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../which/bin/which.js
|
||||
63
node_modules/cmake-js/node_modules/chownr/LICENSE.md
generated
vendored
Normal file
63
node_modules/cmake-js/node_modules/chownr/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
All packages under `src/` are licensed according to the terms in
|
||||
their respective `LICENSE` or `LICENSE.md` files.
|
||||
|
||||
The remainder of this project is licensed under the Blue Oak
|
||||
Model License, as follows:
|
||||
|
||||
-----
|
||||
|
||||
# Blue Oak Model License
|
||||
|
||||
Version 1.0.0
|
||||
|
||||
## Purpose
|
||||
|
||||
This license gives everyone as much permission to work with
|
||||
this software as possible, while protecting contributors
|
||||
from liability.
|
||||
|
||||
## Acceptance
|
||||
|
||||
In order to receive this license, you must agree to its
|
||||
rules. The rules of this license are both obligations
|
||||
under that agreement and conditions to your license.
|
||||
You must not do anything with this software that triggers
|
||||
a rule that you cannot or will not follow.
|
||||
|
||||
## Copyright
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe that contributor's
|
||||
copyright in it.
|
||||
|
||||
## Notices
|
||||
|
||||
You must ensure that everyone who gets a copy of
|
||||
any part of this software from you, with or without
|
||||
changes, also gets the text of this license or a link to
|
||||
<https://blueoakcouncil.org/license/1.0.0>.
|
||||
|
||||
## Excuse
|
||||
|
||||
If anyone notifies you in writing that you have not
|
||||
complied with [Notices](#notices), you can keep your
|
||||
license by taking all practical steps to comply within 30
|
||||
days after the notice. If you do not do so, your license
|
||||
ends immediately.
|
||||
|
||||
## Patent
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe any patent claims
|
||||
they can license or become able to license.
|
||||
|
||||
## Reliability
|
||||
|
||||
No contributor can revoke this license.
|
||||
|
||||
## No Liability
|
||||
|
||||
***As far as the law allows, this software comes as is,
|
||||
without any warranty or condition, and no contributor
|
||||
will be liable to anyone for any damages related to this
|
||||
software or this license, under any kind of legal claim.***
|
||||
3
node_modules/cmake-js/node_modules/chownr/README.md
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/chownr/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Like `chown -R`.
|
||||
|
||||
Takes the same arguments as `fs.chown()`
|
||||
3
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.d.ts
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const chownr: (p: string, uid: number, gid: number, cb: (er?: unknown) => any) => void;
|
||||
export declare const chownrSync: (p: string, uid: number, gid: number) => void;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,MAAM,MACd,MAAM,OACJ,MAAM,OACN,MAAM,YACD,OAAO,KAAK,GAAG,SA0B1B,CAAA;AAcD,eAAO,MAAM,UAAU,MAAO,MAAM,OAAO,MAAM,OAAO,MAAM,SAiB7D,CAAA"}
|
||||
93
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.js
generated
vendored
Normal file
93
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.chownrSync = exports.chownr = void 0;
|
||||
const node_fs_1 = __importDefault(require("node:fs"));
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const lchownSync = (path, uid, gid) => {
|
||||
try {
|
||||
return node_fs_1.default.lchownSync(path, uid, gid);
|
||||
}
|
||||
catch (er) {
|
||||
if (er?.code !== 'ENOENT')
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
const chown = (cpath, uid, gid, cb) => {
|
||||
node_fs_1.default.lchown(cpath, uid, gid, er => {
|
||||
// Skip ENOENT error
|
||||
cb(er && er?.code !== 'ENOENT' ? er : null);
|
||||
});
|
||||
};
|
||||
const chownrKid = (p, child, uid, gid, cb) => {
|
||||
if (child.isDirectory()) {
|
||||
(0, exports.chownr)(node_path_1.default.resolve(p, child.name), uid, gid, (er) => {
|
||||
if (er)
|
||||
return cb(er);
|
||||
const cpath = node_path_1.default.resolve(p, child.name);
|
||||
chown(cpath, uid, gid, cb);
|
||||
});
|
||||
}
|
||||
else {
|
||||
const cpath = node_path_1.default.resolve(p, child.name);
|
||||
chown(cpath, uid, gid, cb);
|
||||
}
|
||||
};
|
||||
const chownr = (p, uid, gid, cb) => {
|
||||
node_fs_1.default.readdir(p, { withFileTypes: true }, (er, children) => {
|
||||
// any error other than ENOTDIR or ENOTSUP means it's not readable,
|
||||
// or doesn't exist. give up.
|
||||
if (er) {
|
||||
if (er.code === 'ENOENT')
|
||||
return cb();
|
||||
else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
|
||||
return cb(er);
|
||||
}
|
||||
if (er || !children.length)
|
||||
return chown(p, uid, gid, cb);
|
||||
let len = children.length;
|
||||
let errState = null;
|
||||
const then = (er) => {
|
||||
/* c8 ignore start */
|
||||
if (errState)
|
||||
return;
|
||||
/* c8 ignore stop */
|
||||
if (er)
|
||||
return cb((errState = er));
|
||||
if (--len === 0)
|
||||
return chown(p, uid, gid, cb);
|
||||
};
|
||||
for (const child of children) {
|
||||
chownrKid(p, child, uid, gid, then);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.chownr = chownr;
|
||||
const chownrKidSync = (p, child, uid, gid) => {
|
||||
if (child.isDirectory())
|
||||
(0, exports.chownrSync)(node_path_1.default.resolve(p, child.name), uid, gid);
|
||||
lchownSync(node_path_1.default.resolve(p, child.name), uid, gid);
|
||||
};
|
||||
const chownrSync = (p, uid, gid) => {
|
||||
let children;
|
||||
try {
|
||||
children = node_fs_1.default.readdirSync(p, { withFileTypes: true });
|
||||
}
|
||||
catch (er) {
|
||||
const e = er;
|
||||
if (e?.code === 'ENOENT')
|
||||
return;
|
||||
else if (e?.code === 'ENOTDIR' || e?.code === 'ENOTSUP')
|
||||
return lchownSync(p, uid, gid);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
for (const child of children) {
|
||||
chownrKidSync(p, child, uid, gid);
|
||||
}
|
||||
return lchownSync(p, uid, gid);
|
||||
};
|
||||
exports.chownrSync = chownrSync;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/chownr/dist/commonjs/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/cmake-js/node_modules/chownr/dist/commonjs/package.json
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/chownr/dist/commonjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
3
node_modules/cmake-js/node_modules/chownr/dist/esm/index.d.ts
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/chownr/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const chownr: (p: string, uid: number, gid: number, cb: (er?: unknown) => any) => void;
|
||||
export declare const chownrSync: (p: string, uid: number, gid: number) => void;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/chownr/dist/esm/index.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/chownr/dist/esm/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,MAAM,MACd,MAAM,OACJ,MAAM,OACN,MAAM,YACD,OAAO,KAAK,GAAG,SA0B1B,CAAA;AAcD,eAAO,MAAM,UAAU,MAAO,MAAM,OAAO,MAAM,OAAO,MAAM,SAiB7D,CAAA"}
|
||||
85
node_modules/cmake-js/node_modules/chownr/dist/esm/index.js
generated
vendored
Normal file
85
node_modules/cmake-js/node_modules/chownr/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
const lchownSync = (path, uid, gid) => {
|
||||
try {
|
||||
return fs.lchownSync(path, uid, gid);
|
||||
}
|
||||
catch (er) {
|
||||
if (er?.code !== 'ENOENT')
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
const chown = (cpath, uid, gid, cb) => {
|
||||
fs.lchown(cpath, uid, gid, er => {
|
||||
// Skip ENOENT error
|
||||
cb(er && er?.code !== 'ENOENT' ? er : null);
|
||||
});
|
||||
};
|
||||
const chownrKid = (p, child, uid, gid, cb) => {
|
||||
if (child.isDirectory()) {
|
||||
chownr(path.resolve(p, child.name), uid, gid, (er) => {
|
||||
if (er)
|
||||
return cb(er);
|
||||
const cpath = path.resolve(p, child.name);
|
||||
chown(cpath, uid, gid, cb);
|
||||
});
|
||||
}
|
||||
else {
|
||||
const cpath = path.resolve(p, child.name);
|
||||
chown(cpath, uid, gid, cb);
|
||||
}
|
||||
};
|
||||
export const chownr = (p, uid, gid, cb) => {
|
||||
fs.readdir(p, { withFileTypes: true }, (er, children) => {
|
||||
// any error other than ENOTDIR or ENOTSUP means it's not readable,
|
||||
// or doesn't exist. give up.
|
||||
if (er) {
|
||||
if (er.code === 'ENOENT')
|
||||
return cb();
|
||||
else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
|
||||
return cb(er);
|
||||
}
|
||||
if (er || !children.length)
|
||||
return chown(p, uid, gid, cb);
|
||||
let len = children.length;
|
||||
let errState = null;
|
||||
const then = (er) => {
|
||||
/* c8 ignore start */
|
||||
if (errState)
|
||||
return;
|
||||
/* c8 ignore stop */
|
||||
if (er)
|
||||
return cb((errState = er));
|
||||
if (--len === 0)
|
||||
return chown(p, uid, gid, cb);
|
||||
};
|
||||
for (const child of children) {
|
||||
chownrKid(p, child, uid, gid, then);
|
||||
}
|
||||
});
|
||||
};
|
||||
const chownrKidSync = (p, child, uid, gid) => {
|
||||
if (child.isDirectory())
|
||||
chownrSync(path.resolve(p, child.name), uid, gid);
|
||||
lchownSync(path.resolve(p, child.name), uid, gid);
|
||||
};
|
||||
export const chownrSync = (p, uid, gid) => {
|
||||
let children;
|
||||
try {
|
||||
children = fs.readdirSync(p, { withFileTypes: true });
|
||||
}
|
||||
catch (er) {
|
||||
const e = er;
|
||||
if (e?.code === 'ENOENT')
|
||||
return;
|
||||
else if (e?.code === 'ENOTDIR' || e?.code === 'ENOTSUP')
|
||||
return lchownSync(p, uid, gid);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
for (const child of children) {
|
||||
chownrKidSync(p, child, uid, gid);
|
||||
}
|
||||
return lchownSync(p, uid, gid);
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/cmake-js/node_modules/chownr/dist/esm/index.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/chownr/dist/esm/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/cmake-js/node_modules/chownr/dist/esm/package.json
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/chownr/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
69
node_modules/cmake-js/node_modules/chownr/package.json
generated
vendored
Normal file
69
node_modules/cmake-js/node_modules/chownr/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"name": "chownr",
|
||||
"description": "like `chown -R`",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/chownr.git"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.5",
|
||||
"mkdirp": "^3.0.1",
|
||||
"prettier": "^3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"tap": "^18.7.2",
|
||||
"tshy": "^1.13.1",
|
||||
"typedoc": "^0.25.12"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "tshy",
|
||||
"pretest": "npm run prepare",
|
||||
"test": "tap",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"prepublishOnly": "git push origin --follow-tags",
|
||||
"format": "prettier --write . --loglevel warn",
|
||||
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
|
||||
},
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"tshy": {
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"type": "module",
|
||||
"prettier": {
|
||||
"semi": false,
|
||||
"printWidth": 75,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"jsxSingleQuote": false,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "avoid",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
}
|
||||
15
node_modules/cmake-js/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
15
node_modules/cmake-js/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2024 JP Richardson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
294
node_modules/cmake-js/node_modules/fs-extra/README.md
generated
vendored
Normal file
294
node_modules/cmake-js/node_modules/fs-extra/README.md
generated
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
Node.js: fs-extra
|
||||
=================
|
||||
|
||||
`fs-extra` adds file system methods that aren't included in the native `fs` module and adds promise support to the `fs` methods. It also uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs) to prevent `EMFILE` errors. It should be a drop in replacement for `fs`.
|
||||
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](https://github.com/jprichardson/node-fs-extra/blob/master/LICENSE)
|
||||
[](https://github.com/jprichardson/node-fs-extra/actions/workflows/ci.yml?query=branch%3Amaster)
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](https://standardjs.com)
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
I got tired of including `mkdirp`, `rimraf`, and `ncp` in most of my projects.
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
npm install fs-extra
|
||||
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### CommonJS
|
||||
|
||||
`fs-extra` is a drop in replacement for native `fs`. All methods in `fs` are attached to `fs-extra`. All `fs` methods return promises if the callback isn't passed.
|
||||
|
||||
You don't ever need to include the original `fs` module again:
|
||||
|
||||
```js
|
||||
const fs = require('fs') // this is no longer necessary
|
||||
```
|
||||
|
||||
you can now do this:
|
||||
|
||||
```js
|
||||
const fs = require('fs-extra')
|
||||
```
|
||||
|
||||
or if you prefer to make it clear that you're using `fs-extra` and not `fs`, you may want
|
||||
to name your `fs` variable `fse` like so:
|
||||
|
||||
```js
|
||||
const fse = require('fs-extra')
|
||||
```
|
||||
|
||||
you can also keep both, but it's redundant:
|
||||
|
||||
```js
|
||||
const fs = require('fs')
|
||||
const fse = require('fs-extra')
|
||||
```
|
||||
|
||||
**NOTE:** The deprecated constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK`, & `fs.X_OK` are not exported on Node.js v24.0.0+; please use their `fs.constants` equivalents.
|
||||
|
||||
### ESM
|
||||
|
||||
There is also an `fs-extra/esm` import, that supports both default and named exports. However, note that `fs` methods are not included in `fs-extra/esm`; you still need to import `fs` and/or `fs/promises` seperately:
|
||||
|
||||
```js
|
||||
import { readFileSync } from 'fs'
|
||||
import { readFile } from 'fs/promises'
|
||||
import { outputFile, outputFileSync } from 'fs-extra/esm'
|
||||
```
|
||||
|
||||
Default exports are supported:
|
||||
|
||||
```js
|
||||
import fs from 'fs'
|
||||
import fse from 'fs-extra/esm'
|
||||
// fse.readFileSync is not a function; must use fs.readFileSync
|
||||
```
|
||||
|
||||
but you probably want to just use regular `fs-extra` instead of `fs-extra/esm` for default exports:
|
||||
|
||||
```js
|
||||
import fs from 'fs-extra'
|
||||
// both fs and fs-extra methods are defined
|
||||
```
|
||||
|
||||
Sync vs Async vs Async/Await
|
||||
-------------
|
||||
Most methods are async by default. All async methods will return a promise if the callback isn't passed.
|
||||
|
||||
Sync methods on the other hand will throw if an error occurs.
|
||||
|
||||
Also Async/Await will throw an error if one occurs.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const fs = require('fs-extra')
|
||||
|
||||
// Async with promises:
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
||||
.then(() => console.log('success!'))
|
||||
.catch(err => console.error(err))
|
||||
|
||||
// Async with callbacks:
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
|
||||
if (err) return console.error(err)
|
||||
console.log('success!')
|
||||
})
|
||||
|
||||
// Sync:
|
||||
try {
|
||||
fs.copySync('/tmp/myfile', '/tmp/mynewfile')
|
||||
console.log('success!')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
// Async/Await:
|
||||
async function copyFiles () {
|
||||
try {
|
||||
await fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
||||
console.log('success!')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
copyFiles()
|
||||
```
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
### Async
|
||||
|
||||
- [copy](docs/copy.md)
|
||||
- [emptyDir](docs/emptyDir.md)
|
||||
- [ensureFile](docs/ensureFile.md)
|
||||
- [ensureDir](docs/ensureDir.md)
|
||||
- [ensureLink](docs/ensureLink.md)
|
||||
- [ensureSymlink](docs/ensureSymlink.md)
|
||||
- [mkdirp](docs/ensureDir.md)
|
||||
- [mkdirs](docs/ensureDir.md)
|
||||
- [move](docs/move.md)
|
||||
- [outputFile](docs/outputFile.md)
|
||||
- [outputJson](docs/outputJson.md)
|
||||
- [pathExists](docs/pathExists.md)
|
||||
- [readJson](docs/readJson.md)
|
||||
- [remove](docs/remove.md)
|
||||
- [writeJson](docs/writeJson.md)
|
||||
|
||||
### Sync
|
||||
|
||||
- [copySync](docs/copy-sync.md)
|
||||
- [emptyDirSync](docs/emptyDir-sync.md)
|
||||
- [ensureFileSync](docs/ensureFile-sync.md)
|
||||
- [ensureDirSync](docs/ensureDir-sync.md)
|
||||
- [ensureLinkSync](docs/ensureLink-sync.md)
|
||||
- [ensureSymlinkSync](docs/ensureSymlink-sync.md)
|
||||
- [mkdirpSync](docs/ensureDir-sync.md)
|
||||
- [mkdirsSync](docs/ensureDir-sync.md)
|
||||
- [moveSync](docs/move-sync.md)
|
||||
- [outputFileSync](docs/outputFile-sync.md)
|
||||
- [outputJsonSync](docs/outputJson-sync.md)
|
||||
- [pathExistsSync](docs/pathExists-sync.md)
|
||||
- [readJsonSync](docs/readJson-sync.md)
|
||||
- [removeSync](docs/remove-sync.md)
|
||||
- [writeJsonSync](docs/writeJson-sync.md)
|
||||
|
||||
|
||||
**NOTE:** You can still use the native Node.js methods. They are promisified and copied over to `fs-extra`. See [notes on `fs.read()`, `fs.write()`, & `fs.writev()`](docs/fs-read-write-writev.md)
|
||||
|
||||
### What happened to `walk()` and `walkSync()`?
|
||||
|
||||
They were removed from `fs-extra` in v2.0.0. If you need the functionality, `walk` and `walkSync` are available as separate packages, [`klaw`](https://github.com/jprichardson/node-klaw) and [`klaw-sync`](https://github.com/manidlou/node-klaw-sync).
|
||||
|
||||
|
||||
Third Party
|
||||
-----------
|
||||
|
||||
### CLI
|
||||
|
||||
[fse-cli](https://www.npmjs.com/package/@atao60/fse-cli) allows you to run `fs-extra` from a console or from [npm](https://www.npmjs.com) scripts.
|
||||
|
||||
### TypeScript
|
||||
|
||||
If you like TypeScript, you can use `fs-extra` with it: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fs-extra
|
||||
|
||||
|
||||
### File / Directory Watching
|
||||
|
||||
If you want to watch for changes to files or directories, then you should use [chokidar](https://github.com/paulmillr/chokidar).
|
||||
|
||||
### Obtain Filesystem (Devices, Partitions) Information
|
||||
|
||||
[fs-filesystem](https://github.com/arthurintelligence/node-fs-filesystem) allows you to read the state of the filesystem of the host on which it is run. It returns information about both the devices and the partitions (volumes) of the system.
|
||||
|
||||
### Misc.
|
||||
|
||||
- [fs-extra-debug](https://github.com/jdxcode/fs-extra-debug) - Send your fs-extra calls to [debug](https://npmjs.org/package/debug).
|
||||
- [mfs](https://github.com/cadorn/mfs) - Monitor your fs-extra calls.
|
||||
|
||||
|
||||
|
||||
Hacking on fs-extra
|
||||
-------------------
|
||||
|
||||
Wanna hack on `fs-extra`? Great! Your help is needed! [fs-extra is one of the most depended upon Node.js packages](http://nodei.co/npm/fs-extra.png?downloads=true&downloadRank=true&stars=true). This project
|
||||
uses [JavaScript Standard Style](https://github.com/feross/standard) - if the name or style choices bother you,
|
||||
you're gonna have to get over it :) If `standard` is good enough for `npm`, it's good enough for `fs-extra`.
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
What's needed?
|
||||
- First, take a look at existing issues. Those are probably going to be where the priority lies.
|
||||
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
|
||||
- Improve test coverage.
|
||||
|
||||
Note: If you make any big changes, **you should definitely file an issue for discussion first.**
|
||||
|
||||
### Running the Test Suite
|
||||
|
||||
fs-extra contains hundreds of tests.
|
||||
|
||||
- `npm run lint`: runs the linter ([standard](http://standardjs.com/))
|
||||
- `npm run unit`: runs the unit tests
|
||||
- `npm run unit-esm`: runs tests for `fs-extra/esm` exports
|
||||
- `npm test`: runs the linter and all tests
|
||||
|
||||
When running unit tests, set the environment variable `CROSS_DEVICE_PATH` to the absolute path of an empty directory on another device (like a thumb drive) to enable cross-device move tests.
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
If you run the tests on the Windows and receive a lot of symbolic link `EPERM` permission errors, it's
|
||||
because on Windows you need elevated privilege to create symbolic links. You can add this to your Windows's
|
||||
account by following the instructions here: http://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7
|
||||
However, I didn't have much luck doing this.
|
||||
|
||||
Since I develop on Mac OS X, I use VMWare Fusion for Windows testing. I create a shared folder that I map to a drive on Windows.
|
||||
I open the `Node.js command prompt` and run as `Administrator`. I then map the network drive running the following command:
|
||||
|
||||
net use z: "\\vmware-host\Shared Folders"
|
||||
|
||||
I can then navigate to my `fs-extra` directory and run the tests.
|
||||
|
||||
|
||||
Naming
|
||||
------
|
||||
|
||||
I put a lot of thought into the naming of these functions. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:
|
||||
|
||||
* https://github.com/jprichardson/node-fs-extra/issues/2
|
||||
* https://github.com/flatiron/utile/issues/11
|
||||
* https://github.com/ryanmcgrath/wrench-js/issues/29
|
||||
* https://github.com/substack/node-mkdirp/issues/17
|
||||
|
||||
First, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.
|
||||
|
||||
For example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.
|
||||
|
||||
We have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?
|
||||
|
||||
My perspective: when in doubt, err on the side of simplicity. A directory is just a hierarchical grouping of directories and files. Consider that for a moment. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too.
|
||||
|
||||
So, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`.
|
||||
|
||||
|
||||
Credit
|
||||
------
|
||||
|
||||
`fs-extra` wouldn't be possible without using the modules from the following authors:
|
||||
|
||||
- [Isaac Shlueter](https://github.com/isaacs)
|
||||
- [Charlie McConnel](https://github.com/avianflu)
|
||||
- [James Halliday](https://github.com/substack)
|
||||
- [Andrew Kelley](https://github.com/andrewrk)
|
||||
|
||||
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under MIT
|
||||
|
||||
Copyright (c) 2011-2024 [JP Richardson](https://github.com/jprichardson)
|
||||
|
||||
[1]: http://nodejs.org/docs/latest/api/fs.html
|
||||
|
||||
|
||||
[jsonfile]: https://github.com/jprichardson/node-jsonfile
|
||||
176
node_modules/cmake-js/node_modules/fs-extra/lib/copy/copy-sync.js
generated
vendored
Normal file
176
node_modules/cmake-js/node_modules/fs-extra/lib/copy/copy-sync.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const mkdirsSync = require('../mkdirs').mkdirsSync
|
||||
const utimesMillisSync = require('../util/utimes').utimesMillisSync
|
||||
const stat = require('../util/stat')
|
||||
|
||||
function copySync (src, dest, opts) {
|
||||
if (typeof opts === 'function') {
|
||||
opts = { filter: opts }
|
||||
}
|
||||
|
||||
opts = opts || {}
|
||||
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
||||
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
||||
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
||||
process.emitWarning(
|
||||
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
|
||||
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
|
||||
'Warning', 'fs-extra-WARN0002'
|
||||
)
|
||||
}
|
||||
|
||||
const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts)
|
||||
stat.checkParentPathsSync(src, srcStat, dest, 'copy')
|
||||
if (opts.filter && !opts.filter(src, dest)) return
|
||||
const destParent = path.dirname(dest)
|
||||
if (!fs.existsSync(destParent)) mkdirsSync(destParent)
|
||||
return getStats(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
function getStats (destStat, src, dest, opts) {
|
||||
const statSync = opts.dereference ? fs.statSync : fs.lstatSync
|
||||
const srcStat = statSync(src)
|
||||
|
||||
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
|
||||
else if (srcStat.isFile() ||
|
||||
srcStat.isCharacterDevice() ||
|
||||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
|
||||
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
|
||||
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
|
||||
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
|
||||
throw new Error(`Unknown file: ${src}`)
|
||||
}
|
||||
|
||||
function onFile (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return copyFile(srcStat, src, dest, opts)
|
||||
return mayCopyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
|
||||
function mayCopyFile (srcStat, src, dest, opts) {
|
||||
if (opts.overwrite) {
|
||||
fs.unlinkSync(dest)
|
||||
return copyFile(srcStat, src, dest, opts)
|
||||
} else if (opts.errorOnExist) {
|
||||
throw new Error(`'${dest}' already exists`)
|
||||
}
|
||||
}
|
||||
|
||||
function copyFile (srcStat, src, dest, opts) {
|
||||
fs.copyFileSync(src, dest)
|
||||
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest)
|
||||
return setDestMode(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
function handleTimestamps (srcMode, src, dest) {
|
||||
// Make sure the file is writable before setting the timestamp
|
||||
// otherwise open fails with EPERM when invoked with 'r+'
|
||||
// (through utimes call)
|
||||
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode)
|
||||
return setDestTimestamps(src, dest)
|
||||
}
|
||||
|
||||
function fileIsNotWritable (srcMode) {
|
||||
return (srcMode & 0o200) === 0
|
||||
}
|
||||
|
||||
function makeFileWritable (dest, srcMode) {
|
||||
return setDestMode(dest, srcMode | 0o200)
|
||||
}
|
||||
|
||||
function setDestMode (dest, srcMode) {
|
||||
return fs.chmodSync(dest, srcMode)
|
||||
}
|
||||
|
||||
function setDestTimestamps (src, dest) {
|
||||
// The initial srcStat.atime cannot be trusted
|
||||
// because it is modified by the read(2) system call
|
||||
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
||||
const updatedSrcStat = fs.statSync(src)
|
||||
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
|
||||
}
|
||||
|
||||
function onDir (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
|
||||
return copyDir(src, dest, opts)
|
||||
}
|
||||
|
||||
function mkDirAndCopy (srcMode, src, dest, opts) {
|
||||
fs.mkdirSync(dest)
|
||||
copyDir(src, dest, opts)
|
||||
return setDestMode(dest, srcMode)
|
||||
}
|
||||
|
||||
function copyDir (src, dest, opts) {
|
||||
const dir = fs.opendirSync(src)
|
||||
|
||||
try {
|
||||
let dirent
|
||||
|
||||
while ((dirent = dir.readSync()) !== null) {
|
||||
copyDirItem(dirent.name, src, dest, opts)
|
||||
}
|
||||
} finally {
|
||||
dir.closeSync()
|
||||
}
|
||||
}
|
||||
|
||||
function copyDirItem (item, src, dest, opts) {
|
||||
const srcItem = path.join(src, item)
|
||||
const destItem = path.join(dest, item)
|
||||
if (opts.filter && !opts.filter(srcItem, destItem)) return
|
||||
const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts)
|
||||
return getStats(destStat, srcItem, destItem, opts)
|
||||
}
|
||||
|
||||
function onLink (destStat, src, dest, opts) {
|
||||
let resolvedSrc = fs.readlinkSync(src)
|
||||
if (opts.dereference) {
|
||||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
|
||||
}
|
||||
|
||||
if (!destStat) {
|
||||
return fs.symlinkSync(resolvedSrc, dest)
|
||||
} else {
|
||||
let resolvedDest
|
||||
try {
|
||||
resolvedDest = fs.readlinkSync(dest)
|
||||
} catch (err) {
|
||||
// dest exists and is a regular file or directory,
|
||||
// Windows may throw UNKNOWN error. If dest already exists,
|
||||
// fs throws error anyway, so no need to guard against it here.
|
||||
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
|
||||
throw err
|
||||
}
|
||||
if (opts.dereference) {
|
||||
resolvedDest = path.resolve(process.cwd(), resolvedDest)
|
||||
}
|
||||
// If both symlinks resolve to the same target, they are still distinct symlinks
|
||||
// that can be copied/overwritten. Only check subdirectory constraints when
|
||||
// the resolved paths are different.
|
||||
if (resolvedSrc !== resolvedDest) {
|
||||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
|
||||
}
|
||||
|
||||
// prevent copy if src is a subdir of dest since unlinking
|
||||
// dest in this case would result in removing src contents
|
||||
// and therefore a broken symlink would be created.
|
||||
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||||
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
|
||||
}
|
||||
}
|
||||
return copyLink(resolvedSrc, dest)
|
||||
}
|
||||
}
|
||||
|
||||
function copyLink (resolvedSrc, dest) {
|
||||
fs.unlinkSync(dest)
|
||||
return fs.symlinkSync(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
module.exports = copySync
|
||||
180
node_modules/cmake-js/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
180
node_modules/cmake-js/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const { mkdirs } = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const { utimesMillis } = require('../util/utimes')
|
||||
const stat = require('../util/stat')
|
||||
const { asyncIteratorConcurrentProcess } = require('../util/async')
|
||||
|
||||
async function copy (src, dest, opts = {}) {
|
||||
if (typeof opts === 'function') {
|
||||
opts = { filter: opts }
|
||||
}
|
||||
|
||||
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
||||
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
||||
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
||||
process.emitWarning(
|
||||
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
|
||||
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
|
||||
'Warning', 'fs-extra-WARN0001'
|
||||
)
|
||||
}
|
||||
|
||||
const { srcStat, destStat } = await stat.checkPaths(src, dest, 'copy', opts)
|
||||
|
||||
await stat.checkParentPaths(src, srcStat, dest, 'copy')
|
||||
|
||||
const include = await runFilter(src, dest, opts)
|
||||
|
||||
if (!include) return
|
||||
|
||||
// check if the parent of dest exists, and create it if it doesn't exist
|
||||
const destParent = path.dirname(dest)
|
||||
const dirExists = await pathExists(destParent)
|
||||
if (!dirExists) {
|
||||
await mkdirs(destParent)
|
||||
}
|
||||
|
||||
await getStatsAndPerformCopy(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
async function runFilter (src, dest, opts) {
|
||||
if (!opts.filter) return true
|
||||
return opts.filter(src, dest)
|
||||
}
|
||||
|
||||
async function getStatsAndPerformCopy (destStat, src, dest, opts) {
|
||||
const statFn = opts.dereference ? fs.stat : fs.lstat
|
||||
const srcStat = await statFn(src)
|
||||
|
||||
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
|
||||
|
||||
if (
|
||||
srcStat.isFile() ||
|
||||
srcStat.isCharacterDevice() ||
|
||||
srcStat.isBlockDevice()
|
||||
) return onFile(srcStat, destStat, src, dest, opts)
|
||||
|
||||
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
|
||||
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
|
||||
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
|
||||
throw new Error(`Unknown file: ${src}`)
|
||||
}
|
||||
|
||||
async function onFile (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return copyFile(srcStat, src, dest, opts)
|
||||
|
||||
if (opts.overwrite) {
|
||||
await fs.unlink(dest)
|
||||
return copyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
if (opts.errorOnExist) {
|
||||
throw new Error(`'${dest}' already exists`)
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFile (srcStat, src, dest, opts) {
|
||||
await fs.copyFile(src, dest)
|
||||
if (opts.preserveTimestamps) {
|
||||
// Make sure the file is writable before setting the timestamp
|
||||
// otherwise open fails with EPERM when invoked with 'r+'
|
||||
// (through utimes call)
|
||||
if (fileIsNotWritable(srcStat.mode)) {
|
||||
await makeFileWritable(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
// Set timestamps and mode correspondingly
|
||||
|
||||
// Note that The initial srcStat.atime cannot be trusted
|
||||
// because it is modified by the read(2) system call
|
||||
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
||||
const updatedSrcStat = await fs.stat(src)
|
||||
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
|
||||
}
|
||||
|
||||
return fs.chmod(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
function fileIsNotWritable (srcMode) {
|
||||
return (srcMode & 0o200) === 0
|
||||
}
|
||||
|
||||
function makeFileWritable (dest, srcMode) {
|
||||
return fs.chmod(dest, srcMode | 0o200)
|
||||
}
|
||||
|
||||
async function onDir (srcStat, destStat, src, dest, opts) {
|
||||
// the dest directory might not exist, create it
|
||||
if (!destStat) {
|
||||
await fs.mkdir(dest)
|
||||
}
|
||||
|
||||
// iterate through the files in the current directory to copy everything
|
||||
await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
|
||||
const srcItem = path.join(src, item.name)
|
||||
const destItem = path.join(dest, item.name)
|
||||
|
||||
const include = await runFilter(srcItem, destItem, opts)
|
||||
// only copy the item if it matches the filter function
|
||||
if (include) {
|
||||
const { destStat } = await stat.checkPaths(srcItem, destItem, 'copy', opts)
|
||||
// If the item is a copyable file, `getStatsAndPerformCopy` will copy it
|
||||
// If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
|
||||
await getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
|
||||
}
|
||||
})
|
||||
|
||||
if (!destStat) {
|
||||
await fs.chmod(dest, srcStat.mode)
|
||||
}
|
||||
}
|
||||
|
||||
async function onLink (destStat, src, dest, opts) {
|
||||
let resolvedSrc = await fs.readlink(src)
|
||||
if (opts.dereference) {
|
||||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
|
||||
}
|
||||
if (!destStat) {
|
||||
return fs.symlink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
let resolvedDest = null
|
||||
try {
|
||||
resolvedDest = await fs.readlink(dest)
|
||||
} catch (e) {
|
||||
// dest exists and is a regular file or directory,
|
||||
// Windows may throw UNKNOWN error. If dest already exists,
|
||||
// fs throws error anyway, so no need to guard against it here.
|
||||
if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)
|
||||
throw e
|
||||
}
|
||||
if (opts.dereference) {
|
||||
resolvedDest = path.resolve(process.cwd(), resolvedDest)
|
||||
}
|
||||
// If both symlinks resolve to the same target, they are still distinct symlinks
|
||||
// that can be copied/overwritten. Only check subdirectory constraints when
|
||||
// the resolved paths are different.
|
||||
if (resolvedSrc !== resolvedDest) {
|
||||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
|
||||
}
|
||||
|
||||
// do not copy if src is a subdir of dest since unlinking
|
||||
// dest in this case would result in removing src contents
|
||||
// and therefore a broken symlink would be created.
|
||||
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||||
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
// copy the link
|
||||
await fs.unlink(dest)
|
||||
return fs.symlink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
module.exports = copy
|
||||
7
node_modules/cmake-js/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
7
node_modules/cmake-js/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
module.exports = {
|
||||
copy: u(require('./copy')),
|
||||
copySync: require('./copy-sync')
|
||||
}
|
||||
39
node_modules/cmake-js/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
39
node_modules/cmake-js/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const mkdir = require('../mkdirs')
|
||||
const remove = require('../remove')
|
||||
|
||||
const emptyDir = u(async function emptyDir (dir) {
|
||||
let items
|
||||
try {
|
||||
items = await fs.readdir(dir)
|
||||
} catch {
|
||||
return mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
|
||||
})
|
||||
|
||||
function emptyDirSync (dir) {
|
||||
let items
|
||||
try {
|
||||
items = fs.readdirSync(dir)
|
||||
} catch {
|
||||
return mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
items.forEach(item => {
|
||||
item = path.join(dir, item)
|
||||
remove.removeSync(item)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
emptyDirSync,
|
||||
emptydirSync: emptyDirSync,
|
||||
emptyDir,
|
||||
emptydir: emptyDir
|
||||
}
|
||||
66
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
66
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const mkdir = require('../mkdirs')
|
||||
|
||||
async function createFile (file) {
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.stat(file)
|
||||
} catch { }
|
||||
if (stats && stats.isFile()) return
|
||||
|
||||
const dir = path.dirname(file)
|
||||
|
||||
let dirStats = null
|
||||
try {
|
||||
dirStats = await fs.stat(dir)
|
||||
} catch (err) {
|
||||
// if the directory doesn't exist, make it
|
||||
if (err.code === 'ENOENT') {
|
||||
await mkdir.mkdirs(dir)
|
||||
await fs.writeFile(file, '')
|
||||
return
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
if (dirStats.isDirectory()) {
|
||||
await fs.writeFile(file, '')
|
||||
} else {
|
||||
// parent is not a directory
|
||||
// This is just to cause an internal ENOTDIR error to be thrown
|
||||
await fs.readdir(dir)
|
||||
}
|
||||
}
|
||||
|
||||
function createFileSync (file) {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.statSync(file)
|
||||
} catch { }
|
||||
if (stats && stats.isFile()) return
|
||||
|
||||
const dir = path.dirname(file)
|
||||
try {
|
||||
if (!fs.statSync(dir).isDirectory()) {
|
||||
// parent is not a directory
|
||||
// This is just to cause an internal ENOTDIR error to be thrown
|
||||
fs.readdirSync(dir)
|
||||
}
|
||||
} catch (err) {
|
||||
// If the stat call above failed because the directory doesn't exist, create it
|
||||
if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir)
|
||||
else throw err
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, '')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createFile: u(createFile),
|
||||
createFileSync
|
||||
}
|
||||
23
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
23
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
const { createFile, createFileSync } = require('./file')
|
||||
const { createLink, createLinkSync } = require('./link')
|
||||
const { createSymlink, createSymlinkSync } = require('./symlink')
|
||||
|
||||
module.exports = {
|
||||
// file
|
||||
createFile,
|
||||
createFileSync,
|
||||
ensureFile: createFile,
|
||||
ensureFileSync: createFileSync,
|
||||
// link
|
||||
createLink,
|
||||
createLinkSync,
|
||||
ensureLink: createLink,
|
||||
ensureLinkSync: createLinkSync,
|
||||
// symlink
|
||||
createSymlink,
|
||||
createSymlinkSync,
|
||||
ensureSymlink: createSymlink,
|
||||
ensureSymlinkSync: createSymlinkSync
|
||||
}
|
||||
64
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
64
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const mkdir = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const { areIdentical } = require('../util/stat')
|
||||
|
||||
async function createLink (srcpath, dstpath) {
|
||||
let dstStat
|
||||
try {
|
||||
dstStat = await fs.lstat(dstpath)
|
||||
} catch {
|
||||
// ignore error
|
||||
}
|
||||
|
||||
let srcStat
|
||||
try {
|
||||
srcStat = await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
throw err
|
||||
}
|
||||
|
||||
if (dstStat && areIdentical(srcStat, dstStat)) return
|
||||
|
||||
const dir = path.dirname(dstpath)
|
||||
|
||||
const dirExists = await pathExists(dir)
|
||||
|
||||
if (!dirExists) {
|
||||
await mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
await fs.link(srcpath, dstpath)
|
||||
}
|
||||
|
||||
function createLinkSync (srcpath, dstpath) {
|
||||
let dstStat
|
||||
try {
|
||||
dstStat = fs.lstatSync(dstpath)
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const srcStat = fs.lstatSync(srcpath)
|
||||
if (dstStat && areIdentical(srcStat, dstStat)) return
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
throw err
|
||||
}
|
||||
|
||||
const dir = path.dirname(dstpath)
|
||||
const dirExists = fs.existsSync(dir)
|
||||
if (dirExists) return fs.linkSync(srcpath, dstpath)
|
||||
mkdir.mkdirsSync(dir)
|
||||
|
||||
return fs.linkSync(srcpath, dstpath)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createLink: u(createLink),
|
||||
createLinkSync
|
||||
}
|
||||
101
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
101
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
/**
|
||||
* Function that returns two types of paths, one relative to symlink, and one
|
||||
* relative to the current working directory. Checks if path is absolute or
|
||||
* relative. If the path is relative, this function checks if the path is
|
||||
* relative to symlink or relative to current working directory. This is an
|
||||
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
||||
* This allows you to determine which path to use out of one of three possible
|
||||
* types of source paths. The first is an absolute path. This is detected by
|
||||
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
||||
* see if it exists. If it does it's used, if not an error is returned
|
||||
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
||||
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
||||
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
||||
* created symlink. If you provide a `srcpath` that does not exist on the file
|
||||
* system it results in a broken symlink. To minimize this, the function
|
||||
* checks to see if the 'relative to symlink' source file exists, and if it
|
||||
* does it will use it. If it does not, it checks if there's a file that
|
||||
* exists that is relative to the current working directory, if does its used.
|
||||
* This preserves the expectations of the original fs.symlink spec and adds
|
||||
* the ability to pass in `relative to current working direcotry` paths.
|
||||
*/
|
||||
|
||||
async function symlinkPaths (srcpath, dstpath) {
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
try {
|
||||
await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
throw err
|
||||
}
|
||||
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const dstdir = path.dirname(dstpath)
|
||||
const relativeToDst = path.join(dstdir, srcpath)
|
||||
|
||||
const exists = await pathExists(relativeToDst)
|
||||
if (exists) {
|
||||
return {
|
||||
toCwd: relativeToDst,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
throw err
|
||||
}
|
||||
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: path.relative(dstdir, srcpath)
|
||||
}
|
||||
}
|
||||
|
||||
function symlinkPathsSync (srcpath, dstpath) {
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
const exists = fs.existsSync(srcpath)
|
||||
if (!exists) throw new Error('absolute srcpath does not exist')
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const dstdir = path.dirname(dstpath)
|
||||
const relativeToDst = path.join(dstdir, srcpath)
|
||||
const exists = fs.existsSync(relativeToDst)
|
||||
if (exists) {
|
||||
return {
|
||||
toCwd: relativeToDst,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const srcExists = fs.existsSync(srcpath)
|
||||
if (!srcExists) throw new Error('relative srcpath does not exist')
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: path.relative(dstdir, srcpath)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symlinkPaths: u(symlinkPaths),
|
||||
symlinkPathsSync
|
||||
}
|
||||
34
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
34
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
async function symlinkType (srcpath, type) {
|
||||
if (type) return type
|
||||
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.lstat(srcpath)
|
||||
} catch {
|
||||
return 'file'
|
||||
}
|
||||
|
||||
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
}
|
||||
|
||||
function symlinkTypeSync (srcpath, type) {
|
||||
if (type) return type
|
||||
|
||||
let stats
|
||||
try {
|
||||
stats = fs.lstatSync(srcpath)
|
||||
} catch {
|
||||
return 'file'
|
||||
}
|
||||
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symlinkType: u(symlinkType),
|
||||
symlinkTypeSync
|
||||
}
|
||||
67
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
67
node_modules/cmake-js/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
|
||||
const { mkdirs, mkdirsSync } = require('../mkdirs')
|
||||
|
||||
const { symlinkPaths, symlinkPathsSync } = require('./symlink-paths')
|
||||
const { symlinkType, symlinkTypeSync } = require('./symlink-type')
|
||||
|
||||
const { pathExists } = require('../path-exists')
|
||||
|
||||
const { areIdentical } = require('../util/stat')
|
||||
|
||||
async function createSymlink (srcpath, dstpath, type) {
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.lstat(dstpath)
|
||||
} catch { }
|
||||
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const [srcStat, dstStat] = await Promise.all([
|
||||
fs.stat(srcpath),
|
||||
fs.stat(dstpath)
|
||||
])
|
||||
|
||||
if (areIdentical(srcStat, dstStat)) return
|
||||
}
|
||||
|
||||
const relative = await symlinkPaths(srcpath, dstpath)
|
||||
srcpath = relative.toDst
|
||||
const toType = await symlinkType(relative.toCwd, type)
|
||||
const dir = path.dirname(dstpath)
|
||||
|
||||
if (!(await pathExists(dir))) {
|
||||
await mkdirs(dir)
|
||||
}
|
||||
|
||||
return fs.symlink(srcpath, dstpath, toType)
|
||||
}
|
||||
|
||||
function createSymlinkSync (srcpath, dstpath, type) {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.lstatSync(dstpath)
|
||||
} catch { }
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const srcStat = fs.statSync(srcpath)
|
||||
const dstStat = fs.statSync(dstpath)
|
||||
if (areIdentical(srcStat, dstStat)) return
|
||||
}
|
||||
|
||||
const relative = symlinkPathsSync(srcpath, dstpath)
|
||||
srcpath = relative.toDst
|
||||
type = symlinkTypeSync(relative.toCwd, type)
|
||||
const dir = path.dirname(dstpath)
|
||||
const exists = fs.existsSync(dir)
|
||||
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
|
||||
mkdirsSync(dir)
|
||||
return fs.symlinkSync(srcpath, dstpath, type)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createSymlink: u(createSymlink),
|
||||
createSymlinkSync
|
||||
}
|
||||
68
node_modules/cmake-js/node_modules/fs-extra/lib/esm.mjs
generated
vendored
Normal file
68
node_modules/cmake-js/node_modules/fs-extra/lib/esm.mjs
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import _copy from './copy/index.js'
|
||||
import _empty from './empty/index.js'
|
||||
import _ensure from './ensure/index.js'
|
||||
import _json from './json/index.js'
|
||||
import _mkdirs from './mkdirs/index.js'
|
||||
import _move from './move/index.js'
|
||||
import _outputFile from './output-file/index.js'
|
||||
import _pathExists from './path-exists/index.js'
|
||||
import _remove from './remove/index.js'
|
||||
|
||||
// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
|
||||
|
||||
export const copy = _copy.copy
|
||||
export const copySync = _copy.copySync
|
||||
export const emptyDirSync = _empty.emptyDirSync
|
||||
export const emptydirSync = _empty.emptydirSync
|
||||
export const emptyDir = _empty.emptyDir
|
||||
export const emptydir = _empty.emptydir
|
||||
export const createFile = _ensure.createFile
|
||||
export const createFileSync = _ensure.createFileSync
|
||||
export const ensureFile = _ensure.ensureFile
|
||||
export const ensureFileSync = _ensure.ensureFileSync
|
||||
export const createLink = _ensure.createLink
|
||||
export const createLinkSync = _ensure.createLinkSync
|
||||
export const ensureLink = _ensure.ensureLink
|
||||
export const ensureLinkSync = _ensure.ensureLinkSync
|
||||
export const createSymlink = _ensure.createSymlink
|
||||
export const createSymlinkSync = _ensure.createSymlinkSync
|
||||
export const ensureSymlink = _ensure.ensureSymlink
|
||||
export const ensureSymlinkSync = _ensure.ensureSymlinkSync
|
||||
export const readJson = _json.readJson
|
||||
export const readJSON = _json.readJSON
|
||||
export const readJsonSync = _json.readJsonSync
|
||||
export const readJSONSync = _json.readJSONSync
|
||||
export const writeJson = _json.writeJson
|
||||
export const writeJSON = _json.writeJSON
|
||||
export const writeJsonSync = _json.writeJsonSync
|
||||
export const writeJSONSync = _json.writeJSONSync
|
||||
export const outputJson = _json.outputJson
|
||||
export const outputJSON = _json.outputJSON
|
||||
export const outputJsonSync = _json.outputJsonSync
|
||||
export const outputJSONSync = _json.outputJSONSync
|
||||
export const mkdirs = _mkdirs.mkdirs
|
||||
export const mkdirsSync = _mkdirs.mkdirsSync
|
||||
export const mkdirp = _mkdirs.mkdirp
|
||||
export const mkdirpSync = _mkdirs.mkdirpSync
|
||||
export const ensureDir = _mkdirs.ensureDir
|
||||
export const ensureDirSync = _mkdirs.ensureDirSync
|
||||
export const move = _move.move
|
||||
export const moveSync = _move.moveSync
|
||||
export const outputFile = _outputFile.outputFile
|
||||
export const outputFileSync = _outputFile.outputFileSync
|
||||
export const pathExists = _pathExists.pathExists
|
||||
export const pathExistsSync = _pathExists.pathExistsSync
|
||||
export const remove = _remove.remove
|
||||
export const removeSync = _remove.removeSync
|
||||
|
||||
export default {
|
||||
..._copy,
|
||||
..._empty,
|
||||
..._ensure,
|
||||
..._json,
|
||||
..._mkdirs,
|
||||
..._move,
|
||||
..._outputFile,
|
||||
..._pathExists,
|
||||
..._remove
|
||||
}
|
||||
146
node_modules/cmake-js/node_modules/fs-extra/lib/fs/index.js
generated
vendored
Normal file
146
node_modules/cmake-js/node_modules/fs-extra/lib/fs/index.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
'use strict'
|
||||
// This is adapted from https://github.com/normalize/mz
|
||||
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
|
||||
const u = require('universalify').fromCallback
|
||||
const fs = require('graceful-fs')
|
||||
|
||||
const api = [
|
||||
'access',
|
||||
'appendFile',
|
||||
'chmod',
|
||||
'chown',
|
||||
'close',
|
||||
'copyFile',
|
||||
'cp',
|
||||
'fchmod',
|
||||
'fchown',
|
||||
'fdatasync',
|
||||
'fstat',
|
||||
'fsync',
|
||||
'ftruncate',
|
||||
'futimes',
|
||||
'glob',
|
||||
'lchmod',
|
||||
'lchown',
|
||||
'lutimes',
|
||||
'link',
|
||||
'lstat',
|
||||
'mkdir',
|
||||
'mkdtemp',
|
||||
'open',
|
||||
'opendir',
|
||||
'readdir',
|
||||
'readFile',
|
||||
'readlink',
|
||||
'realpath',
|
||||
'rename',
|
||||
'rm',
|
||||
'rmdir',
|
||||
'stat',
|
||||
'statfs',
|
||||
'symlink',
|
||||
'truncate',
|
||||
'unlink',
|
||||
'utimes',
|
||||
'writeFile'
|
||||
].filter(key => {
|
||||
// Some commands are not available on some systems. Ex:
|
||||
// fs.cp was added in Node.js v16.7.0
|
||||
// fs.statfs was added in Node v19.6.0, v18.15.0
|
||||
// fs.glob was added in Node.js v22.0.0
|
||||
// fs.lchown is not available on at least some Linux
|
||||
return typeof fs[key] === 'function'
|
||||
})
|
||||
|
||||
// Export cloned fs:
|
||||
Object.assign(exports, fs)
|
||||
|
||||
// Universalify async methods:
|
||||
api.forEach(method => {
|
||||
exports[method] = u(fs[method])
|
||||
})
|
||||
|
||||
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
|
||||
// since we are a drop-in replacement for the native module
|
||||
exports.exists = function (filename, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
return fs.exists(filename, callback)
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
return fs.exists(filename, resolve)
|
||||
})
|
||||
}
|
||||
|
||||
// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
|
||||
|
||||
exports.read = function (fd, buffer, offset, length, position, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
return fs.read(fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesRead, buffer })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature can be
|
||||
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
|
||||
// OR
|
||||
// fs.write(fd, string[, position[, encoding]], callback)
|
||||
// We need to handle both cases, so we use ...args
|
||||
exports.write = function (fd, buffer, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.write(fd, buffer, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesWritten, buffer })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature is
|
||||
// s.readv(fd, buffers[, position], callback)
|
||||
// We need to handle the optional arg, so we use ...args
|
||||
exports.readv = function (fd, buffers, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.readv(fd, buffers, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesRead, buffers })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature is
|
||||
// s.writev(fd, buffers[, position], callback)
|
||||
// We need to handle the optional arg, so we use ...args
|
||||
exports.writev = function (fd, buffers, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.writev(fd, buffers, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesWritten, buffers })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// fs.realpath.native sometimes not available if fs is monkey-patched
|
||||
if (typeof fs.realpath.native === 'function') {
|
||||
exports.realpath.native = u(fs.realpath.native)
|
||||
} else {
|
||||
process.emitWarning(
|
||||
'fs.realpath.native is not a function. Is fs being monkey-patched?',
|
||||
'Warning', 'fs-extra-WARN0003'
|
||||
)
|
||||
}
|
||||
16
node_modules/cmake-js/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
16
node_modules/cmake-js/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
// Export promiseified graceful-fs:
|
||||
...require('./fs'),
|
||||
// Export extra methods:
|
||||
...require('./copy'),
|
||||
...require('./empty'),
|
||||
...require('./ensure'),
|
||||
...require('./json'),
|
||||
...require('./mkdirs'),
|
||||
...require('./move'),
|
||||
...require('./output-file'),
|
||||
...require('./path-exists'),
|
||||
...require('./remove')
|
||||
}
|
||||
16
node_modules/cmake-js/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
16
node_modules/cmake-js/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const jsonFile = require('./jsonfile')
|
||||
|
||||
jsonFile.outputJson = u(require('./output-json'))
|
||||
jsonFile.outputJsonSync = require('./output-json-sync')
|
||||
// aliases
|
||||
jsonFile.outputJSON = jsonFile.outputJson
|
||||
jsonFile.outputJSONSync = jsonFile.outputJsonSync
|
||||
jsonFile.writeJSON = jsonFile.writeJson
|
||||
jsonFile.writeJSONSync = jsonFile.writeJsonSync
|
||||
jsonFile.readJSON = jsonFile.readJson
|
||||
jsonFile.readJSONSync = jsonFile.readJsonSync
|
||||
|
||||
module.exports = jsonFile
|
||||
11
node_modules/cmake-js/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
11
node_modules/cmake-js/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const jsonFile = require('jsonfile')
|
||||
|
||||
module.exports = {
|
||||
// jsonfile exports
|
||||
readJson: jsonFile.readFile,
|
||||
readJsonSync: jsonFile.readFileSync,
|
||||
writeJson: jsonFile.writeFile,
|
||||
writeJsonSync: jsonFile.writeFileSync
|
||||
}
|
||||
12
node_modules/cmake-js/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
12
node_modules/cmake-js/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const { stringify } = require('jsonfile/utils')
|
||||
const { outputFileSync } = require('../output-file')
|
||||
|
||||
function outputJsonSync (file, data, options) {
|
||||
const str = stringify(data, options)
|
||||
|
||||
outputFileSync(file, str, options)
|
||||
}
|
||||
|
||||
module.exports = outputJsonSync
|
||||
12
node_modules/cmake-js/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
12
node_modules/cmake-js/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const { stringify } = require('jsonfile/utils')
|
||||
const { outputFile } = require('../output-file')
|
||||
|
||||
async function outputJson (file, data, options = {}) {
|
||||
const str = stringify(data, options)
|
||||
|
||||
await outputFile(file, str, options)
|
||||
}
|
||||
|
||||
module.exports = outputJson
|
||||
14
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
14
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict'
|
||||
const u = require('universalify').fromPromise
|
||||
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
|
||||
const makeDir = u(_makeDir)
|
||||
|
||||
module.exports = {
|
||||
mkdirs: makeDir,
|
||||
mkdirsSync: makeDirSync,
|
||||
// alias
|
||||
mkdirp: makeDir,
|
||||
mkdirpSync: makeDirSync,
|
||||
ensureDir: makeDir,
|
||||
ensureDirSync: makeDirSync
|
||||
}
|
||||
27
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/make-dir.js
generated
vendored
Normal file
27
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/make-dir.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
const fs = require('../fs')
|
||||
const { checkPath } = require('./utils')
|
||||
|
||||
const getMode = options => {
|
||||
const defaults = { mode: 0o777 }
|
||||
if (typeof options === 'number') return options
|
||||
return ({ ...defaults, ...options }).mode
|
||||
}
|
||||
|
||||
module.exports.makeDir = async (dir, options) => {
|
||||
checkPath(dir)
|
||||
|
||||
return fs.mkdir(dir, {
|
||||
mode: getMode(options),
|
||||
recursive: true
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.makeDirSync = (dir, options) => {
|
||||
checkPath(dir)
|
||||
|
||||
return fs.mkdirSync(dir, {
|
||||
mode: getMode(options),
|
||||
recursive: true
|
||||
})
|
||||
}
|
||||
21
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/utils.js
generated
vendored
Normal file
21
node_modules/cmake-js/node_modules/fs-extra/lib/mkdirs/utils.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Adapted from https://github.com/sindresorhus/make-dir
|
||||
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
// https://github.com/nodejs/node/issues/8987
|
||||
// https://github.com/libuv/libuv/pull/1088
|
||||
module.exports.checkPath = function checkPath (pth) {
|
||||
if (process.platform === 'win32') {
|
||||
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
|
||||
|
||||
if (pathHasInvalidWinCharacters) {
|
||||
const error = new Error(`Path contains invalid characters: ${pth}`)
|
||||
error.code = 'EINVAL'
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
7
node_modules/cmake-js/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
7
node_modules/cmake-js/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
module.exports = {
|
||||
move: u(require('./move')),
|
||||
moveSync: require('./move-sync')
|
||||
}
|
||||
55
node_modules/cmake-js/node_modules/fs-extra/lib/move/move-sync.js
generated
vendored
Normal file
55
node_modules/cmake-js/node_modules/fs-extra/lib/move/move-sync.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const copySync = require('../copy').copySync
|
||||
const removeSync = require('../remove').removeSync
|
||||
const mkdirpSync = require('../mkdirs').mkdirpSync
|
||||
const stat = require('../util/stat')
|
||||
|
||||
function moveSync (src, dest, opts) {
|
||||
opts = opts || {}
|
||||
const overwrite = opts.overwrite || opts.clobber || false
|
||||
|
||||
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
|
||||
stat.checkParentPathsSync(src, srcStat, dest, 'move')
|
||||
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
|
||||
return doRename(src, dest, overwrite, isChangingCase)
|
||||
}
|
||||
|
||||
function isParentRoot (dest) {
|
||||
const parent = path.dirname(dest)
|
||||
const parsedPath = path.parse(parent)
|
||||
return parsedPath.root === parent
|
||||
}
|
||||
|
||||
function doRename (src, dest, overwrite, isChangingCase) {
|
||||
if (isChangingCase) return rename(src, dest, overwrite)
|
||||
if (overwrite) {
|
||||
removeSync(dest)
|
||||
return rename(src, dest, overwrite)
|
||||
}
|
||||
if (fs.existsSync(dest)) throw new Error('dest already exists.')
|
||||
return rename(src, dest, overwrite)
|
||||
}
|
||||
|
||||
function rename (src, dest, overwrite) {
|
||||
try {
|
||||
fs.renameSync(src, dest)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EXDEV') throw err
|
||||
return moveAcrossDevice(src, dest, overwrite)
|
||||
}
|
||||
}
|
||||
|
||||
function moveAcrossDevice (src, dest, overwrite) {
|
||||
const opts = {
|
||||
overwrite,
|
||||
errorOnExist: true,
|
||||
preserveTimestamps: true
|
||||
}
|
||||
copySync(src, dest, opts)
|
||||
return removeSync(src)
|
||||
}
|
||||
|
||||
module.exports = moveSync
|
||||
59
node_modules/cmake-js/node_modules/fs-extra/lib/move/move.js
generated
vendored
Normal file
59
node_modules/cmake-js/node_modules/fs-extra/lib/move/move.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const { copy } = require('../copy')
|
||||
const { remove } = require('../remove')
|
||||
const { mkdirp } = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const stat = require('../util/stat')
|
||||
|
||||
async function move (src, dest, opts = {}) {
|
||||
const overwrite = opts.overwrite || opts.clobber || false
|
||||
|
||||
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts)
|
||||
|
||||
await stat.checkParentPaths(src, srcStat, dest, 'move')
|
||||
|
||||
// If the parent of dest is not root, make sure it exists before proceeding
|
||||
const destParent = path.dirname(dest)
|
||||
const parsedParentPath = path.parse(destParent)
|
||||
if (parsedParentPath.root !== destParent) {
|
||||
await mkdirp(destParent)
|
||||
}
|
||||
|
||||
return doRename(src, dest, overwrite, isChangingCase)
|
||||
}
|
||||
|
||||
async function doRename (src, dest, overwrite, isChangingCase) {
|
||||
if (!isChangingCase) {
|
||||
if (overwrite) {
|
||||
await remove(dest)
|
||||
} else if (await pathExists(dest)) {
|
||||
throw new Error('dest already exists.')
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Try w/ rename first, and try copy + remove if EXDEV
|
||||
await fs.rename(src, dest)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EXDEV') {
|
||||
throw err
|
||||
}
|
||||
await moveAcrossDevice(src, dest, overwrite)
|
||||
}
|
||||
}
|
||||
|
||||
async function moveAcrossDevice (src, dest, overwrite) {
|
||||
const opts = {
|
||||
overwrite,
|
||||
errorOnExist: true,
|
||||
preserveTimestamps: true
|
||||
}
|
||||
|
||||
await copy(src, dest, opts)
|
||||
return remove(src)
|
||||
}
|
||||
|
||||
module.exports = move
|
||||
31
node_modules/cmake-js/node_modules/fs-extra/lib/output-file/index.js
generated
vendored
Normal file
31
node_modules/cmake-js/node_modules/fs-extra/lib/output-file/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const mkdir = require('../mkdirs')
|
||||
const pathExists = require('../path-exists').pathExists
|
||||
|
||||
async function outputFile (file, data, encoding = 'utf-8') {
|
||||
const dir = path.dirname(file)
|
||||
|
||||
if (!(await pathExists(dir))) {
|
||||
await mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
return fs.writeFile(file, data, encoding)
|
||||
}
|
||||
|
||||
function outputFileSync (file, ...args) {
|
||||
const dir = path.dirname(file)
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, ...args)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
outputFile: u(outputFile),
|
||||
outputFileSync
|
||||
}
|
||||
12
node_modules/cmake-js/node_modules/fs-extra/lib/path-exists/index.js
generated
vendored
Normal file
12
node_modules/cmake-js/node_modules/fs-extra/lib/path-exists/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
|
||||
function pathExists (path) {
|
||||
return fs.access(path).then(() => true).catch(() => false)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
pathExists: u(pathExists),
|
||||
pathExistsSync: fs.existsSync
|
||||
}
|
||||
17
node_modules/cmake-js/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
17
node_modules/cmake-js/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const u = require('universalify').fromCallback
|
||||
|
||||
function remove (path, callback) {
|
||||
fs.rm(path, { recursive: true, force: true }, callback)
|
||||
}
|
||||
|
||||
function removeSync (path) {
|
||||
fs.rmSync(path, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
remove: u(remove),
|
||||
removeSync
|
||||
}
|
||||
29
node_modules/cmake-js/node_modules/fs-extra/lib/util/async.js
generated
vendored
Normal file
29
node_modules/cmake-js/node_modules/fs-extra/lib/util/async.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
// https://github.com/jprichardson/node-fs-extra/issues/1056
|
||||
// Performing parallel operations on each item of an async iterator is
|
||||
// surprisingly hard; you need to have handlers in place to avoid getting an
|
||||
// UnhandledPromiseRejectionWarning.
|
||||
// NOTE: This function does not presently handle return values, only errors
|
||||
async function asyncIteratorConcurrentProcess (iterator, fn) {
|
||||
const promises = []
|
||||
for await (const item of iterator) {
|
||||
promises.push(
|
||||
fn(item).then(
|
||||
() => null,
|
||||
(err) => err ?? new Error('unknown error')
|
||||
)
|
||||
)
|
||||
}
|
||||
await Promise.all(
|
||||
promises.map((promise) =>
|
||||
promise.then((possibleErr) => {
|
||||
if (possibleErr !== null) throw possibleErr
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
asyncIteratorConcurrentProcess
|
||||
}
|
||||
159
node_modules/cmake-js/node_modules/fs-extra/lib/util/stat.js
generated
vendored
Normal file
159
node_modules/cmake-js/node_modules/fs-extra/lib/util/stat.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
function getStats (src, dest, opts) {
|
||||
const statFunc = opts.dereference
|
||||
? (file) => fs.stat(file, { bigint: true })
|
||||
: (file) => fs.lstat(file, { bigint: true })
|
||||
return Promise.all([
|
||||
statFunc(src),
|
||||
statFunc(dest).catch(err => {
|
||||
if (err.code === 'ENOENT') return null
|
||||
throw err
|
||||
})
|
||||
]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
|
||||
}
|
||||
|
||||
function getStatsSync (src, dest, opts) {
|
||||
let destStat
|
||||
const statFunc = opts.dereference
|
||||
? (file) => fs.statSync(file, { bigint: true })
|
||||
: (file) => fs.lstatSync(file, { bigint: true })
|
||||
const srcStat = statFunc(src)
|
||||
try {
|
||||
destStat = statFunc(dest)
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return { srcStat, destStat: null }
|
||||
throw err
|
||||
}
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
async function checkPaths (src, dest, funcName, opts) {
|
||||
const { srcStat, destStat } = await getStats(src, dest, opts)
|
||||
if (destStat) {
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
const srcBaseName = path.basename(src)
|
||||
const destBaseName = path.basename(dest)
|
||||
if (funcName === 'move' &&
|
||||
srcBaseName !== destBaseName &&
|
||||
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||||
return { srcStat, destStat, isChangingCase: true }
|
||||
}
|
||||
throw new Error('Source and destination must not be the same.')
|
||||
}
|
||||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
|
||||
}
|
||||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
function checkPathsSync (src, dest, funcName, opts) {
|
||||
const { srcStat, destStat } = getStatsSync(src, dest, opts)
|
||||
|
||||
if (destStat) {
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
const srcBaseName = path.basename(src)
|
||||
const destBaseName = path.basename(dest)
|
||||
if (funcName === 'move' &&
|
||||
srcBaseName !== destBaseName &&
|
||||
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||||
return { srcStat, destStat, isChangingCase: true }
|
||||
}
|
||||
throw new Error('Source and destination must not be the same.')
|
||||
}
|
||||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
|
||||
}
|
||||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
// recursively check if dest parent is a subdirectory of src.
|
||||
// It works for all file types including symlinks since it
|
||||
// checks the src and dest inodes. It starts from the deepest
|
||||
// parent and stops once it reaches the src parent or the root path.
|
||||
async function checkParentPaths (src, srcStat, dest, funcName) {
|
||||
const srcParent = path.resolve(path.dirname(src))
|
||||
const destParent = path.resolve(path.dirname(dest))
|
||||
if (destParent === srcParent || destParent === path.parse(destParent).root) return
|
||||
|
||||
let destStat
|
||||
try {
|
||||
destStat = await fs.stat(destParent, { bigint: true })
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return
|
||||
throw err
|
||||
}
|
||||
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
|
||||
return checkParentPaths(src, srcStat, destParent, funcName)
|
||||
}
|
||||
|
||||
function checkParentPathsSync (src, srcStat, dest, funcName) {
|
||||
const srcParent = path.resolve(path.dirname(src))
|
||||
const destParent = path.resolve(path.dirname(dest))
|
||||
if (destParent === srcParent || destParent === path.parse(destParent).root) return
|
||||
let destStat
|
||||
try {
|
||||
destStat = fs.statSync(destParent, { bigint: true })
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return
|
||||
throw err
|
||||
}
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
return checkParentPathsSync(src, srcStat, destParent, funcName)
|
||||
}
|
||||
|
||||
function areIdentical (srcStat, destStat) {
|
||||
// stat.dev can be 0n on windows when node version >= 22.x.x
|
||||
return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
|
||||
}
|
||||
|
||||
// return true if dest is a subdir of src, otherwise false.
|
||||
// It only checks the path strings.
|
||||
function isSrcSubdir (src, dest) {
|
||||
const srcArr = path.resolve(src).split(path.sep).filter(i => i)
|
||||
const destArr = path.resolve(dest).split(path.sep).filter(i => i)
|
||||
return srcArr.every((cur, i) => destArr[i] === cur)
|
||||
}
|
||||
|
||||
function errMsg (src, dest, funcName) {
|
||||
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// checkPaths
|
||||
checkPaths: u(checkPaths),
|
||||
checkPathsSync,
|
||||
// checkParent
|
||||
checkParentPaths: u(checkParentPaths),
|
||||
checkParentPathsSync,
|
||||
// Misc
|
||||
isSrcSubdir,
|
||||
areIdentical
|
||||
}
|
||||
36
node_modules/cmake-js/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
36
node_modules/cmake-js/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
async function utimesMillis (path, atime, mtime) {
|
||||
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
||||
const fd = await fs.open(path, 'r+')
|
||||
|
||||
let closeErr = null
|
||||
|
||||
try {
|
||||
await fs.futimes(fd, atime, mtime)
|
||||
} finally {
|
||||
try {
|
||||
await fs.close(fd)
|
||||
} catch (e) {
|
||||
closeErr = e
|
||||
}
|
||||
}
|
||||
|
||||
if (closeErr) {
|
||||
throw closeErr
|
||||
}
|
||||
}
|
||||
|
||||
function utimesMillisSync (path, atime, mtime) {
|
||||
const fd = fs.openSync(path, 'r+')
|
||||
fs.futimesSync(fd, atime, mtime)
|
||||
return fs.closeSync(fd)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
utimesMillis: u(utimesMillis),
|
||||
utimesMillisSync
|
||||
}
|
||||
71
node_modules/cmake-js/node_modules/fs-extra/package.json
generated
vendored
Normal file
71
node_modules/cmake-js/node_modules/fs-extra/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "fs-extra",
|
||||
"version": "11.3.3",
|
||||
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.",
|
||||
"engines": {
|
||||
"node": ">=14.14"
|
||||
},
|
||||
"homepage": "https://github.com/jprichardson/node-fs-extra",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jprichardson/node-fs-extra"
|
||||
},
|
||||
"keywords": [
|
||||
"fs",
|
||||
"file",
|
||||
"file system",
|
||||
"copy",
|
||||
"directory",
|
||||
"extra",
|
||||
"mkdirp",
|
||||
"mkdir",
|
||||
"mkdirs",
|
||||
"recursive",
|
||||
"json",
|
||||
"read",
|
||||
"write",
|
||||
"extra",
|
||||
"delete",
|
||||
"remove",
|
||||
"touch",
|
||||
"create",
|
||||
"text",
|
||||
"output",
|
||||
"move",
|
||||
"promise"
|
||||
],
|
||||
"author": "JP Richardson <jprichardson@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"klaw": "^2.1.1",
|
||||
"klaw-sync": "^3.0.2",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^10.1.0",
|
||||
"nyc": "^15.0.0",
|
||||
"proxyquire": "^2.0.1",
|
||||
"read-dir-files": "^0.1.1",
|
||||
"standard": "^17.0.0"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": "./lib/index.js",
|
||||
"./esm": "./lib/esm.mjs"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"!lib/**/__tests__/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha",
|
||||
"test": "npm run lint && npm run unit && npm run unit-esm",
|
||||
"unit": "nyc node test.js",
|
||||
"unit-esm": "node test.mjs"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
55
node_modules/cmake-js/node_modules/isexe/LICENSE.md
generated
vendored
Normal file
55
node_modules/cmake-js/node_modules/isexe/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# Blue Oak Model License
|
||||
|
||||
Version 1.0.0
|
||||
|
||||
## Purpose
|
||||
|
||||
This license gives everyone as much permission to work with
|
||||
this software as possible, while protecting contributors
|
||||
from liability.
|
||||
|
||||
## Acceptance
|
||||
|
||||
In order to receive this license, you must agree to its
|
||||
rules. The rules of this license are both obligations
|
||||
under that agreement and conditions to your license.
|
||||
You must not do anything with this software that triggers
|
||||
a rule that you cannot or will not follow.
|
||||
|
||||
## Copyright
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe that contributor's
|
||||
copyright in it.
|
||||
|
||||
## Notices
|
||||
|
||||
You must ensure that everyone who gets a copy of
|
||||
any part of this software from you, with or without
|
||||
changes, also gets the text of this license or a link to
|
||||
<https://blueoakcouncil.org/license/1.0.0>.
|
||||
|
||||
## Excuse
|
||||
|
||||
If anyone notifies you in writing that you have not
|
||||
complied with [Notices](#notices), you can keep your
|
||||
license by taking all practical steps to comply within 30
|
||||
days after the notice. If you do not do so, your license
|
||||
ends immediately.
|
||||
|
||||
## Patent
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe any patent claims
|
||||
they can license or become able to license.
|
||||
|
||||
## Reliability
|
||||
|
||||
No contributor can revoke this license.
|
||||
|
||||
## No Liability
|
||||
|
||||
***As far as the law allows, this software comes as is,
|
||||
without any warranty or condition, and no contributor
|
||||
will be liable to anyone for any damages related to this
|
||||
software or this license, under any kind of legal claim.***
|
||||
80
node_modules/cmake-js/node_modules/isexe/README.md
generated
vendored
Normal file
80
node_modules/cmake-js/node_modules/isexe/README.md
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# isexe
|
||||
|
||||
Minimal module to check if a file is executable, and a normal file.
|
||||
|
||||
Uses `fs.stat` and tests against the `PATHEXT` environment variable on
|
||||
Windows.
|
||||
|
||||
## USAGE
|
||||
|
||||
```js
|
||||
// default export is a minified version that doesn't need to
|
||||
// load more than one file. Load the 'isexe/raw' export if
|
||||
// you want the non-minified version for some reason.
|
||||
import { isexe, sync } from 'isexe'
|
||||
// or require() works too
|
||||
// const { isexe } = require('isexe')
|
||||
isexe('some-file-name').then(
|
||||
isExe => {
|
||||
if (isExe) {
|
||||
console.error('this thing can be run')
|
||||
} else {
|
||||
console.error('cannot be run')
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.error('probably file doesnt exist or something')
|
||||
},
|
||||
)
|
||||
|
||||
// same thing but synchronous, throws errors
|
||||
isExe = sync('some-file-name')
|
||||
|
||||
// treat errors as just "not executable"
|
||||
const isExe = await isexe('maybe-missing-file', { ignoreErrors: true })
|
||||
const isExe = sync('maybe-missing-file', { ignoreErrors: true })
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `isexe(path, [options]) => Promise<boolean>`
|
||||
|
||||
Check if the path is executable.
|
||||
|
||||
Will raise whatever errors may be raised by `fs.stat`, unless
|
||||
`options.ignoreErrors` is set to true.
|
||||
|
||||
### `sync(path, [options]) => boolean`
|
||||
|
||||
Same as `isexe` but returns the value and throws any errors raised.
|
||||
|
||||
## Platform Specific Implementations
|
||||
|
||||
If for some reason you want to use the implementation for a
|
||||
specific platform, you can do that.
|
||||
|
||||
```js
|
||||
import { win32, posix } from 'isexe'
|
||||
win32.isexe(...)
|
||||
win32.sync(...)
|
||||
// etc
|
||||
|
||||
// or:
|
||||
import { isexe, sync } from 'isexe/posix'
|
||||
```
|
||||
|
||||
The default exported implementation will be chosen based on
|
||||
`process.platform`.
|
||||
|
||||
### Options
|
||||
|
||||
```ts
|
||||
import type IsexeOptions from 'isexe'
|
||||
```
|
||||
|
||||
- `ignoreErrors` Treat all errors as "no, this is not
|
||||
executable", but don't raise them.
|
||||
- `uid` Number to use as the user id on posix
|
||||
- `gid` Number to use as the group id on posix
|
||||
- `pathExt` List of path extensions to use instead of `PATHEXT`
|
||||
environment variable on Windows.
|
||||
14
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.d.ts
generated
vendored
Normal file
14
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as posix from './posix.js';
|
||||
import * as win32 from './win32.js';
|
||||
export * from './options.js';
|
||||
export { win32, posix };
|
||||
/**
|
||||
* Determine whether a path is executable on the current platform.
|
||||
*/
|
||||
export declare const isexe: (path: string, options?: import("./options.js").IsexeOptions) => Promise<boolean>;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable on the
|
||||
* current platform.
|
||||
*/
|
||||
export declare const sync: (path: string, options?: import("./options.js").IsexeOptions) => boolean;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAKvB;;GAEG;AACH,eAAO,MAAM,KAAK,mFAAa,CAAA;AAC/B;;;GAGG;AACH,eAAO,MAAM,IAAI,0EAAY,CAAA"}
|
||||
56
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.js
generated
vendored
Normal file
56
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = 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) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
|
||||
const posix = __importStar(require("./posix.js"));
|
||||
exports.posix = posix;
|
||||
const win32 = __importStar(require("./win32.js"));
|
||||
exports.win32 = win32;
|
||||
__exportStar(require("./options.js"), exports);
|
||||
const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
|
||||
const impl = platform === 'win32' ? win32 : posix;
|
||||
/**
|
||||
* Determine whether a path is executable on the current platform.
|
||||
*/
|
||||
exports.isexe = impl.isexe;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable on the
|
||||
* current platform.
|
||||
*/
|
||||
exports.sync = impl.sync;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmC;AAGnB,sBAAK;AAFrB,kDAAmC;AAE1B,sBAAK;AADd,+CAA4B;AAG5B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,CAAA;AACtE,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AAEjD;;GAEG;AACU,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAC/B;;;GAGG;AACU,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA","sourcesContent":["import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"]}
|
||||
2
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.min.js
generated
vendored
Normal file
2
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";var a=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var _=a(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.sync=i.isexe=void 0;var M=require("node:fs"),x=require("node:fs/promises"),q=async(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return d(await(0,x.stat)(t),e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};i.isexe=q;var m=(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return d((0,M.statSync)(t),e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};i.sync=m;var d=(t,e)=>t.isFile()&&A(t,e),A=(t,e)=>{let r=e.uid??process.getuid?.(),s=e.groups??process.getgroups?.()??[],n=e.gid??process.getgid?.()??s[0];if(r===void 0||n===void 0)throw new Error("cannot get uid or gid");let u=new Set([n,...s]),c=t.mode,S=t.uid,P=t.gid,f=parseInt("100",8),l=parseInt("010",8),j=parseInt("001",8),C=f|l;return!!(c&j||c&l&&u.has(P)||c&f&&S===r||c&C&&r===0)}});var g=a(o=>{"use strict";Object.defineProperty(o,"__esModule",{value:!0});o.sync=o.isexe=void 0;var T=require("node:fs"),I=require("node:fs/promises"),D=require("node:path"),F=async(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return y(await(0,I.stat)(t),t,e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};o.isexe=F;var L=(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return y((0,T.statSync)(t),t,e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};o.sync=L;var B=(t,e)=>{let{pathExt:r=process.env.PATHEXT||""}=e,s=r.split(D.delimiter);if(s.indexOf("")!==-1)return!0;for(let n of s){let u=n.toLowerCase(),c=t.substring(t.length-u.length).toLowerCase();if(u&&c===u)return!0}return!1},y=(t,e,r)=>t.isFile()&&B(e,r)});var p=a(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0})});var v=exports&&exports.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),G=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),w=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var s=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(s[s.length]=n);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var s=t(e),n=0;n<s.length;n++)s[n]!=="default"&&v(r,e,s[n]);return G(r,e),r}})(),X=exports&&exports.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&v(e,t,r)};Object.defineProperty(exports,"__esModule",{value:!0});exports.sync=exports.isexe=exports.posix=exports.win32=void 0;var E=w(_());exports.posix=E;var O=w(g());exports.win32=O;X(p(),exports);var H=process.env._ISEXE_TEST_PLATFORM_||process.platform,b=H==="win32"?O:E;exports.isexe=b.isexe;exports.sync=b.sync;
|
||||
//# sourceMappingURL=index.min.js.map
|
||||
7
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.min.js.map
generated
vendored
Normal file
7
node_modules/cmake-js/node_modules/isexe/dist/commonjs/index.min.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/posix.ts", "../../src/win32.ts", "options.js", "../../src/index.ts"],
|
||||
"sourcesContent": ["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n const myUid = options.uid ?? process.getuid?.()\n const myGroups = options.groups ?? process.getgroups?.() ?? []\n const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n if (myUid === undefined || myGid === undefined) {\n throw new Error('cannot get uid or gid')\n }\n\n const groups = new Set([myGid, ...myGroups])\n\n const mod = stat.mode\n const uid = stat.uid\n const gid = stat.gid\n\n const u = parseInt('100', 8)\n const g = parseInt('010', 8)\n const o = parseInt('001', 8)\n const ug = u | g\n\n return !!(\n mod & o ||\n (mod & g && groups.has(gid)) ||\n (mod & u && uid === myUid) ||\n (mod & ug && myUid === 0)\n )\n}\n", "/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n const { pathExt = process.env.PATHEXT || '' } = options\n const peSplit = pathExt.split(delimiter)\n if (peSplit.indexOf('') !== -1) {\n return true\n }\n\n for (const pes of peSplit) {\n const p = pes.toLowerCase()\n const ext = path.substring(path.length - p.length).toLowerCase()\n\n if (p && ext === p) {\n return true\n }\n }\n return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n stat.isFile() && checkPathExt(path, options)\n", "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n//# sourceMappingURL=options.js.map", "import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"],
|
||||
"mappings": "2KAOA,IAAAA,EAAA,QAAA,SAAA,EACAC,EAAA,QAAA,kBAAA,EAOaC,EAAQ,MACnBC,EACAC,EAAwB,CAAA,IACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,QAAML,EAAA,MAAKE,CAAI,EAAGC,CAAO,CAC5C,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAZaC,EAAA,MAAKP,EAkBX,IAAMQ,EAAO,CAClBP,EACAC,EAAwB,CAAA,IACb,CACX,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,KAAUN,EAAA,UAASG,CAAI,EAAGC,CAAO,CAC1C,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAZaC,EAAA,KAAIC,EAcjB,IAAMJ,EAAY,CAACK,EAAaP,IAC9BO,EAAK,OAAM,GAAMC,EAAUD,EAAMP,CAAO,EAEpCQ,EAAY,CAACD,EAAaP,IAAyB,CACvD,IAAMS,EAAQT,EAAQ,KAAO,QAAQ,SAAQ,EACvCU,EAAWV,EAAQ,QAAU,QAAQ,YAAW,GAAM,CAAA,EACtDW,EAAQX,EAAQ,KAAO,QAAQ,SAAQ,GAAMU,EAAS,CAAC,EAC7D,GAAID,IAAU,QAAaE,IAAU,OACnC,MAAM,IAAI,MAAM,uBAAuB,EAGzC,IAAMC,EAAS,IAAI,IAAI,CAACD,EAAO,GAAGD,CAAQ,CAAC,EAErCG,EAAMN,EAAK,KACXO,EAAMP,EAAK,IACXQ,EAAMR,EAAK,IAEXS,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAKH,EAAIC,EAEf,MAAO,CAAC,EACNJ,EAAMK,GACLL,EAAMI,GAAKL,EAAO,IAAIG,CAAG,GACzBF,EAAMG,GAAKF,IAAQL,GACnBI,EAAMM,GAAMV,IAAU,EAE3B,oGCpEA,IAAAW,EAAA,QAAA,SAAA,EACAC,EAAA,QAAA,kBAAA,EAEAC,EAAA,QAAA,WAAA,EAMaC,EAAQ,MACnBC,EACAC,EAAwB,CAAA,IACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,QAAMN,EAAA,MAAKG,CAAI,EAAGA,EAAMC,CAAO,CAClD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAZaC,EAAA,MAAKP,EAkBX,IAAMQ,EAAO,CAClBP,EACAC,EAAwB,CAAA,IACb,CACX,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,KAAUP,EAAA,UAASI,CAAI,EAAGA,EAAMC,CAAO,CAChD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAZaC,EAAA,KAAIC,EAcjB,IAAMC,EAAe,CAACR,EAAcC,IAAyB,CAC3D,GAAM,CAAE,QAAAQ,EAAU,QAAQ,IAAI,SAAW,EAAE,EAAKR,EAC1CS,EAAUD,EAAQ,MAAMX,EAAA,SAAS,EACvC,GAAIY,EAAQ,QAAQ,EAAE,IAAM,GAC1B,MAAO,GAGT,QAAWC,KAAOD,EAAS,CACzB,IAAME,EAAID,EAAI,YAAW,EACnBE,EAAMb,EAAK,UAAUA,EAAK,OAASY,EAAE,MAAM,EAAE,YAAW,EAE9D,GAAIA,GAAKC,IAAQD,EACf,MAAO,EAEX,CACA,MAAO,EACT,EAEMT,EAAY,CAACW,EAAad,EAAcC,IAC5Ca,EAAK,OAAM,GAAMN,EAAaR,EAAMC,CAAO,ICnE7C,IAAAc,EAAAC,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CAAE,MAAO,EAAK,CAAC,ykCCD5D,IAAAC,EAAAC,EAAA,GAAA,EAGgB,QAAA,MAAAD,EAFhB,IAAAE,EAAAD,EAAA,GAAA,EAES,QAAA,MAAAC,EADTC,EAAA,IAAA,OAAA,EAGA,IAAMC,EAAW,QAAQ,IAAI,uBAAyB,QAAQ,SACxDC,EAAOD,IAAa,QAAUF,EAAQF,EAK/B,QAAA,MAAQK,EAAK,MAKb,QAAA,KAAOA,EAAK",
|
||||
"names": ["node_fs_1", "promises_1", "isexe", "path", "options", "ignoreErrors", "checkStat", "e", "er", "exports", "sync", "stat", "checkMode", "myUid", "myGroups", "myGid", "groups", "mod", "uid", "gid", "u", "g", "o", "ug", "node_fs_1", "promises_1", "node_path_1", "isexe", "path", "options", "ignoreErrors", "checkStat", "e", "er", "exports", "sync", "checkPathExt", "pathExt", "peSplit", "pes", "p", "ext", "stat", "require_options", "__commonJSMin", "exports", "posix", "__importStar", "win32", "__exportStar", "platform", "impl"]
|
||||
}
|
||||
32
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.d.ts
generated
vendored
Normal file
32
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export interface IsexeOptions {
|
||||
/**
|
||||
* Ignore errors arising from attempting to get file access status
|
||||
* Note that EACCES is always ignored, because that just means
|
||||
* it's not executable. If this is not set, then attempting to check
|
||||
* the executable-ness of a nonexistent file will raise ENOENT, for
|
||||
* example.
|
||||
*/
|
||||
ignoreErrors?: boolean;
|
||||
/**
|
||||
* effective uid when checking executable mode flags on posix
|
||||
* Defaults to process.getuid()
|
||||
*/
|
||||
uid?: number;
|
||||
/**
|
||||
* effective gid when checking executable mode flags on posix
|
||||
* Defaults to process.getgid()
|
||||
*/
|
||||
gid?: number;
|
||||
/**
|
||||
* effective group ID list to use when checking executable mode flags
|
||||
* on posix
|
||||
* Defaults to process.getgroups()
|
||||
*/
|
||||
groups?: number[];
|
||||
/**
|
||||
* The ;-delimited path extension list for win32 implementation.
|
||||
* Defaults to process.env.PATHEXT
|
||||
*/
|
||||
pathExt?: string;
|
||||
}
|
||||
//# sourceMappingURL=options.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IAEtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
||||
3
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.js
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=options.js.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/options.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"","sourcesContent":["export interface IsexeOptions {\n /**\n * Ignore errors arising from attempting to get file access status\n * Note that EACCES is always ignored, because that just means\n * it's not executable. If this is not set, then attempting to check\n * the executable-ness of a nonexistent file will raise ENOENT, for\n * example.\n */\n ignoreErrors?: boolean\n\n /**\n * effective uid when checking executable mode flags on posix\n * Defaults to process.getuid()\n */\n uid?: number\n\n /**\n * effective gid when checking executable mode flags on posix\n * Defaults to process.getgid()\n */\n gid?: number\n\n /**\n * effective group ID list to use when checking executable mode flags\n * on posix\n * Defaults to process.getgroups()\n */\n groups?: number[]\n\n /**\n * The ;-delimited path extension list for win32 implementation.\n * Defaults to process.env.PATHEXT\n */\n pathExt?: string\n}\n"]}
|
||||
3
node_modules/cmake-js/node_modules/isexe/dist/commonjs/package.json
generated
vendored
Normal file
3
node_modules/cmake-js/node_modules/isexe/dist/commonjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
18
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.d.ts
generated
vendored
Normal file
18
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* This is the Posix implementation of isexe, which uses the file
|
||||
* mode and uid/gid values.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
import { IsexeOptions } from './options.js';
|
||||
/**
|
||||
* Determine whether a path is executable according to the mode and
|
||||
* current (or specified) user and group IDs.
|
||||
*/
|
||||
export declare const isexe: (path: string, options?: IsexeOptions) => Promise<boolean>;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable according to
|
||||
* the mode and current (or specified) user and group IDs.
|
||||
*/
|
||||
export declare const sync: (path: string, options?: IsexeOptions) => boolean;
|
||||
//# sourceMappingURL=posix.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../src/posix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C;;;GAGG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OAAO,CAAC,OAAO,CASjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OASF,CAAA"}
|
||||
67
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.js
generated
vendored
Normal file
67
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This is the Posix implementation of isexe, which uses the file
|
||||
* mode and uid/gid values.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sync = exports.isexe = void 0;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const promises_1 = require("node:fs/promises");
|
||||
/**
|
||||
* Determine whether a path is executable according to the mode and
|
||||
* current (or specified) user and group IDs.
|
||||
*/
|
||||
const isexe = async (path, options = {}) => {
|
||||
const { ignoreErrors = false } = options;
|
||||
try {
|
||||
return checkStat(await (0, promises_1.stat)(path), options);
|
||||
}
|
||||
catch (e) {
|
||||
const er = e;
|
||||
if (ignoreErrors || er.code === 'EACCES')
|
||||
return false;
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
exports.isexe = isexe;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable according to
|
||||
* the mode and current (or specified) user and group IDs.
|
||||
*/
|
||||
const sync = (path, options = {}) => {
|
||||
const { ignoreErrors = false } = options;
|
||||
try {
|
||||
return checkStat((0, node_fs_1.statSync)(path), options);
|
||||
}
|
||||
catch (e) {
|
||||
const er = e;
|
||||
if (ignoreErrors || er.code === 'EACCES')
|
||||
return false;
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
exports.sync = sync;
|
||||
const checkStat = (stat, options) => stat.isFile() && checkMode(stat, options);
|
||||
const checkMode = (stat, options) => {
|
||||
const myUid = options.uid ?? process.getuid?.();
|
||||
const myGroups = options.groups ?? process.getgroups?.() ?? [];
|
||||
const myGid = options.gid ?? process.getgid?.() ?? myGroups[0];
|
||||
if (myUid === undefined || myGid === undefined) {
|
||||
throw new Error('cannot get uid or gid');
|
||||
}
|
||||
const groups = new Set([myGid, ...myGroups]);
|
||||
const mod = stat.mode;
|
||||
const uid = stat.uid;
|
||||
const gid = stat.gid;
|
||||
const u = parseInt('100', 8);
|
||||
const g = parseInt('010', 8);
|
||||
const o = parseInt('001', 8);
|
||||
const ug = u | g;
|
||||
return !!(mod & o ||
|
||||
(mod & g && groups.has(gid)) ||
|
||||
(mod & u && uid === myUid) ||
|
||||
(mod & ug && myUid === 0));
|
||||
};
|
||||
//# sourceMappingURL=posix.js.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/posix.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"posix.js","sourceRoot":"","sources":["../../src/posix.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAyC;AACzC,+CAAuC;AAGvC;;;GAGG;AACI,MAAM,KAAK,GAAG,KAAK,EACxB,IAAY,EACZ,UAAwB,EAAE,EACR,EAAE;IACpB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,IAAA,eAAI,EAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QACtD,MAAM,EAAE,CAAA;IACV,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,KAAK,SAYjB;AAED;;;GAGG;AACI,MAAM,IAAI,GAAG,CAClB,IAAY,EACZ,UAAwB,EAAE,EACjB,EAAE;IACX,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QACtD,MAAM,EAAE,CAAA;IACV,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,IAAI,QAYhB;AAED,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAqB,EAAE,EAAE,CACvD,IAAI,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAE3C,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAqB,EAAE,EAAE;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAA;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAA;IAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC9D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA;IAE5C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAA;IACrB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IAEpB,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IAEhB,OAAO,CAAC,CAAC,CACP,GAAG,GAAG,CAAC;QACP,CAAC,GAAG,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK,KAAK,CAAC;QAC1B,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAC1B,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n const myUid = options.uid ?? process.getuid?.()\n const myGroups = options.groups ?? process.getgroups?.() ?? []\n const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n if (myUid === undefined || myGid === undefined) {\n throw new Error('cannot get uid or gid')\n }\n\n const groups = new Set([myGid, ...myGroups])\n\n const mod = stat.mode\n const uid = stat.uid\n const gid = stat.gid\n\n const u = parseInt('100', 8)\n const g = parseInt('010', 8)\n const o = parseInt('001', 8)\n const ug = u | g\n\n return !!(\n mod & o ||\n (mod & g && groups.has(gid)) ||\n (mod & u && uid === myUid) ||\n (mod & ug && myUid === 0)\n )\n}\n"]}
|
||||
18
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.d.ts
generated
vendored
Normal file
18
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* This is the Windows implementation of isexe, which uses the file
|
||||
* extension and PATHEXT setting.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
import { IsexeOptions } from './options.js';
|
||||
/**
|
||||
* Determine whether a path is executable based on the file extension
|
||||
* and PATHEXT environment variable (or specified pathExt option)
|
||||
*/
|
||||
export declare const isexe: (path: string, options?: IsexeOptions) => Promise<boolean>;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable based on the file
|
||||
* extension and PATHEXT environment variable (or specified pathExt option)
|
||||
*/
|
||||
export declare const sync: (path: string, options?: IsexeOptions) => boolean;
|
||||
//# sourceMappingURL=win32.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"win32.d.ts","sourceRoot":"","sources":["../../src/win32.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C;;;GAGG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OAAO,CAAC,OAAO,CASjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OASF,CAAA"}
|
||||
63
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.js
generated
vendored
Normal file
63
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This is the Windows implementation of isexe, which uses the file
|
||||
* extension and PATHEXT setting.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sync = exports.isexe = void 0;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const promises_1 = require("node:fs/promises");
|
||||
const node_path_1 = require("node:path");
|
||||
/**
|
||||
* Determine whether a path is executable based on the file extension
|
||||
* and PATHEXT environment variable (or specified pathExt option)
|
||||
*/
|
||||
const isexe = async (path, options = {}) => {
|
||||
const { ignoreErrors = false } = options;
|
||||
try {
|
||||
return checkStat(await (0, promises_1.stat)(path), path, options);
|
||||
}
|
||||
catch (e) {
|
||||
const er = e;
|
||||
if (ignoreErrors || er.code === 'EACCES')
|
||||
return false;
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
exports.isexe = isexe;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable based on the file
|
||||
* extension and PATHEXT environment variable (or specified pathExt option)
|
||||
*/
|
||||
const sync = (path, options = {}) => {
|
||||
const { ignoreErrors = false } = options;
|
||||
try {
|
||||
return checkStat((0, node_fs_1.statSync)(path), path, options);
|
||||
}
|
||||
catch (e) {
|
||||
const er = e;
|
||||
if (ignoreErrors || er.code === 'EACCES')
|
||||
return false;
|
||||
throw er;
|
||||
}
|
||||
};
|
||||
exports.sync = sync;
|
||||
const checkPathExt = (path, options) => {
|
||||
const { pathExt = process.env.PATHEXT || '' } = options;
|
||||
const peSplit = pathExt.split(node_path_1.delimiter);
|
||||
if (peSplit.indexOf('') !== -1) {
|
||||
return true;
|
||||
}
|
||||
for (const pes of peSplit) {
|
||||
const p = pes.toLowerCase();
|
||||
const ext = path.substring(path.length - p.length).toLowerCase();
|
||||
if (p && ext === p) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const checkStat = (stat, path, options) => stat.isFile() && checkPathExt(path, options);
|
||||
//# sourceMappingURL=win32.js.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/commonjs/win32.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"win32.js","sourceRoot":"","sources":["../../src/win32.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAyC;AACzC,+CAAuC;AAEvC,yCAAqC;AAErC;;;GAGG;AACI,MAAM,KAAK,GAAG,KAAK,EACxB,IAAY,EACZ,UAAwB,EAAE,EACR,EAAE;IACpB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,IAAA,eAAI,EAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QACtD,MAAM,EAAE,CAAA;IACV,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,KAAK,SAYjB;AAED;;;GAGG;AACI,MAAM,IAAI,GAAG,CAClB,IAAY,EACZ,UAAwB,EAAE,EACjB,EAAE;IACX,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QACtD,MAAM,EAAE,CAAA;IACV,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,IAAI,QAYhB;AAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,OAAqB,EAAE,EAAE;IAC3D,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,OAAO,CAAA;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,qBAAS,CAAC,CAAA;IACxC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;QAEhE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,IAAY,EAAE,OAAqB,EAAE,EAAE,CACrE,IAAI,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA","sourcesContent":["/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n const { pathExt = process.env.PATHEXT || '' } = options\n const peSplit = pathExt.split(delimiter)\n if (peSplit.indexOf('') !== -1) {\n return true\n }\n\n for (const pes of peSplit) {\n const p = pes.toLowerCase()\n const ext = path.substring(path.length - p.length).toLowerCase()\n\n if (p && ext === p) {\n return true\n }\n }\n return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n stat.isFile() && checkPathExt(path, options)\n"]}
|
||||
14
node_modules/cmake-js/node_modules/isexe/dist/esm/index.d.ts
generated
vendored
Normal file
14
node_modules/cmake-js/node_modules/isexe/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as posix from './posix.js';
|
||||
import * as win32 from './win32.js';
|
||||
export * from './options.js';
|
||||
export { win32, posix };
|
||||
/**
|
||||
* Determine whether a path is executable on the current platform.
|
||||
*/
|
||||
export declare const isexe: (path: string, options?: import("./options.js").IsexeOptions) => Promise<boolean>;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable on the
|
||||
* current platform.
|
||||
*/
|
||||
export declare const sync: (path: string, options?: import("./options.js").IsexeOptions) => boolean;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/esm/index.d.ts.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/esm/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAKvB;;GAEG;AACH,eAAO,MAAM,KAAK,mFAAa,CAAA;AAC/B;;;GAGG;AACH,eAAO,MAAM,IAAI,0EAAY,CAAA"}
|
||||
16
node_modules/cmake-js/node_modules/isexe/dist/esm/index.js
generated
vendored
Normal file
16
node_modules/cmake-js/node_modules/isexe/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as posix from './posix.js';
|
||||
import * as win32 from './win32.js';
|
||||
export * from './options.js';
|
||||
export { win32, posix };
|
||||
const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
|
||||
const impl = platform === 'win32' ? win32 : posix;
|
||||
/**
|
||||
* Determine whether a path is executable on the current platform.
|
||||
*/
|
||||
export const isexe = impl.isexe;
|
||||
/**
|
||||
* Synchronously determine whether a path is executable on the
|
||||
* current platform.
|
||||
*/
|
||||
export const sync = impl.sync;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/cmake-js/node_modules/isexe/dist/esm/index.js.map
generated
vendored
Normal file
1
node_modules/cmake-js/node_modules/isexe/dist/esm/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAEvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,CAAA;AACtE,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAC/B;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA","sourcesContent":["import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"]}
|
||||
2
node_modules/cmake-js/node_modules/isexe/dist/esm/index.min.js
generated
vendored
Normal file
2
node_modules/cmake-js/node_modules/isexe/dist/esm/index.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var y=Object.defineProperty;var u=(t,r)=>{for(var e in r)y(t,e,{get:r[e],enumerable:!0})};var i={};u(i,{isexe:()=>C,sync:()=>A});import{statSync as w}from"node:fs";import{stat as S}from"node:fs/promises";var C=async(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return d(await S(t),r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},A=(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return d(w(t),r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},d=(t,r)=>t.isFile()&&T(t,r),T=(t,r)=>{let e=r.uid??process.getuid?.(),s=r.groups??process.getgroups?.()??[],o=r.gid??process.getgid?.()??s[0];if(e===void 0||o===void 0)throw new Error("cannot get uid or gid");let c=new Set([o,...s]),n=t.mode,l=t.uid,E=t.gid,f=parseInt("100",8),p=parseInt("010",8),x=parseInt("001",8),h=f|p;return!!(n&x||n&p&&c.has(E)||n&f&&l===e||n&h&&e===0)};var a={};u(a,{isexe:()=>F,sync:()=>L});import{statSync as k}from"node:fs";import{stat as I}from"node:fs/promises";import{delimiter as _}from"node:path";var F=async(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return m(await I(t),t,r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},L=(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return m(k(t),t,r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},P=(t,r)=>{let{pathExt:e=process.env.PATHEXT||""}=r,s=e.split(_);if(s.indexOf("")!==-1)return!0;for(let o of s){let c=o.toLowerCase(),n=t.substring(t.length-c.length).toLowerCase();if(c&&n===c)return!0}return!1},m=(t,r,e)=>t.isFile()&&P(r,e);var v=process.env._ISEXE_TEST_PLATFORM_||process.platform,g=v==="win32"?a:i,R=g.isexe,U=g.sync;export{R as isexe,i as posix,U as sync,a as win32};
|
||||
//# sourceMappingURL=index.min.js.map
|
||||
7
node_modules/cmake-js/node_modules/isexe/dist/esm/index.min.js.map
generated
vendored
Normal file
7
node_modules/cmake-js/node_modules/isexe/dist/esm/index.min.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/posix.ts", "../../src/win32.ts", "../../src/index.ts"],
|
||||
"sourcesContent": ["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n const myUid = options.uid ?? process.getuid?.()\n const myGroups = options.groups ?? process.getgroups?.() ?? []\n const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n if (myUid === undefined || myGid === undefined) {\n throw new Error('cannot get uid or gid')\n }\n\n const groups = new Set([myGid, ...myGroups])\n\n const mod = stat.mode\n const uid = stat.uid\n const gid = stat.gid\n\n const u = parseInt('100', 8)\n const g = parseInt('010', 8)\n const o = parseInt('001', 8)\n const ug = u | g\n\n return !!(\n mod & o ||\n (mod & g && groups.has(gid)) ||\n (mod & u && uid === myUid) ||\n (mod & ug && myUid === 0)\n )\n}\n", "/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n const { pathExt = process.env.PATHEXT || '' } = options\n const peSplit = pathExt.split(delimiter)\n if (peSplit.indexOf('') !== -1) {\n return true\n }\n\n for (const pes of peSplit) {\n const p = pes.toLowerCase()\n const ext = path.substring(path.length - p.length).toLowerCase()\n\n if (p && ext === p) {\n return true\n }\n }\n return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n stat.isFile() && checkPathExt(path, options)\n", "import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"],
|
||||
"mappings": "0FAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,SAAAC,IAOA,OAAgB,YAAAC,MAAgB,UAChC,OAAS,QAAAC,MAAY,mBAOd,IAAMH,EAAQ,MACnBI,EACAC,EAAwB,CAAA,IACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,MAAMJ,EAAKC,CAAI,EAAGC,CAAO,CAC5C,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAMaR,EAAO,CAClBG,EACAC,EAAwB,CAAA,IACb,CACX,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAUL,EAASE,CAAI,EAAGC,CAAO,CAC1C,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAEMF,EAAY,CAACJ,EAAaE,IAC9BF,EAAK,OAAM,GAAMO,EAAUP,EAAME,CAAO,EAEpCK,EAAY,CAACP,EAAaE,IAAyB,CACvD,IAAMM,EAAQN,EAAQ,KAAO,QAAQ,SAAQ,EACvCO,EAAWP,EAAQ,QAAU,QAAQ,YAAW,GAAM,CAAA,EACtDQ,EAAQR,EAAQ,KAAO,QAAQ,SAAQ,GAAMO,EAAS,CAAC,EAC7D,GAAID,IAAU,QAAaE,IAAU,OACnC,MAAM,IAAI,MAAM,uBAAuB,EAGzC,IAAMC,EAAS,IAAI,IAAI,CAACD,EAAO,GAAGD,CAAQ,CAAC,EAErCG,EAAMZ,EAAK,KACXa,EAAMb,EAAK,IACXc,EAAMd,EAAK,IAEXe,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAI,SAAS,MAAO,CAAC,EACrBC,EAAKH,EAAIC,EAEf,MAAO,CAAC,EACNJ,EAAMK,GACLL,EAAMI,GAAKL,EAAO,IAAIG,CAAG,GACzBF,EAAMG,GAAKF,IAAQL,GACnBI,EAAMM,GAAMV,IAAU,EAE3B,EC3EA,IAAAW,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,SAAAC,IAOA,OAAgB,YAAAC,MAAgB,UAChC,OAAS,QAAAC,MAAY,mBAErB,OAAS,aAAAC,MAAiB,YAMnB,IAAMJ,EAAQ,MACnBK,EACAC,EAAwB,CAAA,IACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,MAAML,EAAKE,CAAI,EAAGA,EAAMC,CAAO,CAClD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAMaT,EAAO,CAClBI,EACAC,EAAwB,CAAA,IACb,CACX,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAUN,EAASG,CAAI,EAAGA,EAAMC,CAAO,CAChD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAEMC,EAAe,CAACN,EAAcC,IAAyB,CAC3D,GAAM,CAAE,QAAAM,EAAU,QAAQ,IAAI,SAAW,EAAE,EAAKN,EAC1CO,EAAUD,EAAQ,MAAMR,CAAS,EACvC,GAAIS,EAAQ,QAAQ,EAAE,IAAM,GAC1B,MAAO,GAGT,QAAWC,KAAOD,EAAS,CACzB,IAAME,EAAID,EAAI,YAAW,EACnBE,EAAMX,EAAK,UAAUA,EAAK,OAASU,EAAE,MAAM,EAAE,YAAW,EAE9D,GAAIA,GAAKC,IAAQD,EACf,MAAO,EAEX,CACA,MAAO,EACT,EAEMP,EAAY,CAACL,EAAaE,EAAcC,IAC5CH,EAAK,OAAM,GAAMQ,EAAaN,EAAMC,CAAO,EC9D7C,IAAMW,EAAW,QAAQ,IAAI,uBAAyB,QAAQ,SACxDC,EAAOD,IAAa,QAAUE,EAAQC,EAK/BC,EAAQH,EAAK,MAKbI,EAAOJ,EAAK",
|
||||
"names": ["posix_exports", "__export", "isexe", "sync", "statSync", "stat", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkMode", "myUid", "myGroups", "myGid", "groups", "mod", "uid", "gid", "u", "g", "o", "ug", "win32_exports", "__export", "isexe", "sync", "statSync", "stat", "delimiter", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkPathExt", "pathExt", "peSplit", "pes", "p", "ext", "platform", "impl", "win32_exports", "posix_exports", "isexe", "sync"]
|
||||
}
|
||||
32
node_modules/cmake-js/node_modules/isexe/dist/esm/options.d.ts
generated
vendored
Normal file
32
node_modules/cmake-js/node_modules/isexe/dist/esm/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export interface IsexeOptions {
|
||||
/**
|
||||
* Ignore errors arising from attempting to get file access status
|
||||
* Note that EACCES is always ignored, because that just means
|
||||
* it's not executable. If this is not set, then attempting to check
|
||||
* the executable-ness of a nonexistent file will raise ENOENT, for
|
||||
* example.
|
||||
*/
|
||||
ignoreErrors?: boolean;
|
||||
/**
|
||||
* effective uid when checking executable mode flags on posix
|
||||
* Defaults to process.getuid()
|
||||
*/
|
||||
uid?: number;
|
||||
/**
|
||||
* effective gid when checking executable mode flags on posix
|
||||
* Defaults to process.getgid()
|
||||
*/
|
||||
gid?: number;
|
||||
/**
|
||||
* effective group ID list to use when checking executable mode flags
|
||||
* on posix
|
||||
* Defaults to process.getgroups()
|
||||
*/
|
||||
groups?: number[];
|
||||
/**
|
||||
* The ;-delimited path extension list for win32 implementation.
|
||||
* Defaults to process.env.PATHEXT
|
||||
*/
|
||||
pathExt?: string;
|
||||
}
|
||||
//# sourceMappingURL=options.d.ts.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user