@css-modules-kit/codegen 0.6.0 → 0.8.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 +7 -20
- package/bin/cmk.js +44 -0
- package/dist/3rd-party/typescript.js +4 -11
- package/dist/3rd-party/typescript.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -24
- package/dist/cli.js.map +1 -1
- package/dist/dts-writer.js +12 -16
- package/dist/dts-writer.js.map +1 -1
- package/dist/error.d.ts +4 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +9 -10
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -16
- 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 +14 -9
- 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 +27 -19
- 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 +174 -0
- package/dist/project.js.map +1 -0
- package/dist/runner.d.ts +29 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +139 -74
- package/dist/runner.js.map +1 -1
- package/package.json +5 -4
- package/src/cli.ts +15 -6
- package/src/error.ts +11 -1
- package/src/index.ts +2 -2
- package/src/logger/formatter.ts +12 -0
- package/src/logger/logger.ts +23 -9
- package/src/project.ts +242 -0
- package/src/runner.ts +156 -106
- package/bin/cmk.mjs +0 -29
package/README.md
CHANGED
|
@@ -8,21 +8,6 @@ A tool for generating `*.d.ts` files for `*.module.css`.
|
|
|
8
8
|
npm i -D @css-modules-kit/codegen
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Requirements
|
|
12
|
-
|
|
13
|
-
Set `cmkOptions.dtsOutDir` and `"."` to `rootDirs`. This is necessary for the `tsc` command to load the generated `*.d.ts` files.
|
|
14
|
-
|
|
15
|
-
```json
|
|
16
|
-
{
|
|
17
|
-
"compilerOptions": {
|
|
18
|
-
"rootDirs": [".", "generated"] // Required
|
|
19
|
-
},
|
|
20
|
-
"cmkOptions": {
|
|
21
|
-
"dtsOutDir": "generated" // Default is `"generated"`, so it can be omitted
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
11
|
## Usage
|
|
27
12
|
|
|
28
13
|
From the command line, run the `cmk` command.
|
|
@@ -36,11 +21,13 @@ $ npx cmk --help
|
|
|
36
21
|
Usage: cmk [options]
|
|
37
22
|
|
|
38
23
|
Options:
|
|
39
|
-
--help, -h
|
|
40
|
-
--version, -v
|
|
41
|
-
--project, -p
|
|
42
|
-
--pretty
|
|
43
|
-
--clean
|
|
24
|
+
--help, -h Show help information
|
|
25
|
+
--version, -v Show version number
|
|
26
|
+
--project, -p The path to its configuration file, or to a folder with a 'tsconfig.json'.
|
|
27
|
+
--pretty Enable color and formatting in output to make errors easier to read.
|
|
28
|
+
--clean Remove the output directory before generating files. [default: false]
|
|
29
|
+
--watch, -w Watch for changes and regenerate files. [default: false]
|
|
30
|
+
--preserveWatchOutput Disable wiping the console in watch mode. [default: false]
|
|
44
31
|
```
|
|
45
32
|
|
|
46
33
|
## Configuration
|
package/bin/cmk.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable n/no-process-exit */
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
createLogger,
|
|
6
|
+
parseCLIArgs,
|
|
7
|
+
printHelpText,
|
|
8
|
+
printVersion,
|
|
9
|
+
runCMK,
|
|
10
|
+
runCMKInWatchMode,
|
|
11
|
+
shouldBePretty,
|
|
12
|
+
} from '../dist/index.js';
|
|
13
|
+
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
let logger = createLogger(cwd, shouldBePretty(undefined));
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const args = parseCLIArgs(process.argv.slice(2), cwd);
|
|
19
|
+
logger = createLogger(cwd, shouldBePretty(args.pretty));
|
|
20
|
+
|
|
21
|
+
if (args.help) {
|
|
22
|
+
printHelpText();
|
|
23
|
+
process.exit(0);
|
|
24
|
+
} else if (args.version) {
|
|
25
|
+
printVersion();
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
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
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
logger.logError(e);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @fileoverview
|
|
4
3
|
* This is forked from microsoft/TypeScript.
|
|
@@ -60,17 +59,11 @@
|
|
|
60
59
|
*
|
|
61
60
|
* END OF TERMS AND CONDITIONS
|
|
62
61
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.defaultIsPretty = defaultIsPretty;
|
|
68
|
-
exports.shouldBePretty = shouldBePretty;
|
|
69
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
70
|
-
function defaultIsPretty() {
|
|
71
|
-
return !!typescript_1.default.sys.writeOutputIsTTY && typescript_1.default.sys.writeOutputIsTTY() && !process.env['NO_COLOR'];
|
|
62
|
+
import ts from 'typescript';
|
|
63
|
+
export function defaultIsPretty() {
|
|
64
|
+
return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY() && !process.env['NO_COLOR'];
|
|
72
65
|
}
|
|
73
|
-
function shouldBePretty(pretty) {
|
|
66
|
+
export function shouldBePretty(pretty) {
|
|
74
67
|
if (pretty === undefined) {
|
|
75
68
|
return defaultIsPretty();
|
|
76
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/3rd-party/typescript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/3rd-party/typescript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAA2B;IACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,eAAe,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
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":"AAmBA,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;IACf,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CA2BpE"}
|
package/dist/cli.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.printHelpText = printHelpText;
|
|
7
|
-
exports.printVersion = printVersion;
|
|
8
|
-
exports.parseCLIArgs = parseCLIArgs;
|
|
9
|
-
const node_util_1 = require("node:util");
|
|
10
|
-
const core_1 = require("@css-modules-kit/core");
|
|
11
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
12
|
-
const error_js_1 = require("./error.js");
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { resolve } from '@css-modules-kit/core';
|
|
3
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
4
|
+
import { ParseCLIArgsError } from './error.js';
|
|
5
|
+
// NOTE: Keep this help text in sync with the one in packages/codegen/README.md.
|
|
13
6
|
const helpText = `
|
|
14
7
|
Usage: cmk [options]
|
|
15
8
|
|
|
16
9
|
Options:
|
|
17
|
-
--help, -h
|
|
18
|
-
--version, -v
|
|
19
|
-
--project, -p
|
|
20
|
-
--pretty
|
|
21
|
-
--clean
|
|
10
|
+
--help, -h Show help information
|
|
11
|
+
--version, -v Show version number
|
|
12
|
+
--project, -p The path to its configuration file, or to a folder with a 'tsconfig.json'.
|
|
13
|
+
--pretty Enable color and formatting in output to make errors easier to read.
|
|
14
|
+
--clean Remove the output directory before generating files. [default: false]
|
|
15
|
+
--watch, -w Watch for changes and regenerate files. [default: false]
|
|
16
|
+
--preserveWatchOutput Disable wiping the console in watch mode. [default: false]
|
|
22
17
|
`;
|
|
23
|
-
function printHelpText() {
|
|
18
|
+
export function printHelpText() {
|
|
24
19
|
// eslint-disable-next-line no-console
|
|
25
20
|
console.log(helpText);
|
|
26
21
|
}
|
|
27
|
-
function printVersion() {
|
|
22
|
+
export function printVersion() {
|
|
28
23
|
// eslint-disable-next-line no-console
|
|
29
|
-
console.log(
|
|
24
|
+
console.log(packageJson.version);
|
|
30
25
|
}
|
|
31
26
|
/**
|
|
32
27
|
* Parse command-line arguments.
|
|
33
28
|
* @throws {ParseCLIArgsError} If failed to parse CLI arguments.
|
|
34
29
|
*/
|
|
35
|
-
function parseCLIArgs(args, cwd) {
|
|
30
|
+
export function parseCLIArgs(args, cwd) {
|
|
36
31
|
try {
|
|
37
|
-
const { values } =
|
|
32
|
+
const { values } = parseArgs({
|
|
38
33
|
args,
|
|
39
34
|
options: {
|
|
40
35
|
help: { type: 'boolean', short: 'h', default: false },
|
|
@@ -42,19 +37,23 @@ function parseCLIArgs(args, cwd) {
|
|
|
42
37
|
project: { type: 'string', short: 'p', default: '.' },
|
|
43
38
|
pretty: { type: 'boolean' },
|
|
44
39
|
clean: { type: 'boolean', default: false },
|
|
40
|
+
watch: { type: 'boolean', short: 'w', default: false },
|
|
41
|
+
preserveWatchOutput: { type: 'boolean', default: false },
|
|
45
42
|
},
|
|
46
43
|
allowNegative: true,
|
|
47
44
|
});
|
|
48
45
|
return {
|
|
49
46
|
help: values.help,
|
|
50
47
|
version: values.version,
|
|
51
|
-
project:
|
|
48
|
+
project: resolve(cwd, values.project),
|
|
52
49
|
pretty: values.pretty,
|
|
53
50
|
clean: values.clean,
|
|
51
|
+
watch: values.watch,
|
|
52
|
+
preserveWatchOutput: values.preserveWatchOutput,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
catch (cause) {
|
|
57
|
-
throw new
|
|
56
|
+
throw new ParseCLIArgsError(cause);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
//# sourceMappingURL=cli.js.map
|
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":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,gFAAgF;AAChF,MAAM,QAAQ,GAAG;;;;;;;;;;;CAWhB,CAAC;AAEF,MAAM,UAAU,aAAa;IAC3B,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAYD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,GAAW;IACtD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;YAC3B,IAAI;YACJ,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;gBACrD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;gBACxD,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE;gBACrD,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;gBAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;gBACtD,mBAAmB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;aACzD;YACD,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;SAChD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
package/dist/dts-writer.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.writeDtsFile = writeDtsFile;
|
|
5
|
-
const promises_1 = require("node:fs/promises");
|
|
6
|
-
const core_1 = require("@css-modules-kit/core");
|
|
7
|
-
const error_js_1 = require("./error.js");
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, parse, relative, resolve } from '@css-modules-kit/core';
|
|
3
|
+
import { WriteDtsFileError } from './error.js';
|
|
8
4
|
/**
|
|
9
5
|
* Get .d.ts file path.
|
|
10
6
|
* @param cssModuleFileName The path to the CSS Module file (i.e. `/src/foo.module.css`). It is absolute.
|
|
11
7
|
* @param options Output directory options
|
|
12
8
|
* @returns The path to the .d.ts file. It is absolute.
|
|
13
9
|
*/
|
|
14
|
-
function getDtsFilePath(cssModuleFileName, options) {
|
|
15
|
-
const relativePath =
|
|
16
|
-
const outputFilePath =
|
|
10
|
+
export function getDtsFilePath(cssModuleFileName, options) {
|
|
11
|
+
const relativePath = relative(options.basePath, cssModuleFileName);
|
|
12
|
+
const outputFilePath = resolve(options.outDir, relativePath);
|
|
17
13
|
if (options.arbitraryExtensions) {
|
|
18
|
-
const { dir, name, ext } =
|
|
19
|
-
return
|
|
14
|
+
const { dir, name, ext } = parse(outputFilePath);
|
|
15
|
+
return join(dir, `${name}.d${ext}.ts`);
|
|
20
16
|
}
|
|
21
17
|
else {
|
|
22
18
|
return `${outputFilePath}.d.ts`;
|
|
@@ -29,14 +25,14 @@ function getDtsFilePath(cssModuleFileName, options) {
|
|
|
29
25
|
* @param options Options for writing the d.ts file.
|
|
30
26
|
* @throws {WriteDtsFileError} When the file cannot be written.
|
|
31
27
|
*/
|
|
32
|
-
async function writeDtsFile(text, cssModuleFileName, options) {
|
|
28
|
+
export async function writeDtsFile(text, cssModuleFileName, options) {
|
|
33
29
|
const dtsFileName = getDtsFilePath(cssModuleFileName, options);
|
|
34
30
|
try {
|
|
35
|
-
await
|
|
36
|
-
await
|
|
31
|
+
await mkdir(dirname(dtsFileName), { recursive: true });
|
|
32
|
+
await writeFile(dtsFileName, text);
|
|
37
33
|
}
|
|
38
34
|
catch (error) {
|
|
39
|
-
throw new
|
|
35
|
+
throw new WriteDtsFileError(dtsFileName, error);
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
//# sourceMappingURL=dts-writer.js.map
|
package/dist/dts-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dts-writer.js","sourceRoot":"","sources":["../src/dts-writer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dts-writer.js","sourceRoot":"","sources":["../src/dts-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,iBAAyB,EAAE,OAA2B;IACnF,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAE7D,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,GAAG,KAAK,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,cAAc,OAAO,CAAC;IAClC,CAAC;AACH,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,iBAAyB,EACzB,OAA2B;IAE3B,MAAM,WAAW,GAAG,cAAc,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAC/D,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/error.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CMKConfig } from '@css-modules-kit/core';
|
|
1
2
|
import { SystemError } from '@css-modules-kit/core';
|
|
2
3
|
export declare class ParseCLIArgsError extends SystemError {
|
|
3
4
|
constructor(cause: unknown);
|
|
@@ -8,4 +9,7 @@ export declare class WriteDtsFileError extends SystemError {
|
|
|
8
9
|
export declare class ReadCSSModuleFileError extends SystemError {
|
|
9
10
|
constructor(fileName: string, cause: unknown);
|
|
10
11
|
}
|
|
12
|
+
export declare class CMKDisabledError extends SystemError {
|
|
13
|
+
constructor(config: CMKConfig);
|
|
14
|
+
}
|
|
11
15
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAY,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE9D,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,KAAK,EAAE,OAAO;CAG3B;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAG7C;AAED,qBAAa,sBAAuB,SAAQ,WAAW;gBACzC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAG7C;AAED,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,MAAM,EAAE,SAAS;CAM9B"}
|
package/dist/error.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ReadCSSModuleFileError = exports.WriteDtsFileError = exports.ParseCLIArgsError = void 0;
|
|
4
|
-
const core_1 = require("@css-modules-kit/core");
|
|
5
|
-
class ParseCLIArgsError extends core_1.SystemError {
|
|
1
|
+
import { relative, SystemError } from '@css-modules-kit/core';
|
|
2
|
+
export class ParseCLIArgsError extends SystemError {
|
|
6
3
|
constructor(cause) {
|
|
7
4
|
super('PARSE_CLI_ARGS_ERROR', `Failed to parse CLI arguments.`, cause);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
class WriteDtsFileError extends core_1.SystemError {
|
|
7
|
+
export class WriteDtsFileError extends SystemError {
|
|
12
8
|
constructor(fileName, cause) {
|
|
13
9
|
super('WRITE_DTS_FILE_ERROR', `Failed to write .d.ts file ${fileName}.`, cause);
|
|
14
10
|
}
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
class ReadCSSModuleFileError extends core_1.SystemError {
|
|
12
|
+
export class ReadCSSModuleFileError extends SystemError {
|
|
18
13
|
constructor(fileName, cause) {
|
|
19
14
|
super('READ_CSS_MODULE_FILE_ERROR', `Failed to read CSS Module file ${fileName}.`, cause);
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
|
-
|
|
17
|
+
export class CMKDisabledError extends SystemError {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super('CMK_DISABLED_ERROR', `css-modules-kit is disabled by configuration. Set \`"cmkOptions": { "enabled": true }\` in ${relative(config.basePath, config.configFileName)} to enable it.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
23
22
|
//# sourceMappingURL=error.js.map
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,KAAc;QACxB,KAAK,CAAC,sBAAsB,EAAE,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,QAAgB,EAAE,KAAc;QAC1C,KAAK,CAAC,sBAAsB,EAAE,8BAA8B,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,QAAgB,EAAE,KAAc;QAC1C,KAAK,CAAC,4BAA4B,EAAE,kCAAkC,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5F,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,MAAiB;QAC3B,KAAK,CACH,oBAAoB,EACpB,8FAA8F,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAC/J,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { runCMK } from './runner.js';
|
|
1
|
+
export { runCMK, runCMKInWatchMode } from './runner.js';
|
|
2
2
|
export { type Logger, createLogger } from './logger/logger.js';
|
|
3
|
-
export { WriteDtsFileError, ReadCSSModuleFileError } from './error.js';
|
|
3
|
+
export { WriteDtsFileError, ReadCSSModuleFileError, CMKDisabledError } from './error.js';
|
|
4
4
|
export { parseCLIArgs, printHelpText, printVersion } from './cli.js';
|
|
5
5
|
export { shouldBePretty } from './3rd-party/typescript.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
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,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzF,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,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var logger_js_1 = require("./logger/logger.js");
|
|
7
|
-
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_js_1.createLogger; } });
|
|
8
|
-
var error_js_1 = require("./error.js");
|
|
9
|
-
Object.defineProperty(exports, "WriteDtsFileError", { enumerable: true, get: function () { return error_js_1.WriteDtsFileError; } });
|
|
10
|
-
Object.defineProperty(exports, "ReadCSSModuleFileError", { enumerable: true, get: function () { return error_js_1.ReadCSSModuleFileError; } });
|
|
11
|
-
var cli_js_1 = require("./cli.js");
|
|
12
|
-
Object.defineProperty(exports, "parseCLIArgs", { enumerable: true, get: function () { return cli_js_1.parseCLIArgs; } });
|
|
13
|
-
Object.defineProperty(exports, "printHelpText", { enumerable: true, get: function () { return cli_js_1.printHelpText; } });
|
|
14
|
-
Object.defineProperty(exports, "printVersion", { enumerable: true, get: function () { return cli_js_1.printVersion; } });
|
|
15
|
-
var typescript_js_1 = require("./3rd-party/typescript.js");
|
|
16
|
-
Object.defineProperty(exports, "shouldBePretty", { enumerable: true, get: function () { return typescript_js_1.shouldBePretty; } });
|
|
1
|
+
export { runCMK, runCMKInWatchMode } from './runner.js';
|
|
2
|
+
export { createLogger } from './logger/logger.js';
|
|
3
|
+
export { WriteDtsFileError, ReadCSSModuleFileError, CMKDisabledError } from './error.js';
|
|
4
|
+
export { parseCLIArgs, printHelpText, printVersion } from './cli.js';
|
|
5
|
+
export { shouldBePretty } from './3rd-party/typescript.js';
|
|
17
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAe,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -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
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.formatDiagnostics = formatDiagnostics;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
function formatDiagnostics(diagnostics, host, pretty) {
|
|
9
|
-
const format = pretty ? typescript_1.default.formatDiagnosticsWithColorAndContext : typescript_1.default.formatDiagnostics;
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
const GRAY = '\u001b[90m';
|
|
3
|
+
const RESET = '\u001b[0m';
|
|
4
|
+
export function formatDiagnostics(diagnostics, host, pretty) {
|
|
5
|
+
const format = pretty ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics;
|
|
10
6
|
let result = '';
|
|
11
7
|
for (const diagnostic of diagnostics) {
|
|
12
8
|
result += format([diagnostic], host).replace(` TS${diagnostic.code}`, '') + host.getNewLine();
|
|
13
9
|
}
|
|
14
10
|
return result;
|
|
15
11
|
}
|
|
12
|
+
export function formatTime(date, pretty) {
|
|
13
|
+
const text = date.toLocaleTimeString('en-US', { timeZone: 'UTC' });
|
|
14
|
+
if (pretty) {
|
|
15
|
+
return `[${GRAY}${text}${RESET}]`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return `[${text}]`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
16
21
|
//# 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":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,MAAM,KAAK,GAAG,WAAW,CAAC;AAE1B,MAAM,UAAU,iBAAiB,CAC/B,WAA4B,EAC5B,IAA8B,EAC9B,MAAe;IAEf,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,oCAAoC,CAAC,CAAC,CAAC,EAAE,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,MAAM,UAAU,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
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.createLogger = createLogger;
|
|
7
|
-
const core_1 = require("@css-modules-kit/core");
|
|
8
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
9
|
-
const formatter_js_1 = require("./formatter.js");
|
|
10
|
-
function createLogger(cwd, pretty) {
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
import { convertDiagnostic, convertSystemError, SystemError } from '@css-modules-kit/core';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { formatDiagnostics, formatTime } from './formatter.js';
|
|
5
|
+
export function createLogger(cwd, pretty) {
|
|
11
6
|
const host = {
|
|
12
7
|
getCurrentDirectory: () => cwd,
|
|
13
|
-
getCanonicalFileName: (fileName) => (
|
|
14
|
-
getNewLine: () =>
|
|
8
|
+
getCanonicalFileName: (fileName) => (ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase()),
|
|
9
|
+
getNewLine: () => ts.sys.newLine,
|
|
15
10
|
};
|
|
16
11
|
function getSourceFile(file) {
|
|
17
|
-
return
|
|
12
|
+
return ts.createSourceFile(file.fileName, file.text, ts.ScriptTarget.JSON, undefined, ts.ScriptKind.Unknown);
|
|
18
13
|
}
|
|
19
14
|
return {
|
|
20
15
|
logDiagnostics(diagnostics) {
|
|
21
|
-
const result =
|
|
16
|
+
const result = formatDiagnostics(diagnostics.map((d) => convertDiagnostic(d, getSourceFile)), host, pretty);
|
|
22
17
|
process.stderr.write(result);
|
|
23
18
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
logError(error) {
|
|
20
|
+
// NOTE: SystemErrors are errors expected by the css-modules-kit specification and may occur within normal usage.
|
|
21
|
+
// These errors are formatted clearly and concisely. No stack trace is output.
|
|
22
|
+
//
|
|
23
|
+
// All other errors are unexpected errors. To assist in debugging when these errors occur, a stack trace is output.
|
|
24
|
+
if (error instanceof SystemError) {
|
|
25
|
+
const result = formatDiagnostics([convertSystemError(error)], host, pretty);
|
|
26
|
+
process.stderr.write(result);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
process.stderr.write(`${inspect(error, { colors: pretty })}\n`);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
logMessage(message, options) {
|
|
33
|
+
const header = options?.time ? `${formatTime(new Date(), pretty)} ` : '';
|
|
34
|
+
process.stdout.write(`${header}${message}\n`);
|
|
27
35
|
},
|
|
28
|
-
|
|
29
|
-
process.stdout.write(
|
|
36
|
+
clearScreen() {
|
|
37
|
+
process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
|
|
30
38
|
},
|
|
31
39
|
};
|
|
32
40
|
}
|
|
@@ -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,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAS/D,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,MAAe;IACvD,MAAM,IAAI,GAA6B;QACrC,mBAAmB,EAAE,GAAG,EAAE,CAAC,GAAG;QAC9B,oBAAoB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1G,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO;KACjC,CAAC;IAEF,SAAS,aAAa,CAAC,IAA0B;QAC/C,OAAO,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/G,CAAC;IAED,OAAO;QACL,cAAc,CAAC,WAAyB;YACtC,MAAM,MAAM,GAAG,iBAAiB,CAC9B,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,EAC3D,IAAI,EACJ,MAAM,CACP,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QACD,QAAQ,CAAC,KAAc;YACrB,iHAAiH;YACjH,8EAA8E;YAC9E,EAAE;YACF,mHAAmH;YACnH,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;gBACjC,MAAM,MAAM,GAAG,iBAAiB,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;gBAC5E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,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,UAAU,CAAC,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,EASf,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,CAgLxD"}
|