Last commit july 5th

This commit is contained in:
2024-07-05 13:46:23 +02:00
parent dad0d86e8c
commit b0e4dfbb76
24982 changed files with 2621219 additions and 413 deletions

15
spa/node_modules/promzard/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

129
spa/node_modules/promzard/README.md generated vendored Normal file
View File

@@ -0,0 +1,129 @@
# promzard
A prompting wizard for building files from specialized PromZard modules.
Used by `npm init`.
A reimplementation of @SubStack's
[prompter](https://github.com/substack/node-prompter), which does not
use AST traversal.
From another point of view, it's a reimplementation of
[@Marak](https://github.com/marak)'s
[wizard](https://github.com/Marak/wizard) which doesn't use schemas.
The goal is a nice drop-in enhancement for `npm init`.
## Usage
```javascript
const promzard = require('promzard')
const data = await promzard(inputFile, optionalContextAdditions, options)
```
In the `inputFile` you can have something like this:
```javascript
const fs = require('fs/promises')
module.exports = {
"greeting": prompt("Who shall you greet?", "world", (who) => `Hello, ${who}`),
"filename": __filename,
"directory": async () => {
const entries = await fs.readdir(__dirname)
return entries.map(e => `entry: ${e}`)
}
}
```
When run, promzard will display the prompts and resolve the async
functions in order, and then either give you an error, or the resolved
data, ready to be dropped into a JSON file or some other place.
### promzard(inputFile, ctx, options)
The inputFile is just a node module. You can require() things, set
module.exports, etc. Whatever that module exports is the result, and it
is walked over to call any functions as described below.
The only caveat is that you must give PromZard the full absolute path
to the module (you can get this via Node's `require.resolve`.) Also,
the `prompt` function is injected into the context object, so watch out.
Whatever you put in that `ctx` will of course also be available in the
module. You can get quite fancy with this, passing in existing configs
and so on.
#### options.backupFile
Use the `backupFile` option as a fallback when `inputFile` fails to be read.
### Class: promzard.PromZard(file, ctx, options).load()
Just like the `promzard` function, but the class that makes it
all happen. The `load` method returns a promise which will resolve
to the resolved data or throw with an error.
### prompt(...)
In the promzard input module, you can call the `prompt` function.
This prompts the user to input some data. The arguments are interpreted
based on type:
1. `string` The first string encountered is the prompt. The second is
the default value.
2. `function` A transformer function which receives the data and returns
something else. More than meets the eye.
3. `object` The `prompt` member is the prompt, the `default` member is
the default value, and the `transform` is the transformer.
Whatever the final value is, that's what will be put on the resulting
object.
### Functions
If there are any functions on the promzard input module's exports, then
promzard will await each of them. This way, your module
can do asynchronous actions if necessary to validate or ascertain
whatever needs verification.
The functions are called in the context of the ctx object.
In the async function, you can also call prompt() and return the result
of the prompt.
For example, this works fine in a promzard module:
```js
exports.asyncPrompt = async function () {
const st = await fs.stat(someFile)
// if there's an error, no prompt, just error
// otherwise prompt and use the actual file size as the default
return prompt('file size', st.size)
}
```
You can also return other async functions in the async function
callback. Though that's a bit silly, it could be a handy way to reuse
functionality in some cases.
### Sync vs Async
The `prompt()` function is not synchronous, though it appears that way.
It just returns a token that is swapped out when the data object is
walked over asynchronously later, and returns a token.
For that reason, prompt() calls whose results don't end up on the data
object are never shown to the user. For example, this will only prompt
once:
```
exports.promptThreeTimes = prompt('prompt me once', 'shame on you')
exports.promptThreeTimes = prompt('prompt me twice', 'um....')
exports.promptThreeTimes = prompt('you cant prompt me again')
```
### Isn't this exactly the sort of 'looks sync' that you said was bad about other libraries?
Yeah, sorta. I wouldn't use promzard for anything more complicated than
a wizard that spits out prompts to set up a config file or something.
Maybe there are other use cases I haven't considered.

176
spa/node_modules/promzard/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
const fs = require('fs/promises')
const { runInThisContext } = require('vm')
const { promisify } = require('util')
const { randomBytes } = require('crypto')
const { Module } = require('module')
const { dirname, basename } = require('path')
const { read } = require('read')
const files = {}
class PromZard {
#file = null
#backupFile = null
#ctx = null
#unique = randomBytes(8).toString('hex')
#prompts = []
constructor (file, ctx = {}, options = {}) {
this.#file = file
this.#ctx = ctx
this.#backupFile = options.backupFile
}
static async promzard (file, ctx, options) {
const pz = new PromZard(file, ctx, options)
return pz.load()
}
static async fromBuffer (buf, ctx, options) {
let filename = 0
do {
filename = '\0' + Math.random()
} while (files[filename])
files[filename] = buf
const ret = await PromZard.promzard(filename, ctx, options)
delete files[filename]
return ret
}
async load () {
if (files[this.#file]) {
return this.#loaded()
}
try {
files[this.#file] = await fs.readFile(this.#file, 'utf8')
} catch (er) {
if (er && this.#backupFile) {
this.#file = this.#backupFile
this.#backupFile = null
return this.load()
}
throw er
}
return this.#loaded()
}
async #loaded () {
const mod = new Module(this.#file, module)
mod.loaded = true
mod.filename = this.#file
mod.id = this.#file
mod.paths = Module._nodeModulePaths(dirname(this.#file))
this.#ctx.prompt = this.#makePrompt()
this.#ctx.__filename = this.#file
this.#ctx.__dirname = dirname(this.#file)
this.#ctx.__basename = basename(this.#file)
this.#ctx.module = mod
this.#ctx.require = (p) => mod.require(p)
this.#ctx.require.resolve = (p) => Module._resolveFilename(p, mod)
this.#ctx.exports = mod.exports
const body = `(function(${Object.keys(this.#ctx).join(', ')}) { ${files[this.#file]}\n })`
runInThisContext(body, this.#file).apply(this.#ctx, Object.values(this.#ctx))
this.#ctx.res = mod.exports
return this.#walk()
}
#makePrompt () {
return (...args) => {
let p, d, t
for (let i = 0; i < args.length; i++) {
const a = args[i]
if (typeof a === 'string') {
if (p) {
d = a
} else {
p = a
}
} else if (typeof a === 'function') {
t = a
} else if (a && typeof a === 'object') {
p = a.prompt || p
d = a.default || d
t = a.transform || t
}
}
try {
return `${this.#unique}-${this.#prompts.length}`
} finally {
this.#prompts.push([p, d, t])
}
}
}
async #walk (o = this.#ctx.res) {
const keys = Object.keys(o)
const len = keys.length
let i = 0
while (i < len) {
const k = keys[i]
const v = o[k]
i++
if (v && typeof v === 'object') {
o[k] = await this.#walk(v)
continue
}
if (v && typeof v === 'string' && v.startsWith(this.#unique)) {
const n = +v.slice(this.#unique.length + 1)
// default to the key
// default to the ctx value, if there is one
const [prompt = k, def = this.#ctx[k], tx] = this.#prompts[n]
try {
o[k] = await this.#prompt(prompt, def, tx)
} catch (er) {
if (er.notValid) {
// eslint-disable-next-line no-console
console.log(er.message)
i--
} else {
throw er
}
}
continue
}
if (typeof v === 'function') {
// XXX: remove v.length check to remove cb from functions
// would be a breaking change for `npm init`
// XXX: if cb is no longer an argument then this.#ctx should
// be passed in to allow arrow fns to be used and still access ctx
const fn = v.length ? promisify(v) : v
o[k] = await fn.call(this.#ctx)
// back up so that we process this one again.
// this is because it might return a prompt() call in the cb.
i--
continue
}
}
return o
}
async #prompt (prompt, def, tx) {
const res = await read({ prompt: prompt + ':', default: def }).then((r) => tx ? tx(r) : r)
// XXX: remove this to require throwing an error instead of
// returning it. would be a breaking change for `npm init`
if (res instanceof Error && res.notValid) {
throw res
}
return res
}
}
module.exports = PromZard.promzard
module.exports.fromBuffer = PromZard.fromBuffer
module.exports.PromZard = PromZard

View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -0,0 +1,68 @@
# mute-stream
Bytes go in, but they don't come out (when muted).
This is a basic pass-through stream, but when muted, the bytes are
silently dropped, rather than being passed through.
## Usage
```javascript
const MuteStream = require('mute-stream')
const ms = new MuteStream(options)
ms.pipe(process.stdout)
ms.write('foo') // writes 'foo' to stdout
ms.mute()
ms.write('bar') // does not write 'bar'
ms.unmute()
ms.write('baz') // writes 'baz' to stdout
// can also be used to mute incoming data
const ms = new MuteStream
input.pipe(ms)
ms.on('data', function (c) {
console.log('data: ' + c)
})
input.emit('data', 'foo') // logs 'foo'
ms.mute()
input.emit('data', 'bar') // does not log 'bar'
ms.unmute()
input.emit('data', 'baz') // logs 'baz'
```
## Options
All options are optional.
* `replace` Set to a string to replace each character with the
specified string when muted. (So you can show `****` instead of the
password, for example.)
* `prompt` If you are using a replacement char, and also using a
prompt with a readline stream (as for a `Password: *****` input),
then specify what the prompt is so that backspace will work
properly. Otherwise, pressing backspace will overwrite the prompt
with the replacement character, which is weird.
## ms.mute()
Set `muted` to `true`. Turns `.write()` into a no-op.
## ms.unmute()
Set `muted` to `false`
## ms.isTTY
True if the pipe destination is a TTY, or if the incoming pipe source is
a TTY.
## Other stream methods...
The other standard readable and writable stream methods are all
available. The MuteStream object acts as a facade to its pipe source
and destination.

View File

@@ -0,0 +1,142 @@
const Stream = require('stream')
class MuteStream extends Stream {
#isTTY = null
constructor (opts = {}) {
super(opts)
this.writable = this.readable = true
this.muted = false
this.on('pipe', this._onpipe)
this.replace = opts.replace
// For readline-type situations
// This much at the start of a line being redrawn after a ctrl char
// is seen (such as backspace) won't be redrawn as the replacement
this._prompt = opts.prompt || null
this._hadControl = false
}
#destSrc (key, def) {
if (this._dest) {
return this._dest[key]
}
if (this._src) {
return this._src[key]
}
return def
}
#proxy (method, ...args) {
if (typeof this._dest?.[method] === 'function') {
this._dest[method](...args)
}
if (typeof this._src?.[method] === 'function') {
this._src[method](...args)
}
}
get isTTY () {
if (this.#isTTY !== null) {
return this.#isTTY
}
return this.#destSrc('isTTY', false)
}
// basically just get replace the getter/setter with a regular value
set isTTY (val) {
this.#isTTY = val
}
get rows () {
return this.#destSrc('rows')
}
get columns () {
return this.#destSrc('columns')
}
mute () {
this.muted = true
}
unmute () {
this.muted = false
}
_onpipe (src) {
this._src = src
}
pipe (dest, options) {
this._dest = dest
return super.pipe(dest, options)
}
pause () {
if (this._src) {
return this._src.pause()
}
}
resume () {
if (this._src) {
return this._src.resume()
}
}
write (c) {
if (this.muted) {
if (!this.replace) {
return true
}
// eslint-disable-next-line no-control-regex
if (c.match(/^\u001b/)) {
if (c.indexOf(this._prompt) === 0) {
c = c.slice(this._prompt.length)
c = c.replace(/./g, this.replace)
c = this._prompt + c
}
this._hadControl = true
return this.emit('data', c)
} else {
if (this._prompt && this._hadControl &&
c.indexOf(this._prompt) === 0) {
this._hadControl = false
this.emit('data', this._prompt)
c = c.slice(this._prompt.length)
}
c = c.toString().replace(/./g, this.replace)
}
}
this.emit('data', c)
}
end (c) {
if (this.muted) {
if (c && this.replace) {
c = c.toString().replace(/./g, this.replace)
} else {
c = null
}
}
if (c) {
this.emit('data', c)
}
this.emit('end')
}
destroy (...args) {
return this.#proxy('destroy', ...args)
}
destroySoon (...args) {
return this.#proxy('destroySoon', ...args)
}
close (...args) {
return this.#proxy('close', ...args)
}
}
module.exports = MuteStream

View File

@@ -0,0 +1,52 @@
{
"name": "mute-stream",
"version": "1.0.0",
"main": "lib/index.js",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.11.0",
"tap": "^16.3.0"
},
"scripts": {
"test": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "tap",
"posttest": "npm run lint"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/mute-stream.git"
},
"keywords": [
"mute",
"stream",
"pipe"
],
"author": "GitHub Inc.",
"license": "ISC",
"description": "Bytes go in, but they don't come out (when muted).",
"files": [
"bin/",
"lib/"
],
"tap": {
"statements": 70,
"branches": 60,
"functions": 81,
"lines": 70,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.11.0"
}
}

15
spa/node_modules/promzard/node_modules/read/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

40
spa/node_modules/promzard/node_modules/read/README.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
## read
For reading user input from stdin.
Similar to the `readline` builtin's `question()` method, but with a
few more features.
## Usage
```javascript
const { read } = require('read')
// or with ESM: import { read } from 'read'
try {
const result = await read(options)
} catch (er) {
console.error(er)
}
```
## Options
Every option is optional.
* `prompt` What to write to stdout before reading input.
* `silent` Don't echo the output as the user types it.
* `replace` Replace silenced characters with the supplied character value.
* `timeout` Number of ms to wait for user input before giving up.
* `default` The default value if the user enters nothing.
* `edit` Allow the user to edit the default value.
* `terminal` Treat the output as a TTY, whether it is or not.
* `input` Readable stream to get input data from. (default `process.stdin`)
* `output` Writable stream to write prompts to. (default: `process.stdout`)
* `completer` Autocomplete callback (see [official api](https://nodejs.org/api/readline.html#readline_readline_createinterface_options) for details
If silent is true, and the input is a TTY, then read will set raw
mode, and read character by character.
## Contributing
Patches welcome.

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@@ -0,0 +1,20 @@
/// <reference types="node" />
import { Completer, AsyncCompleter, ReadLineOptions } from 'readline';
export interface Options<T extends string | number = string> {
default?: T;
input?: ReadLineOptions['input'] & {
isTTY?: boolean;
};
output?: ReadLineOptions['output'] & {
isTTY?: boolean;
};
prompt?: string;
silent?: boolean;
timeout?: number;
edit?: boolean;
terminal?: boolean;
replace?: string;
completer?: Completer | AsyncCompleter;
}
export declare function read<T extends string | number = string>({ default: def, input, output, completer, prompt, silent, timeout, edit, terminal, replace, }: Options<T>): Promise<T | string>;
//# sourceMappingURL=read.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/read.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAmB,eAAe,EAAE,MAAM,UAAU,CAAA;AAEtF,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IACvD,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG;QACjC,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;QACnC,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;CACxC;AAEH,wBAAsB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAG,EAC9D,OAAO,EAAE,GAAG,EACZ,KAAqB,EACrB,MAAuB,EACvB,SAAS,EACT,MAAW,EACX,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,OAAO,GACR,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAiGlC"}

View File

@@ -0,0 +1,95 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.read = void 0;
const mute_stream_1 = __importDefault(require("mute-stream"));
const readline_1 = require("readline");
async function read({ default: def, input = process.stdin, output = process.stdout, completer, prompt = '', silent, timeout, edit, terminal, replace, }) {
if (typeof def !== 'undefined' &&
typeof def !== 'string' &&
typeof def !== 'number') {
throw new Error('default value must be string or number');
}
let editDef = false;
const defString = def?.toString();
prompt = prompt.trim() + ' ';
terminal = !!(terminal || output.isTTY);
if (defString) {
if (silent) {
prompt += '(<default hidden>) ';
// TODO: add tests for edit
/* c8 ignore start */
}
else if (edit) {
editDef = true;
/* c8 ignore stop */
}
else {
prompt += '(' + defString + ') ';
}
}
const m = new mute_stream_1.default({ replace, prompt });
m.pipe(output, { end: false });
output = m;
return new Promise((resolve, reject) => {
const rl = (0, readline_1.createInterface)({ input, output, terminal, completer });
// TODO: add tests for timeout
/* c8 ignore start */
const timer = timeout && setTimeout(() => onError(new Error('timed out')), timeout);
/* c8 ignore stop */
m.unmute();
rl.setPrompt(prompt);
rl.prompt();
if (silent) {
m.mute();
// TODO: add tests for edit + default
/* c8 ignore start */
}
else if (editDef && defString) {
const rlEdit = rl;
rlEdit.line = defString;
rlEdit.cursor = defString.length;
rlEdit._refreshLine();
}
/* c8 ignore stop */
const done = () => {
rl.close();
clearTimeout(timer);
m.mute();
m.end();
};
// TODO: add tests for rejecting
/* c8 ignore start */
const onError = (er) => {
done();
reject(er);
};
/* c8 ignore stop */
rl.on('error', onError);
rl.on('line', line => {
// TODO: add tests for silent
/* c8 ignore start */
if (silent && terminal) {
m.unmute();
}
/* c8 ignore stop */
done();
// TODO: add tests for default
/* c8 ignore start */
// truncate the \n at the end.
return resolve(line.replace(/\r?\n?$/, '') || defString || '');
/* c8 ignore stop */
});
// TODO: add tests for sigint
/* c8 ignore start */
rl.on('SIGINT', () => {
rl.close();
onError(new Error('canceled'));
});
/* c8 ignore stop */
});
}
exports.read = read;
//# sourceMappingURL=read.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@@ -0,0 +1,20 @@
/// <reference types="node" resolution-mode="require"/>
import { Completer, AsyncCompleter, ReadLineOptions } from 'readline';
export interface Options<T extends string | number = string> {
default?: T;
input?: ReadLineOptions['input'] & {
isTTY?: boolean;
};
output?: ReadLineOptions['output'] & {
isTTY?: boolean;
};
prompt?: string;
silent?: boolean;
timeout?: number;
edit?: boolean;
terminal?: boolean;
replace?: string;
completer?: Completer | AsyncCompleter;
}
export declare function read<T extends string | number = string>({ default: def, input, output, completer, prompt, silent, timeout, edit, terminal, replace, }: Options<T>): Promise<T | string>;
//# sourceMappingURL=read.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/read.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAmB,eAAe,EAAE,MAAM,UAAU,CAAA;AAEtF,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IACvD,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG;QACjC,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;QACnC,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;CACxC;AAEH,wBAAsB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAG,EAC9D,OAAO,EAAE,GAAG,EACZ,KAAqB,EACrB,MAAuB,EACvB,SAAS,EACT,MAAW,EACX,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,OAAO,GACR,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAiGlC"}

View File

@@ -0,0 +1,88 @@
import Mute from 'mute-stream';
import { createInterface } from 'readline';
export async function read({ default: def, input = process.stdin, output = process.stdout, completer, prompt = '', silent, timeout, edit, terminal, replace, }) {
if (typeof def !== 'undefined' &&
typeof def !== 'string' &&
typeof def !== 'number') {
throw new Error('default value must be string or number');
}
let editDef = false;
const defString = def?.toString();
prompt = prompt.trim() + ' ';
terminal = !!(terminal || output.isTTY);
if (defString) {
if (silent) {
prompt += '(<default hidden>) ';
// TODO: add tests for edit
/* c8 ignore start */
}
else if (edit) {
editDef = true;
/* c8 ignore stop */
}
else {
prompt += '(' + defString + ') ';
}
}
const m = new Mute({ replace, prompt });
m.pipe(output, { end: false });
output = m;
return new Promise((resolve, reject) => {
const rl = createInterface({ input, output, terminal, completer });
// TODO: add tests for timeout
/* c8 ignore start */
const timer = timeout && setTimeout(() => onError(new Error('timed out')), timeout);
/* c8 ignore stop */
m.unmute();
rl.setPrompt(prompt);
rl.prompt();
if (silent) {
m.mute();
// TODO: add tests for edit + default
/* c8 ignore start */
}
else if (editDef && defString) {
const rlEdit = rl;
rlEdit.line = defString;
rlEdit.cursor = defString.length;
rlEdit._refreshLine();
}
/* c8 ignore stop */
const done = () => {
rl.close();
clearTimeout(timer);
m.mute();
m.end();
};
// TODO: add tests for rejecting
/* c8 ignore start */
const onError = (er) => {
done();
reject(er);
};
/* c8 ignore stop */
rl.on('error', onError);
rl.on('line', line => {
// TODO: add tests for silent
/* c8 ignore start */
if (silent && terminal) {
m.unmute();
}
/* c8 ignore stop */
done();
// TODO: add tests for default
/* c8 ignore start */
// truncate the \n at the end.
return resolve(line.replace(/\r?\n?$/, '') || defString || '');
/* c8 ignore stop */
});
// TODO: add tests for sigint
/* c8 ignore start */
rl.on('SIGINT', () => {
rl.close();
onError(new Error('canceled'));
});
/* c8 ignore stop */
});
}
//# sourceMappingURL=read.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,87 @@
{
"name": "read",
"version": "3.0.1",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/read.d.ts",
"default": "./dist/esm/read.js"
},
"require": {
"types": "./dist/commonjs/read.d.ts",
"default": "./dist/commonjs/read.js"
}
}
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/read.ts"
}
},
"dependencies": {
"mute-stream": "^1.0.0"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.2",
"@npmcli/template-oss": "4.20.0",
"@types/mute-stream": "^0.0.4",
"@types/tap": "^15.0.11",
"@typescript-eslint/parser": "^6.11.0",
"c8": "^8.0.1",
"eslint-import-resolver-typescript": "^3.6.1",
"tap": "^16.3.9",
"ts-node": "^10.9.1",
"tshy": "^1.8.0",
"typescript": "^5.2.2"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"author": "GitHub Inc.",
"description": "read(1) for node programs",
"repository": {
"type": "git",
"url": "https://github.com/npm/read.git"
},
"license": "ISC",
"scripts": {
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "c8 tap",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "c8 tap",
"posttest": "npm run lint"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.20.0",
"publish": true,
"typescript": true,
"content": "./scripts/template-oss"
},
"main": "./dist/commonjs/read.js",
"types": "./dist/commonjs/read.d.ts",
"tap": {
"coverage": false,
"node-arg": [
"--no-warnings",
"--loader",
"ts-node/esm"
],
"ts": false,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"files": [
"dist/"
]
}

49
spa/node_modules/promzard/package.json generated vendored Normal file
View File

@@ -0,0 +1,49 @@
{
"author": "GitHub Inc.",
"name": "promzard",
"description": "prompting wizardly",
"version": "1.0.2",
"repository": {
"url": "git+https://github.com/npm/promzard.git",
"type": "git"
},
"dependencies": {
"read": "^3.0.1"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.22.0",
"tap": "^16.3.0"
},
"main": "lib/index.js",
"scripts": {
"test": "tap",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "tap",
"posttest": "npm run lint"
},
"license": "ISC",
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.22.0",
"publish": true
},
"tap": {
"jobs": 1,
"test-ignore": "fixtures/",
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
}
}