aurelia / cli

The Aurelia 1 command line tool. Use the CLI to create projects, scaffold components, and bundle your app for release.
MIT License
407 stars 133 forks source link

allow customizing sources folder location #278

Closed atsu85 closed 6 years ago

atsu85 commented 8 years ago

I'm submitting a bug report after renaming "src" folder to"xxx/yyy" au run --watch produces errors

Please tell us about your environment:

Current behavior:

Expected/desired behavior: should be able to relocate (not just rename) src folder: "src"-> "xxx/yyy"

\ Console output ** au run --watch Starting 'readProjectConfiguration'... Finished 'readProjectConfiguration' Starting 'processMarkup'... Starting 'processCSS'... Starting 'configureEnvironment'... Finished 'processCSS' Finished 'processMarkup' Finished 'configureEnvironment' Starting 'buildTypeScript'... Finished 'buildTypeScript' Starting 'writeBundles'... Tracing app... Tracing environment... Tracing main... Tracing resources/index... Tracing app... Tracing text... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\scripts\text.js Tracing aurelia-bootstrapper... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-bootstrapper\dist\amd\aurelia-bootstrapper.js Tracing aurelia-binding... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-binding\dist\amd\aurelia-binding.js Tracing aurelia-dependency-injection... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-dependency-injection\dist\amd\aurelia-dependency-injection.js Tracing aurelia-framework... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-framework\dist\amd\aurelia-framework.js Tracing aurelia-event-aggregator... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-event-aggregator\dist\amd\aurelia-event-aggregator.js Tracing aurelia-history... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-history\dist\amd\aurelia-history.js Tracing aurelia-history-browser... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-history-browser\dist\amd\aurelia-history-browser.js Tracing aurelia-loader... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-loader\dist\amd\aurelia-loader.js Tracing aurelia-loader-default... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-loader-default\dist\amd\aurelia-loader-default.js Tracing aurelia-logging-console... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-logging-console\dist\amd\aurelia-logging-console.js Tracing aurelia-logging... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-logging\dist\amd\aurelia-logging.js Tracing aurelia-metadata... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-metadata\dist\amd\aurelia-metadata.js Tracing aurelia-pal... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-pal\dist\amd\aurelia-pal.js Tracing aurelia-pal-browser... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-pal-browser\dist\amd\aurelia-pal-browser.js Tracing aurelia-path... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-path\dist\amd\aurelia-path.js Tracing aurelia-polyfills... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-polyfills\dist\amd\aurelia-polyfills.js Tracing aurelia-route-recognizer... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-route-recognizer\dist\amd\aurelia-route-recognizer.js Tracing aurelia-router... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-router\dist\amd\aurelia-router.js Tracing aurelia-task-queue... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-task-queue\dist\amd\aurelia-task-queue.js Tracing aurelia-templating... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-templating\dist\amd\aurelia-templating.js Tracing aurelia-templating-resources... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-templating-resources\dist\amd\aurelia-templating-resources.js Tracing aurelia-templating-binding... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-templating-binding\dist\amd\aurelia-templating-binding.js Tracing aurelia-templating-router... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-templating-router\dist\amd\aurelia-templating-router.js Tracing aurelia-testing... error c:\tmp\proj\playfield\aurelia-cli-test2\xxx\node_modules\aurelia-testing\dist\amd\aurelia-testing.js Writing app-bundle.js... Writing vendor-bundle.js... Finished 'writeBundles' Application Available At: http://localhost:9000 BrowserSync Available At: http://localhost:3001

Jenselme commented 8 years ago

It should work. I use a folder named app for my project without problem. Did you think to replace src by your project folder in aurelia_project/aurelia.json?

zamotany commented 8 years ago

@atsu85 you must have misconfigured aurelia_project/aurelia.json. First of all your node_modules are in xxx folder, not sure if that's desirable. Besides cli can't find scripts\text.js so maybe you forgot to change that in config or deleted it. It would help a lot if you could provide us with complete folder structure and aurelia.json.

atsu85 commented 8 years ago

@Jenselme, as I mentioned, just renaming src to app or xxx worked as expected after updating aurelia.json

atsu85 commented 8 years ago

