upleveled / preflight

Preflight checks for your UpLeveled projects before you submit πŸš€
https://www.npmjs.com/package/@upleveled/preflight
MIT License
14 stars 3 forks source link

Preflight Docker fails on `libpg-query` installation #394

Closed ProchaLu closed 1 year ago

ProchaLu commented 1 year ago

When attempting to install libpg-query in the Preflight Docker container, the following error is encountered:

.../node_modules/libpg-query install$ node-pre-gyp install --fallback-to-build
.../node_modules/libpg-query install: node-pre-gyp info it worked if it ends with ok
.../node_modules/libpg-query install: node-pre-gyp info using node-pre-gyp@1.0.10
.../node_modules/libpg-query install: node-pre-gyp info using node@18.16.0 | linux | x64
.../node_modules/libpg-query install: node-pre-gyp info check checked for "/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node" (not found)
.../node_modules/libpg-query install: node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-x64.tar.gz
.../node_modules/libpg-query install: node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-x64.tar.gz 
.../node_modules/libpg-query install: node-pre-gyp WARN Pre-built binaries not installable for libpg-query@15.0.2 and node@18.16.0 (node-v108 ABI, musl) (falling back to source compile with node-gyp) 
.../node_modules/libpg-query install: node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-x64.tar.gz 
.../node_modules/libpg-query install: gyp info it worked if it ends with ok
.../node_modules/libpg-query install: gyp info using node-gyp@9.3.1
.../node_modules/libpg-query install: gyp info using node@18.16.0 | linux | x64
.../node_modules/libpg-query install: gyp info ok 
.../node_modules/libpg-query install: gyp info it worked if it ends with ok
.../node_modules/libpg-query install: gyp info using node-gyp@9.3.1
.../node_modules/libpg-query install: gyp info using node@18.16.0 | linux | x64
.../node_modules/libpg-query install: gyp ERR! find Python 
.../node_modules/libpg-query install: gyp ERR! find Python Python is not set from command line or npm configuration
.../node_modules/libpg-query install: gyp ERR! find Python Python is not set from environment variable PYTHON
.../node_modules/libpg-query install: gyp ERR! find Python checking if "python3" can be used
.../node_modules/libpg-query install: gyp ERR! find Python - "python3" is not in PATH or produced an error
.../node_modules/libpg-query install: gyp ERR! find Python checking if "python" can be used
.../node_modules/libpg-query install: gyp ERR! find Python - "python" is not in PATH or produced an error
.../node_modules/libpg-query install: gyp ERR! find Python 
.../node_modules/libpg-query install: gyp ERR! find Python **********************************************************
.../node_modules/libpg-query install: gyp ERR! find Python You need to install the latest version of Python.
.../node_modules/libpg-query install: gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
.../node_modules/libpg-query install: gyp ERR! find Python you can try one of the following options:
.../node_modules/libpg-query install: gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
.../node_modules/libpg-query install: gyp ERR! find Python   (accepted by both node-gyp and npm)
.../node_modules/libpg-query install: gyp ERR! find Python - Set the environment variable PYTHON
.../node_modules/libpg-query install: gyp ERR! find Python - Set the npm configuration variable python:
.../node_modules/libpg-query install: gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
.../node_modules/libpg-query install: gyp ERR! find Python For more information consult the documentation at:
.../node_modules/libpg-query install: gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
.../node_modules/libpg-query install: gyp ERR! find Python **********************************************************
.../node_modules/libpg-query install: gyp ERR! find Python 
.../node_modules/libpg-query install: gyp ERR! configure error 
.../node_modules/libpg-query install: gyp ERR! stack Error: Could not find any Python installation to use
.../node_modules/libpg-query install: gyp ERR! stack     at PythonFinder.fail (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/lib/find-python.js:330:47)
.../node_modules/libpg-query install: gyp ERR! stack     at PythonFinder.runChecks (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/lib/find-python.js:159:21)
.../node_modules/libpg-query install: gyp ERR! stack     at PythonFinder.<anonymous> (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/lib/find-python.js:202:16)
.../node_modules/libpg-query install: gyp ERR! stack     at PythonFinder.execFileCallback (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/lib/find-python.js:294:16)
.../node_modules/libpg-query install: gyp ERR! stack     at exithandler (node:child_process:427:5)
.../node_modules/libpg-query install: gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:439:5)
.../node_modules/libpg-query install: gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
.../node_modules/libpg-query install: gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
.../node_modules/libpg-query install: gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
.../node_modules/libpg-query install: gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
.../node_modules/libpg-query install: gyp ERR! System Linux 5.15.0-1035-azure
.../node_modules/libpg-query install: gyp ERR! command "/usr/local/bin/node" "/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node" "--module_name=queryparser" "--module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
.../node_modules/libpg-query install: gyp ERR! cwd /preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query
.../node_modules/libpg-query install: gyp ERR! node -v v18.16.0
.../node_modules/libpg-query install: gyp ERR! node-gyp -v v9.3.1
.../node_modules/libpg-query install: gyp ERR! not ok 
.../node_modules/libpg-query install: node-pre-gyp ERR! build error 
.../node_modules/libpg-query install: node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node --module_name=queryparser --module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/preflight/repo-to-check/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.10/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
.../node_modules/libpg-query install: node-pre-gyp ERR! System Linux 5.15.0-1035-azure
.../node_modules/libpg-query install: node-pre-gyp ERR! command "/usr/local/bin/node" "/preflight/repo-to-check/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.10/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
.../node_modules/libpg-query install: node-pre-gyp ERR! cwd /preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query
.../node_modules/libpg-query install: node-pre-gyp ERR! node -v v18.16.0
.../node_modules/libpg-query install: node-pre-gyp ERR! node-pre-gyp -v v1.0.10
.../node_modules/libpg-query install: node-pre-gyp ERR! not ok 
.../node_modules/libpg-query install: Failed to execute '/usr/local/bin/node /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node --module_name=queryparser --module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
.../node_modules/libpg-query install: Failed
 ELIFECYCLE  Command failed with exit code 1.
    at makeError (file:///preflight/node_modules/.pnpm/execa@7.1.1/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///preflight/node_modules/.pnpm/execa@7.1.1/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async executeCommand (file:///preflight/clone-and-preflight.js:15:30)
    at async file:///preflight/clone-and-preflight.js:35:1 {
  shortMessage: 'Command failed with exit code 1: pnpm install',
  command: 'pnpm install',
  escapedCommand: 'pnpm install',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: 'Lockfile is up to date, resolution step is skipped\n' +

When running pnpm install inside the Docker image, the installation of libpg-query is failing due to the dependency on Python. Specifically, it seems that the node-gyp package used by libpg-query is requiring Python.

  "dependencies": {
    "@mapbox/node-pre-gyp": "^1.0.8",
    "node-addon-api": "^1.6.3",
    "node-gyp": "^8.0.0"
  },

Locally, when installing ESLint, a script is being executed (node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query: Running install script...). Since we changed the install command for the Docker image from pnpm install --ignore-scripts to pnpm install in this commit, the same script is being executed inside Docker as well.

I also tried using the older Docker image by reverting the changes made in this commit, but the errors are the same.

I tested different portfolios from the Winter Cohort 2023 using yarn and found no issues with @ts-safeql/eslint-plugin and libpg-query as unused dependencies. However, switching to pnpm and upgrading to the latest version of ESLint, I encountered the following Preflight message:

  βœ– No unused dependencies
    β€Ί Unused dependencies found:
      * @ts-safeql/eslint-plugin
      * libpg-query

      Remove these dependencies by running the following command for each dependency:

      β€Ž  $ pnpm remove <dependency name here>

I also tested Kathi's Next.js e-commerce store using both yarn and pnpm. While there were no issues with the unused dependencies when using yarn, I encountered the same Preflight message after switching to pnpm and upgrading to the latest version of ESLint.

ProchaLu commented 1 year ago

After adding Python to the Dockerfile with RUN apk add --no-cache python3 py3-pip, when installing the dependencies of a project that contains the package libpg-query the node-pre-gyp install --fallback-to-build script command form libpg-query is failing with this error message

.../node_modules/libpg-query install$ node-pre-gyp install --fallback-to-build
.../node_modules/libpg-query install: node-pre-gyp info it worked if it ends with ok
.../node_modules/libpg-query install: node-pre-gyp info using node-pre-gyp@1.0.10
.../node_modules/libpg-query install: node-pre-gyp info using node@18.16.0 | linux | arm64
.../node_modules/libpg-query install: node-pre-gyp info check checked for "/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node" (not found)
.../node_modules/libpg-query install: node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-arm64.tar.gz
.../node_modules/libpg-query install: node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-arm64.tar.gz 
.../node_modules/libpg-query install: node-pre-gyp WARN Pre-built binaries not installable for libpg-query@15.0.2 and node@18.16.0 (node-v108 ABI, musl) (falling back to source compile with node-gyp) 
.../node_modules/libpg-query install: node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-linux-arm64.tar.gz 
.../node_modules/libpg-query install: gyp info it worked if it ends with ok
.../node_modules/libpg-query install: gyp info using node-gyp@9.3.1
.../node_modules/libpg-query install: gyp info using node@18.16.0 | linux | arm64
.../node_modules/libpg-query install: gyp info ok 
.../node_modules/libpg-query install: gyp info it worked if it ends with ok
.../node_modules/libpg-query install: gyp info using node-gyp@9.3.1
.../node_modules/libpg-query install: gyp info using node@18.16.0 | linux | arm64
.../node_modules/libpg-query install: gyp info find Python using Python version 3.10.11 found at "/usr/bin/python3"
.../node_modules/libpg-query install: gyp http GET https://nodejs.org/download/release/v18.16.0/node-v18.16.0-headers.tar.gz
.../node_modules/libpg-query install: gyp http 200 https://nodejs.org/download/release/v18.16.0/node-v18.16.0-headers.tar.gz
.../node_modules/libpg-query install: gyp http GET https://nodejs.org/download/release/v18.16.0/SHASUMS256.txt
.../node_modules/libpg-query install: gyp http 200 https://nodejs.org/download/release/v18.16.0/SHASUMS256.txt
.../node_modules/libpg-query install: gyp info spawn /usr/bin/python3
.../node_modules/libpg-query install: gyp info spawn args [
.../node_modules/libpg-query install: gyp info spawn args   '/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/gyp/gyp_main.py',
.../node_modules/libpg-query install: gyp info spawn args   'binding.gyp',
.../node_modules/libpg-query install: gyp info spawn args   '-f',
.../node_modules/libpg-query install: gyp info spawn args   'make',
.../node_modules/libpg-query install: gyp info spawn args   '-I',
.../node_modules/libpg-query install: gyp info spawn args   '/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/config.gypi',
.../node_modules/libpg-query install: gyp info spawn args   '-I',
.../node_modules/libpg-query install: gyp info spawn args   '/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/addon.gypi',
.../node_modules/libpg-query install: gyp info spawn args   '-I',
.../node_modules/libpg-query install: gyp info spawn args   '/root/.cache/node-gyp/18.16.0/include/node/common.gypi',
.../node_modules/libpg-query install: gyp info spawn args   '-Dlibrary=shared_library',
.../node_modules/libpg-query install: gyp info spawn args   '-Dvisibility=default',
.../node_modules/libpg-query install: gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.16.0',
.../node_modules/libpg-query install: gyp info spawn args   '-Dnode_gyp_dir=/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp',
.../node_modules/libpg-query install: gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.16.0/<(target_arch)/node.lib',
.../node_modules/libpg-query install: gyp info spawn args   '-Dmodule_root_dir=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query',
.../node_modules/libpg-query install: gyp info spawn args   '-Dnode_engine=v8',
.../node_modules/libpg-query install: gyp info spawn args   '--depth=.',
.../node_modules/libpg-query install: gyp info spawn args   '--no-parallel',
.../node_modules/libpg-query install: gyp info spawn args   '--generator-output',
.../node_modules/libpg-query install: gyp info spawn args   'build',
.../node_modules/libpg-query install: gyp info spawn args   '-Goutput_dir=.'
.../node_modules/libpg-query install: gyp info spawn args ]
.../node_modules/libpg-query install: gyp info ok 
.../node_modules/libpg-query install: gyp info it worked if it ends with ok
.../node_modules/libpg-query install: gyp info using node-gyp@9.3.1
.../node_modules/libpg-query install: gyp info using node@18.16.0 | linux | arm64
.../node_modules/libpg-query install: gyp ERR! build error 
.../node_modules/libpg-query install: gyp ERR! stack Error: not found: make
.../node_modules/libpg-query install: gyp ERR! stack     at getNotFoundError (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:10:17)
.../node_modules/libpg-query install: gyp ERR! stack     at /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:57:18
.../node_modules/libpg-query install: gyp ERR! stack     at new Promise (<anonymous>)
.../node_modules/libpg-query install: gyp ERR! stack     at step (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:54:21)
.../node_modules/libpg-query install: gyp ERR! stack     at /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:71:22
.../node_modules/libpg-query install: gyp ERR! stack     at new Promise (<anonymous>)
.../node_modules/libpg-query install: gyp ERR! stack     at subStep (/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:69:33)
.../node_modules/libpg-query install: gyp ERR! stack     at /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/which/which.js:80:22
.../node_modules/libpg-query install: gyp ERR! stack     at /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/isexe/index.js:42:5
.../node_modules/libpg-query install: gyp ERR! stack     at /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/isexe/mode.js:8:5
.../node_modules/libpg-query install: gyp ERR! System Linux 5.10.76-linuxkit
.../node_modules/libpg-query install: gyp ERR! command "/usr/local/bin/node" "/root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node" "--module_name=queryparser" "--module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
.../node_modules/libpg-query install: gyp ERR! cwd /preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query
.../node_modules/libpg-query install: gyp ERR! node -v v18.16.0
.../node_modules/libpg-query install: gyp ERR! node-gyp -v v9.3.1
.../node_modules/libpg-query install: gyp ERR! not ok 
.../node_modules/libpg-query install: node-pre-gyp ERR! build error 
.../node_modules/libpg-query install: node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node --module_name=queryparser --module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/preflight/repo-to-check/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.10/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
.../node_modules/libpg-query install: node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
.../node_modules/libpg-query install: node-pre-gyp ERR! System Linux 5.10.76-linuxkit
.../node_modules/libpg-query install: node-pre-gyp ERR! command "/usr/local/bin/node" "/preflight/repo-to-check/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.10/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
.../node_modules/libpg-query install: node-pre-gyp ERR! cwd /preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query
.../node_modules/libpg-query install: node-pre-gyp ERR! node -v v18.16.0
.../node_modules/libpg-query install: node-pre-gyp ERR! node-pre-gyp -v v1.0.10
.../node_modules/libpg-query install: node-pre-gyp ERR! not ok 
.../node_modules/libpg-query install: Failed to execute '/usr/local/bin/node /root/.cache/node/corepack/pnpm/8.3.1/dist/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release/queryparser.node --module_name=queryparser --module_path=/preflight/repo-to-check/node_modules/.pnpm/libpg-query@15.0.2/node_modules/libpg-query/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
.../node_modules/libpg-query install: Failed
 ELIFECYCLE  Command failed with exit code 1.
    at makeError (file:///preflight/node_modules/.pnpm/execa@7.1.1/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///preflight/node_modules/.pnpm/execa@7.1.1/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async executeCommand (file:///preflight/clone-and-preflight.js:15:30)
    at async file:///preflight/clone-and-preflight.js:35:1 {
  shortMessage: 'Command failed with exit code 1: pnpm install',
  command: 'pnpm install',
  escapedCommand: 'pnpm install',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: 'Lockfile is up to date, resolution step is skipped\n' +
    'Progress: resolved 1, reused 0, downloaded 0, added 0\n' +
    'Packages: +817\n' +
ProchaLu commented 1 year ago

After adding Python to the Docker image, the build failed due to a missing make command with the error message: .../node_modules/libpg-query install: gyp ERR! stack Error: not found: make. To resolve this issue, the build-base package was added. Rebuilding the Docker image, a new error was encountered stating that bash was missing, preventing make from running. The bash package was added, allowing the libpg-query module to be built successfully.

After running this command locally, the Docker image was built successfully and Preflight was executed:

Cloning https://github.com/ProchaLu/portfolio-cms-test...
Installing dependencies...
Running Preflight...
πŸš€ UpLeveled Preflight v2.1.11
[STARTED] All changes committed to Git
[STARTED] node_modules/ folder ignored in Git
[STARTED] No extraneous files committed to Git
[STARTED] No secrets committed to Git
[STARTED] Use single package manager
[COMPLETED] No extraneous files committed to Git
[STARTED] Project folder name matches correct format
[COMPLETED] Project folder name matches correct format
[STARTED] No dependency problems
[STARTED] Next.js project has sharp installed
[STARTED] No unused dependencies
[STARTED] No dependencies without types
[COMPLETED] Next.js project has sharp installed
[COMPLETED] No secrets committed to Git
[STARTED] GitHub repo has deployed project link under About
[COMPLETED] Use single package manager
[STARTED] ESLint
[COMPLETED] node_modules/ folder ignored in Git
[STARTED] Stylelint
[COMPLETED] All changes committed to Git
[STARTED] Prettier
[COMPLETED] No dependencies without types
[COMPLETED] Prettier
[STARTED] ESLint config is latest version
[COMPLETED] GitHub repo has deployed project link under About
[STARTED] Stylelint config is latest version
[COMPLETED] Stylelint
[STARTED] Preflight is latest version
[FAILED] Unused dependencies found:
[FAILED]         * @ts-safeql/eslint-plugin
[FAILED] * libpg-query

[FAILED]         Remove these dependencies by running the following command for each dependency:

[FAILED]         β€Ž  $ pnpm remove <dependency name here>
[COMPLETED] No dependency problems
[COMPLETED] ESLint config is latest version
[COMPLETED] Stylelint config is latest version
[COMPLETED] Preflight is latest version
[COMPLETED] ESLint
karlhorky commented 1 year ago

A) Ok, so the build dependencies is partially solved (still needs caching of the built dependencies so that libpg-query is not built every time Drone runs)

B) But also, what about the other previous repos? They weren't reporting problems with unused dependencies before. What is causing this report now?

