@clerk/dev-cli 0.0.4 → 0.0.5-canary.v35fb0c7

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 CHANGED
@@ -74,14 +74,7 @@ clerk-dev watch
74
74
 
75
75
  This will run the `build` task for any `@clerk/*` packages in the `package.json` of the current working directory, including any of their dependencies.
76
76
 
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`.
85
78
 
86
79
  ```sh
87
80
  clerk-dev watch --no-js
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clerk/dev-cli",
3
3
  "description": "CLI tool designed to simplify the process of iterating on packages within the clerk/javascript repository",
4
- "version": "0.0.4",
4
+ "version": "0.0.5-canary.v35fb0c7",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "author": "Clerk",
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "commander": "^12.1.0",
29
+ "concurrently": "^8.2.2",
29
30
  "dotenv": "^16.4.5",
30
31
  "globby": "^14.0.2",
31
32
  "jscodeshift": "^0.16.1"
@@ -1,6 +1,7 @@
1
- import { spawn } from 'node:child_process';
2
1
  import { join } from 'node:path';
3
2
 
3
+ import concurrently from 'concurrently';
4
+
4
5
  import { getClerkPackages } from '../utils/getClerkPackages.js';
5
6
  import { getDependencies } from '../utils/getDependencies.js';
6
7
  import { getMonorepoRoot } from '../utils/getMonorepoRoot.js';
@@ -9,7 +10,7 @@ import { getMonorepoRoot } from '../utils/getMonorepoRoot.js';
9
10
  * Starts long-running watchers for Clerk dependencies.
10
11
  * @param {object} args
11
12
  * @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[]>}
13
14
  */
14
15
  export async function watch({ js }) {
15
16
  const { dependencies, devDependencies } = await getDependencies(join(process.cwd(), 'package.json'));
@@ -24,54 +25,35 @@ export async function watch({ js }) {
24
25
 
25
26
  const cwd = await getMonorepoRoot();
26
27
 
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
+ };
38
43
 
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;
47
48
  }
48
49
 
50
+ /** @type {import('concurrently').ConcurrentlyCommandInput[]} */
51
+ const commands = [packagesCommand];
49
52
  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);
58
54
  }
59
55
 
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;
77
59
  }