view-ignored 0.1.0 → 0.2.0

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 (165) hide show
  1. package/README.md +37 -54
  2. package/bin/viewig +2 -2
  3. package/out/src/bin.d.ts +2 -0
  4. package/out/src/bin.js +3 -0
  5. package/out/src/browser/binds/index.d.ts +45 -0
  6. package/out/src/browser/binds/index.js +78 -0
  7. package/out/src/browser/binds/plugins/git.d.ts +3 -0
  8. package/out/src/browser/binds/plugins/git.js +24 -0
  9. package/out/src/browser/binds/plugins/npm.d.ts +11 -0
  10. package/out/src/browser/binds/plugins/npm.js +71 -0
  11. package/out/src/browser/binds/plugins/vsce.d.ts +9 -0
  12. package/out/src/browser/binds/plugins/vsce.js +21 -0
  13. package/out/src/browser/binds/plugins/yarn.d.ts +16 -0
  14. package/out/src/browser/binds/plugins/yarn.js +78 -0
  15. package/out/src/browser/binds/targets.d.ts +64 -0
  16. package/out/src/browser/binds/targets.js +56 -0
  17. package/out/src/browser/errors.d.ts +10 -0
  18. package/out/src/browser/errors.js +20 -0
  19. package/out/src/browser/fileinfo.d.ts +82 -0
  20. package/out/src/browser/fileinfo.js +78 -0
  21. package/{lib → out/src/browser}/index.d.ts +0 -1
  22. package/{lib → out/src}/browser/index.js +0 -1
  23. package/out/src/browser/lib.d.ts +141 -0
  24. package/out/src/browser/lib.js +126 -0
  25. package/out/src/browser/scanner.d.ts +103 -0
  26. package/out/src/browser/scanner.js +161 -0
  27. package/out/src/browser/sorting.d.ts +41 -0
  28. package/out/src/browser/sorting.js +133 -0
  29. package/out/src/browser/sourceinfo.d.ts +62 -0
  30. package/out/src/browser/sourceinfo.js +105 -0
  31. package/out/src/browser/styling.d.ts +90 -0
  32. package/out/src/browser/styling.js +153 -0
  33. package/out/src/cli.d.ts +92 -0
  34. package/out/src/cli.js +249 -0
  35. package/out/src/config.d.ts +141 -0
  36. package/out/src/config.js +257 -0
  37. package/{lib/browser → out/src}/index.d.ts +0 -1
  38. package/{lib → out/src}/index.js +0 -1
  39. package/{lib → out/src}/lib.d.ts +1 -2
  40. package/{lib → out/src}/lib.js +1 -2
  41. package/out/src/styling.d.ts +4 -0
  42. package/out/src/styling.js +40 -0
  43. package/package.json +20 -14
  44. package/lib/bin.d.ts +0 -3
  45. package/lib/bin.d.ts.map +0 -1
  46. package/lib/bin.js +0 -4
  47. package/lib/bin.js.map +0 -1
  48. package/lib/browser/binds/index.d.ts +0 -2
  49. package/lib/browser/binds/index.d.ts.map +0 -1
  50. package/lib/browser/binds/index.js +0 -2
  51. package/lib/browser/binds/index.js.map +0 -1
  52. package/lib/browser/binds/targets.d.ts +0 -38
  53. package/lib/browser/binds/targets.d.ts.map +0 -1
  54. package/lib/browser/binds/targets.js +0 -38
  55. package/lib/browser/binds/targets.js.map +0 -1
  56. package/lib/browser/binds.d.ts +0 -22
  57. package/lib/browser/binds.d.ts.map +0 -1
  58. package/lib/browser/binds.js +0 -14
  59. package/lib/browser/binds.js.map +0 -1
  60. package/lib/browser/fileinfo.d.ts +0 -35
  61. package/lib/browser/fileinfo.d.ts.map +0 -1
  62. package/lib/browser/fileinfo.js +0 -42
  63. package/lib/browser/fileinfo.js.map +0 -1
  64. package/lib/browser/index.d.ts.map +0 -1
  65. package/lib/browser/index.js.map +0 -1
  66. package/lib/browser/lib.d.ts +0 -122
  67. package/lib/browser/lib.d.ts.map +0 -1
  68. package/lib/browser/lib.js +0 -115
  69. package/lib/browser/lib.js.map +0 -1
  70. package/lib/browser/looker.d.ts +0 -60
  71. package/lib/browser/looker.d.ts.map +0 -1
  72. package/lib/browser/looker.js +0 -80
  73. package/lib/browser/looker.js.map +0 -1
  74. package/lib/browser/plugins/git.d.ts +0 -10
  75. package/lib/browser/plugins/git.d.ts.map +0 -1
  76. package/lib/browser/plugins/git.js +0 -23
  77. package/lib/browser/plugins/git.js.map +0 -1
  78. package/lib/browser/plugins/npm.d.ts +0 -12
  79. package/lib/browser/plugins/npm.d.ts.map +0 -1
  80. package/lib/browser/plugins/npm.js +0 -70
  81. package/lib/browser/plugins/npm.js.map +0 -1
  82. package/lib/browser/plugins/vsce.d.ts +0 -10
  83. package/lib/browser/plugins/vsce.d.ts.map +0 -1
  84. package/lib/browser/plugins/vsce.js +0 -23
  85. package/lib/browser/plugins/vsce.js.map +0 -1
  86. package/lib/browser/plugins/yarn.d.ts +0 -15
  87. package/lib/browser/plugins/yarn.d.ts.map +0 -1
  88. package/lib/browser/plugins/yarn.js +0 -46
  89. package/lib/browser/plugins/yarn.js.map +0 -1
  90. package/lib/browser/sorting.d.ts +0 -31
  91. package/lib/browser/sorting.d.ts.map +0 -1
  92. package/lib/browser/sorting.js +0 -121
  93. package/lib/browser/sorting.js.map +0 -1
  94. package/lib/browser/sourcepattern.d.ts +0 -25
  95. package/lib/browser/sourcepattern.d.ts.map +0 -1
  96. package/lib/browser/sourcepattern.js +0 -45
  97. package/lib/browser/sourcepattern.js.map +0 -1
  98. package/lib/browser/styling.d.ts +0 -16
  99. package/lib/browser/styling.d.ts.map +0 -1
  100. package/lib/browser/styling.js +0 -116
  101. package/lib/browser/styling.js.map +0 -1
  102. package/lib/browser/tools/index.d.ts +0 -3
  103. package/lib/browser/tools/index.d.ts.map +0 -1
  104. package/lib/browser/tools/index.js +0 -3
  105. package/lib/browser/tools/index.js.map +0 -1
  106. package/lib/browser/tools/sorting.d.ts +0 -31
  107. package/lib/browser/tools/sorting.d.ts.map +0 -1
  108. package/lib/browser/tools/sorting.js +0 -121
  109. package/lib/browser/tools/sorting.js.map +0 -1
  110. package/lib/browser/tools/styles.d.ts +0 -16
  111. package/lib/browser/tools/styles.d.ts.map +0 -1
  112. package/lib/browser/tools/styles.js +0 -116
  113. package/lib/browser/tools/styles.js.map +0 -1
  114. package/lib/cli.d.ts +0 -26
  115. package/lib/cli.d.ts.map +0 -1
  116. package/lib/cli.js +0 -134
  117. package/lib/cli.js.map +0 -1
  118. package/lib/config.d.ts +0 -80
  119. package/lib/config.d.ts.map +0 -1
  120. package/lib/config.js +0 -105
  121. package/lib/config.js.map +0 -1
  122. package/lib/git.d.ts +0 -13
  123. package/lib/git.d.ts.map +0 -1
  124. package/lib/git.js +0 -37
  125. package/lib/git.js.map +0 -1
  126. package/lib/index.d.ts.map +0 -1
  127. package/lib/index.js.map +0 -1
  128. package/lib/lib.d.ts.map +0 -1
  129. package/lib/lib.js.map +0 -1
  130. package/lib/plugins/git.d.ts +0 -9
  131. package/lib/plugins/git.js +0 -22
  132. package/lib/plugins/git.js.map +0 -1
  133. package/lib/plugins/npm.d.ts +0 -12
  134. package/lib/plugins/npm.js +0 -74
  135. package/lib/plugins/npm.js.map +0 -1
  136. package/lib/plugins/vsce.d.ts +0 -9
  137. package/lib/plugins/vsce.js +0 -22
  138. package/lib/plugins/vsce.js.map +0 -1
  139. package/lib/plugins/yarn.d.ts +0 -15
  140. package/lib/plugins/yarn.js +0 -50
  141. package/lib/plugins/yarn.js.map +0 -1
  142. package/lib/tools/index.d.ts +0 -3
  143. package/lib/tools/index.js +0 -4
  144. package/lib/tools/index.js.map +0 -1
  145. package/lib/tools/methods.d.ts +0 -16
  146. package/lib/tools/methods.js +0 -81
  147. package/lib/tools/methods.js.map +0 -1
  148. package/lib/tools/sorting.d.ts +0 -30
  149. package/lib/tools/sorting.js +0 -121
  150. package/lib/tools/sorting.js.map +0 -1
  151. package/lib/tools/styles.d.ts +0 -15
  152. package/lib/tools/styles.js +0 -123
  153. package/lib/tools/styles.js.map +0 -1
  154. package/lib/util/index.d.ts +0 -3
  155. package/lib/util/index.js +0 -4
  156. package/lib/util/index.js.map +0 -1
  157. package/lib/util/presets.d.ts +0 -24
  158. package/lib/util/presets.js +0 -129
  159. package/lib/util/presets.js.map +0 -1
  160. package/lib/util/sorting.d.ts +0 -30
  161. package/lib/util/sorting.js +0 -121
  162. package/lib/util/sorting.js.map +0 -1
  163. package/lib/util/styles.d.ts +0 -8
  164. package/lib/util/styles.js +0 -52
  165. package/lib/util/styles.js.map +0 -1
