scullyio / scully

The Static Site Generator for Angular apps
https://scully.io/
MIT License
2.55k stars 257 forks source link

Scully is using stored routes despite running with --scanRoutes #1319

Closed lukasmatta closed 2 years ago

lukasmatta commented 3 years ago

🐞 Bug report

Update:

I found the bug (more precisely it's misleading message). In the warning message it suggests to run: npm run scully -- --scanRoutes but when I ran it, it didn't work, I think because it runs npx scully -- --scanRoutes instead of npx scully --scanRoutes. I ended up adding custom script to package.json: "scully:routes": "npx scully --scanRoutes",

Hello,

I've added a new route and ran scully with the command npm run scully -- --scanRoutes. When running this command, the output contains the following warning and scully doesn't fetch new routes:

Using stored unhandled routes!.
To discover new routes in the angular app use "npm run scully -- --scanRoutes"

Why is that? I run the command with the --scanRoutes option, I expect it to scan new routes. I should mention, that I did build angular application before running scully command.

Angular Version:



Angular CLI: 11.2.8
Node: 12.10.0
OS: darwin x64

Angular: 11.2.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.8
@angular-devkit/build-angular   0.1102.8
@angular-devkit/core            11.2.8
@angular-devkit/schematics      11.2.8
@angular/cli                    11.2.8
@schematics/angular             11.2.8
@schematics/update              0.1102.8
rxjs                            6.6.7
typescript                      4.1.5

Scully Version:



    "@scullyio/init": "^1.1.3",
    "@scullyio/ng-lib": "^1.0.0",
    "@scullyio/scully": "^1.0.0",

Whole scully output:

> personal-website@0.0.0 scully
> npx scully -- "--scanRoutes"

logging with severity "warning"
using plugins from folder "./scully"
 ☺   new Angular build imported
Starting background servers with: node ./node_modules/@scullyio/scully/src/scully.js serve --tds false --pjf false --ls warning --noCache true --project personal-website
 ☺   Started servers in background
Finding all routes in application.

----------------------------------
Using stored unhandled routes!.
   To discover new routes in the angular app use "npm run scully -- --scanRoutes"
----------------------------------
Pull in data to create additional routes.
Route list created in files:
  "./src/assets/scully-routes.json",
  "/personal-website/dist/static/assets/scully-routes.json",
  "/personal-website/dist/personal-website/assets/scully-routes.json"

Route "/" rendered into file: "./dist/static/index.html"

Generating took 1.51 seconds for 1 pages:
  That is 0.67 pages per second,
  or 1514 milliseconds for each page.

  Finding routes in the angular app took 1 milliseconds
  Pulling in route-data took 0 milliseconds
  Rendering the pages took 719 milliseconds

Routes file:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TestComponent } from './test/test.component';

const routes: Routes = [
  {path: 'test', component: TestComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
aquariuslt commented 3 years ago

try using --forceScan instead?

ponju commented 3 years ago

I'm afraid that there are some problems about npm or npx arguments.

I can make all routes files by adding script on package.json like this.

"scripts: { "jam": "ng build && npx scully --scanRoutes && npm run scully serve" } I just skip arguments,"--",I don't know why does it work.

I was stacked on this issue too. Sorry for my poorness of English. :(

lukasmatta commented 3 years ago

Yes you're right. I've already updated my post, after I found that the problem is in argument handling:

I found the bug (more precisely it's misleading message). In the warning message it suggests to run: npm run scully -- --scanRoutes but when I ran it, it didn't work, I think because it runs npx scully -- --scanRoutesinstead of npx scully --scanRoutes. I ended up adding custom script to package.json: "scully:routes": "npx scully --scanRoutes"

SanderElias commented 3 years ago

@lukasmatta This is more of an npm issue. the -- is telling npm to add whatever is after that, to the command that is being started. However, if that command ends with -- it's not entirely sure what happens.

rogsfernandes commented 3 years ago

Hi, first of all, congrats on the work and I am loving Scully so far.

I followed the doc today and ended with this problem too. When I run npx scully it recommends the usage of npm run scully -- --scanRoutes, which runs the package.json script adding the parameter. But the package.json script added by the schematics already has dashes "scully": "npx scully --" so the result is this npx scully -- --scanRoutes.

Either changing the schematics or the command recommendation would fix this.

kogiokka commented 3 years ago

It will be nice to resolve this problem. Newbie here, just spent an hour figuring out why I kept getting No configuration for route "/id/:id" found. Skipping even I had changed the path in both the scully config and the angular app.

npx scully --scanRoutes works in my case. Another solution is to delete node_modules/.cache.

anshumankmr commented 2 years ago

Ditto same issue is occuring with me. Any idea on how to fix this?

SanderElias commented 2 years ago

This is an issue with how NPM scripts are working and is not something Scully can solve. If you use npm run scully you need to add -- to tell NPM that you want to give parameters to the command. so run it like this:

npm run scully -- --scanRoutes

When using NPX, you don't need to add -- and doing so might break things To make the whole story more cumbersome, in different versions of NPM different things happened. For a while adding the -- into the NPM script helped, and the user didn't need to provide them. But it turns out that this works differently, depending on OS and NPM version. As a result we had the -- in some versions of our schematics, and those ended up in the package.json scripts. If you have them there, remove them. An easy way to workaround this is updating your package.json script with the following:

  "scripts": {
    "/** ","Other scripts are still here! **/",
    "scully": "npx scully",
    "scully.scan": "npx scully --scanRoutes",
    "scully.serve": "npx scully serve"
  },

Then, when you want to scan, you can run npm run scully.scan I'm closing this issue, as its not something we can "fix"