view-ignored 0.8.1 → 0.9.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.
@@ -1,6 +1,7 @@
1
1
  import { type } from "arktype";
2
2
  import { signedPatternIgnores, signedPatternCompile, extractPackageJsonNocase, extractGitignoreNocase, } from "../patterns/index.js";
3
3
  import { join, unixify } from "../unixify.js";
4
+ import { npmManifestParse } from "./npmManifest.js";
4
5
  const extractors = [
5
6
  {
6
7
  extract: extractPackageJsonNocase,
@@ -15,42 +16,44 @@ const extractors = [
15
16
  path: ".gitignore",
16
17
  },
17
18
  ];
18
- const include = [
19
- // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L10
20
- "/package.json",
21
- "/README",
22
- "/README.*",
23
- "/LICENSE",
24
- "/LICENSE.*",
25
- "/LICENCE",
26
- "/LICENCE.*",
27
- ];
28
- const internal = {
29
- exclude: [
30
- // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L26
31
- "/package.tgz",
32
- ".github",
33
- ".git",
34
- ".hg",
35
- "node_modules",
36
- ".npmignore",
37
- ".gitignore",
38
- ".#*",
39
- ".DS_Store",
40
- ],
41
- include: [...include],
42
- compiled: null,
19
+ const internalInclude = {
20
+ excludes: false,
21
+ pattern: [],
22
+ compiled: [],
43
23
  };
44
- signedPatternCompile(internal, { nocase: true });
45
- const npmManifest = type({
46
- "main?": "string",
47
- "module?": "string",
48
- "browser?": "string",
49
- "bin?": "string | Record<string, string>",
50
- });
51
- const parse = type("string")
52
- .pipe((s) => JSON.parse(s))
53
- .pipe(npmManifest);
24
+ const internal = [
25
+ internalInclude,
26
+ signedPatternCompile({
27
+ excludes: true,
28
+ pattern: [
29
+ // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L26
30
+ "/package.tgz",
31
+ ".github",
32
+ ".git",
33
+ ".hg",
34
+ "node_modules",
35
+ ".npmignore",
36
+ ".gitignore",
37
+ ".#*",
38
+ ".DS_Store",
39
+ ],
40
+ compiled: null,
41
+ }),
42
+ signedPatternCompile({
43
+ excludes: false,
44
+ pattern: [
45
+ // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L10
46
+ "/package.json",
47
+ "/README",
48
+ "/README.*",
49
+ "/LICENSE",
50
+ "/LICENSE.*",
51
+ "/LICENCE",
52
+ "/LICENCE.*",
53
+ ],
54
+ compiled: null,
55
+ }, { nocase: true }),
56
+ ];
54
57
  /**
55
58
  * @since 0.6.0
56
59
  */
@@ -62,17 +65,14 @@ export const Yarn = {
62
65
  content = await fs.promises.readFile(normalCwd + "/" + "package.json");
63
66
  }
64
67
  catch (error) {
65
- if (error.code === "ENOENT") {
66
- return; // no package.json
67
- }
68
- throw new Error("Error while initializing Yarn's ignoring implementation", { cause: error });
68
+ throw new Error("Error while initializing Yarn", { cause: error });
69
69
  }
70
- const dist = parse(content.toString());
70
+ const dist = npmManifestParse(content.toString());
71
71
  if (dist instanceof type.errors) {
72
72
  throw new Error("Invalid 'package.json': " + dist.summary, { cause: dist });
73
73
  }
74
74
  // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L215-L231
75
- const set = new Set(include);
75
+ const set = new Set();
76
76
  function normal(path) {
77
77
  const result = unixify(join(normalCwd, path)).substring(normalCwd.length);
78
78
  return result;
@@ -89,9 +89,8 @@ export const Yarn = {
89
89
  else if (typeof dist.bin === "object" && dist.bin !== null) {
90
90
  Object.values(dist.bin).forEach((binPath) => set.add(normal(binPath)));
91
91
  }
92
- internal.include.length = 0;
93
- internal.include.push(...set);
94
- signedPatternCompile(internal, { nocase: true });
92
+ internalInclude.pattern = Array.from(set);
93
+ signedPatternCompile(internalInclude, { nocase: true });
95
94
  },
96
95
  extractors,
97
96
  ignores(o) {
@@ -1,4 +1,7 @@
1
+ import { type } from "arktype";
1
2
  import { signedPatternIgnores, signedPatternCompile, extractPackageJsonNocase, extractGitignoreNocase, } from "../patterns/index.js";
3
+ import { unixify } from "../unixify.js";
4
+ import { npmManifestParse } from "./npmManifest.js";
2
5
  const extractors = [
3
6
  {
4
7
  extract: extractPackageJsonNocase,
@@ -17,54 +20,74 @@ const extractors = [
17
20
  path: ".gitignore",
18
21
  },
19
22
  ];
20
- const internal = {
21
- exclude: [
22
- // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L26
23
- ".git",
24
- "CVS",
25
- ".svn",
26
- ".hg",
27
- "node_modules",
28
- "yarn.lock",
29
- ".lock-wscript",
30
- ".wafpickle-0",
31
- ".wafpickle-1",
32
- ".wafpickle-2",
33
- ".wafpickle-3",
34
- ".wafpickle-4",
35
- ".wafpickle-5",
36
- ".wafpickle-6",
37
- ".wafpickle-7",
38
- ".wafpickle-8",
39
- ".wafpickle-9",
40
- "*.swp",
41
- "._*",
42
- "npm-debug.log",
43
- "yarn-error.log",
44
- ".npmrc",
45
- ".yarnrc",
46
- ".yarnrc.yml",
47
- ".npmignore",
48
- ".gitignore",
49
- ".DS_Store",
50
- ],
51
- include: [
52
- // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L10
53
- "/package.json",
54
- "/readme*",
55
- "/license*",
56
- "/licence*",
57
- "/changes*",
58
- "/changelog*",
59
- "/history*",
60
- ],
61
- compiled: null,
62
- };
63
- signedPatternCompile(internal, { nocase: true });
23
+ const internal = [
24
+ signedPatternCompile({
25
+ excludes: true,
26
+ pattern: [
27
+ // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L26
28
+ ".git",
29
+ "CVS",
30
+ ".svn",
31
+ ".hg",
32
+ "node_modules",
33
+ "yarn.lock",
34
+ ".lock-wscript",
35
+ ".wafpickle-0",
36
+ ".wafpickle-1",
37
+ ".wafpickle-2",
38
+ ".wafpickle-3",
39
+ ".wafpickle-4",
40
+ ".wafpickle-5",
41
+ ".wafpickle-6",
42
+ ".wafpickle-7",
43
+ ".wafpickle-8",
44
+ ".wafpickle-9",
45
+ "*.swp",
46
+ "._*",
47
+ "npm-debug.log",
48
+ "yarn-error.log",
49
+ ".npmrc",
50
+ ".yarnrc",
51
+ ".yarnrc.yml",
52
+ ".npmignore",
53
+ ".gitignore",
54
+ ".DS_Store",
55
+ ],
56
+ compiled: null,
57
+ }, { nocase: true }),
58
+ signedPatternCompile({
59
+ excludes: false,
60
+ pattern: [
61
+ // https://github.com/yarnpkg/berry/blob/master/packages/plugin-pack/sources/packUtils.ts#L10
62
+ "/package.json",
63
+ "/readme*",
64
+ "/license*",
65
+ "/licence*",
66
+ "/changes*",
67
+ "/changelog*",
68
+ "/history*",
69
+ ],
70
+ compiled: null,
71
+ }, { nocase: true }),
72
+ ];
64
73
  /**
65
74
  * @since 0.8.0
66
75
  */
67
76
  export const YarnClassic = {
77
+ async init({ fs, cwd }) {
78
+ let content;
79
+ const normalCwd = unixify(cwd);
80
+ try {
81
+ content = await fs.promises.readFile(normalCwd + "/" + "package.json");
82
+ }
83
+ catch (error) {
84
+ throw new Error("Error while initializing Yarn classic", { cause: error });
85
+ }
86
+ const dist = npmManifestParse(content.toString());
87
+ if (dist instanceof type.errors) {
88
+ throw new Error("Invalid 'package.json': " + dist.summary, { cause: dist });
89
+ }
90
+ },
68
91
  extractors,
69
92
  ignores(o) {
70
93
  return signedPatternIgnores({
package/out/unixify.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare function unixify(path: string): string;
2
2
  export declare function join(from: string, p2: string): string;
3
3
  export declare function relative(base: string, to: string): string;
4
+ export declare function base(path: string): string;
package/out/unixify.js CHANGED
@@ -28,6 +28,9 @@ export function relative(base, to) {
28
28
  const result = to.replace(base, "");
29
29
  return result;
30
30
  }
31
+ export function base(path) {
32
+ return path.substring(path.lastIndexOf("/") + 1);
33
+ }
31
34
  function strip(path) {
32
35
  return path.replaceAll("\\", "/").replace(/\w:/, "");
33
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-ignored",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Retrieve list of files ignored/included by Git, NPM, Yarn, JSR, VSCE or other tools.",
5
5
  "keywords": [
6
6
  ".gitignore",
@@ -77,6 +77,9 @@
77
77
  },
78
78
  "scripts": {
79
79
  "prerelease": "bun run test && bun run prod && bun run lint && bun run fmt --check && bun publint --pack bun --strict",
80
+ "cpu": "bun run cpu:igw; bun run cpu:me",
81
+ "cpu:igw": "bun run --cpu-prof-md --cpu-prof-name CPU.igw.md scripts/ignoreWalk.js",
82
+ "cpu:me": "bun run --cpu-prof-md --cpu-prof-name CPU.me.md scripts/scan.js --fastInternal",
80
83
  "test": "bun test src",
81
84
  "test:patterns": "bun test src/patterns",
82
85
  "test:targets": "bun test src/targets",
@@ -94,21 +97,21 @@
94
97
  },
95
98
  "dependencies": {
96
99
  "arktype": "^2.1.29",
97
- "minimatch": "^10.1.2",
100
+ "minimatch": "^10.2.2",
98
101
  "strip-json-comments": "^5.0.3"
99
102
  },
100
103
  "devDependencies": {
101
104
  "@release-it/keep-a-changelog": "^7.0.1",
102
- "@types/bun": "^1.3.8",
105
+ "@types/bun": "^1.3.9",
103
106
  "@types/ignore-walk": "^4.0.3",
104
107
  "@types/node": "^18.19.130",
105
- "@typescript/native-preview": "^7.0.0-dev.20260209.1",
108
+ "@typescript/native-preview": "^7.0.0-dev.20260223.1",
106
109
  "ignore-walk": "^8.0.0",
107
110
  "memfs": "^4.56.10",
108
111
  "mitata": "^1.0.34",
109
- "oxfmt": "^0.28.0",
110
- "oxlint": "^1.43.0",
111
- "oxlint-tsgolint": "^0.11.5",
112
+ "oxfmt": "^0.35.0",
113
+ "oxlint": "^1.50.0",
114
+ "oxlint-tsgolint": "^0.14.2",
112
115
  "publint": "^0.3.17",
113
116
  "release-it": "^19.2.4"
114
117
  },
@@ -1,23 +0,0 @@
1
- import type { SignedPattern } from "./signedPattern.js";
2
- /**
3
- * Combined internal and external patterns for matching.
4
- *
5
- * @see {@link signedPatternIgnores}
6
- *
7
- * @since 0.6.0
8
- */
9
- export type PatternMatcher = {
10
- /**
11
- * Internal patterns are provided by the target.
12
- * Almost always they are predefined.
13
- *
14
- * @since 0.6.0
15
- */
16
- internal: SignedPattern;
17
- /**
18
- * External patterns are sourced from existing project files at runtime.
19
- *
20
- * @since 0.6.0
21
- */
22
- external: SignedPattern;
23
- };
@@ -1 +0,0 @@
1
- export {};