拿掉 build files

This commit is contained in:
2022-07-18 16:33:23 +08:00
parent 41e2287bcb
commit 3707f158a3
31953 changed files with 0 additions and 4411796 deletions
-106
View File
@@ -1,106 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const fs = require('fs');
const path = require('path');
const os = require('os');
const destr = require('destr');
const flat = require('flat');
const defu = require('defu');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
const destr__default = /*#__PURE__*/_interopDefaultLegacy(destr);
const flat__default = /*#__PURE__*/_interopDefaultLegacy(flat);
const defu__default = /*#__PURE__*/_interopDefaultLegacy(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 val = destr__default(match[2].trim());
if (key.endsWith("[]")) {
const nkey = key.substr(0, key.length - 2);
config[nkey] = (config[nkey] || []).concat(val);
continue;
}
config[key] = val;
}
return options.flat ? config : flat__default.unflatten(config, { overwrite: true });
}
function parseFile(path, options) {
if (!fs.existsSync(path)) {
return {};
}
return parse(fs.readFileSync(path, "utf-8"), options);
}
function read(options) {
options = withDefaults(options);
return parseFile(path.resolve(options.dir, options.name), options);
}
function readUser(options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || os.homedir();
return read(options);
}
function serialize(config) {
return Object.entries(flat__default.flatten(config)).map(([key, val]) => `${key}=${typeof val === "string" ? val : JSON.stringify(val)}`).join("\n");
}
function write(config, options) {
options = withDefaults(options);
fs.writeFileSync(path.resolve(options.dir, options.name), serialize(config), {
encoding: "utf-8"
});
}
function writeUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || os.homedir();
write(config, options);
}
function update(config, options) {
options = withDefaults(options);
if (!options.flat) {
config = flat__default.unflatten(config, { overwrite: true });
}
const newConfig = defu__default(config, read(options));
write(newConfig, options);
return newConfig;
}
function updateUser(config, options) {
options = withDefaults(options);
options.dir = process.env.XDG_CONFIG_HOME || 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
View File
@@ -1,18 +0,0 @@
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 };
-124
View File
@@ -1,124 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var fs = require('fs');
var path = require('path');
var os = require('os');
var destr = _interopDefault(require('destr'));
var flat = require('flat');
var defu = _interopDefault(require('defu'));
var RE_KEY_VAL = /^\s*([^=\s]+)\s*=\s*(.*)?\s*$/;
var RE_LINES = /\n|\r|\r\n/;
var defaults = {
name: '.conf',
dir: process.cwd(),
flat: false
};
function withDefaults(options) {
if (typeof options === 'string') {
options = {
name: options
};
}
return Object.assign(Object.assign({}, defaults), options);
}
function parse(contents, options) {
var config = {};
var lines = contents.split(RE_LINES);
for (var i = 0, list = lines; i < list.length; i += 1) {
var line = list[i];
var match = line.match(RE_KEY_VAL);
if (!match) {
continue;
} // Key
var key = match[1];
if (!key || key === '__proto__' || key === 'constructor') {
continue;
}
config[key] = destr(match[2].trim()
/* val */
);
}
return (options === null || options === void 0 ? void 0 : options.flat) ? config : flat.unflatten(config, {
overwrite: true
});
}
function parseFile(path, options) {
if (!fs.existsSync(path)) {
return {};
}
return parse(fs.readFileSync(path, 'utf-8'), options);
}
function read(options) {
options = withDefaults(options);
return parseFile(path.resolve(options.dir, options.name), options);
}
function readUser(options) {
options = withDefaults(options);
options.dir = os.homedir();
return read(options);
}
function serialize(config) {
return Object.entries(flat.flatten(config)).map(function (ref) {
var key = ref[0];
var val = ref[1];
return (key + "=" + (typeof val === 'string' ? val : JSON.stringify(val)));
}).join('\n');
}
function write(config, options) {
options = withDefaults(options);
fs.writeFileSync(path.resolve(options.dir, options.name), serialize(config), {
encoding: 'utf-8'
});
}
function writeUser(config, options) {
options = withDefaults(options);
options.dir = os.homedir();
write(config, options);
}
function update(config, options) {
options = withDefaults(options);
if (!options.flat) {
config = flat.unflatten(config, {
overwrite: true
});
}
var newConfig = defu(config, read(options));
write(newConfig, options);
return newConfig;
}
function updateUser(config, options) {
options = withDefaults(options);
options.dir = 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;
-87
View File
@@ -1,87 +0,0 @@
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { homedir } from '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 val = destr(match[2].trim());
if (key.endsWith("[]")) {
const nkey = key.substr(0, key.length - 2);
config[nkey] = (config[nkey] || []).concat(val);
continue;
}
config[key] = val;
}
return options.flat ? config : flat.unflatten(config, { overwrite: true });
}
function parseFile(path, options) {
if (!existsSync(path)) {
return {};
}
return parse(readFileSync(path, "utf-8"), 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, val]) => `${key}=${typeof val === "string" ? val : JSON.stringify(val)}`).join("\n");
}
function write(config, options) {
options = withDefaults(options);
writeFileSync(resolve(options.dir, options.name), serialize(config), {
encoding: "utf-8"
});
}
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 };