view-ignored 0.8.0 → 0.8.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/README.md CHANGED
@@ -138,37 +138,37 @@ vign.scan({ target, cwd, fs })
138
138
 
139
139
  ## Targets
140
140
 
141
- > [!NOTE]
142
- > Each scanner expects minimal configurations, but the actual tool can have
143
- > more/less complex rules. Refer to the documentation of each tool for details.
144
-
145
141
  The following built-in scanners are available:
146
142
 
147
- - Git
143
+ - Git ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/git.ts))
148
144
  - Reads `.gitignore` and `.git/info/exclude` but does not consider global settings.
149
145
  - Starts searching from `/`.
150
146
  - Check this scanner by running `git ls-files --others --exclude-standard --cached`.
151
- - See the implementation of [Git target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/git.ts) for details.
152
- - NPM (expecting to be compatible with Bun, PNPM, and others)
153
- - Reads `.npmignore` and `package.json` `files` field.
147
+ - NPM ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/npm.ts))
148
+ - Expecting to be compatible with PNPM, and others.
149
+ - Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
154
150
  - Starts searching from `.` (current working directory).
155
151
  - No additional checks for `name`, `version` or `publishConfig`.
156
152
  - Check this scanner by running `npm pack --dry-run`.
157
- - See the implementation of [NPM target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/npm.ts) for details.
158
- - Yarn
159
- - Modern Berry behavior, but does not include paths from `package.json` `main`, `module`, `browser` and `bin`.
160
- - `YarnClassic` is available.
153
+ - Bun ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/bun.ts))
154
+ - Bun tries to mimic NPM, but that does not mean it behaves the same way.
155
+ - Check this scanner by running `bun pm pack --dry-run`.
156
+ - Yarn ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarn.ts))
157
+ - Modern Berry behavior.
158
+ - Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
159
+ - Requires `package.json`: includes paths from `main`, `module`, `browser` and `bin`.
161
160
  - Starts searching from `.` (current working directory).
162
- - See the implementation of [Yarn target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarn.ts) for details.
163
- - VSCE
161
+ - `YarnClassic` is available. ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarnClassic.ts))
162
+ - VSCE ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/vsce.ts))
164
163
  - Reads `package.json` `files` field, `.vscodeignore` and `.gitignore`.
165
164
  - Starts searching from `.` (current working directory).
166
165
  - Check this scanner by running `vsce ls`.
167
- - See the implementation of [VSCE target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/vsce.ts) for details.
168
- - JSR (compatible with Deno)
166
+ - JSR ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/jsr.ts))
167
+ - Reads `jsr.json(c)` `include` and `exclude` fields.
168
+ - Starts searching from `.` (current working directory).
169
+ - Deno ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/deno.ts))
169
170
  - Reads `jsr.json(c)` and `deno.json(c)` `include` and `exclude` fields.
170
171
  - Starts searching from `.` (current working directory).
171
- - See the implementation of [JSR target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/jsr.ts) for details.
172
172
 
173
173
  ## See also
174
174
 