ProchaLu commented 1 year ago

I was able to avoid the error for unused dependencies in Kathi's e-commerce store and portfolio when switching to pnpm without updating ESLint to the latest version. The preflight throws these errors:

➜  nextjs-ecommerce-store git:(main) βœ— preflight
πŸš€ UpLeveled Preflight v2.1.11
βœ– All changes committed to Git
  β€Ί Some changes have not been committed to Git:
    M package.json
    D yarn.lock
    ?? pnpm-lock.yaml

βœ” node_modules/ folder ignored in Git
βœ” No extraneous files committed to Git
βœ” No secrets committed to Git
βœ– Use single package manager
  β€Ί package-lock.json or yarn.lock file committed to Git. Remove it with:

    β€Ž  $ git rm --cached <filename>

    After you've removed it, you can delete the file with:

    β€Ž  $ rm <filename>

    The presence of this file indicates that another package manager was used in addition to pnpm (eg. "npm install" or "yarn add" was
    run). In order to avoid issues with the state of the pnpm-lock.yaml file, we suggest also forcing regeneration this file with the
    following command:

    β€Ž  $ pnpm install --force

βœ” Project folder name matches correct format
βœ” No dependency problems
βœ” GitHub repo has deployed project link under About
βœ” ESLint
βœ” Stylelint
βœ” Prettier
βœ– ESLint config is latest version
  β€Ί Your current version of the UpLeveled ESLint Config (4.1.6) is older than the latest version 4.1.8 - upgrade by running all lines of
    the install instructions on https://www.npmjs.com/package/eslint-config-upleveled

