@somewhatabstract/x 0.1.0 → 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.
Files changed (39) hide show
  1. package/README.md +9 -37
  2. package/package.json +4 -1
  3. package/.changeset/README.md +0 -8
  4. package/.changeset/config.json +0 -11
  5. package/.github/codeql/codeql-config.yml +0 -5
  6. package/.github/dependabot.yml +0 -28
  7. package/.github/workflows/codeql-analysis.yml +0 -71
  8. package/.github/workflows/dependabot-pr-approval.yml +0 -36
  9. package/.github/workflows/nodejs.yml +0 -129
  10. package/.github/workflows/release.yml +0 -95
  11. package/.vscode/settings.json +0 -19
  12. package/CHANGELOG.md +0 -23
  13. package/CODE_OF_CONDUCT.md +0 -76
  14. package/CONTRIBUTING.md +0 -70
  15. package/biome.json +0 -39
  16. package/src/__tests__/build-environment.test.ts +0 -285
  17. package/src/__tests__/discover-packages.test.ts +0 -196
  18. package/src/__tests__/errors.test.ts +0 -59
  19. package/src/__tests__/execute-script.test.ts +0 -1042
  20. package/src/__tests__/find-matching-bins.test.ts +0 -506
  21. package/src/__tests__/find-workspace-root.test.ts +0 -73
  22. package/src/__tests__/is-node-executable.test.ts +0 -125
  23. package/src/__tests__/resolve-bin-path.test.ts +0 -344
  24. package/src/__tests__/x-impl.test.ts +0 -314
  25. package/src/__tests__/x.test.ts +0 -236
  26. package/src/bin/x.ts +0 -57
  27. package/src/build-environment.ts +0 -98
  28. package/src/discover-packages.ts +0 -35
  29. package/src/errors.ts +0 -10
  30. package/src/execute-script.ts +0 -56
  31. package/src/find-matching-bins.ts +0 -72
  32. package/src/find-workspace-root.ts +0 -24
  33. package/src/is-node-executable.ts +0 -16
  34. package/src/resolve-bin-path.ts +0 -48
  35. package/src/x-impl.ts +0 -96
  36. package/tsconfig-types.json +0 -5
  37. package/tsconfig.json +0 -21
  38. package/tsdown.config.ts +0 -24
  39. 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
- });