fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

9
node_modules/wait-on/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,9 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true

20
node_modules/wait-on/.eslintrc.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
module.exports = {
env: {
mocha: true
},
plugins: ['chai-friendly'],
extends: ['standard', 'prettier'],
root: true,
rules: {
'no-use-before-define': 'off',
'no-unused-vars': [
'error',
{
varsIgnorePattern: 'should|expect'
}
],
// disable the original no-unused-expressions use chai-friendly
'no-unused-expressions': 'off',
'chai-friendly/no-unused-expressions': 'error'
}
};

6
node_modules/wait-on/.prettierrc.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
module.exports = {
tabWidth: 2,
singleQuote: true,
printWidth: 120,
trailingComma: 'none',
};

7
node_modules/wait-on/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,7 @@
dist: jammy
language: node_js
node_js:
- '12'
- '14'
- '16'
- '18'

9
node_modules/wait-on/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2015 Jeff Barczewski
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.

305
node_modules/wait-on/README.md generated vendored Normal file
View File

@@ -0,0 +1,305 @@
# wait-on - wait for files, ports, sockets, http(s) resources
wait-on is a cross-platform command line utility which will wait for files, ports, sockets, and http(s) resources to become available (or not available using reverse mode). Functionality is also available via a Node.js API. Cross-platform - runs everywhere Node.js runs (linux, unix, mac OS X, windows)
wait-on will wait for period of time for a file to stop growing before triggering availability which is good for monitoring files that are being built. Likewise wait-on will wait for period of time for other resources to remain available before triggering success.
For http(s) resources wait-on will check that the requests are returning 2XX (success) to HEAD or GET requests (after following any redirects).
wait-on can also be used in reverse mode which waits for resources to NOT be available. This is useful in waiting for services to shutdown before continuing. (Thanks @skarbovskiy for adding this feature)
[![Build Status](https://travis-ci.com/jeffbski/wait-on.svg?branch=master)](https://travis-ci.com/jeffbski/wait-on)
## Installation
Latest wait-on version 7+ requires Node.js 12+
wait-on versions 4-6 requires Node.js 10+
(Node.js v8 users can use wait-on@5.3.0, v4 users can still use wait-on@2.1.2, and older Node.js
engines, use wait-on@1.5.4)
```bash
npm install wait-on # local version
OR
npm install -g wait-on # global version
```
## Usage
Use from command line or using Node.js programmatic API.
### CLI Usage
Assuming NEXT_CMD is the command to run when resources are available, then wait-on will wait and then exit with a successful exit code (0) once all resources are available, causing NEXT_CMD to be run.
wait-on can also be used in reverse mode, which waits for resources to NOT be available. This is useful in waiting for services to shutdown before continuing. (Thanks @skarbovskiy for adding)
If wait-on is interrupted before all resources are available, it will exit with a non-zero exit code and thus NEXT_CMD will not be run.
```bash
wait-on file1 && NEXT_CMD # wait for file1, then exec NEXT_CMD
wait-on f1 f2 && NEXT_CMD # wait for both f1 and f2, the exec NEXT_CMD
wait-on http://localhost:8000/foo && NEXT_CMD # wait for http 2XX HEAD
wait-on https://myserver/foo && NEXT_CMD # wait for https 2XX HEAD
wait-on http-get://localhost:8000/foo && NEXT_CMD # wait for http 2XX GET
wait-on https-get://myserver/foo && NEXT_CMD # wait for https 2XX GET
wait-on tcp:4000 && NEXT_CMD # wait for service to listen on a TCP port
wait-on socket:/path/mysock # wait for service to listen on domain socket
wait-on http://unix:/var/SOCKPATH:/a/foo # wait for http HEAD on domain socket
wait-on http-get://unix:/var/SOCKPATH:/a/foo # wait for http GET on domain socket
```
```
Usage: wait-on {OPTIONS} resource [...resource]
Description:
wait-on is a command line utility which will wait for files, ports,
sockets, and http(s) resources to become available (or not available
using reverse flag). Exits with success code (0) when all resources
are ready. Non-zero exit code if interrupted or timed out.
Options may also be specified in a config file (js or json). For
example --config configFile.js would result in configFile.js being
required and the resulting object will be merged with any
command line options before wait-on is called. See exampleConfig.js
In shell combine with && to conditionally run another command
once resources are available. ex: wait-on f1 && NEXT_CMD
resources types are defined by their prefix, if no prefix is
present, the resource is assumed to be of type 'file'. Resources
can also be provided in the config file.
resource prefixes are:
file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
tcp: - TCP port is listening. ex: 1.2.3.4:9000 or foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar or
http-get://unix:/path/to/sock:/foo/bar
Standard Options:
-c, --config
js or json config file, useful for http(s) options and resources
-d, --delay
Initial delay before checking for resources in ms, default 0
--httpTimeout
Maximum time in ms to wait for an HTTP HEAD/GET request, default 0
which results in using the OS default
-i, --interval
Interval to poll resources in ms, default 250ms
-l, --log
Log resources begin waited on and when complete or errored
-r, --reverse
Reverse operation, wait for resources to NOT be available
-s, --simultaneous
Simultaneous / Concurrent connections to a resource, default Infinity
Setting this to 1 would delay new requests until previous one has completed.
Used to limit the number of connections attempted to a resource at a time.
-t, --timeout
Maximum time in ms to wait before exiting with failure (1) code,
default Infinity
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
--tcpTimeout
Maximum time in ms for tcp connect, default 300ms
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
--httpTimeout
Maximum time to wait for the HTTP request, default Infinity
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
-v, --verbose
Enable debug output to stdout
-w, --window
Stability window, the time in ms defining the window of time that
resource needs to have not changed (file size or availability) before
signalling success, default 750ms. If less than interval, it will be
reset to the value of interval. This is only used for files, other
resources are considered available on first detection.
-h, --help
Show this message
```
### Node.js API usage
```javascript
var waitOn = require('wait-on');
var opts = {
resources: [
'file1',
'http://foo.com:8000/bar',
'https://my.com/cat',
'http-get://foo.com:8000/bar',
'https-get://my.com/cat',
'tcp:foo.com:8000',
'socket:/my/sock',
'http://unix:/my/sock:/my/url',
'http-get://unix:/my/sock:/my/url'
],
delay: 1000, // initial delay in ms, default 0
interval: 100, // poll interval in ms, default 250ms
simultaneous: 1, // limit to 1 connection per resource at a time
timeout: 30000, // timeout in ms, default Infinity
tcpTimeout: 1000, // tcp timeout in ms, default 300ms
window: 1000, // stabilization time in ms, default 750ms
// http options
ca: [
/* strings or binaries */
],
cert: [
/* strings or binaries */
],
key: [
/* strings or binaries */
],
passphrase: 'yourpassphrase',
proxy: false /* OR proxy config as defined in axios.
If not set axios detects proxy from env vars http_proxy and https_proxy
https://github.com/axios/axios#config-defaults
{
host: '127.0.0.1',
port: 9000,
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
} */,
auth: {
user: 'theuser', // or username
pass: 'thepassword' // or password
},
strictSSL: false,
followRedirect: true,
headers: {
'x-custom': 'headers'
},
validateStatus: function (status) {
return status >= 200 && status < 300; // default if not provided
}
};
// Usage with callback function
waitOn(opts, function (err) {
if (err) {
return handleError(err);
}
// once here, all resources are available
});
// Usage with promises
waitOn(opts)
.then(function () {
// once here, all resources are available
})
.catch(function (err) {
handleError(err);
});
// Usage with async await
try {
await waitOn(opts);
// once here, all resources are available
} catch (err) {
handleError(err);
}
```
waitOn(opts, [cb]) - function which triggers resource checks
- opts.resources - array of string resources to wait for. prefix determines the type of resource with the default type of `file:`
- opts.delay - optional initial delay in ms, default 0
- opts.interval - optional poll resource interval in ms, default 250ms
- opts.log - optional flag which outputs to stdout, remaining resources waited on and when complete or errored
- opts.resources - optional array of string resources to wait for if none are specified via command line
- opts.reverse - optional flag to reverse operation so checks are for resources being NOT available, default false
- opts.simultaneous - optional count to limit concurrent connections per resource at a time, setting to 1 waits for previous connection to succeed, fail, or timeout before sending another, default infinity
- opts.timeout - optional timeout in ms, default Infinity. Aborts with error.
- opts.tcpTimeout - optional tcp timeout in ms, default 300ms
- opts.verbose - optional flag which outputs debug output, default false
- opts.window - optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged.
- http(s) specific options, see https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for specific details
- opts.ca: [ /* strings or binaries */ ],
- opts.cert: [ /* strings or binaries */ ],
- opts.key: [ /* strings or binaries */ ],
- opts.passphrase: 'yourpassphrase',
- opts.proxy: undefined, false, or object as defined in axios. Default is undefined. If not set axios detects proxy from env vars http_proxy and https_proxy. https://github.com/axios/axios#config-defaults
```js
// example proxy object
{
host: '127.0.0.1',
port: 9000,
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
}
```
- opts.auth: { user, pass }
- opts.strictSSL: false,
- opts.followRedirect: false, // defaults to true
- opts.headers: { 'x-custom': 'headers' },
- cb(err) - if err is provided then, resource checks did not succeed
## Goals
- simple command line utility and Node.js API for waiting for resources
- wait for files to stabilize
- wait for http(s) resources to return 2XX in response to HEAD request
- wait for http(s) resources to return 2XX in response to GET request
- wait for services to be listening on tcp ports
- wait for services to be listening on unix domain sockets
- configurable initial delay, poll interval, stabilization window, timeout
- command line utility returns success code (0) when resources are availble
- command line utility that can also wait for resources to not be available using reverse flag. This is useful for waiting for services to shutdown before continuing.
- cross platform - runs anywhere Node.js runs (linux, unix, mac OS X, windows)
## Why
I frequently need to wait on build tasks to complete or services to be available before starting next command, so this project makes that easier and is portable to everywhere Node.js runs.
## Get involved
If you have input or ideas or would like to get involved, you may:
- contact me via twitter @jeffbski - <http://twitter.com/jeffbski>
- open an issue on github to begin a discussion - <https://github.com/jeffbski/wait-on/issues>
- fork the repo and send a pull request (ideally with tests) - <https://github.com/jeffbski/wait-on>
## License
- [MIT license](http://github.com/jeffbski/wait-on/raw/master/LICENSE)

97
node_modules/wait-on/bin/usage.txt generated vendored Normal file
View File

@@ -0,0 +1,97 @@
Usage: wait-on {OPTIONS} resource [...resource]
Description:
wait-on is a command line utility which will wait for files, ports,
sockets, and http(s) resources to become available (or not available
using reverse flag). Exits with success code (0) when all resources
are ready. Non-zero exit code if interrupted or timed out.
Options may also be specified in a config file (js or json). For
example --config configFile.js would result in configFile.js being
required and the resulting object will be merged with any
command line options before wait-on is called. See exampleConfig.js
In shell combine with && to conditionally run another command
once resources are available. ex: wait-on f1 && NEXT_CMD
resources types are defined by their prefix, if no prefix is
present, the resource is assumed to be of type 'file'
resource prefixes are:
file: - regular file (also default type). ex: file:/path/to/file
http: - HTTP HEAD returns 2XX response. ex: http://m.com:90/foo
https: - HTTPS HEAD returns 2XX response. ex: https://my/bar
http-get: - HTTP GET returns 2XX response. ex: http-get://m.com:90/foo
https-get: - HTTPS GET returns 2XX response. ex: https-get://my/bar
tcp: - TCP port is listening. ex: tcp:1.2.3.4:9000 or tcp:foo.com:700
socket: - Domain Socket is listening. ex: socket:/path/to/sock
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar or
http-get://unix:/path/to/sock:/foo/bar
Standard Options:
-c, --config
js or json config file, useful for http(s) options
-d, --delay
Initial delay before checking for resources in ms, default 0
--httpTimeout
Maximum time in ms to wait for an HTTP HEAD/GET request, default 0
which results in using the OS default
-i, --interval
Interval to poll resources in ms, default 250ms
-l, --log
Log resources begin waited on and when complete or errored
-r, --reverse
Reverse operation, wait for resources to NOT be available
-s, --simultaneous
Simultaneous / Concurrent connections to a resource, default Infinity
Setting this to 1 would delay new requests until previous one has completed.
Used to limit the number of connections attempted to a resource at a time.
-t, --timeout
Maximum time in ms to wait before exiting with failure (1) code,
default Infinity
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
--tcpTimeout
Maximum time in ms for tcp connect, default 300ms
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
--httpTimeout
Maximum time to wait for the HTTP request, default Infinity
Use postfix 'ms', 's', 'm' or 'h' to change the unit.
-v, --verbose
Enable debug output to stdout
-w, --window
Stability window, the time in ms defining the window of time that
resource needs to have not changed (file size/availability) before
signaling success, default 750ms. If less than interval, it will be
reset to the value of interval. This is only used for files, other
resources are considered available on first detection.
-h, --help
Show this message

101
node_modules/wait-on/bin/wait-on generated vendored Executable file
View File

@@ -0,0 +1,101 @@
#!/usr/bin/env node
const fs = require('fs');
const minimist = require('minimist');
const path = require('path');
const waitOn = require('../');
const interval = ['timeout', 'httpTimeout', 'tcpTimeout'];
const minimistOpts = {
string: ['c', 'd', 'i', 's', 't', 'w'].concat(interval),
boolean: ['h', 'l', 'r', 'v'],
alias: {
c: 'config',
d: 'delay',
i: 'interval',
l: 'log',
r: 'reverse',
s: 'simultaneous',
t: 'timeout',
v: 'verbose',
w: 'window',
h: 'help'
}
};
const argv = minimist(process.argv.slice(2), minimistOpts);
// if a js/json configuration file is provided require it
const configOpts = argv.config ? require(path.resolve(argv.config)) : {};
const hasResources = argv._.length || (configOpts.resources && configOpts.resources.length);
if (argv.help || !hasResources) {
// help
fs.createReadStream(path.join(__dirname, '/usage.txt'))
.pipe(process.stdout)
.on('close', function () {
process.exit(1);
});
} else {
// if resources are present in the command line then they take
// precedence over those in the config file.
if (argv._.length) {
configOpts.resources = argv._;
}
// now check for specific options and set those
const opts = [
'delay',
'httpTimeout',
'interval',
'log',
'reverse',
'simultaneous',
'timeout',
'tcpTimeout',
'verbose',
'window'
].reduce(function (accum, x) {
if (argv[x]) {
let value = argv[x];
if (interval.includes(x)) {
value = parseInterval(value);
}
accum[x] = value;
}
return accum;
}, configOpts);
waitOn(opts, function (err) {
if (err) {
return errorExit(err);
}
// success, could just let it exit on its own, however since
// rxjs window waits an extra loop before heeding the unsubscribe
// we can exit to speed things up
process.exit(0);
});
}
function errorExit(err) {
if (err.stack) {
console.error(err.stack);
} else {
console.error(String(err));
}
process.exit(1);
}
function parseInterval(arg) {
const res = /^([\d.]+)(|ms|s|m|h)$/i.exec(arg);
if (!res) {
return arg;
}
const value = parseFloat(res[1]);
switch (res[2]) {
case '':
case 'ms': return Math.floor(value);
case 's': return Math.floor(value * 1000);
case 'm': return Math.floor(value * 1000 * 60);
case 'h': return Math.floor(value * 1000 * 60 * 60);
}
}

25
node_modules/wait-on/exampleConfig.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
module.exports = {
// specify additional options here, especially http(s)
// see https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for specifics
ca: [
/* strings or binaries */
],
cert: [
/* strings or binaries */
],
key: [
/* strings or binaries */
],
passphrase: 'yourpassphrase',
auth: {
username: 'yourusername',
password: 'yourpassword'
},
strictSSL: false,
followRedirect: false,
headers: {
'x-custom': 'headers'
},
// optional default resources if not specified in command args
resources: ['http://foo/bar', 'http://cat/dog']
};

400
node_modules/wait-on/lib/wait-on.js generated vendored Normal file
View File

@@ -0,0 +1,400 @@
'use strict';
const fs = require('fs');
const { promisify } = require('util');
const Joi = require('joi');
const https = require('https');
const net = require('net');
const util = require('util');
const axiosPkg = require('axios').default;
const { isBoolean, isEmpty, negate, noop, once, partial, pick, zip } = require('lodash/fp');
const { NEVER, combineLatest, from, merge, throwError, timer } = require('rxjs');
const { distinctUntilChanged, map, mergeMap, scan, startWith, take, takeWhile } = require('rxjs/operators');
// force http adapter for axios, otherwise if using jest/jsdom xhr might
// be used and it logs all errors polluting the logs
const axios = axiosPkg.create({ adapter: 'http' });
const isNotABoolean = negate(isBoolean);
const isNotEmpty = negate(isEmpty);
const fstat = promisify(fs.stat);
const PREFIX_RE = /^((https?-get|https?|tcp|socket|file):)(.+)$/;
const HOST_PORT_RE = /^(([^:]*):)?(\d+)$/;
const HTTP_GET_RE = /^https?-get:/;
const HTTP_UNIX_RE = /^http:\/\/unix:([^:]+):([^:]+)$/;
const TIMEOUT_ERR_MSG = 'Timed out waiting for';
const WAIT_ON_SCHEMA = Joi.object({
resources: Joi.array().items(Joi.string().required()).required(),
delay: Joi.number().integer().min(0).default(0),
httpTimeout: Joi.number().integer().min(0),
interval: Joi.number().integer().min(0).default(250),
log: Joi.boolean().default(false),
reverse: Joi.boolean().default(false),
simultaneous: Joi.number().integer().min(1).default(Infinity),
timeout: Joi.number().integer().min(0).default(Infinity),
validateStatus: Joi.function(),
verbose: Joi.boolean().default(false),
window: Joi.number().integer().min(0).default(750),
tcpTimeout: Joi.number().integer().min(0).default(300),
// http/https options
ca: [Joi.string(), Joi.binary()],
cert: [Joi.string(), Joi.binary()],
key: [Joi.string(), Joi.binary(), Joi.object()],
passphrase: Joi.string(),
proxy: [Joi.boolean(), Joi.object()],
auth: Joi.object({
username: Joi.string(),
password: Joi.string()
}),
strictSSL: Joi.boolean().default(false),
followRedirect: Joi.boolean().default(true), // HTTP 3XX responses
headers: Joi.object()
});
/**
Waits for resources to become available before calling callback
Polls file, http(s), tcp ports, sockets for availability.
Resource types are distinquished by their prefix with default being `file:`
- file:/path/to/file - waits for file to be available and size to stabilize
- http://foo.com:8000/bar verifies HTTP HEAD request returns 2XX
- https://my.bar.com/cat verifies HTTPS HEAD request returns 2XX
- http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
- https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
- tcp:my.server.com:3000 verifies a service is listening on port
- socket:/path/sock verifies a service is listening on (UDS) socket
For http over socket, use http://unix:SOCK_PATH:URL_PATH
like http://unix:/path/to/sock:/foo/bar or
http-get://unix:/path/to/sock:/foo/bar
@param opts object configuring waitOn
@param opts.resources array of string resources to wait for. prefix determines the type of resource with the default type of `file:`
@param opts.delay integer - optional initial delay in ms, default 0
@param opts.httpTimeout integer - optional http HEAD/GET timeout to wait for request, default 0
@param opts.interval integer - optional poll resource interval in ms, default 250ms
@param opts.log boolean - optional flag to turn on logging to stdout
@param opts.reverse boolean - optional flag which reverses the mode, succeeds when resources are not available
@param opts.simultaneous integer - optional limit of concurrent connections to a resource, default Infinity
@param opts.tcpTimeout - Maximum time in ms for tcp connect, default 300ms
@param opts.timeout integer - optional timeout in ms, default Infinity. Aborts with error.
@param opts.verbose boolean - optional flag to turn on debug log
@param opts.window integer - optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged. If less than interval then will be reset to interval
@param cb optional callback function with signature cb(err) - if err is provided then, resource checks did not succeed
if not specified, wait-on will return a promise that will be rejected if resource checks did not succeed or resolved otherwise
*/
function waitOn(opts, cb) {
if (cb !== undefined) {
return waitOnImpl(opts, cb);
} else {
// promise API
return new Promise(function (resolve, reject) {
waitOnImpl(opts, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
}
function waitOnImpl(opts, cbFunc) {
const cbOnce = once(cbFunc);
const validResult = WAIT_ON_SCHEMA.validate(opts);
if (validResult.error) {
return cbOnce(validResult.error);
}
const validatedOpts = {
...validResult.value, // use defaults
// window needs to be at least interval
...(validResult.value.window < validResult.value.interval ? { window: validResult.value.interval } : {}),
...(validResult.value.verbose ? { log: true } : {}) // if debug logging then normal log is also enabled
};
const { resources, log: shouldLog, timeout, verbose, reverse } = validatedOpts;
const output = verbose ? console.log.bind() : noop;
const log = shouldLog ? console.log.bind() : noop;
const logWaitingForWDeps = partial(logWaitingFor, [{ log, resources }]);
const createResourceWithDeps$ = partial(createResource$, [{ validatedOpts, output, log }]);
let lastResourcesState = resources; // the last state we had recorded
const timeoutError$ =
timeout !== Infinity
? timer(timeout).pipe(
mergeMap(() => {
const resourcesWaitingFor = determineRemainingResources(resources, lastResourcesState).join(', ');
return throwError(Error(`${TIMEOUT_ERR_MSG}: ${resourcesWaitingFor}`));
})
)
: NEVER;
function cleanup(err) {
if (err) {
if (err.message.startsWith(TIMEOUT_ERR_MSG)) {
log('wait-on(%s) %s; exiting with error', process.pid, err.message);
} else {
log('wait-on(%s) exiting with error', process.pid, err);
}
} else {
// no error, we are complete
log('wait-on(%s) complete', process.pid);
}
cbOnce(err);
}
if (reverse) {
log('wait-on reverse mode - waiting for resources to be unavailable');
}
logWaitingForWDeps(resources);
const resourcesCompleted$ = combineLatest(resources.map(createResourceWithDeps$));
merge(timeoutError$, resourcesCompleted$)
.pipe(takeWhile((resourceStates) => resourceStates.some((x) => !x)))
.subscribe({
next: (resourceStates) => {
lastResourcesState = resourceStates;
logWaitingForWDeps(resourceStates);
},
error: cleanup,
complete: cleanup
});
}
function logWaitingFor({ log, resources }, resourceStates) {
const remainingResources = determineRemainingResources(resources, resourceStates);
if (isNotEmpty(remainingResources)) {
log(`waiting for ${remainingResources.length} resources: ${remainingResources.join(', ')}`);
}
}
function determineRemainingResources(resources, resourceStates) {
// resourcesState is array of completed booleans
const resourceAndStateTuples = zip(resources, resourceStates);
return resourceAndStateTuples.filter(([, /* r */ s]) => !s).map(([r /*, s */]) => r);
}
function createResource$(deps, resource) {
const prefix = extractPrefix(resource);
switch (prefix) {
case 'https-get:':
case 'http-get:':
case 'https:':
case 'http:':
return createHTTP$(deps, resource);
case 'tcp:':
return createTCP$(deps, resource);
case 'socket:':
return createSocket$(deps, resource);
default:
return createFileResource$(deps, resource);
}
}
function createFileResource$(
{ validatedOpts: { delay, interval, reverse, simultaneous, window: stabilityWindow }, output },
resource
) {
const filePath = extractPath(resource);
const checkOperator = reverse
? map((size) => size === -1) // check that file does not exist
: scan(
// check that file exists and the size is stable
(acc, x) => {
if (x > -1) {
const { size, t } = acc;
const now = Date.now();
if (size !== -1 && x === size) {
if (now >= t + stabilityWindow) {
// file size has stabilized
output(` file stabilized at size:${size} file:${filePath}`);
return true;
}
output(` file exists, checking for size change during stability window, size:${size} file:${filePath}`);
return acc; // return acc unchanged, just waiting to pass stability window
}
output(` file exists, checking for size changes, size:${x} file:${filePath}`);
return { size: x, t: now }; // update acc with new value and timestamp
}
return acc;
},
{ size: -1, t: Date.now() }
);
return timer(delay, interval).pipe(
mergeMap(() => {
output(`checking file stat for file:${filePath} ...`);
return from(getFileSize(filePath));
}, simultaneous),
checkOperator,
map((x) => (isNotABoolean(x) ? false : x)),
startWith(false),
distinctUntilChanged(),
take(2)
);
}
function extractPath(resource) {
const m = PREFIX_RE.exec(resource);
if (m) {
return m[3];
}
return resource;
}
function extractPrefix(resource) {
const m = PREFIX_RE.exec(resource);
if (m) {
return m[1];
}
return '';
}
async function getFileSize(filePath) {
try {
const { size } = await fstat(filePath);
return size;
} catch (err) {
return -1;
}
}
function createHTTP$({ validatedOpts, output }, resource) {
const {
delay,
followRedirect,
httpTimeout: timeout,
interval,
proxy,
reverse,
simultaneous,
strictSSL: rejectUnauthorized
} = validatedOpts;
const method = HTTP_GET_RE.test(resource) ? 'get' : 'head';
const url = resource.replace('-get:', ':');
const matchHttpUnixSocket = HTTP_UNIX_RE.exec(url); // http://unix:/sock:/url
const urlSocketOptions = matchHttpUnixSocket
? { socketPath: matchHttpUnixSocket[1], url: matchHttpUnixSocket[2] }
: { url };
const socketPathDesc = urlSocketOptions.socketPath ? `socketPath:${urlSocketOptions.socketPath}` : '';
const httpOptions = {
...pick(['auth', 'headers', 'validateStatus'], validatedOpts),
httpsAgent: new https.Agent({
rejectUnauthorized,
...pick(['ca', 'cert', 'key', 'passphrase'], validatedOpts)
}),
...(followRedirect ? {} : { maxRedirects: 0 }), // defaults to 5 (enabled)
proxy, // can be undefined, false, or object
...(timeout && { timeout }),
...urlSocketOptions,
method
// by default it provides full response object
// validStatus is 2xx unless followRedirect is true (default)
};
const checkFn = reverse ? negateAsync(httpCallSucceeds) : httpCallSucceeds;
return timer(delay, interval).pipe(
mergeMap(() => {
output(`making HTTP(S) ${method} request to ${socketPathDesc} url:${urlSocketOptions.url} ...`);
return from(checkFn(output, httpOptions));
}, simultaneous),
startWith(false),
distinctUntilChanged(),
take(2)
);
}
async function httpCallSucceeds(output, httpOptions) {
try {
const result = await axios(httpOptions);
output(
` HTTP(S) result for ${httpOptions.url}: ${util.inspect(
pick(['status', 'statusText', 'headers', 'data'], result)
)}`
);
return true;
} catch (err) {
output(` HTTP(S) error for ${httpOptions.url} ${err.toString()}`);
return false;
}
}
function createTCP$({ validatedOpts: { delay, interval, tcpTimeout, reverse, simultaneous }, output }, resource) {
const tcpPath = extractPath(resource);
const checkFn = reverse ? negateAsync(tcpExists) : tcpExists;
return timer(delay, interval).pipe(
mergeMap(() => {
output(`making TCP connection to ${tcpPath} ...`);
return from(checkFn(output, tcpPath, tcpTimeout));
}, simultaneous),
startWith(false),
distinctUntilChanged(),
take(2)
);
}
async function tcpExists(output, tcpPath, tcpTimeout) {
const [, , /* full, hostWithColon */ hostMatched, port] = HOST_PORT_RE.exec(tcpPath);
const host = hostMatched || 'localhost';
return new Promise((resolve) => {
const conn = net
.connect(port, host)
.on('error', (err) => {
output(` error connecting to TCP host:${host} port:${port} ${err.toString()}`);
resolve(false);
})
.on('timeout', () => {
output(` timed out connecting to TCP host:${host} port:${port} tcpTimeout:${tcpTimeout}ms`);
conn.end();
resolve(false);
})
.on('connect', () => {
output(` TCP connection successful to host:${host} port:${port}`);
conn.end();
resolve(true);
});
conn.setTimeout(tcpTimeout);
});
}
function createSocket$({ validatedOpts: { delay, interval, reverse, simultaneous }, output }, resource) {
const socketPath = extractPath(resource);
const checkFn = reverse ? negateAsync(socketExists) : socketExists;
return timer(delay, interval).pipe(
mergeMap(() => {
output(`making socket connection to ${socketPath} ...`);
return from(checkFn(output, socketPath));
}, simultaneous),
startWith(false),
distinctUntilChanged(),
take(2)
);
}
async function socketExists(output, socketPath) {
return new Promise((resolve) => {
const conn = net
.connect(socketPath)
.on('error', (err) => {
output(` error connecting to socket socket:${socketPath} ${err.toString()}`);
resolve(false);
})
.on('connect', () => {
output(` connected to socket:${socketPath}`);
conn.end();
resolve(true);
});
});
}
function negateAsync(asyncFn) {
return async function (...args) {
return !(await asyncFn(...args));
};
}
module.exports = waitOn;

67
node_modules/wait-on/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"name": "wait-on",
"description": "wait-on is a cross platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available",
"version": "7.2.0",
"main": "lib/wait-on",
"bin": {
"wait-on": "bin/wait-on"
},
"author": "Jeff Barczewski <info@codewinds.com>",
"repository": {
"type": "git",
"url": "http://github.com/jeffbski/wait-on.git"
},
"bugs": {
"url": "http://github.com/jeffbski/wait-on/issues"
},
"license": "MIT",
"scripts": {
"lint": "eslint \"lib/**/*.js\" \"test/**/*.js\" \"bin/wait-on\"",
"publish:next": "npm publish --tag next && npm view",
"test": "mocha --exit 'test/**/*.mocha.js'"
},
"engines": {
"node": ">=12.0.0"
},
"devDependencies": {
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"expect-legacy": "^1.20.2",
"mkdirp": "^1.0.4",
"mocha": "^10.2.0",
"temp": "^0.9.4"
},
"dependencies": {
"axios": "^1.6.1",
"joi": "^17.11.0",
"lodash": "^4.17.21",
"minimist": "^1.2.8",
"rxjs": "^7.8.1"
},
"keywords": [
"wait",
"delay",
"cli",
"files",
"tcp",
"ports",
"sockets",
"http",
"exist",
"ready",
"available",
"portable",
"cross-platform",
"unix",
"linux",
"windows",
"win32",
"osx"
]
}