@lsst/pik 0.0.1 → 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.
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +18 -7
- package/dist/lib/config.spec.js +22 -0
- package/package.json +2 -2
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":"AAIA,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAEzD;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAEzD;AAaD,wBAAsB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAYvF"}
|
package/dist/lib/config.js
CHANGED
|
@@ -4,13 +4,24 @@ import { resolve } from 'path';
|
|
|
4
4
|
export function defineConfig(config) {
|
|
5
5
|
return config;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const CONFIG_FILES = [
|
|
8
|
+
'pik.config.mts',
|
|
9
|
+
'pik.config.ts',
|
|
10
|
+
'pik.config.mjs',
|
|
11
|
+
'pik.config.js',
|
|
12
|
+
'.pik.config.mts',
|
|
13
|
+
'.pik.config.ts',
|
|
14
|
+
'.pik.config.mjs',
|
|
15
|
+
'.pik.config.js',
|
|
16
|
+
];
|
|
8
17
|
export async function loadConfig(cwd = process.cwd()) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
for (const configFile of CONFIG_FILES) {
|
|
19
|
+
const configPath = resolve(cwd, configFile);
|
|
20
|
+
if (existsSync(configPath)) {
|
|
21
|
+
const configUrl = pathToFileURL(configPath).href;
|
|
22
|
+
const module = await import(configUrl);
|
|
23
|
+
return module.default;
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
|
-
|
|
14
|
-
const module = await import(configUrl);
|
|
15
|
-
return module.default;
|
|
26
|
+
return null;
|
|
16
27
|
}
|
package/dist/lib/config.spec.js
CHANGED
|
@@ -31,5 +31,27 @@ describe('config', () => {
|
|
|
31
31
|
const config = await loadConfig(testDir);
|
|
32
32
|
expect(config).toEqual({ include: ['src/**/*.ts'] });
|
|
33
33
|
});
|
|
34
|
+
it('should load config from pik.config.mts', async () => {
|
|
35
|
+
const configContent = `
|
|
36
|
+
export default { include: ['lib/**/*.ts'] };
|
|
37
|
+
`;
|
|
38
|
+
await writeFile(join(testDir, 'pik.config.mts'), configContent);
|
|
39
|
+
const config = await loadConfig(testDir);
|
|
40
|
+
expect(config).toEqual({ include: ['lib/**/*.ts'] });
|
|
41
|
+
});
|
|
42
|
+
it('should prefer pik.config.mts over pik.config.ts', async () => {
|
|
43
|
+
await writeFile(join(testDir, 'pik.config.mts'), `export default { include: ['mts'] };`);
|
|
44
|
+
await writeFile(join(testDir, 'pik.config.ts'), `export default { include: ['ts'] };`);
|
|
45
|
+
const config = await loadConfig(testDir);
|
|
46
|
+
expect(config).toEqual({ include: ['mts'] });
|
|
47
|
+
});
|
|
48
|
+
it('should load config from .pik.config.mts (hidden)', async () => {
|
|
49
|
+
const configContent = `
|
|
50
|
+
export default { include: ['hidden/**/*.ts'] };
|
|
51
|
+
`;
|
|
52
|
+
await writeFile(join(testDir, '.pik.config.mts'), configContent);
|
|
53
|
+
const config = await loadConfig(testDir);
|
|
54
|
+
expect(config).toEqual({ include: ['hidden/**/*.ts'] });
|
|
55
|
+
});
|
|
34
56
|
});
|
|
35
57
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsst/pik",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CLI tool for switching config options in source files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "^8.1.0",
|
|
43
|
-
"@lsst/pik-core": "
|
|
43
|
+
"@lsst/pik-core": "*",
|
|
44
44
|
"commander": "^14.0.2",
|
|
45
45
|
"glob": "^10.5.0",
|
|
46
46
|
"picocolors": "^1.1.1",
|