@vlr/bucket-gen v2.0.0
@vlr/bucket-gen
This generator creates index.ts files.
usage convention
It is recommended to create index file only for your types and interfaces, never for the code. \ For example, I use following naming convention for code. \ user.type.ts - file containing interface User {...}, which describes BL level entity. \ user.model.ts - file containing interface UserModel {...}, which describes REST API level entity. \ user.service.ts - file containing class UserService. \ ...and so on \ And then I generate buckets only for following file types: type, model, const, enum, ctor
const and enum files are self explanatory and ctor files are generated by @vlr/type-constructor-gen
usage
import { generateBuckets } from "@vlr/bucket-gen";
import { transformRange } from "@vlr/gulp-transform";
const options = { lineFeed: "\n", quotes: "\"", aliasMap: {} };
gulp.task("generate-buckets", function () {
const types = ["type", "model", "ctor", "const", "enum"];
const files = types.map(type => `${settings.appPath}/**/*.${type}.ts`);
return gulp.src(files)
.pipe(transformRange(files => generateBuckets(files, options)))
.pipe(gulp.dest(settings.appPath));
});
@vlr/gulp-transform gulp plugin is used for all my generators. \ All fields in options are optional, linefeed and quotes are the symbols to use in the output file. \ aliasMap option is irrelevant here.