@regardio/dev 1.11.0 → 1.11.2
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/dist/bin/lint-package.js +20 -8
- package/dist/vitest/node.d.ts +15 -2
- package/dist/vitest/node.d.ts.map +1 -1
- package/dist/vitest/react.d.ts +16 -2
- package/dist/vitest/react.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/bin/lint-package.ts +23 -8
- package/src/vitest/node.ts +1 -3
- package/src/vitest/react.ts +1 -2
package/dist/bin/lint-package.js
CHANGED
|
@@ -18,21 +18,24 @@ else {
|
|
|
18
18
|
bin = 'npx sort-package-json';
|
|
19
19
|
}
|
|
20
20
|
const args = process.argv.slice(2);
|
|
21
|
-
const
|
|
21
|
+
const fixMode = args.includes('--fix');
|
|
22
|
+
const files = args.filter((arg) => arg !== '--fix');
|
|
23
|
+
const targets = files.length > 0 ? files : ['package.json'];
|
|
22
24
|
try {
|
|
23
|
-
|
|
25
|
+
const checkFlag = fixMode ? '' : '--check';
|
|
26
|
+
execSync(`${bin} ${checkFlag} ${targets.join(' ')}`.trim(), { stdio: 'inherit' });
|
|
24
27
|
}
|
|
25
28
|
catch {
|
|
26
29
|
process.exit(1);
|
|
27
30
|
}
|
|
28
|
-
function fixExportsOrder(filePath) {
|
|
31
|
+
function fixExportsOrder(filePath, fix) {
|
|
29
32
|
const fullPath = resolve(process.cwd(), filePath);
|
|
30
33
|
if (!existsSync(fullPath))
|
|
31
|
-
return;
|
|
34
|
+
return false;
|
|
32
35
|
const content = readFileSync(fullPath, 'utf-8');
|
|
33
36
|
const pkg = JSON.parse(content);
|
|
34
37
|
if (!pkg.exports || typeof pkg.exports !== 'object')
|
|
35
|
-
return;
|
|
38
|
+
return false;
|
|
36
39
|
let modified = false;
|
|
37
40
|
function reorderConditions(obj) {
|
|
38
41
|
if (typeof obj !== 'object' || obj === null)
|
|
@@ -65,10 +68,19 @@ function fixExportsOrder(filePath) {
|
|
|
65
68
|
return result;
|
|
66
69
|
}
|
|
67
70
|
pkg.exports = reorderConditions(pkg.exports);
|
|
68
|
-
if (modified) {
|
|
71
|
+
if (modified && fix) {
|
|
69
72
|
writeFileSync(fullPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
70
73
|
}
|
|
74
|
+
return modified;
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
let hasExportsIssues = false;
|
|
77
|
+
for (const file of targets) {
|
|
78
|
+
const needsFix = fixExportsOrder(file, fixMode);
|
|
79
|
+
if (needsFix && !fixMode) {
|
|
80
|
+
console.error(`${file}: exports condition order is incorrect (types must come before default)`);
|
|
81
|
+
hasExportsIssues = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (hasExportsIssues) {
|
|
85
|
+
process.exit(1);
|
|
74
86
|
}
|
package/dist/vitest/node.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import type { TestUserConfig } from 'vitest/node';
|
|
2
1
|
export declare const coverageThresholds: {
|
|
3
2
|
branches: number;
|
|
4
3
|
functions: number;
|
|
5
4
|
lines: number;
|
|
6
5
|
statements: number;
|
|
7
6
|
};
|
|
8
|
-
export declare const vitestNodeConfig:
|
|
7
|
+
export declare const vitestNodeConfig: {
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: string;
|
|
10
|
+
thresholds: {
|
|
11
|
+
branches: number;
|
|
12
|
+
functions: number;
|
|
13
|
+
lines: number;
|
|
14
|
+
statements: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
environment: string;
|
|
18
|
+
exclude: string[];
|
|
19
|
+
globals: boolean;
|
|
20
|
+
include: string[];
|
|
21
|
+
};
|
|
9
22
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/vitest/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/vitest/node.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;CAS5B,CAAC"}
|
package/dist/vitest/react.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const vitestReactConfig: {
|
|
2
|
+
coverage: {
|
|
3
|
+
provider: string;
|
|
4
|
+
thresholds: {
|
|
5
|
+
branches: number;
|
|
6
|
+
functions: number;
|
|
7
|
+
lines: number;
|
|
8
|
+
statements: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
environment: string;
|
|
12
|
+
exclude: string[];
|
|
13
|
+
globals: boolean;
|
|
14
|
+
include: string[];
|
|
15
|
+
setupFiles: string[];
|
|
16
|
+
};
|
|
3
17
|
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/vitest/react.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/vitest/react.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;CAU7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "@regardio/dev",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Regardio developer tooling for testing, linting, and build workflows",
|
|
7
7
|
"keywords": [
|
|
@@ -96,13 +96,13 @@
|
|
|
96
96
|
"@biomejs/biome": "2.3.11",
|
|
97
97
|
"@changesets/changelog-github": "0.5.2",
|
|
98
98
|
"@changesets/cli": "2.29.8",
|
|
99
|
-
"@commitlint/cli": "20.3.
|
|
100
|
-
"@commitlint/config-conventional": "20.3.
|
|
99
|
+
"@commitlint/cli": "20.3.1",
|
|
100
|
+
"@commitlint/config-conventional": "20.3.1",
|
|
101
101
|
"@playwright/test": "1.57.0",
|
|
102
102
|
"@testing-library/jest-dom": "6.9.1",
|
|
103
103
|
"@testing-library/react": "16.3.1",
|
|
104
104
|
"@total-typescript/ts-reset": "0.6.1",
|
|
105
|
-
"@types/node": "25.0.
|
|
105
|
+
"@types/node": "25.0.6",
|
|
106
106
|
"@vitest/coverage-v8": "4.0.16",
|
|
107
107
|
"@vitest/ui": "4.0.16",
|
|
108
108
|
"husky": "9.1.7",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"npm-run-all": "4.1.5",
|
|
112
112
|
"postcss": "8.5.6",
|
|
113
113
|
"rimraf": "6.1.2",
|
|
114
|
-
"sort-package-json": "3.
|
|
114
|
+
"sort-package-json": "3.6.0",
|
|
115
115
|
"tsx": "4.21.0",
|
|
116
116
|
"typescript": "5.9.3",
|
|
117
117
|
"vite": "7.3.1",
|
package/src/bin/lint-package.ts
CHANGED
|
@@ -26,11 +26,14 @@ if (existsSync(sortPkgBin)) {
|
|
|
26
26
|
|
|
27
27
|
// Get args passed to this script
|
|
28
28
|
const args = process.argv.slice(2);
|
|
29
|
-
const
|
|
29
|
+
const fixMode = args.includes('--fix');
|
|
30
|
+
const files = args.filter((arg) => arg !== '--fix');
|
|
31
|
+
const targets = files.length > 0 ? files : ['package.json'];
|
|
30
32
|
|
|
31
33
|
// Run sort-package-json
|
|
32
34
|
try {
|
|
33
|
-
|
|
35
|
+
const checkFlag = fixMode ? '' : '--check';
|
|
36
|
+
execSync(`${bin} ${checkFlag} ${targets.join(' ')}`.trim(), { stdio: 'inherit' });
|
|
34
37
|
} catch {
|
|
35
38
|
process.exit(1);
|
|
36
39
|
}
|
|
@@ -38,15 +41,16 @@ try {
|
|
|
38
41
|
/**
|
|
39
42
|
* Fix exports condition order: types must come before default for TypeScript.
|
|
40
43
|
* See: https://www.typescriptlang.org/docs/handbook/esm-node.html
|
|
44
|
+
* Returns true if the file needs changes.
|
|
41
45
|
*/
|
|
42
|
-
function fixExportsOrder(filePath: string):
|
|
46
|
+
function fixExportsOrder(filePath: string, fix: boolean): boolean {
|
|
43
47
|
const fullPath = resolve(process.cwd(), filePath);
|
|
44
|
-
if (!existsSync(fullPath)) return;
|
|
48
|
+
if (!existsSync(fullPath)) return false;
|
|
45
49
|
|
|
46
50
|
const content = readFileSync(fullPath, 'utf-8');
|
|
47
51
|
const pkg = JSON.parse(content) as Record<string, unknown>;
|
|
48
52
|
|
|
49
|
-
if (!pkg.exports || typeof pkg.exports !== 'object') return;
|
|
53
|
+
if (!pkg.exports || typeof pkg.exports !== 'object') return false;
|
|
50
54
|
|
|
51
55
|
let modified = false;
|
|
52
56
|
|
|
@@ -88,12 +92,23 @@ function fixExportsOrder(filePath: string): void {
|
|
|
88
92
|
|
|
89
93
|
pkg.exports = reorderConditions(pkg.exports as Record<string, unknown>);
|
|
90
94
|
|
|
91
|
-
if (modified) {
|
|
95
|
+
if (modified && fix) {
|
|
92
96
|
writeFileSync(fullPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
93
97
|
}
|
|
98
|
+
|
|
99
|
+
return modified;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
// Fix exports order in each file
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
let hasExportsIssues = false;
|
|
104
|
+
for (const file of targets) {
|
|
105
|
+
const needsFix = fixExportsOrder(file, fixMode);
|
|
106
|
+
if (needsFix && !fixMode) {
|
|
107
|
+
console.error(`${file}: exports condition order is incorrect (types must come before default)`);
|
|
108
|
+
hasExportsIssues = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (hasExportsIssues) {
|
|
113
|
+
process.exit(1);
|
|
99
114
|
}
|
package/src/vitest/node.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { TestUserConfig } from 'vitest/node';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Coverage thresholds for library packages.
|
|
5
3
|
* These ensure adequate test coverage before publishing.
|
|
@@ -15,7 +13,7 @@ export const coverageThresholds = {
|
|
|
15
13
|
* Base Vitest configuration for Node.js packages.
|
|
16
14
|
* Use with defineConfig() in your vitest.config.ts
|
|
17
15
|
*/
|
|
18
|
-
export const vitestNodeConfig
|
|
16
|
+
export const vitestNodeConfig = {
|
|
19
17
|
coverage: {
|
|
20
18
|
provider: 'v8',
|
|
21
19
|
thresholds: coverageThresholds,
|
package/src/vitest/react.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TestUserConfig } from 'vitest/node';
|
|
2
1
|
import { coverageThresholds } from './node';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -7,7 +6,7 @@ import { coverageThresholds } from './node';
|
|
|
7
6
|
*
|
|
8
7
|
* Requires a setup file that imports '@testing-library/jest-dom/vitest'
|
|
9
8
|
*/
|
|
10
|
-
export const vitestReactConfig
|
|
9
|
+
export const vitestReactConfig = {
|
|
11
10
|
coverage: {
|
|
12
11
|
provider: 'v8',
|
|
13
12
|
thresholds: coverageThresholds,
|