@regardio/dev 1.13.8 → 1.14.3
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 +3 -3
- package/dist/bin/exec/clean.d.ts +3 -0
- package/dist/bin/exec/clean.d.ts.map +1 -0
- package/dist/bin/exec/clean.js +25 -0
- package/dist/bin/exec/clean.test.d.ts +2 -0
- package/dist/bin/exec/clean.test.d.ts.map +1 -0
- package/dist/bin/exec/clean.test.js +45 -0
- package/dist/bin/exec/husky.d.ts +3 -0
- package/dist/bin/exec/husky.d.ts.map +1 -0
- package/dist/bin/exec/p.d.ts +3 -0
- package/dist/bin/exec/p.d.ts.map +1 -0
- package/dist/bin/exec/s.d.ts +3 -0
- package/dist/bin/exec/s.d.ts.map +1 -0
- package/dist/bin/exec/ts.d.ts +3 -0
- package/dist/bin/exec/ts.d.ts.map +1 -0
- package/dist/bin/exec/ts.js +36 -0
- package/dist/bin/exec/ts.test.d.ts +2 -0
- package/dist/bin/exec/ts.test.d.ts.map +1 -0
- package/dist/bin/exec/ts.test.js +39 -0
- package/dist/bin/exec/tsc.d.ts +3 -0
- package/dist/bin/exec/tsc.d.ts.map +1 -0
- package/dist/bin/flow/hotfix.d.ts +3 -0
- package/dist/bin/flow/hotfix.d.ts.map +1 -0
- package/dist/bin/flow/hotfix.js +116 -0
- package/dist/bin/flow/release.d.ts +3 -0
- package/dist/bin/flow/release.d.ts.map +1 -0
- package/dist/bin/flow/release.js +68 -0
- package/dist/bin/flow/ship.d.ts +3 -0
- package/dist/bin/flow/ship.d.ts.map +1 -0
- package/dist/bin/flow/ship.js +104 -0
- package/dist/bin/flow/utils.d.ts +9 -0
- package/dist/bin/flow/utils.d.ts.map +1 -0
- package/dist/bin/flow/utils.js +63 -0
- package/dist/bin/flow/utils.test.d.ts +2 -0
- package/dist/bin/flow/utils.test.d.ts.map +1 -0
- package/dist/bin/flow/utils.test.js +127 -0
- package/dist/bin/lint/biome.d.ts +3 -0
- package/dist/bin/lint/biome.d.ts.map +1 -0
- package/dist/bin/lint/commit.d.ts +3 -0
- package/dist/bin/lint/commit.d.ts.map +1 -0
- package/dist/bin/lint/md.d.ts +3 -0
- package/dist/bin/lint/md.d.ts.map +1 -0
- package/dist/bin/lint/package.d.ts +4 -0
- package/dist/bin/lint/package.d.ts.map +1 -0
- package/dist/bin/lint/package.js +81 -0
- package/dist/bin/lint/package.test.d.ts +2 -0
- package/dist/bin/lint/package.test.d.ts.map +1 -0
- package/dist/bin/lint/package.test.js +65 -0
- package/package.json +21 -22
- package/src/bin/exec/clean.test.ts +63 -0
- package/src/bin/exec/clean.ts +36 -0
- package/src/bin/exec/ts.test.ts +54 -0
- package/src/bin/exec/ts.ts +52 -0
- package/src/bin/flow/hotfix.ts +210 -0
- package/src/bin/flow/release.ts +130 -0
- package/src/bin/flow/ship.ts +215 -0
- package/src/bin/flow/utils.test.ts +178 -0
- package/src/bin/flow/utils.ts +109 -0
- package/src/bin/lint/package.test.ts +83 -0
- package/src/bin/lint/package.ts +108 -0
- package/src/templates/release.yml +23 -17
- package/dist/bin/exec-clean.d.ts +0 -3
- package/dist/bin/exec-clean.d.ts.map +0 -1
- package/dist/bin/exec-clean.js +0 -18
- package/dist/bin/exec-husky.d.ts +0 -3
- package/dist/bin/exec-husky.d.ts.map +0 -1
- package/dist/bin/exec-p.d.ts +0 -3
- package/dist/bin/exec-p.d.ts.map +0 -1
- package/dist/bin/exec-s.d.ts +0 -3
- package/dist/bin/exec-s.d.ts.map +0 -1
- package/dist/bin/exec-ts.d.ts +0 -3
- package/dist/bin/exec-ts.d.ts.map +0 -1
- package/dist/bin/exec-ts.js +0 -28
- package/dist/bin/exec-tsc.d.ts +0 -3
- package/dist/bin/exec-tsc.d.ts.map +0 -1
- package/dist/bin/flow-changeset.d.ts +0 -3
- package/dist/bin/flow-changeset.d.ts.map +0 -1
- package/dist/bin/flow-changeset.js +0 -18
- package/dist/bin/flow-release.d.ts +0 -3
- package/dist/bin/flow-release.d.ts.map +0 -1
- package/dist/bin/flow-release.js +0 -115
- package/dist/bin/lint-biome.d.ts +0 -3
- package/dist/bin/lint-biome.d.ts.map +0 -1
- package/dist/bin/lint-commit.d.ts +0 -3
- package/dist/bin/lint-commit.d.ts.map +0 -1
- package/dist/bin/lint-md.d.ts +0 -3
- package/dist/bin/lint-md.d.ts.map +0 -1
- package/dist/bin/lint-package.d.ts +0 -3
- package/dist/bin/lint-package.d.ts.map +0 -1
- package/dist/bin/lint-package.js +0 -86
- package/dist/bin/lint-package.test.d.ts +0 -2
- package/dist/bin/lint-package.test.d.ts.map +0 -1
- package/dist/bin/lint-package.test.js +0 -111
- package/src/bin/exec-clean.ts +0 -24
- package/src/bin/exec-ts.ts +0 -39
- package/src/bin/flow-changeset.ts +0 -23
- package/src/bin/flow-release.ts +0 -185
- package/src/bin/lint-package.test.ts +0 -140
- package/src/bin/lint-package.ts +0 -114
- /package/dist/bin/{exec-husky.js → exec/husky.js} +0 -0
- /package/dist/bin/{exec-p.js → exec/p.js} +0 -0
- /package/dist/bin/{exec-s.js → exec/s.js} +0 -0
- /package/dist/bin/{exec-tsc.js → exec/tsc.js} +0 -0
- /package/dist/bin/{lint-biome.js → lint/biome.js} +0 -0
- /package/dist/bin/{lint-commit.js → lint/commit.js} +0 -0
- /package/dist/bin/{lint-md.js → lint/md.js} +0 -0
- /package/src/bin/{exec-husky.ts → exec/husky.ts} +0 -0
- /package/src/bin/{exec-p.ts → exec/p.ts} +0 -0
- /package/src/bin/{exec-s.ts → exec/s.ts} +0 -0
- /package/src/bin/{exec-tsc.ts → exec/tsc.ts} +0 -0
- /package/src/bin/{lint-biome.ts → lint/biome.ts} +0 -0
- /package/src/bin/{lint-commit.ts → lint/commit.ts} +0 -0
- /package/src/bin/{lint-md.ts → lint/md.ts} +0 -0
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Reorder exports conditions: types must come before default for TypeScript.
|
|
5
|
-
* Extracted from lint-package.ts for testing.
|
|
6
|
-
*/
|
|
7
|
-
function reorderConditions(obj: Record<string, unknown>): Record<string, unknown> {
|
|
8
|
-
function processObject(o: Record<string, unknown>): Record<string, unknown> {
|
|
9
|
-
if (typeof o !== 'object' || o === null) return o;
|
|
10
|
-
|
|
11
|
-
// First, recursively process all nested objects
|
|
12
|
-
const processed: Record<string, unknown> = {};
|
|
13
|
-
for (const [key, value] of Object.entries(o)) {
|
|
14
|
-
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
15
|
-
processed[key] = processObject(value as Record<string, unknown>);
|
|
16
|
-
} else {
|
|
17
|
-
processed[key] = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Then check if this object has both 'types' and 'default' keys
|
|
22
|
-
if ('types' in processed && 'default' in processed) {
|
|
23
|
-
const keys = Object.keys(processed);
|
|
24
|
-
const typesIndex = keys.indexOf('types');
|
|
25
|
-
const defaultIndex = keys.indexOf('default');
|
|
26
|
-
|
|
27
|
-
// If default comes before types, reorder
|
|
28
|
-
if (defaultIndex < typesIndex) {
|
|
29
|
-
const reordered: Record<string, unknown> = {};
|
|
30
|
-
reordered.types = processed.types;
|
|
31
|
-
for (const key of keys) {
|
|
32
|
-
if (key !== 'types') {
|
|
33
|
-
reordered[key] = processed[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return reordered;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return processed;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return processObject(obj);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
describe('lint-package', () => {
|
|
47
|
-
describe('reorderConditions', () => {
|
|
48
|
-
it('should reorder types before default when default comes first', () => {
|
|
49
|
-
const input = {
|
|
50
|
-
'./foo': {
|
|
51
|
-
default: './dist/foo.js',
|
|
52
|
-
types: './dist/foo.d.ts',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const result = reorderConditions(input);
|
|
57
|
-
|
|
58
|
-
expect(Object.keys(result['./foo'] as Record<string, unknown>)).toEqual(['types', 'default']);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should not modify when types already comes before default', () => {
|
|
62
|
-
const input = {
|
|
63
|
-
'./foo': {
|
|
64
|
-
default: './dist/foo.js',
|
|
65
|
-
types: './dist/foo.d.ts',
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const result = reorderConditions(input);
|
|
70
|
-
|
|
71
|
-
expect(Object.keys(result['./foo'] as Record<string, unknown>)).toEqual(['types', 'default']);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should handle multiple exports with mixed order', () => {
|
|
75
|
-
const input = {
|
|
76
|
-
'./a': {
|
|
77
|
-
default: './dist/a.js',
|
|
78
|
-
types: './dist/a.d.ts',
|
|
79
|
-
},
|
|
80
|
-
'./b': {
|
|
81
|
-
default: './dist/b.js',
|
|
82
|
-
types: './dist/b.d.ts',
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const result = reorderConditions(input);
|
|
87
|
-
|
|
88
|
-
expect(Object.keys(result['./a'] as Record<string, unknown>)[0]).toBe('types');
|
|
89
|
-
expect(Object.keys(result['./b'] as Record<string, unknown>)[0]).toBe('types');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('should preserve other keys after types', () => {
|
|
93
|
-
const input = {
|
|
94
|
-
'./foo': {
|
|
95
|
-
default: './dist/foo.js',
|
|
96
|
-
import: './dist/foo.mjs',
|
|
97
|
-
require: './dist/foo.cjs',
|
|
98
|
-
types: './dist/foo.d.ts',
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const result = reorderConditions(input);
|
|
103
|
-
const keys = Object.keys(result['./foo'] as Record<string, unknown>);
|
|
104
|
-
|
|
105
|
-
expect(keys[0]).toBe('types');
|
|
106
|
-
expect(keys.slice(1)).toEqual(['default', 'import', 'require']);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should handle exports without types or default', () => {
|
|
110
|
-
const input = {
|
|
111
|
-
'./styles.css': './dist/styles.css',
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const result = reorderConditions(input);
|
|
115
|
-
|
|
116
|
-
expect(result).toEqual(input);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should handle deeply nested condition objects', () => {
|
|
120
|
-
const input = {
|
|
121
|
-
'./foo': {
|
|
122
|
-
browser: {
|
|
123
|
-
default: './dist/foo.browser.js',
|
|
124
|
-
types: './dist/foo.browser.d.ts',
|
|
125
|
-
},
|
|
126
|
-
node: {
|
|
127
|
-
default: './dist/foo.node.js',
|
|
128
|
-
types: './dist/foo.node.d.ts',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const result = reorderConditions(input);
|
|
134
|
-
const foo = result['./foo'] as Record<string, Record<string, unknown>>;
|
|
135
|
-
|
|
136
|
-
expect(Object.keys(foo.node as object)[0]).toBe('types');
|
|
137
|
-
expect(Object.keys(foo.browser as object)[0]).toBe('types');
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
package/src/bin/lint-package.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Sorts package.json files using sort-package-json and fixes
|
|
4
|
-
* exports condition order (types must come before default for TypeScript).
|
|
5
|
-
*/
|
|
6
|
-
import { execSync } from 'node:child_process';
|
|
7
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import { dirname, join, resolve } from 'node:path';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
-
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const devRoot = resolve(__dirname, '../..');
|
|
13
|
-
|
|
14
|
-
// Find sort-package-json binary
|
|
15
|
-
const sortPkgBin = join(devRoot, 'node_modules/.bin/sort-package-json');
|
|
16
|
-
const sortPkgBinAlt = join(devRoot, 'node_modules/sort-package-json/cli.js');
|
|
17
|
-
|
|
18
|
-
let bin = '';
|
|
19
|
-
if (existsSync(sortPkgBin)) {
|
|
20
|
-
bin = sortPkgBin;
|
|
21
|
-
} else if (existsSync(sortPkgBinAlt)) {
|
|
22
|
-
bin = `node ${sortPkgBinAlt}`;
|
|
23
|
-
} else {
|
|
24
|
-
bin = 'npx sort-package-json';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Get args passed to this script
|
|
28
|
-
const args = process.argv.slice(2);
|
|
29
|
-
const fixMode = args.includes('--fix');
|
|
30
|
-
const files = args.filter((arg) => arg !== '--fix');
|
|
31
|
-
const targets = files.length > 0 ? files : ['package.json'];
|
|
32
|
-
|
|
33
|
-
// Run sort-package-json
|
|
34
|
-
try {
|
|
35
|
-
const checkFlag = fixMode ? '' : '--check';
|
|
36
|
-
execSync(`${bin} ${checkFlag} ${targets.join(' ')}`.trim(), { stdio: 'inherit' });
|
|
37
|
-
} catch {
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Fix exports condition order: types must come before default for TypeScript.
|
|
43
|
-
* See: https://www.typescriptlang.org/docs/handbook/esm-node.html
|
|
44
|
-
* Returns true if the file needs changes.
|
|
45
|
-
*/
|
|
46
|
-
function fixExportsOrder(filePath: string, fix: boolean): boolean {
|
|
47
|
-
const fullPath = resolve(process.cwd(), filePath);
|
|
48
|
-
if (!existsSync(fullPath)) return false;
|
|
49
|
-
|
|
50
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
51
|
-
const pkg = JSON.parse(content) as Record<string, unknown>;
|
|
52
|
-
|
|
53
|
-
if (!pkg.exports || typeof pkg.exports !== 'object') return false;
|
|
54
|
-
|
|
55
|
-
let modified = false;
|
|
56
|
-
|
|
57
|
-
function reorderConditions(obj: Record<string, unknown>): Record<string, unknown> {
|
|
58
|
-
if (typeof obj !== 'object' || obj === null) return obj;
|
|
59
|
-
|
|
60
|
-
// Check if this object has both 'types' and 'default' keys
|
|
61
|
-
if ('types' in obj && 'default' in obj) {
|
|
62
|
-
const keys = Object.keys(obj);
|
|
63
|
-
const typesIndex = keys.indexOf('types');
|
|
64
|
-
const defaultIndex = keys.indexOf('default');
|
|
65
|
-
|
|
66
|
-
// If default comes before types, reorder
|
|
67
|
-
if (defaultIndex < typesIndex) {
|
|
68
|
-
modified = true;
|
|
69
|
-
const reordered: Record<string, unknown> = {};
|
|
70
|
-
// Put types first, then all other keys in original order
|
|
71
|
-
reordered.types = obj.types;
|
|
72
|
-
for (const key of keys) {
|
|
73
|
-
if (key !== 'types') {
|
|
74
|
-
reordered[key] = obj[key];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return reordered;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Recursively process nested objects
|
|
82
|
-
const result: Record<string, unknown> = {};
|
|
83
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
84
|
-
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
85
|
-
result[key] = reorderConditions(value as Record<string, unknown>);
|
|
86
|
-
} else {
|
|
87
|
-
result[key] = value;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
pkg.exports = reorderConditions(pkg.exports as Record<string, unknown>);
|
|
94
|
-
|
|
95
|
-
if (modified && fix) {
|
|
96
|
-
writeFileSync(fullPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return modified;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Fix exports order in each file
|
|
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);
|
|
114
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|