⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

get prismaFile issue. #140

@GrayMediaLtd

Description

@GrayMediaLtd

I'm using fly launch to launch my first Shopify App.

Not the greatest experience so far.

Being a Shopify Remix app it's running Prisma. When I run the fly launch command get to the app config bit and then when I run the next stage dockerfile fails with the following error

file:///Users/jessegray/Developer/SewEzi/sew-ezi-product-picker/node_modules/@flydotio/dockerfile/gdf.js:179
    if (url.startsWith('file:')) return URL.parse(url).pathname
                                            ^

TypeError: URL.parse is not a function
    at get prismaFile [as prismaFile] (file:///Users/jessegray/Developer/SewEzi/sew-ezi-product-picker/node_modules/@flydotio/dockerfile/gdf.js:179:45)
    at GDF.run (file:///Users/jessegray/Developer/SewEzi/sew-ezi-product-picker/node_modules/@flydotio/dockerfile/gdf.js:995:33)
    at file:///Users/jessegray/Developer/SewEzi/sew-ezi-product-picker/node_modules/@flydotio/dockerfile/index.js:343:11
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.20.5
Error: failed to generate Dockerfile: exit status 1

My good friend chatGPT helped me make the following change to the file

  get prismaFile() {
    const schema = path.join(this._appdir, 'prisma/schema.prisma')
    if (!fs.existsSync(schema)) return null
  
    const schemaContent = fs.readFileSync(schema, 'utf-8')
    const urlMatch = schemaContent.match(/url\s*=\s*"(.*?)"/)
    if (!urlMatch) return null
    const dbUrl = urlMatch[1]
    console.log("URL:", dbUrl)
    if (dbUrl.startsWith('file:.')) return dbUrl.slice(5)
    if (dbUrl.startsWith('file:')) return new URL(dbUrl).pathname
  }

To replace this

  get prismaFile() {
    const schema = path.join(this._appdir, 'prisma/schema.prisma')
    if (!fs.existsSync(schema)) return null

    const schemaContent = fs.readFileSync(schema, 'utf-8')
    const urlMatch = schemaContent.match(/url\s*=\s*"(.*?)"/)
    if (!urlMatch) return null
    const url = urlMatch[1]
    console.log("URL:", url);
    if (url.startsWith('file:.')) return url.slice(5)
    if (url.startsWith('file:')) return URL.parse(url).pathname
  }

This is the explanation given

URL.parse (in Node.js pre-10) or the modern new URL() throws an error because "file:dev.db" is not an absolute URL (missing slashes). For example, file:///dev.db would work, but file:dev.db is not valid.

I've made the suggested change and got most of the way through fly launch now. Is this something that should be updated?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions