@dotpi/tools 2.9.2 → 2.9.5

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.
Files changed (110) hide show
  1. package/dotpi_root/bin/dotpi_prepare_system +8 -0
  2. package/dotpi_root/dist/@dotpi/avahi-monitor-module/package.json +1 -1
  3. package/dotpi_root/dist/@dotpi/javascript/package.json +1 -1
  4. package/dotpi_root/dist/@dotpi/module/package.json +2 -2
  5. package/dotpi_root/dist/@dotpi/module-module/package.json +3 -3
  6. package/package.json +5 -5
  7. package/dotpi_root/dist/@dotpi/javascript/node_modules/figures/index.d.ts +0 -279
  8. package/dotpi_root/dist/@dotpi/javascript/node_modules/figures/index.js +0 -292
  9. package/dotpi_root/dist/@dotpi/javascript/node_modules/figures/license +0 -9
  10. package/dotpi_root/dist/@dotpi/javascript/node_modules/figures/package.json +0 -49
  11. package/dotpi_root/dist/@dotpi/javascript/node_modules/figures/readme.md +0 -337
  12. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/LICENSE +0 -201
  13. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/README.md +0 -180
  14. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/build/src/core.js +0 -273
  15. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/build/src/main.d.ts +0 -206
  16. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/build/src/main.js +0 -70
  17. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/build/src/realtime.js +0 -16
  18. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/build/src/signals.js +0 -34
  19. package/dotpi_root/dist/@dotpi/javascript/node_modules/human-signals/package.json +0 -64
  20. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-plain-obj/index.d.ts +0 -35
  21. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-plain-obj/index.js +0 -8
  22. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-plain-obj/license +0 -9
  23. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-plain-obj/package.json +0 -41
  24. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-plain-obj/readme.md +0 -58
  25. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-unicode-supported/index.d.ts +0 -12
  26. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-unicode-supported/index.js +0 -21
  27. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-unicode-supported/license +0 -9
  28. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-unicode-supported/package.json +0 -47
  29. package/dotpi_root/dist/@dotpi/javascript/node_modules/is-unicode-supported/readme.md +0 -35
  30. package/dotpi_root/dist/@dotpi/javascript/node_modules/npm-run-path/index.d.ts +0 -90
  31. package/dotpi_root/dist/@dotpi/javascript/node_modules/npm-run-path/index.js +0 -55
  32. package/dotpi_root/dist/@dotpi/javascript/node_modules/npm-run-path/license +0 -9
  33. package/dotpi_root/dist/@dotpi/javascript/node_modules/npm-run-path/package.json +0 -52
  34. package/dotpi_root/dist/@dotpi/javascript/node_modules/npm-run-path/readme.md +0 -104
  35. package/dotpi_root/dist/@dotpi/javascript/node_modules/path-key/index.d.ts +0 -31
  36. package/dotpi_root/dist/@dotpi/javascript/node_modules/path-key/index.js +0 -12
  37. package/dotpi_root/dist/@dotpi/javascript/node_modules/path-key/license +0 -9
  38. package/dotpi_root/dist/@dotpi/javascript/node_modules/path-key/package.json +0 -41
  39. package/dotpi_root/dist/@dotpi/javascript/node_modules/path-key/readme.md +0 -57
  40. package/dotpi_root/dist/@dotpi/javascript/node_modules/strip-final-newline/index.d.ts +0 -18
  41. package/dotpi_root/dist/@dotpi/javascript/node_modules/strip-final-newline/index.js +0 -26
  42. package/dotpi_root/dist/@dotpi/javascript/node_modules/strip-final-newline/license +0 -9
  43. package/dotpi_root/dist/@dotpi/javascript/node_modules/strip-final-newline/package.json +0 -49
  44. package/dotpi_root/dist/@dotpi/javascript/node_modules/strip-final-newline/readme.md +0 -34
  45. package/dotpi_root/dist/@dotpi/module/node_modules/figures/index.d.ts +0 -279
  46. package/dotpi_root/dist/@dotpi/module/node_modules/figures/index.js +0 -292
  47. package/dotpi_root/dist/@dotpi/module/node_modules/figures/license +0 -9
  48. package/dotpi_root/dist/@dotpi/module/node_modules/figures/package.json +0 -49
  49. package/dotpi_root/dist/@dotpi/module/node_modules/figures/readme.md +0 -337
  50. package/dotpi_root/dist/@dotpi/module/node_modules/globby/ignore.js +0 -109
  51. package/dotpi_root/dist/@dotpi/module/node_modules/globby/index.d.ts +0 -207
  52. package/dotpi_root/dist/@dotpi/module/node_modules/globby/index.js +0 -264
  53. package/dotpi_root/dist/@dotpi/module/node_modules/globby/license +0 -9
  54. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/@sindresorhus/merge-streams/index.d.ts +0 -44
  55. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/@sindresorhus/merge-streams/index.js +0 -223
  56. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/@sindresorhus/merge-streams/license +0 -9
  57. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/@sindresorhus/merge-streams/package.json +0 -49
  58. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/@sindresorhus/merge-streams/readme.md +0 -53
  59. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/default.js +0 -14
  60. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/index.d.ts +0 -29
  61. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/license +0 -9
  62. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/node.js +0 -7
  63. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/package.json +0 -49
  64. package/dotpi_root/dist/@dotpi/module/node_modules/globby/node_modules/unicorn-magic/readme.md +0 -25
  65. package/dotpi_root/dist/@dotpi/module/node_modules/globby/package.json +0 -94
  66. package/dotpi_root/dist/@dotpi/module/node_modules/globby/readme.md +0 -177
  67. package/dotpi_root/dist/@dotpi/module/node_modules/globby/utilities.js +0 -1
  68. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/LICENSE +0 -201
  69. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/README.md +0 -180
  70. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/build/src/core.js +0 -273
  71. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/build/src/main.d.ts +0 -206
  72. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/build/src/main.js +0 -70
  73. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/build/src/realtime.js +0 -16
  74. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/build/src/signals.js +0 -34
  75. package/dotpi_root/dist/@dotpi/module/node_modules/human-signals/package.json +0 -64
  76. package/dotpi_root/dist/@dotpi/module/node_modules/is-plain-obj/index.d.ts +0 -35
  77. package/dotpi_root/dist/@dotpi/module/node_modules/is-plain-obj/index.js +0 -8
  78. package/dotpi_root/dist/@dotpi/module/node_modules/is-plain-obj/license +0 -9
  79. package/dotpi_root/dist/@dotpi/module/node_modules/is-plain-obj/package.json +0 -41
  80. package/dotpi_root/dist/@dotpi/module/node_modules/is-plain-obj/readme.md +0 -58
  81. package/dotpi_root/dist/@dotpi/module/node_modules/is-unicode-supported/index.d.ts +0 -12
  82. package/dotpi_root/dist/@dotpi/module/node_modules/is-unicode-supported/index.js +0 -21
  83. package/dotpi_root/dist/@dotpi/module/node_modules/is-unicode-supported/license +0 -9
  84. package/dotpi_root/dist/@dotpi/module/node_modules/is-unicode-supported/package.json +0 -47
  85. package/dotpi_root/dist/@dotpi/module/node_modules/is-unicode-supported/readme.md +0 -35
  86. package/dotpi_root/dist/@dotpi/module/node_modules/npm-run-path/index.d.ts +0 -90
  87. package/dotpi_root/dist/@dotpi/module/node_modules/npm-run-path/index.js +0 -55
  88. package/dotpi_root/dist/@dotpi/module/node_modules/npm-run-path/license +0 -9
  89. package/dotpi_root/dist/@dotpi/module/node_modules/npm-run-path/package.json +0 -52
  90. package/dotpi_root/dist/@dotpi/module/node_modules/npm-run-path/readme.md +0 -104
  91. package/dotpi_root/dist/@dotpi/module/node_modules/path-key/index.d.ts +0 -31
  92. package/dotpi_root/dist/@dotpi/module/node_modules/path-key/index.js +0 -12
  93. package/dotpi_root/dist/@dotpi/module/node_modules/path-key/license +0 -9
  94. package/dotpi_root/dist/@dotpi/module/node_modules/path-key/package.json +0 -41
  95. package/dotpi_root/dist/@dotpi/module/node_modules/path-key/readme.md +0 -57
  96. package/dotpi_root/dist/@dotpi/module/node_modules/path-type/index.d.ts +0 -51
  97. package/dotpi_root/dist/@dotpi/module/node_modules/path-type/index.js +0 -41
  98. package/dotpi_root/dist/@dotpi/module/node_modules/path-type/license +0 -9
  99. package/dotpi_root/dist/@dotpi/module/node_modules/path-type/package.json +0 -47
  100. package/dotpi_root/dist/@dotpi/module/node_modules/path-type/readme.md +0 -74
  101. package/dotpi_root/dist/@dotpi/module/node_modules/slash/index.d.ts +0 -23
  102. package/dotpi_root/dist/@dotpi/module/node_modules/slash/index.js +0 -9
  103. package/dotpi_root/dist/@dotpi/module/node_modules/slash/license +0 -9
  104. package/dotpi_root/dist/@dotpi/module/node_modules/slash/package.json +0 -39
  105. package/dotpi_root/dist/@dotpi/module/node_modules/slash/readme.md +0 -36
  106. package/dotpi_root/dist/@dotpi/module/node_modules/strip-final-newline/index.d.ts +0 -18
  107. package/dotpi_root/dist/@dotpi/module/node_modules/strip-final-newline/index.js +0 -26
  108. package/dotpi_root/dist/@dotpi/module/node_modules/strip-final-newline/license +0 -9
  109. package/dotpi_root/dist/@dotpi/module/node_modules/strip-final-newline/package.json +0 -49
  110. package/dotpi_root/dist/@dotpi/module/node_modules/strip-final-newline/readme.md +0 -34
