@css-modules-kit/codegen 0.6.0 → 0.7.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/README.md +1 -0
- package/bin/cmk.mjs +23 -8
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/formatter.d.ts +1 -0
- package/dist/logger/formatter.d.ts.map +1 -1
- package/dist/logger/formatter.js +12 -0
- package/dist/logger/formatter.js.map +1 -1
- package/dist/logger/logger.d.ts +6 -3
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +19 -5
- package/dist/logger/logger.js.map +1 -1
- package/dist/project.d.ts +46 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +168 -0
- package/dist/project.js.map +1 -0
- package/dist/runner.d.ts +26 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +121 -67
- package/dist/runner.js.map +1 -1
- package/package.json +3 -2
- package/src/cli.ts +4 -0
- package/src/index.ts +1 -1
- package/src/logger/formatter.ts +12 -0
- package/src/logger/logger.ts +23 -9
- package/src/project.ts +229 -0
- package/src/runner.ts +138 -107
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ Options:
|
|
|
41
41
|
--project, -p The path to its configuration file, or to a folder with a 'tsconfig.json'.
|
|
42
42
|
--pretty Enable color and formatting in output to make errors easier to read.
|
|
43
43
|
--clean Remove the output directory before generating files. [default: false]
|
|
44
|
+
--watch, -w Watch for changes and regenerate files. [default: false]
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
## Configuration
|
package/bin/cmk.mjs
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable n/no-process-exit */
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
createLogger,
|
|
6
|
+
parseCLIArgs,
|
|
7
|
+
printHelpText,
|
|
8
|
+
printVersion,
|
|
9
|
+
runCMK,
|
|
10
|
+
runCMKInWatchMode,
|
|
11
|
+
shouldBePretty,
|
|
12
|
+
} from '../dist/index.js';
|
|
6
13
|
|
|
7
14
|
const cwd = process.cwd();
|
|
8
15
|
let logger = createLogger(cwd, shouldBePretty(undefined));
|
|
@@ -19,11 +26,19 @@ try {
|
|
|
19
26
|
process.exit(0);
|
|
20
27
|
}
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
// Normal mode and watch mode behave differently when errors occur.
|
|
30
|
+
// - Normal mode: Outputs errors to the terminal and exits the process with exit code 1.
|
|
31
|
+
// - Watch mode: Outputs errors to the terminal but does not terminate the process. Continues watching the file.
|
|
32
|
+
if (args.watch) {
|
|
33
|
+
const watcher = await runCMKInWatchMode(args, logger);
|
|
34
|
+
process.on('SIGINT', () => watcher.close());
|
|
35
|
+
} else {
|
|
36
|
+
const success = await runCMK(args, logger);
|
|
37
|
+
if (!success) {
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
|
-
|
|
41
|
+
} catch (e) {
|
|
42
|
+
logger.logError(e);
|
|
43
|
+
process.exit(1);
|
|
29
44
|
}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAiBA,wBAAgB,aAAa,IAAI,IAAI,CAGpC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAGnC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAyBpE"}
|
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ Options:
|
|
|
19
19
|
--project, -p The path to its configuration file, or to a folder with a 'tsconfig.json'.
|
|
20
20
|
--pretty Enable color and formatting in output to make errors easier to read.
|
|
21
21
|
--clean Remove the output directory before generating files. [default: false]
|
|
22
|
+
--watch, -w Watch for changes and regenerate files. [default: false]
|
|
22
23
|
`;
|
|
23
24
|
function printHelpText() {
|
|
24
25
|
// eslint-disable-next-line no-console
|
|
@@ -42,6 +43,7 @@ function parseCLIArgs(args, cwd) {
|
|
|
42
43
|
project: { type: 'string', short: 'p', default: '.' },
|
|
43
44
|
pretty: { type: 'boolean' },
|
|
44
45
|
clean: { type: 'boolean', default: false },
|
|
46
|
+
watch: { type: 'boolean', short: 'w', default: false },
|
|
45
47
|
},
|
|
46
48
|
allowNegative: true,
|
|
47
49
|
});
|
|
@@ -51,6 +53,7 @@ function parseCLIArgs(args, cwd) {
|
|
|
51
53
|
project: (0, core_1.resolve)(cwd, values.project),
|
|
52
54
|
pretty: values.pretty,
|
|
53
55
|
clean: values.clean,
|
|
56
|
+
watch: values.watch,
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
catch (cause) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;AAiB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AAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { runCMK } from './runner.js';
|
|
1
|
+
export { runCMK, runCMKInWatchMode } from './runner.js';
|
|
2
2
|
export { type Logger, createLogger } from './logger/logger.js';
|
|
3
3
|
export { WriteDtsFileError, ReadCSSModuleFileError } from './error.js';
|
|
4
4
|
export { parseCLIArgs, printHelpText, printVersion } from './cli.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shouldBePretty = exports.printVersion = exports.printHelpText = exports.parseCLIArgs = exports.ReadCSSModuleFileError = exports.WriteDtsFileError = exports.createLogger = exports.runCMK = void 0;
|
|
3
|
+
exports.shouldBePretty = exports.printVersion = exports.printHelpText = exports.parseCLIArgs = exports.ReadCSSModuleFileError = exports.WriteDtsFileError = exports.createLogger = exports.runCMKInWatchMode = exports.runCMK = void 0;
|
|
4
4
|
var runner_js_1 = require("./runner.js");
|
|
5
5
|
Object.defineProperty(exports, "runCMK", { enumerable: true, get: function () { return runner_js_1.runCMK; } });
|
|
6
|
+
Object.defineProperty(exports, "runCMKInWatchMode", { enumerable: true, get: function () { return runner_js_1.runCMKInWatchMode; } });
|
|
6
7
|
var logger_js_1 = require("./logger/logger.js");
|
|
7
8
|
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_js_1.createLogger; } });
|
|
8
9
|
var error_js_1 = require("./error.js");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAwD;AAA/C,mGAAA,MAAM,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAClC,gDAA+D;AAAzC,yGAAA,YAAY,OAAA;AAClC,uCAAuE;AAA9D,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAClD,mCAAqE;AAA5D,sGAAA,YAAY,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AAClD,2DAA2D;AAAlD,+GAAA,cAAc,OAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
export declare function formatDiagnostics(diagnostics: ts.Diagnostic[], host: ts.FormatDiagnosticsHost, pretty: boolean): string;
|
|
3
|
+
export declare function formatTime(date: Date, pretty: boolean): string;
|
|
3
4
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/logger/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/logger/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,EAAE,CAAC,UAAU,EAAE,EAC5B,IAAI,EAAE,EAAE,CAAC,qBAAqB,EAC9B,MAAM,EAAE,OAAO,GACd,MAAM,CAOR;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAO9D"}
|
package/dist/logger/formatter.js
CHANGED
|
@@ -4,7 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.formatDiagnostics = formatDiagnostics;
|
|
7
|
+
exports.formatTime = formatTime;
|
|
7
8
|
const typescript_1 = __importDefault(require("typescript"));
|
|
9
|
+
const GRAY = '\u001b[90m';
|
|
10
|
+
const RESET = '\u001b[0m';
|
|
8
11
|
function formatDiagnostics(diagnostics, host, pretty) {
|
|
9
12
|
const format = pretty ? typescript_1.default.formatDiagnosticsWithColorAndContext : typescript_1.default.formatDiagnostics;
|
|
10
13
|
let result = '';
|
|
@@ -13,4 +16,13 @@ function formatDiagnostics(diagnostics, host, pretty) {
|
|
|
13
16
|
}
|
|
14
17
|
return result;
|
|
15
18
|
}
|
|
19
|
+
function formatTime(date, pretty) {
|
|
20
|
+
const text = date.toLocaleTimeString('en-US', { timeZone: 'UTC' });
|
|
21
|
+
if (pretty) {
|
|
22
|
+
return `[${GRAY}${text}${RESET}]`;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return `[${text}]`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
16
28
|
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/logger/formatter.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/logger/formatter.ts"],"names":[],"mappings":";;;;;AAKA,8CAWC;AAED,gCAOC;AAzBD,4DAA4B;AAE5B,MAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,MAAM,KAAK,GAAG,WAAW,CAAC;AAE1B,SAAgB,iBAAiB,CAC/B,WAA4B,EAC5B,IAA8B,EAC9B,MAAe;IAEf,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAE,CAAC,oCAAoC,CAAC,CAAC,CAAC,oBAAE,CAAC,iBAAiB,CAAC;IACvF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,IAAI,MAAM,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,UAAU,CAAC,IAAU,EAAE,MAAe;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,GAAG,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/logger/logger.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { type Diagnostic
|
|
1
|
+
import { type Diagnostic } from '@css-modules-kit/core';
|
|
2
2
|
export interface Logger {
|
|
3
3
|
logDiagnostics(diagnostics: Diagnostic[]): void;
|
|
4
|
-
|
|
5
|
-
logMessage(message: string
|
|
4
|
+
logError(error: unknown): void;
|
|
5
|
+
logMessage(message: string, options?: {
|
|
6
|
+
time?: boolean;
|
|
7
|
+
}): void;
|
|
8
|
+
clearScreen(): void;
|
|
6
9
|
}
|
|
7
10
|
export declare function createLogger(cwd: string, pretty: boolean): Logger;
|
|
8
11
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAI5G,MAAM,WAAW,MAAM;IACrB,cAAc,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAChE,WAAW,IAAI,IAAI,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAwCjE"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createLogger = createLogger;
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
7
8
|
const core_1 = require("@css-modules-kit/core");
|
|
8
9
|
const typescript_1 = __importDefault(require("typescript"));
|
|
9
10
|
const formatter_js_1 = require("./formatter.js");
|
|
@@ -21,12 +22,25 @@ function createLogger(cwd, pretty) {
|
|
|
21
22
|
const result = (0, formatter_js_1.formatDiagnostics)(diagnostics.map((d) => (0, core_1.convertDiagnostic)(d, getSourceFile)), host, pretty);
|
|
22
23
|
process.stderr.write(result);
|
|
23
24
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
logError(error) {
|
|
26
|
+
// NOTE: SystemErrors are errors expected by the css-modules-kit specification and may occur within normal usage.
|
|
27
|
+
// These errors are formatted clearly and concisely. No stack trace is output.
|
|
28
|
+
//
|
|
29
|
+
// All other errors are unexpected errors. To assist in debugging when these errors occur, a stack trace is output.
|
|
30
|
+
if (error instanceof core_1.SystemError) {
|
|
31
|
+
const result = (0, formatter_js_1.formatDiagnostics)([(0, core_1.convertSystemError)(error)], host, pretty);
|
|
32
|
+
process.stderr.write(result);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
process.stderr.write(`${(0, node_util_1.inspect)(error, { colors: pretty })}\n`);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
logMessage(message, options) {
|
|
39
|
+
const header = options?.time ? `${(0, formatter_js_1.formatTime)(new Date(), pretty)} ` : '';
|
|
40
|
+
process.stdout.write(`${header}${message}\n`);
|
|
27
41
|
},
|
|
28
|
-
|
|
29
|
-
process.stdout.write(
|
|
42
|
+
clearScreen() {
|
|
43
|
+
process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
|
|
30
44
|
},
|
|
31
45
|
};
|
|
32
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;AAaA,oCAwCC;AArDD,yCAAoC;AAEpC,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C;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,mBAAO,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;QACD,UAAU,CAAC,OAAe,EAAE,OAA4B;YACtD,MAAM,MAAM,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAA,yBAAU,EAAC,IAAI,IAAI,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACzE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC;QAChD,CAAC;QACD,WAAW;YACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Diagnostic } from '@css-modules-kit/core';
|
|
2
|
+
import { type CMKConfig } from '@css-modules-kit/core';
|
|
3
|
+
interface ProjectArgs {
|
|
4
|
+
project: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Project {
|
|
7
|
+
config: CMKConfig;
|
|
8
|
+
/** Whether the file matches the wildcard patterns in `include` / `exclude` options */
|
|
9
|
+
isWildcardMatchedFile(fileName: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Add a file to the project.
|
|
12
|
+
* @throws {ReadCSSModuleFileError}
|
|
13
|
+
*/
|
|
14
|
+
addFile(fileName: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Update a file in the project.
|
|
17
|
+
* @throws {ReadCSSModuleFileError}
|
|
18
|
+
*/
|
|
19
|
+
updateFile(fileName: string): void;
|
|
20
|
+
/** Remove a file from the project. */
|
|
21
|
+
removeFile(fileName: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get all diagnostics.
|
|
24
|
+
* Including three types of diagnostics: project diagnostics, syntactic diagnostics, and semantic diagnostics.
|
|
25
|
+
* - Project diagnostics: For example, it includes configuration errors in tsconfig.json or warnings when there are no target files.
|
|
26
|
+
* - Syntactic diagnostics: Syntax errors in CSS Module files.
|
|
27
|
+
* - Semantic diagnostics: Errors related to the use of imports and exports in CSS module files.
|
|
28
|
+
* If there are any project diagnostics or syntactic diagnostics, semantic diagnostics will be skipped.
|
|
29
|
+
*/
|
|
30
|
+
getDiagnostics(): Diagnostic[];
|
|
31
|
+
/**
|
|
32
|
+
* Emit .d.ts files for all project files.
|
|
33
|
+
* @throws {WriteDtsFileError}
|
|
34
|
+
*/
|
|
35
|
+
emitDtsFiles(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a Project instance.
|
|
39
|
+
* Project is like a facade that calls core operations such as loading settings, parsing CSS Module files, and performing checks.
|
|
40
|
+
* The parsing and checking results are cached, and methods are also provided to clear the cache when files change.
|
|
41
|
+
* @throws {TsConfigFileNotFoundError}
|
|
42
|
+
* @throws {ReadCSSModuleFileError}
|
|
43
|
+
*/
|
|
44
|
+
export declare function createProject(args: ProjectArgs): Project;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,uBAAuB,CAAC;AAK/B,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,SAAS,CAAC;IAClB,sFAAsF;IACtF,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACjD;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,sCAAsC;IACtC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC;;;;;;;OAOG;IACH,cAAc,IAAI,UAAU,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAoKxD"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createProject = createProject;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const core_1 = require("@css-modules-kit/core");
|
|
9
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
+
const dts_writer_js_1 = require("./dts-writer.js");
|
|
11
|
+
const error_js_1 = require("./error.js");
|
|
12
|
+
/**
|
|
13
|
+
* Create a Project instance.
|
|
14
|
+
* Project is like a facade that calls core operations such as loading settings, parsing CSS Module files, and performing checks.
|
|
15
|
+
* The parsing and checking results are cached, and methods are also provided to clear the cache when files change.
|
|
16
|
+
* @throws {TsConfigFileNotFoundError}
|
|
17
|
+
* @throws {ReadCSSModuleFileError}
|
|
18
|
+
*/
|
|
19
|
+
function createProject(args) {
|
|
20
|
+
const config = (0, core_1.readConfigFile)(args.project);
|
|
21
|
+
const getCanonicalFileName = (fileName) => typescript_1.default.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
|
22
|
+
const moduleResolutionCache = typescript_1.default.createModuleResolutionCache(config.basePath, getCanonicalFileName, config.compilerOptions);
|
|
23
|
+
const resolver = (0, core_1.createResolver)(config.compilerOptions, moduleResolutionCache);
|
|
24
|
+
const matchesPattern = (0, core_1.createMatchesPattern)(config);
|
|
25
|
+
const cssModuleMap = new Map();
|
|
26
|
+
const semanticDiagnosticsMap = new Map();
|
|
27
|
+
// Tracks whether .d.ts has been emitted after the last change
|
|
28
|
+
const emittedSet = new Set();
|
|
29
|
+
const getCSSModule = (path) => cssModuleMap.get(path);
|
|
30
|
+
const exportBuilder = (0, core_1.createExportBuilder)({ getCSSModule, matchesPattern, resolver });
|
|
31
|
+
for (const fileName of (0, core_1.getFileNamesByPattern)(config)) {
|
|
32
|
+
// NOTE: Files may be deleted between executing `getFileNamesByPattern` and `tryParseCSSModule`.
|
|
33
|
+
// Therefore, `tryParseCSSModule` may return `undefined`.
|
|
34
|
+
const cssModule = tryParseCSSModule(fileName);
|
|
35
|
+
if (cssModule)
|
|
36
|
+
cssModuleMap.set(fileName, cssModule);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @throws {ReadCSSModuleFileError}
|
|
40
|
+
*/
|
|
41
|
+
function addFile(fileName) {
|
|
42
|
+
if (cssModuleMap.has(fileName))
|
|
43
|
+
return;
|
|
44
|
+
const cssModule = tryParseCSSModule(fileName);
|
|
45
|
+
if (!cssModule)
|
|
46
|
+
return;
|
|
47
|
+
cssModuleMap.set(fileName, cssModule);
|
|
48
|
+
// TODO: Delete only the minimum amount of check stage cache
|
|
49
|
+
moduleResolutionCache.clear();
|
|
50
|
+
exportBuilder.clearCache();
|
|
51
|
+
semanticDiagnosticsMap.clear();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @throws {ReadCSSModuleFileError}
|
|
55
|
+
*/
|
|
56
|
+
function updateFile(fileName) {
|
|
57
|
+
if (!cssModuleMap.has(fileName))
|
|
58
|
+
return;
|
|
59
|
+
const cssModule = tryParseCSSModule(fileName);
|
|
60
|
+
if (!cssModule)
|
|
61
|
+
return;
|
|
62
|
+
cssModuleMap.set(fileName, cssModule);
|
|
63
|
+
// TODO: Delete only the minimum amount of check stage cache
|
|
64
|
+
exportBuilder.clearCache();
|
|
65
|
+
semanticDiagnosticsMap.clear();
|
|
66
|
+
emittedSet.delete(fileName);
|
|
67
|
+
}
|
|
68
|
+
function removeFile(fileName) {
|
|
69
|
+
if (!cssModuleMap.has(fileName))
|
|
70
|
+
return;
|
|
71
|
+
cssModuleMap.delete(fileName);
|
|
72
|
+
// TODO: Delete only the minimum amount of check stage cache
|
|
73
|
+
moduleResolutionCache.clear();
|
|
74
|
+
exportBuilder.clearCache();
|
|
75
|
+
semanticDiagnosticsMap.clear();
|
|
76
|
+
emittedSet.delete(fileName);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @throws {ReadCSSModuleFileError}
|
|
80
|
+
*/
|
|
81
|
+
function tryParseCSSModule(fileName) {
|
|
82
|
+
let text;
|
|
83
|
+
try {
|
|
84
|
+
// NOTE: We are not using asynchronous APIs for the following reasons:
|
|
85
|
+
//
|
|
86
|
+
// - Asynchronous APIs are slow in Node.js.
|
|
87
|
+
// - https://github.com/nodejs/performance/issues/151
|
|
88
|
+
// - Handling race conditions is cumbersome.
|
|
89
|
+
// - Using an asynchronous API makes `addFile` asynchronous too.
|
|
90
|
+
// - If `deleteFile` runs while `addFile` is executing, a race condition occurs.
|
|
91
|
+
// - Avoiding this requires something like a mutex. However, implementing that is cumbersome.
|
|
92
|
+
text = (0, node_fs_1.readFileSync)(fileName, 'utf-8');
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (isNodeJSSystemError(error) && error.code === 'ENOENT') {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
throw new error_js_1.ReadCSSModuleFileError(fileName, error);
|
|
99
|
+
}
|
|
100
|
+
return (0, core_1.parseCSSModule)(text, { fileName, includeSyntaxError: true, keyframes: config.keyframes });
|
|
101
|
+
}
|
|
102
|
+
function getDiagnostics() {
|
|
103
|
+
const diagnostics = [...getProjectDiagnostics(), ...getSyntacticDiagnostics()];
|
|
104
|
+
// If there are project or syntactic diagnostics, skip semantic diagnostics
|
|
105
|
+
if (diagnostics.length > 0)
|
|
106
|
+
return diagnostics;
|
|
107
|
+
diagnostics.push(...getSemanticDiagnostics());
|
|
108
|
+
return diagnostics;
|
|
109
|
+
}
|
|
110
|
+
function getProjectDiagnostics() {
|
|
111
|
+
const diagnostics = [];
|
|
112
|
+
diagnostics.push(...config.diagnostics);
|
|
113
|
+
if (cssModuleMap.size === 0) {
|
|
114
|
+
diagnostics.push({
|
|
115
|
+
category: 'error',
|
|
116
|
+
text: `The file specified in tsconfig.json not found.`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return diagnostics;
|
|
120
|
+
}
|
|
121
|
+
function getSyntacticDiagnostics() {
|
|
122
|
+
return Array.from(cssModuleMap.values()).flatMap(({ diagnostics }) => diagnostics);
|
|
123
|
+
}
|
|
124
|
+
function getSemanticDiagnostics() {
|
|
125
|
+
const allDiagnostics = [];
|
|
126
|
+
for (const cssModule of cssModuleMap.values()) {
|
|
127
|
+
let diagnostics = semanticDiagnosticsMap.get(cssModule.fileName);
|
|
128
|
+
if (!diagnostics) {
|
|
129
|
+
diagnostics = (0, core_1.checkCSSModule)(cssModule, config, exportBuilder, matchesPattern, resolver, getCSSModule);
|
|
130
|
+
semanticDiagnosticsMap.set(cssModule.fileName, diagnostics);
|
|
131
|
+
}
|
|
132
|
+
allDiagnostics.push(...diagnostics);
|
|
133
|
+
}
|
|
134
|
+
return allDiagnostics;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @throws {WriteDtsFileError}
|
|
138
|
+
*/
|
|
139
|
+
async function emitDtsFiles() {
|
|
140
|
+
const promises = [];
|
|
141
|
+
for (const cssModule of cssModuleMap.values()) {
|
|
142
|
+
if (emittedSet.has(cssModule.fileName))
|
|
143
|
+
continue;
|
|
144
|
+
const dts = (0, core_1.generateDts)(cssModule, { resolver, matchesPattern }, { ...config, forTsPlugin: false });
|
|
145
|
+
promises.push((0, dts_writer_js_1.writeDtsFile)(dts.text, cssModule.fileName, {
|
|
146
|
+
outDir: config.dtsOutDir,
|
|
147
|
+
basePath: config.basePath,
|
|
148
|
+
arbitraryExtensions: config.arbitraryExtensions,
|
|
149
|
+
}).then(() => {
|
|
150
|
+
emittedSet.add(cssModule.fileName);
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
await Promise.all(promises);
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
config,
|
|
157
|
+
isWildcardMatchedFile: (fileName) => matchesPattern(fileName),
|
|
158
|
+
addFile,
|
|
159
|
+
updateFile,
|
|
160
|
+
removeFile,
|
|
161
|
+
getDiagnostics,
|
|
162
|
+
emitDtsFiles,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function isNodeJSSystemError(error) {
|
|
166
|
+
return typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string';
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";;;;;AA4DA,sCAoKC;AAhOD,qCAAuC;AAEvC,gDAU+B;AAC/B,4DAA4B;AAC5B,mDAA+C;AAC/C,yCAAoD;AAsCpD;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,IAAiB;IAC7C,MAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE5C,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAChD,oBAAE,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvE,MAAM,qBAAqB,GAAG,oBAAE,CAAC,2BAA2B,CAC1D,MAAM,CAAC,QAAQ,EACf,oBAAoB,EACpB,MAAM,CAAC,eAAe,CACv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AC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC1G,CAAC"}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
import type { ParsedArgs } from './cli.js';
|
|
2
1
|
import type { Logger } from './logger/logger.js';
|
|
2
|
+
import { type Project } from './project.js';
|
|
3
|
+
interface RunnerArgs {
|
|
4
|
+
project: string;
|
|
5
|
+
clean: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface Watcher {
|
|
8
|
+
/** Exported for testing purposes */
|
|
9
|
+
project: Project;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* Run css-modules-kit .d.ts generation.
|
|
5
14
|
* @param project The absolute path to the project directory or the path to `tsconfig.json`.
|
|
6
15
|
* @throws {ReadCSSModuleFileError} When failed to read CSS Module file.
|
|
7
16
|
* @throws {WriteDtsFileError}
|
|
17
|
+
* @returns Whether the process succeeded without errors.
|
|
8
18
|
*/
|
|
9
|
-
export declare function runCMK(args:
|
|
19
|
+
export declare function runCMK(args: RunnerArgs, logger: Logger): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Run css-modules-kit .d.ts generation in watch mode.
|
|
22
|
+
*
|
|
23
|
+
* The promise resolves when the initial diagnostics report, emit, and watcher initialization are complete.
|
|
24
|
+
* Errors are reported through the logger.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: For implementation simplicity, config file changes are not watched.
|
|
27
|
+
* @param project The absolute path to the project directory or the path to `tsconfig.json`.
|
|
28
|
+
* @throws {TsConfigFileNotFoundError}
|
|
29
|
+
* @throws {ReadCSSModuleFileError}
|
|
30
|
+
* @throws {WriteDtsFileError}
|
|
31
|
+
*/
|
|
32
|
+
export declare function runCMKInWatchMode(args: RunnerArgs, logger: Logger): Promise<Watcher>;
|
|
33
|
+
export {};
|
|
10
34
|
//# 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":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE3D,UAAU,UAAU;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAY/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG1F"}
|