denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.65k stars 655 forks source link

Fresh updater fails when deno.jsonc is in parent folder #2371

Open sergeysolovev opened 8 months ago

sergeysolovev commented 8 months ago

Hello. I’ve followed the steps from here because I keep my fresh app in a separate app directory, and the parent deno.jsonc contains configuration for both fresh and other code as well. https://fresh.deno.dev/docs/examples/changing-the-src-dir

As a result, automatic fresh updates don’t work. The updater expects the routes folder to be at the same level as deno.jsonc. Is there any workaround or fix for this?

sergeysolovev commented 8 months ago

My deno.jsonc:

{
  "unstable": ["ffi", "cron", "http", "kv"],
  "tasks": {
    "cache_deps": "deno cache deps/**/*.ts && deno cache app/main.ts && deno cache app/dev.ts",
    "app_check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
    "app_cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
    "app_manifest": "deno task app_cli manifest $(pwd)/app",
    "app_start": "deno run -A --watch=app/static/,app/routes/ app/dev.ts",
    "app_build": "deno run -A app/dev.ts build",
    "app_preview": "deno run -A app/main.ts",
    "app_update": "deno run -A -r https://fresh.deno.dev/update ."
  },
  "exclude": [
    "dash_app",
    "dash/app/dist",
    "log",
    "node_modules",
    "postgres",
    "sys/ax/test/out/",
    "tmp",
    "**/_fresh/*"
  ],
  "lint": { "rules": { "tags": ["fresh", "recommended"] } },
  "fmt": { "singleQuote": true, "proseWrap": "always" },
  "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" },
  "imports": {
    "app/": "./app/",
    "lib/": "./lib/",
    "deps/": "./deps/",
    "dash/": "./dash/",
    "env/": "./lib/env/",
    "mmap/": "./mmap/",
    "data/": "./data/",
    "sys/": "./sys/",
    "scripts/": "./scripts/",
    "std/": "https://deno.land/std@0.211.0/",
    "$fresh/": "https://deno.land/x/fresh@1.6.5/",
    "ms": "https://esm.sh/ms@2.1.3",
    "preact": "https://esm.sh/preact@10.19.2",
    "preact/": "https://esm.sh/preact@10.19.2/",
    "@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.0"
  }
}

If I call deno task app_update I get this error:

error: Uncaught (in promise) NotFound: No such file or directory (os error 2): readdir '/home/ec2-user/bromo/dash/server/routes'
const routes = Array.from(Deno.readDirSync(join(srcDirectory, "routes")));
                               ^
    at Object.readDirSync (ext:deno_fs/30_fs.js:210:10)
    at https://deno.land/x/fresh@1.6.5/update.ts:279:32
    at eventLoopTick (ext:core/01_core.js:169:7)

Calling this command actually updates deno.jsonc, it replaces $fresh/ and does a few other unexpected things, like removes my comments (it’s jsonc after all) and adds build and preview tasks (I already have them under different names).