@css-modules-kit/codegen 0.4.1 → 0.6.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/bin/cmk.mjs +1 -1
- package/dist/runner.d.ts +2 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +7 -7
- package/dist/runner.js.map +1 -1
- package/package.json +2 -10
- package/src/runner.ts +8 -7
package/bin/cmk.mjs
CHANGED
package/dist/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ParsedArgs } from './cli.js';
|
|
1
2
|
import type { Logger } from './logger/logger.js';
|
|
2
3
|
/**
|
|
3
4
|
* Run css-modules-kit .d.ts generation.
|
|
@@ -5,5 +6,5 @@ import type { Logger } from './logger/logger.js';
|
|
|
5
6
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
6
7
|
* @throws {WriteDtsFileError}
|
|
7
8
|
*/
|
|
8
|
-
export declare function runCMK(
|
|
9
|
+
export declare function runCMK(args: ParsedArgs, logger: Logger): Promise<void>;
|
|
9
10
|
//# sourceMappingURL=runner.d.ts.map
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAoCjD;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiE5E"}
|
package/dist/runner.js
CHANGED
|
@@ -12,7 +12,7 @@ const error_js_1 = require("./error.js");
|
|
|
12
12
|
/**
|
|
13
13
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
14
14
|
*/
|
|
15
|
-
async function parseCSSModuleByFileName(fileName) {
|
|
15
|
+
async function parseCSSModuleByFileName(fileName, config) {
|
|
16
16
|
let text;
|
|
17
17
|
try {
|
|
18
18
|
text = await (0, promises_1.readFile)(fileName, 'utf-8');
|
|
@@ -20,7 +20,7 @@ async function parseCSSModuleByFileName(fileName) {
|
|
|
20
20
|
catch (error) {
|
|
21
21
|
throw new error_js_1.ReadCSSModuleFileError(fileName, error);
|
|
22
22
|
}
|
|
23
|
-
return (0, core_1.parseCSSModule)(text, { fileName, safe: false });
|
|
23
|
+
return (0, core_1.parseCSSModule)(text, { fileName, safe: false, keyframes: config.keyframes });
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* @throws {WriteDtsFileError}
|
|
@@ -39,8 +39,8 @@ async function writeDtsByCSSModule(cssModule, { dtsOutDir, basePath, arbitraryEx
|
|
|
39
39
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
40
40
|
* @throws {WriteDtsFileError}
|
|
41
41
|
*/
|
|
42
|
-
async function runCMK(
|
|
43
|
-
const config = (0, core_1.readConfigFile)(project);
|
|
42
|
+
async function runCMK(args, logger) {
|
|
43
|
+
const config = (0, core_1.readConfigFile)(args.project);
|
|
44
44
|
if (config.diagnostics.length > 0) {
|
|
45
45
|
logger.logDiagnostics(config.diagnostics);
|
|
46
46
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -62,7 +62,7 @@ async function runCMK(project, clean, logger) {
|
|
|
62
62
|
]);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
const parseResults = await Promise.all(fileNames.map(async (fileName) => parseCSSModuleByFileName(fileName)));
|
|
65
|
+
const parseResults = await Promise.all(fileNames.map(async (fileName) => parseCSSModuleByFileName(fileName, config)));
|
|
66
66
|
for (const parseResult of parseResults) {
|
|
67
67
|
cssModuleMap.set(parseResult.cssModule.fileName, parseResult.cssModule);
|
|
68
68
|
syntacticDiagnostics.push(...parseResult.diagnostics);
|
|
@@ -76,7 +76,7 @@ async function runCMK(project, clean, logger) {
|
|
|
76
76
|
const exportBuilder = (0, core_1.createExportBuilder)({ getCSSModule, matchesPattern, resolver });
|
|
77
77
|
const semanticDiagnostics = [];
|
|
78
78
|
for (const { cssModule } of parseResults) {
|
|
79
|
-
const diagnostics = (0, core_1.checkCSSModule)(cssModule, exportBuilder, matchesPattern, resolver, getCSSModule);
|
|
79
|
+
const diagnostics = (0, core_1.checkCSSModule)(cssModule, config, exportBuilder, matchesPattern, resolver, getCSSModule);
|
|
80
80
|
semanticDiagnostics.push(...diagnostics);
|
|
81
81
|
}
|
|
82
82
|
if (semanticDiagnostics.length > 0) {
|
|
@@ -84,7 +84,7 @@ async function runCMK(project, clean, logger) {
|
|
|
84
84
|
// eslint-disable-next-line n/no-process-exit
|
|
85
85
|
process.exit(1);
|
|
86
86
|
}
|
|
87
|
-
if (clean) {
|
|
87
|
+
if (args.clean) {
|
|
88
88
|
await (0, promises_1.rm)(config.dtsOutDir, { recursive: true, force: true });
|
|
89
89
|
}
|
|
90
90
|
await Promise.all(parseResults.map(async (parseResult) => writeDtsByCSSModule(parseResult.cssModule, config, resolver, matchesPattern)));
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;AAkEA,wBAiEC;AAnID,+CAAgD;AAUhD,gDAS+B;AAC/B,4DAA4B;AAE5B,mDAA+C;AAC/C,yCAAoD;AAGpD;;GAEG;AACH,KAAK,UAAU,wBAAwB,CAAC,QAAgB,EAAE,MAAiB;IACzE,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,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AAC;IAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,aAAa,GAAG,IAAA,0BAAmB,EAAC,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtF,MAAM,mBAAmB,GAAiB,EAAE,CAAC;IAC7C,KAAK,MAAM,EAAE,SAAS,EAAE,IAAI,YAAY,EAAE,CAAC;QACzC,MAAM,WAAW,GAAG,IAAA,qBAAc,EAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC7G,mBAAmB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC3C,6CAA6C;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,IAAA,aAAE,EAAC,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,CACrC,mBAAmB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,CAC7E,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-modules-kit/codegen",
|
|
3
3
|
"description": "A tool for generating `*.d.ts` files for `*.module.css`.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|
|
@@ -12,14 +12,6 @@
|
|
|
12
12
|
"author": "mizdra <pp.mizdra@gmail.com>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"private": false,
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"default": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"default": "./dist/index.js"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
15
|
"scripts": {
|
|
24
16
|
"build": "tsc -b tsconfig.build.json"
|
|
25
17
|
},
|
|
@@ -46,7 +38,7 @@
|
|
|
46
38
|
"dist"
|
|
47
39
|
],
|
|
48
40
|
"dependencies": {
|
|
49
|
-
"@css-modules-kit/core": "^0.
|
|
41
|
+
"@css-modules-kit/core": "^0.6.0"
|
|
50
42
|
},
|
|
51
43
|
"peerDependencies": {
|
|
52
44
|
"typescript": "^5.7.3"
|
package/src/runner.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
readConfigFile,
|
|
20
20
|
} from '@css-modules-kit/core';
|
|
21
21
|
import ts from 'typescript';
|
|
22
|
+
import type { ParsedArgs } from './cli.js';
|
|
22
23
|
import { writeDtsFile } from './dts-writer.js';
|
|
23
24
|
import { ReadCSSModuleFileError } from './error.js';
|
|
24
25
|
import type { Logger } from './logger/logger.js';
|
|
@@ -26,14 +27,14 @@ import type { Logger } from './logger/logger.js';
|
|
|
26
27
|
/**
|
|
27
28
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
28
29
|
*/
|
|
29
|
-
async function parseCSSModuleByFileName(fileName: string): Promise<ParseCSSModuleResult> {
|
|
30
|
+
async function parseCSSModuleByFileName(fileName: string, config: CMKConfig): Promise<ParseCSSModuleResult> {
|
|
30
31
|
let text: string;
|
|
31
32
|
try {
|
|
32
33
|
text = await readFile(fileName, 'utf-8');
|
|
33
34
|
} catch (error) {
|
|
34
35
|
throw new ReadCSSModuleFileError(fileName, error);
|
|
35
36
|
}
|
|
36
|
-
return parseCSSModule(text, { fileName, safe: false });
|
|
37
|
+
return parseCSSModule(text, { fileName, safe: false, keyframes: config.keyframes });
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -63,8 +64,8 @@ async function writeDtsByCSSModule(
|
|
|
63
64
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
64
65
|
* @throws {WriteDtsFileError}
|
|
65
66
|
*/
|
|
66
|
-
export async function runCMK(
|
|
67
|
-
const config = readConfigFile(project);
|
|
67
|
+
export async function runCMK(args: ParsedArgs, logger: Logger): Promise<void> {
|
|
68
|
+
const config = readConfigFile(args.project);
|
|
68
69
|
if (config.diagnostics.length > 0) {
|
|
69
70
|
logger.logDiagnostics(config.diagnostics);
|
|
70
71
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -94,7 +95,7 @@ export async function runCMK(project: string, clean: boolean, logger: Logger): P
|
|
|
94
95
|
]);
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
|
-
const parseResults = await Promise.all(fileNames.map(async (fileName) => parseCSSModuleByFileName(fileName)));
|
|
98
|
+
const parseResults = await Promise.all(fileNames.map(async (fileName) => parseCSSModuleByFileName(fileName, config)));
|
|
98
99
|
for (const parseResult of parseResults) {
|
|
99
100
|
cssModuleMap.set(parseResult.cssModule.fileName, parseResult.cssModule);
|
|
100
101
|
syntacticDiagnostics.push(...parseResult.diagnostics);
|
|
@@ -110,7 +111,7 @@ export async function runCMK(project: string, clean: boolean, logger: Logger): P
|
|
|
110
111
|
const exportBuilder = createExportBuilder({ getCSSModule, matchesPattern, resolver });
|
|
111
112
|
const semanticDiagnostics: Diagnostic[] = [];
|
|
112
113
|
for (const { cssModule } of parseResults) {
|
|
113
|
-
const diagnostics = checkCSSModule(cssModule, exportBuilder, matchesPattern, resolver, getCSSModule);
|
|
114
|
+
const diagnostics = checkCSSModule(cssModule, config, exportBuilder, matchesPattern, resolver, getCSSModule);
|
|
114
115
|
semanticDiagnostics.push(...diagnostics);
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -120,7 +121,7 @@ export async function runCMK(project: string, clean: boolean, logger: Logger): P
|
|
|
120
121
|
process.exit(1);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
if (clean) {
|
|
124
|
+
if (args.clean) {
|
|
124
125
|
await rm(config.dtsOutDir, { recursive: true, force: true });
|
|
125
126
|
}
|
|
126
127
|
await Promise.all(
|