Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error in case of invalid specification #100

Open
mgm1313 opened this issue Sep 22, 2024 · 0 comments
Open

Improve error in case of invalid specification #100

mgm1313 opened this issue Sep 22, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mgm1313
Copy link

mgm1313 commented Sep 22, 2024

Edit: I found out the issue is within my specification. If I paste an example YAML, the build does work. Would be nice if the error message was more specific on this!

I'm creating a proof of concept for using Skiffa in our Buchung monorepo. I followed the examples as closely as possible, but the skiffa-generator throws an error.

initialize.js:

#!/usr/bin/env node
import { execFileSync } from "child_process";
import path from "path";
import { fileURLToPath } from "url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
const workspaceRoot = path.resolve(dirname, "..");

const options = { shell: true, stdio: "inherit", env: process.env };

execFileSync(
  "pnpm",
  [
    "--package",
    "@skiffa/[email protected]",
    "dlx",
    "skiffa-generator",
    "package",
    path.resolve(workspaceRoot, "specifications", "api.yaml"),
    "--package-directory",
    path.resolve(workspaceRoot, "generated", "sdk"),
    "--package-name",
    "@buchungapp/sdk",
    "--package-version",
    "0.1.0",
  ],
  options,
);

execFileSync("pnpm", ["--filter", "@buchungapp/sdk", "install"], options);
execFileSync("pnpm", ["--filter", "@buchungapp/sdk", "build"], options);
> node scripts/initialize.js

program.js package [specification-location]

create package from specification location

Positionals:
  specification-location  url to download specification from            [string]

Options:
  --help                          Show help                            [boolean]
  --version                       Show version number                  [boolean]
  --package-directory             where to output the package[string] [required]
  --package-name                  name of the package        [string] [required]
  --package-version               version of the package     [string] [required]
  --default-type-name             default name for types
                                                    [string] [default: "schema"]
  --transform-maximum-iterations  maximum number of iterations for transforming
                                                        [number] [default: 1000]
  --request-types                 Preferred request content-types
      [array] [default: ["application/json","multipart/form-data","text/plain"]]
  --response-types                Preferred response content-types
  [array] [default: ["application/x-ndjson","application/json","multipart/form-d
                                                             ata","text/plain"]]
  --base-url                      The default location from where the api is
                                  served                                [string]

6
node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: pnpm --package @skiffa/[email protected] dlx skiffa-generator package /Users/techmaus/code/MijnZeilschool/buchung/specifications/api.yaml --package-directory /Users/techmaus/code/MijnZeilschool/buchung/generated/sdk --package-name @buchungapp/sdk --package-version 0.1.0
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:890:11)
    at execFileSync (node:child_process:926:15)
    at file:///Users/techmaus/code/MijnZeilschool/buchung/scripts/initialize.js:11:1
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 79912,
  stdout: null,
  stderr: null
}

Node.js v22.9.0
 ELIFECYCLE  Command failed with exit code 1.

I'm having trouble because the error message isn't very helpful. I'm not sure what's going wrong.

@mgm1313 mgm1313 changed the title skiffa-generator fails with generic error Improve error in case of invalid specification Sep 22, 2024
@elmerbulthuis elmerbulthuis self-assigned this Oct 25, 2024
@elmerbulthuis elmerbulthuis added the enhancement New feature or request label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants