Commit Graph

62 Commits

Author SHA1 Message Date
Hugh Willson
4a10a1b26b Making sure asset filenames are Unicode normalized when loaded (to help address issue #5626). 2016-11-30 20:31:37 -05:00
Ben Newman
817876f7b3 Use optimistic functions in PackageSource#initFromPackageDir. 2016-10-07 19:31:17 -04:00
Ben Newman
14ee8775c3 Decompose PackageNamespace, PackageNpm, and PackageCordova classes.
Similar to the treatment given to PackageAPI in my commit
af50b4cc5b.

This clear separation of concerns will be helpful for optimizing
PackageSource#initFromPackageDir.
2016-10-06 17:39:23 -04:00
Ben Newman
4c1fe8ff22 Convert options.npmDir only if it's a string. 2016-08-17 18:18:07 -04:00
Ben Newman
61c1ab0cac Avoid colons in .npm/plugin/... paths.
Fixes #7661.
2016-08-17 18:08:29 -04:00
Tom Coleman
696de36549 More subtle logic for deciding when test files should be lazily loaded
The logic at the top of this function was basically just for the case of
"file is in imports but also a test file". But the logic caught up some
other edge cases, such as "file is in node_modules but also a test file".
2016-07-27 16:15:51 +10:00
Ben Newman
b14fb05128 In node_modules directories, cache packageSource._findSources.
This caching vastly reduces the amount of work _findSources must do when
the server restarts, at the small cost of ignoring new files added within
node_modules subdirectories. Even if you have to restart the server when
you add a file to node_modules (super rare), that's still MUCH better than
waiting for _findSources to rescan the node_modules directory every time
the server restarts.

Part of #7253 and #7008.
2016-06-22 14:45:11 -04:00
Ben Newman
a2e380d154 Cache files.{stat,lstat,realpath,readdir} hierarchically.
Passing a function to files.withCache invokes the function and causes the
results of these four files.* methods to be cached for the duration of the
function invocation.

Part of #7253 and #7008.
2016-06-22 14:41:54 -04:00
Ben Newman
3f9b8c2566 Watch package.json files in addition to package.js files. 2016-05-18 16:37:36 -04:00
Ben Newman
de5411e8fd Allow importing from app node_modules when running test-packages.
Fixes #6827.
2016-05-16 18:21:08 -04:00
Tom Coleman
01a745a99d Ensure that test files for both kinds of tests.
Fixes #6901 by ensuring that we short circuit laziness detection for test files in both modes.
2016-05-10 16:58:59 -07:00
Ben Newman
12d2d4229d When testing, load test files in imports directories eagerly.
Fixes #6831.
2016-04-18 10:34:10 -04:00
Ben Newman
d287681868 Don't interfere with explicit sourceReadOptions.names.
Fixes #6787.
2016-04-11 17:02:10 -04:00
Ben Newman
a073280e3f Ignore nested node_modules directories if parent contains no sources.
This in important optimization for #6037, and it also fixes #6627, since
we are now registering watchSet dependencies on the contents of
node_modules directories.
2016-04-08 11:11:01 -04:00
Ben Newman
43659ff561 Search local node_modules directories for non-.js(on) source files.
Part of #6037.
2016-04-08 11:11:01 -04:00
Ben Newman
eb18d59faa Make all files in imports and node_modules directories lazy.
The most notable change here is that we now treat files in app imports
directories as lazy even before we know whether the app is using modules.
This could be a breaking change for some 1.3 apps that do not use modules
but have imports directories containing eager .js files. That (very minor)
level of backwards incompatibility seems acceptable in the context of
upgrading to Meteor ~1.3, however.
2016-04-08 11:10:52 -04:00
Ben Newman
b1c3f22ff4 Make quiet symlink loop checking the default.
Fixes #6665.
2016-04-07 13:05:52 -04:00
Ben Newman
3417f104eb Stop deleting nonexistent pre-linker files.
This one weird trick saves ~800 calls to files.rm_recursive on every
rebuild, or ~300 milliseconds of rebuild time.
2016-03-14 13:40:02 -04:00
Ben Newman
26e3cd7df2 Make sure <bundle>/npm/ contains all node_modules directories. 2016-03-07 19:41:15 -05:00
Tom Coleman
ab5ab15768 Rename test-app -> test and test --full-app
Our old "unit" test mode didn't really enforce "unit-ness" and was perfectly capable of running integration test. So it was confusing to call the two modes unit and integration test modes.

Instead, we call them "test mode" and "full app test mode", run with `meteor test` and `meteor test --full-app`.

The rules for test files were also simplified -- simply *.test[s].* for test mode, and *.app-test[s].* for full app tests. `tests/` directories are simply ignored again.
2016-02-29 11:16:54 +11:00
Tom Coleman
0cee429c7f Add a new file regexp for unit and integration tests
You can now differentiate test files based on their filename.

Also added an exclude for the acceptance-tests folder in all situations.

#6321
2016-02-29 11:11:44 +11:00
Tom Coleman
a22b7e4eff Fix bug where app would restart when you changed a test 2016-02-29 11:11:44 +11:00
Avital Oliver
dfe3853f2f Refactor test filename matching code
Now, all the code describing which files represent
test files in an app is in `tools/isobuild/app-test-files.js`,
and there is no code duplication.
2016-02-22 04:10:13 -08:00
Avital Oliver
cf5cd7bb7e meteor test-app --unit now finds files in imports/ 2016-02-16 14:28:16 -08:00
Avital Oliver
9ec968ec65 WIP: Include test files in imports/ directories 2016-02-16 12:15:56 -08:00
Avital Oliver
83922dfc3a Start support for unit tests.
You can now run `meteor test-app --unit` to load just test files
and their dependencies.

Also, `Meteor.isIntegrationTest` and `Meteor.isUnitTest` are now
available on the client side of your apps. This can be used to
only run some tests in either mode.

TODO: Find unit tests inside imports/ directories even if they're
not explicitly imported.
2016-02-16 09:32:05 -08:00
Avital Oliver
0deeda7be2 Merge branch 'release-1.3' into app-tests 2016-02-15 22:22:48 -08:00
Ben Newman
1437e07ee5 Forbid server bundles from importing client-only files.
This partially reverts 35a02864af, and also
fixes #6182.
2016-02-11 11:41:39 -05:00
Ben Newman
35a02864af Allow client modules to be imported by server modules. 2016-02-05 18:37:54 -05:00
Avital Oliver
a335875e19 Merge remote-tracking branch 'origin/release-1.3' into app-tests 2016-02-05 14:57:44 -08:00
Avital Oliver
43bb94cccc Don't ignore tests/ when running meteor test-app. 2016-02-05 11:43:15 -08:00
Ben Newman
4c890ac20d Use Babel 6 to implement ECMAScript 2015+ in tool code.
Note that `export default` no longer modifies `module.exports`, but simply
defines `exports.default`, so these two import styles will work:

  import DefaultExport from "./export-default-module.js"; // preferred
  var DefaultExport = require("./export-default-module.js").default;

but this style will no longer work:

  var DefaultExport = require("./export-default-module.js");
2016-02-04 21:37:34 -05:00
Avital Oliver
6682972c3a Implement "testOnly" packages
These packages are only bundled with the app when running
`meteor test-app`.
2016-02-01 22:18:00 -08:00
Avital Oliver
ac5a4bc809 WIP: Implement a meteor test-app command.
This command builds the app with a different directory for
`.meteor/local`, including built packages and the app database. This
allows running `meteor test-app` and `meteor test` in parallel
for a given app, with DB isolation.

Also, we've changed how test driver packages work (as used for
`meteor test-packages`, like "test-in-browser"). Instead of automatically
running tests when they load, they export a `runTests` function that
you should call when you're ready to run tests.