@@ -1,109 +0,0 @@
1
- import process from 'node:process';
2
- import fs from 'node:fs';
3
- import fsPromises from 'node:fs/promises';
4
- import path from 'node:path';
5
- import fastGlob from 'fast-glob';
6
- import gitIgnore from 'ignore';
7
- import slash from 'slash';
8
- import {toPath} from 'unicorn-magic';
9
- import {isNegativePattern} from './utilities.js';
10
-
11
- const defaultIgnoredDirectories = [
12
- '**/node_modules',
13
- '**/flow-typed',
14
- '**/coverage',
15
- '**/.git',
16
- ];
17
- const ignoreFilesGlobOptions = {
18
- absolute: true,
19
- dot: true,
20
- };
21
-
22
- export const GITIGNORE_FILES_PATTERN = '**/.gitignore';
23
-
24
- const applyBaseToPattern = (pattern, base) => isNegativePattern(pattern)
25
- ? '!' + path.posix.join(base, pattern.slice(1))
26
- : path.posix.join(base, pattern);
27
-
28
- const parseIgnoreFile = (file, cwd) => {
29
- const base = slash(path.relative(cwd, path.dirname(file.filePath)));
30
-
31
- return file.content
32
- .split(/\r?\n/)
33
- .filter(line => line && !line.startsWith('#'))
34
- .map(pattern => applyBaseToPattern(pattern, base));
35
- };
36
-
37
- const toRelativePath = (fileOrDirectory, cwd) => {
38
- cwd = slash(cwd);
39
- if (path.isAbsolute(fileOrDirectory)) {
40
- if (slash(fileOrDirectory).startsWith(cwd)) {
41
- return path.relative(cwd, fileOrDirectory);
42
- }
43
-
44
- throw new Error(`Path ${fileOrDirectory} is not in cwd ${cwd}`);
45
- }
46
-
47
- return fileOrDirectory;
48
- };
49
-
50
- const getIsIgnoredPredicate = (files, cwd) => {
51
- const patterns = files.flatMap(file => parseIgnoreFile(file, cwd));
52
- const ignores = gitIgnore().add(patterns);
53
-
54
- return fileOrDirectory => {
55
- fileOrDirectory = toPath(fileOrDirectory);
56
- fileOrDirectory = toRelativePath(fileOrDirectory, cwd);
57
- return fileOrDirectory ? ignores.ignores(slash(fileOrDirectory)) : false;
58
- };
59
- };
60
-
61
- const normalizeOptions = (options = {}) => ({
62
- cwd: toPath(options.cwd) ?? process.cwd(),
63
- suppressErrors: Boolean(options.suppressErrors),
64
- deep: typeof options.deep === 'number' ? options.deep : Number.POSITIVE_INFINITY,
65
- ignore: [...options.ignore ?? [], ...defaultIgnoredDirectories],
66
- });
67
-
68
- export const isIgnoredByIgnoreFiles = async (patterns, options) => {
69
- const {cwd, suppressErrors, deep, ignore} = normalizeOptions(options);
70
-
71
- const paths = await fastGlob(patterns, {
72
- cwd,
73
- suppressErrors,
74
- deep,
75
- ignore,
76
- ...ignoreFilesGlobOptions,
77
- });
78
-
79
- const files = await Promise.all(
80
- paths.map(async filePath => ({
81
- filePath,
82
- content: await fsPromises.readFile(filePath, 'utf8'),
83
- })),
84
- );
85
-
86
- return getIsIgnoredPredicate(files, cwd);
87
- };
88
-
89
- export const isIgnoredByIgnoreFilesSync = (patterns, options) => {
90
- const {cwd, suppressErrors, deep, ignore} = normalizeOptions(options);
91
-
92
- const paths = fastGlob.sync(patterns, {
93
- cwd,
94
- suppressErrors,
95
- deep,
96
- ignore,
97
- ...ignoreFilesGlobOptions,
98
- });
99
-
100
- const files = paths.map(filePath => ({
101
- filePath,
102
- content: fs.readFileSync(filePath, 'utf8'),
103
- }));
104
-
105
- return getIsIgnoredPredicate(files, cwd);
106
- };
107
-
108
- export const isGitIgnored = options => isIgnoredByIgnoreFiles(GITIGNORE_FILES_PATTERN, options);
109
- export const isGitIgnoredSync = options => isIgnoredByIgnoreFilesSync(GITIGNORE_FILES_PATTERN, options);
@@ -1,207 +0,0 @@
1
- import type FastGlob from 'fast-glob';
2
-
3
- export type GlobEntry = FastGlob.Entry;
4
-
5
- export type GlobTask = {
6
- readonly patterns: string[];
7
- readonly options: Options;
8
- };
9
-
10
- export type ExpandDirectoriesOption =
11
- | boolean
12
- | readonly string[]
13
- | {files?: readonly string[]; extensions?: readonly string[]};
14
-
15
- type FastGlobOptionsWithoutCwd = Omit<FastGlob.Options, 'cwd'>;
16
-
17
- export type Options = {
18
- /**
19
- If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like in the example below.
20
-
21
- Note that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`.
22
-
23
- @default true
24
-
25
- @example
26
- ```
27
- import {globby} from 'globby';
28
-
29
- const paths = await globby('images', {
30
- expandDirectories: {
31
- files: ['cat', 'unicorn', '*.jpg'],
32
- extensions: ['png']
33
- }
34
- });
35
-
36
- console.log(paths);
37
- //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
38
- ```
39
- */
40
- readonly expandDirectories?: ExpandDirectoriesOption;
41
-
42
- /**
43
- Respect ignore patterns in `.gitignore` files that apply to the globbed files.
44
-
45
- @default false
46
- */
47
- readonly gitignore?: boolean;
48
-
49
- /**
50
- Glob patterns to look for ignore files, which are then used to ignore globbed files.
51
-
52
- This is a more generic form of the `gitignore` option, allowing you to find ignore files with a [compatible syntax](http://git-scm.com/docs/gitignore). For instance, this works with Babel's `.babelignore`, Prettier's `.prettierignore`, or ESLint's `.eslintignore` files.
53
-
54
- @default undefined
55
- */
56
- readonly ignoreFiles?: string | readonly string[];
57
-
58
- /**
59
- The current working directory in which to search.
60
-
61
- @default process.cwd()
62
- */
63
- readonly cwd?: URL | string;
64
- } & FastGlobOptionsWithoutCwd;
65
-
66
- export type GitignoreOptions = {
67
- readonly cwd?: URL | string;
68
- };
69
-
70
- export type GlobbyFilterFunction = (path: URL | string) => boolean;
71
-
72
- /**
73
- Find files and directories using glob patterns.
74
-
75
- Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
76
-
77
- @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
78
- @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
79
- @returns The matching paths.
80
-
81
- @example
82
- ```
83
- import {globby} from 'globby';
84
-
85
- const paths = await globby(['*', '!cake']);
86
-
87
- console.log(paths);
88
- //=> ['unicorn', 'rainbow']
89
- ```
90
- */
91
- export function globby(
92
- patterns: string | readonly string[],
93
- options: Options & {objectMode: true}
94
- ): Promise<GlobEntry[]>;
95
- export function globby(
96
- patterns: string | readonly string[],
97
- options?: Options
98
- ): Promise<string[]>;
99
-
100
- /**
101
- Find files and directories using glob patterns.
102
-
103
- Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
104
-
105
- @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
106
- @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
107
- @returns The matching paths.
108
- */
109
- export function globbySync(
110
- patterns: string | readonly string[],
111
- options: Options & {objectMode: true}
112
- ): GlobEntry[];
113
- export function globbySync(
114
- patterns: string | readonly string[],
115
- options?: Options
116
- ): string[];
117
-
118
- /**
119
- Find files and directories using glob patterns.
120
-
121
- Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
122
-
123
- @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
124
- @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
125
- @returns The stream of matching paths.
126
-
127
- @example
128
- ```
129
- import {globbyStream} from 'globby';
130
-
131
- for await (const path of globbyStream('*.tmp')) {
132
- console.log(path);
133
- }
134
- ```
135
- */
136
- export function globbyStream(
137
- patterns: string | readonly string[],
138
- options?: Options
139
- ): NodeJS.ReadableStream;
140
-
141
- /**
142
- Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
143
-
144
- @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
145
- @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
146
- @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
147
- */
148
- export function generateGlobTasks(
149
- patterns: string | readonly string[],
150
- options?: Options
151
- ): Promise<GlobTask[]>;
152
-
153
- /**
154
- @see generateGlobTasks
155
-
156
- @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
157
- */
158
- export function generateGlobTasksSync(
159
- patterns: string | readonly string[],
160
- options?: Options
161
- ): GlobTask[];
162
-
163
- /**
164
- Note that the options affect the results.
165
-
166
- This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
167
-
168
- @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
169
- @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
170
- @returns Whether there are any special glob characters in the `patterns`.
171
- */
172
- export function isDynamicPattern(
173
- patterns: string | readonly string[],
174
- options?: FastGlobOptionsWithoutCwd & {
175
- /**
176
- The current working directory in which to search.
177
-
178
- @default process.cwd()
179
- */
180
- readonly cwd?: URL | string;
181
- }
182
- ): boolean;
183
-
184
- /**
185
- `.gitignore` files matched by the ignore config are not used for the resulting filter function.
186
-
187
- @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
188
-
189
- @example
190
- ```
191
- import {isGitIgnored} from 'globby';
192
-
193
- const isIgnored = await isGitIgnored();
194
-
195
- console.log(isIgnored('some/file'));
196
- ```
197
- */
198
- export function isGitIgnored(options?: GitignoreOptions): Promise<GlobbyFilterFunction>;
199
-
200
- /**
201
- @see isGitIgnored
202
-
203
- @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
204
- */
205
- export function isGitIgnoredSync(options?: GitignoreOptions): GlobbyFilterFunction;
206
-
207
- export function convertPathToPattern(source: string): FastGlob.Pattern;
@@ -1,264 +0,0 @@
1
- import process from 'node:process';
2
- import fs from 'node:fs';
3
- import nodePath from 'node:path';
4
- import mergeStreams from '@sindresorhus/merge-streams';
5
- import fastGlob from 'fast-glob';
6
- import {isDirectory, isDirectorySync} from 'path-type';
7
- import {toPath} from 'unicorn-magic';
8
- import {
9
- GITIGNORE_FILES_PATTERN,
10
- isIgnoredByIgnoreFiles,
11
- isIgnoredByIgnoreFilesSync,
12
- } from './ignore.js';
13
- import {isNegativePattern} from './utilities.js';
14
-
15
- const assertPatternsInput = patterns => {
16
- if (patterns.some(pattern => typeof pattern !== 'string')) {
17
- throw new TypeError('Patterns must be a string or an array of strings');
18
- }
19
- };
20
-
21
- const normalizePathForDirectoryGlob = (filePath, cwd) => {
22
- const path = isNegativePattern(filePath) ? filePath.slice(1) : filePath;
23
- return nodePath.isAbsolute(path) ? path : nodePath.join(cwd, path);
24
- };
25
-
26
- const getDirectoryGlob = ({directoryPath, files, extensions}) => {
27
- const extensionGlob = extensions?.length > 0 ? `.${extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]}` : '';
28
- return files
29
- ? files.map(file => nodePath.posix.join(directoryPath, `**/${nodePath.extname(file) ? file : `${file}${extensionGlob}`}`))
30
- : [nodePath.posix.join(directoryPath, `**${extensionGlob ? `/*${extensionGlob}` : ''}`)];
31
- };
32
-
33
- const directoryToGlob = async (directoryPaths, {
34
- cwd = process.cwd(),
35
- files,
36
- extensions,
37
- } = {}) => {
38
- const globs = await Promise.all(directoryPaths.map(async directoryPath =>
39
- (await isDirectory(normalizePathForDirectoryGlob(directoryPath, cwd))) ? getDirectoryGlob({directoryPath, files, extensions}) : directoryPath),
40
- );
41
-
42
- return globs.flat();
43
- };
44
-
45
- const directoryToGlobSync = (directoryPaths, {
46
- cwd = process.cwd(),
47
- files,
48
- extensions,
49
- } = {}) => directoryPaths.flatMap(directoryPath => isDirectorySync(normalizePathForDirectoryGlob(directoryPath, cwd)) ? getDirectoryGlob({directoryPath, files, extensions}) : directoryPath);
50
-
51
- const toPatternsArray = patterns => {
52
- patterns = [...new Set([patterns].flat())];
53
- assertPatternsInput(patterns);
54
- return patterns;
55
- };
56
-
57
- const checkCwdOption = cwd => {
58
- if (!cwd) {
59
- return;
60
- }
61
-
62
- let stat;
63
- try {
64
- stat = fs.statSync(cwd);
65
- } catch {
66
- return;
67
- }
68
-
69
- if (!stat.isDirectory()) {
70
- throw new Error('The `cwd` option must be a path to a directory');
71
- }
72
- };
73
-
74
- const normalizeOptions = (options = {}) => {
75
- options = {
76
- ...options,
77
- ignore: options.ignore ?? [],
78
- expandDirectories: options.expandDirectories ?? true,
79
- cwd: toPath(options.cwd),
80
- };
81
-
82
- checkCwdOption(options.cwd);
83
-
84
- return options;
85
- };
86
-
87
- const normalizeArguments = function_ => async (patterns, options) => function_(toPatternsArray(patterns), normalizeOptions(options));
88
- const normalizeArgumentsSync = function_ => (patterns, options) => function_(toPatternsArray(patterns), normalizeOptions(options));
89
-
90
- const getIgnoreFilesPatterns = options => {
91
- const {ignoreFiles, gitignore} = options;
92
-
93
- const patterns = ignoreFiles ? toPatternsArray(ignoreFiles) : [];
94
- if (gitignore) {
95
- patterns.push(GITIGNORE_FILES_PATTERN);
96
- }
97
-
98
- return patterns;
99
- };
100
-
101
- const getFilter = async options => {
102
- const ignoreFilesPatterns = getIgnoreFilesPatterns(options);
103
- return createFilterFunction(
104
- ignoreFilesPatterns.length > 0 && await isIgnoredByIgnoreFiles(ignoreFilesPatterns, options),
105
- );
106
- };
107
-
108
- const getFilterSync = options => {
109
- const ignoreFilesPatterns = getIgnoreFilesPatterns(options);
110
- return createFilterFunction(
111
- ignoreFilesPatterns.length > 0 && isIgnoredByIgnoreFilesSync(ignoreFilesPatterns, options),
112
- );
113
- };
114
-
115
- const createFilterFunction = isIgnored => {
116
- const seen = new Set();
117
-
118
- return fastGlobResult => {
119
- const pathKey = nodePath.normalize(fastGlobResult.path ?? fastGlobResult);
120
-
121
- if (seen.has(pathKey) || (isIgnored && isIgnored(pathKey))) {
122
- return false;
123
- }
124
-
125
- seen.add(pathKey);
126
-
127
- return true;
128
- };
129
- };
130
-
131
- const unionFastGlobResults = (results, filter) => results.flat().filter(fastGlobResult => filter(fastGlobResult));
132
-
133
- const convertNegativePatterns = (patterns, options) => {
134
- const tasks = [];
135
-
136
- while (patterns.length > 0) {
137
- const index = patterns.findIndex(pattern => isNegativePattern(pattern));
138
-
139
- if (index === -1) {
140
- tasks.push({patterns, options});
141
- break;
142
- }
143
-
144
- const ignorePattern = patterns[index].slice(1);
145
-
146
- for (const task of tasks) {
147
- task.options.ignore.push(ignorePattern);
148
- }
149
-
150
- if (index !== 0) {
151
- tasks.push({
152
- patterns: patterns.slice(0, index),
153
- options: {
154
- ...options,
155
- ignore: [
156
- ...options.ignore,
157
- ignorePattern,
158
- ],
159
- },
160
- });
161
- }
162
-
163
- patterns = patterns.slice(index + 1);
164
- }
165
-
166
- return tasks;
167
- };
168
-
169
- const normalizeExpandDirectoriesOption = (options, cwd) => ({
170
- ...(cwd ? {cwd} : {}),
171
- ...(Array.isArray(options) ? {files: options} : options),
172
- });
173
-
174
- const generateTasks = async (patterns, options) => {
175
- const globTasks = convertNegativePatterns(patterns, options);
176
-
177
- const {cwd, expandDirectories} = options;
178
-
179
- if (!expandDirectories) {
180
- return globTasks;
181
- }
182
-
183
- const directoryToGlobOptions = normalizeExpandDirectoriesOption(expandDirectories, cwd);
184
-
185
- return Promise.all(
186
- globTasks.map(async task => {
187
- let {patterns, options} = task;
188
-
189
- [
190
- patterns,
191
- options.ignore,
192
- ] = await Promise.all([
193
- directoryToGlob(patterns, directoryToGlobOptions),
194
- directoryToGlob(options.ignore, {cwd}),
195
- ]);
196
-
197
- return {patterns, options};
198
- }),
199
- );
200
- };
201
-
202
- const generateTasksSync = (patterns, options) => {
203
- const globTasks = convertNegativePatterns(patterns, options);
204
- const {cwd, expandDirectories} = options;
205
-
206
- if (!expandDirectories) {
207
- return globTasks;
208
- }
209
-
210
- const directoryToGlobSyncOptions = normalizeExpandDirectoriesOption(expandDirectories, cwd);
211
-
212
- return globTasks.map(task => {
213
- let {patterns, options} = task;
214
- patterns = directoryToGlobSync(patterns, directoryToGlobSyncOptions);
215
- options.ignore = directoryToGlobSync(options.ignore, {cwd});
216
- return {patterns, options};
217
- });
218
- };
219
-
220
- export const globby = normalizeArguments(async (patterns, options) => {
221
- const [
222
- tasks,
223
- filter,
224
- ] = await Promise.all([
225
- generateTasks(patterns, options),
226
- getFilter(options),
227
- ]);
228
-
229
- const results = await Promise.all(tasks.map(task => fastGlob(task.patterns, task.options)));
230
- return unionFastGlobResults(results, filter);
231
- });
232
-
233
- export const globbySync = normalizeArgumentsSync((patterns, options) => {
234
- const tasks = generateTasksSync(patterns, options);
235
- const filter = getFilterSync(options);
236
- const results = tasks.map(task => fastGlob.sync(task.patterns, task.options));
237
- return unionFastGlobResults(results, filter);
238
- });
239
-
240
- export const globbyStream = normalizeArgumentsSync((patterns, options) => {
241
- const tasks = generateTasksSync(patterns, options);
242
- const filter = getFilterSync(options);
243
- const streams = tasks.map(task => fastGlob.stream(task.patterns, task.options));
244
- const stream = mergeStreams(streams).filter(fastGlobResult => filter(fastGlobResult));
245
-
246
- // TODO: Make it return a web stream at some point.
247
- // return Readable.toWeb(stream);
248
-
249
- return stream;
250
- });
251
-
252
- export const isDynamicPattern = normalizeArgumentsSync(
253
- (patterns, options) => patterns.some(pattern => fastGlob.isDynamicPattern(pattern, options)),
254
- );
255
-
256
- export const generateGlobTasks = normalizeArguments(generateTasks);
257
- export const generateGlobTasksSync = normalizeArgumentsSync(generateTasksSync);
258
-
259
- export {
260
- isGitIgnored,
261
- isGitIgnoredSync,
262
- } from './ignore.js';
263
-
264
- export const {convertPathToPattern} = fastGlob;
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,44 +0,0 @@
1
- import {type Readable} from 'node:stream';
2
-
3
- /**
4
- Merges an array of [readable streams](https://nodejs.org/api/stream.html#readable-streams) and returns a new readable stream that emits data from the individual streams as it arrives.
5
-
6
- If you provide an empty array, it returns an already-ended stream.
7
-
8
- @example
9
- ```
10
- import mergeStreams from '@sindresorhus/merge-streams';
11
-
12
- const stream = mergeStreams([streamA, streamB]);
13
-
14
- for await (const chunk of stream) {
15
- console.log(chunk);
16
- //=> 'A1'
17
- //=> 'B1'
18
- //=> 'A2'
19
- //=> 'B2'
20
- }
21
- ```
22
- */
23
- export default function mergeStreams(streams: Readable[]): MergedStream;
24
-
25
- /**
26
- A single stream combining the output of multiple streams.
27
- */
28
- export class MergedStream extends Readable {
29
- /**
30
- Pipe a new readable stream.
31
-
32
- Throws if `MergedStream` has already ended.
33
- */
34
- add(stream: Readable): void;
35
-
36
- /**
37
- Unpipe a stream previously added using either `mergeStreams(streams)` or `MergedStream.add(stream)`.
38
-
39
- Returns `false` if the stream was not previously added, or if it was already removed by `MergedStream.remove(stream)`.
40
-
41
- The removed stream is not automatically ended.
42
- */
43
- remove(stream: Readable): boolean;
44
- }