bun-workspaces 1.0.2 → 1.1.1

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
@@ -10,7 +10,7 @@ A CLI and API to enhance your monorepo development with Bun's [native workspaces
10
10
 
11
11
  - Works right away, with no boilerplate required 🍔🍴
12
12
  - Get metadata about your monorepo 🤖
13
- - Run package.json scripts across workspaces 📋
13
+ - Orchestrate your workspaces' `package.json` scripts 📋
14
14
  - Run inline [Bun Shell](https://bun.com/docs/runtime/shell) scripts in workspaces 🐚
15
15
 
16
16
  This is a tool to help manage a Bun monorepo, offering features beyond what [Bun's --filter feature](https://bun.com/docs/pm/filter) can do. It can be used to get a variety of metadata about your project and run scripts across your workspaces with advanced control.
@@ -84,12 +84,13 @@ bw run "bun build" --inline # Run an inline command via the Bun shell
84
84
  bw run lint --parallel=false # Run in series
85
85
  bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
86
86
  bw run lint --parallel=auto # Default, based on number of available logical CPUs
87
+ bw run lint --parallel=50% # Run in parallel with a max of 50% of the "auto" limit
87
88
 
88
89
  # Use the grouped output style (default when on a TTY)
89
90
  bw run my-script --output-style=grouped
90
91
 
91
92
  # Set the max preview lines for script output in grouped output style
92
- bw run my-script --output-style=grouped --grouped-lines=all
93
+ bw run my-script --output-style=grouped --grouped-lines=auto
93
94
  bw run my-script --output-style=grouped --grouped-lines=10
94
95
 
95
96
  # Use simple script output with workspace prefixes (default when not on a TTY)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-workspaces",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "A monorepo management tool for Bun, with a CLI and API to enhance Bun's native workspaces.",
5
5
  "license": "MIT",
6
6
  "main": "src/index.mjs",
@@ -14,6 +14,7 @@ export type GlobalCommandContext = {
14
14
  middleware: CliMiddleware;
15
15
  outputWriters: Required<WriteOutputOptions>;
16
16
  terminalWidth: number;
17
+ terminalHeight: number;
17
18
  };
18
19
  export type ProjectCommandContext = GlobalCommandContext & {
19
20
  project: FileSystemProject;
@@ -26,7 +26,6 @@ export type CliProjectCommandName = Exclude<
26
26
  CliGlobalCommandName
27
27
  >;
28
28
  export declare const JSON_FLAGS: readonly ["-j", "--json"];
29
- export declare const DEFAULT_GROUPED_LINES = 20;
30
29
  export declare const CLI_COMMANDS_CONFIG: {
31
30
  readonly doctor: {
32
31
  readonly command: "doctor";
@@ -153,7 +152,7 @@ export declare const CLI_COMMANDS_CONFIG: {
153
152
  };
154
153
  readonly groupedLines: {
155
154
  readonly flags: ["-L", "--grouped-lines <count>"];
156
- readonly description: 'With "grouped" output, the max preview lines (number or "all", default 20)';
155
+ readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
157
156
  };
158
157
  readonly noPrefix: {
159
158
  readonly flags: ["-N", "--no-prefix"];
@@ -314,7 +313,7 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
314
313
  };
315
314
  readonly groupedLines: {
316
315
  readonly flags: ["-L", "--grouped-lines <count>"];
317
- readonly description: 'With "grouped" output, the max preview lines (number or "all", default 20)';
316
+ readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
318
317
  };
319
318
  readonly noPrefix: {
320
319
  readonly flags: ["-N", "--no-prefix"];
@@ -4,7 +4,6 @@ import { OUTPUT_STYLE_VALUES } from "./runScript/output/outputStyle.mjs"; // CON
4
4
  // CONCATENATED MODULE: ./src/cli/commands/commandsConfig.ts
5
5
 
6
6
  const JSON_FLAGS = ["-j", "--json"];
7
- const DEFAULT_GROUPED_LINES = 20;
8
7
  const CLI_COMMANDS_CONFIG = {
9
8
  doctor: {
10
9
  command: "doctor",
@@ -133,7 +132,7 @@ const CLI_COMMANDS_CONFIG = {
133
132
  },
134
133
  groupedLines: {
135
134
  flags: ["-L", "--grouped-lines <count>"],
136
- description: `With "grouped" output, the max preview lines (number or "all", default ${DEFAULT_GROUPED_LINES})`,
135
+ description: `With grouped output, the max preview lines (number or "auto", default "auto")`,
137
136
  },
138
137
  noPrefix: {
139
138
  flags: ["-N", "--no-prefix"],
@@ -176,7 +175,6 @@ const getCliCommandNames = () => Object.keys(CLI_COMMANDS_CONFIG);
176
175
 
177
176
  export {
178
177
  CLI_COMMANDS_CONFIG,
179
- DEFAULT_GROUPED_LINES,
180
178
  JSON_FLAGS,
181
179
  getCliCommandConfig,
182
180
  getCliCommandNames,
@@ -1,11 +1,11 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { expandHomePath } from "../../../internal/core/index.mjs";
3
4
  import { logger } from "../../../internal/logger/index.mjs";
4
5
  import {
5
6
  handleProjectCommand,
6
7
  splitWorkspacePatterns,
7
8
  } from "../commandHandlerUtils.mjs";
8
- import { DEFAULT_GROUPED_LINES } from "../commandsConfig.mjs";
9
9
  import {
10
10
  getDefaultOutputStyle,
11
11
  validateOutputStyle,
@@ -17,9 +17,9 @@ import {
17
17
  } from "./output/renderGroupedOutput.mjs";
18
18
  import { renderPlainOutput } from "./output/renderPlainOutput.mjs"; // CONCATENATED MODULE: external "fs"
19
19
  // CONCATENATED MODULE: external "path"
20
+ // CONCATENATED MODULE: external "../../../internal/core/index.mjs"
20
21
  // CONCATENATED MODULE: external "../../../internal/logger/index.mjs"
21
22
  // CONCATENATED MODULE: external "../commandHandlerUtils.mjs"
22
- // CONCATENATED MODULE: external "../commandsConfig.mjs"
23
23
  // CONCATENATED MODULE: external "./output/outputStyle.mjs"
24
24
  // CONCATENATED MODULE: external "./output/renderGroupedOutput.mjs"
25
25
  // CONCATENATED MODULE: external "./output/renderPlainOutput.mjs"
@@ -28,7 +28,13 @@ import { renderPlainOutput } from "./output/renderPlainOutput.mjs"; // CONCATENA
28
28
  const runScript = handleProjectCommand(
29
29
  "runScript",
30
30
  async (
31
- { project, postTerminatorArgs, outputWriters, terminalWidth },
31
+ {
32
+ project,
33
+ postTerminatorArgs,
34
+ outputWriters,
35
+ terminalWidth,
36
+ terminalHeight,
37
+ },
32
38
  positionalScript,
33
39
  positionalWorkspacePatterns,
34
40
  options,
@@ -114,10 +120,12 @@ const runScript = handleProjectCommand(
114
120
  logger.debug(`Script name: ${scriptName}`);
115
121
  const stripDisruptiveControls = workspaces.length > 1 || !!options.parallel;
116
122
  logger.debug(`Strip disruptive controls: ${stripDisruptiveControls}`);
117
- let groupedLines = DEFAULT_GROUPED_LINES;
123
+ let groupedLines = "auto";
118
124
  if (options.groupedLines) {
119
125
  if (options.groupedLines === "all") {
120
126
  groupedLines = "all";
127
+ } else if (options.groupedLines === "auto") {
128
+ groupedLines = "auto";
121
129
  } else {
122
130
  const parsedGroupedLines = parseInt(options.groupedLines);
123
131
  if (parsedGroupedLines <= 0 || isNaN(parsedGroupedLines)) {
@@ -148,6 +156,7 @@ const runScript = handleProjectCommand(
148
156
  groupedLines,
149
157
  outputWriters,
150
158
  terminalWidth,
159
+ terminalHeight,
151
160
  ),
152
161
  prefixed: () =>
153
162
  renderPlainOutput(output, outputWriters, {
@@ -196,7 +205,7 @@ const runScript = handleProjectCommand(
196
205
  if (options.jsonOutfile) {
197
206
  const fullOutputPath = path.resolve(
198
207
  project.rootDirectory,
199
- options.jsonOutfile,
208
+ expandHomePath(options.jsonOutfile),
200
209
  );
201
210
  // Check if can make directory
202
211
  const jsonOutputDir = path.dirname(fullOutputPath);
@@ -67,8 +67,9 @@ export declare const renderGroupedOutput: (
67
67
  output: RunScriptAcrossWorkspacesOutput,
68
68
  summary: Promise<RunScriptsSummary<RunWorkspaceScriptMetadata>>,
69
69
  scriptEventTarget: ScriptEventTarget,
70
- activeScriptLines: number | "all",
70
+ activeScriptLines: number | "all" | "auto",
71
71
  outputWriters: Required<WriteOutputOptions>,
72
72
  terminalWidth: number,
73
+ terminalHeight: number,
73
74
  ) => Promise<void>;
74
75
  export {};
@@ -55,7 +55,7 @@ const textOps = {
55
55
  };
56
56
  const STATUS_COLORS = {
57
57
  pending: "gray",
58
- running: "intenseCyan",
58
+ running: "intenseMagenta",
59
59
  skipped: "gray",
60
60
  success: "intenseGreen",
61
61
  failure: "intenseRed",
@@ -63,7 +63,8 @@ const STATUS_COLORS = {
63
63
  cancelled: "gray",
64
64
  killed: "intenseRed",
65
65
  };
66
- const BORDER_COLOR = "blue";
66
+ const BORDER_COLOR = "intenseCyan";
67
+ const HEADER_ROWS_PER_WORKSPACE = 2;
67
68
  const renderGroupedOutput = async (
68
69
  workspaces,
69
70
  output,
@@ -72,6 +73,7 @@ const renderGroupedOutput = async (
72
73
  activeScriptLines,
73
74
  outputWriters,
74
75
  terminalWidth,
76
+ terminalHeight,
75
77
  ) => {
76
78
  const workspaceState = workspaces.reduce((acc, workspace) => {
77
79
  acc[workspace.name] = {
@@ -112,7 +114,26 @@ const renderGroupedOutput = async (
112
114
  if (isFinal) {
113
115
  didFinalRender = true;
114
116
  }
115
- const width = Math.max(2, terminalWidth || process.stdout.columns);
117
+ const width = Math.max(2, terminalWidth || process.stdout.columns || 2);
118
+ const height = Math.max(1, terminalHeight || process.stdout.rows || 1);
119
+ // Compute the max script lines to show per workspace based on terminal
120
+ // height, so the live TUI never exceeds the visible viewport (cursor up
121
+ // is clamped and cannot recover from overflow). Each workspace occupies
122
+ // HEADER_ROWS_PER_WORKSPACE rows plus one row for the hidden-lines
123
+ // indicator, with one additional safety row to prevent scroll on the
124
+ // final newline. The user's activeScriptLines acts as a ceiling if lower.
125
+ const availableRows = Math.max(
126
+ 1,
127
+ height - 1 - workspaces.length * (HEADER_ROWS_PER_WORKSPACE + 1),
128
+ );
129
+ const computedScriptLines = Math.max(
130
+ 1,
131
+ Math.floor(availableRows / workspaces.length),
132
+ );
133
+ const effectiveScriptLines =
134
+ activeScriptLines === "all" || activeScriptLines === "auto"
135
+ ? computedScriptLines
136
+ : Math.min(activeScriptLines, computedScriptLines);
116
137
  const linesToWrite = [];
117
138
  const workspaceBoxContents = {};
118
139
  workspaces.forEach((workspace) => {
@@ -134,69 +155,51 @@ const renderGroupedOutput = async (
134
155
  } else if (exitState === "signal") {
135
156
  statusText += ` (signal: ${state.signal})`;
136
157
  }
137
- const workspaceLine = "Workspace: " + textOps.bold(workspace.name);
158
+ const workspaceLine =
159
+ textOps[BORDER_COLOR]("Workspace: ") + textOps.bold(workspace.name);
138
160
  const statusLine =
139
- " Status: " + textOps[STATUS_COLORS[state.status]](statusText);
161
+ textOps[BORDER_COLOR](" Status: ") +
162
+ textOps[STATUS_COLORS[state.status]](statusText);
140
163
  workspaceBoxContents[workspace.name] = {
141
164
  name: workspaceLine,
142
165
  status: statusLine,
143
166
  };
144
167
  });
145
168
  const padding = 4; // left border, spaces, right border
146
- const workspaceBoxWidth = Math.min(
147
- width,
148
- Math.max(
149
- ...Object.values(workspaceBoxContents).map((content) =>
150
- Math.max(
151
- calculateVisibleLength(content.name),
152
- calculateVisibleLength(content.status),
153
- ),
154
- ),
155
- ) + padding,
156
- );
157
169
  workspaces.forEach((workspace) => {
158
170
  const state = workspaceState[workspace.name];
159
171
  const { name: workspaceNameContent, status: statusTextContent } =
160
172
  workspaceBoxContents[workspace.name];
161
- linesToWrite.push({
162
- text: textOps[BORDER_COLOR](
163
- "┌" + "─".repeat(workspaceBoxWidth - 2) + "┐",
164
- ),
165
- type: "border",
166
- });
167
- const borderText = (text) => {
173
+ const borderText = (text, top, headerWidth) => {
168
174
  const visibleLength = calculateVisibleLength(text);
169
175
  const truncated =
170
176
  visibleLength > width - padding
171
177
  ? truncateTerminalString(text, width - padding - 1) + "\x1b[0m…"
172
178
  : text;
173
179
  return (
174
- textOps[BORDER_COLOR](" ") +
180
+ textOps[BORDER_COLOR](top ? " " : "└ ") +
175
181
  truncated +
176
- " ".repeat(Math.max(0, workspaceBoxWidth - visibleLength - padding)) +
177
- textOps[BORDER_COLOR](" ")
182
+ " ".repeat(Math.max(0, headerWidth - visibleLength - padding)) +
183
+ textOps[BORDER_COLOR](top ? " " : " ┘")
178
184
  );
179
185
  };
186
+ const headerWidth = Math.min(
187
+ width,
188
+ Math.max(
189
+ Bun.stripANSI(workspaceNameContent).length,
190
+ Bun.stripANSI(statusTextContent).length,
191
+ ) + padding,
192
+ );
180
193
  linesToWrite.push({
181
- text: borderText(workspaceNameContent),
194
+ text: borderText(workspaceNameContent, true, headerWidth),
182
195
  type: "borderedContent",
183
196
  });
184
197
  linesToWrite.push({
185
- text: borderText(statusTextContent),
198
+ text: borderText(statusTextContent, false, headerWidth),
186
199
  type: "borderedContent",
187
200
  });
188
- linesToWrite.push({
189
- text: textOps[BORDER_COLOR](
190
- "└" + "─".repeat(workspaceBoxWidth - 2) + "┘",
191
- ),
192
- type: "border",
193
- });
194
- if (
195
- activeScriptLines !== "all" &&
196
- state.lines.length > activeScriptLines &&
197
- !isFinal
198
- ) {
199
- const hiddenLines = state.lines.length - activeScriptLines;
201
+ if (state.lines.length > effectiveScriptLines && !isFinal) {
202
+ const hiddenLines = state.lines.length - effectiveScriptLines;
200
203
  linesToWrite.push({
201
204
  text: textOps.gray(
202
205
  `(${hiddenLines} line${hiddenLines === 1 ? "" : "s"} hidden until exit)`,
@@ -206,7 +209,7 @@ const renderGroupedOutput = async (
206
209
  }
207
210
  linesToWrite.push(
208
211
  ...state.lines
209
- .slice(isFinal ? undefined : -activeScriptLines)
212
+ .slice(isFinal ? undefined : -effectiveScriptLines)
210
213
  .map((line) => ({
211
214
  text: line.text,
212
215
  type: "scriptOutput",
@@ -214,6 +217,12 @@ const renderGroupedOutput = async (
214
217
  );
215
218
  return linesToWrite;
216
219
  });
220
+ if (isFinal) {
221
+ linesToWrite.push({
222
+ text: textOps[BORDER_COLOR]("─ Summary ─"),
223
+ type: "borderedContent",
224
+ });
225
+ }
217
226
  if (previousHeight > 0) {
218
227
  // clear previous frame
219
228
  outputWriters.stdout(cursorOps.up(previousHeight));
@@ -10,6 +10,7 @@ export interface RunCliOptions {
10
10
  middleware?: CliMiddlewareOptions;
11
11
  writeOutput?: WriteOutputOptions;
12
12
  terminalWidth?: number;
13
+ terminalHeight?: number;
13
14
  }
14
15
  export interface CLI {
15
16
  run: (options?: RunCliOptions) => Promise<void>;
@@ -30,6 +30,7 @@ const createCli = ({ defaultCwd = process.cwd(), defaultMiddleware } = {}) => {
30
30
  middleware: _runMiddleware,
31
31
  writeOutput,
32
32
  terminalWidth = process.stdout.columns,
33
+ terminalHeight = process.stdout.rows,
33
34
  } = {}) => {
34
35
  const middleware = resolveMiddleware(
35
36
  defaultMiddleware ?? {},
@@ -93,7 +94,6 @@ const createCli = ({ defaultCwd = process.cwd(), defaultMiddleware } = {}) => {
93
94
  const { project, projectError } = initializeWithGlobalOptions(
94
95
  program,
95
96
  args,
96
- defaultCwd,
97
97
  middleware,
98
98
  );
99
99
  middleware.findProject({
@@ -113,6 +113,7 @@ const createCli = ({ defaultCwd = process.cwd(), defaultMiddleware } = {}) => {
113
113
  middleware,
114
114
  outputWriters,
115
115
  terminalWidth,
116
+ terminalHeight,
116
117
  });
117
118
  defineGlobalCommands({
118
119
  program,
@@ -120,6 +121,7 @@ const createCli = ({ defaultCwd = process.cwd(), defaultMiddleware } = {}) => {
120
121
  middleware,
121
122
  outputWriters,
122
123
  terminalWidth,
124
+ terminalHeight,
123
125
  });
124
126
  logger.debug(`Commands initialized. Parsing args...`);
125
127
  middleware.preParse({
@@ -3,7 +3,6 @@ import type { CliMiddleware } from "../middleware";
3
3
  export declare const initializeWithGlobalOptions: (
4
4
  program: Command,
5
5
  args: string[],
6
- defaultCwd: string,
7
6
  middleware: CliMiddleware,
8
7
  ) => {
9
8
  project: import("../../internal/core").Simplify<{
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { Option } from "commander";
4
- import { defineErrors } from "../../internal/core/index.mjs";
4
+ import { defineErrors, expandHomePath } from "../../internal/core/index.mjs";
5
5
  import { logger } from "../../internal/logger/index.mjs";
6
6
  import {
7
7
  createFileSystemProject,
@@ -19,6 +19,8 @@ import { getCliGlobalOptionConfig } from "./globalOptionsConfig.mjs"; // CONCATE
19
19
  const ERRORS = defineErrors(
20
20
  "WorkingDirectoryNotFound",
21
21
  "WorkingDirectoryNotADirectory",
22
+ "NoCwdAndWorkspaceRoot",
23
+ "ProjectRootNotFound",
22
24
  );
23
25
  const addGlobalOption = (program, optionName, defaultOverride) => {
24
26
  const { mainOption, shortOption, description, param, values, defaultValue } =
@@ -42,13 +44,55 @@ const addGlobalOption = (program, optionName, defaultOverride) => {
42
44
  );
43
45
  }
44
46
  };
45
- const getWorkingDirectoryFromArgs = (program, args, defaultCwd) => {
46
- addGlobalOption(program, "cwd", defaultCwd);
47
+ const getWorkingDirectoryFromArgs = (program, args) => {
48
+ addGlobalOption(program, "cwd");
49
+ addGlobalOption(program, "workspaceRoot");
47
50
  program.parseOptions(args);
48
- return program.opts().cwd;
51
+ const { cwd, workspaceRoot } = program.opts();
52
+ if (cwd && workspaceRoot) {
53
+ throw new ERRORS.NoCwdAndWorkspaceRoot(
54
+ `Cannot use both ${getCliGlobalOptionConfig("cwd").mainOption} (${getCliGlobalOptionConfig("cwd").shortOption}) and ${getCliGlobalOptionConfig("workspaceRoot").mainOption} (${getCliGlobalOptionConfig("workspaceRoot").shortOption}) options together`,
55
+ );
56
+ }
57
+ return {
58
+ cwdOption: cwd,
59
+ workspaceRootOption: workspaceRoot,
60
+ };
49
61
  };
50
- const defineGlobalOptions = (program, args, defaultCwd, middleware) => {
51
- const cwd = getWorkingDirectoryFromArgs(program, args, defaultCwd);
62
+ const findRootFromCwd = () => {
63
+ let currentDirectory = process.cwd();
64
+ while (true) {
65
+ const packageJsonPath = path.join(currentDirectory, "package.json");
66
+ if (fs.existsSync(packageJsonPath)) {
67
+ try {
68
+ const packageJsonContent = JSON.parse(
69
+ fs.readFileSync(packageJsonPath, "utf8"),
70
+ );
71
+ if (packageJsonContent.workspaces) {
72
+ return currentDirectory;
73
+ }
74
+ } catch {
75
+ continue;
76
+ }
77
+ }
78
+ const parentDirectory = path.dirname(currentDirectory);
79
+ if (parentDirectory === currentDirectory) {
80
+ break;
81
+ }
82
+ currentDirectory = parentDirectory;
83
+ }
84
+ throw new ERRORS.ProjectRootNotFound(
85
+ `${getCliGlobalOptionConfig("workspaceRoot").shortOption}|${getCliGlobalOptionConfig("workspaceRoot").mainOption} option: Project root not found from current working directory "${process.cwd()}"`,
86
+ );
87
+ };
88
+ const defineGlobalOptions = (program, args, middleware) => {
89
+ const { cwdOption, workspaceRootOption } = getWorkingDirectoryFromArgs(
90
+ program,
91
+ args,
92
+ );
93
+ const cwd = expandHomePath(
94
+ cwdOption || (workspaceRootOption ? findRootFromCwd() : process.cwd()),
95
+ );
52
96
  const exists = fs.existsSync(cwd);
53
97
  const isDirectory = exists ? fs.statSync(cwd).isDirectory() : false;
54
98
  middleware.processWorkingDirectory({
@@ -98,9 +142,9 @@ const applyGlobalOptions = (options) => {
98
142
  projectError: error,
99
143
  };
100
144
  };
101
- const initializeWithGlobalOptions = (program, args, defaultCwd, middleware) => {
145
+ const initializeWithGlobalOptions = (program, args, middleware) => {
102
146
  program.allowUnknownOption(true);
103
- const { cwd } = defineGlobalOptions(program, args, defaultCwd, middleware);
147
+ const { cwd } = defineGlobalOptions(program, args, middleware);
104
148
  program.parseOptions(args);
105
149
  program.allowUnknownOption(false);
106
150
  const options = program.opts();
@@ -3,6 +3,7 @@ export interface CliGlobalOptions {
3
3
  logLevel: LogLevelSetting;
4
4
  cwd: string;
5
5
  includeRoot: boolean;
6
+ workspaceRoot: boolean;
6
7
  }
7
8
  export interface CliGlobalOptionConfig {
8
9
  mainOption: string;
@@ -28,7 +29,7 @@ export declare const getCliGlobalOptionConfig: (
28
29
  readonly mainOption: "--cwd";
29
30
  readonly shortOption: "-d";
30
31
  readonly description: "Working directory";
31
- readonly defaultValue: ".";
32
+ readonly defaultValue: "";
32
33
  readonly values: null;
33
34
  readonly param: "path";
34
35
  }
@@ -39,5 +40,13 @@ export declare const getCliGlobalOptionConfig: (
39
40
  readonly defaultValue: "";
40
41
  readonly values: null;
41
42
  readonly param: "";
43
+ }
44
+ | {
45
+ readonly mainOption: "--workspace-root";
46
+ readonly shortOption: "-w";
47
+ readonly description: "Run from the project root above the current working directory";
48
+ readonly defaultValue: "";
49
+ readonly values: null;
50
+ readonly param: "";
42
51
  };
43
52
  export declare const getCliGlobalOptionNames: () => CliGlobalOptionName[];
@@ -14,7 +14,7 @@ const CLI_GLOBAL_OPTIONS_CONFIG = {
14
14
  mainOption: "--cwd",
15
15
  shortOption: "-d",
16
16
  description: "Working directory",
17
- defaultValue: ".",
17
+ defaultValue: "",
18
18
  values: null,
19
19
  param: "path",
20
20
  },
@@ -26,6 +26,15 @@ const CLI_GLOBAL_OPTIONS_CONFIG = {
26
26
  values: null,
27
27
  param: "",
28
28
  },
29
+ workspaceRoot: {
30
+ mainOption: "--workspace-root",
31
+ shortOption: "-w",
32
+ description:
33
+ "Run from the project root above the current working directory",
34
+ defaultValue: "",
35
+ values: null,
36
+ param: "",
37
+ },
29
38
  };
30
39
  const getCliGlobalOptionConfig = (optionName) =>
31
40
  CLI_GLOBAL_OPTIONS_CONFIG[optionName];
@@ -1,4 +1,6 @@
1
1
  export declare const IS_WINDOWS: boolean;
2
2
  export declare const IS_MACOS: boolean;
3
3
  export declare const IS_LINUX: boolean;
4
- export declare const IS_UNIX: boolean;
4
+ export declare const IS_POSIX: boolean;
5
+ /** Expands a leading `~` or `~/` to the user's home directory */
6
+ export declare const expandHomePath: (filePath: string) => string;
@@ -1,7 +1,19 @@
1
+ import os from "os";
2
+ import path from "path"; // CONCATENATED MODULE: external "os"
3
+ // CONCATENATED MODULE: external "path"
1
4
  // CONCATENATED MODULE: ./src/internal/core/runtime/os.ts
5
+
2
6
  const IS_WINDOWS = process.platform === "win32";
3
7
  const IS_MACOS = process.platform === "darwin";
4
8
  const IS_LINUX = process.platform === "linux";
5
- const IS_UNIX = IS_MACOS || IS_LINUX;
9
+ const IS_POSIX = IS_MACOS || IS_LINUX;
10
+ /** Expands a leading `~` or `~/` to the user's home directory */ const expandHomePath =
11
+ (filePath) => {
12
+ if (filePath === "~") return os.homedir();
13
+ if (filePath.startsWith("~/") || filePath.startsWith("~\\")) {
14
+ return path.join(os.homedir(), filePath.slice(2));
15
+ }
16
+ return filePath;
17
+ };
6
18
 
7
- export { IS_LINUX, IS_MACOS, IS_UNIX, IS_WINDOWS };
19
+ export { IS_LINUX, IS_MACOS, IS_POSIX, IS_WINDOWS, expandHomePath };
@@ -4,6 +4,7 @@ import { loadRootConfig } from "../../config/index.mjs";
4
4
  import { getUserEnvVar } from "../../config/userEnvVars/index.mjs";
5
5
  import {
6
6
  DEFAULT_TEMP_DIR,
7
+ expandHomePath,
7
8
  isPlainObject,
8
9
  validateJSTypes,
9
10
  } from "../../internal/core/index.mjs";
@@ -76,7 +77,7 @@ class _FileSystemProject extends ProjectBase {
76
77
  }
77
78
  this.rootDirectory = path.resolve(
78
79
  process.cwd(),
79
- options.rootDirectory ?? "",
80
+ expandHomePath(options.rootDirectory ?? ""),
80
81
  );
81
82
  const rootConfig = loadRootConfig(this.rootDirectory);
82
83
  const { workspaces, workspaceMap, rootWorkspace } = findWorkspaces({