lincd-cli 0.1.4 → 0.1.5

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.
@@ -1,161 +1,161 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- /// <reference path="colors.d.ts" />
4
- var colors = require("colors");
5
- var included = [];
6
- var exportRoot = '/lib';
7
- var libraryName = 'lincd';
8
- var lincdModules = new Map();
9
- //This function determines which modules that are requested by the module being built are external
10
- //it basically turns every import from @dacore/[something] request into a lookup for that class/object in the global daCore object (which BrowserCore maintains when modules register themselves)
11
- //See also: https://webpack.js.org/configuration/externals/
12
- var externaliseModules = function (config, es5) {
13
- function debug() {
14
- var msgs = [];
15
- for (var _i = 0; _i < arguments.length; _i++) {
16
- msgs[_i] = arguments[_i];
17
- }
18
- msgs.unshift('externals: ');
19
- if (config && config.debug) {
20
- console.log.apply(null, msgs);
21
- }
22
- }
23
- function log() {
24
- var msgs = [];
25
- for (var _i = 0; _i < arguments.length; _i++) {
26
- msgs[_i] = arguments[_i];
27
- }
28
- msgs.unshift('externals: ');
29
- console.log.apply(null, msgs);
30
- }
31
- //return the function that is handed to webpack in the 'externals' option.
32
- //it determines for each request what is external and what is not
33
- return function (context, request, callback) {
34
- if (config.externals && config.externals[request]) {
35
- debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
36
- // return callback(config.externals[request]);
37
- return callback(null, 'var ' + config.externals[request]);
38
- }
39
- if (config.externals && config.externals[request]) {
40
- debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
41
- // return callback(config.externals[request]);
42
- return callback(null, 'var ' + config.externals[request]);
43
- }
44
- //log(colors.gray(request));
45
- //"@dacore/core/foo" => "daCore.core.foo"
46
- // if (/^\@dacore\//.test(request)) {
47
- //remove @dacore/
48
- // if (request.indexOf('@dacore') !== 0) {
49
- // console.warn(
50
- // colors.red('this plugin currently works with @dacore modules only'),
51
- // );
52
- // return;
53
- // }
54
- // debug(colors.green('request: ' + request));
55
- if (request.substr(0, 1) == '.' || request.substr(0, 1) == '/') {
56
- // debug('skipping local');
57
- callback();
58
- return;
59
- }
60
- if (request.indexOf('lincd/') === 0 && es5) {
61
- // var result = request.replace("@dacore/core/","@dacore/core-es5/");
62
- // debug('Requested ES6 for ES5 target: '+colors.yellow(request) + ' => ' + colors.cyan(result));
63
- debug('Requested ES6 for ES5 target: ' + colors.yellow(request));
64
- // return callback(null, 'commonjs '+result);
65
- }
66
- //get module name without @dacore
67
- // var transformed = request.substr(8);
68
- var moduleName = request.indexOf('/') !== -1
69
- ? request.substr(0, request.indexOf('/'))
70
- : request;
71
- //if this module is listed as internal module in the config
72
- if (config &&
73
- config.internals &&
74
- config.internals.indexOf(moduleName) !== -1) {
75
- //then don't exclude and don't continue this function
76
- //only log once
77
- if (included.indexOf(moduleName) !== -1) {
78
- included.push(moduleName);
79
- }
80
- debug(colors.blue('marked internal & will be included: ' + request));
81
- return callback();
82
- }
83
- //check if this module is a lincd module
84
- if (!lincdModules.has(moduleName)) {
85
- // debug(colors.green('checking ' + moduleName + '/package.json'));
86
- var isLincdModule = void 0;
87
- var modulePackage = void 0;
88
- try {
89
- modulePackage = require(moduleName + '/package.json');
90
- }
91
- catch (e) {
92
- debug(colors.red(moduleName + '/package.json' + ' does not exist'));
93
- return callback();
94
- }
95
- isLincdModule = modulePackage.lincd && true;
96
- if (isLincdModule) {
97
- debug(colors.magenta(modulePackage.name +
98
- ' is a lincd module, imports will be excluded from this bundle and refer to a global variable instead'));
99
- }
100
- else {
101
- debug(modulePackage.name +
102
- ' is NOT a linked module, it will be included in the bundle');
103
- }
104
- lincdModules.set(moduleName, isLincdModule && true);
105
- }
106
- if (lincdModules.get(moduleName) !== true) {
107
- return callback();
108
- }
109
- //remove export root path (for example with @dacore/core/lib/models: the core module has lib/ as root, so to get to the exported path dacore.core.UriResource we need to remove it)
110
- var cleanRequest = request.replace(exportRoot, '');
111
- var targetVariable;
112
- //expects a flat export / global tree with all the modules classes
113
- //replace - by _ and remove es5, because both es6 and es5 modules will be listed under the bare module name in the global treemap
114
- var firstSlash = cleanRequest.indexOf('/');
115
- //if importing {x} from "lincd" (so directly from library without any paths)
116
- if (firstSlash === -1 && cleanRequest == libraryName) {
117
- //then we refer straight to the global object
118
- targetVariable = libraryName;
119
- }
120
- else {
121
- //for all other cases, there is slash, so lets split module before the first slash and classname after the last slash
122
- var module_1 = cleanRequest
123
- .substr(0, firstSlash)
124
- .replace(/-/g, '_')
125
- .replace('_es5', '');
126
- var className = cleanRequest
127
- .substr(cleanRequest.lastIndexOf('/') + 1)
128
- .replace(/-/g, '_');
129
- if (module_1 == libraryName) {
130
- //the library itself should directly expose the main class of each file for clean variable names
131
- targetVariable = libraryName;
132
- //targetVariable = libraryName + '.' + className;
133
- }
134
- else {
135
- //reading this back I'm not sure why module would be empty?
136
- //Note: we don't include className here anymore, since all linked Components/Utils register themselves as libraryName._modules.moduleName.ComponentName
137
- //and we don't do default exports, so the import would be `import {ComponentName} from 'foo'` OR `import {ComponentName} from 'foo/lib/components/ComponentName'`
138
- //Typescript then translates `ComponentName` to `ComponentName_1.ComponentName` in the javascript output
139
- //And when we build the tree, we put each individual exports of linked components directly under `lincd._modules.moduleName`
140
- //so here we return the entire module as the result of such imports
141
- //and ComponentName_1 will contain all things linked/exported by the module
142
- //and ComponentName_1.ComponentName resolves to the desired class/function
143
- targetVariable = libraryName + '._modules.' + module_1;
144
- //import {PersonView} from 'lincd-test/lib/PersonView';
145
- //lincd._modules.lincd_test
146
- //PersonView_1
147
- //PersonView_1.PersonView --> lincd._modules.lincd_test.PersonView
148
- // targetVariable =
149
- // libraryName +
150
- // '.' +
151
- // (module ? '_modules.' + module + '.' : '') +
152
- // className;
153
- }
154
- }
155
- debug(colors.yellow(request) + ' => ' + colors.cyan(targetVariable));
156
- //See also: https://webpack.js.org/configuration/externals/
157
- return callback(null, 'var ' + targetVariable);
158
- // }
159
- };
160
- };
161
- exports["default"] = externaliseModules;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ /// <reference path="colors.d.ts" />
4
+ var colors = require("colors");
5
+ var included = [];
6
+ var exportRoot = '/lib';
7
+ var libraryName = 'lincd';
8
+ var lincdModules = new Map();
9
+ //This function determines which modules that are requested by the module being built are external
10
+ //it basically turns every import from @dacore/[something] request into a lookup for that class/object in the global daCore object (which BrowserCore maintains when modules register themselves)
11
+ //See also: https://webpack.js.org/configuration/externals/
12
+ var externaliseModules = function (config, es5) {
13
+ function debug() {
14
+ var msgs = [];
15
+ for (var _i = 0; _i < arguments.length; _i++) {
16
+ msgs[_i] = arguments[_i];
17
+ }
18
+ msgs.unshift('externals: ');
19
+ if (config && config.debug) {
20
+ console.log.apply(null, msgs);
21
+ }
22
+ }
23
+ function log() {
24
+ var msgs = [];
25
+ for (var _i = 0; _i < arguments.length; _i++) {
26
+ msgs[_i] = arguments[_i];
27
+ }
28
+ msgs.unshift('externals: ');
29
+ console.log.apply(null, msgs);
30
+ }
31
+ //return the function that is handed to webpack in the 'externals' option.
32
+ //it determines for each request what is external and what is not
33
+ return function (context, request, callback) {
34
+ if (config.externals && config.externals[request]) {
35
+ debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
36
+ // return callback(config.externals[request]);
37
+ return callback(null, 'var ' + config.externals[request]);
38
+ }
39
+ if (config.externals && config.externals[request]) {
40
+ debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
41
+ // return callback(config.externals[request]);
42
+ return callback(null, 'var ' + config.externals[request]);
43
+ }
44
+ //log(colors.gray(request));
45
+ //"@dacore/core/foo" => "daCore.core.foo"
46
+ // if (/^\@dacore\//.test(request)) {
47
+ //remove @dacore/
48
+ // if (request.indexOf('@dacore') !== 0) {
49
+ // console.warn(
50
+ // colors.red('this plugin currently works with @dacore modules only'),
51
+ // );
52
+ // return;
53
+ // }
54
+ // debug(colors.green('request: ' + request));
55
+ if (request.substr(0, 1) == '.' || request.substr(0, 1) == '/') {
56
+ // debug('skipping local');
57
+ callback();
58
+ return;
59
+ }
60
+ if (request.indexOf('lincd/') === 0 && es5) {
61
+ // var result = request.replace("@dacore/core/","@dacore/core-es5/");
62
+ // debug('Requested ES6 for ES5 target: '+colors.yellow(request) + ' => ' + colors.cyan(result));
63
+ debug('Requested ES6 for ES5 target: ' + colors.yellow(request));
64
+ // return callback(null, 'commonjs '+result);
65
+ }
66
+ //get module name without @dacore
67
+ // var transformed = request.substr(8);
68
+ var moduleName = request.indexOf('/') !== -1
69
+ ? request.substr(0, request.indexOf('/'))
70
+ : request;
71
+ //if this module is listed as internal module in the config
72
+ if (config &&
73
+ config.internals &&
74
+ config.internals.indexOf(moduleName) !== -1) {
75
+ //then don't exclude and don't continue this function
76
+ //only log once
77
+ if (included.indexOf(moduleName) !== -1) {
78
+ included.push(moduleName);
79
+ }
80
+ debug(colors.blue('marked internal & will be included: ' + request));
81
+ return callback();
82
+ }
83
+ //check if this module is a lincd module
84
+ if (!lincdModules.has(moduleName)) {
85
+ // debug(colors.green('checking ' + moduleName + '/package.json'));
86
+ var isLincdModule = void 0;
87
+ var modulePackage = void 0;
88
+ try {
89
+ modulePackage = require(moduleName + '/package.json');
90
+ }
91
+ catch (e) {
92
+ debug(colors.red(moduleName + '/package.json' + ' does not exist'));
93
+ return callback();
94
+ }
95
+ isLincdModule = modulePackage.lincd && true;
96
+ if (isLincdModule) {
97
+ debug(colors.magenta(modulePackage.name +
98
+ ' is a lincd module, imports will be excluded from this bundle and refer to a global variable instead'));
99
+ }
100
+ else {
101
+ debug(modulePackage.name +
102
+ ' is NOT a linked module, it will be included in the bundle');
103
+ }
104
+ lincdModules.set(moduleName, isLincdModule && true);
105
+ }
106
+ if (lincdModules.get(moduleName) !== true) {
107
+ return callback();
108
+ }
109
+ //remove export root path (for example with @dacore/core/lib/models: the core module has lib/ as root, so to get to the exported path dacore.core.UriResource we need to remove it)
110
+ var cleanRequest = request.replace(exportRoot, '');
111
+ var targetVariable;
112
+ //expects a flat export / global tree with all the modules classes
113
+ //replace - by _ and remove es5, because both es6 and es5 modules will be listed under the bare module name in the global treemap
114
+ var firstSlash = cleanRequest.indexOf('/');
115
+ //if importing {x} from "lincd" (so directly from library without any paths)
116
+ if (firstSlash === -1 && cleanRequest == libraryName) {
117
+ //then we refer straight to the global object
118
+ targetVariable = libraryName;
119
+ }
120
+ else {
121
+ //for all other cases, there is slash, so lets split module before the first slash and classname after the last slash
122
+ var module_1 = cleanRequest
123
+ .substr(0, firstSlash)
124
+ .replace(/-/g, '_')
125
+ .replace('_es5', '');
126
+ var className = cleanRequest
127
+ .substr(cleanRequest.lastIndexOf('/') + 1)
128
+ .replace(/-/g, '_');
129
+ if (module_1 == libraryName) {
130
+ //the library itself should directly expose the main class of each file for clean variable names
131
+ targetVariable = libraryName;
132
+ //targetVariable = libraryName + '.' + className;
133
+ }
134
+ else {
135
+ //reading this back I'm not sure why module would be empty?
136
+ //Note: we don't include className here anymore, since all linked Components/Utils register themselves as libraryName._modules.moduleName.ComponentName
137
+ //and we don't do default exports, so the import would be `import {ComponentName} from 'foo'` OR `import {ComponentName} from 'foo/lib/components/ComponentName'`
138
+ //Typescript then translates `ComponentName` to `ComponentName_1.ComponentName` in the javascript output
139
+ //And when we build the tree, we put each individual exports of linked components directly under `lincd._modules.moduleName`
140
+ //so here we return the entire module as the result of such imports
141
+ //and ComponentName_1 will contain all things linked/exported by the module
142
+ //and ComponentName_1.ComponentName resolves to the desired class/function
143
+ targetVariable = libraryName + '._modules.' + module_1;
144
+ //import {PersonView} from 'lincd-test/lib/PersonView';
145
+ //lincd._modules.lincd_test
146
+ //PersonView_1
147
+ //PersonView_1.PersonView --> lincd._modules.lincd_test.PersonView
148
+ // targetVariable =
149
+ // libraryName +
150
+ // '.' +
151
+ // (module ? '_modules.' + module + '.' : '') +
152
+ // className;
153
+ }
154
+ }
155
+ debug(colors.yellow(request) + ' => ' + colors.cyan(targetVariable));
156
+ //See also: https://webpack.js.org/configuration/externals/
157
+ return callback(null, 'var ' + targetVariable);
158
+ // }
159
+ };
160
+ };
161
+ exports["default"] = externaliseModules;
@@ -1,69 +1,69 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- /// <reference path="colors.d.ts" />
4
- var colors = require("colors");
5
- var ShapesPlugin = /** @class */ (function () {
6
- function ShapesPlugin(options) {
7
- if (options === void 0) { options = {}; }
8
- this.shapeFiles = [];
9
- this.logMessages = true;
10
- this.exportRoot = '/lib';
11
- this.logMessages = options.debug ? options.debug : false;
12
- }
13
- ShapesPlugin.prototype.apply = function (compiler) {
14
- var _this = this;
15
- this.debug('applying');
16
- //when the compiler is ready to emit files
17
- // compiler.plugin('emit', (compilation,callback) =>
18
- compiler.hooks.emit.tapAsync('DeclarationPlugin', function (compilation, callback) {
19
- // this.debug('emitted');
20
- _this.debug(Object.keys(compilation.assets));
21
- //collect all generated shape files
22
- //NOTE: at some point we decided to overwrite declaration files between emits because sometimes only one new declaration file is emitted
23
- //this may cause issues when you remove a file during the continuous building process, but better than the other way around for now
24
- for (var filename in compilation.assets) {
25
- if (filename.indexOf('.js') !== -1 &&
26
- filename.indexOf('.map') === -1) {
27
- _this.debug(filename, Object.keys(compilation.assets[filename]));
28
- // require(filename);
29
- // this.declarationFiles[filename] = compilation.assets[filename];
30
- // this.debug('not using: '+filename);
31
- // delete compilation.assets[filename];
32
- }
33
- }
34
- //and insert that back into the assets
35
- // compilation.assets[this.options.out] = {
36
- // source: function () {
37
- // return combinedDeclaration;
38
- // },
39
- // size: function () {
40
- // return combinedDeclaration.length;
41
- // },
42
- // };
43
- //webpack may continue now
44
- callback();
45
- });
46
- };
47
- ShapesPlugin.prototype.debug = function () {
48
- var msgs = [];
49
- for (var _i = 0; _i < arguments.length; _i++) {
50
- msgs[_i] = arguments[_i];
51
- }
52
- msgs.unshift('shapes:');
53
- // if (this.logMessages) {
54
- msgs = msgs.map(function (msg) { return colors.blue(msg); });
55
- console.log.apply(null, msgs);
56
- // }
57
- };
58
- ShapesPlugin.prototype.log = function () {
59
- var msgs = [];
60
- for (var _i = 0; _i < arguments.length; _i++) {
61
- msgs[_i] = arguments[_i];
62
- }
63
- msgs.unshift('shapes:');
64
- msgs = msgs.map(function (msg) { return colors.blue(msg); });
65
- console.log.apply(null, msgs);
66
- };
67
- return ShapesPlugin;
68
- }());
69
- exports["default"] = ShapesPlugin;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ /// <reference path="colors.d.ts" />
4
+ var colors = require("colors");
5
+ var ShapesPlugin = /** @class */ (function () {
6
+ function ShapesPlugin(options) {
7
+ if (options === void 0) { options = {}; }
8
+ this.shapeFiles = [];
9
+ this.logMessages = true;
10
+ this.exportRoot = '/lib';
11
+ this.logMessages = options.debug ? options.debug : false;
12
+ }
13
+ ShapesPlugin.prototype.apply = function (compiler) {
14
+ var _this = this;
15
+ this.debug('applying');
16
+ //when the compiler is ready to emit files
17
+ // compiler.plugin('emit', (compilation,callback) =>
18
+ compiler.hooks.emit.tapAsync('DeclarationPlugin', function (compilation, callback) {
19
+ // this.debug('emitted');
20
+ _this.debug(Object.keys(compilation.assets));
21
+ //collect all generated shape files
22
+ //NOTE: at some point we decided to overwrite declaration files between emits because sometimes only one new declaration file is emitted
23
+ //this may cause issues when you remove a file during the continuous building process, but better than the other way around for now
24
+ for (var filename in compilation.assets) {
25
+ if (filename.indexOf('.js') !== -1 &&
26
+ filename.indexOf('.map') === -1) {
27
+ _this.debug(filename, Object.keys(compilation.assets[filename]));
28
+ // require(filename);
29
+ // this.declarationFiles[filename] = compilation.assets[filename];
30
+ // this.debug('not using: '+filename);
31
+ // delete compilation.assets[filename];
32
+ }
33
+ }
34
+ //and insert that back into the assets
35
+ // compilation.assets[this.options.out] = {
36
+ // source: function () {
37
+ // return combinedDeclaration;
38
+ // },
39
+ // size: function () {
40
+ // return combinedDeclaration.length;
41
+ // },
42
+ // };
43
+ //webpack may continue now
44
+ callback();
45
+ });
46
+ };
47
+ ShapesPlugin.prototype.debug = function () {
48
+ var msgs = [];
49
+ for (var _i = 0; _i < arguments.length; _i++) {
50
+ msgs[_i] = arguments[_i];
51
+ }
52
+ msgs.unshift('shapes:');
53
+ // if (this.logMessages) {
54
+ msgs = msgs.map(function (msg) { return colors.blue(msg); });
55
+ console.log.apply(null, msgs);
56
+ // }
57
+ };
58
+ ShapesPlugin.prototype.log = function () {
59
+ var msgs = [];
60
+ for (var _i = 0; _i < arguments.length; _i++) {
61
+ msgs[_i] = arguments[_i];
62
+ }
63
+ msgs.unshift('shapes:');
64
+ msgs = msgs.map(function (msg) { return colors.blue(msg); });
65
+ console.log.apply(null, msgs);
66
+ };
67
+ return ShapesPlugin;
68
+ }());
69
+ exports["default"] = ShapesPlugin;
@@ -1,47 +1,47 @@
1
- // WebpackWatchRunPlugin.js
2
- /*
3
- * This simple webpack plugin helps to identify the list of file changes, that
4
- * triggered webpack re-compilation/re-build
5
- */
6
- 'use strict';
7
- exports.__esModule = true;
8
- var WatchRunPlugin = /** @class */ (function () {
9
- function WatchRunPlugin() {
10
- }
11
- WatchRunPlugin.prototype.apply = function (compiler) {
12
- compiler.hooks.watchRun.tap('WatchRun', function (comp) {
13
- var changedTimes = comp.watchFileSystem.watcher.mtimes;
14
- var changedFiles = Object.keys(changedTimes)
15
- .map(function (file) { return "\n ".concat(file); })
16
- .join('');
17
- if (changedFiles.length) {
18
- console.log('====================================');
19
- console.log('NEW BUILD FILES CHANGED:', changedFiles);
20
- console.log('====================================');
21
- }
22
- });
23
- };
24
- return WatchRunPlugin;
25
- }());
26
- /*class WebpackWatchRunPlugin {
27
- constructor(options?) {
28
- if (typeof options !== "object") options = {};
29
- this['options'] = options;
30
- }
31
-
32
- apply(compiler) {
33
- const options = this['options'];
34
- compiler.plugin("watch-run",
35
- function (watching, done) {
36
- const changedTimes = watching.compiler.watchFileSystem.watcher.mtimes;
37
- const changedFiles = Object.keys(changedTimes)
38
- .map(file => `\n ${file}`)
39
- .join("");
40
- if (changedFiles.length) {
41
- console.log("Files modified:", changedFiles);
42
- }
43
- done();
44
- });
45
- }
46
- }*/
47
- exports["default"] = WatchRunPlugin;
1
+ // WebpackWatchRunPlugin.js
2
+ /*
3
+ * This simple webpack plugin helps to identify the list of file changes, that
4
+ * triggered webpack re-compilation/re-build
5
+ */
6
+ 'use strict';
7
+ exports.__esModule = true;
8
+ var WatchRunPlugin = /** @class */ (function () {
9
+ function WatchRunPlugin() {
10
+ }
11
+ WatchRunPlugin.prototype.apply = function (compiler) {
12
+ compiler.hooks.watchRun.tap('WatchRun', function (comp) {
13
+ var changedTimes = comp.watchFileSystem.watcher.mtimes;
14
+ var changedFiles = Object.keys(changedTimes)
15
+ .map(function (file) { return "\n ".concat(file); })
16
+ .join('');
17
+ if (changedFiles.length) {
18
+ console.log('====================================');
19
+ console.log('NEW BUILD FILES CHANGED:', changedFiles);
20
+ console.log('====================================');
21
+ }
22
+ });
23
+ };
24
+ return WatchRunPlugin;
25
+ }());
26
+ /*class WebpackWatchRunPlugin {
27
+ constructor(options?) {
28
+ if (typeof options !== "object") options = {};
29
+ this['options'] = options;
30
+ }
31
+
32
+ apply(compiler) {
33
+ const options = this['options'];
34
+ compiler.plugin("watch-run",
35
+ function (watching, done) {
36
+ const changedTimes = watching.compiler.watchFileSystem.watcher.mtimes;
37
+ const changedFiles = Object.keys(changedTimes)
38
+ .map(file => `\n ${file}`)
39
+ .join("");
40
+ if (changedFiles.length) {
41
+ console.log("Files modified:", changedFiles);
42
+ }
43
+ done();
44
+ });
45
+ }
46
+ }*/
47
+ exports["default"] = WatchRunPlugin;