@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.
Files changed (113) hide show
  1. package/README.md +3 -3
  2. package/dist/bin/exec/clean.d.ts +3 -0
  3. package/dist/bin/exec/clean.d.ts.map +1 -0
  4. package/dist/bin/exec/clean.js +25 -0
  5. package/dist/bin/exec/clean.test.d.ts +2 -0
  6. package/dist/bin/exec/clean.test.d.ts.map +1 -0
  7. package/dist/bin/exec/clean.test.js +45 -0
  8. package/dist/bin/exec/husky.d.ts +3 -0
  9. package/dist/bin/exec/husky.d.ts.map +1 -0
  10. package/dist/bin/exec/p.d.ts +3 -0
  11. package/dist/bin/exec/p.d.ts.map +1 -0
  12. package/dist/bin/exec/s.d.ts +3 -0
  13. package/dist/bin/exec/s.d.ts.map +1 -0
  14. package/dist/bin/exec/ts.d.ts +3 -0
  15. package/dist/bin/exec/ts.d.ts.map +1 -0
  16. package/dist/bin/exec/ts.js +36 -0
  17. package/dist/bin/exec/ts.test.d.ts +2 -0
  18. package/dist/bin/exec/ts.test.d.ts.map +1 -0
  19. package/dist/bin/exec/ts.test.js +39 -0
  20. package/dist/bin/exec/tsc.d.ts +3 -0
  21. package/dist/bin/exec/tsc.d.ts.map +1 -0
  22. package/dist/bin/flow/hotfix.d.ts +3 -0
  23. package/dist/bin/flow/hotfix.d.ts.map +1 -0
  24. package/dist/bin/flow/hotfix.js +116 -0
  25. package/dist/bin/flow/release.d.ts +3 -0
  26. package/dist/bin/flow/release.d.ts.map +1 -0
  27. package/dist/bin/flow/release.js +68 -0
  28. package/dist/bin/flow/ship.d.ts +3 -0
  29. package/dist/bin/flow/ship.d.ts.map +1 -0
  30. package/dist/bin/flow/ship.js +104 -0
  31. package/dist/bin/flow/utils.d.ts +9 -0
  32. package/dist/bin/flow/utils.d.ts.map +1 -0
  33. package/dist/bin/flow/utils.js +63 -0
  34. package/dist/bin/flow/utils.test.d.ts +2 -0
  35. package/dist/bin/flow/utils.test.d.ts.map +1 -0
  36. package/dist/bin/flow/utils.test.js +127 -0
  37. package/dist/bin/lint/biome.d.ts +3 -0
  38. package/dist/bin/lint/biome.d.ts.map +1 -0
  39. package/dist/bin/lint/commit.d.ts +3 -0
  40. package/dist/bin/lint/commit.d.ts.map +1 -0
  41. package/dist/bin/lint/md.d.ts +3 -0
  42. package/dist/bin/lint/md.d.ts.map +1 -0
  43. package/dist/bin/lint/package.d.ts +4 -0
  44. package/dist/bin/lint/package.d.ts.map +1 -0
  45. package/dist/bin/lint/package.js +81 -0
  46. package/dist/bin/lint/package.test.d.ts +2 -0
  47. package/dist/bin/lint/package.test.d.ts.map +1 -0
  48. package/dist/bin/lint/package.test.js +65 -0
  49. package/package.json +21 -22
  50. package/src/bin/exec/clean.test.ts +63 -0
  51. package/src/bin/exec/clean.ts +36 -0
  52. package/src/bin/exec/ts.test.ts +54 -0
  53. package/src/bin/exec/ts.ts +52 -0
  54. package/src/bin/flow/hotfix.ts +210 -0
  55. package/src/bin/flow/release.ts +130 -0
  56. package/src/bin/flow/ship.ts +215 -0
  57. package/src/bin/flow/utils.test.ts +178 -0
  58. package/src/bin/flow/utils.ts +109 -0
  59. package/src/bin/lint/package.test.ts +83 -0
  60. package/src/bin/lint/package.ts +108 -0
  61. package/src/templates/release.yml +23 -17
  62. package/dist/bin/exec-clean.d.ts +0 -3
  63. package/dist/bin/exec-clean.d.ts.map +0 -1
  64. package/dist/bin/exec-clean.js +0 -18
  65. package/dist/bin/exec-husky.d.ts +0 -3
  66. package/dist/bin/exec-husky.d.ts.map +0 -1
  67. package/dist/bin/exec-p.d.ts +0 -3
  68. package/dist/bin/exec-p.d.ts.map +0 -1
  69. package/dist/bin/exec-s.d.ts +0 -3
  70. package/dist/bin/exec-s.d.ts.map +0 -1
  71. package/dist/bin/exec-ts.d.ts +0 -3
  72. package/dist/bin/exec-ts.d.ts.map +0 -1
  73. package/dist/bin/exec-ts.js +0 -28
  74. package/dist/bin/exec-tsc.d.ts +0 -3
  75. package/dist/bin/exec-tsc.d.ts.map +0 -1
  76. package/dist/bin/flow-changeset.d.ts +0 -3
  77. package/dist/bin/flow-changeset.d.ts.map +0 -1
  78. package/dist/bin/flow-changeset.js +0 -18
  79. package/dist/bin/flow-release.d.ts +0 -3
  80. package/dist/bin/flow-release.d.ts.map +0 -1
  81. package/dist/bin/flow-release.js +0 -115
  82. package/dist/bin/lint-biome.d.ts +0 -3
  83. package/dist/bin/lint-biome.d.ts.map +0 -1
  84. package/dist/bin/lint-commit.d.ts +0 -3
  85. package/dist/bin/lint-commit.d.ts.map +0 -1
  86. package/dist/bin/lint-md.d.ts +0 -3
  87. package/dist/bin/lint-md.d.ts.map +0 -1
  88. package/dist/bin/lint-package.d.ts +0 -3
  89. package/dist/bin/lint-package.d.ts.map +0 -1
  90. package/dist/bin/lint-package.js +0 -86
  91. package/dist/bin/lint-package.test.d.ts +0 -2
  92. package/dist/bin/lint-package.test.d.ts.map +0 -1
  93. package/dist/bin/lint-package.test.js +0 -111
  94. package/src/bin/exec-clean.ts +0 -24
  95. package/src/bin/exec-ts.ts +0 -39
  96. package/src/bin/flow-changeset.ts +0 -23
  97. package/src/bin/flow-release.ts +0 -185
  98. package/src/bin/lint-package.test.ts +0 -140
  99. package/src/bin/lint-package.ts +0 -114
  100. /package/dist/bin/{exec-husky.js → exec/husky.js} +0 -0
  101. /package/dist/bin/{exec-p.js → exec/p.js} +0 -0
  102. /package/dist/bin/{exec-s.js → exec/s.js} +0 -0
  103. /package/dist/bin/{exec-tsc.js → exec/tsc.js} +0 -0
  104. /package/dist/bin/{lint-biome.js → lint/biome.js} +0 -0
  105. /package/dist/bin/{lint-commit.js → lint/commit.js} +0 -0
  106. /package/dist/bin/{lint-md.js → lint/md.js} +0 -0
  107. /package/src/bin/{exec-husky.ts → exec/husky.ts} +0 -0
  108. /package/src/bin/{exec-p.ts → exec/p.ts} +0 -0
  109. /package/src/bin/{exec-s.ts → exec/s.ts} +0 -0
  110. /package/src/bin/{exec-tsc.ts → exec/tsc.ts} +0 -0
  111. /package/src/bin/{lint-biome.ts → lint/biome.ts} +0 -0
  112. /package/src/bin/{lint-commit.ts → lint/commit.ts} +0 -0
  113. /package/src/bin/{lint-md.ts → lint/md.ts} +0 -0
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from 'node:child_process';
3
- import { createRequire } from 'node:module';
4
- import path from 'node:path';
5
- const require = createRequire(import.meta.url);
6
- const pkgPath = require.resolve('@changesets/cli/package.json');
7
- const pkg = require(pkgPath);
8
- let binRel = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.changeset;
9
- if (!binRel) {
10
- console.error('Unable to locate changeset binary from package.json bin field');
11
- process.exit(1);
12
- }
13
- if (binRel.startsWith('./'))
14
- binRel = binRel.slice(2);
15
- const bin = path.join(path.dirname(pkgPath), binRel);
16
- const args = process.argv.slice(2);
17
- const child = spawn(process.execPath, [bin, ...args], { stdio: 'inherit' });
18
- child.on('exit', (code) => process.exit(code ?? 0));
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=flow-release.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-release.d.ts","sourceRoot":"","sources":["../../src/bin/flow-release.ts"],"names":[],"mappings":""}
@@ -1,115 +0,0 @@
1
- #!/usr/bin/env node
2
- import { execSync, spawn } from 'node:child_process';
3
- import { existsSync, mkdirSync, readdirSync, readFileSync, unlinkSync, writeFileSync, } from 'node:fs';
4
- import { createRequire } from 'node:module';
5
- import path, { join } from 'node:path';
6
- const args = process.argv.slice(2);
7
- const bumpType = args[0];
8
- const message = args.slice(1).join(' ') || 'Release update';
9
- if (!bumpType || !['patch', 'minor', 'major'].includes(bumpType)) {
10
- console.error('Usage: flow-release <patch|minor|major> [message]');
11
- console.error('Example: flow-release minor "Add new vitest configs"');
12
- process.exit(1);
13
- }
14
- const run = (cmd) => {
15
- console.log(`$ ${cmd}`);
16
- execSync(cmd, { stdio: 'inherit' });
17
- };
18
- const runQuiet = (cmd) => {
19
- return execSync(cmd, { encoding: 'utf-8' }).trim();
20
- };
21
- const packageJsonPath = join(process.cwd(), 'package.json');
22
- if (!existsSync(packageJsonPath)) {
23
- console.error('No package.json found in current directory');
24
- process.exit(1);
25
- }
26
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
27
- const packageName = packageJson.name;
28
- if (!packageName) {
29
- console.error('No "name" field found in package.json');
30
- process.exit(1);
31
- }
32
- console.log(`Releasing ${packageName} with ${bumpType} bump...`);
33
- console.log('Running quality checks...');
34
- try {
35
- run('pnpm build');
36
- run('pnpm typecheck');
37
- run('pnpm report');
38
- }
39
- catch {
40
- console.error('Quality checks failed. Fix issues before releasing.');
41
- process.exit(1);
42
- }
43
- console.log('✅ Quality checks passed');
44
- try {
45
- const status = runQuiet('git status --porcelain');
46
- if (status) {
47
- console.log('Working directory has uncommitted changes. Staging all changes...');
48
- }
49
- }
50
- catch {
51
- console.error('Not in a git repository');
52
- process.exit(1);
53
- }
54
- const changesetDir = join(process.cwd(), '.changeset');
55
- const changesetConfigPath = join(changesetDir, 'config.json');
56
- if (!existsSync(changesetConfigPath)) {
57
- console.error('No .changeset/config.json found.');
58
- console.error('Run: pnpm changeset init');
59
- console.error('Then configure .changeset/config.json for your package.');
60
- process.exit(1);
61
- }
62
- mkdirSync(changesetDir, { recursive: true });
63
- const existingChangesets = readdirSync(changesetDir).filter((f) => f.endsWith('.md') && f !== 'README.md');
64
- for (const file of existingChangesets) {
65
- unlinkSync(join(changesetDir, file));
66
- console.log(`Removed existing changeset: ${file}`);
67
- }
68
- const changesetId = `release-${Date.now()}`;
69
- const changesetFile = join(changesetDir, `${changesetId}.md`);
70
- const changesetContent = `---
71
- "${packageName}": ${bumpType}
72
- ---
73
-
74
- ${message}
75
- `;
76
- writeFileSync(changesetFile, changesetContent);
77
- console.log(`Created changeset: .changeset/${changesetId}.md`);
78
- const require = createRequire(import.meta.url);
79
- const changesetPkgPath = require.resolve('@changesets/cli/package.json');
80
- const changesetPkg = require(changesetPkgPath);
81
- let changesetBinRel = typeof changesetPkg.bin === 'string' ? changesetPkg.bin : changesetPkg.bin?.changeset;
82
- if (!changesetBinRel) {
83
- console.error('Unable to locate changeset binary');
84
- process.exit(1);
85
- }
86
- if (changesetBinRel.startsWith('./'))
87
- changesetBinRel = changesetBinRel.slice(2);
88
- const changesetBin = path.join(path.dirname(changesetPkgPath), changesetBinRel);
89
- const changesetChild = spawn(process.execPath, [changesetBin, 'version'], {
90
- stdio: 'inherit',
91
- });
92
- await new Promise((resolve, reject) => {
93
- changesetChild.on('exit', (code) => {
94
- if (code === 0)
95
- resolve();
96
- else
97
- reject(new Error(`changeset version failed with code ${code}`));
98
- });
99
- });
100
- console.log('Updating lockfile...');
101
- run('pnpm install --ignore-workspace');
102
- console.log('Fixing formatting...');
103
- try {
104
- run('pnpm fix');
105
- }
106
- catch {
107
- }
108
- run('git add -A');
109
- const updatedPackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
110
- const { version } = updatedPackageJson;
111
- run(`git commit -m "chore(release): v${version}"`);
112
- const branch = runQuiet('git branch --show-current');
113
- run(`git push origin ${branch}`);
114
- console.log(`\n✅ Released v${version}`);
115
- console.log('The GitHub Action will now publish to npm.');
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=lint-biome.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lint-biome.d.ts","sourceRoot":"","sources":["../../src/bin/lint-biome.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=lint-commit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lint-commit.d.ts","sourceRoot":"","sources":["../../src/bin/lint-commit.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=lint-md.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lint-md.d.ts","sourceRoot":"","sources":["../../src/bin/lint-md.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=lint-package.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lint-package.d.ts","sourceRoot":"","sources":["../../src/bin/lint-package.ts"],"names":[],"mappings":""}
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env node
2
- import { execSync } from 'node:child_process';
3
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
4
- import { dirname, join, resolve } from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const devRoot = resolve(__dirname, '../..');
8
- const sortPkgBin = join(devRoot, 'node_modules/.bin/sort-package-json');
9
- const sortPkgBinAlt = join(devRoot, 'node_modules/sort-package-json/cli.js');
10
- let bin = '';
11
- if (existsSync(sortPkgBin)) {
12
- bin = sortPkgBin;
13
- }
14
- else if (existsSync(sortPkgBinAlt)) {
15
- bin = `node ${sortPkgBinAlt}`;
16
- }
17
- else {
18
- bin = 'npx sort-package-json';
19
- }
20
- const args = process.argv.slice(2);
21
- const fixMode = args.includes('--fix');
22
- const files = args.filter((arg) => arg !== '--fix');
23
- const targets = files.length > 0 ? files : ['package.json'];
24
- try {
25
- const checkFlag = fixMode ? '' : '--check';
26
- execSync(`${bin} ${checkFlag} ${targets.join(' ')}`.trim(), { stdio: 'inherit' });
27
- }
28
- catch {
29
- process.exit(1);
30
- }
31
- function fixExportsOrder(filePath, fix) {
32
- const fullPath = resolve(process.cwd(), filePath);
33
- if (!existsSync(fullPath))
34
- return false;
35
- const content = readFileSync(fullPath, 'utf-8');
36
- const pkg = JSON.parse(content);
37
- if (!pkg.exports || typeof pkg.exports !== 'object')
38
- return false;
39
- let modified = false;
40
- function reorderConditions(obj) {
41
- if (typeof obj !== 'object' || obj === null)
42
- return obj;
43
- if ('types' in obj && 'default' in obj) {
44
- const keys = Object.keys(obj);
45
- const typesIndex = keys.indexOf('types');
46
- const defaultIndex = keys.indexOf('default');
47
- if (defaultIndex < typesIndex) {
48
- modified = true;
49
- const reordered = {};
50
- reordered.types = obj.types;
51
- for (const key of keys) {
52
- if (key !== 'types') {
53
- reordered[key] = obj[key];
54
- }
55
- }
56
- return reordered;
57
- }
58
- }
59
- const result = {};
60
- for (const [key, value] of Object.entries(obj)) {
61
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
62
- result[key] = reorderConditions(value);
63
- }
64
- else {
65
- result[key] = value;
66
- }
67
- }
68
- return result;
69
- }
70
- pkg.exports = reorderConditions(pkg.exports);
71
- if (modified && fix) {
72
- writeFileSync(fullPath, `${JSON.stringify(pkg, null, 2)}\n`);
73
- }
74
- return modified;
75
- }
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);
86
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=lint-package.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lint-package.test.d.ts","sourceRoot":"","sources":["../../src/bin/lint-package.test.ts"],"names":[],"mappings":""}
@@ -1,111 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- function reorderConditions(obj) {
3
- function processObject(o) {
4
- if (typeof o !== 'object' || o === null)
5
- return o;
6
- const processed = {};
7
- for (const [key, value] of Object.entries(o)) {
8
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
9
- processed[key] = processObject(value);
10
- }
11
- else {
12
- processed[key] = value;
13
- }
14
- }
15
- if ('types' in processed && 'default' in processed) {
16
- const keys = Object.keys(processed);
17
- const typesIndex = keys.indexOf('types');
18
- const defaultIndex = keys.indexOf('default');
19
- if (defaultIndex < typesIndex) {
20
- const reordered = {};
21
- reordered.types = processed.types;
22
- for (const key of keys) {
23
- if (key !== 'types') {
24
- reordered[key] = processed[key];
25
- }
26
- }
27
- return reordered;
28
- }
29
- }
30
- return processed;
31
- }
32
- return processObject(obj);
33
- }
34
- describe('lint-package', () => {
35
- describe('reorderConditions', () => {
36
- it('should reorder types before default when default comes first', () => {
37
- const input = {
38
- './foo': {
39
- default: './dist/foo.js',
40
- types: './dist/foo.d.ts',
41
- },
42
- };
43
- const result = reorderConditions(input);
44
- expect(Object.keys(result['./foo'])).toEqual(['types', 'default']);
45
- });
46
- it('should not modify when types already comes before default', () => {
47
- const input = {
48
- './foo': {
49
- default: './dist/foo.js',
50
- types: './dist/foo.d.ts',
51
- },
52
- };
53
- const result = reorderConditions(input);
54
- expect(Object.keys(result['./foo'])).toEqual(['types', 'default']);
55
- });
56
- it('should handle multiple exports with mixed order', () => {
57
- const input = {
58
- './a': {
59
- default: './dist/a.js',
60
- types: './dist/a.d.ts',
61
- },
62
- './b': {
63
- default: './dist/b.js',
64
- types: './dist/b.d.ts',
65
- },
66
- };
67
- const result = reorderConditions(input);
68
- expect(Object.keys(result['./a'])[0]).toBe('types');
69
- expect(Object.keys(result['./b'])[0]).toBe('types');
70
- });
71
- it('should preserve other keys after types', () => {
72
- const input = {
73
- './foo': {
74
- default: './dist/foo.js',
75
- import: './dist/foo.mjs',
76
- require: './dist/foo.cjs',
77
- types: './dist/foo.d.ts',
78
- },
79
- };
80
- const result = reorderConditions(input);
81
- const keys = Object.keys(result['./foo']);
82
- expect(keys[0]).toBe('types');
83
- expect(keys.slice(1)).toEqual(['default', 'import', 'require']);
84
- });
85
- it('should handle exports without types or default', () => {
86
- const input = {
87
- './styles.css': './dist/styles.css',
88
- };
89
- const result = reorderConditions(input);
90
- expect(result).toEqual(input);
91
- });
92
- it('should handle deeply nested condition objects', () => {
93
- const input = {
94
- './foo': {
95
- browser: {
96
- default: './dist/foo.browser.js',
97
- types: './dist/foo.browser.d.ts',
98
- },
99
- node: {
100
- default: './dist/foo.node.js',
101
- types: './dist/foo.node.d.ts',
102
- },
103
- },
104
- };
105
- const result = reorderConditions(input);
106
- const foo = result['./foo'];
107
- expect(Object.keys(foo.node)[0]).toBe('types');
108
- expect(Object.keys(foo.browser)[0]).toBe('types');
109
- });
110
- });
111
- });
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * exec-clean: Thin wrapper around rimraf for cleaning paths.
4
- * Usage: exec-clean <path> [morePaths...]
5
- */
6
- import { spawn } from 'node:child_process';
7
- import { createRequire } from 'node:module';
8
- import path from 'node:path';
9
-
10
- const require = createRequire(import.meta.url);
11
- const pkgPath = require.resolve('rimraf/package.json');
12
- const pkg = require(pkgPath);
13
- let binRel = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.rimraf;
14
- if (!binRel) {
15
- console.error('Unable to locate rimraf binary from package.json bin field');
16
- process.exit(1);
17
- }
18
- if (binRel.startsWith('./')) binRel = binRel.slice(2);
19
- // Build an absolute path to the bin file relative to the resolved package root
20
- const bin = path.join(path.dirname(pkgPath), binRel);
21
-
22
- const args = process.argv.slice(2);
23
- const child = spawn(process.execPath, [bin, ...args], { stdio: 'inherit' });
24
- child.on('exit', (code) => process.exit(code ?? 0));
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * exec-ts: Run a local TypeScript file via tsx with TS support.
4
- * Usage: exec-ts path/to/script.ts [args...]
5
- */
6
- import { type SpawnOptions, spawn } from 'node:child_process';
7
- import { createRequire } from 'node:module';
8
- import path from 'node:path';
9
-
10
- const args = process.argv.slice(2);
11
- if (args.length === 0) {
12
- console.error('Usage: exec-ts <script.ts> [args...]');
13
- process.exit(1);
14
- }
15
-
16
- const [scriptArg, ...rest] = args;
17
- const script = scriptArg ?? '';
18
-
19
- // Delegate to tsx to run a local TypeScript file with full TypeScript support
20
- const require = createRequire(import.meta.url);
21
- const pkgPath = require.resolve('tsx/package.json');
22
- const pkg = require(pkgPath);
23
- const binRel = pkg.bin;
24
- const binPath: string | undefined =
25
- typeof binRel === 'string'
26
- ? binRel
27
- : typeof binRel === 'object' && binRel !== null && 'tsx' in binRel
28
- ? (binRel as Record<string, string>).tsx
29
- : undefined;
30
-
31
- if (!binPath) {
32
- console.error('Unable to locate tsx binary from package.json bin field');
33
- process.exit(1);
34
- }
35
- // Build an absolute path to the bin file relative to the resolved package root
36
- const bin = path.join(path.dirname(pkgPath), binPath);
37
- const spawnOptions: SpawnOptions = { stdio: 'inherit' };
38
- const child = spawn(process.execPath, [bin, script, ...rest], spawnOptions);
39
- child.on('exit', (code: number | null) => process.exit(code ?? 0));
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * flow-changeset: Run @changesets/cli commands.
4
- * Usage: flow-changeset [changeset args...]
5
- */
6
- import { spawn } from 'node:child_process';
7
- import { createRequire } from 'node:module';
8
- import path from 'node:path';
9
-
10
- const require = createRequire(import.meta.url);
11
- const pkgPath = require.resolve('@changesets/cli/package.json');
12
- const pkg = require(pkgPath);
13
- let binRel = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.changeset;
14
- if (!binRel) {
15
- console.error('Unable to locate changeset binary from package.json bin field');
16
- process.exit(1);
17
- }
18
- if (binRel.startsWith('./')) binRel = binRel.slice(2);
19
- const bin = path.join(path.dirname(pkgPath), binRel);
20
-
21
- const args = process.argv.slice(2);
22
- const child = spawn(process.execPath, [bin, ...args], { stdio: 'inherit' });
23
- child.on('exit', (code) => process.exit(code ?? 0));
@@ -1,185 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * flow-release: Automate the release flow for any @regardio package.
4
- *
5
- * Usage: flow-release <patch|minor|major> [message]
6
- *
7
- * This script:
8
- * 1. Reads the package name from package.json
9
- * 2. Creates a changeset file with the specified bump type
10
- * 3. Runs `changeset version` to apply the version bump
11
- * 4. Updates the lockfile (pnpm install --ignore-workspace)
12
- * 5. Commits all changes
13
- * 6. Pushes to the current branch
14
- *
15
- * The GitHub Action will then publish to npm automatically.
16
- *
17
- * Prerequisites for adopting packages:
18
- * - Add @regardio/dev as a devDependency
19
- * - Create .changeset/config.json (see template in dev docs)
20
- * - Add .github/workflows/release.yml (see template in dev docs)
21
- * - Add "release": "flow-release" to package.json scripts
22
- */
23
- import { execSync, spawn } from 'node:child_process';
24
- import {
25
- existsSync,
26
- mkdirSync,
27
- readdirSync,
28
- readFileSync,
29
- unlinkSync,
30
- writeFileSync,
31
- } from 'node:fs';
32
- import { createRequire } from 'node:module';
33
- import path, { join } from 'node:path';
34
-
35
- const args = process.argv.slice(2);
36
- const bumpType = args[0];
37
- const message = args.slice(1).join(' ') || 'Release update';
38
-
39
- if (!bumpType || !['patch', 'minor', 'major'].includes(bumpType)) {
40
- console.error('Usage: flow-release <patch|minor|major> [message]');
41
- console.error('Example: flow-release minor "Add new vitest configs"');
42
- process.exit(1);
43
- }
44
-
45
- const run = (cmd: string) => {
46
- console.log(`$ ${cmd}`);
47
- execSync(cmd, { stdio: 'inherit' });
48
- };
49
-
50
- const runQuiet = (cmd: string): string => {
51
- return execSync(cmd, { encoding: 'utf-8' }).trim();
52
- };
53
-
54
- // Read package name from package.json
55
- const packageJsonPath = join(process.cwd(), 'package.json');
56
- if (!existsSync(packageJsonPath)) {
57
- console.error('No package.json found in current directory');
58
- process.exit(1);
59
- }
60
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
61
- name: string;
62
- version: string;
63
- };
64
- const packageName = packageJson.name;
65
-
66
- if (!packageName) {
67
- console.error('No "name" field found in package.json');
68
- process.exit(1);
69
- }
70
-
71
- console.log(`Releasing ${packageName} with ${bumpType} bump...`);
72
-
73
- // Run quality checks before release
74
- console.log('Running quality checks...');
75
- try {
76
- run('pnpm build');
77
- run('pnpm typecheck');
78
- run('pnpm report');
79
- } catch {
80
- console.error('Quality checks failed. Fix issues before releasing.');
81
- process.exit(1);
82
- }
83
- console.log('✅ Quality checks passed');
84
-
85
- // Ensure we're in a clean git state
86
- try {
87
- const status = runQuiet('git status --porcelain');
88
- if (status) {
89
- console.log('Working directory has uncommitted changes. Staging all changes...');
90
- }
91
- } catch {
92
- console.error('Not in a git repository');
93
- process.exit(1);
94
- }
95
-
96
- // Verify .changeset/config.json exists
97
- const changesetDir = join(process.cwd(), '.changeset');
98
- const changesetConfigPath = join(changesetDir, 'config.json');
99
- if (!existsSync(changesetConfigPath)) {
100
- console.error('No .changeset/config.json found.');
101
- console.error('Run: pnpm changeset init');
102
- console.error('Then configure .changeset/config.json for your package.');
103
- process.exit(1);
104
- }
105
-
106
- // Clean up existing changesets to ensure only our bump type is applied
107
- mkdirSync(changesetDir, { recursive: true });
108
-
109
- const existingChangesets = readdirSync(changesetDir).filter(
110
- (f) => f.endsWith('.md') && f !== 'README.md',
111
- );
112
- for (const file of existingChangesets) {
113
- unlinkSync(join(changesetDir, file));
114
- console.log(`Removed existing changeset: ${file}`);
115
- }
116
-
117
- // Generate a unique changeset filename
118
- const changesetId = `release-${Date.now()}`;
119
- const changesetFile = join(changesetDir, `${changesetId}.md`);
120
-
121
- // Create the changeset file with dynamic package name
122
- const changesetContent = `---
123
- "${packageName}": ${bumpType}
124
- ---
125
-
126
- ${message}
127
- `;
128
-
129
- writeFileSync(changesetFile, changesetContent);
130
- console.log(`Created changeset: .changeset/${changesetId}.md`);
131
-
132
- // Run changeset version to apply the bump
133
- // Resolve changeset bin directly to avoid dependency on flow-changeset being in PATH
134
- const require = createRequire(import.meta.url);
135
- const changesetPkgPath = require.resolve('@changesets/cli/package.json');
136
- const changesetPkg = require(changesetPkgPath);
137
- let changesetBinRel =
138
- typeof changesetPkg.bin === 'string' ? changesetPkg.bin : changesetPkg.bin?.changeset;
139
- if (!changesetBinRel) {
140
- console.error('Unable to locate changeset binary');
141
- process.exit(1);
142
- }
143
- if (changesetBinRel.startsWith('./')) changesetBinRel = changesetBinRel.slice(2);
144
- const changesetBin = path.join(path.dirname(changesetPkgPath), changesetBinRel);
145
- const changesetChild = spawn(process.execPath, [changesetBin, 'version'], {
146
- stdio: 'inherit',
147
- });
148
- await new Promise<void>((resolve, reject) => {
149
- changesetChild.on('exit', (code) => {
150
- if (code === 0) resolve();
151
- else reject(new Error(`changeset version failed with code ${code}`));
152
- });
153
- });
154
-
155
- // Update lockfile to ensure it matches package.json
156
- // Use --ignore-workspace to update this package's lockfile independently
157
- console.log('Updating lockfile...');
158
- run('pnpm install --ignore-workspace');
159
-
160
- // Run fix to ensure package.json formatting is correct after changeset version
161
- console.log('Fixing formatting...');
162
- try {
163
- run('pnpm fix');
164
- } catch {
165
- // fix may not exist in all packages, ignore errors
166
- }
167
-
168
- // Stage all changes
169
- run('git add -A');
170
-
171
- // Re-read package.json to get the new version after changeset version
172
- const updatedPackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
173
- version: string;
174
- };
175
- const { version } = updatedPackageJson;
176
-
177
- // Commit
178
- run(`git commit -m "chore(release): v${version}"`);
179
-
180
- // Push
181
- const branch = runQuiet('git branch --show-current');
182
- run(`git push origin ${branch}`);
183
-
184
- console.log(`\n✅ Released v${version}`);
185
- console.log('The GitHub Action will now publish to npm.');