Package API extension to recursively scan package assets/files

Hi, everybody I need your opinion/feedback on my new package:


Copying README:

Meteor Api folder walker

The package will define getFilesFromFolder method in Package API instance which will recusively scan given folder and returns all files under this folder.


mkdir packages 
cd packages 
git clone 
meteor add kschingiz:api-folder-walker

!!!Installing from atmosphere repository will not work!!!


Package.onUse(api => {
  // just to make sure it's initialized before your package

  const assets = api.getFilesFromFolder('myPackage', 'assets');
  api.addAssets(assets, 'server');

  const files = api.getFilesFromFolder('myPackage', 'src');
  api.addFiles(files, 'server');


The problem

If you are developing meteor packages you will have lots of files and assets:

- assets
  - asset1
  - asset2
  - asset3
  - asset4
  - asset5

You will need to register/add those assets into package API in order to use them:

Package.onUse(api => {
    ['assets/asset1', 'assets/asset2', 'assets/asset3', 'assets/asset4', 'assets/asset5'],

When some asset changes it’s name, deleted or you have added new assets/file, you are going to fix package.js again and again.
Imagine if you have +100 assets, listing them all manually is time consuming.
Meteor does not provide a method of adding assets like:

Package.onUse(api => {
  api.addAssets(['assets/*'], 'server');



The package adds new method into Package API

api.getFilesFromFolder(myPackage, folderToScan);

The method scans folderToScan under myPackage and return all files:

Package.onUse(api => {
  const assets = api.getFilesFromFolder('myPackage', 'assets');
  api.addAssets(assets, 'server');

So you don’t need to manually manage arrays of assets and files

Credits to “saimeunt” user:


Hi, that sounds great for writing more packages! I didn’t check out the implementation yet but if it’s solid I’m sure it’ll be of great help to many.

Hi everybody, please don’t use atmosphere to install the package, installation steps are described in github.

@kschingiz does the package ensure, that the assets are cacheable on the client?

no, it reads only current files and folder. It may miss cached object which does not exist.