When running `meteor test-app` or `meteor test-packages` a new additional
last line of code is added that calls `Meteor.startup(...runTests()...)`

TODO:
* Implement `testOnly` packages. The current pattern of reading a global
  from `package.js` won't work for published packages, which are stored
  as metadata, not code.
* Let you choose a test driver package as an argument to `meteor test-app`
* Demonstrate that a Mocha test and driver package are possible to write.
* Expose Meteor.isTest, Meteor.isIntegrationTest, Meteor.isUnitTest
* Implement `meteor test-app --unit` which only loads test files
* `meteor test-app` should load ALL *.tests?.* files, including ones
  inside imports/ directories
2016-01-22 15:18:10 -08:00
Ben Newman
fff2e46661 Process all package source files with compiler plugins.
Files not explicitly added with api.addFiles are currently ignored by the
Linker, but that will change once we have a module system.
2015-12-09 14:29:53 -05:00
Ben Newman
5883c3feb7 Decompose PackageSource#_find{Sources,Assets} methods. 2015-12-09 14:29:53 -05:00
Ben Newman
7c15fb5c8a Decompose a reusable SymlinkLoopChecker class. 2015-12-09 14:29:53 -05:00
Ben Newman
1e4e67df5a Turn readAndWatchDirectory into a helper method. 2015-12-09 14:29:53 -05:00
Ben Newman
6733e21975 Convert SourceArch to an ES2015 class and move it to its own module. 2015-12-09 14:29:52 -05:00
Tom Coleman
60e378f8f6 It turns out file:// paths *do not* currently work with NPM 2015-11-25 17:39:52 +11:00
Tom Coleman
0a9866ed76 Added some documentation and history about git change. 2015-11-25 17:21:44 +11:00
Tom Coleman
705a7eda1a Switch the semantics - forNpm -> forCordova
Cordova uses npm but is *more* specific so this is less potentially confusing.
2015-11-25 16:27:36 +11:00
Tom Coleman
54396f78b7 Switch semantics to isValidVersion 2015-11-25 16:27:36 +11:00
Tom Coleman
222115665b Refactored isExactVersionto handle npm/cordova
See https://github.com/meteor/meteor/pull/5562/files for a discussion. Basically Cordova doesn't really support

