bfmatei / rectangle-pro-raycast

Control windows using Rectangle Pro from Raycast
1 stars 0 forks source link

Could not find command's executable JS file. You might need to rebuild the extension. #2

Closed bigplayer-ai closed 4 months ago

bigplayer-ai commented 4 months ago

Bug Report

Description: The executable JS file for the command is not found after building and importing the extension into Raycast after running any raycast command:

Could not find command's executable JS file. You might need to rebuild the extension.

Could not find command's executable JS file. You might need to rebuild the extension.

This other issue arises during the build process with the following error encountered:

% npm run build

> build
> run-s build:*

> build:generate
> ts-node ./generate/index.ts

/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
generate/writePackageJsonContents.ts:11:5 - error TS2578: Unused '@ts-expect-error' directive.

11     // @ts-expect-error: There is a mismatch between the types in package.json and the types in the script. Nothing to worry about to be honest
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    at createTSError (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/user/code/extensions/rectangle-pro-raycast/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1249:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1065:12)
    at Module.require (node:internal/modules/cjs/loader:1271:19) {
  diagnosticCodes: [ 2578 ]
}
ERROR: "build:generate" exited with 1.

Steps to Reproduce:

  1. Download, install and configure Rectangle Pro from the official website.
  2. Clone this repository to your local machine.
  3. Customize the configuration file config.json to your needs.
  4. Build the extension using the npm run build command.
  5. Use Import Extension feature in Raycast to import the extension folder.
  6. Attempt to run any command from the extension in Raycast.

Expected Behavior: The extension should build successfully without errors, and commands should run as expected in Raycast.

Actual Behavior: Encountered TypeScript compilation error as shown above, preventing the successful build and execution of commands in Raycast.

Here is my config.ts configuration: config.ts.zip

bigplayer-ai commented 4 months ago

this solved the issue for me:

import { writeFileSync } from "fs";
import { join } from "path";

import { isEqual } from "lodash";

import packageJson from "../package.json";
import { Command } from "./types";

export function writePackageJsonContents(commands: Command[]): void {
  if (!isEqual(packageJson.commands, commands)) {
    // Removed @ts-expect-error directive
    packageJson.commands = commands.map(({ parameter: _parameter, ...command }) => command);

    writeFileSync(join(__dirname, "../package.json"), JSON.stringify(packageJson, null, 2), "utf-8");
  }
}