esm port:fs
This commit is contained in:
parent
3081cff065
commit
bc4dce8a4b
6
packages/commons/dist/_glob.js
vendored
6
packages/commons/dist/_glob.js
vendored
@ -7,7 +7,7 @@ import { sync as exists } from '@polymech/fs/exists';
|
||||
export const files = (cwd, glob, options) => globSync(glob, { ...{ dot: true, cwd, absolute: true, caseSensitiveMatch: false }, ...options || {} });
|
||||
export const filesEx = (cwd, glob, options) => globSync(glob, { ...{ dot: true, cwd, absolute: true, caseSensitiveMatch: false }, ...options || {} });
|
||||
import { substitute } from '@/variables.js';
|
||||
import { isFile, isFolder, getExtensions } from '@/fs.js';
|
||||
import { isFile, isFolder } from '@/fs.js';
|
||||
const globBase = require('glob-base');
|
||||
export const forward_slash = (path) => {
|
||||
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
||||
@ -42,7 +42,7 @@ export const pathInfoEx = (src, altToken = false, globOptions = {}) => {
|
||||
variables.DIR = path.resolve(glob_base.base);
|
||||
variables.FILE_NAME = glob_base.glob;
|
||||
variables.GLOB = glob_base.glob;
|
||||
variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob);
|
||||
//variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
globOptions = {
|
||||
...globOptions,
|
||||
cwd: globOptions.cwd ? path.join(globOptions.cwd, glob_base.base) : null
|
||||
@ -78,7 +78,7 @@ export const pathInfo = (src, altToken = false, cwd = null) => {
|
||||
variables.DIR = path.resolve(glob_base.base);
|
||||
variables.FILE_NAME = glob_base.glob;
|
||||
variables.GLOB = glob_base.glob;
|
||||
variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob);
|
||||
//variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
variables.FILES = globSync(glob_base.glob, {
|
||||
dot: true,
|
||||
cwd: path.resolve(cwd || variables.DIR),
|
||||
|
||||
2
packages/commons/dist/_glob.js.map
vendored
2
packages/commons/dist/_glob.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"_glob.js","sourceRoot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S,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAA;KAC1B;IACD,OAAO,SAAS,CAAA;AACpB,CAAC,CAAA"}
|
||||
5
packages/commons/dist/config.js
vendored
5
packages/commons/dist/config.js
vendored
@ -1,11 +1,12 @@
|
||||
import * as env from 'env-var';
|
||||
import pkg from 'env-var';
|
||||
const { get } = pkg;
|
||||
import { sync as read } from '@polymech/fs/read';
|
||||
import { sync as exists } from '@polymech/fs/exists';
|
||||
import * as path from 'path';
|
||||
export const API_PREFIX = 'osr';
|
||||
export const API_PREFIX_NEXT = 'polymech';
|
||||
export const HOME = (sub = '') => path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], sub);
|
||||
export const get_var = (key = '') => env.get(key).asString() || env.get(key.replace(/-/g, '_')).asString() || env.get(key.replace(/_/g, '-')).asString();
|
||||
export const get_var = (key = '') => get(key).asString() || get(key.replace(/-/g, '_')).asString() || get(key.replace(/_/g, '-')).asString();
|
||||
export const OSR_ROOT = (key = 'OSR-ROOT') => get_var(key) || path.join(HOME('desktop'), API_PREFIX);
|
||||
export const OSR_SUB_DEFAULT = (key = '') => get_var(key) || path.join(OSR_ROOT(), key);
|
||||
export const CONFIG_DEFAULT_PATH = (key = 'OSR-CONFIG') => get_var(key) || path.join(HOME(`${API_PREFIX}`), '.config.json');
|
||||
|
||||
2
packages/commons/dist/config.js.map
vendored
2
packages/commons/dist/config.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAA;AAC/B,MAA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AC,CAAC;KAC9B;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAA"}
|
||||
1
packages/commons/dist/fs.d.ts
vendored
1
packages/commons/dist/fs.d.ts
vendored
@ -1,7 +1,6 @@
|
||||
export declare const GLOB_GROUP_PATTERN: RegExp;
|
||||
export declare const UNC_REGEX: RegExp;
|
||||
export declare const WIN32_PATH_REGEX: RegExp;
|
||||
export declare const getExtensions: (glob: string) => any[];
|
||||
export declare const isFile: (src: string) => boolean;
|
||||
export declare const isFolder: (src: string) => boolean;
|
||||
export declare const is_absolute: (fp: any) => boolean;
|
||||
|
||||
16
packages/commons/dist/fs.js
vendored
16
packages/commons/dist/fs.js
vendored
@ -5,16 +5,18 @@ export const GLOB_GROUP_PATTERN = /[!*+?@]\(.*\)/;
|
||||
export const UNC_REGEX = /^[\\\/]{2,}[^\\\/]+[\\\/]+[^\\\/]+/;
|
||||
export const WIN32_PATH_REGEX = /^([a-z]:)?[\\\/]/i;
|
||||
import { is_windows } from './os.js';
|
||||
const parseGlob = require('parse-glob');
|
||||
export const getExtensions = (glob) => {
|
||||
/*
|
||||
const parseGlob = require('parse-glob')
|
||||
|
||||
export const getExtensions = (glob: string) => {
|
||||
const match = glob.match(GLOB_GROUP_PATTERN);
|
||||
if (match) {
|
||||
return glob.substring((match.index || 0) + 2, glob.lastIndexOf(')')).split('|');
|
||||
return glob.substring((match.index || 0) + 2, glob.lastIndexOf(')')).split('|')
|
||||
} else {
|
||||
return [parseGlob(glob).path.ext]
|
||||
}
|
||||
else {
|
||||
return [parseGlob(glob).path.ext];
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
export const isFile = (src) => {
|
||||
let srcIsFile = false;
|
||||
try {
|
||||
|
||||
2
packages/commons/dist/fs.js.map
vendored
2
packages/commons/dist/fs.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI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OAAO,IAAI,CAAC;KACf;IACD,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;AACjC,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,EAAE,EAAE,CAAE,UAAU,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA"}
|
||||
10
packages/commons/dist/index.d.ts
vendored
10
packages/commons/dist/index.d.ts
vendored
@ -1 +1,9 @@
|
||||
export {};
|
||||
export * from './fs.js';
|
||||
export * from './config.js';
|
||||
export * from './os.js';
|
||||
export * from './paths.js';
|
||||
export * from './variables.js';
|
||||
export * from './profile.js';
|
||||
export * from './types.js';
|
||||
export * from './constants.js';
|
||||
export * from './_glob.js';
|
||||
|
||||
10
packages/commons/dist/index.js
vendored
10
packages/commons/dist/index.js
vendored
@ -1,2 +1,10 @@
|
||||
export {};
|
||||
export * from './fs.js';
|
||||
export * from './config.js';
|
||||
export * from './os.js';
|
||||
export * from './paths.js';
|
||||
export * from './variables.js';
|
||||
export * from './profile.js';
|
||||
export * from './types.js';
|
||||
export * from './constants.js';
|
||||
export * from './_glob.js';
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
packages/commons/dist/index.js.map
vendored
2
packages/commons/dist/index.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
||||
2
packages/commons/dist/shemas/index.js.map
vendored
2
packages/commons/dist/shemas/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
packages/commons/dist/variables.js
vendored
2
packages/commons/dist/variables.js
vendored
@ -1,5 +1,5 @@
|
||||
import { REGEX_VAR, REGEX_VAR_ALT } from "@polymech/core/constants.js";
|
||||
import { DEFAULT_ROOTS } from '@/config.js';
|
||||
import { DEFAULT_ROOTS } from './config.js';
|
||||
export const DATE_VARS = () => {
|
||||
return {
|
||||
YYYY: new Date(Date.now()).getFullYear(),
|
||||
|
||||
@ -22,6 +22,10 @@
|
||||
"./schemas": {
|
||||
"import": "./dist/schemas/index.js",
|
||||
"require": "./dist/schemas/index.cjs"
|
||||
},
|
||||
"./config": {
|
||||
"import": "./dist/config.js",
|
||||
"require": "./dist/config.cjs"
|
||||
}
|
||||
},
|
||||
"licenses": [
|
||||
|
||||
@ -9,7 +9,7 @@ export const files = (cwd, glob, options?: any) => globSync(glob, { ...{ dot: tr
|
||||
export const filesEx = (cwd, glob, options?: GlobOptions) => globSync(glob, { ...{ dot: true, cwd, absolute: true, caseSensitiveMatch: false }, ...options || {} }) as []
|
||||
|
||||
import { substitute } from '@/variables.js'
|
||||
import { isFile, isFolder, getExtensions } from '@/fs.js'
|
||||
import { isFile, isFolder } from '@/fs.js'
|
||||
import { PATH_INFO } from '@/types_common.js'
|
||||
|
||||
const globBase = require('glob-base')
|
||||
@ -48,7 +48,7 @@ export const pathInfoEx = (src: string, altToken: boolean = false, globOptions:
|
||||
variables.DIR = path.resolve(glob_base.base)
|
||||
variables.FILE_NAME = glob_base.glob
|
||||
variables.GLOB = glob_base.glob
|
||||
variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
//variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
globOptions = {
|
||||
...globOptions,
|
||||
cwd: globOptions.cwd ? path.join(globOptions.cwd as string, glob_base.base) : null
|
||||
@ -83,7 +83,7 @@ export const pathInfo = (src: string, altToken: boolean = false, cwd: string = n
|
||||
variables.DIR = path.resolve(glob_base.base)
|
||||
variables.FILE_NAME = glob_base.glob
|
||||
variables.GLOB = glob_base.glob
|
||||
variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
//variables.GLOB_EXTENSIONS = getExtensions(glob_base.glob)
|
||||
variables.FILES = globSync(glob_base.glob, {
|
||||
dot: true,
|
||||
cwd: path.resolve(cwd || variables.DIR),
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import * as env from 'env-var'
|
||||
import pkg from 'env-var';
|
||||
const { get } = pkg;
|
||||
|
||||
import { sync as read } from '@polymech/fs/read'
|
||||
import { sync as exists } from '@polymech/fs/exists'
|
||||
import * as path from 'path'
|
||||
@ -8,7 +10,7 @@ export const API_PREFIX_NEXT = 'polymech'
|
||||
|
||||
export const HOME = (sub = '') => path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], sub)
|
||||
|
||||
export const get_var = (key: string ='') => env.get(key).asString() || env.get(key.replace(/-/g, '_')).asString() || env.get(key.replace(/_/g, '-')).asString()
|
||||
export const get_var = (key: string = '') => get(key).asString() || get(key.replace(/-/g, '_')).asString() || get(key.replace(/_/g, '-')).asString()
|
||||
|
||||
export const OSR_ROOT = (key: string = 'OSR-ROOT') => get_var(key) || path.join(HOME('desktop'), API_PREFIX)
|
||||
export const OSR_SUB_DEFAULT = (key: string = '') => get_var(key) || path.join(OSR_ROOT(), key)
|
||||
|
||||
@ -8,6 +8,7 @@ export const WIN32_PATH_REGEX = /^([a-z]:)?[\\\/]/i
|
||||
|
||||
import { is_windows } from './os.js'
|
||||
|
||||
/*
|
||||
const parseGlob = require('parse-glob')
|
||||
|
||||
export const getExtensions = (glob: string) => {
|
||||
@ -18,6 +19,7 @@ export const getExtensions = (glob: string) => {
|
||||
return [parseGlob(glob).path.ext]
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
export const isFile = (src: string) => {
|
||||
let srcIsFile = false;
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
export * from './fs.js'
|
||||
export * from './config.js'
|
||||
export * from './os.js'
|
||||
export * from './paths.js'
|
||||
export * from './variables.js'
|
||||
export * from './profile.js'
|
||||
export * from './types.js'
|
||||
export * from './constants.js'
|
||||
export * from './_glob.js'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import { zodToTs, printNode } from 'zod-to-ts'
|
||||
import { zodToJsonSchema } from "zod-to-json-schema"
|
||||
|
||||
import { logger } from '@/logger.js'
|
||||
|
||||
export * from './path.js'
|
||||
export * from './zod_map.js'
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { REGEX_VAR, REGEX_VAR_ALT } from "@polymech/core/constants.js"
|
||||
import { DEFAULT_ROOTS } from '@/config.js'
|
||||
import { DEFAULT_ROOTS } from './config.js'
|
||||
|
||||
export const DATE_VARS = () => {
|
||||
return {
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
"include": ["src/**/*.ts"],
|
||||
"files": ["src/index.ts"],
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": false,
|
||||
"allowJs": true,
|
||||
"baseUrl": ".",
|
||||
"declarationDir": "./dist",
|
||||
"outDir": "./dist",
|
||||
"sourceMap": true,
|
||||
"preserveConstEnums": true,
|
||||
"preserveConstEnums": true,
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
|
||||
2
packages/fs/dist/append.d.ts
vendored
2
packages/fs/dist/append.d.ts
vendored
@ -5,4 +5,4 @@ export interface Options {
|
||||
}
|
||||
export declare const validateInput: (methodName: string, path: string, data: any, options?: Options) => void;
|
||||
export declare const sync: (path: string, data: any, options: Options) => void;
|
||||
export declare const async: (path: string, data: string | Buffer | object, options?: Options) => Promise<null>;
|
||||
export declare const async: (path: string, data: string | Uint8Array, options?: Options) => Promise<void>;
|
||||
|
||||
24
packages/fs/dist/append.js
vendored
24
packages/fs/dist/append.js
vendored
@ -1,6 +1,5 @@
|
||||
import * as fs from 'fs';
|
||||
const Q = require('q');
|
||||
import { sync as writeSync, async as writeASync } from './write.js';
|
||||
import * as fs from 'node:fs';
|
||||
import { sync as writeSync } from './write.js';
|
||||
import { validateArgument, validateOptions } from './utils/validate.js';
|
||||
export const validateInput = (methodName, path, data, options) => {
|
||||
const methodSignature = methodName + '(path, data, [options])';
|
||||
@ -28,23 +27,6 @@ export const sync = (path, data, options) => {
|
||||
}
|
||||
}
|
||||
};
|
||||
// ---------------------------------------------------------
|
||||
// ASYNC
|
||||
// ---------------------------------------------------------
|
||||
const promisedAppendFile = Q.denodeify(fs.appendFile);
|
||||
export const async = (path, data, options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
promisedAppendFile(path, data, options)
|
||||
.then(resolve)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directory doesn't exist, so just pass the task to `write`,
|
||||
// which will create the folder and file.
|
||||
writeASync(path, data, options).then(resolve, reject);
|
||||
}
|
||||
else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
return fs.promises.appendFile(path, data, options);
|
||||
};
|
||||
|
||||
10
packages/fs/dist/copy.js
vendored
10
packages/fs/dist/copy.js
vendored
@ -19,7 +19,6 @@ const promisedSymlink = promisify(fs.symlink);
|
||||
const promisedReadlink = promisify(fs.readlink);
|
||||
const promisedUnlink = promisify(fs.unlink);
|
||||
const promisedMkdirp = promisify(mkdirp);
|
||||
const progress = require('progress-stream');
|
||||
const CPROGRESS_THRESHOLD = 1048576 * 5; // minimum file size threshold to use write progress = 5MB
|
||||
export function validateInput(methodName, from, to, options) {
|
||||
const methodSignature = methodName + '(from, to, [options])';
|
||||
@ -88,20 +87,22 @@ async function copyFileSyncWithProgress(from, to, options = {}) {
|
||||
};
|
||||
const rd = createReadStream(from).
|
||||
on('error', (err) => done(err));
|
||||
/*
|
||||
const str = progress({
|
||||
length: fs.statSync(from).size,
|
||||
time: 100
|
||||
}).on('progress', (e) => {
|
||||
}).on('progress', (e: any) => {
|
||||
elapsed = (Date.now() - started) / 1000;
|
||||
speed = e.transferred / elapsed;
|
||||
if (options.writeProgress) {
|
||||
options.writeProgress(from, e.transferred, e.length);
|
||||
}
|
||||
});
|
||||
*/
|
||||
const wr = createWriteStream(to);
|
||||
wr.on('error', (err) => done(err));
|
||||
wr.on('close', done);
|
||||
rd.pipe(str).pipe(wr);
|
||||
//rd.pipe(str).pipe(wr);
|
||||
});
|
||||
}
|
||||
async function copyFileSync(from, to, mode, options) {
|
||||
@ -289,10 +290,11 @@ const copyFileAsync = (from, to, mode, options, retriedAttempt) => {
|
||||
const size = fs.statSync(from).size;
|
||||
let progressStream = null;
|
||||
if (options && options.writeProgress && size > CPROGRESS_THRESHOLD) {
|
||||
/*
|
||||
progressStream = progress({
|
||||
length: fs.statSync(from).size,
|
||||
time: 100 // call progress each 100 ms
|
||||
});
|
||||
});*/
|
||||
let elapsed = Date.now();
|
||||
let speed = 0;
|
||||
const started = Date.now();
|
||||
|
||||
6
packages/fs/dist/errors.js
vendored
6
packages/fs/dist/errors.js
vendored
@ -1,7 +1,7 @@
|
||||
import { ErrnoException } from './interfaces.js';
|
||||
const errno = require('errno');
|
||||
Object.keys(errno.code).forEach(function (code) {
|
||||
const e = errno.code[code];
|
||||
import { code } from './errno.js';
|
||||
Object.keys(code).forEach(function (code) {
|
||||
const e = code[code];
|
||||
exports[code] = (path) => {
|
||||
const err = new Error(code + ', ' + e.description + (path ? ' \'' + path + '\'' : ''));
|
||||
err.errno = e.errno;
|
||||
|
||||
21
packages/fs/dist/file.js
vendored
21
packages/fs/dist/file.js
vendored
@ -1,12 +1,11 @@
|
||||
import * as fs from 'fs';
|
||||
const Q = require('q');
|
||||
import { normalizeFileMode } from './utils/mode.js';
|
||||
import { validateArgument, validateOptions } from './utils/validate.js';
|
||||
import { sync as writeSync, async as writeASync } from './write.js';
|
||||
import { ErrNotFile } from './errors.js';
|
||||
import { EError } from './interfaces.js';
|
||||
const promisedStat = Q.denodeify(fs.stat);
|
||||
const promisedChmod = Q.denodeify(fs.chmod);
|
||||
const promisedStat = fs.promises.stat;
|
||||
const promisedChmod = fs.promises.chmod;
|
||||
export function validateInput(methodName, path, options) {
|
||||
const methodSignature = methodName + '(path, [criteria])';
|
||||
validateArgument(methodSignature, 'path', path, ['string']);
|
||||
@ -109,24 +108,18 @@ const checkContentAsync = (path, mode, options) => {
|
||||
writeASync(path, options.content, {
|
||||
mode: mode,
|
||||
jsonIndent: options.jsonIndent
|
||||
}).then(() => resolve(true))
|
||||
.catch(reject);
|
||||
}).then(() => resolve(true)).catch(reject);
|
||||
}
|
||||
else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
async function writeAsync(path, stat, options) {
|
||||
const writeAsync = async (path, stat, options) => {
|
||||
const mode = normalizeFileMode(stat.mode);
|
||||
return checkContentAsync(path, mode, options)
|
||||
.then(contentReplaced => {
|
||||
if (!contentReplaced) {
|
||||
return checkModeAsync(path, mode, options);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
return checkContentAsync(path, mode, options);
|
||||
//.then()
|
||||
};
|
||||
const touchAsync = (path, options) => {
|
||||
return writeASync(path, options.content !== undefined ? options.content : '', {
|
||||
mode: options.mode,
|
||||
|
||||
4
packages/fs/dist/imports.js
vendored
4
packages/fs/dist/imports.js
vendored
@ -1,6 +1,6 @@
|
||||
const writefs = require('write-file-atomic');
|
||||
import { sync } from 'write-file-atomic';
|
||||
export const file = {
|
||||
write_atomic: writefs
|
||||
write_atomic: sync
|
||||
};
|
||||
export const json = {
|
||||
parse: JSON.parse,
|
||||
|
||||
2
packages/fs/dist/index.d.ts
vendored
2
packages/fs/dist/index.d.ts
vendored
@ -10,7 +10,7 @@ export interface IJetpack {
|
||||
cwd(w?: any): IJetpack | string;
|
||||
path(): string;
|
||||
append(path: string, data: string | Buffer | object, options?: AppendOptions): void;
|
||||
appendAsync(path: string, data: string | Buffer | object, options?: AppendOptions): Promise<null>;
|
||||
appendAsync(path: string, data: string | Buffer | object, options?: AppendOptions): Promise<void>;
|
||||
copy(from: string, to: string, options?: ICopyOptions): void;
|
||||
copyAsync(from: string, to: string, options?: ICopyOptions): Promise<TCopyResult>;
|
||||
createWriteStream(path: string, options?: {
|
||||
|
||||
179
packages/fs/dist/index.js
vendored
179
packages/fs/dist/index.js
vendored
@ -1,22 +1,5 @@
|
||||
import * as util from 'util';
|
||||
import * as pathUtil from 'path';
|
||||
import * as append from './append.js';
|
||||
import * as dir from './dir.js';
|
||||
import * as file from './file.js';
|
||||
import * as find from './find.js';
|
||||
import * as inspect from './inspect.js';
|
||||
import * as inspectTree from './inspect_tree.js';
|
||||
import * as copy from './copy.js';
|
||||
import * as exists from './exists.js';
|
||||
import * as list from './list.js';
|
||||
import * as move from './move.js';
|
||||
import * as remove from './remove.js';
|
||||
import * as rename from './rename.js';
|
||||
import * as symlink from './symlink.js';
|
||||
import * as streams from './streams.js';
|
||||
import * as write from './write.js';
|
||||
import * as read from './read.js';
|
||||
const Q = require('q');
|
||||
// The Jetpack Context object.
|
||||
// It provides the public API, and resolves all paths regarding to
|
||||
// passed cwdPath, or default process.cwd() if cwdPath was not specified.
|
||||
@ -50,167 +33,7 @@ export const fs = (cwdPath) => {
|
||||
return options || { cwd: getCwdPath() };
|
||||
};
|
||||
// API
|
||||
const api = {
|
||||
cwd: cwd,
|
||||
path: getPath,
|
||||
append: function (path, data, options) {
|
||||
append.validateInput('append', path, data, options);
|
||||
append.sync(resolvePath(path), data, options);
|
||||
},
|
||||
appendAsync: function (path, data, options) {
|
||||
append.validateInput('appendAsync', path, data, options);
|
||||
return append.async(resolvePath(path), data, options);
|
||||
},
|
||||
copy: function (from, to, options) {
|
||||
copy.validateInput('copy', from, to, options);
|
||||
copy.sync(resolvePath(from), resolvePath(to), options);
|
||||
},
|
||||
copyAsync: function (from, to, options) {
|
||||
copy.validateInput('copyAsync', from, to, options);
|
||||
return copy.async(resolvePath(from), resolvePath(to), options);
|
||||
},
|
||||
createWriteStream: function (path, options) {
|
||||
return streams.createWriteStream(resolvePath(path), options);
|
||||
},
|
||||
createReadStream: function (path, options) {
|
||||
return streams.createReadStream(resolvePath(path), options);
|
||||
},
|
||||
dir: function (path, criteria) {
|
||||
let normalizedPath;
|
||||
dir.validateInput('dir', path, criteria);
|
||||
normalizedPath = resolvePath(path);
|
||||
dir.sync(normalizedPath, criteria);
|
||||
return cwd(normalizedPath);
|
||||
},
|
||||
dirAsync: function (path, criteria) {
|
||||
const deferred = Q.defer();
|
||||
let normalizedPath;
|
||||
dir.validateInput('dirAsync', path, criteria);
|
||||
normalizedPath = resolvePath(path);
|
||||
dir.async(normalizedPath, criteria)
|
||||
.then(function () {
|
||||
deferred.resolve(cwd(normalizedPath));
|
||||
}, deferred.reject);
|
||||
return deferred.promise;
|
||||
},
|
||||
exists: function (path) {
|
||||
exists.validateInput('exists', path);
|
||||
return exists.sync(resolvePath(path));
|
||||
},
|
||||
existsAsync: function (path) {
|
||||
exists.validateInput('existsAsync', path);
|
||||
return exists.async(resolvePath(path));
|
||||
},
|
||||
file: function (path, criteria) {
|
||||
file.validateInput('file', path, criteria);
|
||||
file.sync(resolvePath(path), criteria);
|
||||
return this;
|
||||
},
|
||||
fileAsync: function (path, criteria) {
|
||||
const deferred = Q.defer();
|
||||
const that = this;
|
||||
file.validateInput('fileAsync', path, criteria);
|
||||
file.async(resolvePath(path), criteria)
|
||||
.then(function () {
|
||||
deferred.resolve(that);
|
||||
}, deferred.reject);
|
||||
return deferred.promise;
|
||||
},
|
||||
find: function (startPath, options) {
|
||||
// startPath is optional parameter, if not specified move rest of params
|
||||
// to proper places and default startPath to CWD.
|
||||
if (typeof options === 'undefined' && typeof startPath === 'object') {
|
||||
options = startPath;
|
||||
startPath = '.';
|
||||
}
|
||||
find.validateInput('find', startPath, options);
|
||||
return find.sync(resolvePath(startPath), normalizeOptions(options));
|
||||
},
|
||||
findAsync: function (startPath, options) {
|
||||
// startPath is optional parameter, if not specified move rest of params
|
||||
// to proper places and default startPath to CWD.
|
||||
if (typeof options === 'undefined' && typeof startPath === 'object') {
|
||||
options = startPath;
|
||||
startPath = '.';
|
||||
}
|
||||
find.validateInput('findAsync', startPath, options);
|
||||
return find.async(resolvePath(startPath), normalizeOptions(options));
|
||||
},
|
||||
inspect: function (path, fieldsToInclude) {
|
||||
inspect.validateInput('inspect', path, fieldsToInclude);
|
||||
return inspect.sync(resolvePath(path), fieldsToInclude);
|
||||
},
|
||||
inspectAsync: function (path, fieldsToInclude) {
|
||||
inspect.validateInput('inspectAsync', path, fieldsToInclude);
|
||||
return inspect.async(resolvePath(path), fieldsToInclude);
|
||||
},
|
||||
inspectTree: function (path, options) {
|
||||
inspectTree.validateInput('inspectTree', path, options);
|
||||
return inspectTree.sync(resolvePath(path), options);
|
||||
},
|
||||
inspectTreeAsync: function (path, options) {
|
||||
inspectTree.validateInput('inspectTreeAsync', path, options);
|
||||
return inspectTree.async(resolvePath(path), options);
|
||||
},
|
||||
list: function (path) {
|
||||
list.validateInput('list', path);
|
||||
return list.sync(resolvePath(path || '.'));
|
||||
},
|
||||
listAsync: function (path) {
|
||||
list.validateInput('listAsync', path);
|
||||
return list.async(resolvePath(path || '.'));
|
||||
},
|
||||
move: function (from, to) {
|
||||
move.validateInput('move', from, to);
|
||||
move.sync(resolvePath(from), resolvePath(to));
|
||||
},
|
||||
moveAsync: function (from, to) {
|
||||
move.validateInput('moveAsync', from, to);
|
||||
return move.async(resolvePath(from), resolvePath(to));
|
||||
},
|
||||
read: function (path, returnAs) {
|
||||
read.validateInput('read', path, returnAs);
|
||||
return read.sync(resolvePath(path), returnAs);
|
||||
},
|
||||
readAsync: function (path, returnAs) {
|
||||
read.validateInput('readAsync', path, returnAs);
|
||||
return read.async(resolvePath(path), returnAs);
|
||||
},
|
||||
remove: function (path) {
|
||||
remove.validateInput('remove', path);
|
||||
// If path not specified defaults to CWD
|
||||
remove.sync(resolvePath(path || '.'));
|
||||
},
|
||||
removeAsync: function (path) {
|
||||
remove.validateInput('removeAsync', path);
|
||||
// If path not specified defaults to CWD
|
||||
return remove.async(resolvePath(path || '.'));
|
||||
},
|
||||
rename: function (path, newName) {
|
||||
rename.validateInput('rename', path, newName);
|
||||
rename.sync(resolvePath(path), newName);
|
||||
},
|
||||
renameAsync: function (path, newName) {
|
||||
rename.validateInput('renameAsync', path, newName);
|
||||
return rename.async(resolvePath(path), newName);
|
||||
},
|
||||
symlink: function (symlinkValue, path) {
|
||||
symlink.validateInput('symlink', symlinkValue, path);
|
||||
symlink.sync(symlinkValue, resolvePath(path));
|
||||
},
|
||||
symlinkAsync: function (symlinkValue, path) {
|
||||
symlink.validateInput('symlinkAsync', symlinkValue, path);
|
||||
return symlink.async(symlinkValue, resolvePath(path));
|
||||
},
|
||||
write: function (path, data, options) {
|
||||
write.validateInput('write', path, data, options);
|
||||
write.sync(resolvePath(path), data, options);
|
||||
},
|
||||
writeAsync: function (path, data, options) {
|
||||
write.validateInput('writeAsync', path, data, options);
|
||||
return write.async(resolvePath(path), data, options);
|
||||
}
|
||||
};
|
||||
const api = {};
|
||||
if (util.inspect['custom'] !== undefined) {
|
||||
// Without this console.log(jetpack) throws obscure error. Details:
|
||||
// https://github.com/szwacz/fs-jetpack/issues/29
|
||||
|
||||
6
packages/fs/dist/read.js
vendored
6
packages/fs/dist/read.js
vendored
@ -1,9 +1,7 @@
|
||||
import { readFile, readFileSync } from 'fs';
|
||||
import { promises, readFileSync } from 'fs';
|
||||
import { json } from './imports.js';
|
||||
import { validateArgument } from './utils/validate.js';
|
||||
const Q = require('q');
|
||||
const supportedReturnAs = ['utf8', 'buffer', 'json', 'jsonWithDates'];
|
||||
const promisedReadFile = Q.denodeify(readFile);
|
||||
export function validateInput(methodName, path, returnAs) {
|
||||
const methodSignature = methodName + '(path, returnAs)';
|
||||
validateArgument(methodSignature, 'path', path, ['string']);
|
||||
@ -66,7 +64,7 @@ export function sync(path, returnAs) {
|
||||
export function async(path, returnAs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const retAs = returnAs || 'utf8';
|
||||
promisedReadFile(path, { encoding: retAs === 'buffer' ? null : 'utf8' })
|
||||
promises.readFile(path, { encoding: retAs === 'buffer' ? null : 'utf8' })
|
||||
.then((data) => {
|
||||
// Make final parsing of the data before returning.
|
||||
try {
|
||||
|
||||
10
packages/fs/dist/symlink.js
vendored
10
packages/fs/dist/symlink.js
vendored
@ -1,10 +1,8 @@
|
||||
const Q = require('q');
|
||||
import * as fs from 'fs';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import { mkdirp, mkdirpSync } from 'mkdirp';
|
||||
import * as pathUtil from "path";
|
||||
import { validateArgument } from './utils/validate.js';
|
||||
const promisedSymlink = Q.denodeify(fs.symlink);
|
||||
const promisedMkdirp = Q.denodeify(mkdirp);
|
||||
const promisedSymlink = fs.promises.symlink;
|
||||
export function validateInput(methodName, symlinkValue, path) {
|
||||
const methodSignature = methodName + '(symlinkValue, path)';
|
||||
validateArgument(methodSignature, 'symlinkValue', symlinkValue, ['string']);
|
||||
@ -21,7 +19,7 @@ export function sync(symlinkValue, path) {
|
||||
catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directories don't exist. Just create them and rety.
|
||||
mkdirp.sync(pathUtil.dirname(path));
|
||||
mkdirpSync(pathUtil.dirname(path));
|
||||
fs.symlinkSync(symlinkValue, path);
|
||||
}
|
||||
else {
|
||||
@ -39,7 +37,7 @@ export function async(symlinkValue, path) {
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directories don't exist. Just create them and rety.
|
||||
promisedMkdirp(pathUtil.dirname(path))
|
||||
mkdirp(pathUtil.dirname(path))
|
||||
.then(() => { return promisedSymlink(symlinkValue, path); })
|
||||
.then(resolve, reject);
|
||||
}
|
||||
|
||||
3
packages/fs/dist/utils/fs.js
vendored
3
packages/fs/dist/utils/fs.js
vendored
@ -1,6 +1,5 @@
|
||||
// Adater module exposing all `fs` methods with promises instead of callbacks.
|
||||
import * as fs from 'fs';
|
||||
const promisify = require('./promisify');
|
||||
import { promisify } from '../promisify.js';
|
||||
const isCallbackMethod = (key) => {
|
||||
return [
|
||||
typeof fs[key] === 'function',
|
||||
|
||||
2
packages/fs/dist/write.d.ts
vendored
2
packages/fs/dist/write.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { IWriteOptions, ReadWriteDataType } from './interfaces.js';
|
||||
export declare function validateInput(methodName: string, path: string, data: ReadWriteDataType, options: IWriteOptions): void;
|
||||
export declare function sync(path: string, data: ReadWriteDataType, options?: IWriteOptions): void;
|
||||
export declare function async(path: string, data: ReadWriteDataType, options?: IWriteOptions): Promise<null>;
|
||||
export declare function async(path: string, data: ReadWriteDataType, options?: IWriteOptions): Promise<any>;
|
||||
|
||||
10
packages/fs/dist/write.js
vendored
10
packages/fs/dist/write.js
vendored
@ -1,10 +1,10 @@
|
||||
import * as pathUtil from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { writeFileSync } from 'fs';
|
||||
const Q = require('q');
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import { mkdirp } from 'mkdirp';
|
||||
import { json, file } from './imports.js';
|
||||
import { validateArgument, validateOptions } from './utils/validate.js';
|
||||
import { promisify } from './promisify.js';
|
||||
// Temporary file extensions used for atomic file overwriting.
|
||||
const newExt = '.__new__';
|
||||
export function validateInput(methodName, path, data, options) {
|
||||
@ -55,9 +55,9 @@ export function sync(path, data, options) {
|
||||
// ---------------------------------------------------------
|
||||
// ASYNC
|
||||
// ---------------------------------------------------------
|
||||
const promisedWriteFile = Q.denodeify(fs.writeFile);
|
||||
const promisedMkdirp = Q.denodeify(mkdirp);
|
||||
const promisedAtomic = Q.denodeify(writeAtomicSync);
|
||||
const promisedWriteFile = fs.promises.writeFile;
|
||||
const promisedMkdirp = mkdirp;
|
||||
const promisedAtomic = promisify(writeAtomicSync);
|
||||
function writeFileAsync(path, data, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
promisedWriteFile(path, data, options)
|
||||
|
||||
@ -23,16 +23,15 @@
|
||||
"dependencies": {
|
||||
"@polymech/core": "workspace:*",
|
||||
"denodeify": "^1.2.1",
|
||||
"errno": "^0.1.4",
|
||||
"eslint-plugin-regexp": "^2.7.0",
|
||||
"glob": "^10.4.1",
|
||||
"mime": "^2.0.3",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mkdirp": "^3.0.1",
|
||||
"progress-stream": "^1.2.0",
|
||||
"q": "^1.4.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"write-file-atomic": "^1.3.1",
|
||||
"write-file-atomic": "^6.0.0",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import * as fs from 'fs'
|
||||
const Q = require('q')
|
||||
|
||||
import * as fs from 'node:fs'
|
||||
import { sync as writeSync, async as writeASync } from './write.js'
|
||||
|
||||
import { validateArgument, validateOptions } from './utils/validate.js'
|
||||
export interface Options {
|
||||
mode: string;
|
||||
@ -33,22 +32,6 @@ export const sync = (path: string, data: any, options: Options): void => {
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ASYNC
|
||||
// ---------------------------------------------------------
|
||||
const promisedAppendFile = Q.denodeify(fs.appendFile);
|
||||
export const async = (path: string, data: string | Buffer | object, options?: Options): Promise<null> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
promisedAppendFile(path, data, options)
|
||||
.then(resolve)
|
||||
.catch((err: any) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directory doesn't exist, so just pass the task to `write`,
|
||||
// which will create the folder and file.
|
||||
writeASync(path, data, options).then(resolve, reject);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
export const async = (path: string, data: string | Uint8Array, options?: Options): Promise<void> => {
|
||||
return fs.promises.appendFile(path, data, options as any)
|
||||
};
|
||||
|
||||
@ -42,8 +42,6 @@ const promisedReadlink = promisify(fs.readlink);
|
||||
const promisedUnlink = promisify(fs.unlink);
|
||||
const promisedMkdirp = promisify<string, any, Function>(mkdirp);
|
||||
|
||||
const progress = require('progress-stream');
|
||||
|
||||
const CPROGRESS_THRESHOLD = 1048576 * 5; // minimum file size threshold to use write progress = 5MB
|
||||
|
||||
export function validateInput(methodName: string, from: string, to: string, options?: ICopyOptions): void {
|
||||
@ -116,6 +114,7 @@ async function copyFileSyncWithProgress(from: string, to: string, options: ICopy
|
||||
const rd = createReadStream(from).
|
||||
on('error', (err: Error) => done(err));
|
||||
|
||||
/*
|
||||
const str = progress({
|
||||
length: fs.statSync(from).size,
|
||||
time: 100
|
||||
@ -126,12 +125,12 @@ async function copyFileSyncWithProgress(from: string, to: string, options: ICopy
|
||||
options.writeProgress(from, e.transferred, e.length);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
const wr = createWriteStream(to);
|
||||
wr.on('error', (err: Error) => done(err));
|
||||
wr.on('close', done);
|
||||
|
||||
rd.pipe(str).pipe(wr);
|
||||
//rd.pipe(str).pipe(wr);
|
||||
});
|
||||
}
|
||||
|
||||
@ -324,10 +323,11 @@ const copyFileAsync = (from: string, to: string, mode: any, options?: ICopyOptio
|
||||
const size = fs.statSync(from).size;
|
||||
let progressStream = null;
|
||||
if (options && options.writeProgress && size > CPROGRESS_THRESHOLD) {
|
||||
/*
|
||||
progressStream = progress({
|
||||
length: fs.statSync(from).size,
|
||||
time: 100 // call progress each 100 ms
|
||||
});
|
||||
});*/
|
||||
let elapsed = Date.now();
|
||||
let speed = 0;
|
||||
const started = Date.now();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { ErrnoException } from './interfaces.js';
|
||||
const errno = require('errno');
|
||||
import { errno, code } from './errno.js'
|
||||
|
||||
Object.keys(errno.code).forEach(function (code) {
|
||||
const e = errno.code[code];
|
||||
Object.keys(code).forEach(function (code) {
|
||||
const e = code[code];
|
||||
exports[code] = (path: string) => {
|
||||
const err = new Error(code + ', ' + e.description + (path ? ' \'' + path + '\'' : '')) as ErrnoException;
|
||||
err.errno = e.errno;
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import * as fs from 'fs';
|
||||
import { Stats } from 'fs';
|
||||
const Q = require('q');
|
||||
|
||||
import { normalizeFileMode } from './utils/mode.js';
|
||||
import { validateArgument, validateOptions } from './utils/validate.js';
|
||||
import { sync as writeSync, async as writeASync } from './write.js';
|
||||
import { ErrNotFile } from './errors.js';
|
||||
import { EError } from './interfaces.js';
|
||||
|
||||
const promisedStat = Q.denodeify(fs.stat);
|
||||
const promisedChmod = Q.denodeify(fs.chmod);
|
||||
const promisedStat = fs.promises.stat;
|
||||
const promisedChmod = fs.promises.chmod;
|
||||
|
||||
export interface IOptions {
|
||||
content: string | Buffer | object | Array<any>;
|
||||
@ -121,28 +121,22 @@ const checkModeAsync = (path: string, mode: string, options: IOptions) => {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const checkContentAsync = (path: string, mode: string, options: IOptions) => {
|
||||
const checkContentAsync = (path: string, mode: string, options: IOptions):Promise<boolean> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (options.content !== undefined) {
|
||||
writeASync(path, options.content, {
|
||||
mode: mode,
|
||||
jsonIndent: options.jsonIndent
|
||||
}).then(() => resolve(true))
|
||||
.catch(reject);
|
||||
}).then(() => resolve(true)).catch(reject);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
async function writeAsync(path: string, stat: Stats, options: IOptions): Promise<boolean> {
|
||||
const writeAsync = async (path: string, stat: Stats, options: IOptions): Promise<any> => {
|
||||
const mode = normalizeFileMode(stat.mode);
|
||||
return checkContentAsync(path, mode, options)
|
||||
.then(contentReplaced => {
|
||||
if (!contentReplaced) {
|
||||
return checkModeAsync(path, mode, options);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
//.then()
|
||||
}
|
||||
|
||||
const touchAsync = (path: string, options: IOptions) => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
const writefs = require('write-file-atomic');
|
||||
import { sync } from 'write-file-atomic'
|
||||
|
||||
export const file = {
|
||||
write_atomic: writefs
|
||||
write_atomic: sync
|
||||
};
|
||||
export const json = {
|
||||
parse: JSON.parse,
|
||||
|
||||
@ -30,12 +30,11 @@ import { ICopyOptions, INode, IInspectOptions } from './interfaces.js'
|
||||
import { ReadWriteDataType, TCopyResult, ENodeType, TDeleteResult } from './interfaces.js'
|
||||
|
||||
|
||||
const Q = require('q')
|
||||
export interface IJetpack {
|
||||
cwd(w?: any): IJetpack | string;
|
||||
path(): string;
|
||||
append(path: string, data: string | Buffer | object, options?: AppendOptions): void;
|
||||
appendAsync(path: string, data: string | Buffer | object, options?: AppendOptions): Promise<null>;
|
||||
appendAsync(path: string, data: string | Buffer | object, options?: AppendOptions): Promise<void>;
|
||||
copy(from: string, to: string, options?: ICopyOptions): void;
|
||||
copyAsync(from: string, to: string, options?: ICopyOptions): Promise<TCopyResult>;
|
||||
createWriteStream(path: string, options?: {
|
||||
@ -122,196 +121,8 @@ export const fs = (cwdPath?: string): IJetpack => {
|
||||
};
|
||||
|
||||
// API
|
||||
const api: IJetpack = {
|
||||
cwd: cwd,
|
||||
path: getPath,
|
||||
append: function (path: string, data: string | Buffer | object, options?: AppendOptions): void {
|
||||
append.validateInput('append', path, data, options);
|
||||
append.sync(resolvePath(path), data, options);
|
||||
},
|
||||
appendAsync: function (path: string, data: string | Buffer | object, options?: AppendOptions): Promise<null> {
|
||||
append.validateInput('appendAsync', path, data, options);
|
||||
return append.async(resolvePath(path), data, options);
|
||||
},
|
||||
|
||||
copy: function (from: string, to: string, options?: ICopyOptions) {
|
||||
copy.validateInput('copy', from, to, options);
|
||||
copy.sync(resolvePath(from), resolvePath(to), options);
|
||||
},
|
||||
copyAsync: function (from: string, to: string, options?: ICopyOptions) {
|
||||
copy.validateInput('copyAsync', from, to, options);
|
||||
return copy.async(resolvePath(from), resolvePath(to), options);
|
||||
},
|
||||
createWriteStream: function (path: string, options?: {
|
||||
flags?: string;
|
||||
encoding?: string;
|
||||
fd?: number;
|
||||
mode?: number;
|
||||
autoClose?: boolean;
|
||||
start?: number;
|
||||
}) {
|
||||
return streams.createWriteStream(resolvePath(path), options as any);
|
||||
},
|
||||
createReadStream: function (path: string, options?: {
|
||||
flags?: string;
|
||||
encoding?: string;
|
||||
fd?: number;
|
||||
mode?: number;
|
||||
autoClose?: boolean;
|
||||
start?: number;
|
||||
end?: number;
|
||||
}) {
|
||||
return streams.createReadStream(resolvePath(path), options as any);
|
||||
},
|
||||
|
||||
dir: function (path: string, criteria?: DirOptions): IJetpack {
|
||||
let normalizedPath;
|
||||
dir.validateInput('dir', path, criteria);
|
||||
normalizedPath = resolvePath(path);
|
||||
dir.sync(normalizedPath, criteria);
|
||||
return cwd(normalizedPath) as IJetpack;
|
||||
},
|
||||
dirAsync: function (path: string, criteria?: DirOptions): Promise<IJetpack> {
|
||||
const deferred = Q.defer();
|
||||
let normalizedPath: string;
|
||||
dir.validateInput('dirAsync', path, criteria);
|
||||
normalizedPath = resolvePath(path);
|
||||
dir.async(normalizedPath, criteria)
|
||||
.then(function () {
|
||||
deferred.resolve(cwd(normalizedPath));
|
||||
}, deferred.reject);
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
exists: function (path: string): boolean | string {
|
||||
exists.validateInput('exists', path);
|
||||
return exists.sync(resolvePath(path));
|
||||
},
|
||||
|
||||
existsAsync: function (path: string): Promise<boolean | string | ENodeType> {
|
||||
exists.validateInput('existsAsync', path);
|
||||
return exists.async(resolvePath(path));
|
||||
},
|
||||
|
||||
file: function (path: string, criteria?: FileOptions) {
|
||||
file.validateInput('file', path, criteria);
|
||||
file.sync(resolvePath(path), criteria);
|
||||
return this;
|
||||
},
|
||||
|
||||
fileAsync: function (path: string, criteria?: FileOptions) {
|
||||
const deferred = Q.defer();
|
||||
const that = this;
|
||||
file.validateInput('fileAsync', path, criteria);
|
||||
file.async(resolvePath(path), criteria)
|
||||
.then(function () {
|
||||
deferred.resolve(that);
|
||||
}, deferred.reject);
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
find: function (startPath: string, options: FindOptions): string[] {
|
||||
// startPath is optional parameter, if not specified move rest of params
|
||||
// to proper places and default startPath to CWD.
|
||||
if (typeof options === 'undefined' && typeof startPath === 'object') {
|
||||
options = startPath;
|
||||
startPath = '.';
|
||||
}
|
||||
find.validateInput('find', startPath, options);
|
||||
return find.sync(resolvePath(startPath), normalizeOptions(options));
|
||||
},
|
||||
findAsync: function (startPath: string, options: FindOptions): Promise<string[]> {
|
||||
// startPath is optional parameter, if not specified move rest of params
|
||||
// to proper places and default startPath to CWD.
|
||||
if (typeof options === 'undefined' && typeof startPath === 'object') {
|
||||
options = startPath;
|
||||
startPath = '.';
|
||||
}
|
||||
find.validateInput('findAsync', startPath, options);
|
||||
return find.async(resolvePath(startPath), normalizeOptions(options));
|
||||
},
|
||||
|
||||
inspect: function (path: string, fieldsToInclude: IInspectOptions) {
|
||||
inspect.validateInput('inspect', path, fieldsToInclude);
|
||||
return inspect.sync(resolvePath(path), fieldsToInclude);
|
||||
},
|
||||
inspectAsync: function (path: string, fieldsToInclude: IInspectOptions) {
|
||||
inspect.validateInput('inspectAsync', path, fieldsToInclude);
|
||||
return inspect.async(resolvePath(path), fieldsToInclude);
|
||||
},
|
||||
inspectTree: function (path: string, options?: InspectTreeOptions) {
|
||||
inspectTree.validateInput('inspectTree', path, options);
|
||||
return inspectTree.sync(resolvePath(path), options);
|
||||
},
|
||||
inspectTreeAsync: function (path: string, options?: InspectTreeOptions) {
|
||||
inspectTree.validateInput('inspectTreeAsync', path, options);
|
||||
return inspectTree.async(resolvePath(path), options);
|
||||
},
|
||||
|
||||
list: function (path: string): string[] {
|
||||
list.validateInput('list', path);
|
||||
return list.sync(resolvePath(path || '.'));
|
||||
},
|
||||
listAsync: function (path: string): Promise<string[]> {
|
||||
list.validateInput('listAsync', path);
|
||||
return list.async(resolvePath(path || '.'));
|
||||
},
|
||||
|
||||
move: function (from: string, to: string): void {
|
||||
move.validateInput('move', from, to);
|
||||
move.sync(resolvePath(from), resolvePath(to));
|
||||
},
|
||||
moveAsync: function (from: string, to: string): Promise<null> {
|
||||
move.validateInput('moveAsync', from, to);
|
||||
return move.async(resolvePath(from), resolvePath(to));
|
||||
},
|
||||
|
||||
read: function (path: string, returnAs?: string) {
|
||||
read.validateInput('read', path, returnAs);
|
||||
return read.sync(resolvePath(path), returnAs);
|
||||
},
|
||||
readAsync: function (path: string, returnAs?: string): Promise<ReadWriteDataType> {
|
||||
read.validateInput('readAsync', path, returnAs);
|
||||
return read.async(resolvePath(path), returnAs);
|
||||
},
|
||||
|
||||
remove: function (path: string): void {
|
||||
remove.validateInput('remove', path);
|
||||
// If path not specified defaults to CWD
|
||||
remove.sync(resolvePath(path || '.'));
|
||||
},
|
||||
removeAsync: function (path: string): Promise<TDeleteResult> {
|
||||
remove.validateInput('removeAsync', path);
|
||||
// If path not specified defaults to CWD
|
||||
return remove.async(resolvePath(path || '.'));
|
||||
},
|
||||
|
||||
rename: function (path: string, newName: string): void {
|
||||
rename.validateInput('rename', path, newName);
|
||||
rename.sync(resolvePath(path), newName);
|
||||
},
|
||||
renameAsync: function (path: string, newName: string): Promise<null> {
|
||||
rename.validateInput('renameAsync', path, newName);
|
||||
return rename.async(resolvePath(path), newName);
|
||||
},
|
||||
|
||||
symlink: function (symlinkValue: string, path: string): void {
|
||||
symlink.validateInput('symlink', symlinkValue, path);
|
||||
symlink.sync(symlinkValue, resolvePath(path));
|
||||
},
|
||||
symlinkAsync: function (symlinkValue: string, path: string): Promise<void> {
|
||||
symlink.validateInput('symlinkAsync', symlinkValue, path);
|
||||
return symlink.async(symlinkValue, resolvePath(path));
|
||||
},
|
||||
|
||||
write: function (path: string, data: string | Buffer | object, options?: IWriteOptions): void {
|
||||
write.validateInput('write', path, data, options);
|
||||
write.sync(resolvePath(path), data, options);
|
||||
},
|
||||
writeAsync: function (path: string, data: string | Buffer | object, options?: IWriteOptions) {
|
||||
write.validateInput('writeAsync', path, data, options);
|
||||
return write.async(resolvePath(path), data, options);
|
||||
}
|
||||
const api: any = {
|
||||
|
||||
};
|
||||
if ((util.inspect as any)['custom'] !== undefined) {
|
||||
// Without this console.log(jetpack) throws obscure error. Details:
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { readFile, readFileSync } from 'fs';
|
||||
import { readFile, promises,readFileSync } from 'fs';
|
||||
|
||||
import { json } from './imports.js';
|
||||
import { validateArgument } from './utils/validate.js';
|
||||
import type { ReadWriteDataType } from './interfaces.js';
|
||||
const Q = require('q');
|
||||
|
||||
const supportedReturnAs = ['utf8', 'buffer', 'json', 'jsonWithDates'];
|
||||
const promisedReadFile = Q.denodeify(readFile);
|
||||
|
||||
|
||||
export function validateInput(methodName: string, path: string, returnAs: string) {
|
||||
const methodSignature = methodName + '(path, returnAs)';
|
||||
@ -71,7 +72,7 @@ export function sync(path: string, returnAs?: string): ReadWriteDataType | undef
|
||||
export function async(path: string, returnAs?: string): Promise<ReadWriteDataType | null> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const retAs = returnAs || 'utf8';
|
||||
promisedReadFile(path, { encoding: retAs === 'buffer' ? null : 'utf8' })
|
||||
promises.readFile(path, { encoding: retAs === 'buffer' ? null : 'utf8' })
|
||||
.then((data: ReadWriteDataType) => {
|
||||
// Make final parsing of the data before returning.
|
||||
try {
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
const Q = require('q');
|
||||
import * as fs from 'fs';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as pathUtil from "path";
|
||||
import { validateArgument } from './utils/validate.js';
|
||||
const promisedSymlink = Q.denodeify(fs.symlink);
|
||||
const promisedMkdirp = Q.denodeify(mkdirp);
|
||||
import * as fs from 'fs'
|
||||
import { mkdirp, mkdirpSync } from 'mkdirp'
|
||||
import * as pathUtil from "path"
|
||||
import { validateArgument } from './utils/validate.js'
|
||||
|
||||
const promisedSymlink = fs.promises.symlink
|
||||
|
||||
export function validateInput(methodName: string, symlinkValue: string, path: string) {
|
||||
const methodSignature = methodName + '(symlinkValue, path)';
|
||||
@ -21,7 +20,7 @@ export function sync(symlinkValue: string, path: string): void {
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directories don't exist. Just create them and rety.
|
||||
mkdirp.sync(pathUtil.dirname(path));
|
||||
mkdirpSync(pathUtil.dirname(path));
|
||||
fs.symlinkSync(symlinkValue, path);
|
||||
} else {
|
||||
throw err;
|
||||
@ -39,7 +38,7 @@ export function async(symlinkValue: string, path: string):Promise<void> {
|
||||
.catch((err: any) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
// Parent directories don't exist. Just create them and rety.
|
||||
promisedMkdirp(pathUtil.dirname(path))
|
||||
mkdirp(pathUtil.dirname(path))
|
||||
.then(() => { return promisedSymlink(symlinkValue, path); })
|
||||
.then(resolve, reject);
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Adater module exposing all `fs` methods with promises instead of callbacks.
|
||||
|
||||
import * as fs from 'fs';
|
||||
const promisify = require('./promisify');
|
||||
import { promisify } from '../promisify.js'
|
||||
|
||||
const isCallbackMethod = (key) => {
|
||||
return [
|
||||
@ -19,7 +19,6 @@ const adaptMethod = (name) => {
|
||||
|
||||
const adaptAllMethods = () => {
|
||||
const adapted = {};
|
||||
|
||||
Object.keys(fs).forEach((key) => {
|
||||
if (isCallbackMethod(key)) {
|
||||
if (key === 'exists') {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import * as pathUtil from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { writeFileSync } from 'fs';
|
||||
const Q = require('q');
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import { json, file } from './imports.js';
|
||||
import { IWriteOptions, ReadWriteDataType } from './interfaces.js';
|
||||
import { validateArgument, validateOptions } from './utils/validate.js';
|
||||
import * as pathUtil from 'path'
|
||||
import * as fs from 'fs'
|
||||
import { writeFileSync } from 'fs'
|
||||
import { mkdirp , mkdirpSync} from 'mkdirp'
|
||||
import { json, file } from './imports.js'
|
||||
import { IWriteOptions, ReadWriteDataType } from './interfaces.js'
|
||||
import { validateArgument, validateOptions } from './utils/validate.js'
|
||||
|
||||
import { promisify } from './promisify.js'
|
||||
|
||||
// Temporary file extensions used for atomic file overwriting.
|
||||
const newExt = '.__new__';
|
||||
@ -61,12 +62,12 @@ export function sync(path: string, data: ReadWriteDataType, options?: IWriteOpti
|
||||
// ---------------------------------------------------------
|
||||
// ASYNC
|
||||
// ---------------------------------------------------------
|
||||
const promisedWriteFile = Q.denodeify(fs.writeFile);
|
||||
const promisedMkdirp = Q.denodeify(mkdirp);
|
||||
const promisedAtomic = Q.denodeify(writeAtomicSync);
|
||||
const promisedWriteFile = fs. promises.writeFile;
|
||||
const promisedMkdirp = mkdirp
|
||||
const promisedAtomic = promisify(writeAtomicSync);
|
||||
|
||||
function writeFileAsync(path: string, data: string, options?: IWriteOptions): Promise<null> {
|
||||
return new Promise<null>((resolve, reject) => {
|
||||
function writeFileAsync(path: string, data: string, options?: IWriteOptions): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
promisedWriteFile(path, data, options)
|
||||
.then(resolve)
|
||||
.catch((err: any) => {
|
||||
@ -84,8 +85,8 @@ function writeFileAsync(path: string, data: string, options?: IWriteOptions): Pr
|
||||
});
|
||||
});
|
||||
}
|
||||
export function async(path: string, data: ReadWriteDataType, options?: IWriteOptions): Promise<null> {
|
||||
export function async(path: string, data: ReadWriteDataType, options?: IWriteOptions): Promise<any> {
|
||||
const opts: any = options || {};
|
||||
const processedData: string = toJson(data, opts.jsonIndent);
|
||||
return (opts.atomic ? promisedAtomic : writeFileAsync)(path, processedData, { mode: opts.mode });
|
||||
return (opts.atomic ? promisedAtomic : writeFileAsync)(path, processedData, { mode: opts.mode })
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"strict": false,
|
||||
"moduleResolution": "Node16",
|
||||
"target": "ES2022",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "nodenext",
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"stripInternal": true
|
||||
|
||||
@ -26,15 +26,30 @@ importers:
|
||||
'@polymech/fs':
|
||||
specifier: workspace:*
|
||||
version: link:../fs
|
||||
env-var:
|
||||
specifier: ^7.5.0
|
||||
version: 7.5.0
|
||||
glob:
|
||||
specifier: ^10.4.1
|
||||
version: 10.4.5
|
||||
tslog:
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.4
|
||||
tsup:
|
||||
specifier: ^8.3.5
|
||||
version: 8.3.5(typescript@4.9.5)(yaml@2.4.2)
|
||||
yargs:
|
||||
specifier: ^17.7.2
|
||||
version: 17.7.2
|
||||
zod:
|
||||
specifier: ^3.24.1
|
||||
version: 3.24.1
|
||||
zod-to-json-schema:
|
||||
specifier: ^3.24.1
|
||||
version: 3.24.1(zod@3.24.1)
|
||||
zod-to-ts:
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0(typescript@4.9.5)(zod@3.24.1)
|
||||
devDependencies:
|
||||
'@eslint/js':
|
||||
specifier: ^9.18.0
|
||||
@ -53,7 +68,7 @@ importers:
|
||||
version: 8.57.1
|
||||
eslint-plugin-import:
|
||||
specifier: ^2.31.0
|
||||
version: 2.31.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@4.9.5))(eslint@8.57.1)
|
||||
version: 2.31.0(eslint@8.57.1)
|
||||
eslint-plugin-regexp:
|
||||
specifier: ^2.7.0
|
||||
version: 2.7.0(eslint@8.57.1)
|
||||
@ -142,9 +157,6 @@ importers:
|
||||
denodeify:
|
||||
specifier: ^1.2.1
|
||||
version: 1.2.1
|
||||
errno:
|
||||
specifier: ^0.1.4
|
||||
version: 0.1.8
|
||||
eslint-plugin-regexp:
|
||||
specifier: ^2.7.0
|
||||
version: 2.7.0(eslint@8.57.1)
|
||||
@ -158,8 +170,8 @@ importers:
|
||||
specifier: ^3.0.4
|
||||
version: 3.1.2
|
||||
mkdirp:
|
||||
specifier: ^0.5.1
|
||||
version: 0.5.6
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1
|
||||
progress-stream:
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0
|
||||
@ -170,8 +182,8 @@ importers:
|
||||
specifier: ^6.0.1
|
||||
version: 6.0.1
|
||||
write-file-atomic:
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.4
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
yargs:
|
||||
specifier: ^17.7.2
|
||||
version: 17.7.2
|
||||
@ -214,7 +226,7 @@ importers:
|
||||
version: 8.57.1
|
||||
eslint-plugin-import:
|
||||
specifier: ^2.31.0
|
||||
version: 2.31.0(eslint@8.57.1)
|
||||
version: 2.31.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)
|
||||
fs-extra:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.3
|
||||
@ -1578,9 +1590,9 @@ packages:
|
||||
resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==}
|
||||
engines: {node: '>=8.6'}
|
||||
|
||||
errno@0.1.8:
|
||||
resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}
|
||||
hasBin: true
|
||||
env-var@7.5.0:
|
||||
resolution: {integrity: sha512-mKZOzLRN0ETzau2W2QXefbFjo5EF4yWq28OyKb9ICdeNhHJlOE/pHHnz4hdYJ9cNZXcJHo5xN4OT4pzuSHSNvA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
error-ex@1.3.2:
|
||||
resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==}
|
||||
@ -2779,6 +2791,11 @@ packages:
|
||||
resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
|
||||
hasBin: true
|
||||
|
||||
mkdirp@3.0.1:
|
||||
resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
mocha-typescript@1.1.17:
|
||||
resolution: {integrity: sha512-Ge6pCQkZumkkhxVNdAf3JxunskShgaynCb30HYD7TT1Yhog/7NW2+6w5RcRHI+nuQrCMTX6z1+qf2pD8qwCoQA==}
|
||||
deprecated: mocha-typescript has been deprecated, use @testdeck/mocha instead
|
||||
@ -3111,9 +3128,6 @@ packages:
|
||||
prop-types@15.8.1:
|
||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
||||
|
||||
prr@1.0.1:
|
||||
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
|
||||
|
||||
pseudomap@1.0.2:
|
||||
resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==}
|
||||
|
||||
@ -3364,9 +3378,6 @@ packages:
|
||||
resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
slide@1.1.6:
|
||||
resolution: {integrity: sha512-NwrtjCg+lZoqhFU8fOwl4ay2ei8PaqCBOUV3/ektPY9trO1yQ1oXEfmHAhKArUVUr/hOHvy5f6AdP17dCM0zMw==}
|
||||
|
||||
smartwrap@2.0.2:
|
||||
resolution: {integrity: sha512-vCsKNQxb7PnCNd2wY1WClWifAc2lwqsG8OaswpJkVJsvMGcnEntdTCDajZCkk93Ay1U3t/9puJmb525Rg5MZBA==}
|
||||
engines: {node: '>=6'}
|
||||
@ -3970,8 +3981,9 @@ packages:
|
||||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
write-file-atomic@1.3.4:
|
||||
resolution: {integrity: sha512-SdrHoC/yVBPpV0Xq/mUZQIpW2sWXAShb/V4pomcJXh92RuaO+f3UTWItiR3Px+pLnV2PvC2/bfn5cwr5X6Vfxw==}
|
||||
write-file-atomic@6.0.0:
|
||||
resolution: {integrity: sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==}
|
||||
engines: {node: ^18.17.0 || >=20.5.0}
|
||||
|
||||
xtend@2.1.2:
|
||||
resolution: {integrity: sha512-vMNKzr2rHP9Dp/e1NQFnLQlwlhp9L/LfvnsVdHxN1f+uggyVI3i08uD14GPvCToPkdsRfyPqIyYGmIk58V98ZQ==}
|
||||
@ -4040,6 +4052,17 @@ packages:
|
||||
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
zod-to-json-schema@3.24.1:
|
||||
resolution: {integrity: sha512-3h08nf3Vw3Wl3PK+q3ow/lIil81IT2Oa7YpQyUUDsEWbXveMesdfK1xBd2RhCkynwZndAxixji/7SYJJowr62w==}
|
||||
peerDependencies:
|
||||
zod: ^3.24.1
|
||||
|
||||
zod-to-ts@1.2.0:
|
||||
resolution: {integrity: sha512-x30XE43V+InwGpvTySRNz9kB7qFU8DlyEy7BsSTCHPH1R0QasMmHWZDCzYm6bVXtj/9NNJAZF3jW8rzFvH5OFA==}
|
||||
peerDependencies:
|
||||
typescript: ^4.9.4 || ^5.0.2
|
||||
zod: ^3
|
||||
|
||||
zod@3.24.1:
|
||||
resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
|
||||
|
||||
@ -5546,9 +5569,7 @@ snapshots:
|
||||
ansi-colors: 4.1.3
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
errno@0.1.8:
|
||||
dependencies:
|
||||
prr: 1.0.1
|
||||
env-var@7.5.0: {}
|
||||
|
||||
error-ex@1.3.2:
|
||||
dependencies:
|
||||
@ -5758,11 +5779,11 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@4.9.5))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1):
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1):
|
||||
dependencies:
|
||||
debug: 3.2.7
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/parser': 8.20.0(eslint@8.57.1)(typescript@4.9.5)
|
||||
'@typescript-eslint/parser': 8.20.0(eslint@8.57.1)(typescript@5.7.3)
|
||||
eslint: 8.57.1
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
transitivePeerDependencies:
|
||||
@ -5813,7 +5834,7 @@ snapshots:
|
||||
- eslint-import-resolver-webpack
|
||||
- supports-color
|
||||
|
||||
eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@4.9.5))(eslint@8.57.1):
|
||||
eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1):
|
||||
dependencies:
|
||||
'@rtsao/scc': 1.1.0
|
||||
array-includes: 3.1.8
|
||||
@ -5824,7 +5845,7 @@ snapshots:
|
||||
doctrine: 2.1.0
|
||||
eslint: 8.57.1
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@4.9.5))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1)
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.20.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.1)
|
||||
hasown: 2.0.2
|
||||
is-core-module: 2.16.1
|
||||
is-glob: 4.0.3
|
||||
@ -5836,7 +5857,7 @@ snapshots:
|
||||
string.prototype.trimend: 1.0.8
|
||||
tsconfig-paths: 3.15.0
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/parser': 8.20.0(eslint@8.57.1)(typescript@4.9.5)
|
||||
'@typescript-eslint/parser': 8.20.0(eslint@8.57.1)(typescript@5.7.3)
|
||||
transitivePeerDependencies:
|
||||
- eslint-import-resolver-typescript
|
||||
- eslint-import-resolver-webpack
|
||||
@ -7171,6 +7192,8 @@ snapshots:
|
||||
dependencies:
|
||||
minimist: 1.2.8
|
||||
|
||||
mkdirp@3.0.1: {}
|
||||
|
||||
mocha-typescript@1.1.17:
|
||||
dependencies:
|
||||
'@types/mocha': 5.2.7
|
||||
@ -7494,8 +7517,6 @@ snapshots:
|
||||
object-assign: 4.1.1
|
||||
react-is: 16.13.1
|
||||
|
||||
prr@1.0.1: {}
|
||||
|
||||
pseudomap@1.0.2: {}
|
||||
|
||||
pump@3.0.2:
|
||||
@ -7779,8 +7800,6 @@ snapshots:
|
||||
|
||||
slash@4.0.0: {}
|
||||
|
||||
slide@1.1.6: {}
|
||||
|
||||
smartwrap@2.0.2:
|
||||
dependencies:
|
||||
array.prototype.flat: 1.3.2
|
||||
@ -8560,11 +8579,10 @@ snapshots:
|
||||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
write-file-atomic@1.3.4:
|
||||
write-file-atomic@6.0.0:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
imurmurhash: 0.1.4
|
||||
slide: 1.1.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
xtend@2.1.2:
|
||||
dependencies:
|
||||
@ -8655,6 +8673,15 @@ snapshots:
|
||||
|
||||
yocto-queue@0.1.0: {}
|
||||
|
||||
zod-to-json-schema@3.24.1(zod@3.24.1):
|
||||
dependencies:
|
||||
zod: 3.24.1
|
||||
|
||||
zod-to-ts@1.2.0(typescript@4.9.5)(zod@3.24.1):
|
||||
dependencies:
|
||||
typescript: 4.9.5
|
||||
zod: 3.24.1
|
||||
|
||||
zod@3.24.1: {}
|
||||
|
||||
zwitch@2.0.4: {}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user