lincd-cli 0.1.6 → 0.1.9
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/{src/cli.js → cli.js} +2 -2
- package/config-generator.js +568 -0
- package/defaults/app/Gruntfile.js +13 -0
- package/defaults/app/index.html +12 -0
- package/defaults/{package.json → app/package.json} +4 -2
- package/defaults/app/tsconfig-es5.json +18 -0
- package/defaults/module/.npmignore +6 -0
- package/defaults/module/package.json +14 -6
- package/defaults/shape.ts +8 -0
- package/{src/index.js → index.js} +9 -5
- package/lib/cli.js +362 -107
- package/lib/config-grunt.js +34 -30
- package/lib/config-webpack.js +9 -7
- package/lib/index.js +5 -1
- package/lib/plugins/declaration-plugin.js +9 -9
- package/lib/plugins/externalise-modules.js +13 -13
- package/lib/plugins/watch-run.js +1 -1
- package/lib/utils.js +5 -1
- package/package.json +12 -10
- package/{src/plugins → plugins}/declaration-plugin.js +0 -0
- package/{src/plugins → plugins}/externalise-modules.js +0 -0
- package/{src/plugins → plugins}/watch-run.js +0 -0
- package/utils.js +39 -0
- package/defaults/create_migration.js +0 -155
- package/defaults/create_migration.ts +0 -7
- package/defaults/defaultModule/Index.js +0 -30
- package/defaults/defaultModule/Index.scss +0 -19
- package/defaults/defaultModule/Index.tsx +0 -25
- package/defaults/defaultModule/data.json +0 -56
- package/defaults/defaultModule/defaultOntology.json +0 -23
- package/defaults/defaultModule/index.ts +0 -12
- package/defaults/defaultModule/ontology.js +0 -21
- package/defaults/defaultModule/ontology.ts +0 -16
- package/defaults/gitignorefile +0 -4
- package/defaults/index.ts +0 -13
- package/defaults/module/src/components/ExampleComponent.tsx +0 -22
- package/defaults/module/src/data/example-ontology.json +0 -20
- package/defaults/module/src/data/example-ontology.json.d.ts +0 -1
- package/defaults/module/src/index.ts +0 -7
- package/defaults/module/src/module.ts +0 -9
- package/defaults/module/src/ontologies/example-ontology.ts +0 -33
- package/defaults/module/src/shapes/ExampleShapeClass.ts +0 -30
- package/defaults/ontology.ts +0 -16
- package/defaults/providers.ts +0 -1
- package/defaults/site/package.json +0 -40
- package/defaults/site/storage/filestores/settings-production-template.jsonld +0 -129
- package/defaults/site/web/.htaccess +0 -19
- package/defaults/site/web/favicon.png +0 -0
- package/defaults/site/web/img/placeholder.jpg +0 -0
- package/src/config-grunt.js +0 -263
- package/src/config-webpack.js +0 -281
- package/src/interfaces.js +0 -2
- package/src/plugins/shapes-plugin.js +0 -69
- package/src/utils.js +0 -127
package/{src/cli.js → cli.js}
RENAMED
|
@@ -511,7 +511,7 @@ program.command('register [version]').action(function (newVersion) {
|
|
|
511
511
|
Accept: 'application/json, text/plain, */*',
|
|
512
512
|
'Content-Type': 'application/json'
|
|
513
513
|
},
|
|
514
|
-
body: JSON.stringify({ package: moduleName
|
|
514
|
+
body: JSON.stringify({ package: moduleName })
|
|
515
515
|
})
|
|
516
516
|
.then(function (res) { return res.text(); })
|
|
517
517
|
.then(function (text) {
|
|
@@ -823,7 +823,7 @@ var executeSingleBuild = function (module, previousResult, test, info) {
|
|
|
823
823
|
' ' +
|
|
824
824
|
nextVersion));
|
|
825
825
|
if (!test) {
|
|
826
|
-
return execPromise('cd ' + module.path + ' && yarn lincd
|
|
826
|
+
return execPromise('cd ' + module.path + ' && yarn lincd publish', true)
|
|
827
827
|
.then(function (res) {
|
|
828
828
|
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
829
829
|
res.indexOf('Could not publish') !== -1 ||
|
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
exports.__esModule = true;
|
|
23
|
+
exports.generateWebpackConfig = exports.setupGrunt = void 0;
|
|
24
|
+
var declaration_plugin_1 = require("./plugins/declaration-plugin");
|
|
25
|
+
var externalise_modules_1 = require("./plugins/externalise-modules");
|
|
26
|
+
var watch_run_1 = require("./plugins/watch-run");
|
|
27
|
+
var utils_1 = require("./utils");
|
|
28
|
+
var colors = require("colors");
|
|
29
|
+
var fs = require('fs');
|
|
30
|
+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
31
|
+
var chalk = require('chalk');
|
|
32
|
+
var webpack = require('webpack');
|
|
33
|
+
var path = require('path');
|
|
34
|
+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
35
|
+
var WebpackLicencePlugin = require('webpack-license-plugin');
|
|
36
|
+
var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
37
|
+
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
38
|
+
var TerserPlugin = require('terser-webpack-plugin');
|
|
39
|
+
var exec = require('child_process').exec;
|
|
40
|
+
var NODE_ENV = process.env.NODE_ENV;
|
|
41
|
+
var nodeProduction = NODE_ENV == 'production';
|
|
42
|
+
var libraryName = 'lincd';
|
|
43
|
+
function log() {
|
|
44
|
+
var messages = [];
|
|
45
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
46
|
+
messages[_i] = arguments[_i];
|
|
47
|
+
}
|
|
48
|
+
messages.forEach(function (message) {
|
|
49
|
+
console.log(chalk.cyan(message));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function debug(config) {
|
|
53
|
+
var messages = [];
|
|
54
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
55
|
+
messages[_i - 1] = arguments[_i];
|
|
56
|
+
}
|
|
57
|
+
if (config.debug) {
|
|
58
|
+
log.apply(void 0, messages);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function warn() {
|
|
62
|
+
var messages = [];
|
|
63
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
64
|
+
messages[_i] = arguments[_i];
|
|
65
|
+
}
|
|
66
|
+
messages.forEach(function (message) {
|
|
67
|
+
console.log(chalk.red(message));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
var flatten = function (arr) {
|
|
71
|
+
return arr.reduce(function (a, b) {
|
|
72
|
+
return b ? a.concat(b) : a;
|
|
73
|
+
}, []);
|
|
74
|
+
};
|
|
75
|
+
function generateGruntConfig(moduleName, config) {
|
|
76
|
+
if (config === void 0) { config = {}; }
|
|
77
|
+
return function (grunt) {
|
|
78
|
+
setupGrunt(grunt, moduleName, config);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports["default"] = generateGruntConfig;
|
|
82
|
+
var generateScopedName = function (name, filename, css) {
|
|
83
|
+
var path = require('path');
|
|
84
|
+
var file = path.basename(filename, '.scss');
|
|
85
|
+
var module = filename.match(/[\\\/]modules[\\\/]([\w\-_]+)/);
|
|
86
|
+
var moduleName;
|
|
87
|
+
if (module) {
|
|
88
|
+
moduleName = module[1];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
//if we cant find module name from path, we'll use a hash
|
|
92
|
+
//https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
|
|
93
|
+
var hash = 0;
|
|
94
|
+
if (filename.length == 0) {
|
|
95
|
+
moduleName = '_unknown';
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
for (var i = 0; i < filename.length; i++) {
|
|
99
|
+
var char = filename.charCodeAt(i);
|
|
100
|
+
hash = (hash << 5) - hash + char;
|
|
101
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
102
|
+
}
|
|
103
|
+
moduleName = hash;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// console.log("Module name: "+moduleName);
|
|
107
|
+
// console.log("Returning: " + moduleName + "_" + file + "_" + name);
|
|
108
|
+
return moduleName + '_' + file + '_' + name;
|
|
109
|
+
};
|
|
110
|
+
function setupGrunt(grunt, moduleName, config) {
|
|
111
|
+
var buildServer = !config.environment || config.environment == 'server';
|
|
112
|
+
var buildFrontend = !config.environment || config.environment == 'frontend';
|
|
113
|
+
//when not specified and we ARe building frontend OR we are compiling the server for es5.. or if simply specified, then es5 is targeted
|
|
114
|
+
var targetES5 = (!config.target && (buildFrontend || config.es5Server)) ||
|
|
115
|
+
config.target == 'es5';
|
|
116
|
+
var targetES6 = !config.target || config.target == 'es6';
|
|
117
|
+
var targets = [];
|
|
118
|
+
if (targetES5)
|
|
119
|
+
targets.push('es5');
|
|
120
|
+
if (targetES6)
|
|
121
|
+
targets.push('es6');
|
|
122
|
+
var targetLog = 'building ' + targets.join(', ');
|
|
123
|
+
if (buildServer && !buildFrontend) {
|
|
124
|
+
log(targetLog + ' lib only');
|
|
125
|
+
}
|
|
126
|
+
else if (!buildServer && buildFrontend) {
|
|
127
|
+
log(targetLog + ' dist bundles only');
|
|
128
|
+
}
|
|
129
|
+
else if (buildServer && buildFrontend) {
|
|
130
|
+
if (config.es5Server) {
|
|
131
|
+
log(targetLog + ' lib files & dist bundles');
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
log(targetLog + ' dist bundles and es6 lib files');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
log('invalid configuration combination');
|
|
139
|
+
}
|
|
140
|
+
require('load-grunt-tasks')(grunt);
|
|
141
|
+
//defaults
|
|
142
|
+
grunt.registerTask('default', ['prepare-build', 'concurrent:dev']);
|
|
143
|
+
grunt.registerTask('dev', targetES6 ? ['prepare-build', 'dev-es6'] : ['prepare-build', 'dev-es5']);
|
|
144
|
+
grunt.registerTask('build', targets.map(function (target) { return 'build-' + target; }));
|
|
145
|
+
if (buildFrontend) {
|
|
146
|
+
grunt.registerTask('build-frontend', __spreadArray([
|
|
147
|
+
'prepare-build'
|
|
148
|
+
], targets.map(function (target) { return 'webpack:build-' + target; }), true));
|
|
149
|
+
}
|
|
150
|
+
grunt.registerTask('build-production', flatten([
|
|
151
|
+
'clean:lib',
|
|
152
|
+
'prepare-build',
|
|
153
|
+
buildFrontend ? targets.map(function (target) { return 'webpack:prod-' + target; }) : null,
|
|
154
|
+
buildServer ? ['exec:build-lib'] : null,
|
|
155
|
+
]));
|
|
156
|
+
var prepareBuild = ['postcss:cssjson'];
|
|
157
|
+
if (config.beforeBuildCommand) {
|
|
158
|
+
prepareBuild.push('exec:beforeBuildCommand');
|
|
159
|
+
}
|
|
160
|
+
//specific tasks
|
|
161
|
+
grunt.registerTask('prepare-build', prepareBuild);
|
|
162
|
+
grunt.registerTask('dev-es6-production', [
|
|
163
|
+
'prepare-build',
|
|
164
|
+
'concurrent:dev-prod',
|
|
165
|
+
]);
|
|
166
|
+
grunt.registerTask('dev-es6', ['prepare-build', 'concurrent:dev']);
|
|
167
|
+
grunt.registerTask('dev-es5', ['prepare-build', 'concurrent:dev-es5']);
|
|
168
|
+
//build-es5 is by default just the frontend because the server is es6
|
|
169
|
+
//however some specific modules (like @dacore/module) require the typescript compiler ('build-lib') to run for es5
|
|
170
|
+
//so that core-es5 or browser-core-es5 can internalise its files
|
|
171
|
+
//this can by triggered with es5Server
|
|
172
|
+
grunt.registerTask('build-es5', flatten([
|
|
173
|
+
'postcss',
|
|
174
|
+
buildFrontend ? 'webpack:build-es5' : null,
|
|
175
|
+
config.es5Server ? 'exec:build-lib-es5' : null,
|
|
176
|
+
]));
|
|
177
|
+
grunt.registerTask('build-es6', flatten([
|
|
178
|
+
'prepare-build',
|
|
179
|
+
buildFrontend ? 'webpack:build-es6' : null,
|
|
180
|
+
buildServer ? ['clean:lib', 'exec:build-lib'] : null,
|
|
181
|
+
// 'exec:shapes',
|
|
182
|
+
]));
|
|
183
|
+
grunt.registerTask('build-lib', ['prepare-build', 'exec:build-lib']);
|
|
184
|
+
grunt.registerTask('build-production-es5', [
|
|
185
|
+
'prepare-build',
|
|
186
|
+
'webpack:prod-es5',
|
|
187
|
+
// 'exec:shapes',
|
|
188
|
+
]);
|
|
189
|
+
grunt.registerTask('build-production-es6', [
|
|
190
|
+
'prepare-build',
|
|
191
|
+
'webpack:prod-es6',
|
|
192
|
+
// 'exec:shapes',
|
|
193
|
+
]);
|
|
194
|
+
// log('setting grunt config');
|
|
195
|
+
grunt.initConfig({
|
|
196
|
+
exec: {
|
|
197
|
+
'build-lib': 'tsc --pretty',
|
|
198
|
+
'build-lib-es5': 'tsc --pretty -p tsconfig-es5.json',
|
|
199
|
+
beforeBuildCommand: config.beforeBuildCommand,
|
|
200
|
+
'server-dev': 'tsc -w',
|
|
201
|
+
test: 'tsc -w',
|
|
202
|
+
// shapes: 'lincd shapes',
|
|
203
|
+
'css-declarations': 'tcm -p **/*.scss',
|
|
204
|
+
'postcss-modules': 'yarn postcss --use postcss-import postcss-cssnext postcss-nested postcss-modules -o build/draft.css -i scss/*'
|
|
205
|
+
},
|
|
206
|
+
postcss: {
|
|
207
|
+
options: {
|
|
208
|
+
map: true,
|
|
209
|
+
processors: [require('postcss-modules')({ generateScopedName: generateScopedName })],
|
|
210
|
+
syntax: require('postcss-scss'),
|
|
211
|
+
writeDest: false
|
|
212
|
+
},
|
|
213
|
+
cssjson: {
|
|
214
|
+
src: 'src/**/*.scss'
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
clean: {
|
|
218
|
+
lib: ['lib/']
|
|
219
|
+
},
|
|
220
|
+
concurrent: {
|
|
221
|
+
dev: flatten([
|
|
222
|
+
buildFrontend ? 'webpack:dev' : null,
|
|
223
|
+
buildServer ? 'exec:server-dev' : null,
|
|
224
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
225
|
+
// 'exec:css-declarations-watch'
|
|
226
|
+
]),
|
|
227
|
+
'dev-prod': flatten([
|
|
228
|
+
buildFrontend ? 'webpack:dev-prod' : null,
|
|
229
|
+
buildServer ? 'exec:server-dev' : null,
|
|
230
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
231
|
+
// 'exec:css-declarations-watch'
|
|
232
|
+
]),
|
|
233
|
+
'dev-es5': flatten([
|
|
234
|
+
buildFrontend ? 'webpack:dev-es5' : null,
|
|
235
|
+
buildServer ? 'exec:server-dev' : null,
|
|
236
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
237
|
+
// 'exec:css-declarations-watch'
|
|
238
|
+
]),
|
|
239
|
+
options: {
|
|
240
|
+
logConcurrentOutput: true,
|
|
241
|
+
logTaskName: 3,
|
|
242
|
+
logBlacklist: []
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
webpack: {
|
|
246
|
+
options: {
|
|
247
|
+
stats: {
|
|
248
|
+
chunks: false,
|
|
249
|
+
version: false,
|
|
250
|
+
warningsFilter: function (warning) {
|
|
251
|
+
return warning.indexOf('There are multiple modules') !== -1;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
dev: generateWebpackConfig('dev', moduleName, Object.assign({
|
|
256
|
+
target: 'es6',
|
|
257
|
+
watch: true
|
|
258
|
+
}, config, config.es6, config.dev)),
|
|
259
|
+
'dev-prod': generateWebpackConfig('dev', moduleName, Object.assign({
|
|
260
|
+
target: 'es6',
|
|
261
|
+
watch: true,
|
|
262
|
+
productionMode: true
|
|
263
|
+
}, config, config.es6, config.prod)),
|
|
264
|
+
'dev-es5': generateWebpackConfig('dev-es5', moduleName, Object.assign({
|
|
265
|
+
target: 'es5',
|
|
266
|
+
watch: true
|
|
267
|
+
}, config, config.es5, config.dev)),
|
|
268
|
+
'build-es6': generateWebpackConfig('build-es6', moduleName, Object.assign({
|
|
269
|
+
target: 'es6',
|
|
270
|
+
watch: false
|
|
271
|
+
}, config, config.es6, config.dev)),
|
|
272
|
+
'build-es5': generateWebpackConfig('build-es5', moduleName, Object.assign({
|
|
273
|
+
target: 'es5',
|
|
274
|
+
watch: false
|
|
275
|
+
}, config, config.es5, config.dev)),
|
|
276
|
+
'prod-es5': generateWebpackConfig('prod-es5', moduleName, Object.assign({
|
|
277
|
+
target: 'es5',
|
|
278
|
+
watch: false,
|
|
279
|
+
productionMode: true
|
|
280
|
+
}, config, config.es5, config.prod)),
|
|
281
|
+
'prod-es6': generateWebpackConfig('prod-es6', moduleName, Object.assign({
|
|
282
|
+
target: 'es6',
|
|
283
|
+
watch: false,
|
|
284
|
+
productionMode: true
|
|
285
|
+
}, config, config.es6, config.prod))
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
grunt.config.init.exec = {
|
|
289
|
+
test: 'echo "yey"'
|
|
290
|
+
};
|
|
291
|
+
//load the npm grunt task modules
|
|
292
|
+
[
|
|
293
|
+
'grunt-webpack',
|
|
294
|
+
'grunt-exec',
|
|
295
|
+
'grunt-concurrent',
|
|
296
|
+
'grunt-contrib-clean',
|
|
297
|
+
'@lodder/grunt-postcss',
|
|
298
|
+
].forEach(function (taskName) {
|
|
299
|
+
debug(config, 'loading grunt task ' + taskName);
|
|
300
|
+
var localPath = path.resolve(__dirname, 'node_modules', taskName, 'tasks');
|
|
301
|
+
var localPath2 = path.resolve(__dirname, '..', 'node_modules', taskName, 'tasks');
|
|
302
|
+
var workspacePath = path.resolve(__dirname, '..', '..', 'node_modules', taskName, 'tasks');
|
|
303
|
+
var nestedWorkspacePath = path.resolve(__dirname, '..', '..', '..', 'node_modules', taskName, 'tasks');
|
|
304
|
+
if (fs.existsSync(localPath)) {
|
|
305
|
+
// grunt.loadNpmTasks(taskName);
|
|
306
|
+
debug('Loading from ' + localPath);
|
|
307
|
+
grunt.task.loadTasks(localPath);
|
|
308
|
+
}
|
|
309
|
+
else if (fs.existsSync(localPath2)) {
|
|
310
|
+
// grunt.loadNpmTasks(taskName);
|
|
311
|
+
debug('Loading from ' + localPath2);
|
|
312
|
+
grunt.task.loadTasks(localPath2);
|
|
313
|
+
}
|
|
314
|
+
else if (fs.existsSync(workspacePath)) {
|
|
315
|
+
//windows, so it seems
|
|
316
|
+
debug('Loading from ' + workspacePath);
|
|
317
|
+
grunt.task.loadTasks(workspacePath);
|
|
318
|
+
}
|
|
319
|
+
else if (fs.existsSync(nestedWorkspacePath)) {
|
|
320
|
+
//mac / linux
|
|
321
|
+
debug('Loading from ' + nestedWorkspacePath);
|
|
322
|
+
grunt.task.loadTasks(nestedWorkspacePath);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
warn("Could not load grunt task module ".concat(taskName, "\nCould not find task at any of these paths:\n").concat(localPath, "\n").concat(localPath2, "\n").concat(workspacePath, "\n").concat(nestedWorkspacePath));
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
exports.setupGrunt = setupGrunt;
|
|
330
|
+
function generateWebpackConfig(buildName, moduleName, config) {
|
|
331
|
+
if (config === void 0) { config = {}; }
|
|
332
|
+
if (!config.externals)
|
|
333
|
+
config.externals = {};
|
|
334
|
+
if (!config.internals)
|
|
335
|
+
config.internals = [];
|
|
336
|
+
var watch = config.watch;
|
|
337
|
+
var productionMode = nodeProduction || config.productionMode;
|
|
338
|
+
var es5 = config.target == 'es5';
|
|
339
|
+
var es6 = config.target == 'es6';
|
|
340
|
+
var configFile;
|
|
341
|
+
if (es5 && fs.existsSync('tsconfig-es5.json')) {
|
|
342
|
+
configFile = 'tsconfig-es5.json';
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
configFile = 'tsconfig.json';
|
|
346
|
+
}
|
|
347
|
+
if (!fs.existsSync(configFile)) {
|
|
348
|
+
warn('Cannot find ' + configFile);
|
|
349
|
+
process.exit();
|
|
350
|
+
}
|
|
351
|
+
var pack = (0, utils_1.getPackageJSON)();
|
|
352
|
+
var plugins = [
|
|
353
|
+
new webpack.DefinePlugin({
|
|
354
|
+
'process.env.BROWSER': JSON.stringify(true),
|
|
355
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
356
|
+
}),
|
|
357
|
+
new webpack.NoEmitOnErrorsPlugin(),
|
|
358
|
+
new ExtractTextPlugin(config.cssFileName
|
|
359
|
+
? config.cssFileName
|
|
360
|
+
: libraryName + '.' + moduleName + '.css'),
|
|
361
|
+
new MiniCssExtractPlugin({
|
|
362
|
+
// linkType: false,
|
|
363
|
+
filename: config.cssFileName
|
|
364
|
+
? config.cssFileName
|
|
365
|
+
: libraryName + '.' + moduleName + '.css'
|
|
366
|
+
}),
|
|
367
|
+
new WebpackLicencePlugin({
|
|
368
|
+
excludedPackageTest: function (packageName, version) {
|
|
369
|
+
return packageName.indexOf('lincd') !== -1;
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
//output sometimes includes things like webpack, which seems not needed? this doesn't work though
|
|
373
|
+
// {
|
|
374
|
+
// excludedPackageTest:((packageName, packageVersion) => {
|
|
375
|
+
// return pack.devDependencies && packageName in pack.devDependencies;
|
|
376
|
+
// })
|
|
377
|
+
// }
|
|
378
|
+
];
|
|
379
|
+
if (config.debug) {
|
|
380
|
+
plugins.push(new watch_run_1["default"]());
|
|
381
|
+
}
|
|
382
|
+
if (config.afterBuildCommand) {
|
|
383
|
+
plugins.push({
|
|
384
|
+
apply: function (compiler) {
|
|
385
|
+
compiler.hooks.afterEmit.tap('AfterEmitPlugin', function (compilation) {
|
|
386
|
+
exec(config.afterBuildCommand, function (err, stdout, stderr) {
|
|
387
|
+
if (stdout)
|
|
388
|
+
process.stdout.write(stdout);
|
|
389
|
+
if (stderr)
|
|
390
|
+
process.stderr.write(stderr);
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (config.analyse) {
|
|
397
|
+
plugins.push(new BundleAnalyzerPlugin());
|
|
398
|
+
}
|
|
399
|
+
if (es6 || config.declarations === true) {
|
|
400
|
+
plugins.push(new declaration_plugin_1["default"]({
|
|
401
|
+
out: (config.filename ? config.filename : libraryName + '.' + moduleName) +
|
|
402
|
+
'.d.ts',
|
|
403
|
+
root: config.outputPath ? config.outputPath : './lib/',
|
|
404
|
+
debug: 'debug' in config ? config.debug : false
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
var resolvePlugins = [
|
|
408
|
+
new TsconfigPathsPlugin({
|
|
409
|
+
configFile: configFile,
|
|
410
|
+
silent: true
|
|
411
|
+
}),
|
|
412
|
+
];
|
|
413
|
+
var aliases = config.alias || {};
|
|
414
|
+
var rules = [
|
|
415
|
+
{
|
|
416
|
+
test: /\.(scss|css)$/,
|
|
417
|
+
use: [
|
|
418
|
+
MiniCssExtractPlugin.loader,
|
|
419
|
+
{
|
|
420
|
+
loader: 'css-loader',
|
|
421
|
+
options: {
|
|
422
|
+
url: false
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
loader: 'postcss-loader',
|
|
427
|
+
options: {
|
|
428
|
+
postcssOptions: {
|
|
429
|
+
plugins: {
|
|
430
|
+
'postcss-import': {},
|
|
431
|
+
'postcss-cssnext': {},
|
|
432
|
+
'postcss-nested': {},
|
|
433
|
+
// "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
|
|
434
|
+
'postcss-modules': {
|
|
435
|
+
//by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
|
|
436
|
+
generateScopedName: generateScopedName,
|
|
437
|
+
globalModulePaths: [/tailwind/]
|
|
438
|
+
},
|
|
439
|
+
tailwindcss: {
|
|
440
|
+
purge: {
|
|
441
|
+
enabled: productionMode,
|
|
442
|
+
content: [
|
|
443
|
+
'./src/**/*.tsx',
|
|
444
|
+
'./src/**/*.ts',
|
|
445
|
+
//also include @dacore modules which are internalized with the "internal" config option
|
|
446
|
+
//imports like ... from '@dacore/module/lib/views/SomeView' will
|
|
447
|
+
//these modules should live in the node_modules folder of the root of the site
|
|
448
|
+
//TODO: remake this with multiple lincd modules
|
|
449
|
+
// '../../node_modules/@dacore/*/lib/**/*.js',
|
|
450
|
+
// './node_modules/@dacore/*/lib/**/*.js',
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
loader: 'sass-loader',
|
|
460
|
+
options: { sourceMap: true }
|
|
461
|
+
},
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
test: /\.tsx?$/,
|
|
466
|
+
use: [
|
|
467
|
+
{
|
|
468
|
+
loader: 'ts-loader?' +
|
|
469
|
+
JSON.stringify(__assign({ configFile: configFile, compilerOptions: {
|
|
470
|
+
declaration: !es5,
|
|
471
|
+
/*
|
|
472
|
+
for webpack we overwrite the module settings of the modules' tsconfig file
|
|
473
|
+
because we NEED esnext for code splitting. But the VM we currently use for the registry does not support esnext modules
|
|
474
|
+
*/
|
|
475
|
+
module: 'esnext',
|
|
476
|
+
moduleResolution: 'node'
|
|
477
|
+
} }, config.tsConfigOverwrites))
|
|
478
|
+
},
|
|
479
|
+
]
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
enforce: 'pre',
|
|
483
|
+
test: /\.js$/,
|
|
484
|
+
use: [
|
|
485
|
+
{
|
|
486
|
+
loader: 'source-map-loader'
|
|
487
|
+
},
|
|
488
|
+
]
|
|
489
|
+
},
|
|
490
|
+
];
|
|
491
|
+
if (es5 && config.internalsources && config.internalsources.length > 0) {
|
|
492
|
+
//usually a module that transpiles to es5 will only have es5 code in the bundle.
|
|
493
|
+
//however a module that INTERNALISES other dacore modules will directly include es6 code from @dacore/other_modules/lib
|
|
494
|
+
//which eventually results in an import of @dacore/core being bundled as 'const =', which trips up old browsers
|
|
495
|
+
//so we fix that here by just referring directly to the typescript source instead of the transpiled js for internalised modules
|
|
496
|
+
//however this means that for internalised modules THE SOURCE CODE NEEDS TO BE AVAILABLE. This is currently NOT the case with how we publish modules to yarn
|
|
497
|
+
//so that means internalised modules need to be LOCALLY AVAILABLE with yarn workspaces
|
|
498
|
+
plugins.push(new webpack.NormalModuleReplacementPlugin(/\lincd\/lib\//, function (resource, match) {
|
|
499
|
+
var moduleName = resource.request.match(/lincd\/lib\//)[1];
|
|
500
|
+
if (config.internalsources.indexOf(moduleName) !== -1) {
|
|
501
|
+
console.log(colors.magenta('internal sources + ES5: Replacing /lib/ with /src/ for source-internalised module ' +
|
|
502
|
+
moduleName));
|
|
503
|
+
resource.request = resource.request.replace('/lib/', '/src/');
|
|
504
|
+
console.log(colors.magenta('internal sources + ES5: ' + resource.request));
|
|
505
|
+
console.log(colors.red("WARNING: Make sure you have the TYPESCRIPT SOURCE FILES of the modules listed as 'internal' AVAILABLE ON YOUR LOCAL MACHINE. So if you check in node_modules/your-internalised-module - that should be a symbolic link and you will find a 'src' folder with typescript files there."));
|
|
506
|
+
}
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
entry: config.entry ? config.entry : './src/index.ts',
|
|
511
|
+
output: {
|
|
512
|
+
filename: (config.filename ? config.filename : libraryName + '.' + moduleName) +
|
|
513
|
+
(es5 ? '.es5' : '') +
|
|
514
|
+
'.js',
|
|
515
|
+
path: path.resolve(process.cwd(), config.bundlePath || 'dist'),
|
|
516
|
+
devtoolModuleFilenameTemplate: moduleName + '/[resource-path]'
|
|
517
|
+
},
|
|
518
|
+
devtool: productionMode ? 'cheap-source-map' : 'cheap-source-map',
|
|
519
|
+
mode: productionMode ? 'production' : 'development',
|
|
520
|
+
//fixing a persistent but strange build error here that showed up once, this is a workaround. See: https://github.com/webpack-contrib/css-loader/issues/447
|
|
521
|
+
node: {
|
|
522
|
+
fs: 'empty',
|
|
523
|
+
child_process: 'empty'
|
|
524
|
+
},
|
|
525
|
+
resolve: {
|
|
526
|
+
extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
|
|
527
|
+
alias: aliases,
|
|
528
|
+
plugins: resolvePlugins
|
|
529
|
+
},
|
|
530
|
+
resolveLoader: {
|
|
531
|
+
modules: [
|
|
532
|
+
path.join(__dirname, 'plugins'),
|
|
533
|
+
path.join(__dirname, 'node_modules'),
|
|
534
|
+
'node_modules',
|
|
535
|
+
]
|
|
536
|
+
},
|
|
537
|
+
optimization: {
|
|
538
|
+
minimize: productionMode,
|
|
539
|
+
minimizer: [
|
|
540
|
+
new TerserPlugin({
|
|
541
|
+
extractComments: {
|
|
542
|
+
condition: /^\**!|@preserve|@license|@cc_on/i,
|
|
543
|
+
banner: function (licenseFile) {
|
|
544
|
+
return "License information can be found in ".concat(licenseFile, " and oss-licences.json");
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}),
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
watch: watch,
|
|
551
|
+
module: {
|
|
552
|
+
rules: rules
|
|
553
|
+
},
|
|
554
|
+
//See plugins/externalise-modules.ts We're passing in a function here that determines what to exclude from the bundle and what not
|
|
555
|
+
//See also https://webpack.js.org/configuration/externals/
|
|
556
|
+
externals: (0, externalise_modules_1["default"])(config, es5),
|
|
557
|
+
plugins: plugins,
|
|
558
|
+
stats: {
|
|
559
|
+
errorDetails: config.debug,
|
|
560
|
+
chunks: false,
|
|
561
|
+
children: false,
|
|
562
|
+
version: true,
|
|
563
|
+
hash: false,
|
|
564
|
+
modules: false
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
exports.generateWebpackConfig = generateWebpackConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var buildTools = require('lincd-cli');
|
|
2
|
+
module.exports = buildTools.generateGruntConfig('${app_name}', {
|
|
3
|
+
internals: '*', //for applications we tell the bundler to bundle everything
|
|
4
|
+
//externals:{}, //list of non lincd modules that are already loaded and made globally available by one of the dependencies of this module
|
|
5
|
+
//alias:{},//webpack alias -> maps on type of npm path to another
|
|
6
|
+
//target:"es5"|"es6",
|
|
7
|
+
//environment:"server"|"frontend",
|
|
8
|
+
//outputPath:string,
|
|
9
|
+
//es5Server:boolean
|
|
10
|
+
//es5:{},//es5 specific config, use same properties as above
|
|
11
|
+
//es6:{},//es6 specific config, use same properties as above
|
|
12
|
+
//debug:false,//debug the build process
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="stylesheet" type="text/css" href="./dist/${app_name}.css">
|
|
6
|
+
<title>${app_name}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script src="./dist/${app_name}.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "${app_name}",
|
|
3
|
+
"displayName": "${app_name}",
|
|
3
4
|
"version": "0.1.0",
|
|
4
5
|
"description": "",
|
|
5
6
|
"lincd": true,
|
|
6
7
|
"main": "lib/index.js",
|
|
8
|
+
"types": "dist/${app_name}.d.ts",
|
|
7
9
|
"author": "",
|
|
8
10
|
"license": "ISC",
|
|
9
11
|
"scripts": {
|
|
10
12
|
"build": "npm exec lincd build",
|
|
11
13
|
"dev": "npm exec lincd dev",
|
|
12
|
-
"
|
|
14
|
+
"prepublishOnly": "npm exec lincd build production",
|
|
13
15
|
"postpublish": "npm exec lincd publish"
|
|
14
16
|
},
|
|
15
17
|
"keywords": [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"target": "es5",
|
|
6
|
+
"outDir": "lib",
|
|
7
|
+
"declaration": false,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"downlevelIteration": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"jsx": "react",
|
|
14
|
+
"baseUrl": "./",
|
|
15
|
+
"rootDir": "src"
|
|
16
|
+
},
|
|
17
|
+
"files": ["./src/index.tsx"]
|
|
18
|
+
}
|