Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package api.addFiles accept wildcards / folders #7

Open
raix opened this issue Nov 20, 2014 · 21 comments
Open

Package api.addFiles accept wildcards / folders #7

raix opened this issue Nov 20, 2014 · 21 comments

Comments

@raix
Copy link
Contributor

raix commented Nov 20, 2014

Hugo Magalhaes: developing a application using the method suggested at http://www.matb33.me/2013/09/05/meteor-project-structure.html, so I have a package per feature and all the packages have the following structure:

-> client
    |-> sub_folder
    |   |-> file_1.js
    |   |->    ...
    |   |-> file_n.js
    |-> file_1.js
    |->    ...
    |-> file_n.js
-> lib
    |-> sub_folder
    |   |-> file_1.js
    |   |->    ...
    |   |-> file_n.js
    |-> file_1.js
    |->    ...
    |-> file_n.js
-> server
    |-> sub_folder
    |   |-> file_1.js
    |   |->    ...
    |   |-> file_n.js
    |-> file_1.js
    |->    ...
    |-> file_n.js

Trying to find a way to add all files from each folder (and sub-folder in the following way):

api.add_files(["client/*","client");
api.add_files(["lib/*", ["client", "server"]);
api.add_files(["server/*","server");
@raix
Copy link
Contributor Author

raix commented Nov 20, 2014

+1
Could be a better pattern when control files arrive?

@HugoMag
Copy link

HugoMag commented Nov 20, 2014

+1

1 similar comment
@IstoraMandiri
Copy link

👍

@dandv
Copy link
Member

dandv commented Nov 21, 2014

Great idea! (and pretty obvious... hey @ekatek)

@dcsan
Copy link

dcsan commented Nov 21, 2014

there is something like this

but it got confusing when using PACKAGE_DIRS to load files while in local dev mode.

packages in production have the "author:package" prefix when bundled but path.resolve(".") seems to work for this.

"client/* would be soo much cleaner!

@cvrebert
Copy link

So, someone should file an issue upstream?

@mitar
Copy link

mitar commented Dec 18, 2014

+1

@mitar
Copy link

mitar commented Dec 18, 2014

So, someone should file an issue upstream?

This is a feature request, there is no place to file this upstream.

@mitar
Copy link

mitar commented Dec 18, 2014

It would be also great if package could traverse directories, so that one would not have to hard-code the paths but allow self-discovery: meteor/meteor#2626

@awgneo
Copy link

awgneo commented Apr 1, 2015

+1

@raix
Copy link
Contributor Author

raix commented Apr 1, 2015

PR added, more for discussion - you are wellcome to join in working on the pr. raix:package-api-addfiles-accept-wildcards#4088

Some of the comments are off talking about Arrays, needs tests+documentation writing before it can be merged - but let's get a "go" from core before polishing.

At the moment its not recursive - but we could replace the fs.readdirSync with a fs.readdirRecursiveSync fictive name

Comments / ideas etc. are welcome - also please clone/checkout the branch and se if its working.

Kind regards Morten

@fabyeah
Copy link

fabyeah commented Oct 10, 2015

+1

@thpham
Copy link

thpham commented Oct 13, 2015

+1 really urgently needed !

@AddoSolutions
Copy link

+1

@maxenceC
Copy link

maxenceC commented Mar 3, 2016

Any update on this ?

@omidahourai
Copy link

+1

@wilau2
Copy link

wilau2 commented Jun 14, 2016

+1
updates ?

@mikeifomin
Copy link

@wilau2 use ecmascript imports

example in coffeescript

{ Template } = require 'meteor/templating'

require './someTemplate.html'
require './someTemplate.scss'

Template.someTemplate.onCreated ->
   # do some 

So in Meteor 1.3+ packages You does not actual use api.addFile for all of templates/styles

Just create a single entrypoint in pacakge.js

api.mainModule('main.coffee');

@ahmedtabrez
Copy link

👍

1 similar comment
@stefanocudini
Copy link

+1

@stefanocudini
Copy link

It's a good temporary solution?

Package.onUse(function(api) {
  var path = Npm.require('path'),
      glob = Npm.require('glob'),
      files = glob.sync('client/**/*js', {cwd: path.join(path.resolve('.'), 'packages'));
  api.addFiles(files, ['client']);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests