@alchemy.run/node-utils 0.0.4 → 2.0.0-beta.72

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 (49) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/THIRD_PARTY_LICENSES.md +138 -0
  4. package/lib/ignore.d.ts +52 -2
  5. package/lib/ignore.d.ts.map +1 -1
  6. package/lib/ignore.js +50 -61
  7. package/lib/ignore.js.map +1 -1
  8. package/package.json +33 -31
  9. package/src/ignore.ts +157 -105
  10. package/lib/adapter.d.ts +0 -14
  11. package/lib/adapter.d.ts.map +0 -1
  12. package/lib/adapter.js +0 -65
  13. package/lib/adapter.js.map +0 -1
  14. package/lib/exit-hook.d.ts +0 -22
  15. package/lib/exit-hook.d.ts.map +0 -1
  16. package/lib/exit-hook.js +0 -86
  17. package/lib/exit-hook.js.map +0 -1
  18. package/lib/foreground-child.d.ts +0 -57
  19. package/lib/foreground-child.d.ts.map +0 -1
  20. package/lib/foreground-child.js +0 -201
  21. package/lib/foreground-child.js.map +0 -1
  22. package/lib/index.d.ts +0 -6
  23. package/lib/index.d.ts.map +0 -1
  24. package/lib/index.js +0 -6
  25. package/lib/index.js.map +0 -1
  26. package/lib/lockfile-async.d.ts +0 -9
  27. package/lib/lockfile-async.d.ts.map +0 -1
  28. package/lib/lockfile-async.js +0 -23
  29. package/lib/lockfile-async.js.map +0 -1
  30. package/lib/lockfile.d.ts +0 -53
  31. package/lib/lockfile.d.ts.map +0 -1
  32. package/lib/lockfile.js +0 -287
  33. package/lib/lockfile.js.map +0 -1
  34. package/lib/mtime-precision.d.ts +0 -11
  35. package/lib/mtime-precision.d.ts.map +0 -1
  36. package/lib/mtime-precision.js +0 -40
  37. package/lib/mtime-precision.js.map +0 -1
  38. package/lib/retry.d.ts +0 -56
  39. package/lib/retry.d.ts.map +0 -1
  40. package/lib/retry.js +0 -203
  41. package/lib/retry.js.map +0 -1
  42. package/src/adapter.ts +0 -94
  43. package/src/exit-hook.ts +0 -96
  44. package/src/foreground-child.ts +0 -243
  45. package/src/index.ts +0 -5
  46. package/src/lockfile-async.ts +0 -44
  47. package/src/lockfile.ts +0 -502
  48. package/src/mtime-precision.ts +0 -83
  49. package/src/retry.ts +0 -309
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Alchemy
2
+ Copyright 2026 Functionless Corp.
3
+
4
+ This product includes software developed by third parties. See
5
+ THIRD_PARTY_LICENSES.md for attribution and license details.
@@ -0,0 +1,138 @@
1
+ # Third-Party Licenses
2
+
3
+ Alchemy is licensed under the Apache License 2.0. Portions of the repository
4
+ are derived from the projects listed below and remain subject to their
5
+ respective license notices.
6
+
7
+ ## Astro
8
+
9
+ Portions of `packages/cloudflare-frameworks/src/astro` are derived from
10
+ `@astrojs/cloudflare`.
11
+
12
+ Copyright (c) 2021 Fred K. Schott
13
+
14
+ MIT License
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
33
+
34
+ ## SvelteKit
35
+
36
+ Portions of `packages/cloudflare-frameworks/src/sveltekit` are derived from
37
+ `@sveltejs/adapter-cloudflare`.
38
+
39
+ Copyright (c) 2020 SvelteKit contributors
40
+
41
+ The SvelteKit portions are provided under the MIT License reproduced in the
42
+ Astro section above.
43
+
44
+ ## Waku
45
+
46
+ Portions of `packages/cloudflare-frameworks/src/waku` are derived from Waku.
47
+
48
+ Copyright (c) 2023 Daishi Kato
49
+
50
+ The Waku portions are provided under the MIT License reproduced in the Astro
51
+ section above.
52
+
53
+ ## Cloudflare Workers SDK and Miniflare
54
+
55
+ Portions of `packages/cloudflare-runtime`, including the vendored
56
+ `workers-shared` and `workflows-shared` source trees and local binding
57
+ implementations adapted from Miniflare, are derived from Cloudflare's
58
+ `workers-sdk` repository. Alchemy uses these portions under the MIT option of
59
+ the upstream `MIT OR Apache-2.0` license.
60
+
61
+ Copyright (c) 2020 Cloudflare, Inc. <wrangler@cloudflare.com>
62
+
63
+ The Cloudflare Workers SDK and Miniflare portions are provided under the MIT
64
+ License reproduced in the Astro section above.
65
+
66
+ ## OpenNext for Cloudflare
67
+
68
+ Portions of `packages/cloudflare-frameworks/src/nextjs`, including the build
69
+ runner and development-context integration, are derived from OpenNext for
70
+ Cloudflare.
71
+
72
+ Copyright (c) 2020 Cloudflare, Inc.
73
+
74
+ The OpenNext portions are provided under the MIT License reproduced in the
75
+ Astro section above.
76
+
77
+ ## SST
78
+
79
+ `packages/alchemy/src/AWS/Website/cfcode.ts` contains CloudFront Function code
80
+ ported from SST's Router component.
81
+
82
+ Copyright (c) 2024 SST
83
+
84
+ The SST portions are provided under the MIT License reproduced in the Astro
85
+ section above.
86
+
87
+ ## node-sanitize-filename
88
+
89
+ Path-sanitization expressions in
90
+ `packages/cloudflare-runtime/src/core/internal/shared.worker.ts` are adapted
91
+ from `node-sanitize-filename` and used under its ISC license option.
92
+
93
+ Copyright Parsha Pourkhomami
94
+
95
+ Permission to use, copy, modify, and/or distribute this software for any
96
+ purpose with or without fee is hereby granted, provided that the above
97
+ copyright notice and this permission notice appear in all copies.
98
+
99
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
100
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
101
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
102
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
103
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
104
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
105
+ PERFORMANCE OF THIS SOFTWARE.
106
+
107
+ ## node-ignore
108
+
109
+ `packages/node-utils/src/ignore.ts` is a TypeScript port
110
+ of `ignore` (node-ignore) v7.0.5.
111
+
112
+ Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
113
+
114
+ The node-ignore portions are provided under the MIT License reproduced in the
115
+ Astro section above.
116
+
117
+ ## SQLite
118
+
119
+ The D1 simulator contains a TypeScript port of SQLite shell quoting logic.
120
+ SQLite's deliverable source code, including its command-line interface, has
121
+ been dedicated to the public domain. See <https://www.sqlite.org/copyright.html>.
122
+
123
+ ## Upstream source references
124
+
125
+ - Astro: <https://github.com/withastro/astro>
126
+ - SvelteKit: <https://github.com/sveltejs/kit>
127
+ - Waku: <https://github.com/wakujs/waku>
128
+ - Cloudflare Workers SDK: <https://github.com/cloudflare/workers-sdk>
129
+ - OpenNext for Cloudflare: <https://github.com/opennextjs/opennextjs-cloudflare>
130
+ - SST: <https://github.com/sst/sst>
131
+ - node-sanitize-filename: <https://github.com/parshap/node-sanitize-filename>
132
+ - node-ignore: <https://github.com/kaelzhang/node-ignore>
133
+ - SQLite: <https://github.com/sqlite/sqlite>
134
+
135
+ The external `.vendor` Git submodules are separate works governed by the
136
+ license files in their respective repositories. This notice covers code copied
137
+ or adapted into the Alchemy repository; it does not replace the license
138
+ documentation within those submodules.
package/lib/ignore.d.ts CHANGED
@@ -1,12 +1,62 @@
1
- declare const isPathValid: (path: any) => any;
1
+ declare const KEY_IGNORE: string | symbol;
2
+ declare const MODE_IGNORE = "regex";
3
+ declare const MODE_CHECK_IGNORE = "checkRegex";
4
+ type MatcherMode = typeof MODE_IGNORE | typeof MODE_CHECK_IGNORE;
5
+ declare class IgnoreRule {
6
+ readonly pattern: string;
7
+ readonly mark: string | undefined;
8
+ readonly negative: boolean;
9
+ readonly body: string;
10
+ readonly ignoreCase: boolean;
11
+ readonly regexPrefix: string;
12
+ private _regex?;
13
+ private _checkRegex?;
14
+ constructor(pattern: string, mark: string | undefined, body: string, ignoreCase: boolean, negative: boolean, prefix: string);
15
+ get regex(): RegExp;
16
+ get checkRegex(): RegExp;
17
+ _make(mode: MatcherMode, key: "_regex" | "_checkRegex"): RegExp;
18
+ }
19
+ declare class RuleManager {
20
+ private readonly _ignoreCase;
21
+ _rules: IgnoreRule[];
22
+ private _added;
23
+ constructor(ignoreCase: boolean);
24
+ _add(pattern: string | Ignore | PatternParams): void;
25
+ add(pattern: string | Ignore | PatternParams | readonly (string | Ignore)[]): boolean;
26
+ test(path: string, checkUnignored: boolean, mode: MatcherMode): IgnoreTestResult;
27
+ }
28
+ declare class Ignore {
29
+ readonly [KEY_IGNORE]?: true | undefined;
30
+ readonly _rules: RuleManager;
31
+ private readonly _strictPathCheck;
32
+ private _ignoreCache;
33
+ private _testCache;
34
+ constructor({ ignorecase, ignoreCase, allowRelativePaths, }?: IgnoreOptions);
35
+ _initCache(): void;
36
+ add(pattern: string | Ignore | readonly (string | Ignore)[] | PatternParams): this;
37
+ addPattern(pattern: string | readonly string[]): this;
38
+ _test(originalPath: string, cache: Record<string, IgnoreTestResult>, checkUnignored: boolean, slices?: string[]): IgnoreTestResult;
39
+ checkIgnore(path: string): IgnoreTestResult;
40
+ _t(path: string, cache: Record<string, IgnoreTestResult>, checkUnignored: boolean, slices?: string[]): IgnoreTestResult;
41
+ ignores(path: string): boolean;
42
+ createFilter(): (path: string) => boolean;
43
+ filter(paths: readonly string[]): string[];
44
+ test(path: string): IgnoreTestResult;
45
+ }
46
+ declare const isPathValid: (path: string) => boolean;
2
47
  declare const _default: (options?: IgnoreOptions) => IgnoreInstance;