@@ -0,0 +1,257 @@
1
+ import { filterNameList, isFilterName, Plugins, Sorting, Styling } from "./browser/index.js";
2
+ import * as os from "os";
3
+ import * as yaml from "yaml";
4
+ import path from "path";
5
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "fs";
6
+ /**
7
+ * Contains all color level names.
8
+ */
9
+ export const colorTypeList = [0, 1, 2, 3];
10
+ /**
11
+ * Checks if the value is the {@link ColorType}.
12
+ */
13
+ export function isColorType(value) {
14
+ const num = Number(value);
15
+ return Number.isFinite(num) && colorTypeList.includes(num);
16
+ }
17
+ /**
18
+ * The full config file name - `".view-ignored"`.
19
+ */
20
+ export const configFileName = ".view-ignored";
21
+ /**
22
+ * The user's home directory + the config file name.
23
+ * @see {@link os.homedir}
24
+ */
25
+ export const configFilePath = path.join(os.homedir(), configFileName);
26
+ /**
27
+ * Command-line configuration property list.
28
+ */
29
+ export const configKeyList = ["color", "target", "filter", "sort", "style", "decor", "depth", "showSources", "plugins", "parsable"];
30
+ /**
31
+ * Checks if the value is the {@link ConfigKey}.
32
+ */
33
+ export function isConfigKey(value) {
34
+ return typeof value === "string" && configKeyList.includes(value);
35
+ }
36
+ export function isShowSources(value) {
37
+ return typeof value === "boolean";
38
+ }
39
+ /**
40
+ * Checks if the value is the {@link Config} value for the specific {@link ConfigKey}.
41
+ */
42
+ export function isConfigValue(key, value) {
43
+ const c = {
44
+ parsable: v => typeof v === "boolean",
45
+ plugins: v => Array.isArray(v) && v.every(p => typeof p === "string"),
46
+ color: isColorType,
47
+ target: t => Plugins.isTargetId(t) && Plugins.targetGet(t) !== undefined,
48
+ filter: isFilterName,
49
+ sort: Sorting.isSortName,
50
+ style: Styling.isStyleName,
51
+ decor: Styling.isDecorName,
52
+ depth: Number.isInteger,
53
+ showSources: isShowSources
54
+ };
55
+ const check = c[key];
56
+ return check(value);
57
+ }
58
+ /**
59
+ * Command-line default config values.
60
+ */
61
+ export const configDefault = {
62
+ parsable: false,
63
+ plugins: [],
64
+ color: 3,
65
+ target: "git",
66
+ filter: "included",
67
+ sort: "firstFolders",
68
+ style: "tree",
69
+ decor: "normal",
70
+ depth: Infinity,
71
+ showSources: false
72
+ };
73
+ /**
74
+ * @returns `true`, if the value can be used as a configuration.
75
+ */
76
+ export function isConfigPartial(cfg) {
77
+ if (cfg?.constructor !== Object) {
78
+ return false;
79
+ }
80
+ const jsonobj = cfg;
81
+ return Object.entries(jsonobj).every(([key, value]) => isConfigKey(key)
82
+ ? isConfigValue(key, value)
83
+ : true);
84
+ }
85
+ export const trueValues = ['true', 'on', 'yes', 'y', 'enable', 'enabled', '1'];
86
+ export const falseValues = ['false', 'off', 'no', 'n', 'disable', 'disabled', '0'];
87
+ export const boolValues = trueValues.concat(falseValues);
88
+ /**
89
+ * @returns available values or requirement message for the specified property.
90
+ * @param key The config property.
91
+ * @param fallbackDefault If `true`, the default value will be used when the value is `undefined`. Default `true`.
92
+ */
93
+ export function configValueList(key) {
94
+ const msg = {
95
+ int: 'The value should be an integer.',
96
+ bool: `The value should be a boolean. Available bool literals: ${boolValues.join(', ')}`,
97
+ arrStr: `The value should be an array of a strings.`,
98
+ };
99
+ /**
100
+ * Represents allowed values for each config property.
101
+ */
102
+ const configAvailable = {
103
+ color: colorTypeList,
104
+ filter: filterNameList,
105
+ target: Plugins.targetList,
106
+ sort: Sorting.sortNameList,
107
+ style: Styling.styleNameList,
108
+ decor: Styling.decorNameList,
109
+ depth: msg.int,
110
+ parsable: msg.bool,
111
+ plugins: msg.arrStr,
112
+ showSources: msg.bool,
113
+ };
114
+ const val = configAvailable[key];
115
+ const choices = (typeof val === "function" ? val() : val);
116
+ return choices;
117
+ }
118
+ const configCliOptMap = new Map;
119
+ export function configValueLinkCliOption(key, command, option, parseArg) {
120
+ const list = configValueList(key);
121
+ if (Array.isArray(list)) {
122
+ option.choices(list);
123
+ }
124
+ if (parseArg) {
125
+ option.argParser(parseArg);
126
+ }
127
+ option.default(configManager.get(key));
128
+ command.addOption(option);
129
+ configCliOptMap.set(key, option);
130
+ return option;
131
+ }
132
+ export function configValueGetCliOption(key) {
133
+ return configCliOptMap.get(key);
134
+ }
135
+ /**
136
+ * File-specific actions container.
137
+ */
138
+ export class ConfigManager {
139
+ filePath;
140
+ constructor(filePath) {
141
+ this.filePath = filePath;
142
+ }
143
+ /**
144
+ * Do not change this value directly.
145
+ * @see {@link configManager}.
146
+ */
147
+ data = {};
148
+ dataRaw() {
149
+ return structuredClone(this.data);
150
+ }
151
+ entries() {
152
+ const obj = this.dataRaw();
153
+ if (obj?.constructor !== Object) {
154
+ return;
155
+ }
156
+ return Object.entries(obj);
157
+ }
158
+ /**
159
+ * Loads the config from the file to {@link configManager.data}. If the data is not valid, throws an error without loading.
160
+ * @returns `undefined` if the config file does not exist.
161
+ */
162
+ load() {
163
+ const parsed = existsSync(this.filePath) ? yaml.parse(readFileSync(this.filePath).toString()) : undefined;
164
+ if (parsed === undefined) {
165
+ return parsed;
166
+ }
167
+ const obj = parsed;
168
+ if (obj?.constructor !== Object) {
169
+ return this;
170
+ }
171
+ for (const key in obj) {
172
+ const element = obj[key];
173
+ if (typeof element !== "string") {
174
+ continue;
175
+ }
176
+ if (element.startsWith('|')) {
177
+ const array = element.split(',');
178
+ array.shift();
179
+ parsed[key] = array;
180
+ }
181
+ }
182
+ if (!isConfigPartial(parsed)) {
183
+ throw new TypeError(`Invalid config.`, { cause: parsed });
184
+ }
185
+ Object.assign(this.data, parsed);
186
+ return this;
187
+ }
188
+ /**
189
+ * Saves the partial config to the file. If there are no settings, the file will be deleted, if exists.
190
+ */
191
+ save() {
192
+ if (Object.keys(this.data).length === 0) {
193
+ if (existsSync(this.filePath)) {
194
+ rmSync(this.filePath);
195
+ }
196
+ return this;
197
+ }
198
+ writeFileSync(this.filePath, yaml.stringify(this.data));
199
+ return this;
200
+ }
201
+ /**
202
+ * Sets a new value for the specified config property.
203
+ * Expects a valid value.
204
+ * @param key The name of the config property.
205
+ * @param value The new value for the config property.
206
+ */
207
+ set(key, value) {
208
+ this.data[key] = value;
209
+ return this;
210
+ }
211
+ /**
212
+ * Deletes the specified property from the config.
213
+ * If the property is not specified, then all properties will be deleted.
214
+ * @param key The config property.
215
+ */
216
+ unset(key) {
217
+ if (key === undefined) {
218
+ for (const key of Object.keys(this.data)) {
219
+ delete this.data[key];
220
+ }
221
+ return this;
222
+ }
223
+ delete this.data[key];
224
+ return this;
225
+ }
226
+ /**
227
+ * @returns An array of properties which defined in the configuration file.
228
+ */
229
+ definedKeys() {
230
+ const keys = Object.keys(this.data);
231
+ return keys.filter(k => this.data[k] !== undefined);
232
+ }
233
+ get(key, defs = true) {
234
+ const value = this.data[key];
235
+ if (defs && value === undefined) {
236
+ return configDefault[key];
237
+ }
238
+ return value;
239
+ }
240
+ /**
241
+ * @param key The config property.
242
+ * @param defs If `true`, the default value will be used when the value is `undefined`. Default `true`.
243
+ * @returns A string in the `"key=value"` format, if the property is specified.
244
+ * Otherwise in format `"key=value\nkey=value\n..."` without the '\n' ending.
245
+ */
246
+ getPairString(key, defs = true) {
247
+ if (key === undefined) {
248
+ return configKeyList.map((key) => this.getPairString(key, defs)).filter(Boolean).join('\n');
249
+ }
250
+ const val = this.get(key, defs);
251
+ return val === undefined ? '' : `${key}=${val}`;
252
+ }
253
+ }
254
+ /**
255
+ * File-specific actions container. Contains get, set, unset, save, load and other configuration actions.
256
+ */
257
+ export const configManager = new ConfigManager(configFilePath);
@@ -1,4 +1,3 @@
1
1
  import * as ViewIgnored from "./lib.js";
