diff --git a/.changeset/old-points-raise.md b/.changeset/old-points-raise.md new file mode 100644 index 00000000000..9ca6d2e2a48 --- /dev/null +++ b/.changeset/old-points-raise.md @@ -0,0 +1,5 @@ +--- +"@clerk/dev-cli": patch +--- + +Remove macOS-specific Terminal functionality diff --git a/package-lock.json b/package-lock.json index eafdc1a6318..b024d8ef5f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22530,8 +22530,8 @@ }, "node_modules/concurrently": { "version": "8.2.2", - "dev": true, - "license": "MIT", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", + "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", "dependencies": { "chalk": "^4.1.2", "date-fns": "^2.30.0", @@ -22556,7 +22556,6 @@ }, "node_modules/concurrently/node_modules/ansi-styles": { "version": "4.3.0", - "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -22570,7 +22569,6 @@ }, "node_modules/concurrently/node_modules/chalk": { "version": "4.1.2", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", @@ -22585,7 +22583,6 @@ }, "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { "version": "7.2.0", - "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -22596,7 +22593,6 @@ }, "node_modules/concurrently/node_modules/color-convert": { "version": "2.0.1", - "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -22607,12 +22603,10 @@ }, "node_modules/concurrently/node_modules/color-name": { "version": "1.1.4", - "dev": true, "license": "MIT" }, "node_modules/concurrently/node_modules/has-flag": { "version": "4.0.0", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -22620,7 +22614,6 @@ }, "node_modules/concurrently/node_modules/rxjs": { "version": "7.8.1", - "dev": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" @@ -22628,7 +22621,6 @@ }, "node_modules/concurrently/node_modules/supports-color": { "version": "8.1.1", - "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -24100,7 +24092,6 @@ }, "node_modules/date-fns": { "version": "2.30.0", - "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.21.0" @@ -44301,7 +44292,6 @@ }, "node_modules/shell-quote": { "version": "1.8.1", - "devOptional": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -44880,8 +44870,7 @@ } }, "node_modules/spawn-command": { - "version": "0.0.2", - "dev": true + "version": "0.0.2" }, "node_modules/spawndamnit": { "version": "2.0.0", @@ -46630,7 +46619,6 @@ }, "node_modules/tree-kill": { "version": "1.2.2", - "dev": true, "license": "MIT", "bin": { "tree-kill": "cli.js" @@ -51402,6 +51390,7 @@ "license": "MIT", "dependencies": { "commander": "^12.1.0", + "concurrently": "^8.2.2", "dotenv": "^16.4.5", "globby": "^14.0.2", "jscodeshift": "^0.16.1" diff --git a/packages/dev-cli/README.md b/packages/dev-cli/README.md index 66ca1af6807..0807be9224b 100644 --- a/packages/dev-cli/README.md +++ b/packages/dev-cli/README.md @@ -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 diff --git a/packages/dev-cli/package.json b/packages/dev-cli/package.json index 20065f0f7f7..313c5045b93 100644 --- a/packages/dev-cli/package.json +++ b/packages/dev-cli/package.json @@ -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" diff --git a/packages/dev-cli/src/commands/watch.js b/packages/dev-cli/src/commands/watch.js index e5db7ef89fa..88fa03fbab3 100644 --- a/packages/dev-cli/src/commands/watch.js +++ b/packages/dev-cli/src/commands/watch.js @@ -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'; @@ -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} + * @returns {Promise} */ export async function watch({ js }) { const { dependencies, devDependencies } = await getDependencies(join(process.cwd(), 'package.json')); @@ -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"`, - ]); - } + 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; }