@@ -0,0 +1,5 @@
1
+ import type { Target } from "./target.js";
2
+ /**
3
+ * @since 0.8.1
4
+ */
5
+ export declare const Bun: Target;
@@ -0,0 +1,78 @@
1
+ import { signedPatternIgnores, signedPatternCompile, extractPackageJson, extractGitignore, } from "../patterns/index.js";
2
+ const extractors = [
3
+ {
4
+ extract: extractPackageJson,
5
+ path: "package.json",
6
+ },
7
+ {
8
+ extract: extractGitignore,
9
+ path: ".npmignore",
10
+ },
11
+ {
12
+ extract: extractGitignore,
13
+ path: ".gitignore",
14
+ },
15
+ ];
16
+ const internal = {
17
+ exclude: [
18
+ // https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L180
19
+ "package-lock.json",
20
+ "yarn.lock",
21
+ "pnpm-lock.yaml",
22
+ "bun.lockb",
23
+ "bun.lock", // npm includes it
24
+ // https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L189
25
+ ".*.swp",
26
+ "._*",
27
+ ".DS_Store",
28
+ ".git",
29
+ ".gitignore",
30
+ ".hg",
31
+ ".npmignore",
32
+ ".npmrc",
33
+ ".lock-wscript",
34
+ ".svn",
35
+ "wafpickle-*",
36
+ "CVS",
37
+ "npm-debug.log",
38
+ // bun says it is "mentioned in the docs but does not appear to be ignored by default"
39
+ // but we know it should be /build/config.gypi, not just config.gypi, haha
40
+ // "config.gypi",
41
+ ".env.production", // npm includes it
42
+ "bunfig.toml", // npm includes it
43
+ // https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L284
44
+ // manifest should be included, but bun ignores it on this line
45
+ // bun forces it later: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
46
+ // "package.json",
47
+ // https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L285
48
+ "node_modules",
49
+ ],
50
+ include: [
51
+ // https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
52
+ "package.json",
53
+ // the special?.* check works this way: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2599
54
+ "LICENSE",
55
+ "LICENSE.*",
56
+ "LICENCE",
57
+ "LICENCE.*",
58
+ "README",
59
+ "README.*",
60
+ ],
61
+ compiled: null,
62
+ };
63
+ signedPatternCompile(internal);
64
+ /**
65
+ * @since 0.8.1
66
+ */
67
+ export const Bun = {
68
+ // TODO: Bun should include some paths: bins, bundled deps, nothing else.
69
+ extractors,
70
+ ignores(o) {
71
+ return signedPatternIgnores({
72
+ ...o,
73
+ internal,
74
+ root: ".",
75
+ target: Bun,
76
+ });
77
+ },
78
+ };
@@ -0,0 +1,5 @@
1
+ import type { Target } from "./target.js";
2
+ /**
3
+ * @since 0.8.1
4
+ */
5
+ export declare const Deno: Target;
@@ -0,0 +1,40 @@
1
+ import { signedPatternIgnores, signedPatternCompile, extractJsrJson, extractJsrJsonc, } from "../patterns/index.js";
2
+ const extractors = [
3
+ {
4
+ extract: extractJsrJson,
5
+ path: "deno.json",
6
+ },
7
+ {
8
+ extract: extractJsrJsonc,
9
+ path: "deno.jsonc",
10
+ },
11
+ {
12
+ extract: extractJsrJson,
13
+ path: "jsr.json",
14
+ },
15
+ {
16
+ extract: extractJsrJsonc,
17
+ path: "jsr.jsonc",
18
+ },
19
+ ];
20
+ const internal = {
21
+ exclude: [".git", ".DS_Store"],
22
+ include: [],
23
+ compiled: null,
24
+ };
25
+ signedPatternCompile(internal);
26
+ /**
27
+ * @since 0.8.1
28
+ */
29
+ export const Deno = {
30
+ // TODO: Deno should validate manifest
31
+ extractors,
32
+ ignores(o) {
33
+ return signedPatternIgnores({
34
+ ...o,
35
+ internal,
36
+ root: ".",
37
+ target: Deno,
38
+ });
39
+ },
40
+ };
@@ -19,6 +19,7 @@ signedPatternCompile(internal);
19
19
  * @since 0.6.0
20
20
  */
21
21
  export const Git = {
22
+ // TODO: Git should read configs
22
23
  extractors,
23
24
  ignores(o) {
24
25
  return signedPatternIgnores({
@@ -1,3 +1,5 @@
1
+ export * from "./bun.js";
2
+ export * from "./deno.js";
1
3
  export * from "./git.js";
2
4
  export * from "./jsr.js";
3
5
  export * from "./npm.js";
@@ -1,3 +1,5 @@
1
+ export * from "./bun.js";
2
+ export * from "./deno.js";
1
3
  export * from "./git.js";
2
4
  export * from "./jsr.js";
3
5
  export * from "./npm.js";
@@ -1,13 +1,5 @@
1
1
  import { signedPatternIgnores, signedPatternCompile, extractJsrJson, extractJsrJsonc, } from "../patterns/index.js";
2
2
  const extractors = [
3
- {
4
- extract: extractJsrJson,
5
- path: "deno.json",
6
- },
7
- {
8
- extract: extractJsrJsonc,
9
- path: "deno.jsonc",
10
- },
11
3
  {
12
4
  extract: extractJsrJson,
13
5
  path: "jsr.json",
@@ -27,6 +19,7 @@ signedPatternCompile(internal);
27
19
  * @since 0.6.0
28
20
  */
29
21
  export const JSR = {
22
+ // TODO: JSR should validate manifest
30
23
  extractors,
31
24
  ignores(o) {
32
25
  return signedPatternIgnores({
@@ -63,6 +63,7 @@ signedPatternCompile(internal);
63
63
  * @since 0.6.0
64
64
  */
65
65
  export const NPM = {
66
+ // TODO: NPM should validate package.json
66
67
  extractors,
67
68
  ignores(o) {
68
69
  return signedPatternIgnores({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-ignored",
3
- "version": "0.8.0",
3
+ "version": "0.8.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",