2
2
  export default ViewIgnored;
3
3
  export * from "./lib.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import * as ViewIgnored from "./lib.js";
2
2
  export default ViewIgnored;
3
3
  export * from "./lib.js";
4
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,4 @@
1
1
  export * from "./browser/lib.js";
2
- export * as Git from "./git.js";
2
+ export * as Styling from "./styling.js";
3
3
  export * as Cli from "./cli.js";
4
4
  export * as Config from "./config.js";
5
- //# sourceMappingURL=lib.d.ts.map
@@ -1,5 +1,4 @@
1
1
  export * from "./browser/lib.js";
2
- export * as Git from "./git.js";
2
+ export * as Styling from "./styling.js";
3
3
  export * as Cli from "./cli.js";
4
4
  export * as Config from "./config.js";
5
- //# sourceMappingURL=lib.js.map
@@ -0,0 +1,4 @@
1
+ import { ChalkInstance } from "chalk";
2
+ import { DecorName } from "./browser/styling.js";
3
+ export * from "./browser/styling.js";
4
+ export declare function formatConfigConflicts(chalk: ChalkInstance, decor: DecorName, error: unknown): void;
@@ -0,0 +1,40 @@
1
+ import { decorCondition } from "./browser/styling.js";
2
+ import { configFilePath, configValueList, isConfigKey, isConfigValue } from "./config.js";
3
+ export * from "./browser/styling.js";
4
+ export function formatConfigConflicts(chalk, decor, error) {
5
+ if (!(error instanceof TypeError && error.cause?.constructor === Object)) {
6
+ throw error;
7
+ }
8
+ const entries = Object.entries(error.cause);
9
+ if (entries === undefined) {
10
+ console.error('An object expected.');
11
+ return;
12
+ }
13
+ if (entries.length === 0) {
14
+ return;
15
+ }
16
+ const badEntries = entries.filter(([key, value]) => {
17
+ // keys can be undefined
18
+ if (!isConfigKey(key)) {
19
+ return false;
20
+ }
21
+ if (isConfigValue(key, value)) {
22
+ return false;
23
+ }
24
+ // bad config value
25
+ return true;
26
+ });
27
+ if (badEntries.length === 0) {
28
+ return;
29
+ }
30
+ let message = 'Configuration invalid properties:\n';
31
+ const prefix = chalk.redBright(decorCondition(decor, { ifNerd: '\udb82\ude15', ifNormal: '-', postfix: ' ', prefix: ' ' }));
32
+ message += badEntries.map(([key, value]) => {
33
+ const choices = configValueList(key);
34
+ const errorMessage = choices === undefined ? '' : decorCondition(decor, { ifNormal: typeof choices === "string" ? choices : `Choices: ${choices.join(', ')}.`, prefix });
35
+ return '\t' + chalk.reset(`${key}=${value}`) + chalk.red(errorMessage);
36
+ }).join('\n');
37
+ console.error(message);
38
+ console.log();
39
+ console.log(configFilePath);
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-ignored",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Retrieve list of files ignored/included by Git, NPM, Yarn and VSC Extension.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,9 +8,12 @@
8
8
  "view-ignored": "./bin/viewig"
9
9
  },