βœ– Stylelint config is latest version
  β€Ί The UpLeveled Stylelint Config has not been installed - please install using the instructions on
    https://www.npmjs.com/package/eslint-config-upleveled

βœ” Preflight is latest version

When I update to the latest version of ESLint, I get the unused dependency errors:

➜  nextjs-ecommerce-store git:(main) βœ— preflight 
πŸš€ UpLeveled Preflight v2.1.11
βœ– All changes committed to Git
  β€Ί Some changes have not been committed to Git:
    M .eslintignore
    M .eslintrc.cjs
    M package.json
    D pages/api/hello.js
    M stylelint.config.cjs
    M tsconfig.json
    D yarn.lock
    ?? next.d.ts
    ?? pnpm-lock.yaml

βœ” node_modules/ folder ignored in Git
βœ” No extraneous files committed to Git
βœ” No secrets committed to Git
βœ– Use single package manager
  β€Ί package-lock.json or yarn.lock file committed to Git. Remove it with:

    β€Ž  $ git rm --cached <filename>

    After you've removed it, you can delete the file with:

    β€Ž  $ rm <filename>

    The presence of this file indicates that another package manager was used in addition to pnpm (eg. "npm install" or "yarn add" was
    run). In order to avoid issues with the state of the pnpm-lock.yaml file, we suggest also forcing regeneration this file with the
    following command:

    β€Ž  $ pnpm install --force

