Update capacitor version

This commit is contained in:
Pieter Vander Vennet 2025-07-06 20:20:48 +02:00
parent 91155bce0a
commit f3b3a86b32
610 changed files with 28718 additions and 7101 deletions

View file

@ -0,0 +1,185 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.1.6](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.5...@ionic/utils-array@2.1.6) (2023-03-29)
**Note:** Version bump only for package @ionic/utils-array
## [2.1.5](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.4...@ionic/utils-array@2.1.5) (2020-08-28)
**Note:** Version bump only for package @ionic/utils-array
## [2.1.4](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.3...@ionic/utils-array@2.1.4) (2020-08-25)
**Note:** Version bump only for package @ionic/utils-array
## [2.1.3](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.2...@ionic/utils-array@2.1.3) (2020-05-12)
### Bug Fixes
* pin tslib to avoid "Cannot set property pathExists" error ([689e1f0](https://github.com/ionic-team/ionic-cli/commit/689e1f038b907356ef855a067a76d4822e7072a8))
## [2.1.2](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.1...@ionic/utils-array@2.1.2) (2020-05-06)
**Note:** Version bump only for package @ionic/utils-array
## [2.1.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.1.0...@ionic/utils-array@2.1.1) (2020-03-03)
**Note:** Version bump only for package @ionic/utils-array
# 2.1.0 (2020-02-11)
### Features
* **start:** add new list starter option ([#4315](https://github.com/ionic-team/ionic-cli/issues/4315)) ([1df44c1](https://github.com/ionic-team/ionic-cli/commit/1df44c1591f37b89f2b672857740edd6cb2aea67))
## [2.0.2](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.0.1...@ionic/utils-array@2.0.2) (2020-02-10)
**Note:** Version bump only for package @ionic/utils-array
## [2.0.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@2.0.0...@ionic/utils-array@2.0.1) (2020-02-03)
**Note:** Version bump only for package @ionic/utils-array
# [2.0.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.2.2...@ionic/utils-array@2.0.0) (2020-01-25)
### chore
* require Node 10 ([5a47874](https://github.com/ionic-team/ionic-cli/commit/5a478746c074207b6dc96aa8771f04a606deb1ef))
### BREAKING CHANGES
* A minimum of Node.js 10.3.0 is required.
## [1.2.2](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.2.1...@ionic/utils-array@1.2.2) (2019-12-05)
**Note:** Version bump only for package @ionic/utils-array
## [1.2.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.2.0...@ionic/utils-array@1.2.1) (2019-09-18)
**Note:** Version bump only for package @ionic/utils-array
# [1.2.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.1.1...@ionic/utils-array@1.2.0) (2019-08-28)
### Features
* **replace:** add replace item in array by index function ([011ddf7](https://github.com/ionic-team/ionic-cli/commit/011ddf7))
* **splice:** add non-mutating splice function ([758d287](https://github.com/ionic-team/ionic-cli/commit/758d287))
## [1.1.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.1.0...@ionic/utils-array@1.1.1) (2019-08-23)
**Note:** Version bump only for package @ionic/utils-array
# [1.1.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.0.2...@ionic/utils-array@1.1.0) (2019-08-14)
### Features
* add new `move` function ([ba8da3b](https://github.com/ionic-team/ionic-cli/commit/ba8da3b))
## [1.0.2](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.0.1...@ionic/utils-array@1.0.2) (2019-08-07)
**Note:** Version bump only for package @ionic/utils-array
## [1.0.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@1.0.0...@ionic/utils-array@1.0.1) (2019-06-05)
**Note:** Version bump only for package @ionic/utils-array
# [1.0.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/utils-array@0.0.1...@ionic/utils-array@1.0.0) (2019-05-29)
### chore
* require Node 8 ([5670e68](https://github.com/ionic-team/ionic-cli/commit/5670e68))
### BREAKING CHANGES
* A minimum of Node.js 8.9.4 is required.
<a name="0.0.1"></a>
## 0.0.1 (2019-02-27)
**Note:** Version bump only for package @ionic/utils-array

21
@capacitor/cli/node_modules/@ionic/utils-array/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Drifty Co
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.

View file

@ -0,0 +1 @@
# @ionic/utils-array

View file

@ -0,0 +1,39 @@
export declare function conform<T>(t?: T | T[]): T[];
export declare function concurrentFilter<T>(array: T[], callback: (currentValue: T) => Promise<boolean>): Promise<T[]>;
export declare function filter<T>(array: T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<boolean>): Promise<T[]>;
export declare function filter<T>(array: readonly T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<boolean>): Promise<readonly T[]>;
export declare function map<T, U>(array: T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>): Promise<U[]>;
export declare function map<T, U>(array: T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>): Promise<readonly U[]>;
export declare function map<T, U>(array: readonly T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>): Promise<U[]>;
export declare function map<T, U>(array: readonly T[], callback: (currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>): Promise<readonly U[]>;
export declare function reduce<T>(array: T[], callback: (accumulator: T, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<T>): Promise<T>;
export declare function reduce<T>(array: T[], callback: (accumulator: T, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<T>, initialValue: T): Promise<T>;
export declare function reduce<T, R>(array: T[], callback: (accumulator: R, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<R>): Promise<R>;
export declare function reduce<T, U>(array: T[], callback: (accumulator: U, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>, initialValue: U): Promise<U>;
export declare function reduce<T>(array: readonly T[], callback: (accumulator: T, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<T>): Promise<T>;
export declare function reduce<T>(array: readonly T[], callback: (accumulator: T, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<T>, initialValue: T): Promise<T>;
export declare function reduce<T, R>(array: readonly T[], callback: (accumulator: R, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<R>): Promise<R>;
export declare function reduce<T, U>(array: readonly T[], callback: (accumulator: U, currentValue: T, currentIndex: number, array: readonly T[]) => Promise<U>, initialValue: U): Promise<U>;
/**
* Splice an array.
*
* This function will return a new array with the standard splice behavior
* applied. Unlike the standard array splice, the array of removed items is not
* returned.
*/
export declare function splice<T>(array: readonly T[], start: number, deleteCount?: number, ...items: T[]): T[];
/**
* Move an item in an array by index.
*
* This function will return a new array with the item in the `fromIndex`
* position moved to the `toIndex` position. If `fromIndex` or `toIndex` are
* out of bounds, the array items remain unmoved.
*/
export declare function move<T>(array: readonly T[], fromIndex: number, toIndex: number): T[];
/**
* Replace an item in an array by index.
*
* This function will return a new array with the item in the `index` position
* replaced with `item`. If `index` is out of bounds, the item is not replaced.
*/
export declare function replace<T>(array: readonly T[], index: number, item: T): T[];

View file

@ -0,0 +1,97 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.replace = exports.move = exports.splice = exports.reduce = exports.map = exports.filter = exports.concurrentFilter = exports.conform = void 0;
function conform(t) {
if (typeof t === 'undefined') {
return [];
}
if (!Array.isArray(t)) {
return [t];
}
return t;
}
exports.conform = conform;
async function concurrentFilter(array, callback) {
const mapper = async (v) => [v, await callback(v)];
const mapped = await Promise.all(array.map(mapper));
return mapped
.filter(([, f]) => f)
.map(([v]) => v);
}
exports.concurrentFilter = concurrentFilter;
async function filter(array, callback) {
const initial = [];
return reduce(array, async (acc, v, i, arr) => {
if (await callback(v, i, arr)) {
acc.push(v);
}
return acc;
}, initial);
}
exports.filter = filter;
async function map(array, callback) {
const initial = [];
return reduce(array, async (acc, v, i, arr) => {
acc.push(await callback(v, i, arr));
return acc;
}, initial);
}
exports.map = map;
async function reduce(array, callback, initialValue) {
const hadInitialValue = typeof initialValue === 'undefined';
const startingIndex = hadInitialValue ? 1 : 0;
if (typeof initialValue === 'undefined') {
if (array.length === 0) {
throw new TypeError('Reduce of empty array with no initial value');
}
initialValue = array[0];
}
let value = initialValue;
for (let i = startingIndex; i < array.length; i++) {
const v = await callback(value, array[i], i, array);
value = v;
}
return value;
}
exports.reduce = reduce;
/**
* Splice an array.
*
* This function will return a new array with the standard splice behavior
* applied. Unlike the standard array splice, the array of removed items is not
* returned.
*/
function splice(array, start, deleteCount = array.length - start, ...items) {
const result = [...array];
result.splice(start, deleteCount, ...items);
return result;
}
exports.splice = splice;
/**
* Move an item in an array by index.
*
* This function will return a new array with the item in the `fromIndex`
* position moved to the `toIndex` position. If `fromIndex` or `toIndex` are
* out of bounds, the array items remain unmoved.
*/
function move(array, fromIndex, toIndex) {
const element = array[fromIndex];
if (fromIndex < 0 || toIndex < 0 || fromIndex >= array.length || toIndex >= array.length) {
return [...array];
}
return splice(splice(array, fromIndex, 1), toIndex, 0, element);
}
exports.move = move;
/**
* Replace an item in an array by index.
*
* This function will return a new array with the item in the `index` position
* replaced with `item`. If `index` is out of bounds, the item is not replaced.
*/
function replace(array, index, item) {
if (index < 0 || index > array.length) {
return [...array];
}
return splice(array, index, 1, item);
}
exports.replace = replace;

View file

@ -0,0 +1,49 @@
{
"name": "@ionic/utils-array",
"version": "2.1.6",
"description": "Array utils",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://ionicframework.com/",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"files": [
"dist/",
"LICENSE",
"README.md"
],
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-cli.git"
},
"bugs": {
"url": "https://github.com/ionic-team/ionic-cli/issues"
},
"scripts": {
"clean": "rimraf dist",
"lint": "true",
"build": "npm run clean && tsc",
"watch": "tsc -w --preserveWatchOutput",
"test": "jest --maxWorkers=4",
"prepublishOnly": "npm run build"
},
"dependencies": {
"debug": "^4.0.0",
"tslib": "^2.0.1"
},
"devDependencies": {
"@types/debug": "^4.1.1",
"@types/jest": "^26.0.10",
"@types/node": "~16.0.0",
"jest": "^26.4.2",
"jest-cli": "^26.0.1",
"lint-staged": "^10.0.2",
"rimraf": "^3.0.0",
"ts-jest": "~26.3.0",
"typescript": "~4.8.0"
},
"gitHead": "15ef6e7da4eace4fd55d16fd9508d156a4bc8203"
}

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Drifty Co
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.

View file

@ -0,0 +1 @@
# @ionic/utils-stream

View file

@ -0,0 +1,39 @@
/// <reference types="node" />
/// <reference types="node" />
import { Readable, ReadableOptions, Writable, WritableOptions } from 'stream';
export declare class NullStream extends Writable {
_write(chunk: any, encoding: string, callback: () => void): void;
}
export interface ReadableStreamBufferOptions extends ReadableOptions {
chunkSize?: number;
allocSize?: number;
growSize?: number;
}
export declare class ReadableStreamBuffer extends Readable {
protected buffer: Buffer;
protected _size: number;
protected _stopped: boolean;
protected chunkSize: number;
protected growSize: number;
constructor(opts?: ReadableStreamBufferOptions);
get size(): number;
get stopped(): boolean;
_read(): void;
feed(data: Buffer | string, encoding?: BufferEncoding): void;
stop(): void;
protected _send(): void;
}
export interface WritableStreamBufferOptions extends WritableOptions {
allocSize?: number;
growSize?: number;
}
export declare class WritableStreamBuffer extends Writable {
protected buffer: Buffer;
protected _size: number;
protected growSize: number;
constructor(opts?: WritableStreamBufferOptions);
get size(): number;
_write(chunk: any, encoding: string, callback: () => void): void;
consume(bytes?: number): Buffer;
}
export declare function growBufferForAppendedData(buf: Buffer, actualsize: number, appendsize: number): Buffer;

View file

@ -0,0 +1,108 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.growBufferForAppendedData = exports.WritableStreamBuffer = exports.ReadableStreamBuffer = exports.NullStream = void 0;
const stream_1 = require("stream");
const DEFAULT_CHUNK_SIZE = 4;
const DEFAULT_ALLOC_SIZE = 32;
const DEFAULT_GROW_SIZE = 16;
class NullStream extends stream_1.Writable {
_write(chunk, encoding, callback) {
callback();
}
}
exports.NullStream = NullStream;
class ReadableStreamBuffer extends stream_1.Readable {
constructor(opts) {
super(opts);
this._size = 0;
this._stopped = false;
this.buffer = Buffer.alloc(opts && opts.allocSize ? opts.allocSize : DEFAULT_ALLOC_SIZE);
this.chunkSize = opts && opts.chunkSize ? opts.chunkSize : DEFAULT_CHUNK_SIZE;
this.growSize = opts && opts.growSize ? opts.growSize : DEFAULT_GROW_SIZE;
}
get size() {
return this._size;
}
get stopped() {
return this._stopped;
}
_read() {
this._send();
}
feed(data, encoding = 'utf8') {
if (this._stopped) {
throw new Error('ReadableStreamBuffer is stopped. Can no longer feed.');
}
const datasize = typeof data === 'string' ? Buffer.byteLength(data) : data.length;
this.buffer = growBufferForAppendedData(this.buffer, this._size, Math.ceil(datasize / this.growSize) * this.growSize);
if (typeof data === 'string') {
this.buffer.write(data, this._size, datasize, encoding);
}
else {
this.buffer.copy(data, this._size, 0);
}
this._size += datasize;
}
stop() {
if (this._stopped) {
return;
}
this._stopped = true;
if (this._size === 0) {
this.push(null);
}
}
_send() {
const chunkSize = Math.min(this.chunkSize, this._size);
let done = false;
if (chunkSize > 0) {
const chunk = Buffer.alloc(chunkSize);
this.buffer.copy(chunk, 0, 0, chunkSize);
done = !this.push(chunk);
this.buffer.copy(this.buffer, 0, chunkSize, this._size);
this._size -= chunkSize;
}
if (this._size === 0 && this._stopped) {
this.push(null);
}
if (!done) {
setTimeout(() => this._send(), 1);
}
}
}
exports.ReadableStreamBuffer = ReadableStreamBuffer;
class WritableStreamBuffer extends stream_1.Writable {
constructor(opts) {
super(opts);
this._size = 0;
this.buffer = Buffer.alloc(opts && opts.allocSize ? opts.allocSize : DEFAULT_ALLOC_SIZE);
this.growSize = opts && opts.growSize ? opts.growSize : DEFAULT_GROW_SIZE;
}
get size() {
return this._size;
}
_write(chunk, encoding, callback) {
this.buffer = growBufferForAppendedData(this.buffer, this._size, Math.ceil(chunk.length / this.growSize) * this.growSize);
chunk.copy(this.buffer, this._size, 0);
this._size += chunk.length;
callback();
}
consume(bytes) {
bytes = typeof bytes === 'number' ? bytes : this._size;
const data = Buffer.alloc(bytes);
this.buffer.copy(data, 0, 0, data.length);
this.buffer.copy(this.buffer, 0, data.length);
this._size -= data.length;
return data;
}
}
exports.WritableStreamBuffer = WritableStreamBuffer;
function growBufferForAppendedData(buf, actualsize, appendsize) {
if ((buf.length - actualsize) >= appendsize) {
return buf;
}
const newbuffer = Buffer.alloc(buf.length + appendsize);
buf.copy(newbuffer, 0, 0, actualsize);
return newbuffer;
}
exports.growBufferForAppendedData = growBufferForAppendedData;

View file

@ -0,0 +1,49 @@
{
"name": "@ionic/utils-stream",
"version": "3.1.7",
"description": "Stream utils for NodeJS",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://ionicframework.com/",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"files": [
"dist/",
"LICENSE",
"README.md"
],
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-cli.git"
},
"bugs": {
"url": "https://github.com/ionic-team/ionic-cli/issues"
},
"scripts": {
"clean": "rimraf dist",
"lint": "true",
"build": "npm run clean && tsc",
"watch": "tsc -w --preserveWatchOutput",
"test": "jest --maxWorkers=4",
"prepublishOnly": "npm run build"
},
"dependencies": {
"debug": "^4.0.0",
"tslib": "^2.0.1"
},
"devDependencies": {
"@types/debug": "^4.1.1",
"@types/jest": "^26.0.10",
"@types/node": "~16.0.0",
"jest": "^26.4.2",
"jest-cli": "^26.0.1",
"lint-staged": "^10.0.2",
"rimraf": "^3.0.0",
"stream-combiner2": "^1.1.1",
"ts-jest": "~26.3.0",
"typescript": "~4.8.0"
}
}

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Drifty Co
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.

View file

@ -0,0 +1 @@
# @ionic/utils-process

View file

@ -0,0 +1,98 @@
/// <reference types="node" />
import { ChildProcess, ForkOptions, SpawnOptions } from 'child_process';
export declare const ERROR_COMMAND_NOT_FOUND = "ERR_SUBPROCESS_COMMAND_NOT_FOUND";
export declare const ERROR_NON_ZERO_EXIT = "ERR_SUBPROCESS_NON_ZERO_EXIT";
export declare const ERROR_SIGNAL_EXIT = "ERR_SUBPROCESS_SIGNAL_EXIT";
export declare const TILDE_PATH_REGEX: RegExp;
export declare function expandTildePath(p: string): string;
/**
* Prepare the PATH environment variable for use with subprocesses.
*
* If a raw tilde is found in PATH, e.g. `~/.bin`, it is expanded. The raw
* tilde works in Bash, but not in Node's `child_process` outside of a shell.
*
* This is a utility method. You do not need to use it with `Subprocess`.
*
* @param path Defaults to `process.env.PATH`
*/
export declare function convertPATH(path?: string): string;
export declare class SubprocessError extends Error {
readonly name = "SubprocessError";
code?: typeof ERROR_COMMAND_NOT_FOUND | typeof ERROR_NON_ZERO_EXIT | typeof ERROR_SIGNAL_EXIT;
output?: string;
signal?: string;
exitCode?: number;
}
export interface SubprocessOptions extends SpawnOptions {
}
export interface SubprocessBashifyOptions {
/**
* Mask file path to first argument.
*
* The first argument to subprocesses is the program name or path, e.g.
* `/path/to/bin/my-program`. If `true`, `bashify()` will return the program
* name without a file path, e.g. `my-program`.
*
* The default is `true`.
*/
maskArgv0?: boolean;
/**
* Mask file path to second argument.
*
* In some subprocesses, the second argument is a script file to run, e.g.
* `node ./scripts/post-install`. If `true`, `bashify()` will return the
* script name without a file path, e.g. `node post-install`.
*
* The default is `false`.
*/
maskArgv1?: boolean;
/**
* Remove the first argument from output.
*
* Useful to make a command such as `node ./scripts/post-install` appear as
* simply `post-install`.
*
* The default is `false`.
*/
shiftArgv0?: boolean;
}
export declare class Subprocess {
name: string;
args: readonly string[];
protected readonly path?: string;
protected _options: SpawnOptions;
constructor(name: string, args: readonly string[], options?: SubprocessOptions);
get options(): Readonly<SpawnOptions>;
output(): Promise<string>;
combinedOutput(): Promise<string>;
run(): Promise<void> & {
p: ChildProcess;
};
spawn(): ChildProcess;
bashify({ maskArgv0, maskArgv1, shiftArgv0 }?: SubprocessBashifyOptions): string;
bashifyArg(arg: string): string;
maskArg(arg: string): string;
}
export declare function spawn(command: string, args?: readonly string[], options?: SpawnOptions): ChildProcess;
export declare function fork(modulePath: string, args?: readonly string[], options?: ForkOptions & Pick<SpawnOptions, 'stdio'>): ChildProcess;
export interface WhichOptions {
PATH?: string;
PATHEXT?: string;
}
/**
* Find the first instance of a program in PATH.
*
* If `program` contains a path separator, this function will merely return it.
*
* @param program A command name, such as `ionic`
*/
export declare function which(program: string, { PATH, PATHEXT }?: WhichOptions): Promise<string>;
/**
* Find all instances of a program in PATH.
*
* If `program` contains a path separator, this function will merely return it
* inside an array.
*
* @param program A command name, such as `ionic`
*/
export declare function findExecutables(program: string, { PATH, PATHEXT }?: WhichOptions): Promise<string[]>;

View file

@ -0,0 +1,228 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findExecutables = exports.which = exports.fork = exports.spawn = exports.Subprocess = exports.SubprocessError = exports.convertPATH = exports.expandTildePath = exports.TILDE_PATH_REGEX = exports.ERROR_SIGNAL_EXIT = exports.ERROR_NON_ZERO_EXIT = exports.ERROR_COMMAND_NOT_FOUND = void 0;
const tslib_1 = require("tslib");
const utils_array_1 = require("@ionic/utils-array");
const utils_fs_1 = require("@ionic/utils-fs");
const utils_process_1 = require("@ionic/utils-process");
const utils_stream_1 = require("@ionic/utils-stream");
const utils_terminal_1 = require("@ionic/utils-terminal");
const child_process_1 = require("child_process");
const cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn"));
const os = tslib_1.__importStar(require("os"));
const pathlib = tslib_1.__importStar(require("path"));
exports.ERROR_COMMAND_NOT_FOUND = 'ERR_SUBPROCESS_COMMAND_NOT_FOUND';
exports.ERROR_NON_ZERO_EXIT = 'ERR_SUBPROCESS_NON_ZERO_EXIT';
exports.ERROR_SIGNAL_EXIT = 'ERR_SUBPROCESS_SIGNAL_EXIT';
exports.TILDE_PATH_REGEX = /^~($|\/|\\)/;
function expandTildePath(p) {
const h = os.homedir();
return p.replace(exports.TILDE_PATH_REGEX, `${h}$1`);
}
exports.expandTildePath = expandTildePath;
/**
* Prepare the PATH environment variable for use with subprocesses.
*
* If a raw tilde is found in PATH, e.g. `~/.bin`, it is expanded. The raw
* tilde works in Bash, but not in Node's `child_process` outside of a shell.
*
* This is a utility method. You do not need to use it with `Subprocess`.
*
* @param path Defaults to `process.env.PATH`
*/
function convertPATH(path = process.env.PATH || '') {
return path.split(pathlib.delimiter).map(expandTildePath).join(pathlib.delimiter);
}
exports.convertPATH = convertPATH;
class SubprocessError extends Error {
constructor() {
super(...arguments);
this.name = 'SubprocessError';
}
}
exports.SubprocessError = SubprocessError;
class Subprocess {
constructor(name, args, options = {}) {
this.name = name;
this.args = args;
const masked = this.maskArg(name);
if (masked !== name) {
this.name = masked;
this.path = name;
}
this._options = options;
}
get options() {
const opts = this._options;
if (!opts.env) {
opts.env = process.env;
}
const env = (0, utils_process_1.createProcessEnv)(opts.env || {}, {
PATH: convertPATH(typeof opts.env.PATH === 'string' ? opts.env.PATH : process.env.PATH),
});
return { ...opts, env };
}
async output() {
this._options.stdio = 'pipe';
const promise = this.run();
const stdoutBuf = new utils_stream_1.WritableStreamBuffer();
const stderrBuf = new utils_stream_1.WritableStreamBuffer();
const combinedBuf = new utils_stream_1.WritableStreamBuffer();
promise.p.stdout?.pipe(stdoutBuf);
promise.p.stdout?.pipe(combinedBuf);
promise.p.stderr?.pipe(stderrBuf);
promise.p.stderr?.pipe(combinedBuf);
try {
await promise;
}
catch (e) {
stdoutBuf.end();
stderrBuf.end();
e.output = combinedBuf.consume().toString();
throw e;
}
stderrBuf.end();
combinedBuf.end();
return stdoutBuf.consume().toString();
}
async combinedOutput() {
this._options.stdio = 'pipe';
const promise = this.run();
const buf = new utils_stream_1.WritableStreamBuffer();
promise.p.stdout?.pipe(buf);
promise.p.stderr?.pipe(buf);
try {
await promise;
}
catch (e) {
e.output = buf.consume().toString();
throw e;
}
return buf.consume().toString();
}
run() {
const p = this.spawn();
const promise = new Promise((resolve, reject) => {
p.on('error', (error) => {
let err;
if (error.code === 'ENOENT') {
err = new SubprocessError('Command not found.', { cause: error });
err.code = exports.ERROR_COMMAND_NOT_FOUND;
}
else {
err = new SubprocessError('Command error.', { cause: error });
}
reject(err);
});
p.on('close', (code, signal) => {
let err;
if (code === 0) {
return resolve();
}
else if (signal) {
err = new SubprocessError('Signal exit from subprocess.');
err.code = exports.ERROR_SIGNAL_EXIT;
err.signal = signal;
}
else if (code) {
err = new SubprocessError('Non-zero exit from subprocess.');
err.code = exports.ERROR_NON_ZERO_EXIT;
err.exitCode = code;
}
else {
return resolve();
}
reject(err);
});
});
Object.defineProperties(promise, {
p: { value: p },
});
return promise;
}
spawn() {
return spawn(this.path ? this.path : this.name, this.args, this.options);
}
bashify({ maskArgv0 = true, maskArgv1 = false, shiftArgv0 = false } = {}) {
const args = [this.path ? this.path : this.name, ...this.args];
if (shiftArgv0) {
args.shift();
}
if (args[0] && maskArgv0) {
args[0] = this.maskArg(args[0]);
}
if (args[1] && maskArgv1) {
args[1] = this.maskArg(args[1]);
}
return args.length > 0
? args.map(arg => this.bashifyArg(arg)).join(' ')
: '';
}
bashifyArg(arg) {
return arg.includes(' ') ? `"${arg.replace(/\"/g, '\\"')}"` : arg;
}
maskArg(arg) {
const i = arg.lastIndexOf(pathlib.sep);
return i >= 0 ? arg.substring(i + 1) : arg;
}
}
exports.Subprocess = Subprocess;
function spawn(command, args = [], options) {
return (0, cross_spawn_1.default)(command, [...args], options);
}
exports.spawn = spawn;
function fork(modulePath, args = [], options = {}) {
return (0, child_process_1.fork)(modulePath, [...args], options);
}
exports.fork = fork;
const DEFAULT_PATHEXT = utils_terminal_1.TERMINAL_INFO.windows ? '.COM;.EXE;.BAT;.CMD' : undefined;
/**
* Find the first instance of a program in PATH.
*
* If `program` contains a path separator, this function will merely return it.
*
* @param program A command name, such as `ionic`
*/
async function which(program, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT } = {}) {
if (program.includes(pathlib.sep)) {
return program;
}
const results = await _findExecutables(program, { PATH });
if (!results.length) {
const err = new Error(`${program} cannot be found within PATH`);
err.code = 'ENOENT';
throw err;
}
return results[0];
}
exports.which = which;
/**
* Find all instances of a program in PATH.
*
* If `program` contains a path separator, this function will merely return it
* inside an array.
*
* @param program A command name, such as `ionic`
*/
async function findExecutables(program, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT } = {}) {
if (program.includes(pathlib.sep)) {
return [program];
}
return _findExecutables(program, { PATH });
}
exports.findExecutables = findExecutables;
async function _findExecutables(program, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT } = {}) {
const pathParts = (0, utils_process_1.getPathParts)(PATH);
let programNames;
// if windows, cycle through all possible executable extensions
// ex: node.exe, npm.cmd, etc.
if (utils_terminal_1.TERMINAL_INFO.windows) {
const exts = (0, utils_process_1.getPathParts)(PATHEXT).map(ext => ext.toLowerCase());
// don't append extensions if one has already been provided
programNames = exts.includes(pathlib.extname(program).toLowerCase()) ? [program] : exts.map(ext => program + ext);
}
else {
programNames = [program];
}
return [].concat(...await (0, utils_array_1.map)(programNames, async (programName) => (0, utils_array_1.concurrentFilter)(pathParts.map(p => pathlib.join(p, programName)), async (p) => (0, utils_fs_1.isExecutableFile)(p))));
}

View file

@ -0,0 +1,55 @@
{
"name": "@ionic/utils-subprocess",
"version": "3.0.1",
"description": "Subprocess utils for NodeJS",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://ionicframework.com/",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"files": [
"dist/",
"LICENSE",
"README.md"
],
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-cli.git"
},
"bugs": {
"url": "https://github.com/ionic-team/ionic-cli/issues"
},
"scripts": {
"clean": "rimraf dist",
"lint": "true",
"build": "npm run clean && tsc",
"watch": "tsc -w --preserveWatchOutput",
"test": "jest --maxWorkers=4",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@ionic/utils-array": "2.1.6",
"@ionic/utils-fs": "3.1.7",
"@ionic/utils-process": "2.1.12",
"@ionic/utils-stream": "3.1.7",
"@ionic/utils-terminal": "2.3.5",
"cross-spawn": "^7.0.3",
"debug": "^4.0.0",
"tslib": "^2.0.1"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.0",
"@types/debug": "^4.1.1",
"@types/jest": "^26.0.10",
"@types/node": "~16.0.0",
"jest": "^26.4.2",
"jest-cli": "^26.0.1",
"lint-staged": "^10.0.2",
"rimraf": "^3.0.0",
"ts-jest": "~26.3.0",
"typescript": "~4.8.0"
}
}