@nice-move/cli 0.11.4 → 0.11.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.
@@ -0,0 +1,335 @@
1
+ export const id = "vendors-node_modules_lilconfig_dist_index_js";
2
+ export const ids = ["vendors-node_modules_lilconfig_dist_index_js"];
3
+ export const modules = {
4
+
5
+ /***/ "../../node_modules/lilconfig/dist/index.js":
6
+ /*!**************************************************!*\
7
+ !*** ../../node_modules/lilconfig/dist/index.js ***!
8
+ \**************************************************/
9
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
10
+
11
+
12
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
13
+ exports.lilconfigSync = exports.lilconfig = exports.defaultLoaders = void 0;
14
+ const path = __webpack_require__(/*! path */ "path");
15
+ const fs = __webpack_require__(/*! fs */ "fs");
16
+ const os = __webpack_require__(/*! os */ "os");
17
+ const fsReadFileAsync = fs.promises.readFile;
18
+ function getDefaultSearchPlaces(name) {
19
+ return [
20
+ 'package.json',
21
+ `.${name}rc.json`,
22
+ `.${name}rc.js`,
23
+ `.${name}rc.cjs`,
24
+ `.config/${name}rc`,
25
+ `.config/${name}rc.json`,
26
+ `.config/${name}rc.js`,
27
+ `.config/${name}rc.cjs`,
28
+ `${name}.config.js`,
29
+ `${name}.config.cjs`,
30
+ ];
31
+ }
32
+ function parentDir(p) {
33
+ return path.dirname(p) || path.sep;
34
+ }
35
+ exports.defaultLoaders = Object.freeze({
36
+ '.js': __webpack_require__("../../node_modules/lilconfig/dist sync recursive"),
37
+ '.json': __webpack_require__("../../node_modules/lilconfig/dist sync recursive"),
38
+ '.cjs': __webpack_require__("../../node_modules/lilconfig/dist sync recursive"),
39
+ noExt(_, content) {
40
+ return JSON.parse(content);
41
+ },
42
+ });
43
+ function getExtDesc(ext) {
44
+ return ext === 'noExt' ? 'files without extensions' : `extension "${ext}"`;
45
+ }
46
+ function getOptions(name, options = {}) {
47
+ const conf = {
48
+ stopDir: os.homedir(),
49
+ searchPlaces: getDefaultSearchPlaces(name),
50
+ ignoreEmptySearchPlaces: true,
51
+ cache: true,
52
+ transform: (x) => x,
53
+ packageProp: [name],
54
+ ...options,
55
+ loaders: { ...exports.defaultLoaders, ...options.loaders },
56
+ };
57
+ conf.searchPlaces.forEach(place => {
58
+ const key = path.extname(place) || 'noExt';
59
+ const loader = conf.loaders[key];
60
+ if (!loader) {
61
+ throw new Error(`No loader specified for ${getExtDesc(key)}, so searchPlaces item "${place}" is invalid`);
62
+ }
63
+ if (typeof loader !== 'function') {
64
+ throw new Error(`loader for ${getExtDesc(key)} is not a function (type provided: "${typeof loader}"), so searchPlaces item "${place}" is invalid`);
65
+ }
66
+ });
67
+ return conf;
68
+ }
69
+ function getPackageProp(props, obj) {
70
+ if (typeof props === 'string' && props in obj)
71
+ return obj[props];
72
+ return ((Array.isArray(props) ? props : props.split('.')).reduce((acc, prop) => (acc === undefined ? acc : acc[prop]), obj) || null);
73
+ }
74
+ function validateFilePath(filepath) {
75
+ if (!filepath)
76
+ throw new Error('load must pass a non-empty string');
77
+ }
78
+ function validateLoader(loader, ext) {
79
+ if (!loader)
80
+ throw new Error(`No loader specified for extension "${ext}"`);
81
+ if (typeof loader !== 'function')
82
+ throw new Error('loader is not a function');
83
+ }
84
+ const makeEmplace = (enableCache) => (c, filepath, res) => {
85
+ if (enableCache)
86
+ c.set(filepath, res);
87
+ return res;
88
+ };
89
+ function lilconfig(name, options) {
90
+ const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache, } = getOptions(name, options);
91
+ const searchCache = new Map();
92
+ const loadCache = new Map();
93
+ const emplace = makeEmplace(cache);
94
+ return {
95
+ async search(searchFrom = process.cwd()) {
96
+ const result = {
97
+ config: null,
98
+ filepath: '',
99
+ };
100
+ const visited = new Set();
101
+ let dir = searchFrom;
102
+ dirLoop: while (true) {
103
+ if (cache) {
104
+ const r = searchCache.get(dir);
105
+ if (r !== undefined) {
106
+ for (const p of visited)
107
+ searchCache.set(p, r);
108
+ return r;
109
+ }
110
+ visited.add(dir);
111
+ }
112
+ for (const searchPlace of searchPlaces) {
113
+ const filepath = path.join(dir, searchPlace);
114
+ try {
115
+ await fs.promises.access(filepath);
116
+ }
117
+ catch (_a) {
118
+ continue;
119
+ }
120
+ const content = String(await fsReadFileAsync(filepath));
121
+ const loaderKey = path.extname(searchPlace) || 'noExt';
122
+ const loader = loaders[loaderKey];
123
+ if (searchPlace === 'package.json') {
124
+ const pkg = await loader(filepath, content);
125
+ const maybeConfig = getPackageProp(packageProp, pkg);
126
+ if (maybeConfig != null) {
127
+ result.config = maybeConfig;
128
+ result.filepath = filepath;
129
+ break dirLoop;
130
+ }
131
+ continue;
132
+ }
133
+ const isEmpty = content.trim() === '';
134
+ if (isEmpty && ignoreEmptySearchPlaces)
135
+ continue;
136
+ if (isEmpty) {
137
+ result.isEmpty = true;
138
+ result.config = undefined;
139
+ }
140
+ else {
141
+ validateLoader(loader, loaderKey);
142
+ result.config = await loader(filepath, content);
143
+ }
144
+ result.filepath = filepath;
145
+ break dirLoop;
146
+ }
147
+ if (dir === stopDir || dir === parentDir(dir))
148
+ break dirLoop;
149
+ dir = parentDir(dir);
150
+ }
151
+ const transformed = result.filepath === '' && result.config === null
152
+ ? transform(null)
153
+ : transform(result);
154
+ if (cache) {
155
+ for (const p of visited)
156
+ searchCache.set(p, transformed);
157
+ }
158
+ return transformed;
159
+ },
160
+ async load(filepath) {
161
+ validateFilePath(filepath);
162
+ const absPath = path.resolve(process.cwd(), filepath);
163
+ if (cache && loadCache.has(absPath)) {
164
+ return loadCache.get(absPath);
165
+ }
166
+ const { base, ext } = path.parse(absPath);
167
+ const loaderKey = ext || 'noExt';
168
+ const loader = loaders[loaderKey];
169
+ validateLoader(loader, loaderKey);
170
+ const content = String(await fsReadFileAsync(absPath));
171
+ if (base === 'package.json') {
172
+ const pkg = await loader(absPath, content);
173
+ return emplace(loadCache, absPath, transform({
174
+ config: getPackageProp(packageProp, pkg),
175
+ filepath: absPath,
176
+ }));
177
+ }
178
+ const result = {
179
+ config: null,
180
+ filepath: absPath,
181
+ };
182
+ const isEmpty = content.trim() === '';
183
+ if (isEmpty && ignoreEmptySearchPlaces)
184
+ return emplace(loadCache, absPath, transform({
185
+ config: undefined,
186
+ filepath: absPath,
187
+ isEmpty: true,
188
+ }));
189
+ result.config = isEmpty
190
+ ? undefined
191
+ : await loader(absPath, content);
192
+ return emplace(loadCache, absPath, transform(isEmpty ? { ...result, isEmpty, config: undefined } : result));
193
+ },
194
+ clearLoadCache() {
195
+ if (cache)
196
+ loadCache.clear();
197
+ },
198
+ clearSearchCache() {
199
+ if (cache)
200
+ searchCache.clear();
201
+ },
202
+ clearCaches() {
203
+ if (cache) {
204
+ loadCache.clear();
205
+ searchCache.clear();
206
+ }
207
+ },
208
+ };
209
+ }
210
+ exports.lilconfig = lilconfig;
211
+ function lilconfigSync(name, options) {
212
+ const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache, } = getOptions(name, options);
213
+ const searchCache = new Map();
214
+ const loadCache = new Map();
215
+ const emplace = makeEmplace(cache);
216
+ return {
217
+ search(searchFrom = process.cwd()) {
218
+ const result = {
219
+ config: null,
220
+ filepath: '',
221
+ };
222
+ const visited = new Set();
223
+ let dir = searchFrom;
224
+ dirLoop: while (true) {
225
+ if (cache) {
226
+ const r = searchCache.get(dir);
227
+ if (r !== undefined) {
228
+ for (const p of visited)
229
+ searchCache.set(p, r);
230
+ return r;
231
+ }
232
+ visited.add(dir);
233
+ }
234
+ for (const searchPlace of searchPlaces) {
235
+ const filepath = path.join(dir, searchPlace);
236
+ try {
237
+ fs.accessSync(filepath);
238
+ }
239
+ catch (_a) {
240
+ continue;
241
+ }
242
+ const loaderKey = path.extname(searchPlace) || 'noExt';
243
+ const loader = loaders[loaderKey];
244
+ const content = String(fs.readFileSync(filepath));
245
+ if (searchPlace === 'package.json') {
246
+ const pkg = loader(filepath, content);
247
+ const maybeConfig = getPackageProp(packageProp, pkg);
248
+ if (maybeConfig != null) {
249
+ result.config = maybeConfig;
250
+ result.filepath = filepath;
251
+ break dirLoop;
252
+ }
253
+ continue;
254
+ }
255
+ const isEmpty = content.trim() === '';
256
+ if (isEmpty && ignoreEmptySearchPlaces)
257
+ continue;
258
+ if (isEmpty) {
259
+ result.isEmpty = true;
260
+ result.config = undefined;
261
+ }
262
+ else {
263
+ validateLoader(loader, loaderKey);
264
+ result.config = loader(filepath, content);
265
+ }
266
+ result.filepath = filepath;
267
+ break dirLoop;
268
+ }
269
+ if (dir === stopDir || dir === parentDir(dir))
270
+ break dirLoop;
271
+ dir = parentDir(dir);
272
+ }
273
+ const transformed = result.filepath === '' && result.config === null
274
+ ? transform(null)
275
+ : transform(result);
276
+ if (cache) {
277
+ for (const p of visited)
278
+ searchCache.set(p, transformed);
279
+ }
280
+ return transformed;
281
+ },
282
+ load(filepath) {
283
+ validateFilePath(filepath);
284
+ const absPath = path.resolve(process.cwd(), filepath);
285
+ if (cache && loadCache.has(absPath)) {
286
+ return loadCache.get(absPath);
287
+ }
288
+ const { base, ext } = path.parse(absPath);
289
+ const loaderKey = ext || 'noExt';
290
+ const loader = loaders[loaderKey];
291
+ validateLoader(loader, loaderKey);
292
+ const content = String(fs.readFileSync(absPath));
293
+ if (base === 'package.json') {
294
+ const pkg = loader(absPath, content);
295
+ return transform({
296
+ config: getPackageProp(packageProp, pkg),
297
+ filepath: absPath,
298
+ });
299
+ }
300
+ const result = {
301
+ config: null,
302
+ filepath: absPath,
303
+ };
304
+ const isEmpty = content.trim() === '';
305
+ if (isEmpty && ignoreEmptySearchPlaces)
306
+ return emplace(loadCache, absPath, transform({
307
+ filepath: absPath,
308
+ config: undefined,
309
+ isEmpty: true,
310
+ }));
311
+ result.config = isEmpty ? undefined : loader(absPath, content);
312
+ return emplace(loadCache, absPath, transform(isEmpty ? { ...result, isEmpty, config: undefined } : result));
313
+ },
314
+ clearLoadCache() {
315
+ if (cache)
316
+ loadCache.clear();
317
+ },
318
+ clearSearchCache() {
319
+ if (cache)
320
+ searchCache.clear();
321
+ },
322
+ clearCaches() {
323
+ if (cache) {
324
+ loadCache.clear();
325
+ searchCache.clear();
326
+ }
327
+ },
328
+ };
329
+ }
330
+ exports.lilconfigSync = lilconfigSync;
331
+
332
+
333
+ /***/ })
334
+
335
+ };