βœ” Project folder name matches correct format
⚠ No dependency problems
  βœ” Next.js project has sharp installed
  βœ– No unused dependencies
    β€Ί Unused dependencies found:
      * @ts-safeql/eslint-plugin
      * libpg-query

      Remove these dependencies by running the following command for each dependency:

      β€Ž  $ pnpm remove <dependency name here>

  βœ” No dependencies without types
βœ” GitHub repo has deployed project link under About
βœ– ESLint
  β€Ί ESLint problems found in the following files:
    app/cart/CartTable.tsx
    app/page.tsx
    app/products/page.js

    Open these files in your editor - there should be problems to fix

βœ” Stylelint
βœ” Prettier
βœ” ESLint config is latest version
βœ” Stylelint config is latest version
βœ” Preflight is latest version
karlhorky commented 1 year ago

Cool, so it's something with the changes in the ESLint config, I guess? What is causing it?

ProchaLu commented 1 year ago

I've discovered that if I include a .env file with the following variables:

PGHOST=xxxxxxxxxxxxxxxxxx
PGUSERNAME=xxxxxxxxxxxxxx
PGPASSWORD=xxxxxxxxxxxxxx
PGDATABASE=xxxxxxxxxxxxxx

then the project will make use of the libpg-query and @ts-safeql/eslint-plugin dependencies.

On the other hand, if I remove one of these variables, such as PGUSERNAME, or don't even have a .env file, then both libpg-query and @ts-safeql/eslint-plugin become unused dependencies.

Preflight with a .env file:

βœ” No dependency problems

Preflight without a .env file:

  βœ– No unused dependencies
    β€Ί Unused dependencies found:
      * @ts-safeql/eslint-plugin
      * libpg-query

      Remove these dependencies by running the following command for each dependency:

      β€Ž  $ pnpm remove <dependency name here>
karlhorky commented 1 year ago

@ProchaLu Since you mentioned offline you're considering splitting this issue into 2 parts, you can document this in this issue and then link to the new issue:

  1. this issue: Add necessary dependencies to the Preflight Dockerfile to build and cache libpg-query (and maybe other dependencies)
  2. new issue: Improve the setup conditions of libpg-query and @ts-safeql/eslint-plugin in the ESLint setup and database setup instructions
ProchaLu commented 1 year ago
karlhorky commented 1 year ago

Closed in https://github.com/upleveled/preflight/pull/454

  1. cache libpg-query (and maybe other dependencies)

Moved this to: