Skip to content

Commit d432332

Browse files
committed
feat(dev-cli): Remove macOS-specific Terminal functionality
1 parent d8d752c commit d432332

File tree

5 files changed

+39
-69
lines changed

5 files changed

+39
-69
lines changed

.changeset/old-points-raise.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/dev-cli": patch
3+
---
4+
5+
Remove macOS-specific Terminal functionality

package-lock.json

+4-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dev-cli/README.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,7 @@ clerk-dev watch
7474

7575
This will run the `build` task for any `@clerk/*` packages in the `package.json` of the current working directory, including any of their dependencies.
7676

77-
> [!NOTE]
78-
> On macOS, this command will automatically spawn a new Terminal.app window running the dev task for `clerk-js`. On other operating systems, you will need to run the following command in a new terminal:
79-
>
80-
> ```sh
81-
> clerk-dev watch --js
82-
> ```
83-
84-
If you do not want to spawn the watcher for `@clerk/clerk-js`, you can instead pass `--no-js`.
77+
If you do not want to start the watcher for `@clerk/clerk-js`, you can instead pass `--no-js`.
8578

8679
```sh
8780
clerk-dev watch --no-js

packages/dev-cli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"dependencies": {
2828
"commander": "^12.1.0",
29+
"concurrently": "^8.2.2",
2930
"dotenv": "^16.4.5",
3031
"globby": "^14.0.2",
3132
"jscodeshift": "^0.16.1"
+28-46
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { spawn } from 'node:child_process';
21
import { join } from 'node:path';
32

3+
import concurrently from 'concurrently';
4+
45
import { getClerkPackages } from '../utils/getClerkPackages.js';
56
import { getDependencies } from '../utils/getDependencies.js';
67
import { getMonorepoRoot } from '../utils/getMonorepoRoot.js';
@@ -9,7 +10,7 @@ import { getMonorepoRoot } from '../utils/getMonorepoRoot.js';
910
* Starts long-running watchers for Clerk dependencies.
1011
* @param {object} args
1112
* @param {boolean | undefined} args.js If `true`, only spawn the builder for `@clerk/clerk-js`.
12-
* @returns {Promise<void>}
13+
* @returns {Promise<import('concurrently').CloseEvent[]>}
1314
*/
1415
export async function watch({ js }) {
1516
const { dependencies, devDependencies } = await getDependencies(join(process.cwd(), 'package.json'));
@@ -24,54 +25,35 @@ export async function watch({ js }) {
2425

2526
const cwd = await getMonorepoRoot();
2627

27-
if (js) {
28-
return new Promise((resolve, reject) => {
29-
const child = spawn(
30-
'turbo',
31-
['run', 'dev', '--filter=@clerk/clerk-js', '--', '--env', 'devOrigin=http://localhost:4000'],
32-
{
33-
cwd,
34-
stdio: 'inherit',
35-
env: { ...process.env },
36-
},
37-
);
28+
/** @type {import('concurrently').ConcurrentlyCommandInput} */
29+
const clerkJsCommand = {
30+
name: 'clerk-js',
31+
command: 'turbo run dev --filter=@clerk/clerk-js -- --env devOrigin=http://localhost:4000',
32+
cwd,
33+
env: { TURBO_UI: '0', ...process.env },
34+
};
35+
36+
/** @type {import('concurrently').ConcurrentlyCommandInput} */
37+
const packagesCommand = {
38+
name: 'packages',
39+
command: `turbo ${args.join(' ')}`,
40+
cwd,
41+
env: { TURBO_UI: '0', ...process.env },
42+
};
3843

39-
child.on('close', code => {
40-
if (code !== 0) {
41-
reject();
42-
return;
43-
}
44-
resolve();
45-
});
46-
});
44+
if (js) {
45+
//@ts-expect-error The TypeScript types for the ESM version of concurrently are wrong. https://github.com/open-cli-tools/concurrently/issues/494
46+
const { result } = concurrently([clerkJsCommand], { prefixColors: 'auto' });
47+
return result;
4748
}
4849

50+
/** @type {import('concurrently').ConcurrentlyCommandInput[]} */
51+
const commands = [packagesCommand];
4952
if (typeof js === 'undefined') {
50-
// On macOS, we spawn a new Terminal.app instance containing the watcher for clerk-js. This is because clerk-js is
51-
// not declared as a dependency for any other packages, so Turborepo is unable to automatically start it.
52-
if (process.platform === 'darwin') {
53-
spawn('osascript', [
54-
'-e',
55-
`tell app "Terminal" to do script "cd ${cwd} && turbo run dev --filter=@clerk/clerk-js -- --env devOrigin=http://localhost:4000"`,
56-
]);
57-
}
53+
commands.push(clerkJsCommand);
5854
}
5955

60-
return new Promise((resolve, reject) => {
61-
const child = spawn('turbo', args, {
62-
cwd,
63-
stdio: 'inherit',
64-
env: {
65-
...process.env,
66-
},
67-
});
68-
69-
child.on('close', code => {
70-
if (code !== 0) {
71-
reject();
72-
return;
73-
}
74-
resolve();
75-
});
76-
});
56+
//@ts-expect-error The TypeScript types for the ESM version of concurrently are wrong. https://github.com/open-cli-tools/concurrently/issues/494
57+
const { result } = concurrently(commands, { prefixColors: 'auto' });
58+
return result;
7759
}

0 commit comments

Comments
 (0)