@somewhatabstract/x 0.1.0 → 0.2.0

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.
Files changed (40) hide show
  1. package/README.md +9 -37
  2. package/dist/x.mjs +13 -20
  3. package/package.json +6 -3
  4. package/.changeset/README.md +0 -8
  5. package/.changeset/config.json +0 -11
  6. package/.github/codeql/codeql-config.yml +0 -5
  7. package/.github/dependabot.yml +0 -28
  8. package/.github/workflows/codeql-analysis.yml +0 -71
  9. package/.github/workflows/dependabot-pr-approval.yml +0 -36
  10. package/.github/workflows/nodejs.yml +0 -129
  11. package/.github/workflows/release.yml +0 -95
  12. package/.vscode/settings.json +0 -19
  13. package/CHANGELOG.md +0 -23
  14. package/CODE_OF_CONDUCT.md +0 -76
  15. package/CONTRIBUTING.md +0 -70
  16. package/biome.json +0 -39
  17. package/src/__tests__/build-environment.test.ts +0 -285
  18. package/src/__tests__/discover-packages.test.ts +0 -196
  19. package/src/__tests__/errors.test.ts +0 -59
  20. package/src/__tests__/execute-script.test.ts +0 -1042
  21. package/src/__tests__/find-matching-bins.test.ts +0 -506
  22. package/src/__tests__/find-workspace-root.test.ts +0 -73
  23. package/src/__tests__/is-node-executable.test.ts +0 -125
  24. package/src/__tests__/resolve-bin-path.test.ts +0 -344
  25. package/src/__tests__/x-impl.test.ts +0 -314
  26. package/src/__tests__/x.test.ts +0 -236
  27. package/src/bin/x.ts +0 -57
  28. package/src/build-environment.ts +0 -98
  29. package/src/discover-packages.ts +0 -35
  30. package/src/errors.ts +0 -10
  31. package/src/execute-script.ts +0 -56
  32. package/src/find-matching-bins.ts +0 -72
  33. package/src/find-workspace-root.ts +0 -24
  34. package/src/is-node-executable.ts +0 -16
  35. package/src/resolve-bin-path.ts +0 -48
  36. package/src/x-impl.ts +0 -96
  37. package/tsconfig-types.json +0 -5
  38. package/tsconfig.json +0 -21
  39. package/tsdown.config.ts +0 -24
  40. package/vitest.config.ts +0 -10
package/src/x-impl.ts DELETED
@@ -1,96 +0,0 @@
1
- import {discoverPackages} from "./discover-packages";
2
- import {HandledError} from "./errors";
3
- import {executeScript} from "./execute-script";
4
- import {findMatchingBins} from "./find-matching-bins";
5
- import {findWorkspaceRoot} from "./find-workspace-root";
6
-
7
- export interface XOptions {
8
- dryRun?: boolean;
9
- }
10
-
11
- export interface XResult {
12
- exitCode: number;
13
- }
14
-
15
- /**
16
- * Main implementation of the x command.
17
- * Finds and executes a bin script from any package in the workspace.
18
- *
19
- * @param scriptName - Name of the bin script to execute
20
- * @param args - Arguments to pass to the script
21
- * @param options - Additional options
22
- * @returns Result object with exit code
23
- */
24
- export async function xImpl(
25
- scriptName: string,
26
- args: string[] = [],
27
- options: XOptions = {},
28
- ): Promise<XResult> {
29
- try {
30
- if (!scriptName || !scriptName.trim()) {
31
- throw new HandledError("Script name cannot be empty");
32
- }
33
- if (scriptName.includes("/") || scriptName.includes("\\")) {
34
- throw new HandledError(
35
- "Script name cannot contain path separators",
36
- );
37
- }
38
-
39
- // Find workspace root
40
- const workspaceRoot = await findWorkspaceRoot();
41
-
42
- // Discover all packages
43
- const packages = await discoverPackages(workspaceRoot);
44
-
45
- if (packages.length === 0) {
46
- throw new HandledError(
47
- "No packages found in workspace. Is this a valid monorepo?",
48
- );
49
- }
50
-
51
- // Find matching bins
52
- const matchingBins = await findMatchingBins(packages, scriptName);
53
-
54
- if (matchingBins.length === 0) {
55
- throw new HandledError(
56
- `No bin script named "${scriptName}" found in any workspace package.`,
57
- );
58
- }
59
-
60
- if (matchingBins.length > 1) {
61
- console.error(
62
- `Multiple packages provide bin "${scriptName}". Please be more specific.`,
63
- );
64
- console.error("\nMatching packages:");
65
- matchingBins.forEach((bin) => {
66
- console.error(` - ${bin.packageName} (${bin.packagePath})`);
67
- });
68
- throw new HandledError(
69
- `Ambiguous bin name "${scriptName}". Found ${matchingBins.length} matches.`,
70
- );
71
- }
72
-
73
- const bin = matchingBins[0];
74
-
75
- // Dry run mode - just show what would be executed
76
- if (options.dryRun) {
77
- console.log(
78
- `Would execute: ${bin.binName} from ${bin.packageName}`,
79
- );
80
- console.log(` Binary: ${bin.binPath}`);
81
- console.log(` Arguments: ${args.join(" ")}`);
82
- return {exitCode: 0};
83
- }
84
-
85
- // Execute the script
86
- const exitCode = await executeScript(bin, args, workspaceRoot);
87
-
88
- return {exitCode};
89
- } catch (error) {
90
- if (error instanceof HandledError) {
91
- console.error(`Error: ${error.message}`);
92
- return {exitCode: 1};
93
- }
94
- throw error;
95
- }
96
- }
@@ -1,5 +0,0 @@
1
- /* Visit https://aka.ms/tsconfig to read more about this file */
2
- {
3
- "extends": "./tsconfig.json",
4
- "exclude": ["**/*.test.ts"]
5
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "lib": ["es2023"],
5
- "moduleDetection": "force",
6
- "module": "preserve",
7
- "moduleResolution": "bundler",
8
- "resolveJsonModule": true,
9
- "types": ["node"],
10
- "typeRoots": ["./node_modules/@types"],
11
- "strict": true,
12
- "noUnusedLocals": true,
13
- "declaration": true,
14
- "emitDeclarationOnly": true,
15
- "esModuleInterop": true,
16
- "isolatedModules": true,
17
- "verbatimModuleSyntax": true,
18
- "skipLibCheck": true
19
- },
20
- "include": ["src"]
21
- }
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
- });
package/vitest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import {defineConfig} from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- coverage: {
6
- include: ["src/**/*.ts"],
7
- reporter: ["text", "json"],
8
- },
9
- },
10
- });