@somewhatabstract/x 0.0.1 β 0.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 +104 -1
- package/dist/x.mjs +278 -3
- package/package.json +17 -4
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.github/codeql/codeql-config.yml +0 -5
- package/.github/workflows/codeql-analysis.yml +0 -71
- package/.github/workflows/nodejs.yml +0 -131
- package/.github/workflows/release.yml +0 -98
- package/CODE_OF_CONDUCT.md +0 -76
- package/CONTRIBUTING.md +0 -70
- package/src/__tests__/x-impl.test.ts +0 -15
- package/src/bin/x.ts +0 -3
- package/src/x-impl.ts +0 -5
- package/tsconfig-types.json +0 -7
- package/tsconfig.json +0 -29
- package/tsdown.config.ts +0 -24
- package/vitest.config.ts +0 -9
package/README.md
CHANGED
|
@@ -1,2 +1,105 @@
|
|
|
1
1
|
# x
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Execute any bin defined by any package within a monorepo without needing to install that package at the root.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`x` is a tool for monorepos that allows you to execute binary scripts from any package in your workspace without installing them globally or in your current package. It automatically discovers all packages in your workspace and finds the matching bin script.
|
|
8
|
+
|
|
9
|
+
**Supports multiple package managers:**
|
|
10
|
+
|
|
11
|
+
- π¦ npm workspaces
|
|
12
|
+
- π§Ά Yarn (classic and modern)
|
|
13
|
+
- π pnpm workspaces
|
|
14
|
+
- π― Lerna
|
|
15
|
+
- π Bun workspaces
|
|
16
|
+
- π Rush
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @somewhatabstract/x
|
|
22
|
+
# or
|
|
23
|
+
pnpm add -g @somewhatabstract/x
|
|
24
|
+
# or
|
|
25
|
+
yarn global add @somewhatabstract/x
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Execute a bin script from any package in the workspace
|
|
32
|
+
x <script-name> [-- <args...>]
|
|
33
|
+
|
|
34
|
+
# Preview what would be executed (dry-run mode)
|
|
35
|
+
x --dry-run <script-name>
|
|
36
|
+
|
|
37
|
+
# Pass arguments to the script (use `--` when args might look like x's own options)
|
|
38
|
+
x my-script -- --flag value
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This only executes bin scripts defined by packages in your workspace, not their dependencies. The bin must be an executable file with a shebang (on Unix-like systems) or a directly runnable file (on Windows), or a JS script that can be executed with Node.js.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- π **Automatic Discovery**: Finds all packages in your monorepo workspace
|
|
46
|
+
- π― **Smart Matching**: Locates the bin script you want to run
|
|
47
|
+
- π **No Installation Needed**: Execute bins without installing packages
|
|
48
|
+
- ποΈ **Dry-Run Mode**: Preview what would be executed with `--dry-run`
|
|
49
|
+
- π§ **Multi-Language Support**: Works with any executable script (Node.js, Bash, Python, etc.)
|
|
50
|
+
- π¦ **Multi-Package-Manager**: Works with npm, Yarn, pnpm, Lerna, Bun, and Rush
|
|
51
|
+
- β‘ **Fast**: Efficient package discovery using @manypkg
|
|
52
|
+
- π‘οΈ **Type-Safe**: Written in TypeScript with full type safety
|
|
53
|
+
|
|
54
|
+
## How It Works
|
|
55
|
+
|
|
56
|
+
1. **Workspace Detection**: Uses `@manypkg/find-root` to find the workspace root (supports npm, Yarn, pnpm, Lerna, Bun, Rush)
|
|
57
|
+
2. **Package Discovery**: Uses `@manypkg/get-packages` to discover all packages in the workspace
|
|
58
|
+
3. **Bin Matching**: Searches through package.json files to find bins matching your requested script name
|
|
59
|
+
4. **Execution**: Executes the matched script either directly via the OS or via Node.js:
|
|
60
|
+
- **Direct OS execution**: On Unix-like systems this requires an executable file with a shebang; on Windows the bin must be a directly runnable file such as a `.exe`, `.cmd`, or `.bat`.
|
|
61
|
+
- **Node.js execution**: If the bin is a JS file, it is executed with Node.js.
|
|
62
|
+
|
|
63
|
+
## Requirements
|
|
64
|
+
|
|
65
|
+
- Node.js >= 20
|
|
66
|
+
- A monorepo workspace (npm, Yarn, pnpm, Lerna, Bun, or Rush)
|
|
67
|
+
|
|
68
|
+
## CLI Options
|
|
69
|
+
|
|
70
|
+
- `<script-name>` - Name of the bin script to execute (required)
|
|
71
|
+
- `[args...]` - Arguments to pass to the script (optional)
|
|
72
|
+
- `-d, --dry-run` - Show what would be executed without running it
|
|
73
|
+
- `-h, --help` - Show help
|
|
74
|
+
- `-v, --version` - Show version
|
|
75
|
+
|
|
76
|
+
## Error Handling
|
|
77
|
+
|
|
78
|
+
The tool provides clear, user-friendly error messages:
|
|
79
|
+
|
|
80
|
+
- **Not in a workspace**: "Could not find workspace root. Make sure you're in a monorepo workspace."
|
|
81
|
+
- **Script not found**: "No bin script named '<name>' found in any workspace package."
|
|
82
|
+
- **Ambiguous match**: Lists all packages that provide the bin and asks you to be more specific
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Install dependencies
|
|
88
|
+
pnpm install
|
|
89
|
+
|
|
90
|
+
# Run tests
|
|
91
|
+
pnpm test
|
|
92
|
+
|
|
93
|
+
# Type check
|
|
94
|
+
pnpm typecheck
|
|
95
|
+
|
|
96
|
+
# Build
|
|
97
|
+
pnpm build
|
|
98
|
+
|
|
99
|
+
# Run locally
|
|
100
|
+
./dist/x.mjs <script-name>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT
|
package/dist/x.mjs
CHANGED
|
@@ -1,12 +1,287 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
import { hideBin } from "yargs/helpers";
|
|
4
|
+
import { getPackages } from "@manypkg/get-packages";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import * as fs from "node:fs/promises";
|
|
7
|
+
import * as path$1 from "node:path";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { findRoot } from "@manypkg/find-root";
|
|
10
|
+
|
|
11
|
+
//#region src/errors.ts
|
|
12
|
+
/**
|
|
13
|
+
* Error class for known/expected errors that should be displayed to the user
|
|
14
|
+
* without a stack trace.
|
|
15
|
+
*/
|
|
16
|
+
var HandledError = class extends Error {
|
|
17
|
+
constructor(message, options) {
|
|
18
|
+
super(message, options);
|
|
19
|
+
this.name = "HandledError";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/discover-packages.ts
|
|
25
|
+
/**
|
|
26
|
+
* Discover all packages in the workspace using @manypkg/get-packages.
|
|
27
|
+
* Supports multiple package managers: npm, yarn, pnpm, lerna, bun, rush.
|
|
28
|
+
*
|
|
29
|
+
* @param workspaceRoot - The absolute path to the workspace root
|
|
30
|
+
* @returns Array of package information
|
|
31
|
+
* @throws {HandledError} If package discovery fails
|
|
32
|
+
*/
|
|
33
|
+
async function discoverPackages(workspaceRoot) {
|
|
34
|
+
try {
|
|
35
|
+
return (await getPackages(workspaceRoot)).packages.map((pkg) => ({
|
|
36
|
+
name: pkg.packageJson.name,
|
|
37
|
+
path: pkg.dir,
|
|
38
|
+
version: pkg.packageJson.version || "unknown"
|
|
39
|
+
}));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof HandledError) throw error;
|
|
42
|
+
throw new HandledError(`Failed to discover packages`, { cause: error });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/build-environment.ts
|
|
48
|
+
/**
|
|
49
|
+
* Build environment variables for script execution that mimics npm/pnpm behavior.
|
|
50
|
+
* The environment is set as if the package were installed at the workspace root.
|
|
51
|
+
*
|
|
52
|
+
* @param workspaceRoot - Path to the workspace root
|
|
53
|
+
* @param currentEnv - Current environment variables (usually process.env)
|
|
54
|
+
* @returns Environment object to pass to child_process.spawn
|
|
55
|
+
*/
|
|
56
|
+
async function buildEnvironment(workspaceRoot, currentEnv) {
|
|
57
|
+
let workspacePackageJson = {};
|
|
58
|
+
try {
|
|
59
|
+
const packageJsonPath = path$1.join(workspaceRoot, "package.json");
|
|
60
|
+
const content = await fs.readFile(packageJsonPath, "utf-8");
|
|
61
|
+
workspacePackageJson = JSON.parse(content);
|
|
62
|
+
} catch {}
|
|
63
|
+
let ourPackageVersion = "0.0.0-development";
|
|
64
|
+
try {
|
|
65
|
+
const ownPackageJsonPath = path$1.join(__dirname, "..", "package.json");
|
|
66
|
+
const ownPackageJsonContent = await fs.readFile(ownPackageJsonPath, "utf-8");
|
|
67
|
+
const ownPackageJson = JSON.parse(ownPackageJsonContent);
|
|
68
|
+
if (typeof ownPackageJson.version === "string") ourPackageVersion = ownPackageJson.version;
|
|
69
|
+
} catch {}
|
|
70
|
+
const env = {
|
|
71
|
+
...currentEnv,
|
|
72
|
+
PATH: [path$1.join(workspaceRoot, "node_modules", ".bin"), currentEnv.PATH].filter(Boolean).join(path$1.delimiter),
|
|
73
|
+
npm_command: "exec",
|
|
74
|
+
npm_execpath: process.execPath,
|
|
75
|
+
npm_node_execpath: process.execPath,
|
|
76
|
+
NODE: process.execPath,
|
|
77
|
+
INIT_CWD: process.cwd(),
|
|
78
|
+
npm_config_user_agent: `x/${ourPackageVersion} node/${process.version} ${process.platform} ${process.arch}`
|
|
79
|
+
};
|
|
80
|
+
if (workspacePackageJson.name) env.npm_package_name = workspacePackageJson.name;
|
|
81
|
+
if (workspacePackageJson.version) env.npm_package_version = workspacePackageJson.version;
|
|
82
|
+
if (workspacePackageJson.description) env.npm_package_description = workspacePackageJson.description;
|
|
83
|
+
for (const field of [
|
|
84
|
+
"author",
|
|
85
|
+
"license",
|
|
86
|
+
"homepage",
|
|
87
|
+
"repository",
|
|
88
|
+
"bugs",
|
|
89
|
+
"keywords"
|
|
90
|
+
]) if (workspacePackageJson[field]) {
|
|
91
|
+
const value = workspacePackageJson[field];
|
|
92
|
+
env[`npm_package_${field}`] = typeof value === "string" ? value : JSON.stringify(value);
|
|
93
|
+
}
|
|
94
|
+
return env;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/is-node-executable.ts
|
|
99
|
+
/**
|
|
100
|
+
* Determine if a bin file should be invoked via the Node executable,
|
|
101
|
+
* based on its file extension (case-insensitive).
|
|
102
|
+
* Matches npm's behavior for .js, .mjs, and .cjs files.
|
|
103
|
+
*
|
|
104
|
+
* @param binPath - The path to the bin file
|
|
105
|
+
* @returns True if the file should be invoked via node
|
|
106
|
+
*/
|
|
107
|
+
function isNodeExecutable(binPath) {
|
|
108
|
+
const lower = binPath.toLowerCase();
|
|
109
|
+
return lower.endsWith(".js") || lower.endsWith(".mjs") || lower.endsWith(".cjs");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/execute-script.ts
|
|
114
|
+
/**
|
|
115
|
+
* Execute a bin script with the given arguments.
|
|
116
|
+
* Executes the script as if the package were installed at the workspace root,
|
|
117
|
+
* with npm/pnpm-style environment variables.
|
|
118
|
+
*
|
|
119
|
+
* @param bin - The bin info to execute
|
|
120
|
+
* @param args - Arguments to pass to the script
|
|
121
|
+
* @param workspaceRoot - Path to the workspace root
|
|
122
|
+
* @returns A promise that resolves with the exit code
|
|
123
|
+
*/
|
|
124
|
+
async function executeScript(bin, args, workspaceRoot) {
|
|
125
|
+
const env = await buildEnvironment(workspaceRoot, process.env);
|
|
126
|
+
const [executable, spawnArgs] = isNodeExecutable(bin.binPath) ? [process.execPath, [bin.binPath, ...args]] : [bin.binPath, args];
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
const child = spawn(executable, spawnArgs, {
|
|
129
|
+
stdio: "inherit",
|
|
130
|
+
env
|
|
131
|
+
});
|
|
132
|
+
child.on("error", (_) => {
|
|
133
|
+
resolve(1);
|
|
134
|
+
});
|
|
135
|
+
child.on("exit", (code, signal) => {
|
|
136
|
+
if (signal) resolve(1);
|
|
137
|
+
else resolve(code ?? 1);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/resolve-bin-path.ts
|
|
144
|
+
/**
|
|
145
|
+
* Resolve a bin script to the actual file path.
|
|
146
|
+
*
|
|
147
|
+
* This function ensures that the resolved bin path is within the package
|
|
148
|
+
* directory to prevent path traversal issues.
|
|
149
|
+
*
|
|
150
|
+
* @param pkg - The package information containing the path to the package
|
|
151
|
+
* @param bin - The bin entry from package.json, which can be a string or an
|
|
152
|
+
* object
|
|
153
|
+
* @param binName - The name of the bin as specified in package.json
|
|
154
|
+
* @returns The resolved absolute path to the bin script, or null if invalid
|
|
155
|
+
|
|
156
|
+
*/
|
|
157
|
+
function resolveBinPath(pkg, bin, binName) {
|
|
158
|
+
const binPath = !bin ? null : typeof bin === "string" && pkg.name === binName ? bin : typeof bin === "object" && bin[binName] ? bin[binName] : null;
|
|
159
|
+
if (!binPath) return null;
|
|
160
|
+
const packageDir = path.resolve(pkg.path);
|
|
161
|
+
const resolvedBinPath = path.resolve(pkg.path, binPath);
|
|
162
|
+
if (resolvedBinPath !== packageDir && !resolvedBinPath.startsWith(packageDir + path.sep)) return null;
|
|
163
|
+
return resolvedBinPath;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/find-matching-bins.ts
|
|
168
|
+
/**
|
|
169
|
+
* Find all packages that have a bin script matching the given name.
|
|
170
|
+
*
|
|
171
|
+
* @param packages - List of packages from discoverPackages
|
|
172
|
+
* @param binName - Name of the bin script to find
|
|
173
|
+
* @returns Array of matching bin information
|
|
174
|
+
*/
|
|
175
|
+
async function findMatchingBins(packages, binName) {
|
|
176
|
+
const matches = [];
|
|
177
|
+
for (const pkg of packages) try {
|
|
178
|
+
const packageJsonPath = path$1.join(pkg.path, "package.json");
|
|
179
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, "utf-8");
|
|
180
|
+
const bin = JSON.parse(packageJsonContent).bin;
|
|
181
|
+
const resolvedBinPath = resolveBinPath(pkg, bin, binName);
|
|
182
|
+
if (!resolvedBinPath) continue;
|
|
183
|
+
matches.push({
|
|
184
|
+
packageName: pkg.name,
|
|
185
|
+
packagePath: pkg.path,
|
|
186
|
+
binName,
|
|
187
|
+
binPath: resolvedBinPath
|
|
188
|
+
});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof SyntaxError) console.warn(`Warning: Failed to parse package.json for package "${pkg.name}" at "${pkg.path}": invalid JSON.`);
|
|
191
|
+
else if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {} else console.warn(`Warning: Could not read package.json for package "${pkg.name}" at "${pkg.path}":`, error);
|
|
192
|
+
}
|
|
193
|
+
return matches;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/find-workspace-root.ts
|
|
198
|
+
/**
|
|
199
|
+
* Find the workspace root using @manypkg/find-root.
|
|
200
|
+
* Supports multiple package managers: npm, yarn, pnpm, lerna, bun, rush.
|
|
201
|
+
*
|
|
202
|
+
* @param startDir - Directory to start searching from (defaults to cwd)
|
|
203
|
+
* @returns The absolute path to the workspace root
|
|
204
|
+
* @throws {HandledError} If workspace root cannot be found
|
|
205
|
+
*/
|
|
206
|
+
async function findWorkspaceRoot(startDir = process.cwd()) {
|
|
207
|
+
try {
|
|
208
|
+
return (await findRoot(startDir)).rootDir;
|
|
209
|
+
} catch (error) {
|
|
210
|
+
throw new HandledError("Could not find workspace root. Make sure you're in a monorepo workspace.", { cause: error });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
2
215
|
//#region src/x-impl.ts
|
|
3
|
-
|
|
4
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Main implementation of the x command.
|
|
218
|
+
* Finds and executes a bin script from any package in the workspace.
|
|
219
|
+
*
|
|
220
|
+
* @param scriptName - Name of the bin script to execute
|
|
221
|
+
* @param args - Arguments to pass to the script
|
|
222
|
+
* @param options - Additional options
|
|
223
|
+
* @returns Result object with exit code
|
|
224
|
+
*/
|
|
225
|
+
async function xImpl(scriptName, args = [], options = {}) {
|
|
226
|
+
try {
|
|
227
|
+
if (!scriptName || !scriptName.trim()) throw new HandledError("Script name cannot be empty");
|
|
228
|
+
if (scriptName.includes("/") || scriptName.includes("\\")) throw new HandledError("Script name cannot contain path separators");
|
|
229
|
+
const workspaceRoot = await findWorkspaceRoot();
|
|
230
|
+
const packages = await discoverPackages(workspaceRoot);
|
|
231
|
+
if (packages.length === 0) throw new HandledError("No packages found in workspace. Is this a valid monorepo?");
|
|
232
|
+
const matchingBins = await findMatchingBins(packages, scriptName);
|
|
233
|
+
if (matchingBins.length === 0) throw new HandledError(`No bin script named "${scriptName}" found in any workspace package.`);
|
|
234
|
+
if (matchingBins.length > 1) {
|
|
235
|
+
console.error(`Multiple packages provide bin "${scriptName}". Please be more specific.`);
|
|
236
|
+
console.error("\nMatching packages:");
|
|
237
|
+
matchingBins.forEach((bin) => {
|
|
238
|
+
console.error(` - ${bin.packageName} (${bin.packagePath})`);
|
|
239
|
+
});
|
|
240
|
+
throw new HandledError(`Ambiguous bin name "${scriptName}". Found ${matchingBins.length} matches.`);
|
|
241
|
+
}
|
|
242
|
+
const bin = matchingBins[0];
|
|
243
|
+
if (options.dryRun) {
|
|
244
|
+
console.log(`Would execute: ${bin.binName} from ${bin.packageName}`);
|
|
245
|
+
console.log(` Binary: ${bin.binPath}`);
|
|
246
|
+
console.log(` Arguments: ${args.join(" ")}`);
|
|
247
|
+
return { exitCode: 0 };
|
|
248
|
+
}
|
|
249
|
+
return { exitCode: await executeScript(bin, args, workspaceRoot) };
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (error instanceof HandledError) {
|
|
252
|
+
console.error(`Error: ${error.message}`);
|
|
253
|
+
return { exitCode: 1 };
|
|
254
|
+
}
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
5
257
|
}
|
|
6
258
|
|
|
7
259
|
//#endregion
|
|
8
260
|
//#region src/bin/x.ts
|
|
9
|
-
|
|
261
|
+
const argv = yargs(hideBin(process.argv)).usage("Usage: $0 <script-name> [...args]").command("$0 <script-name> [args..]", "Execute a bin script from any package in the workspace", (yargs) => {
|
|
262
|
+
return yargs.positional("script-name", {
|
|
263
|
+
describe: "Name of the bin script to execute",
|
|
264
|
+
type: "string",
|
|
265
|
+
demandOption: true
|
|
266
|
+
}).positional("args", {
|
|
267
|
+
describe: "Arguments to pass to the script",
|
|
268
|
+
type: "string",
|
|
269
|
+
array: true,
|
|
270
|
+
default: []
|
|
271
|
+
});
|
|
272
|
+
}).option("dry-run", {
|
|
273
|
+
alias: "d",
|
|
274
|
+
describe: "Show what would be executed without running it",
|
|
275
|
+
type: "boolean",
|
|
276
|
+
default: false
|
|
277
|
+
}).help().alias("help", "h").version().alias("version", "v").example("$0 tsc --noEmit", "Run TypeScript compiler from any package").example("$0 eslint src/", "Run ESLint from any package that provides it").example("$0 --dry-run jest", "Preview which jest would be executed").strict().parseSync();
|
|
278
|
+
const scriptName = argv["script-name"];
|
|
279
|
+
xImpl(scriptName, argv._ || [], { dryRun: argv["dry-run"] }).then((result) => {
|
|
280
|
+
process.exit(result.exitCode);
|
|
281
|
+
}).catch((error) => {
|
|
282
|
+
console.error("Unexpected error:", error);
|
|
283
|
+
process.exit(1);
|
|
284
|
+
});
|
|
10
285
|
|
|
11
286
|
//#endregion
|
|
12
287
|
export { };
|
package/package.json
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
"name": "@somewhatabstract/x",
|
|
3
3
|
"private": false,
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
6
7
|
},
|
|
7
8
|
"bin": {
|
|
8
9
|
"x": "./dist/x.mjs"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"version": "0.1.1",
|
|
11
16
|
"description": "Execute any bin defined by any package in a monorepo without needing to install that package",
|
|
12
17
|
"bugs": {
|
|
13
18
|
"url": "https://github.com/somewhatabstract/x/issues"
|
|
@@ -22,18 +27,26 @@
|
|
|
22
27
|
"yarn": "please-use-pnpm"
|
|
23
28
|
},
|
|
24
29
|
"devDependencies": {
|
|
30
|
+
"@biomejs/biome": "^2.4.3",
|
|
25
31
|
"@changesets/cli": "^2.29.8",
|
|
26
32
|
"@codecov/rollup-plugin": "^1.9.1",
|
|
27
33
|
"@types/node": "^20.19.29",
|
|
34
|
+
"@types/yargs": "^17.0.35",
|
|
28
35
|
"@vitest/coverage-v8": "^4.0.17",
|
|
29
|
-
"tsdown": "0.20.
|
|
36
|
+
"tsdown": "0.20.3",
|
|
30
37
|
"typescript": "^5.9.3",
|
|
31
38
|
"vitest": "^4.0.17"
|
|
32
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@manypkg/find-root": "^3.1.0",
|
|
42
|
+
"@manypkg/get-packages": "^3.1.0",
|
|
43
|
+
"yargs": "^18.0.0"
|
|
44
|
+
},
|
|
33
45
|
"scripts": {
|
|
34
46
|
"build": "tsdown",
|
|
35
47
|
"dev": "tsdown --watch",
|
|
36
|
-
"lint": "
|
|
48
|
+
"lint": "biome check",
|
|
49
|
+
"lint:fix": "biome check --write --unsafe",
|
|
37
50
|
"typecheck": "tsc --noEmit --project tsconfig.json",
|
|
38
51
|
"typewatch": "pnpm typecheck --watch",
|
|
39
52
|
"test": "vitest",
|
package/.changeset/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Changesets
|
|
2
|
-
|
|
3
|
-
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
-
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
-
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
-
|
|
7
|
-
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
-
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
|
3
|
-
"changelog": "@changesets/cli/changelog",
|
|
4
|
-
"commit": false,
|
|
5
|
-
"fixed": [],
|
|
6
|
-
"linked": [],
|
|
7
|
-
"access": "restricted",
|
|
8
|
-
"baseBranch": "main",
|
|
9
|
-
"updateInternalDependencies": "patch",
|
|
10
|
-
"ignore": []
|
|
11
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
-
# to commit it to your repository.
|
|
3
|
-
#
|
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
-
# or to provide custom queries or build logic.
|
|
6
|
-
#
|
|
7
|
-
# ******** NOTE ********
|
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
-
# supported CodeQL languages.
|
|
11
|
-
#
|
|
12
|
-
name: "CodeQL"
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
push:
|
|
16
|
-
branches: [ main ]
|
|
17
|
-
pull_request:
|
|
18
|
-
# The branches below must be a subset of the branches above
|
|
19
|
-
branches: [ main ]
|
|
20
|
-
schedule:
|
|
21
|
-
- cron: '16 7 * * 2'
|
|
22
|
-
|
|
23
|
-
jobs:
|
|
24
|
-
analyze:
|
|
25
|
-
name: Analyze
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
permissions:
|
|
28
|
-
actions: read
|
|
29
|
-
contents: read
|
|
30
|
-
security-events: write
|
|
31
|
-
|
|
32
|
-
strategy:
|
|
33
|
-
fail-fast: false
|
|
34
|
-
matrix:
|
|
35
|
-
language: [ 'javascript' ]
|
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
|
37
|
-
# Learn more:
|
|
38
|
-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
|
39
|
-
|
|
40
|
-
steps:
|
|
41
|
-
- name: Checkout repository
|
|
42
|
-
uses: actions/checkout@v5
|
|
43
|
-
|
|
44
|
-
# Initializes the CodeQL tools for scanning.
|
|
45
|
-
- name: Initialize CodeQL
|
|
46
|
-
uses: github/codeql-action/init@v4
|
|
47
|
-
with:
|
|
48
|
-
languages: ${{ matrix.language }}
|
|
49
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
50
|
-
# By default, queries listed here will override any specified in a config file.
|
|
51
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
52
|
-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
53
|
-
|
|
54
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
55
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
|
56
|
-
- name: Autobuild
|
|
57
|
-
uses: github/codeql-action/autobuild@v4
|
|
58
|
-
|
|
59
|
-
# βΉοΈ Command-line programs to run using the OS shell.
|
|
60
|
-
# π https://git.io/JvXDl
|
|
61
|
-
|
|
62
|
-
# βοΈ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
63
|
-
# and modify them (or add more) to build your code if your project
|
|
64
|
-
# uses a compiled language
|
|
65
|
-
|
|
66
|
-
#- run: |
|
|
67
|
-
# make bootstrap
|
|
68
|
-
# make release
|
|
69
|
-
|
|
70
|
-
- name: Perform CodeQL Analysis
|
|
71
|
-
uses: github/codeql-action/analyze@v4
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
name: Node CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
# ready_for_review is useful for when a PR is converted from "draft" to "not
|
|
6
|
-
# draft".
|
|
7
|
-
types: [edited, opened, synchronize, ready_for_review, reopened]
|
|
8
|
-
|
|
9
|
-
push:
|
|
10
|
-
branches:
|
|
11
|
-
- main
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
lint:
|
|
15
|
-
name: Lint and static types check
|
|
16
|
-
env:
|
|
17
|
-
CI: true
|
|
18
|
-
runs-on: ${{ matrix.os }}
|
|
19
|
-
strategy:
|
|
20
|
-
matrix:
|
|
21
|
-
os: [ubuntu-latest]
|
|
22
|
-
node-version: [20.x]
|
|
23
|
-
steps:
|
|
24
|
-
- uses: actions/checkout@v4
|
|
25
|
-
|
|
26
|
-
- uses: pnpm/action-setup@v4
|
|
27
|
-
name: Install pnpm
|
|
28
|
-
with:
|
|
29
|
-
run_install: false
|
|
30
|
-
package_json_file: 'package.json'
|
|
31
|
-
|
|
32
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
33
|
-
uses: actions/setup-node@v4
|
|
34
|
-
with:
|
|
35
|
-
node-version: ${{ matrix.node-version }}
|
|
36
|
-
cache: 'pnpm'
|
|
37
|
-
cache-dependency-path: 'pnpm-lock.yaml'
|
|
38
|
-
|
|
39
|
-
- name: Install Dependencies
|
|
40
|
-
shell: bash
|
|
41
|
-
run: pnpm install --frozen-lockfile
|
|
42
|
-
|
|
43
|
-
- name: Lint
|
|
44
|
-
run: pnpm lint
|
|
45
|
-
|
|
46
|
-
- name: Static Types
|
|
47
|
-
run: pnpm typecheck
|
|
48
|
-
|
|
49
|
-
- name: Changesets check
|
|
50
|
-
uses: Khan/actions@check-for-changeset-v1
|
|
51
|
-
if: |
|
|
52
|
-
github.actor != 'dependabot[bot]' &&
|
|
53
|
-
github.actor != 'dependabot-preview[bot]' &&
|
|
54
|
-
github.event_name == 'pull_request'
|
|
55
|
-
with:
|
|
56
|
-
exclude: .github/,.storybook/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
coverage:
|
|
60
|
-
name: Update test coverage
|
|
61
|
-
env:
|
|
62
|
-
CI: true
|
|
63
|
-
runs-on: ${{ matrix.os }}
|
|
64
|
-
strategy:
|
|
65
|
-
matrix:
|
|
66
|
-
os: [ubuntu-latest]
|
|
67
|
-
node-version: [20.x]
|
|
68
|
-
steps:
|
|
69
|
-
- uses: actions/checkout@v4
|
|
70
|
-
|
|
71
|
-
- uses: pnpm/action-setup@v4
|
|
72
|
-
name: Install pnpm
|
|
73
|
-
with:
|
|
74
|
-
run_install: false
|
|
75
|
-
package_json_file: 'package.json'
|
|
76
|
-
|
|
77
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
78
|
-
uses: actions/setup-node@v4
|
|
79
|
-
with:
|
|
80
|
-
node-version: ${{ matrix.node-version }}
|
|
81
|
-
cache: 'pnpm'
|
|
82
|
-
cache-dependency-path: 'pnpm-lock.yaml'
|
|
83
|
-
|
|
84
|
-
- name: Install Dependencies
|
|
85
|
-
shell: bash
|
|
86
|
-
run: pnpm install --frozen-lockfile
|
|
87
|
-
|
|
88
|
-
- name: Run tests with coverage
|
|
89
|
-
run: pnpm coverage
|
|
90
|
-
- name: Upload coverage
|
|
91
|
-
uses: codecov/codecov-action@v5
|
|
92
|
-
env:
|
|
93
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
build:
|
|
97
|
-
needs: [coverage, lint]
|
|
98
|
-
name: Build
|
|
99
|
-
env:
|
|
100
|
-
CI: true
|
|
101
|
-
runs-on: ${{ matrix.os }}
|
|
102
|
-
strategy:
|
|
103
|
-
matrix:
|
|
104
|
-
os: [ubuntu-latest]
|
|
105
|
-
node-version: [20.x]
|
|
106
|
-
steps:
|
|
107
|
-
- uses: actions/checkout@v4
|
|
108
|
-
|
|
109
|
-
- uses: pnpm/action-setup@v4
|
|
110
|
-
name: Install pnpm
|
|
111
|
-
with:
|
|
112
|
-
run_install: false
|
|
113
|
-
package_json_file: 'package.json'
|
|
114
|
-
|
|
115
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
116
|
-
uses: actions/setup-node@v4
|
|
117
|
-
with:
|
|
118
|
-
node-version: ${{ matrix.node-version }}
|
|
119
|
-
cache: 'pnpm'
|
|
120
|
-
cache-dependency-path: 'pnpm-lock.yaml'
|
|
121
|
-
|
|
122
|
-
- name: Install Dependencies
|
|
123
|
-
shell: bash
|
|
124
|
-
run: pnpm install --frozen-lockfile
|
|
125
|
-
|
|
126
|
-
- name: Run build
|
|
127
|
-
env:
|
|
128
|
-
# We only want to upload bundle analysis for a PR once,
|
|
129
|
-
# so we only provide a token for the ubuntu-latest job.
|
|
130
|
-
CODECOV_TOKEN: ${{ matrix.os == 'ubuntu-latest' && secrets.CODECOV_TOKEN || '' }}
|
|
131
|
-
run: pnpm build
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
# This workflow will run changesets depending on two different scenarios:
|
|
9
|
-
#
|
|
10
|
-
# 1. If we are landing a specific commit into main (Author PR), then
|
|
11
|
-
# changesets will check if there are changes verifying the Markdown files
|
|
12
|
-
# generated automatically:
|
|
13
|
-
#
|
|
14
|
-
# a) There are new versions and there's NO Release PR, then the changesets
|
|
15
|
-
# action will create a new Release PR.
|
|
16
|
-
#
|
|
17
|
-
# b) There's a Release PR, then the changesets action will update the
|
|
18
|
-
# existing Release PR with the new commit.
|
|
19
|
-
#
|
|
20
|
-
# NOTE: (in both cases, changesets will modify the new version in
|
|
21
|
-
# package.json for each package, and will remove the MD files as part of the
|
|
22
|
-
# Release PR).
|
|
23
|
-
#
|
|
24
|
-
# 2. If we are landing the Release PR into main, then the changesets action
|
|
25
|
-
# will publish the changes to npm.
|
|
26
|
-
#
|
|
27
|
-
# For more info about this workflow, see:
|
|
28
|
-
# https://github.com/changesets/action#usage
|
|
29
|
-
jobs:
|
|
30
|
-
release:
|
|
31
|
-
name: Release
|
|
32
|
-
runs-on: ubuntu-latest
|
|
33
|
-
permissions:
|
|
34
|
-
id-token: write # For provenance and trusted publishing
|
|
35
|
-
contents: write # For creating release PRs
|
|
36
|
-
pull-requests: write # For creating release PRs
|
|
37
|
-
steps:
|
|
38
|
-
- uses: actions/checkout@v5
|
|
39
|
-
with:
|
|
40
|
-
fetch-depth: 0
|
|
41
|
-
persist-credentials: false
|
|
42
|
-
|
|
43
|
-
- uses: pnpm/action-setup@v4
|
|
44
|
-
name: Install pnpm
|
|
45
|
-
with:
|
|
46
|
-
run_install: false
|
|
47
|
-
package_json_file: package.json
|
|
48
|
-
|
|
49
|
-
- name: Use Node.js 20.x
|
|
50
|
-
uses: actions/setup-node@v6
|
|
51
|
-
with:
|
|
52
|
-
node-version: 20.x
|
|
53
|
-
cache: pnpm
|
|
54
|
-
cache-dependency-path: pnpm-lock.yaml
|
|
55
|
-
|
|
56
|
-
- name: Install Dependencies
|
|
57
|
-
shell: bash
|
|
58
|
-
run: pnpm install --frozen-lockfile
|
|
59
|
-
|
|
60
|
-
- name: β¬οΈ Upgrade npm for OIDC support
|
|
61
|
-
shell: bash
|
|
62
|
-
run: |
|
|
63
|
-
# npm trusted publishing requires npm CLI v11.5.1+
|
|
64
|
-
# Node.js 20 shipped with npm 9.x, so we likely need to upgrade
|
|
65
|
-
|
|
66
|
-
# First, let's check the current npm version, and if it's already
|
|
67
|
-
# sufficient, we can skip the upgrade step.
|
|
68
|
-
CURRENT_NPM_VERSION=$(npm --version)
|
|
69
|
-
REQUIRED_NPM_VERSION="11.5.1"
|
|
70
|
-
|
|
71
|
-
# This sorts the version numbers using `sort -V` and then takes
|
|
72
|
-
# the lowest version.
|
|
73
|
-
LOWEST_NPM_VERSION=$(printf '%s\n' "$REQUIRED_NPM_VERSION" "$CURRENT_NPM_VERSION" | sort -V | head -n1)
|
|
74
|
-
|
|
75
|
-
# If the lowest version is the same as the required version, then we
|
|
76
|
-
# don't need to upgrade as that means our current version is newer.
|
|
77
|
-
if [ "$LOWEST_NPM_VERSION" = "$REQUIRED_NPM_VERSION" ]; then
|
|
78
|
-
echo "β
npm is already at version $CURRENT_NPM_VERSION"
|
|
79
|
-
else
|
|
80
|
-
npm install -g npm@latest && echo "β
npm upgraded to $(npm --version)"
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
- name: Create Release Pull Request or Publish to npm
|
|
84
|
-
id: changesets
|
|
85
|
-
uses: changesets/action@v1
|
|
86
|
-
with:
|
|
87
|
-
publish: pnpm publish:ci
|
|
88
|
-
env:
|
|
89
|
-
# We use a Personal Access Token here rather than the GITHUB_TOKEN
|
|
90
|
-
# so that it will trigger our other actions. The token has to be on
|
|
91
|
-
# the account of someone with appropriate access levels and given the
|
|
92
|
-
# repo scope.
|
|
93
|
-
GITHUB_TOKEN: ${{ secrets.BOT_PA_TOKEN }}
|
|
94
|
-
# This is the token used to publish to npm when OIDC trusted
|
|
95
|
-
# publishing isn't yet setup
|
|
96
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
97
|
-
# This is used for the bundle analysis
|
|
98
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
-
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
-
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project e-mail
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at jeff[at]somewhatabstract[dot]com. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
-
|
|
73
|
-
[homepage]: https://www.contributor-covenant.org
|
|
74
|
-
|
|
75
|
-
For answers to common questions about this code of conduct, see
|
|
76
|
-
https://www.contributor-covenant.org/faq
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Contributing to `x`
|
|
2
|
-
|
|
3
|
-
πThank you for your interest in contributing to this π¦.
|
|
4
|
-
|
|
5
|
-
Whether raising an issue, reviewing a pull request, or implementing a change, the participation of others is a wonderful π. Read on to find out how you can get involved.
|
|
6
|
-
|
|
7
|
-
π Be sure to read our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
8
|
-
|
|
9
|
-
## π Bugs And Feature Requests
|
|
10
|
-
|
|
11
|
-
If you find a bug or want to make enhancements to the project, head on over to the [πIssues](https://github.com/somewhatabstract/x/issues) section and raise an issue. The issue templates will guide you in providing details that will help others help you.
|
|
12
|
-
|
|
13
|
-
## π» Code Changes
|
|
14
|
-
|
|
15
|
-
### β΅ Making your first change
|
|
16
|
-
|
|
17
|
-
Look for bugs or feature requests with the [good first issue](https://github.com/somewhatabstract/x/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) or [help wanted](https://github.com/somewhatabstract/x/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+) labels and have a go at implementing a change. Once your change is ready, you can submit a pull request.
|
|
18
|
-
|
|
19
|
-
### π¬ Getting Started
|
|
20
|
-
|
|
21
|
-
To work in the `x` repository, follow these steps:
|
|
22
|
-
|
|
23
|
-
1. Clone the repository
|
|
24
|
-
- `gh repo clone somewhatabstract/x`
|
|
25
|
-
- -or-
|
|
26
|
-
- `git clone git@github.com:somewhatabstract/x.git`
|
|
27
|
-
2. Install `pnpm`
|
|
28
|
-
- `corepack enable pnpm`
|
|
29
|
-
- `corepack prepare pnpm --activate`
|
|
30
|
-
3. Run `pnpm install` to install the dependencies
|
|
31
|
-
|
|
32
|
-
You can now work on `x`. We prefer [πVisual Studio Code](https://code.visualstudio.com/) as our development environment (it's cross-platform and awesome), but please use what you feel comfortable with (we'll even forgive you for using vim).
|
|
33
|
-
|
|
34
|
-
### π§ͺ Code Quality
|
|
35
|
-
|
|
36
|
-
#### Manual
|
|
37
|
-
|
|
38
|
-
We love code reviews. If there are open pull requests, please feel free to review them and provide feedback. Feedback is a gift and code reviews are often a bottleneck in getting new things released. Jump in, even if you don't know anything; you probably know more than you think.
|
|
39
|
-
|
|
40
|
-
π**REMEMBER** Be kind and considerate. Folks are volunteering their time and code reviews are a moment of vulnerability where a criticism of the code can easily become a criticism of the individual that wrote it.
|
|
41
|
-
|
|
42
|
-
1. Take your time
|
|
43
|
-
2. Consider how you might receive the feedback you are giving if it were attached to code you wrote
|
|
44
|
-
3. Favor asking questions over prescribing solutions.
|
|
45
|
-
|
|
46
|
-
#### Automated
|
|
47
|
-
|
|
48
|
-
To ensure code quality, we use TypeScript, biome, and vitest. These are all executed when you submit a pull request to ensure contributions meet our code quality standards.
|
|
49
|
-
|
|
50
|
-
To execute these operations outside of a pull request, you can use `pnpm`.
|
|
51
|
-
|
|
52
|
-
- `pnpm typecheck`
|
|
53
|
-
- `pnpm lint`
|
|
54
|
-
- `pnpm test`
|
|
55
|
-
|
|
56
|
-
If you make changes that change snapshots, you may need to run tests with the `-u` vitest option and commit the updated snapshot files along with the rest of your contribution.
|
|
57
|
-
|
|
58
|
-
π**REMEMBER** If you would like to contribute code changes to the project, first make sure there's a corresponding issue for the change you wish to make.
|
|
59
|
-
|
|
60
|
-
## π¦ Build And Publish
|
|
61
|
-
|
|
62
|
-
Anyone can create a local build of the distributed code by running `pnpm build`.
|
|
63
|
-
|
|
64
|
-
Running the build will execute tests first.
|
|
65
|
-
|
|
66
|
-
### Publishing
|
|
67
|
-
|
|
68
|
-
Publishing is automated through our use of [changesets][1]. When a PR is merged, a release PR is created that bundles all the changes since the last release. This PR is then merged and the changeset is published to npm.
|
|
69
|
-
|
|
70
|
-
[1]:https://github.com/changesets/changesets/blob/main/README.md#documentation
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it, vi} from "vitest";
|
|
2
|
-
import { xImpl } from "../x-impl";
|
|
3
|
-
|
|
4
|
-
describe("xImpl", () => {
|
|
5
|
-
it("should log 'Hello, world!'", () => {
|
|
6
|
-
// Arrange
|
|
7
|
-
const consoleSpy = vi.spyOn(console, "log");
|
|
8
|
-
|
|
9
|
-
// Act
|
|
10
|
-
xImpl();
|
|
11
|
-
|
|
12
|
-
// Assert
|
|
13
|
-
expect(consoleSpy).toHaveBeenCalledWith("Hello, world!");
|
|
14
|
-
});
|
|
15
|
-
});
|
package/src/bin/x.ts
DELETED
package/src/x-impl.ts
DELETED
package/tsconfig-types.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"lib": [
|
|
5
|
-
"es2023"
|
|
6
|
-
],
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
"module": "preserve",
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"types": [
|
|
12
|
-
"node"
|
|
13
|
-
],
|
|
14
|
-
"typeRoots": [
|
|
15
|
-
"./node_modules/@types"
|
|
16
|
-
],
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"emitDeclarationOnly": true,
|
|
21
|
-
"esModuleInterop": true,
|
|
22
|
-
"isolatedModules": true,
|
|
23
|
-
"verbatimModuleSyntax": true,
|
|
24
|
-
"skipLibCheck": true
|
|
25
|
-
},
|
|
26
|
-
"include": [
|
|
27
|
-
"src"
|
|
28
|
-
]
|
|
29
|
-
}
|
package/tsdown.config.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {codecovRollupPlugin} from "@codecov/rollup-plugin";
|
|
2
|
-
import {defineConfig} from "tsdown";
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
entry: ["./src/bin/x.ts"],
|
|
6
|
-
platform: "node",
|
|
7
|
-
sourcemap: false,
|
|
8
|
-
dts: {
|
|
9
|
-
oxc: true,
|
|
10
|
-
tsconfig: "tsconfig-types.json"
|
|
11
|
-
},
|
|
12
|
-
plugins: [
|
|
13
|
-
process.env.CODECOV_TOKEN
|
|
14
|
-
? // This plugin provides bundle analysis from codecov, but does
|
|
15
|
-
// not work locally without additional config, and it does not
|
|
16
|
-
// output size info to the console.
|
|
17
|
-
codecovRollupPlugin({
|
|
18
|
-
enableBundleAnalysis: true, // true when CODECOV_TOKEN set
|
|
19
|
-
bundleName: "x",
|
|
20
|
-
uploadToken: process.env.CODECOV_TOKEN,
|
|
21
|
-
})
|
|
22
|
-
: undefined,
|
|
23
|
-
],
|
|
24
|
-
});
|