@cmmn/tools 1.9.11 → 1.9.13

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.
@@ -135,10 +135,11 @@ export class ConfigCreator {
135
135
  es: 'esm'
136
136
  })[format] ?? format,
137
137
  outExtension: {
138
- '.js': this.getOutExtension(format, platform)
138
+ '.js': this.getOutExtension(format, platform),
139
+ '.css': this.options.minify ? '.min.css' : '.css'
139
140
  },
140
141
  footer:{
141
- js: `//# sourceMappingURL=./${this.options.name}.js.map`
142
+ js: `//# sourceMappingURL=./${this.options.name+this.getOutExtension(format, platform)}.map`
142
143
  },
143
144
  platform: platform,
144
145
  tsconfig: 'tsconfig.json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.9.11",
3
+ "version": "1.9.13",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -41,13 +41,11 @@
41
41
  "helpers/*"
42
42
  ],
43
43
  "dependencies": {
44
- "@jest/globals": "27.x.x",
45
- "@swc/jest": "0.2.17",
46
44
  "@testdeck/jest": "0.2.0",
47
- "@types/jest": "27.x.x",
45
+ "@types/node": "20.x.x",
48
46
  "@types/sinon": "10.x.x",
49
47
  "@zerollup/ts-helpers": "1.7.18",
50
- "dependency-order": "1.1.6",
48
+ "earl": "^1.1.0",
51
49
  "esbuild": "0.19.5",
52
50
  "esbuild-plugin-less": "1.3.1",
53
51
  "esbuild-register": "3.5.0",
@@ -55,11 +53,10 @@
55
53
  "fast-glob": "^3.2.11",
56
54
  "file-uri-to-path": "2.x.x",
57
55
  "import-meta-resolve": "2",
58
- "jest": "29.x.x",
56
+ "jasmine-expect": "5.0.0",
59
57
  "less": "^4",
60
58
  "live-server": "1.2.2",
61
- "sinon": "10.x.x",
62
- "ts-jest": "29.x.x"
59
+ "sinon": "17.0.1"
63
60
  },
64
61
  "author": "",
65
62
  "license": "ISC",
package/readme.md CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  @test
27
27
  equalsTest() {
28
- expect(1).toBe(2);
28
+ expect(1).toEqual(2);
29
29
  }
30
30
  }
31
31
  ```
package/test/index.d.ts CHANGED
@@ -1,3 +1,18 @@
1
1
  export {suite, test, timeout,} from "@testdeck/jest";
2
- export {expect,} from "@jest/globals";
3
- export * as sinon from "sinon";
2
+ export {expect} from "earl";
3
+ import * as sinonModule from "sinon";
4
+
5
+ export type AssertionExt = Assertion & {
6
+ toEqual: Assertion["eql"]
7
+ }
8
+ export const sinon = sinonModule;
9
+
10
+ declare module 'earl' {
11
+ interface Validators<T> {
12
+ // Note that `this: Validators<number>` ensures that
13
+ // the validator is only callable for numbers.
14
+ toBeInstanceOf<V>(this: Validators<T>, type: V): T extends V ? true : false;
15
+ toBe: Validators<T>["toEqual"];
16
+ toHaveProperty<TProp, TValue>(this: Validators<T>, prop: TProp, value: TValue): T extends Record<TProp, TValue> ? true: false;
17
+ }
18
+ }
package/test/index.js CHANGED
@@ -1,6 +1,11 @@
1
+ import * as test from "node:test";
2
+ Object.assign(globalThis, test);
1
3
  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
- export {expect};
4
+ import { expect as expectBase, registerValidator, isEqual} from "earl";
5
+ import assert from "node:assert";
6
+ // import * as globals from "@jest/globals";
7
+ export * as sinon from "sinon";
8
+ registerValidator("toBe", isEqual)
9
+ registerValidator("toBeInstanceOf", type => value => value instanceof type)
10
+ registerValidator("toHaveProperty", (prop, value) => obj => isEqual(obj[prop], value))
11
+ export const expect = expectBase;
@@ -1,5 +1,5 @@
1
- import {pathsToModuleNameMapper} from "ts-jest";
2
1
  import {getTSCompilerOptions} from "../helpers/getTSConfig.js";
2
+ import {pathsToModuleNameMapper} from "./pathsToModuleNameMapper.js";
3
3
 
4
4
  const options = getTSCompilerOptions(process.cwd());
5
5
 
@@ -0,0 +1,46 @@
1
+ // we don't need to escape all chars, so commented out is the real one
2
+ // const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
3
+ const escapeRegex = (str) => str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
4
+
5
+ export const pathsToModuleNameMapper = (mapping, { prefix = '', useESM = false }= {}) => {
6
+ const jestMap = {}
7
+ for (const fromPath of Object.keys(mapping)) {
8
+ const toPaths = mapping[fromPath]
9
+ // check that we have only one target path
10
+ if (toPaths.length === 0) {
11
+ continue
12
+ }
13
+
14
+ // split with '*'
15
+ const segments = fromPath.split(/\*/g)
16
+ if (segments.length === 1) {
17
+ const paths = toPaths.map((target) => {
18
+ const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix
19
+
20
+ return `${enrichedPrefix}${target}`
21
+ })
22
+ const cjsPattern = `^${escapeRegex(fromPath)}$`
23
+ jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths
24
+ } else if (segments.length === 2) {
25
+ const paths = toPaths.map((target) => {
26
+ const enrichedTarget =
27
+ target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target
28
+ const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix
29
+
30
+ return `${enrichedPrefix}${enrichedTarget.replace(/\*/g, '$1')}`
31
+ })
32
+ if (useESM) {
33
+ const esmPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}\\.js$`
34
+ jestMap[esmPattern] = paths.length === 1 ? paths[0] : paths
35
+ }
36
+ const cjsPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}$`
37
+ jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths
38
+ }
39
+ }
40
+
41
+ if (useESM) {
42
+ jestMap['^(\\.{1,2}/.*)\\.js$'] = '$1'
43
+ }
44
+
45
+ return jestMap
46
+ }