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

--file flag ignored (possible Windows issue?) #579

Open
bbsimonbb opened this issue May 7, 2024 · 3 comments · May be fixed by #589
Open

--file flag ignored (possible Windows issue?) #579

bbsimonbb opened this issue May 7, 2024 · 3 comments · May be fixed by #589
Labels
bug Something isn't working

Comments

@bbsimonbb
Copy link

bbsimonbb commented May 7, 2024

Describe the bug
When I run pgtyped with a --file argument, it is ignored. All files in the workspace are regenerated (or checked), and at the end of the ouput, I see the message "File override specified, but file was not found in provided transforms". But the specified file is in fact found and processed. I'm 100% sure the filename I provide is correct.

I'm running pgtyped on Windows 10 with Node 18.18.0

Expected behavior
pgtyped should only process the specified file. The output should not contain a long list of all the queries in my application.

Test case

I have forked the project and will try and do a test case soon.

@bbsimonbb bbsimonbb added the bug Something isn't working label May 7, 2024
@bbsimonbb
Copy link
Author

Here is terminal output from the run. The filename is guaranteed correct because it comes from the RunOnSave extension I've installed. I tried replacing antislashes with slashes, no difference. Quotes or no quotes, no difference. Relative or absolute path, no difference. In the output, you can see the referenced file, deleteMajorVersion.psql, is found and processed.

PS C:\dev\simplyfirst-catalogues\catalogues\acme-pvc> node_modules/.bin/env-cmd npx pgtyped -c pgtyped-config.json --file 'c:\dev\simplyfirst-catalogues\catalogues\acme-pvc\installation\queries\deleteMajorVersion.psql'
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
Using a pool of 6 threads.
Processing installation\queries\setCurrentMinorVersion.psql
Processing installation\queries\setCurrentMajorVersion.psql
Processing installation\queries\insertZVarHotNumbers.psql
Processing installation\queries\insertZPath.psql
Processing installation\queries\insertHotNumberValue.psql
Processing installation\queries\insertDocumentInstance.psql
Processing installation\queries\insertCatalogueMinorVersion.psql
Processing installation\queries\insertCatalogueMajorVersion.psql
Processing installation\queries\insertCatalogueDocument.psql
Processing installation\queries\deleteMajorVersion.psql
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
(node:23792) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use node --trace-warnings ... to show where the warning was created)
Skipped installation\queries\setCurrentMinorVersion.psql: no changes or no queries detected
Skipped installation\queries\setCurrentMajorVersion.psql: no changes or no queries detected
Skipped installation\queries\insertZVarHotNumbers.psql: no changes or no queries detected
Skipped installation\queries\insertZPath.psql: no changes or no queries detected
Skipped installation\queries\insertHotNumberValue.psql: no changes or no queries detected
Skipped installation\queries\insertDocumentInstance.psql: no changes or no queries detected
Skipped installation\queries\deleteMajorVersion.psql: no changes or no queries detected
Skipped installation\queries\insertCatalogueDocument.psql: no changes or no queries detected
Skipped installation\queries\insertCatalogueMajorVersion.psql: no changes or no queries detected
Skipped installation\queries\insertCatalogueMinorVersion.psql: no changes or no queries detected
File override specified, but file was not found in provided transforms

@zacherkkila
Copy link

zacherkkila commented Jul 22, 2024

Same issue here (Mac). Not sure if you ever found a solution for this but it should also crash if the filename is not found, instead you can just throw garbage in there and it will still run everything

I assume it is just because of this in the docs

Uses transforms defined in the config file to determine the mode and emit template, so a file path that doesn't fit the include glob patterns will not be processed.

However, my transform is pretty darn simple.. Also removing the transform all together will cause a crash immediately with File override specified, but file was not found in provided transforms rather than trying to run everything

  "transforms": [
    {
      "mode": "ts",
      "include": "**/*.ts",
      "emitTemplate": "{{dir}}/{{name}}.pgtyped.ts"
    }
  ]

@zacherkkila
Copy link

zacherkkila commented Jul 23, 2024

Only way I was able to get this to work was to create a temp config. Just pass in the transform for the single file you need, also don't pass the --file flag to pgtyped in this case

So in a bash script (mac or linux)

    #!/bin/bash
    
    file="$1"
    jq --arg new_include_path "$file" '
    .transforms |= map(
        if .mode == "ts" then
        .include = $new_include_path
        else
        .
        end
    )' pgtyped_config.json > temp_pgtyped_config.json
    
    pgtyped --uri ${ENV} -c temp_pgtyped_config.json

Kind of a hack but seems to do the trick

@cakerug cakerug linked a pull request Sep 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants