gulp-bem / gulp-bem-src

DEPRECATED repository, moved to https://github.com/bem/gulp-bem/tree/master/packages/gulp-bem-src
7 stars 0 forks source link

Primary functionality #2

Open qfox opened 8 years ago

qfox commented 8 years ago

It should realize this:

const src = require('gulp-bem-src');

src({
  config: BemConfig,
  sources: String[],
  bemdecl: *,
  techs: String[],
  techsAliases: ?Object<String,String[]>
}): Stream<BemVinyl?>

class BemVynil extends Vynil {
  entity: BemEntity
}
blond commented 8 years ago

I think we can move sources options to first argument:

const src = require('gulp-bem-src');

src(String[], {
  config: BemConfig,
  bemdecl: *,
  techs: String[],
  techsAliases: ?Object<String,String[]>
}): Stream<BemVinyl?>

Reasons:

  1. The sources option is required.
  2. This API is more like a gulp.src()
blond commented 8 years ago

The config option is not required. If this option is not specified we should find .bemrc file in project root.

blond commented 8 years ago

Alse we should support gulp.src options: https://github.com/gulpjs/vinyl-fs#options

blond commented 8 years ago

techsAliases: ?Object<String,String[]>

techsAliases -> techAliases?

blond commented 8 years ago
class BemVynil extends Vynil {
  entity: BemEntity
}

I think we should use native Vynil.

vithar commented 8 years ago

The config option is not required. If this option is not specified we should find .bemrc file in project root.

I suggest to lookup .bemrc from gulpfile directory and further as usual.

qfox commented 8 years ago

This API is more like a gulp.src()

In gulp.src we have src(globs[, options]) in opposite to src(levels[, options]), it's an incorrect comparison at my pov.

With the idea to put required options as soon as possible, I'd say we should put declaration as the first argument because its like globs just for bem project instead of pure fs.

Alse we should support gulp.src options: https://github.com/gulpjs/vinyl-fs#options

Good point!

According to all comments seems like it should looks like this:

src(decl: Tenorok[], techs: String|String[], [, options: {
  config: ?BemConfig, // Should be loaded from .bemrc by default
  sources: ?String[], // Should use levels from config by default and throw if nothing found
  techAliases: ?Object<String,String[]> // Should use aliases from .bemrc if any

  // vfs.src options:
  buffer: Boolean=true,
  read: Boolean=true,
  since: ?(Date|Number),
  stripBOM: Boolean=true,
  passthrough: Boolean=false,
  sourcemaps: Boolean=false,
  followSymlinks: Boolean=true, // we should pass it to bem-walk?
  dots: Boolean=false // pointless?,
  // etc.
}]): Stream<Vinyl>

Like that, right? I suggest to support them (all set of options) iteratively to not block anything else.

blond commented 8 years ago

In gulp.src we have src(globs[, options]) in opposite to src(levels[, options]), it's an incorrect comparison at my pov.

I think we should support globs.

bemSrc('*.blocks', {...})

Also we can use globs as bemdecl or techs options:

bemSrc('*.blocks/button/**', {...})

With the idea to put required options as soon as possible, I'd say we should put declaration as the first argument because its like globs just for bem project instead of pure fs.

In some projects we can build only one bundle with all sources.

qfox commented 8 years ago

I think we should support globs.

I think it's not blocking feature so we can do it later ;-)