10
10
  "scripts": {
11
- "prerelease": "pnpm lint && pnpm test && pnpm build",
12
- "test": "pnpm mocha --require tsx ./test/**/*.test.ts",
13
- "build": "pnpm tsc",
11
+ "prerelease": "pnpm lint && pnpm build:pub && pnpm test",
12
+ "postinstall": "pnpm run build",
13
+ "test": "pnpm mocha ./out/test/**/*.test.js",
14
+ "build": "pnpm shx rm -rf out && pnpm tsc",
15
+ "build:pub": "pnpm shx rm -rf out && pnpm tsc --sourceMap false",
16
+ "build:watch": "pnpm tsc --watch",
14
17
  "lint": "pnpm eslint .",
15
18
  "lint:fix": "pnpm eslint . --fix",
16
19
  "release:major": "pnpm release-it --increment=major",
@@ -19,9 +22,9 @@
19
22
  },
20
23
  "author": "Mopsgamer",
21
24
  "license": "ISC",
22
- "main": "./lib/index.js",
25
+ "main": "./lib/src/index.js",
23
26
  "files": [
24
- "lib"
27
+ "out/src"
25
28
  ],
26
29
  "repository": {
27
30
  "type": "git",
@@ -53,35 +56,38 @@
53
56
  "access": "public"
54
57
  },