a) Urls with @'s in them
b) Urls that don't point to fixed commits.

As this branch allows both of the above (and our NPM support does reasonably handle a+b), we split the way we handle cordova + npm URLs a little.
2015-11-25 16:27:35 +11:00
Ben Newman
ed17924940 Add braces to every if/for(-in)/while statement in tools directory. 2015-11-13 12:25:19 -05:00
Sashko Stubailo
38c4be2bd1 Fix typo in docs
Fixes #5554
2015-11-03 13:55:02 -08:00
Ben Weissmann
f68cf5c79f Fix documentation for Cordova.depends
* Fix broken link to Github cordova documentation.
* Fix invalid Github tarball URL example
2015-10-19 19:38:22 -04:00
Sashko Stubailo
0bb7c7c0b2 New addAssets package.js API; same file can be source and asset
1. Add `addAssets` API to `package.js`
2. Rename `getSourcesFunc` to `getFiles` in internal code
3. Changed `PackageAPI#sources` to `PackageAPI#files` with a new structure that
   has separate objects for assets and sources
4. Added some tests for different error conditions
5. The same file can now be a source and an asset
2015-09-02 13:14:02 -07:00
David Greenspan
c3c07f74a1 Don't add imports of prodOnly packages in compiler
The compiler inserts code that imports the exports of used packages.
It's important that we don't do this for the exports of used
debugOnly and prodOnly packages, because the inserted code will
fail at runtime if the packages are not linked in because we aren't
in dev mode or aren't in prod mode.
2015-08-07 09:28:37 -07:00
David Greenspan
621617d868 Document debugOnly and prodOnly 2015-08-06 16:49:27 -07:00