3
48
  export default _default;
4
- export { isPathValid };
49
+ export { Ignore, isPathValid };
5
50
  type Pathname = string;
6
51
  interface PatternParams {
7
52
  pattern: string;
8
53
  mark?: string;
9
54
  }
55
+ interface IgnoreTestResult {
56
+ ignored: boolean;
57
+ unignored: boolean;
58
+ rule?: IgnoreRule;
59
+ }
10
60
  export interface IgnoreOptions {
11
61
  ignorecase?: boolean;
12
62
  /** For compatibility. */
@@ -1 +1 @@
1
- {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../src/ignore.ts"],"names":[],"mappings":"AAguBA,QAAA,MAAM,WAAW,GAAI,SAAI,QACuC,CAAC;wBAkC5B,CACnC,OAAO,CAAC,EAAE,aAAa,KACpB,cAAc;AAFnB,wBAEoB;AACpB,OAAO,EAAE,WAAW,EAAE,CAAC;AAKvB,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CACD,QAAQ,EACJ,MAAM,GACN,cAAc,GACd,SAAS,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GACpC,aAAa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CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CACD,QAAQ,EACJ,MAAM,GACN,cAAc,GACd,SAAS,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GACpC,aAAa,GAChB,IAAI,CAAC;IACR,MAAM,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC;IACnD,YAAY,IAAI,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;IAChD,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG;QACxB,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAC9D,CAAC;IACF,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAC/B,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAC9D,CAAC;CACH"}
package/lib/ignore.js CHANGED
@@ -1,39 +1,10 @@
1
- // @ts-nocheck
2
- /*
3
- * Vendored copy of `ignore` (https://github.com/kaelzhang/node-ignore)
4
- * Version: 7.0.5
5
- *
6
- * The body below is a mechanical copy of upstream `index.js`. The only
7
- * substantive change is the CommonJS export footer, which has been rewritten
8
- * as ES module exports; the upstream `index.d.ts` declarations are appended.
9
- *
10
- * ---------------------------------------------------------------------------
11
- * Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
12
- * http://kael.me/
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining
15
- * a copy of this software and associated documentation files (the
16
- * "Software"), to deal in the Software without restriction, including
17
- * without limitation the rights to use, copy, modify, merge, publish,
18
- * distribute, sublicense, and/or sell copies of the Software, and to
19
- * permit persons to whom the Software is furnished to do so, subject to
20
- * the following conditions:
21
- *
22
- * The above copyright notice and this permission notice shall be
23
- * included in all copies or substantial portions of the Software.
24
- *
25
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
- * ---------------------------------------------------------------------------
33
- */
34
- // A simple implementation of make-array
1
+ // Alchemy modifications are licensed under Apache-2.0.
2
+ // This file includes third-party code; see /THIRD_PARTY_LICENSES.md.
3
+ //
4
+ // TypeScript port of `ignore` (https://github.com/kaelzhang/node-ignore) v7.0.5.
5
+ // Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors. MIT License.
35
6
  function makeArray(subject) {
36
- return Array.isArray(subject) ? subject : [subject];
7
+ return Array.isArray(subject) ? [...subject] : [subject];
37
8
  }
38
9
  const UNDEFINED = undefined;
39
10
  const EMPTY = "";
@@ -75,21 +46,19 @@ const sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from,
75
46
  : // Invalid range (out of order) which is ok for gitignore rules but
76
47
  // fatal for JavaScript regular expression, so eliminate it.
77
48
  EMPTY);
49
+ // > An optional `!` or `^` at the start of a class negates it, so that it
50
+ // > matches any character not in the set. (gitignore(5), fnmatch(3))
51
+ // The leading `^` has already been escaped to `\^` by the metacharacter
52
+ // escaper, so we strip the literal `!` or escaped `^` and emit a single
53
+ // regex `^` which is the JavaScript negation token.
54
+ const negateRange = (range) => range.startsWith("!") || range.startsWith("\\^")
55
+ ? `^${range.slice(range[0] === "!" ? 1 : 2)}`
56
+ : range;
78
57
  // See fixtures #59
79
58
  const cleanRangeBackSlash = (slashes) => {
80
59
  const { length } = slashes;
81
60
  return slashes.slice(0, length - (length % 2));
82
61
  };
83
- // > If the pattern ends with a slash,
84
- // > it is removed for the purpose of the following description,
85
- // > but it would only find a match with a directory.
86
- // > In other words, foo/ will match a directory foo and paths underneath it,
87
- // > but will not match a regular file or a symbolic link foo
88
- // > (this is consistent with the way how pathspec works in general in Git).
89
- // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
90
- // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
91
- // you could use option `mark: true` with `glob`
92
- // '`foo/`' should not continue with the '`..`'
93
62
  const REPLACERS = [
94
63
  [
95
64
  // Remove BOM
@@ -157,7 +126,7 @@ const REPLACERS = [
157
126
  // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
158
127
  // > under directory "foo".
159
128
  // Notice that the '*'s have been replaced as '\\*'
160
- /^\^*\\\*\\\*\\\//,
129
+ /^\^*(?:\\\*\\\*\\\/)+/,
161
130
  // '**/foo' <-> 'foo'
162
131
  () => "^(?:.*\\/)?",
163
132
  ],
@@ -251,7 +220,7 @@ const REPLACERS = [
251
220
  ? // A normal case, and it is a range notation
252
221
  // '[bar]'
253
222
  // '[bar\\\\]'
254
- `[${sanitizeRange(range)}${endEscape}]`
223
+ `[${negateRange(sanitizeRange(range))}${endEscape}]`
255
224
  : // Invalid range notaton
256
225
  // '[bar\\]' -> '[bar\\\\]'
257
226
  "[]"
@@ -282,7 +251,6 @@ const REPLACERS = [
282
251
  const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
283
252
  const MODE_IGNORE = "regex";
284
253
  const MODE_CHECK_IGNORE = "checkRegex";
285
- const UNDERSCORE = "_";
286
254
  const TRAILING_WILD_CARD_REPLACERS = {
287
255
  [MODE_IGNORE](_, p1) {
288
256
  const prefix = p1
@@ -313,14 +281,21 @@ const TRAILING_WILD_CARD_REPLACERS = {
313
281
  const makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
314
282
  const isString = (subject) => typeof subject === "string";
315
283
  // > A blank line matches no files, so it can serve as a separator for readability.
316
- const checkPattern = (pattern) => pattern &&
317
- isString(pattern) &&
284
+ const checkPattern = (pattern) => Boolean(pattern &&
318
285
  !REGEX_TEST_BLANK_LINE.test(pattern) &&
319
286
  !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) &&
320
287
  // > A line starting with # serves as a comment.
321
- pattern.indexOf("#") !== 0;
288
+ pattern.indexOf("#") !== 0);
322
289
  const splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
323
290
  class IgnoreRule {
291
+ pattern;
292
+ mark;
293
+ negative;
294
+ body;
295
+ ignoreCase;
296
+ regexPrefix;
297
+ _regex;
298
+ _checkRegex;
324
299
  constructor(pattern, mark, body, ignoreCase, negative, prefix) {
325
300
  this.pattern = pattern;
326
301
  this.mark = mark;
@@ -330,14 +305,14 @@ class IgnoreRule {
330
305
  define(this, "regexPrefix", prefix);
331
306
  }
332
307
  get regex() {
333
- const key = UNDERSCORE + MODE_IGNORE;
308
+ const key = `_${MODE_IGNORE}`;
334
309
  if (this[key]) {
335
310
  return this[key];
336
311
  }
337
312
  return this._make(MODE_IGNORE, key);
338
313
  }
339
314
  get checkRegex() {
340
- const key = UNDERSCORE + MODE_CHECK_IGNORE;
315
+ const key = `_${MODE_CHECK_IGNORE}`;
341
316
  if (this[key]) {
342
317
  return this[key];
343
318
  }
@@ -370,14 +345,17 @@ const createRule = ({ pattern, mark }, ignoreCase) => {
370
345
  return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
371
346
  };
372
347
  class RuleManager {
348
+ _ignoreCase;
349
+ _rules = [];
350
+ _added = false;
373
351
  constructor(ignoreCase) {
374
352
  this._ignoreCase = ignoreCase;
375
- this._rules = [];
376
353
  }
377
354
  _add(pattern) {
378
355
  // #32
379
- if (pattern && pattern[KEY_IGNORE]) {
380
- this._rules = this._rules.concat(pattern._rules._rules);
356
+ const ignorePattern = pattern;
357
+ if (pattern && ignorePattern[KEY_IGNORE]) {
358
+ this._rules = this._rules.concat(ignorePattern._rules._rules);
381
359
  this._added = true;
382
360
  return;
383
361
  }
@@ -386,8 +364,9 @@ class RuleManager {
386
364
  pattern,
387
365
  };
388
366
  }
389
- if (checkPattern(pattern.pattern)) {
390
- const rule = createRule(pattern, this._ignoreCase);
367
+ const patternParams = pattern;
368
+ if (checkPattern(patternParams.pattern)) {
369
+ const rule = createRule(patternParams, this._ignoreCase);
391
370
  this._added = true;
392
371
  this._rules.push(rule);
393
372
  }
@@ -395,7 +374,12 @@ class RuleManager {
395
374
  // @param {Array<string> | string | Ignore} pattern
396
375
  add(pattern) {
397
376
  this._added = false;
398
- makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
377
+ const patterns = isString(pattern)
378
+ ? splitPattern(pattern)
379
+ : Array.isArray(pattern)
380
+ ? pattern
381
+ : [pattern];
382
+ patterns.forEach(this._add, this);
399
383
  return this._added;
400
384
  }
401
385
  // Test one single path without recursively checking parent directories
@@ -465,8 +449,13 @@ const isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
465
449
  checkPath.isNotRelative = isNotRelative;
466
450
  // On windows, the following function will be replaced
467
451
  /* istanbul ignore next */
468
- checkPath.convert = (p) => p;
452
+ checkPath.convert = (path) => path;
469
453
  class Ignore {
454
+ [KEY_IGNORE];
455
+ _rules;
456
+ _strictPathCheck;
457
+ _ignoreCache;
458
+ _testCache;
470
459
  constructor({ ignorecase = true, ignoreCase = ignorecase, allowRelativePaths = false, } = {}) {
471
460
  define(this, KEY_IGNORE, true);
472
461
  this._rules = new RuleManager(ignoreCase);
@@ -587,5 +576,5 @@ typeof process !== "undefined" &&
587
576
  // `setupWindows` via `Symbol.for("setupWindows")` for its own test suite; we
588
577
  // drop that hook since it's unused.
589
578
  export default factory;
590
- export { isPathValid };
579
+ export { Ignore, isPathValid };
591
580
  //# sourceMappingURL=ignore.js.map