55
58
  "directories": {
56
- "lib": "lib"
59
+ "lib": "out/src"
57
60
  },
58
61
  "dependencies": {
62
+ "arrify": "^3.0.0",
63
+ "boxen": "^8.0.1",
59
64
  "chalk": "^5.3.0",
60
65
  "commander": "^12.1.0",
61
- "fast-glob": "^3.3.2",
62
66
  "get-value": "^3.0.1",
67
+ "glob": "^11.0.0",
63
68
  "ignore": "^5.3.1",
64
69
  "jsonify-paths": "^1.1.0",
65
- "minimatch": "^9.0.4",
66
- "properties": "^1.2.1",
70
+ "load-plugin": "^6.0.3",
71
+ "minimatch": "^10.0.1",
72
+ "ora": "^8.0.1",
67
73
  "treeify": "^1.1.0",
68
- "tslib": "^2.6.3"
74
+ "tslib": "^2.6.3",
75
+ "yaml": "^2.5.0"
69
76
  },
70
77
  "devDependencies": {
71
78
  "@eslint/js": "^9.4.0",
72
79
  "@release-it/keep-a-changelog": "^5.0.0",
73
80
  "@types/get-value": "^3.0.5",
74
81
  "@types/mocha": "^10.0.6",
75
- "@types/mock-fs": "^4.13.4",
76
82
  "@types/node": "^20.14.2",
77
83
  "@types/treeify": "^1.0.3",
78
84
  "eslint": "^8.57.0",
79
85
  "eslint-plugin-only-warn": "^1.1.0",
86
+ "fs-fixture": "^2.4.0",
80
87
  "globals": "^15.4.0",
81
88
  "mocha": "^10.4.0",
82
- "mock-fs": "^5.2.0",
83
89
  "release-it": "^17.3.0",
84
- "tsx": "^4.15.1",
90
+ "shx": "^0.3.4",
85
91
  "typescript": "^5.4.5",
86
92
  "typescript-eslint": "^7.13.0"
87
93
  },
