initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

72
node_modules/rc9/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,72 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.0.0](https://github.com/unjs/rc9/compare/v1.2.3...v2.0.0) (2022-11-15)
### [1.2.3](https://github.com/unjs/rc9/compare/v1.2.2...v1.2.3) (2022-11-15)
### [1.2.2](https://github.com/unjs/rc9/compare/v1.2.1...v1.2.2) (2022-04-07)
### Bug Fixes
* avoid optional chaining for node 12.x compatibility ([a4349ab](https://github.com/unjs/rc9/commit/a4349ab85606e71b65e6a4df70dc889d26223efd))
### [1.2.1](https://github.com/unjs/rc9/compare/v1.2.0...v1.2.1) (2022-04-07)
### Bug Fixes
* use `XDG_CONFIG_HOME` for `writeUser` and `updateUser` ([5c1f7a9](https://github.com/unjs/rc9/commit/5c1f7a9873302b9ae04bf2eb979a315caaa4ce96))
## [1.2.0](https://github.com/unjs/rc9/compare/v1.1.0...v1.2.0) (2020-11-25)
### Features
* support `XDG_CONFIG_HOME` (closes [#1](https://github.com/unjs/rc9/issues/1)) ([2792d9b](https://github.com/unjs/rc9/commit/2792d9b93d16771425a56a0166e3d2a3cac3fa34))
## [1.1.0](https://github.com/unjs/rc9/compare/v1.0.0...v1.1.0) (2020-11-09)
### Features
* support array push syntax ([6d1ff0d](https://github.com/unjs/rc9/commit/6d1ff0dff0dfb4fa94b3687f91a8b629c020ed54))
## [1.0.0](https://github.com/unjs/rc9/compare/v0.0.7...v1.0.0) (2020-06-16)
### [0.0.7](https://github.com/unjs/rc9/compare/v0.0.6...v0.0.7) (2020-05-28)
### Bug Fixes
* set `sideEffects` field in package.json to allow tree-shaking ([c8fc9cc](https://github.com/unjs/rc9/commit/c8fc9ccc8eeffe70f5cf6d8ae832989c9ce3bdb4))
### [0.0.6](https://github.com/unjs/rc9/compare/v0.0.5...v0.0.6) (2020-05-28)
### [0.0.5](https://github.com/unjs/rc9/compare/v0.0.4...v0.0.5) (2020-05-28)
### [0.0.4](https://github.com/unjs/rc9/compare/v0.0.3...v0.0.4) (2020-05-28)
### [0.0.3](https://github.com/unjs/rc9/compare/v0.0.2...v0.0.3) (2020-05-28)
### Features
* update() and improvements ([69539be](https://github.com/unjs/rc9/commit/69539bed862cf5659971329d2007e78d97bcd2a4))
### [0.0.2](https://github.com/unjs/rc9/compare/v0.0.1...v0.0.2) (2020-05-27)
### Features
* support directly passing name as options ([e493cdf](https://github.com/unjs/rc9/commit/e493cdf8fda7bda4eb2b95148485d8a008feff4c))
### Bug Fixes
* allow more characters for key ([9557009](https://github.com/unjs/rc9/commit/955700996ff0b9f3c34135adb42146d718df83a7))
* pass encoding to writeFileSync ([59c937a](https://github.com/unjs/rc9/commit/59c937a9a434e28d9e083db66b552383b61a975f))
### 0.0.1 (2020-05-27)

21
node_modules/rc9/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Pooya Parsa <pooya@pi0.io>
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.

155
node_modules/rc9/README.md generated vendored Normal file
View File

@@ -0,0 +1,155 @@
# RC9
> Read/Write config couldn't be easier!
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]
## Install
Install using npm or yarn:
```bash
npm i rc9
# or
yarn add rc9
```
Import into your Node.js project:
```js
// CommonJS
const { read, write, update } = require('rc9')
// ESM
import { read, write, update } from 'rc9'
```
## Usage
`.conf`:
```ts
db.username=db username
db.password=db pass
db.enabled=true
```
**Update config:**
```ts
update({ 'db.enabled': true }) // or update(..., { name: '.conf' })
```
Push to an array:
```ts
update({ 'modules[]': 'test' })
```
**Read/Write config:**
```ts
const config = read() // or read('.conf')
// config = {
// db: {
// username: 'db username',
// password: 'db pass',
// enabled: true
// }
// }
config.enabled = false
write(config) // or write(config, '.conf')
```
**User Config:**
It is common to keep config in user home directory (MacOS: `/Users/{name}`, Linux: `/home/{name}`, Windows: `C:\users\{name}`)
you can use `readUser`/`writeuser`/`updateUser` shortcuts to quickly do this:
```js
writeUser({ token: 123 }, '.zoorc') // Will be saved in {home}/.zoorc
const conf = readUser('.zoorc') // { token: 123 }
```
## Unflatten
RC uses [flat](https://www.npmjs.com/package/flat) to automatically flat/unflat when writing and reading rcfile.
It means that you can use `.` for keys to define objects. Some examples:
- `hello.world = true` <=> `{ hello: { world: true }`
- `test.0 = A` <=> `tags: [ 'A' ]`
**Note:** If you use keys that can override like `x=` and `x.y=`, you can disable this feature by passing `flat: true` option.
**Tip:** You can use keys ending with `[]` to push to an array like `test[]=A`
## Native Values
RC uses [destr](https://www.npmjs.com/package/destr) to convert values into native javascript values.
So reading `count=123` results `{ count: 123 }` (instead of `{ count: "123" }`) if you want to preserve strings as is, can use `count="123"`.
## Exports
```ts
const defaults: RCOptions;
function parse(contents: string, options?: RCOptions): RC
function parseFile(path: string, options?: RCOptions): RC
function read(options?: RCOptions | string): RC;
function readUser(options?: RCOptions | string): RC;
function serialize(config: RC): string;
function write(config: RC, options?: RCOptions | string): void;
function writeUser(config: RC, options?: RCOptions | string): void;
function update(config: RC, options?: RCOptions | string): RC;
function updateUser(config: RC, options?: RCOptions | string): RC;
```
**Types:**
```ts
type RC = Record<string, any>;
interface RCOptions {
name?: string;
dir?: string;
flat?: boolean;
}
```
**Defaults:**
```ts
{
name: '.conf',
dir: process.cwd(),
flat: false
}
```
### Why RC9?
Be the first one to guess 🐇 <!-- Hint: do research about rc files history -->
## License
MIT. Made with 💖
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/rc9?style=flat-square
[npm-version-href]: https://npmjs.com/package/rc9
[npm-downloads-src]: https://img.shields.io/npm/dm/rc9?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/rc9
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/rc9/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/rc9/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/rc9/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/rc9

98
node_modules/rc9/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,98 @@
'use strict';
const node_fs = require('node:fs');
const node_path = require('node:path');
const node_os = require('node:os');
const destr = require('destr');
const flat = require('flat');
const defu = require('defu');
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
const RE_LINES = /\n|\r|\r\n/;
const defaults = {
name: ".conf",
dir: process.cwd(),
flat: false
};
function withDefaults(options) {
if (typeof options === "string") {
options = { name: options };
}
return { ...defaults, ...options };
}
function parse(contents, options = {}) {
const config = {};
const lines = contents.split(RE_LINES);
for (const line of lines) {
const match = line.match(RE_KEY_VAL);
if (!match) {
continue;
}
const key = match[1];
if (!key || key === "__proto__" || key === "constructor") {
continue;
}
const value = destr(match[2].trim());
if (key.endsWith("[]")) {
const nkey = key.slice(0, Math.max(0, key.length - 2));
config[nkey] = (config[nkey] || []).concat(value);
continue;
}
config[key] = value;
}
return options.flat ? config : flat.unflatten(config, { overwrite: true });
}
function parseFile(path, options) {
if (!node_fs.existsSync(path)) {
return {};
}
return parse(node_fs.readFileSync(path, "utf8"), options);
}
function read(options) {
options = withDefaults(options);
return parseFile(node_path.resolve(options.dir, options.name), options);
}
function readUser(options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || node_os.homedir();
return read(options);
}
function serialize(config) {
return Object.entries(flat.flatten(config)).map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`).join("\n");
}
function write(config, options) {
options = withDefaults(options);
node_fs.writeFileSync(node_path.resolve(options.dir, options.name), serialize(config), {
encoding: "utf8"
});
}
function writeUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || node_os.homedir();
write(config, options);
}
function update(config, options) {
options = withDefaults(options);
if (!options.flat) {
config = flat.unflatten(config, { overwrite: true });
}
const newConfig = defu(config, read(options));
write(newConfig, options);
return newConfig;
}
function updateUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || node_os.homedir();
return update(config, options);
}
exports.defaults = defaults;
exports.parse = parse;
exports.parseFile = parseFile;
exports.read = read;
exports.readUser = readUser;
exports.serialize = serialize;
exports.update = update;
exports.updateUser = updateUser;
exports.write = write;
exports.writeUser = writeUser;

18
node_modules/rc9/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
declare type RC = Record<string, any>;
interface RCOptions {
name?: string;
dir?: string;
flat?: boolean;
}
declare const defaults: RCOptions;
declare function parse(contents: string, options?: RCOptions): RC;
declare function parseFile(path: string, options?: RCOptions): RC;
declare function read(options?: RCOptions | string): RC;
declare function readUser(options?: RCOptions | string): RC;
declare function serialize(config: RC): string;
declare function write(config: RC, options?: RCOptions | string): void;
declare function writeUser(config: RC, options?: RCOptions | string): void;
declare function update(config: RC, options?: RCOptions | string): RC;
declare function updateUser(config: RC, options?: RCOptions | string): RC;
export { defaults, parse, parseFile, read, readUser, serialize, update, updateUser, write, writeUser };

87
node_modules/rc9/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,87 @@
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { homedir } from 'node:os';
import destr from 'destr';
import flat from 'flat';
import defu from 'defu';
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
const RE_LINES = /\n|\r|\r\n/;
const defaults = {
name: ".conf",
dir: process.cwd(),
flat: false
};
function withDefaults(options) {
if (typeof options === "string") {
options = { name: options };
}
return { ...defaults, ...options };
}
function parse(contents, options = {}) {
const config = {};
const lines = contents.split(RE_LINES);
for (const line of lines) {
const match = line.match(RE_KEY_VAL);
if (!match) {
continue;
}
const key = match[1];
if (!key || key === "__proto__" || key === "constructor") {
continue;
}
const value = destr(match[2].trim());
if (key.endsWith("[]")) {
const nkey = key.slice(0, Math.max(0, key.length - 2));
config[nkey] = (config[nkey] || []).concat(value);
continue;
}
config[key] = value;
}
return options.flat ? config : flat.unflatten(config, { overwrite: true });
}
function parseFile(path, options) {
if (!existsSync(path)) {
return {};
}
return parse(readFileSync(path, "utf8"), options);
}
function read(options) {
options = withDefaults(options);
return parseFile(resolve(options.dir, options.name), options);
}
function readUser(options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || homedir();
return read(options);
}
function serialize(config) {
return Object.entries(flat.flatten(config)).map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`).join("\n");
}
function write(config, options) {
options = withDefaults(options);
writeFileSync(resolve(options.dir, options.name), serialize(config), {
encoding: "utf8"
});
}
function writeUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || homedir();
write(config, options);
}
function update(config, options) {
options = withDefaults(options);
if (!options.flat) {
config = flat.unflatten(config, { overwrite: true });
}
const newConfig = defu(config, read(options));
write(newConfig, options);
return newConfig;
}
function updateUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || homedir();
return update(config, options);
}
export { defaults, parse, parseFile, read, readUser, serialize, update, updateUser, write, writeUser };

43
node_modules/rc9/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "rc9",
"version": "2.0.0",
"description": "Read/Write config couldn't be easier!",
"repository": "unjs/rc9",
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "vitest",
"lint": "eslint --ext .ts .",
"release": "pnpm test && pnpm build && standard-version && git push --follow-tags && pnpm publish",
"test": "pnpm lint && vitest run --coverage"
},
"dependencies": {
"defu": "^6.1.1",
"destr": "^1.2.1",
"flat": "^5.0.2"
},
"devDependencies": {
"@types/flat": "^5.0.2",
"@types/node": "^18.11.9",
"@vitest/coverage-c8": "^0.25.2",
"eslint": "^8.27.0",
"eslint-config-unjs": "^0.0.2",
"standard-version": "^9.5.0",
"typescript": "^4.8.4",
"unbuild": "^0.9.4",
"vitest": "^0.25.2"
},
"packageManager": "pnpm@7.16.0"
}