fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Fresh updater fails when deno.jsonc is in parent folder

Open sergeysolovev opened this issue 3 months ago • 1 comments

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 avatar Mar 21 '24 07:03 sergeysolovev

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/[email protected]/",
    "$fresh/": "https://deno.land/x/[email protected]/",
    "ms": "https://esm.sh/[email protected]",
    "preact": "https://esm.sh/[email protected]",
    "preact/": "https://esm.sh/[email protected]/",
    "@preact/signals": "https://esm.sh/*@preact/[email protected]",
    "@preact/signals-core": "https://esm.sh/*@preact/[email protected]"
  }
}

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/[email protected]/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).

sergeysolovev avatar Mar 21 '24 08:03 sergeysolovev