@zamotany, see my previous comment - are You sure I misunderstood the aurelia.json? As I said

after renaming "src" folder to "xxx" and changing aurelia.json, tsconfig.json, aurelia-karma.js and app.spec.ts applications and tests work as expected (au run --watch and au run test), but after renaming the folder from "xxx" to "xxx/yyy" and updating previously mentioned conf files to reflect the cnage au run --watch produces errors

I don't understand why You though that i moved my node_modules also to xxx folder or why should i have moved them? I just wanted to relocate src folder.

zamotany commented 8 years ago

@atsu85 Log errors indicates that cli is looking for node_modules in wrong directory: aurelia-cli-test2\xxx\node_modules. Nevertheless I dig deeper into it and if you manually add dependencies for vendor-bundle.js with custom path and main then edit rest of the paths there, au build works, but when running it in browser I got error:

vendor-bundle.js:18782 Uncaught TypeError: Cannot convert undefined or null to object

So without editing aurelia-cli code to properly resolve paths, expected behaviour cannot be achieved. CLI assumes that node_modules are in parent directory of app source and use single ../. In you case they are in grandparent. That's the reason why it fails.

alpox commented 8 years ago

I have the same problem here. I have an ASP.NET 5 Multi-Project setup with one main Project (Web) and multiple other Modules which get loaded dynamically and hold views, css, javascript code and C# Code.

My desire is to be able to run the aurelia-cli from the root folder to collect everything from all modules and ouput them into the Web project wwwroot and later maybe even into a database.

I would like to hold the node_modules folder in the root folder which is not possible at the moment since when i set the paths.root in aurelia.json to src/Web/src, the node_modules folder cannot be located anymore.

I hope there will soon be a possibility to configure the node_modules path as well? Not sure how i should structure my app now.

EDIT: After some tests it seems that only changing the path to the node_modules folder wouldn't help. The build works fine with using the shorter path "root": "src" but the Environment.ts file gets pushed to the wrong folder (src/ of course) and the script tag injected to the page on load of index.html becomes src/main.js instead of something like "src/../scripts/app-bundle.js".

I guess the only way for now is to go with the skeleton setup which still works as expected. The cli would have been nice though.

EisenbergEffect commented 8 years ago

@atsu85 Is this still an issue?

atsu85 commented 8 years ago

I haven't tried aurelia-cli meanwhile, but I'll repeat the experiment and let You know.

atsu85 commented 8 years ago

@EisenbergEffect, Yes I have still the same problem after moving sources one level deeper(moving src->xxx is ok as it used to be, but moving xxx -> xxx/yyy causes problems).

I've created a public repo to demonstrate this problem. It includes commits for each change: 1) aurelia-cli version 0.20.1 - after creating project 2) changed src to xxx - updated aurelia conf so it should use xxx folder instead of src 3) moved src to xxx - actually moved all the files from src to xxx folder

at this point everything works, including au test and au run

4) changed xxx to xxx/yyy - updated aurelia conf so it should use xxx/yyy folder instead of original src folder (that was successfully renamed to xxx meanwhile) 5) moved xxx to xxx/yyy - actually moved all files to the folder specified by previous commit

at this point things start to go wrong:

c:\tmp\proj\aurelia\cli-experiment4>au run --watch
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'configureEnvironment'...
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
Finished 'buildTypeScript'
Starting 'writeBundles'...
Tracing app...
Tracing environment...
Tracing main...
Tracing resources/index...
Tracing app...
Tracing text...
error c:\tmp\proj\aurelia\cli-experiment4\xxx\scripts\text.js
Tracing aurelia-binding...
error c:\tmp\proj\aurelia\cli-experiment4\xxx\node_modules\aurelia-binding\dist\amd\aurelia-binding.js
Tracing aurelia-bootstrapper...
...

