@stacksjs/utils 0.58.73 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +2 -0
- package/dist/clean.d.ts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/currency.d.ts +3 -0
- package/dist/debounce.d.ts +1 -0
- package/dist/equal.d.ts +1 -0
- package/dist/export-size.d.ts +1 -0
- package/dist/find.d.ts +5 -0
- package/dist/function.d.ts +18 -0
- package/dist/git.d.ts +1 -0
- package/dist/guards.d.ts +28 -0
- package/dist/hash.d.ts +2 -0
- package/dist/helpers.d.ts +52 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +96 -2044
- package/dist/macroable.d.ts +1 -0
- package/dist/math.d.ts +3 -0
- package/dist/p.d.ts +41 -0
- package/dist/promise.d.ts +61 -0
- package/dist/regex.d.ts +2 -0
- package/dist/retry.d.ts +2 -0
- package/dist/sleep.d.ts +32 -0
- package/dist/throttle.d.ts +20 -0
- package/dist/vendors.d.ts +4 -0
- package/dist/versions.d.ts +2 -0
- package/package.json +13 -12
- package/src/clean.ts +11 -13
- package/src/find.ts +47 -41
- package/src/index.ts +0 -1
- package/src/delete.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Macroable } from 'macroable';
|
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
2
|
+
export declare function rand(min: number, max: number): number;
|
|
3
|
+
export { and, createGenericProjection, createProjection, logicNot, logicOr, or, useAbs, useAverage, useCeil, useClamp, useFloor, useMath, useMax, useMin, usePrecision, useProjection, useRound, useSum, useTrunc, } from '@vueuse/math';
|
package/dist/p.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
interface POptions {
|
|
2
|
+
/**
|
|
3
|
+
* How many promises are resolved at the same time.
|
|
4
|
+
*/
|
|
5
|
+
concurrency?: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare class PInstance<T = any> extends Promise<Awaited<T>[]> {
|
|
8
|
+
items: Iterable<T>;
|
|
9
|
+
options?: POptions | undefined;
|
|
10
|
+
private promises;
|
|
11
|
+
get promise(): Promise<Awaited<T>[]>;
|
|
12
|
+
constructor(items?: Iterable<T>, options?: POptions | undefined);
|
|
13
|
+
add(...args: (T | Promise<T>)[]): void;
|
|
14
|
+
map<U>(fn: (value: Awaited<T>, index: number) => U): PInstance<Promise<U>>;
|
|
15
|
+
filter(fn: (value: Awaited<T>, index: number) => boolean | Promise<boolean>): PInstance<Promise<T>>;
|
|
16
|
+
forEach(fn: (value: Awaited<T>, index: number) => void): Promise<void>;
|
|
17
|
+
reduce<U>(fn: (previousValue: U, currentValue: Awaited<T>, currentIndex: number, array: Awaited<T>[]) => U, initialValue: U): Promise<U>;
|
|
18
|
+
clear(): void;
|
|
19
|
+
then(fn?: () => PromiseLike<any>): Promise<any>;
|
|
20
|
+
catch(fn?: (err: unknown) => PromiseLike<any>): Promise<any>;
|
|
21
|
+
finally(fn?: () => void): Promise<Awaited<T>[]>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Utility for managing multiple promises.
|
|
25
|
+
*
|
|
26
|
+
* @see https://github.com/antfu/utils/tree/main/docs/p.md
|
|
27
|
+
* @category Promise
|
|
28
|
+
* @example
|
|
29
|
+
* ```
|
|
30
|
+
* import { p } from '@stacksjs/utils'
|
|
31
|
+
*
|
|
32
|
+
* const items = [1, 2, 3, 4, 5]
|
|
33
|
+
*
|
|
34
|
+
* await p(items)
|
|
35
|
+
* .map(async i => await multiply(i, 3))
|
|
36
|
+
* .filter(async i => await isEven(i))
|
|
37
|
+
* // [6, 12]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function p<T = any>(items?: Iterable<T>, options?: POptions): PInstance<T>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface SingletonPromiseReturn<T> {
|
|
2
|
+
(): Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Reset current staled promise.
|
|
5
|
+
* Await it to have proper shutdown.
|
|
6
|
+
*/
|
|
7
|
+
reset: () => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Promise with `resolve` and `reject` methods of itself
|
|
11
|
+
*/
|
|
12
|
+
export interface ControlledPromise<T = void> extends Promise<T> {
|
|
13
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
14
|
+
reject: (reason?: any) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create singleton promise function.
|
|
18
|
+
*
|
|
19
|
+
* @category Promise
|
|
20
|
+
*/
|
|
21
|
+
export declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a promise lock.
|
|
24
|
+
*
|
|
25
|
+
* @category Promise
|
|
26
|
+
* @example
|
|
27
|
+
* ```
|
|
28
|
+
* const lock = createPromiseLock()
|
|
29
|
+
*
|
|
30
|
+
* lock.run(async () => {
|
|
31
|
+
* await doSomething()
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* // in anther context:
|
|
35
|
+
* await lock.wait() // it will wait all tasking finished
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createPromiseLock(): {
|
|
39
|
+
run<T = void>(fn: () => Promise<T>): Promise<T>;
|
|
40
|
+
wait(): Promise<void>;
|
|
41
|
+
isWaiting(): boolean;
|
|
42
|
+
clear(): void;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Return a Promise with `resolve` and `reject` methods
|
|
46
|
+
*
|
|
47
|
+
* @category Promise
|
|
48
|
+
* @example
|
|
49
|
+
* ```
|
|
50
|
+
* const promise = createControlledPromise()
|
|
51
|
+
*
|
|
52
|
+
* await promise
|
|
53
|
+
*
|
|
54
|
+
* // in anther context:
|
|
55
|
+
* promise.resolve(data)
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function createControlledPromise<T>(): ControlledPromise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Create a promise that will be resolved after `ms` milliseconds.
|
|
61
|
+
*/
|
package/dist/regex.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { Flag, MagicRegExp, MagicRegExpMatchArray, Input, MapToStringCapturedBy, StringCapturedBy } from 'magic-regexp';
|
|
2
|
+
export { createRegExp, caseInsensitive, anyOf, carriageReturn, char, charIn, charNotIn, digit, dotAll, exactly, global, letter, linefeed, maybe, multiline, not, oneOrMore, sticky, tab, unicode, whitespace, withIndices, word, wordBoundary, wordChar } from 'magic-regexp';
|
package/dist/retry.d.ts
ADDED
package/dist/sleep.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified number of milliseconds.
|
|
3
|
+
* @param ms The number of milliseconds to pause execution.
|
|
4
|
+
* @returns A promise that resolves after the specified delay.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Pauses execution for a specified number of milliseconds.
|
|
9
|
+
* @param ms The number of milliseconds to pause execution.
|
|
10
|
+
* @returns A promise that resolves after the specified delay.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wait(ms: number): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Pauses execution for a specified number of milliseconds.
|
|
15
|
+
* @param ms The number of milliseconds to pause execution.
|
|
16
|
+
* @returns A promise that resolves after the specified delay.
|
|
17
|
+
*/
|
|
18
|
+
export declare function delay(ms: number): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Pauses execution until a specified condition is met.
|
|
21
|
+
* @param condition The condition to wait for.
|
|
22
|
+
* @param interval The interval at which to check the condition, in milliseconds. Defaults to 1000.
|
|
23
|
+
* @returns A promise that resolves when the condition is met.
|
|
24
|
+
*/
|
|
25
|
+
export declare function waitUntil(condition: () => boolean, interval?: number): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Pauses execution while a specified condition is met.
|
|
28
|
+
* @param condition The condition to wait while.
|
|
29
|
+
* @param interval The interval at which to check the condition, in milliseconds. Defaults to 1000.
|
|
30
|
+
* @returns A promise that resolves when the condition is no longer met.
|
|
31
|
+
*/
|
|
32
|
+
export declare function waitWhile(condition: () => boolean, interval?: number): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle a function.
|
|
3
|
+
*
|
|
4
|
+
* @param {Function} fn - The function to throttle.
|
|
5
|
+
* @param {number} [wait] - The time to wait between function calls.
|
|
6
|
+
* @returns {Function} - A new function that throttles the calls to the original function.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // logs window dimensions at most every 250ms
|
|
11
|
+
* window.addEventListener(
|
|
12
|
+
* "resize",
|
|
13
|
+
* throttle(function (evt) {
|
|
14
|
+
* console.log(window.innerWidth)
|
|
15
|
+
* console.log(window.innerHeight)
|
|
16
|
+
* }, 250)
|
|
17
|
+
* )
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function throttle(fn: Function, wait?: number): (this: unknown, ...args: any[]) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, cloneFnJSON, computedAsync, computedInject, createFetch, createReusableTemplate, createTemplatePromise, createUnrefFn, customStorageEventName, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, getSSRHandler, mapGamepadToXbox360Controller, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, setSSRHandler, templateRef, unrefElement, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useCloned, useColorMode, useConfirmDialog, useCssVar, useCurrentElement, useCycleList, useDark, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottledRefHistory, useTimeAgo, useTimeoutPoll, useTimestamp, useTitle, useTransition, useToggle, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, useDateFormat, useNow, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever, syncRef, syncRefs, throttledRef, throttledWatch, toReactive, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, isDefined, ignorableWatch, extendRef, eagerComputed, debouncedRef, debouncedWatch, createReactiveFn, createSharedComposable, createInjectionState, createGlobalState, createEventHook, controlledRef, controlledComputed, computedEager, computedWithControl, autoResetRef, injectLocal, makeDestructurable, pausableWatch, provideLocal, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayIncludes, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useClipboardItems, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, } from '@vueuse/core';
|
|
2
|
+
export type { HeadObject, HeadObjectPlain, } from '@vueuse/head';
|
|
3
|
+
export { Head, HeadVuePlugin, createHead, renderHeadToString, } from '@vueuse/head';
|
|
4
|
+
export { default as readableSize } from 'pretty-bytes';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.59.1",
|
|
5
5
|
"description": "The Stacks helper functions.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"@stacksjs/strings": "latest",
|
|
64
64
|
"@stacksjs/types": "latest",
|
|
65
65
|
"@types/js-yaml": "^4.0.9",
|
|
66
|
-
"@vueuse/core": "^10.
|
|
66
|
+
"@vueuse/core": "^10.9.0",
|
|
67
67
|
"@vueuse/head": "^2.0.0",
|
|
68
|
-
"@vueuse/math": "^10.
|
|
69
|
-
"@vueuse/shared": "^10.
|
|
68
|
+
"@vueuse/math": "^10.9.0",
|
|
69
|
+
"@vueuse/shared": "^10.9.0",
|
|
70
|
+
"bun-plugin-env": "^0.4.1",
|
|
71
|
+
"bun-plugin-yml": "^0.3.0",
|
|
70
72
|
"export-size": "^0.7.0",
|
|
71
|
-
"
|
|
72
|
-
"rimraf": "^5.0.5",
|
|
73
|
-
"yaml": "^2.3.4"
|
|
73
|
+
"yaml": "^2.4.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@dinero.js/currencies": "2.0.0-alpha.14",
|
|
@@ -83,10 +83,12 @@
|
|
|
83
83
|
"@stacksjs/storage": "latest",
|
|
84
84
|
"@stacksjs/strings": "latest",
|
|
85
85
|
"@stacksjs/types": "latest",
|
|
86
|
-
"@vueuse/core": "^10.
|
|
86
|
+
"@vueuse/core": "^10.9.0",
|
|
87
87
|
"@vueuse/head": "^2.0.0",
|
|
88
|
-
"@vueuse/math": "^10.
|
|
89
|
-
"@vueuse/shared": "^10.
|
|
88
|
+
"@vueuse/math": "^10.9.0",
|
|
89
|
+
"@vueuse/shared": "^10.9.0",
|
|
90
|
+
"bun-plugin-env": "^0.4.1",
|
|
91
|
+
"bun-plugin-yml": "^0.3.0",
|
|
90
92
|
"defu": "^6.1.4",
|
|
91
93
|
"detect-indent": "^7.0.1",
|
|
92
94
|
"detect-newline": "^4.0.1",
|
|
@@ -99,8 +101,7 @@
|
|
|
99
101
|
"p-limit": "^5.0.0",
|
|
100
102
|
"perfect-debounce": "^1.0.0",
|
|
101
103
|
"pretty-bytes": "^6.1.1",
|
|
102
|
-
"
|
|
103
|
-
"yaml": "^2.3.4"
|
|
104
|
+
"yaml": "^2.4.0"
|
|
104
105
|
},
|
|
105
106
|
"devDependencies": {
|
|
106
107
|
"@stacksjs/development": "latest",
|
package/src/clean.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { path as p } from '@stacksjs/path'
|
|
2
|
-
import {
|
|
2
|
+
import { $ } from 'bun'
|
|
3
3
|
|
|
4
4
|
export async function cleanProject() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
p.frameworkCloudPath('dist.zip'),
|
|
16
|
-
])
|
|
5
|
+
await $`rm -rf ${p.projectPath('bun.lockb')}`
|
|
6
|
+
await $`rm -rf ${p.projectPath('yarn.lock')}` // just in case
|
|
7
|
+
await $`rm -rf ${p.projectPath('node_modules/')}`
|
|
8
|
+
await $`rm -rf ${p.frameworkPath('dist')}`
|
|
9
|
+
await $`rm -rf ${p.frameworkPath('node_modules')}`
|
|
10
|
+
await $`rm -rf ${p.frameworkPath('**/dist')}`
|
|
11
|
+
await $`rm -rf ${p.frameworkPath('**/node_modules')}`
|
|
12
|
+
await $`rm -rf ${p.frameworkCloudPath('cdk.out/')}`
|
|
13
|
+
await $`rm -rf ${p.frameworkCloudPath('cdk.context.json')}`
|
|
14
|
+
await $`rm -rf ${p.frameworkCloudPath('dist.zip')}`
|
|
17
15
|
}
|
package/src/find.ts
CHANGED
|
@@ -11,11 +11,13 @@ const targetFileName = 'buddy' // The exact name of the target file
|
|
|
11
11
|
const excludePatterns = [
|
|
12
12
|
'node_modules',
|
|
13
13
|
'dist',
|
|
14
|
-
|
|
14
|
+
'vendor',
|
|
15
15
|
`${os.homedir()}/Documents`,
|
|
16
16
|
`${os.homedir()}/Pictures`,
|
|
17
17
|
`${os.homedir()}/Library`,
|
|
18
18
|
`${os.homedir()}/.Trash`,
|
|
19
|
+
/.*out.*|.*\.out.*|out-.*/, // exclude any folder with 'out' in the name
|
|
20
|
+
/.*\/\..*/, // exclude any folder that starts with a dot
|
|
19
21
|
]
|
|
20
22
|
|
|
21
23
|
interface FindStacksProjectsOptions {
|
|
@@ -26,7 +28,8 @@ export async function findStacksProjects(dir?: string, options?: FindStacksProje
|
|
|
26
28
|
dir = dir || os.homedir()
|
|
27
29
|
|
|
28
30
|
if (!options?.quiet) {
|
|
29
|
-
log.info(`
|
|
31
|
+
log.info(`Searching for Stacks projects in: ${italic(dir)}`)
|
|
32
|
+
log.info(`This may take a few moments...`)
|
|
30
33
|
// eslint-disable-next-line no-console
|
|
31
34
|
console.log('')
|
|
32
35
|
// eslint-disable-next-line no-console
|
|
@@ -38,54 +41,57 @@ export async function findStacksProjects(dir?: string, options?: FindStacksProje
|
|
|
38
41
|
log.debug(`Excluding directories: ${excludePatterns.join(', ')}`)
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
const foundProjects
|
|
44
|
+
const foundProjects = await searchDirectory(dir)
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
+
if (!foundProjects)
|
|
47
|
+
throw new Error('No Stacks projects found')
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
49
|
+
return foundProjects
|
|
50
|
+
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
items = await fs.readdir(directory, { withFileTypes: true })
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
console.error(`Error reading directory ${directory}:`, error)
|
|
57
|
-
return
|
|
58
|
-
}
|
|
52
|
+
async function searchDirectory(directory: string) {
|
|
53
|
+
const foundProjects: string[] = []
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const isExcluded = excludePatterns.some(pattern => typeof pattern === 'string' ? directory.includes(pattern) : pattern.test(directory))
|
|
56
|
+
if (isExcluded)
|
|
57
|
+
return
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
let items: Dirent[]
|
|
60
|
+
try {
|
|
61
|
+
items = await fs.readdir(directory, { withFileTypes: true })
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error(`Error reading directory ${directory}:`, error)
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let buddyFileFound = false
|
|
69
|
+
let storageDirFound = false
|
|
70
|
+
|
|
71
|
+
for (const item of items) {
|
|
72
|
+
if (item.isFile() && item.name === targetFileName) {
|
|
73
|
+
buddyFileFound = true
|
|
74
|
+
}
|
|
75
|
+
else if (item.isDirectory()) {
|
|
76
|
+
// Recursively search in directories
|
|
77
|
+
const fullPath = path.join(directory, item.name)
|
|
78
|
+
if (item.name === 'storage') {
|
|
79
|
+
// Check if the 'storage/framework/core/buddy/' structure exists within this directory
|
|
80
|
+
try {
|
|
81
|
+
const storagePath = path.join(fullPath, 'framework/core/buddy')
|
|
82
|
+
await fs.access(storagePath)
|
|
83
|
+
storageDirFound = true
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// The specific directory structure does not exist
|
|
80
87
|
}
|
|
81
|
-
await searchDirectory(fullPath)
|
|
82
88
|
}
|
|
89
|
+
await searchDirectory(fullPath)
|
|
83
90
|
}
|
|
84
|
-
|
|
85
|
-
if (buddyFileFound && storageDirFound)
|
|
86
|
-
foundProjects.push(directory) // Both conditions are met
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
if (buddyFileFound && storageDirFound)
|
|
94
|
+
foundProjects.push(directory) // Both conditions are met
|
|
95
|
+
|
|
90
96
|
return foundProjects
|
|
91
97
|
}
|
package/src/index.ts
CHANGED
package/src/delete.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rimraf } from 'rimraf'
|