package/lib/bin.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=bin.d.ts.map
package/lib/bin.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/lib/bin.js DELETED
@@ -1,4 +0,0 @@
1
- #! /usr/bin/env node
2
- import { program } from "./cli.js";
3
- program.parse();
4
- //# sourceMappingURL=bin.js.map
package/lib/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AACjC,OAAO,CAAC,KAAK,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from "./targets.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/binds/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from "./targets.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/binds/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,38 +0,0 @@
1
- import { LookFolderOptions, Source } from "../lib.js";
2
- export interface TargetBind {
3
- id: string;
4
- name: string;
5
- sources: Source[];
6
- scanOptions?: LookFolderOptions;
7
- /**
8
- * Test command.
9
- *
10
- * @example
11
- * "npm pack --dry run"
12
- * "vsce ls"
13
- */
14
- testCommad?: string;
15
- }
16
- export declare function isValidId(id: unknown): boolean;
17
- /**
18
- * Allows to create targets for view-ignored scan* functions.
19
- *
20
- * @example
21
- * scanProject("abc") // error
22
- * Bindings.targetSet("abc", {...})
23
- * scanProject("abc") // ok
24
- */
25
- export declare function targetSet(bind: TargetBind): void;
26
- /**
27
- * Get all target ids.
28
- *
29
- * @example
30
- * ["git", "npm", "vsce", ...]
31
- */
32
- export declare function targetList(): string[];
33
- /**
34
- * Get target bind by target id.
35
- * @param id Target id.
36
- */
37
- export declare function targetGet(id: string): TargetBind | undefined;
38
- //# sourceMappingURL=targets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../../src/browser/binds/targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAErD,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,WAEpC;AAGD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAKhD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAErC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAK5D"}
@@ -1,38 +0,0 @@
1
- export function isValidId(id) {
2
- return typeof id === "string" && id.match(/^[-a-zA-Z0-9]+$/) != null;
3
- }
4
- const targetBindMap = new Map();
5
- /**
6
- * Allows to create targets for view-ignored scan* functions.
7
- *
8
- * @example
9
- * scanProject("abc") // error
10
- * Bindings.targetSet("abc", {...})
11
- * scanProject("abc") // ok
12
- */
13
- export function targetSet(bind) {
14
- if (!isValidId(bind.id)) {
15
- throw TypeError(`view-ignored can not bind target with id '${bind.id}'`);
16
- }
17
- targetBindMap.set(bind.id, bind);
18
- }
19
- /**
20
- * Get all target ids.
21
- *
22
- * @example
23
- * ["git", "npm", "vsce", ...]
24
- */
25
- export function targetList() {
26
- return Array.from(targetBindMap.keys());
27
- }
28
- /**
29
- * Get target bind by target id.
30
- * @param id Target id.
31
- */
32
- export function targetGet(id) {
33
- if (!isValidId(id)) {
34
- throw TypeError(`view-ignored can not get bind for target with id '${id}'`);
35
- }
36
- return targetBindMap.get(id);
37
- }
38
- //# sourceMappingURL=targets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targets.js","sourceRoot":"","sources":["../../../src/browser/binds/targets.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,SAAS,CAAC,EAAW;IACjC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAA;AACxE,CAAC;AACD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB;IACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,6CAA6C,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5E,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU;IACtB,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU;IAChC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;QACjB,MAAM,SAAS,CAAC,qDAAqD,EAAE,GAAG,CAAC,CAAA;IAC/E,CAAC;IACD,OAAO,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAChC,CAAC"}
@@ -1,22 +0,0 @@
1
- import { LookFolderOptions, Source } from "./lib.js";
2
- export interface TargetBind {
3
- id: string;
4
- name: string;
5
- sources: Source[];
6
- scanOptions?: LookFolderOptions;
7
- /**
8
- * Check command hint.
9
- *
10
- * @example
11
- * "npm pack --dry run"
12
- * "vsce ls"
13
- */
14
- check?: string;
15
- }
16
- export declare const targetBindMap: Map<string, TargetBind>;
17
- export declare function isValidTargetId(id: unknown): boolean;
18
- /**
19
- * Allows to create defaults.
20
- */
21
- export declare function targetBind(bind: TargetBind): void;
22
- //# sourceMappingURL=binds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binds.d.ts","sourceRoot":"","sources":["../../src/browser/binds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEpD,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACT,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AACD,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAa,CAAA;AAC/D,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,WAE1C;AACD;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,QAK1C"}
@@ -1,14 +0,0 @@
1
- export const targetBindMap = new Map();
2
- export function isValidTargetId(id) {
3
- return typeof id === "string" && id.match(/^[-a-zA-Z0-9]+$/) != null;
4
- }
5
- /**
6
- * Allows to create defaults.
7
- */
8
- export function targetBind(bind) {
9
- if (!isValidTargetId(bind.id)) {
10
- throw TypeError(`view-ignored can not bind target with id '${bind.id}'`);
11
- }
12
- targetBindMap.set(bind.id, bind);
13
- }
14
- //# sourceMappingURL=binds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binds.js","sourceRoot":"","sources":["../../src/browser/binds.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,aAAa,GAA4B,IAAI,GAAG,EAAE,CAAA;AAC/D,MAAM,UAAU,eAAe,CAAC,EAAW;IACvC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAA;AACxE,CAAC;AACD;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAgB;IACvC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM,SAAS,CAAC,6CAA6C,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5E,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
@@ -1,35 +0,0 @@
1
- import { ChalkInstance } from "chalk";
2
- import { StyleName } from "./styling.js";
3
- import { SourceFile } from "./lib.js";
4
- import { Looker } from "./looker.js";
5
- export interface FileInfoToStringOptions {
6
- /**
7
- * Determines if file icon should be used.
8
- * @default
9
- * undefined
10
- */
11
- styleName?: StyleName;
12
- /**
13
- * `true` if should add prefix: `+` or `!`.
14
- */
15
- usePrefix?: boolean;
16
- chalk?: ChalkInstance;
17
- }
18
- /**
19
- * Result of the file path scan.
20
- */
21
- export declare class FileInfo {
22
- readonly filePath: string;
23
- readonly looker: Looker;
24
- readonly source: SourceFile;
25
- readonly ignored: boolean;
26
- constructor(filePath: string, looker: Looker, source: SourceFile);
27
- static from(paths: string[], looker: Looker, source?: SourceFile | string): FileInfo[];
28
- static from(path: string, looker: Looker, source?: SourceFile | string): FileInfo;
29
- /**
30
- * @param options Styling options.
31
- * @param formatEntire Determines if path base or entire file path should be formatted. Default `true`.
32
- */
33
- toString(options?: FileInfoToStringOptions, formatEntire?: boolean): string;
34
- }
35
- //# sourceMappingURL=fileinfo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileinfo.d.ts","sourceRoot":"","sources":["../../src/browser/fileinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAsB,SAAS,EAAE,MAAM,cAAc,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,aAAa,CAAA;CACrB;AACD;;GAEG;AACH,qBAAa,QAAQ;aAGH,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,UAAU;IAJnC,SAAgB,OAAO,EAAE,OAAO,CAAA;gBAEf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU;IAInC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE;IACtF,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;IAQjF;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,EAAE,YAAY,UAAO,GAAG,MAAM;CAiBxE"}
@@ -1,42 +0,0 @@
1
- import { styleConditionFile } from "./styling.js";
2
- import path from "path";
3
- /**
4
- * Result of the file path scan.
5
- */
6
- export class FileInfo {
7
- constructor(filePath, looker, source) {
8
- this.filePath = filePath;
9
- this.looker = looker;
10
- this.source = source;
11
- this.ignored = looker.ignores(filePath);
12
- }
13
- static from(arg, looker, source) {
14
- if (Array.isArray(arg)) {
15
- return arg.map(path => FileInfo.from(path, looker, source));
16
- }
17
- const src = typeof source === "object" ? source : { path: '<no-source>', content: source !== null && source !== void 0 ? source : '' };
18
- return new FileInfo(arg, looker, src);
19
- }
20
- /**
21
- * @param options Styling options.
22
- * @param formatEntire Determines if path base or entire file path should be formatted. Default `true`.
23
- */
24
- toString(options, formatEntire = true) {
25
- const { styleName, usePrefix = false, chalk } = options !== null && options !== void 0 ? options : {};
26
- const parsed = path.parse(this.filePath);
27
- const fileIcon = styleConditionFile(styleName, this.filePath);
28
- const prefix = usePrefix ? (this.ignored ? '!' : '+') : '';
29
- if (chalk) {
30
- const clr = chalk[this.ignored ? "red" : "green"];
31
- if (formatEntire) {
32
- return fileIcon + clr(prefix + this.filePath);
33
- }
34
- return parsed.dir + '/' + fileIcon + clr(prefix + parsed.base);
35
- }
36
- if (formatEntire) {
37
- return prefix + this.filePath;
38
- }
39
- return parsed.dir + '/' + fileIcon + prefix + parsed.base;
40
- }
41
- }
42
- //# sourceMappingURL=fileinfo.js.map