and lots of more errors like this (also browser doesn't load the Aurelia app - no errors in console or network tab tough).

Also tests fail:

c:\tmp\proj\aurelia\cli-experiment4>au test
Starting 'unit'...
06 10 2016 00:05:29.768:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
06 10 2016 00:05:29.801:INFO [launcher]: Starting browser Chrome
06 10 2016 00:05:31.127:INFO [Chrome 53.0.2785 (Windows 10 0.0.0)]: Connected on socket /#XJwQwJ8794mWZJR3AAAA with id 87816797
Chrome 53.0.2785 (Windows 10 0.0.0) ERROR
  Uncaught TypeError: Cannot read property 'initialize' of undefined
  at c:/tmp/proj/aurelia/cli-experiment4/test/unit/setup.js:3

06 10 2016 00:05:31.273:WARN [web-server]: 404: /base/xxx/yyy/app

{ uid: 0,
  name: 'unit',
  branch: false,
  error: 1,
  duration: [ 2, 34442283 ],
  time: 1475701531476 }
1

From the au run error there were 2 types of errors: 1) related to scripts folder 2) related to node_modules folder (lots of them)

atsu85 commented 8 years ago

Regarding the first error I found a manual workaround:

From the au run error there were 2 types of errors: 1) related to scripts folder

error c:\tmp\proj\aurelia\cli-experiment4\xxx\scripts\text.js I can see, that it searches scripts from incorrect folder - it should be c:\tmp\proj\aurelia\cli-experiment4\scripts\text.js instead. So I found out, that one specific occurrence of scripts in aurelia.json affects this - so i changed it and got rid of that specific error.


But I it didn't resolve the second type of errors:

2) related to node_modules folder (lots of them)

error c:\tmp\proj\aurelia\cli-experiment4\xxx\node_modules\aurelia-binding\dist\amd\aurelia-binding.js (that are related to node_modules folder) still remained.

However similar workaround with node_modules doesn't work, because other errors start popping up (even earlier compared to where they appeared in the log above) related to changed path: `c:\tmp\proj\aurelia\cli-experiment4>au run Starting 'readProjectConfiguration'... { uid: 2, name: 'readProjectConfiguration', branch: false, error: { Error: ENOENT: no such file or directory, open 'c:\tmp\proj\aurelia\cli-experiment4\node_modules2\aurelia-templating-resources\dist\amd\package.json'

This shows what happens if i change all occurences of "node_modules" in aurelia.json to smth like "node_modules1", "node_modules2", ... (which isn't correct, but it shows that in this case there were no errors previously in readProjectConfiguration when the errors showed up in writeBundles phase)

I don't have time to pinpoint the second problem related to node_modules folder but it seems to be related to writeBundles and probably related to path used on this line in package-analyzer.js

atsu85 commented 8 years ago

Oh, now i noticed, that there was in fact a PR by @alpox that he found incomplete, but that was related to package-analyzer.js as I suspected:

but it seems to be related to writeBundles and probably related to path used on this line in package-analyzer.js

@alpox, what are Your plans with that change? Have You had any progress with it?

@EisenbergEffect, what would be the easiest way to debug au run task with an IDE? Start some script manually from IDE?

alpox commented 8 years ago

@atsu85 What had success with it as soon as i set the useAbsolutePath property. I didn't explicitly test my PR for the use for using any source location, though i think its possible that it could work out. I primarily made it for allowing a deeper root path inside the project. (Not sure if backward paths work like ../../source/ but everything inside your aurelia folder should work with the PR). Seems though, that @EisenbergEffect didn't see this as an appropriate solution and he might be right. He didn't give any feedback on it though.

atsu85 commented 8 years ago

@alpox, I guess @EisenbergEffect either misunderstood Your commend:

Please do not integrate yet, i found that it cannot find the bundle anymore with deeper source folder ...

or he didn't notice the

Edit: Worked as soon as i added "useAbsolutePath": true for the build.targets (build.targets.useAbsolutePath = true)

and probably thought that it might be easier for You to open new PR when You figure out the issue You initially mentioned.

I think @EisenbergEffect didn't even look into Your changes, so I suggest You to send another PR.

EisenbergEffect commented 8 years ago

That's correct. I only saw "do not integrate". Please send a new PR. Sorry!

alpox commented 8 years ago

@EisenbergEffect oh my bad, i didn't communicate clearly :smiley: i'll send a new PR on time.

Alexander-Taran commented 6 years ago

merged: https://github.com/aurelia/cli/pull/427 can be closed