@plotdb/srcbuild 0.0.57 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,6 +103,10 @@ Except common options, each builder may support different options:
103
103
  - `false`: all files in `configFile` are relative to current working directory.
104
104
  - `true`: all files in `configFile` are relative to the directory containing `bundle.json`
105
105
  - or, specific a path as the relative root.
106
+ - `manager`: block manager, optional. required for @plotdb/block bundling.
107
+ - can be either an `block.manager` object, or ...
108
+ - a function returning such object which accepts an object with following fields as parameter:
109
+ - `base`: the base dir of this bundle.
106
110
  - `config`: bundle configuration in following format:
107
111
  {
108
112
  "css": {
package/dist/ext/base.js CHANGED
@@ -17,12 +17,21 @@ basebuild.prototype = import$(Object.create(Object.prototype), {
17
17
  purge: function(files){},
18
18
  resolve: function(file){},
19
19
  init: function(opt){
20
- var this$ = this;
20
+ opt == null && (opt = {});
21
+ this.initVars(opt);
22
+ this.initAdapter(opt);
23
+ return this;
24
+ },
25
+ initVars: function(opt){
21
26
  opt == null && (opt = {});
22
27
  this.log = opt.logger || aux.logger;
23
28
  this.base = opt.base || this.base || '.';
24
29
  this.srcdir = path.normalize(path.join(this.base, opt.srcdir || this.srcdir || '.'));
25
- this.desdir = path.normalize(path.join(this.base, opt.desdir || this.desdir || '.'));
30
+ return this.desdir = path.normalize(path.join(this.base, opt.desdir || this.desdir || '.'));
31
+ },
32
+ initAdapter: function(opt){
33
+ var this$ = this;
34
+ opt == null && (opt = {});
26
35
  this.adapter = new adapter({
27
36
  base: this.srcdir,
28
37
  getDependencies: function(it){
@@ -41,8 +50,7 @@ basebuild.prototype = import$(Object.create(Object.prototype), {
41
50
  return this$.resolve(file);
42
51
  }
43
52
  });
44
- this.adapter.init();
45
- return this;
53
+ return this.adapter.init();
46
54
  },
47
55
  getAdapter: function(){
48
56
  return this.adapter;
@@ -17,7 +17,8 @@ spec = function(o){
17
17
  type: o.type,
18
18
  codesrc: o.codesrc,
19
19
  specsrc: o.specsrc,
20
- deps: o.deps
20
+ deps: o.deps,
21
+ src: o.src
21
22
  }));
22
23
  this.type = (ref$ = this.o).type;
23
24
  this.name = ref$.name;
@@ -37,7 +38,8 @@ spec.prototype = import$(Object.create(Object.prototype), {
37
38
  return ref$ = {
38
39
  codesrc: Array.from(this.codesrc),
39
40
  specsrc: Array.from(this.specsrc),
40
- deps: Array.from(this.deps)
41
+ deps: Array.from(this.deps),
42
+ src: Array.from(this.src)
41
43
  }, ref$.type = this.type, ref$.name = this.name, ref$;
42
44
  },
43
45
  cacheFn: function(){
@@ -315,22 +317,29 @@ specmgr.prototype = import$(Object.create(Object.prototype), {
315
317
  }
316
318
  });
317
319
  build = function(o){
320
+ var opt;
318
321
  o == null && (o = {});
319
- this.mgr = o.manager;
322
+ opt = import$({
323
+ srcdir: 'static',
324
+ desdir: 'static'
325
+ }, o);
326
+ this.initVars(opt);
327
+ this.mgr = typeof o.manager === 'function'
328
+ ? o.manager({
329
+ base: this.base
330
+ })
331
+ : o.manager;
320
332
  this.defcfg = o.config || null;
321
333
  this.cachedir = path.join(o.base || '.', '.bundle-dep');
322
334
  this.cfgfn = o.configFile ? path.join(o.base || '.', o.configFile) : null;
323
335
  this.reldir = typeof o.relativePath === 'string'
324
336
  ? o.relativePath
325
- : o.relativePath && this.cfgfn
337
+ : (!(o.relativePath != null) || o.relativePath) && this.cfgfn
326
338
  ? path.dirname(this.cfgfn)
327
339
  : process.cwd();
328
340
  this.log = o.logger || aux.logger;
329
341
  this.reload();
330
- this.init(import$({
331
- srcdir: 'static',
332
- desdir: 'static'
333
- }, o));
342
+ this.initAdapter(opt);
334
343
  return this;
335
344
  };
336
345
  build.prototype = import$(Object.create(base.prototype), {
@@ -352,10 +361,10 @@ build.prototype = import$(Object.create(base.prototype), {
352
361
  },
353
362
  reload: function(){
354
363
  this.reset();
355
- this.loadCfg({
364
+ this.loadCaches();
365
+ return this.loadCfg({
356
366
  init: true
357
367
  });
358
- return this.loadCaches();
359
368
  },
360
369
  reset: function(){
361
370
  var this$ = this;
@@ -558,6 +567,9 @@ build.prototype = import$(Object.create(base.prototype), {
558
567
  return fs.ensureDir(desdir).then(function(){
559
568
  var ps;
560
569
  if (type === 'block') {
570
+ if (!this$.mgr || !this$.mgr.bundle) {
571
+ throw new Error("block bundling requires manager of @plotdb/block provided via bundler option.");
572
+ }
561
573
  return this$.mgr.bundle({
562
574
  blocks: spec.src
563
575
  }).then(function(ret){
@@ -622,7 +634,9 @@ build.prototype = import$(Object.create(base.prototype), {
622
634
  return ret;
623
635
  })['catch'](function(e){
624
636
  this$.log.error((des + " failed: ").red);
625
- return this$.log.error(e.message.toString());
637
+ return this$.log.error({
638
+ err: e
639
+ }, e.message.toString());
626
640
  });
627
641
  });
628
642
  }
package/dist/ext/pug.js CHANGED
@@ -131,16 +131,20 @@ pugbuild.prototype = import$(Object.create(base.prototype), {
131
131
  src: list,
132
132
  specsrc: _opt.filename
133
133
  };
134
- this$.bundler.addSpec(spec);
135
- des = this$.bundler.desPath(spec);
136
- relDesMin = path.relative(this$.desdir, des.desMin);
137
- relDes = path.relative(this$.desdir, des.des);
138
- if (o.type === 'css') {
139
- return ret += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/" + relDesMin + "\"/>";
140
- } else if (o.type === 'js') {
141
- return ret += "<script type=\"text/javascript\" src=\"/" + relDesMin + "\"></script>";
142
- } else if (o.type === 'block') {
143
- return ret += "<link rel=\"block\" href=\"/" + relDesMin + "\">";
134
+ if (this$.bundler) {
135
+ this$.bundler.addSpec(spec);
136
+ des = this$.bundler.desPath(spec);
137
+ relDesMin = path.relative(this$.desdir, des.desMin);
138
+ relDes = path.relative(this$.desdir, des.des);
139
+ if (o.type === 'css') {
140
+ return ret += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/" + relDesMin + "\"/>";
141
+ } else if (o.type === 'js') {
142
+ return ret += "<script type=\"text/javascript\" src=\"/" + relDesMin + "\"></script>";
143
+ } else if (o.type === 'block') {
144
+ return ret += "<link rel=\"block\" href=\"/" + relDesMin + "\">";
145
+ }
146
+ } else {
147
+ return ret += "<!-- no bundler available for bundling " + name + " in type " + o.type + " -->";
144
148
  }
145
149
  });
146
150
  return ret;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "zbryikt",
3
3
  "name": "@plotdb/srcbuild",
4
- "version": "0.0.57",
4
+ "version": "0.0.59",
5
5
  "description": "",
6
6
  "main": "./dist/main.js",
7
7
  "files": [