Skip to content

Commit

Permalink
feat: remove globby and del
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Dec 21, 2024
1 parent e01162e commit 882897c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 23 deletions.
File renamed without changes.
18 changes: 9 additions & 9 deletions src/fs/del.ts → __exclude/fs/del.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _since, pFilter, pMap, UnixTimestampMillis } from '@naturalcycles/js-lib'
import { dimGrey, yellow } from '../colors/colors'
import { fs2, globby } from '../index'
import { fs2, fastGlob } from '../index'

export interface DelOptions {
/**
Expand Down Expand Up @@ -57,9 +57,9 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {

// 1. glob only files, expand dirs, delete

const filenames = await globby(patterns, {
const filenames = await fastGlob(patterns, {
dot: true,
expandDirectories: true,
// expandDirectories: true, // todo: test
onlyFiles: true,
})

Expand All @@ -72,9 +72,9 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {
await pMap(filenames, filepath => fs2.removePath(filepath), { concurrency })

// 2. glob only dirs, expand, delete only empty!
let dirnames = await globby(patterns, {
let dirnames = await fastGlob(patterns, {
dot: true,
expandDirectories: true,
// expandDirectories: true, // todo: test
onlyDirectories: true,
})

Expand Down Expand Up @@ -131,9 +131,9 @@ export function delSync(_opt: DelOptions | DelSingleOption): void {

// 1. glob only files, expand dirs, delete

const filenames = globby.sync(patterns, {
const filenames = fastGlob.sync(patterns, {
dot: true,
expandDirectories: true,
// expandDirectories: true, // todo: test
onlyFiles: true,
})

Expand All @@ -146,9 +146,9 @@ export function delSync(_opt: DelOptions | DelSingleOption): void {
filenames.forEach(filepath => fs2.removePath(filepath))

// 2. glob only dirs, expand, delete only empty!
let dirnames = globby.sync(patterns, {
let dirnames = fastGlob.sync(patterns, {
dot: true,
expandDirectories: true,
// expandDirectories: true, // todo: test
onlyDirectories: true,
})

Expand Down
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
- `/` root
- `/bin` cli
- yargs
- globby
- `/script`
- exports `runScript` lightweight function (0 deps)
- `/exec`
Expand Down
2 changes: 1 addition & 1 deletion docs/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Example: `secret1.json` will become `secret1.json.enc`.
Options:

- `--pattern` - directory (pattern) to encrypt (default to `./secret`). Can provide many like
`--pattern p1 p2` or `--pattern p1 --pattern p2`. Supports `globby` pattern, e.g
`--pattern p1 p2` or `--pattern p1 --pattern p2`. Supports "glob" pattern, e.g
`--pattern ./secret/**/*.txt`.
- `--encKey` - provide encryption key
- `--encKeyVar` - read encryption key from env variable with this name (default
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"secrets-encrypt-debug": "tsn ./src/bin/secrets-encrypt.ts",
"secrets-decrypt-debug": "tsn ./src/bin/secrets-decrypt.ts",
"kpy-debug": "tsn ./src/bin/kpy.ts node_modules dist",
"del-debug": "tsn ./src/bin/del.ts dist --verbose --debug",
"json2env-debug": "tsn ./src/bin/json2env.ts ./src/test/someFile.json"
},
"dependencies": {
Expand All @@ -28,7 +27,6 @@
"chalk": "^4.0.0",
"dotenv": "^16.0.0",
"fast-glob": "^3.2.11",
"globby": "^11.0.0",
"joi": "^17.9.2",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^9.0.0",
Expand All @@ -45,7 +43,6 @@
"jest": "^29.0.0"
},
"bin": {
"del": "dist/bin/del.js",
"kpy": "dist/bin/kpy.js",
"json2env": "dist/bin/json2env.js",
"generate-build-info": "dist/bin/generate-build-info.js",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/secrets-encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getEncryptCLIOptions(): EncryptCLIOptions {
pattern: {
type: 'string',
array: true,
desc: 'Globby pattern for secrets. Can be multiple.',
desc: 'Glob pattern for secrets. Can be multiple.',
// demandOption: true,
default: './secret/**',
},
Expand Down
6 changes: 3 additions & 3 deletions src/fs/kpy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path'
import { _since, UnixTimestampMillis } from '@naturalcycles/js-lib'
import { boldWhite, dimGrey, grey, yellow } from '../colors/colors'
import { fs2, globby } from '../index'
import { fastGlob, fs2 } from '../index'

/**
* Everything defaults to `undefined`.
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function kpy(opt: KpyOptions): Promise<void> {

kpyPrepare(opt)

const filenames = await globby(opt.inputPatterns!, {
const filenames = await fastGlob(opt.inputPatterns!, {
cwd: opt.baseDir,
dot: opt.dotfiles,
})
Expand Down Expand Up @@ -86,7 +86,7 @@ export function kpySync(opt: KpyOptions): void {

kpyPrepare(opt)

const filenames = globby.sync(opt.inputPatterns!, {
const filenames = fastGlob.sync(opt.inputPatterns!, {
cwd: opt.baseDir,
dot: opt.dotfiles,
})
Expand Down
6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Ajv from 'ajv'
import type { Options as FastGlobOptions } from 'fast-glob'
import fastGlob from 'fast-glob'
import type { GlobbyOptions } from 'globby'
import globby from 'globby'
import type {
AlternativesSchema,
AnySchema,
Expand All @@ -20,7 +18,6 @@ export * from './csv/csvReader'
export * from './csv/csvWriter'
export * from './csv/transformToCSV'
export * from './diff/tableDiff'
export * from './fs/del'
export * from './fs/fs2'
export * from './fs/json2env'
export * from './fs/kpy'
Expand Down Expand Up @@ -95,12 +92,11 @@ export type {
DateSchema,
FastGlobOptions,
FunctionSchema,
GlobbyOptions,
ObjectSchema,
ValidationErrorItem,
// extended
// NumberSchema,
// StringSchema,
}

export { Ajv, fastGlob, globby }
export { Ajv, fastGlob }

0 comments on commit 882897c

Please sign in to comment.