@lsst/pik-core 0.6.4 → 0.6.6
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -36
- package/dist/lib/comment-manipulator.d.ts +14 -0
- package/dist/lib/comment-manipulator.d.ts.map +1 -1
- package/dist/lib/config.d.ts +9 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/parser.d.ts +6 -1
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/single-switcher.d.ts +5 -1
- package/dist/lib/single-switcher.d.ts.map +1 -1
- package/dist/lib/switcher.d.ts +1 -1
- package/dist/lib/types/comment-style.d.ts +8 -0
- package/dist/lib/types/comment-style.d.ts.map +1 -1
- package/dist/lib/types/parse-result.d.ts +1 -1
- package/dist/lib/types/plugin.d.ts +1 -1
- package/dist/lib/types/selector.d.ts +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { Option, Selector, ParseResult, PikPlugin } from './lib/types/index.js';
|
|
2
2
|
export { CommentStyle } from './lib/types/index.js';
|
|
3
|
-
export { defineConfig, loadConfig, isValidPlugin, type PikConfig, } from './lib/config.js';
|
|
3
|
+
export { defineConfig, loadConfig, findLocalConfig, isValidPlugin, type PikConfig, } from './lib/config.js';
|
|
4
4
|
export { Parser } from './lib/parser.js';
|
|
5
5
|
export { Switcher } from './lib/switcher.js';
|
|
6
6
|
export { SingleSwitcher } from './lib/single-switcher.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import { resolve } from "path";
|
|
1
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
4
2
|
class CommentStyle {
|
|
5
3
|
constructor(lineComment, blockOpen, blockClose) {
|
|
6
4
|
this.lineComment = lineComment;
|
|
@@ -48,6 +46,25 @@ class CommentStyle {
|
|
|
48
46
|
const ext = extension.replace(/^\./, "").toLowerCase();
|
|
49
47
|
return CommentStyle.styles[ext] ?? CommentStyle.defaultStyle;
|
|
50
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Get comment style for a file path, handling dotfiles like .env correctly.
|
|
51
|
+
*
|
|
52
|
+
* Unlike fromExtension(), this method properly handles:
|
|
53
|
+
* - `.env` files (where extname returns '')
|
|
54
|
+
* - `.env.local`, `.env.development`, etc. (where extname returns '.local', '.development')
|
|
55
|
+
*/
|
|
56
|
+
static fromFilePath(filePath) {
|
|
57
|
+
const basename = filePath.split(/[/\\]/).pop() ?? "";
|
|
58
|
+
if (basename === ".env" || basename.startsWith(".env.")) {
|
|
59
|
+
return CommentStyle.styles["env"] ?? CommentStyle.defaultStyle;
|
|
60
|
+
}
|
|
61
|
+
const lastDot = basename.lastIndexOf(".");
|
|
62
|
+
if (lastDot > 0) {
|
|
63
|
+
const ext = basename.slice(lastDot + 1).toLowerCase();
|
|
64
|
+
return CommentStyle.styles[ext] ?? CommentStyle.defaultStyle;
|
|
65
|
+
}
|
|
66
|
+
return CommentStyle.defaultStyle;
|
|
67
|
+
}
|
|
51
68
|
/**
|
|
52
69
|
* Register a custom comment style for an extension
|
|
53
70
|
*/
|
|
@@ -59,24 +76,20 @@ class CommentStyle {
|
|
|
59
76
|
function defineConfig(config) {
|
|
60
77
|
return config;
|
|
61
78
|
}
|
|
62
|
-
const CONFIG_FILES = [
|
|
63
|
-
"pik.config.mts",
|
|
64
|
-
"pik.config.ts",
|
|
65
|
-
"pik.config.mjs",
|
|
66
|
-
"pik.config.js",
|
|
67
|
-
".pik.config.mts",
|
|
68
|
-
".pik.config.ts",
|
|
69
|
-
".pik.config.mjs",
|
|
70
|
-
".pik.config.js"
|
|
71
|
-
];
|
|
72
79
|
async function loadConfig(cwd = process.cwd()) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
const explorer = cosmiconfig("pik", {
|
|
81
|
+
searchStrategy: "global"
|
|
82
|
+
});
|
|
83
|
+
const result = await explorer.search(cwd);
|
|
84
|
+
return result?.config ?? null;
|
|
85
|
+
}
|
|
86
|
+
async function findLocalConfig(cwd = process.cwd()) {
|
|
87
|
+
const explorer = cosmiconfig("pik", {
|
|
88
|
+
searchStrategy: "none"
|
|
89
|
+
});
|
|
90
|
+
const result = await explorer.search(cwd);
|
|
91
|
+
if (result) {
|
|
92
|
+
return result.filepath.split("/").pop() || null;
|
|
80
93
|
}
|
|
81
94
|
return null;
|
|
82
95
|
}
|
|
@@ -99,6 +112,12 @@ class Parser {
|
|
|
99
112
|
static forExtension(extension) {
|
|
100
113
|
return new Parser(CommentStyle.fromExtension(extension));
|
|
101
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a parser for a file path, correctly handling dotfiles like .env
|
|
117
|
+
*/
|
|
118
|
+
static forFilePath(filePath) {
|
|
119
|
+
return new Parser(CommentStyle.fromFilePath(filePath));
|
|
120
|
+
}
|
|
102
121
|
/**
|
|
103
122
|
* Parse content string for pik selectors and options
|
|
104
123
|
*/
|
|
@@ -219,6 +238,13 @@ class CommentManipulator {
|
|
|
219
238
|
const { blockOpen, blockClose } = this.commentStyle;
|
|
220
239
|
return trimmed.startsWith(blockOpen) && trimmed.includes(blockClose);
|
|
221
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Check if a line is a line comment (not a block comment)
|
|
243
|
+
*/
|
|
244
|
+
isLineComment(line) {
|
|
245
|
+
const trimmed = line.trimStart();
|
|
246
|
+
return trimmed.startsWith(this.commentStyle.lineComment);
|
|
247
|
+
}
|
|
222
248
|
/**
|
|
223
249
|
* Comment out a line if not already commented.
|
|
224
250
|
* Uses the same comment style as the original if block-commented,
|
|
@@ -240,30 +266,48 @@ class CommentManipulator {
|
|
|
240
266
|
return `${indent}${this.commentStyle.lineComment} ${trimmed}`;
|
|
241
267
|
}
|
|
242
268
|
/**
|
|
243
|
-
* Uncomment a
|
|
269
|
+
* Uncomment a block comment
|
|
270
|
+
* @throws Error if the line is not a block comment
|
|
244
271
|
*/
|
|
245
|
-
|
|
272
|
+
uncommentBlockComment(line) {
|
|
273
|
+
if (!this.isBlockCommented(line)) {
|
|
274
|
+
throw new Error("Expected line to be a block comment");
|
|
275
|
+
}
|
|
246
276
|
const trimmed = line.trimStart();
|
|
247
277
|
const indent = line.slice(0, line.length - trimmed.length);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (!
|
|
261
|
-
|
|
278
|
+
const { blockOpen, blockClose } = this.commentStyle;
|
|
279
|
+
const afterOpen = trimmed.slice(blockOpen.length);
|
|
280
|
+
const closeIndex = afterOpen.indexOf(blockClose);
|
|
281
|
+
const content = afterOpen.slice(0, closeIndex).trim();
|
|
282
|
+
const rest = afterOpen.slice(closeIndex + blockClose.length);
|
|
283
|
+
return `${indent}${content}${rest}`;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Uncomment a line comment
|
|
287
|
+
* @throws Error if the line is not a line comment
|
|
288
|
+
*/
|
|
289
|
+
uncommentLineComment(line) {
|
|
290
|
+
if (!this.isLineComment(line)) {
|
|
291
|
+
throw new Error("Expected line to be a line comment");
|
|
262
292
|
}
|
|
293
|
+
const trimmed = line.trimStart();
|
|
294
|
+
const indent = line.slice(0, line.length - trimmed.length);
|
|
263
295
|
const withoutComment = trimmed.slice(this.commentStyle.lineComment.length);
|
|
264
296
|
const content = withoutComment.startsWith(" ") ? withoutComment.slice(1) : withoutComment;
|
|
265
297
|
return `${indent}${content}`;
|
|
266
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Uncomment a line if commented (handles both line and block comments)
|
|
301
|
+
*/
|
|
302
|
+
uncommentLine(line) {
|
|
303
|
+
if (this.isBlockCommented(line)) {
|
|
304
|
+
return this.uncommentBlockComment(line);
|
|
305
|
+
}
|
|
306
|
+
if (this.isLineComment(line)) {
|
|
307
|
+
return this.uncommentLineComment(line);
|
|
308
|
+
}
|
|
309
|
+
return line;
|
|
310
|
+
}
|
|
267
311
|
}
|
|
268
312
|
class Switcher extends CommentManipulator {
|
|
269
313
|
/**
|
|
@@ -285,6 +329,12 @@ class SingleSwitcher extends Switcher {
|
|
|
285
329
|
static forExtension(extension) {
|
|
286
330
|
return new SingleSwitcher(CommentStyle.fromExtension(extension));
|
|
287
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Create a switcher for a file path, correctly handling dotfiles like .env
|
|
334
|
+
*/
|
|
335
|
+
static forFilePath(filePath) {
|
|
336
|
+
return new SingleSwitcher(CommentStyle.fromFilePath(filePath));
|
|
337
|
+
}
|
|
288
338
|
/**
|
|
289
339
|
* Switch to a specific option, deactivating all others
|
|
290
340
|
*/
|
|
@@ -314,6 +364,7 @@ export {
|
|
|
314
364
|
SingleSwitcher,
|
|
315
365
|
Switcher,
|
|
316
366
|
defineConfig,
|
|
367
|
+
findLocalConfig,
|
|
317
368
|
isValidPlugin,
|
|
318
369
|
loadConfig
|
|
319
370
|
};
|
|
@@ -13,12 +13,26 @@ export declare abstract class CommentManipulator {
|
|
|
13
13
|
* Check if a line uses block comment style
|
|
14
14
|
*/
|
|
15
15
|
protected isBlockCommented(line: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a line is a line comment (not a block comment)
|
|
18
|
+
*/
|
|
19
|
+
private isLineComment;
|
|
16
20
|
/**
|
|
17
21
|
* Comment out a line if not already commented.
|
|
18
22
|
* Uses the same comment style as the original if block-commented,
|
|
19
23
|
* otherwise uses line comment style.
|
|
20
24
|
*/
|
|
21
25
|
protected commentLine(line: string, useBlockStyle?: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* Uncomment a block comment
|
|
28
|
+
* @throws Error if the line is not a block comment
|
|
29
|
+
*/
|
|
30
|
+
private uncommentBlockComment;
|
|
31
|
+
/**
|
|
32
|
+
* Uncomment a line comment
|
|
33
|
+
* @throws Error if the line is not a line comment
|
|
34
|
+
*/
|
|
35
|
+
private uncommentLineComment;
|
|
22
36
|
/**
|
|
23
37
|
* Uncomment a line if commented (handles both line and block comments)
|
|
24
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-manipulator.d.ts","sourceRoot":"","sources":["../../src/lib/comment-manipulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,8BAAsB,kBAAkB;IAC1B,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY;gBAA1B,YAAY,EAAE,YAAY;IAEzD;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAmBhD;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAUjD;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,UAAQ,GAAG,MAAM;IAwBlE;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"comment-manipulator.d.ts","sourceRoot":"","sources":["../../src/lib/comment-manipulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,8BAAsB,kBAAkB;IAC1B,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY;gBAA1B,YAAY,EAAE,YAAY;IAEzD;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAmBhD;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAUjD;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,UAAQ,GAAG,MAAM;IAwBlE;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAa9C"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PikPlugin } from './types/plugin.js';
|
|
1
|
+
import type { PikPlugin } from './types/plugin.js';
|
|
2
2
|
/**
|
|
3
3
|
* Base config interface - plugins extend this via declaration merging
|
|
4
4
|
*/
|
|
@@ -25,9 +25,16 @@ export interface PikConfig {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function defineConfig<T extends PikConfig>(config: T): T;
|
|
27
27
|
/**
|
|
28
|
-
* Load pik config
|
|
28
|
+
* Load pik config by searching up the directory tree
|
|
29
|
+
* Uses cosmiconfig to search for config files starting from cwd
|
|
30
|
+
* Uses 'global' strategy to search up to home directory
|
|
29
31
|
*/
|
|
30
32
|
export declare function loadConfig(cwd?: string): Promise<PikConfig | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a pik config file exists in the specified directory (not parent directories)
|
|
35
|
+
* Returns the config file name if found, null otherwise
|
|
36
|
+
*/
|
|
37
|
+
export declare function findLocalConfig(cwd?: string): Promise<string | null>;
|
|
31
38
|
/**
|
|
32
39
|
* Validate that an object satisfies the PikPlugin interface
|
|
33
40
|
*/
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAE9D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAO3B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAa5D"}
|
package/dist/lib/parser.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ParseResult
|
|
1
|
+
import type { ParseResult } from './types/index.js';
|
|
2
|
+
import { CommentStyle } from './types/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* Parser for pik selectors and options in source files
|
|
4
5
|
*/
|
|
@@ -11,6 +12,10 @@ export declare class Parser {
|
|
|
11
12
|
* Create a parser for a specific file extension
|
|
12
13
|
*/
|
|
13
14
|
static forExtension(extension: string): Parser;
|
|
15
|
+
/**
|
|
16
|
+
* Create a parser for a file path, correctly handling dotfiles like .env
|
|
17
|
+
*/
|
|
18
|
+
static forFilePath(filePath: string): Parser;
|
|
14
19
|
/**
|
|
15
20
|
* Parse content string for pik selectors and options
|
|
16
21
|
*/
|
package/dist/lib/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/lib/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAY,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,qBAAa,MAAM;IAIL,OAAO,CAAC,QAAQ,CAAC,YAAY;IAHzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAyB;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAyB;gBAEhC,YAAY,EAAE,YAAY;IAEvD;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI9C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAuDnC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA6B1B;;OAEG;IACH,OAAO,CAAC,eAAe;CAkBxB"}
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/lib/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAY,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,qBAAa,MAAM;IAIL,OAAO,CAAC,QAAQ,CAAC,YAAY;IAHzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAyB;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAyB;gBAEhC,YAAY,EAAE,YAAY;IAEvD;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI9C;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI5C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAuDnC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA6B1B;;OAEG;IACH,OAAO,CAAC,eAAe;CAkBxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Selector } from './types/index.js';
|
|
1
|
+
import type { Selector } from './types/index.js';
|
|
2
2
|
import { Switcher } from './switcher.js';
|
|
3
3
|
/**
|
|
4
4
|
* Switcher that allows only one option to be active at a time
|
|
@@ -8,6 +8,10 @@ export declare class SingleSwitcher extends Switcher {
|
|
|
8
8
|
* Create a switcher for a specific file extension
|
|
9
9
|
*/
|
|
10
10
|
static forExtension(extension: string): SingleSwitcher;
|
|
11
|
+
/**
|
|
12
|
+
* Create a switcher for a file path, correctly handling dotfiles like .env
|
|
13
|
+
*/
|
|
14
|
+
static forFilePath(filePath: string): SingleSwitcher;
|
|
11
15
|
/**
|
|
12
16
|
* Switch to a specific option, deactivating all others
|
|
13
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-switcher.d.ts","sourceRoot":"","sources":["../../src/lib/single-switcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc;IAItD;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAyBxE"}
|
|
1
|
+
{"version":3,"file":"single-switcher.d.ts","sourceRoot":"","sources":["../../src/lib/single-switcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc;IAItD;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc;IAIpD;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAyBxE"}
|
package/dist/lib/switcher.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ export declare class CommentStyle {
|
|
|
21
21
|
* Get comment style for a file extension
|
|
22
22
|
*/
|
|
23
23
|
static fromExtension(extension: string): CommentStyle;
|
|
24
|
+
/**
|
|
25
|
+
* Get comment style for a file path, handling dotfiles like .env correctly.
|
|
26
|
+
*
|
|
27
|
+
* Unlike fromExtension(), this method properly handles:
|
|
28
|
+
* - `.env` files (where extname returns '')
|
|
29
|
+
* - `.env.local`, `.env.development`, etc. (where extname returns '.local', '.development')
|
|
30
|
+
*/
|
|
31
|
+
static fromFilePath(filePath: string): CommentStyle;
|
|
24
32
|
/**
|
|
25
33
|
* Register a custom comment style for an extension
|
|
26
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-style.d.ts","sourceRoot":"","sources":["../../../src/lib/types/comment-style.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,YAAY;IAiCrB,4CAA4C;aAC5B,WAAW,EAAE,MAAM;IAjCrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAsB5B;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA0B;IAE9D,2CAA2C;IAC3C,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,0CAA0C;IAC1C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;;IAGlC,4CAA4C;IAC5B,WAAW,EAAE,MAAM,EACnC,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM;IAMrB;;OAEG;IACH,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAKrD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;CAI9D"}
|
|
1
|
+
{"version":3,"file":"comment-style.d.ts","sourceRoot":"","sources":["../../../src/lib/types/comment-style.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,YAAY;IAiCrB,4CAA4C;aAC5B,WAAW,EAAE,MAAM;IAjCrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAsB5B;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA0B;IAE9D,2CAA2C;IAC3C,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,0CAA0C;IAC1C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;;IAGlC,4CAA4C;IAC5B,WAAW,EAAE,MAAM,EACnC,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM;IAMrB;;OAEG;IACH,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAKrD;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY;IAkBnD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;CAI9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsst/pik-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "Core library for parsing and switching @pik config markers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"!**/*.tsbuildinfo"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"commander": "^14.0.0"
|
|
37
|
+
"commander": "^14.0.0",
|
|
38
|
+
"cosmiconfig": "^9.0.0"
|
|
38
39
|
}
|
|
39
40
|
}
|