@cmmn/tools 1.5.0 → 1.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.js +18 -18
- package/bundle/bundle.js +132 -132
- package/bundle/rollup.config.js +255 -256
- package/compile/compile.js +33 -33
- package/compile/tsconfig.json +48 -48
- package/compile/typings.d.ts +19 -19
- package/gen/component.ts.tpl +16 -16
- package/gen/gen.js +27 -27
- package/gen/style.less.tpl +3 -3
- package/gen/template.ts.tpl +8 -8
- package/package.json +77 -78
- package/plugins/absolute-plugin.cjs +98 -98
- package/readme.md +30 -30
- package/test/index.d.ts +2 -2
- package/test/index.js +5 -5
- package/test/jest.config.js +45 -45
package/readme.md
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
## Builder and bundler for your projects
|
|
2
|
-
|
|
3
|
-
### Use cases:
|
|
4
|
-
* `cmmn compile [target] [-b] [--watch]`
|
|
5
|
-
> Runs typescript compiler
|
|
6
|
-
|
|
7
|
-
* `cmmn bundle [target] [-b] [--watch] [--run] [--prod]`
|
|
8
|
-
> Runs rollup bundler
|
|
9
|
-
|
|
10
|
-
* `cmmn gen name directory [-n]`
|
|
11
|
-
> Generates component with template at directory
|
|
12
|
-
|
|
13
|
-
* default `jest.config.js`:
|
|
14
|
-
```typescript
|
|
15
|
-
import config from "@cmmn/tools/test/config";
|
|
16
|
-
export default config;
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
* tests: `some.spec.ts`
|
|
20
|
-
```typescript
|
|
21
|
-
import {suite, test, expect} from "@cmmn/tools/test";
|
|
22
|
-
|
|
23
|
-
@suite
|
|
24
|
-
export class SomeSpec {
|
|
25
|
-
|
|
26
|
-
@test
|
|
27
|
-
equalsTest() {
|
|
28
|
-
expect(1).toBe(2);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
## Builder and bundler for your projects
|
|
2
|
+
|
|
3
|
+
### Use cases:
|
|
4
|
+
* `cmmn compile [target] [-b] [--watch]`
|
|
5
|
+
> Runs typescript compiler
|
|
6
|
+
|
|
7
|
+
* `cmmn bundle [target] [-b] [--watch] [--run] [--prod]`
|
|
8
|
+
> Runs rollup bundler
|
|
9
|
+
|
|
10
|
+
* `cmmn gen name directory [-n]`
|
|
11
|
+
> Generates component with template at directory
|
|
12
|
+
|
|
13
|
+
* default `jest.config.js`:
|
|
14
|
+
```typescript
|
|
15
|
+
import config from "@cmmn/tools/test/config";
|
|
16
|
+
export default config;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
* tests: `some.spec.ts`
|
|
20
|
+
```typescript
|
|
21
|
+
import {suite, test, expect} from "@cmmn/tools/test";
|
|
22
|
+
|
|
23
|
+
@suite
|
|
24
|
+
export class SomeSpec {
|
|
25
|
+
|
|
26
|
+
@test
|
|
27
|
+
equalsTest() {
|
|
28
|
+
expect(1).toBe(2);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
31
|
```
|
package/test/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {suite, test, timeout,} from "@testdeck/jest";
|
|
2
|
-
export {expect,} from "@jest/globals";
|
|
1
|
+
export {suite, test, timeout,} from "@testdeck/jest";
|
|
2
|
+
export {expect,} from "@jest/globals";
|
|
3
3
|
export * as sinon from "sinon";
|
package/test/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {suite, test, timeout,} from "@testdeck/jest";
|
|
2
|
-
import * as globals from "@jest/globals";
|
|
3
|
-
import * as sinon1 from "sinon/pkg/sinon.js";
|
|
4
|
-
export const sinon = sinon1.default;
|
|
5
|
-
const {expect} = globals;
|
|
1
|
+
export {suite, test, timeout,} from "@testdeck/jest";
|
|
2
|
+
import * as globals from "@jest/globals";
|
|
3
|
+
import * as sinon1 from "sinon/pkg/sinon.js";
|
|
4
|
+
export const sinon = sinon1.default;
|
|
5
|
+
const {expect} = globals;
|
|
6
6
|
export {expect};
|
package/test/jest.config.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import {pathsToModuleNameMapper} from "ts-jest";
|
|
3
|
-
|
|
4
|
-
const options = getTSConfig();
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
transform: {
|
|
8
|
-
'^.+\\.tsx?$': ['@swc/jest', {
|
|
9
|
-
jsc: {
|
|
10
|
-
parser: {
|
|
11
|
-
syntax: "typescript",
|
|
12
|
-
// tsx: true, // If you use react
|
|
13
|
-
dynamicImport: true,
|
|
14
|
-
decorators: true,
|
|
15
|
-
},
|
|
16
|
-
target: "es2021",
|
|
17
|
-
transform: {
|
|
18
|
-
decoratorMetadata: true,
|
|
19
|
-
},
|
|
20
|
-
paths: options.paths,
|
|
21
|
-
baseUrl: '.'
|
|
22
|
-
},
|
|
23
|
-
}],
|
|
24
|
-
},
|
|
25
|
-
roots: [process.cwd()],
|
|
26
|
-
moduleNameMapper: pathsToModuleNameMapper(options.paths ?? {}, {
|
|
27
|
-
prefix: '<rootDir>'
|
|
28
|
-
}),
|
|
29
|
-
extensionsToTreatAsEsm: ['.ts', '.tsx', '.jsx?'],
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function getTSConfig() {
|
|
34
|
-
const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'tsconfig.json');
|
|
35
|
-
const readConfigFileResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
36
|
-
if (readConfigFileResult.error) {
|
|
37
|
-
throw new Error(ts.formatDiagnostic(readConfigFileResult.error, formatHost));
|
|
38
|
-
}
|
|
39
|
-
const jsonConfig = readConfigFileResult.config;
|
|
40
|
-
const convertResult = ts.convertCompilerOptionsFromJson(jsonConfig.compilerOptions, './');
|
|
41
|
-
if (convertResult.errors && convertResult.errors.length > 0) {
|
|
42
|
-
throw new Error(ts.formatDiagnostics(convertResult.errors, formatHost));
|
|
43
|
-
}
|
|
44
|
-
const compilerOptions = convertResult.options;
|
|
45
|
-
return compilerOptions;
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import {pathsToModuleNameMapper} from "ts-jest";
|
|
3
|
+
|
|
4
|
+
const options = getTSConfig();
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.tsx?$': ['@swc/jest', {
|
|
9
|
+
jsc: {
|
|
10
|
+
parser: {
|
|
11
|
+
syntax: "typescript",
|
|
12
|
+
// tsx: true, // If you use react
|
|
13
|
+
dynamicImport: true,
|
|
14
|
+
decorators: true,
|
|
15
|
+
},
|
|
16
|
+
target: "es2021",
|
|
17
|
+
transform: {
|
|
18
|
+
decoratorMetadata: true,
|
|
19
|
+
},
|
|
20
|
+
paths: options.paths,
|
|
21
|
+
baseUrl: '.'
|
|
22
|
+
},
|
|
23
|
+
}],
|
|
24
|
+
},
|
|
25
|
+
roots: [process.cwd()],
|
|
26
|
+
moduleNameMapper: pathsToModuleNameMapper(options.paths ?? {}, {
|
|
27
|
+
prefix: '<rootDir>'
|
|
28
|
+
}),
|
|
29
|
+
extensionsToTreatAsEsm: ['.ts', '.tsx', '.jsx?'],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function getTSConfig() {
|
|
34
|
+
const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'tsconfig.json');
|
|
35
|
+
const readConfigFileResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
36
|
+
if (readConfigFileResult.error) {
|
|
37
|
+
throw new Error(ts.formatDiagnostic(readConfigFileResult.error, formatHost));
|
|
38
|
+
}
|
|
39
|
+
const jsonConfig = readConfigFileResult.config;
|
|
40
|
+
const convertResult = ts.convertCompilerOptionsFromJson(jsonConfig.compilerOptions, './');
|
|
41
|
+
if (convertResult.errors && convertResult.errors.length > 0) {
|
|
42
|
+
throw new Error(ts.formatDiagnostics(convertResult.errors, formatHost));
|
|
43
|
+
}
|
|
44
|
+
const compilerOptions = convertResult.options;
|
|
45
|
+
return compilerOptions;
|
|
46
46
|
}
|