Skip to content

feat(dev-cli): Remove macOS-specific Terminal functionality #3859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-points-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/dev-cli": patch
---

Remove macOS-specific Terminal functionality
19 changes: 4 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions packages/dev-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,7 @@ clerk-dev watch

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

> [!NOTE]
> 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:
>
> ```sh
> clerk-dev watch --js
> ```

If you do not want to spawn the watcher for `@clerk/clerk-js`, you can instead pass `--no-js`.
If you do not want to start the watcher for `@clerk/clerk-js`, you can instead pass `--no-js`.

```sh
clerk-dev watch --no-js
Expand Down
1 change: 1 addition & 0 deletions packages/dev-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"commander": "^12.1.0",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"globby": "^14.0.2",
"jscodeshift": "^0.16.1"
Expand Down
74 changes: 28 additions & 46 deletions packages/dev-cli/src/commands/watch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spawn } from 'node:child_process';
import { join } from 'node:path';

import concurrently from 'concurrently';

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

const cwd = await getMonorepoRoot();

if (js) {
return new Promise((resolve, reject) => {
const child = spawn(
'turbo',
['run', 'dev', '--filter=@clerk/clerk-js', '--', '--env', 'devOrigin=http://localhost:4000'],
{
cwd,
stdio: 'inherit',
env: { ...process.env },
},
);
/** @type {import('concurrently').ConcurrentlyCommandInput} */
const clerkJsCommand = {
name: 'clerk-js',
command: 'turbo run dev --filter=@clerk/clerk-js -- --env devOrigin=http://localhost:4000',
cwd,
env: { TURBO_UI: '0', ...process.env },
};

/** @type {import('concurrently').ConcurrentlyCommandInput} */
const packagesCommand = {
name: 'packages',
command: `turbo ${args.join(' ')}`,
cwd,
env: { TURBO_UI: '0', ...process.env },
};

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apple script is wild 🪄

commands.push(clerkJsCommand);
}

return new Promise((resolve, reject) => {
const child = spawn('turbo', args, {
cwd,
stdio: 'inherit',
env: {
...process.env,
},
});

child.on('close', code => {
if (code !== 0) {
reject();
return;
}
resolve();
});
});
//@ts-expect-error The TypeScript types for the ESM version of concurrently are wrong. https://github.com/open-cli-tools/concurrently/issues/494
const { result } = concurrently(commands, { prefixColors: 'auto' });
return result;
}
Loading