lincd-cli 0.1.14 → 0.1.15
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/defaults/{app3/.env-cmdrc → app-with-backend/.env-cmdrc.json} +1 -1
- package/defaults/app-with-backend/babel.config.js +10 -0
- package/defaults/app-with-backend/backend/server.js +5 -0
- package/defaults/{app3 → app-with-backend}/frontend/scripts/build.js +15 -15
- package/defaults/app-with-backend/frontend/src/App.scss +45 -0
- package/defaults/app-with-backend/frontend/src/App.scss.json +1 -0
- package/defaults/app-with-backend/frontend/src/App.tsx +123 -0
- package/defaults/{app3 → app-with-backend}/frontend/src/components/Spinner.scss +1 -2
- package/defaults/app-with-backend/frontend/src/components/Spinner.scss.json +1 -0
- package/defaults/{app3 → app-with-backend}/frontend/src/components/Spinner.tsx +1 -1
- package/defaults/{app3 → app-with-backend}/frontend/src/index.tsx +0 -4
- package/defaults/app-with-backend/frontend/src/pages/Home.tsx +14 -0
- package/defaults/app-with-backend/frontend/src/pages/Page1.tsx +7 -0
- package/defaults/{app2 → app-with-backend}/frontend/web/favicon.ico +0 -0
- package/defaults/{app3 → app-with-backend}/package.json +12 -11
- package/defaults/{app3 → app-with-backend}/tsconfig.json +0 -0
- package/lib/cli.js +3 -3
- package/lib/config-grunt.js +1 -4
- package/lib/config-webpack.js +74 -40
- package/lib/plugins/declaration-plugin.js +75 -69
- package/lib/plugins/externalise-modules.js +30 -14
- package/package.json +24 -18
- package/defaults/app2/backend/src/server.js +0 -152
- package/defaults/app2/backend/src/server.js.map +0 -1
- package/defaults/app2/backend/src/server.tsx +0 -137
- package/defaults/app2/frontend/scripts/build.js +0 -100
- package/defaults/app2/frontend/src/App.js +0 -52
- package/defaults/app2/frontend/src/App.js.map +0 -1
- package/defaults/app2/frontend/src/App.tsx +0 -35
- package/defaults/app2/frontend/src/Html.js +0 -12
- package/defaults/app2/frontend/src/Html.js.map +0 -0
- package/defaults/app2/frontend/src/Html.tsx +0 -29
- package/defaults/app2/frontend/src/Layout.js +0 -153
- package/defaults/app2/frontend/src/Layout.js.map +0 -1
- package/defaults/app2/frontend/src/Layout.tsx +0 -5
- package/defaults/app2/frontend/src/Spinner.js +0 -9
- package/defaults/app2/frontend/src/Spinner.js.map +0 -0
- package/defaults/app2/frontend/src/Spinner.scss +0 -17
- package/defaults/app2/frontend/src/Spinner.tsx +0 -10
- package/defaults/app2/frontend/src/index.js +0 -14
- package/defaults/app2/frontend/src/index.js.map +0 -0
- package/defaults/app2/frontend/src/index.tsx +0 -16
- package/defaults/app2/package.json +0 -71
- package/defaults/app2/tailwind.config.js +0 -3
- package/defaults/app2/tsconfig.json +0 -17
- package/defaults/app3/backend/server.js +0 -5
- package/defaults/app3/frontend/scripts/webpack-config.js +0 -121
- package/defaults/app3/frontend/src/App.tsx +0 -72
- package/defaults/app3/frontend/src/Header.tsx +0 -16
- package/defaults/app3/frontend/src/Html.tsx +0 -29
- package/defaults/app3/frontend/src/Layout.tsx +0 -11
- package/defaults/app3/frontend/src/_tailwind.scss +0 -3
- package/defaults/app3/frontend/src/pages/Home.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page1.scss +0 -3
- package/defaults/app3/frontend/src/pages/Page1.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page1.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page2.scss +0 -16
- package/defaults/app3/frontend/src/pages/Page2.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page2.tsx +0 -21
- package/defaults/app3/frontend/web/favicon.ico +0 -0
- package/defaults/app3/tailwind.config.js +0 -3
- package/plugins/declaration-plugin.js +0 -248
- package/plugins/externalise-modules.js +0 -161
- package/plugins/watch-run.js +0 -47
|
@@ -3,6 +3,8 @@ exports.__esModule = true;
|
|
|
3
3
|
/// <reference path="colors.d.ts" />
|
|
4
4
|
var colors = require("colors");
|
|
5
5
|
var path = require("path");
|
|
6
|
+
var webpack = require('webpack');
|
|
7
|
+
var Compilation = webpack.Compilation;
|
|
6
8
|
var DeclarationPlugin = /** @class */ (function () {
|
|
7
9
|
function DeclarationPlugin(options) {
|
|
8
10
|
if (options === void 0) { options = {}; }
|
|
@@ -17,71 +19,83 @@ var DeclarationPlugin = /** @class */ (function () {
|
|
|
17
19
|
this.modulePackageInfo = require(process.cwd() + '/package.json');
|
|
18
20
|
// this.debug('found package name: '+this.modulePackageInfo.name);
|
|
19
21
|
}
|
|
22
|
+
// apply(compiler) {
|
|
23
|
+
// // Specify the event hook to attach to
|
|
24
|
+
// compiler.hooks.emit.tapAsync(
|
|
25
|
+
// 'MyExampleWebpackPlugin',
|
|
26
|
+
// (compilation, callback) => {
|
|
27
|
+
//
|
|
28
|
+
// }
|
|
20
29
|
DeclarationPlugin.prototype.apply = function (compiler) {
|
|
21
30
|
var _this = this;
|
|
22
|
-
this.debug('applying');
|
|
31
|
+
this.debug('applying ');
|
|
23
32
|
//when the compiler is ready to emit files
|
|
24
33
|
// compiler.plugin('emit', (compilation,callback) =>
|
|
25
|
-
compiler.hooks.
|
|
26
|
-
//
|
|
27
|
-
// this
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
_this.declarationFiles[filename] = compilation.assets[filename];
|
|
41
|
-
// this.debug('not using: '+filename);
|
|
42
|
-
delete compilation.assets[filename];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (Object.keys(_this.declarationFiles).length == 0) {
|
|
46
|
-
_this.log('Cannot build .d.ts file because no declarations where found.'.red);
|
|
47
|
-
_this.log('Make sure to add '.yellow + '"declaration":true'.blue.bold['underline'] + ' to tsconfig.json'.yellow);
|
|
48
|
-
_this.log('Make sure to run '.yellow + 'tsc'.blue + ' before running webpack'.yellow);
|
|
49
|
-
_this.log('Make sure to test for '.yellow +
|
|
50
|
-
'/(?!.*.d.ts).ts(x?)$/'.blue.bold['underline'] +
|
|
51
|
-
' in the ts-loader in webpack.config.json'.yellow);
|
|
52
|
-
_this.log(('Assets: ' + Object.keys(compilation.assets).toString()).yellow);
|
|
53
|
-
callback();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
//var moduleConfig = this.getModuleConfig();
|
|
57
|
-
//this.debug(moduleConfig);
|
|
58
|
-
//if (moduleConfig)
|
|
59
|
-
//{
|
|
60
|
-
//combine them into one declaration file
|
|
61
|
-
var combinedDeclaration = _this.generateCombinedDeclaration(_this.declarationFiles); //moduleConfig
|
|
62
|
-
//and insert that back into the assets
|
|
63
|
-
compilation.assets[_this.options.out] = {
|
|
64
|
-
source: function () {
|
|
65
|
-
return combinedDeclaration;
|
|
66
|
-
},
|
|
67
|
-
size: function () {
|
|
68
|
-
return combinedDeclaration.length;
|
|
34
|
+
compiler.hooks.compilation.tap('DeclarationPlugin', function (compilation) {
|
|
35
|
+
//NOTE: even though the stage comes from the processAssets hook and not the afterProcessAssets hook
|
|
36
|
+
// somehow this only works WITH the stage defined
|
|
37
|
+
compilation.hooks.afterProcessAssets.tap({
|
|
38
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
|
|
39
|
+
name: 'DeclarationPlugin'
|
|
40
|
+
}, function () {
|
|
41
|
+
// this.debug('indexing and removing declaration assets');
|
|
42
|
+
//collect all generated declaration files
|
|
43
|
+
//and remove them from the assets that will be emitted
|
|
44
|
+
//NOTE: at some point we decided to overwrite declaration files between emits because sometimes only one new declaration file is emitted
|
|
45
|
+
//this may cause issues when you remove a file during the continuous building process, but better than the other way around for now
|
|
46
|
+
if (!_this.declarationFiles) {
|
|
47
|
+
_this.declarationFiles = {};
|
|
69
48
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
49
|
+
compilation.getAssets().forEach(function (asset, key) {
|
|
50
|
+
// this.debug('key '+key.toString())
|
|
51
|
+
// this.debug('value '+Object.getOwnPropertyNames(asset).join(", "))
|
|
52
|
+
// this.debug('asset: ' + asset.name);
|
|
53
|
+
if (asset.name.indexOf('.d.ts') !== -1) {
|
|
54
|
+
if (_this.declarationFiles[asset.name]) {
|
|
55
|
+
_this.debug('overwriting ' + asset.name);
|
|
56
|
+
}
|
|
57
|
+
_this.declarationFiles[asset.name] = asset;
|
|
58
|
+
_this.debug('indexed and removed asset: ' + colors.green(asset.name));
|
|
59
|
+
compilation.deleteAsset(asset.name);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (Object.keys(_this.declarationFiles).length == 0) {
|
|
63
|
+
_this.log('Cannot build .d.ts file because no declarations where found.'.red);
|
|
64
|
+
_this.log('Make sure to add '.yellow + '"declaration":true'.blue.bold['underline'] + ' to tsconfig.json'.yellow);
|
|
65
|
+
_this.log('Make sure to run '.yellow + 'tsc'.blue + ' before running webpack'.yellow);
|
|
66
|
+
_this.log('Make sure to test for '.yellow +
|
|
67
|
+
'/(?!.*.d.ts).ts(x?)$/'.blue.bold['underline'] +
|
|
68
|
+
' in the ts-loader in webpack.config.json'.yellow);
|
|
69
|
+
_this.log(('Assets: ' + Object.keys(compilation.assets).toString()).yellow);
|
|
70
|
+
// callback();
|
|
71
|
+
return;
|
|
80
72
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
//combine them into one declaration file
|
|
74
|
+
var combinedDeclaration = _this.generateCombinedDeclaration(_this.declarationFiles); //moduleConfig
|
|
75
|
+
//and insert that back into the assets
|
|
76
|
+
// compilation.assets[this.options.out] = {
|
|
77
|
+
// source: function() {
|
|
78
|
+
// return combinedDeclaration;
|
|
79
|
+
// },
|
|
80
|
+
// size: function() {
|
|
81
|
+
// return combinedDeclaration.length;
|
|
82
|
+
// },
|
|
83
|
+
// };
|
|
84
|
+
// As suggested by @JonWallsten here: https://github.com/TypeStrong/ts-loader/pull/1251#issuecomment-800032753
|
|
85
|
+
compilation.emitAsset(_this.options.out, new webpack.sources.RawSource(combinedDeclaration));
|
|
86
|
+
//get meta data from module exports
|
|
87
|
+
/*var metaRdfJson = this.generateMetaRdfJson(compilation,moduleConfig);
|
|
88
|
+
//and insert that back into the assets as [module_name].meta.json
|
|
89
|
+
compilation.assets[this.options.out.replace(".d.ts",".meta.rdf.json")] = {
|
|
90
|
+
source: function() {
|
|
91
|
+
return metaRdfJson;
|
|
92
|
+
},
|
|
93
|
+
size: function() {
|
|
94
|
+
return metaRdfJson.length;
|
|
95
|
+
}
|
|
96
|
+
};*/
|
|
97
|
+
//}
|
|
98
|
+
});
|
|
85
99
|
});
|
|
86
100
|
};
|
|
87
101
|
DeclarationPlugin.prototype.debug = function () {
|
|
@@ -111,13 +125,12 @@ var DeclarationPlugin = /** @class */ (function () {
|
|
|
111
125
|
var basePath = process.cwd().replace(/\\/g, '/') + '/';
|
|
112
126
|
this.debug('Base path:', colors.blue(basePath));
|
|
113
127
|
var npmModuleName = this.modulePackageInfo.name;
|
|
114
|
-
|
|
128
|
+
// let moduleName = npmModuleName.replace(/\@\w+\//, '');
|
|
115
129
|
var importMap = {};
|
|
116
130
|
for (var declarationFileName in declarationFiles) {
|
|
117
131
|
//this.debug("Parsing "+declarationFileName);
|
|
118
132
|
var declarationFile = declarationFiles[declarationFileName];
|
|
119
|
-
|
|
120
|
-
var data = declarationFile.source();
|
|
133
|
+
var data = declarationFile.source.source();
|
|
121
134
|
if (!data.split) {
|
|
122
135
|
console.warn(typeof data, declarationFileName + ' - cannot split declaration contents. Not a string?');
|
|
123
136
|
continue;
|
|
@@ -167,23 +180,16 @@ var DeclarationPlugin = /** @class */ (function () {
|
|
|
167
180
|
lines[i] = lines[i];
|
|
168
181
|
}
|
|
169
182
|
}
|
|
170
|
-
//declare module '@dacore/dacore-es6/lib/sub/File' {
|
|
171
|
-
//@dacore/core/F:/wamp-new/www/dacore/modules/core/lib/ontologies/xsd
|
|
172
|
-
//F:/wamp-new/www/dacore/modules/core/lib/ontologies/xsd.d.ts
|
|
173
|
-
// var declarationFileNameWithoutBase = declarationFileName.substr(0,basePath.length) == basePath ? declarationFileName.substr(basePath.length) : declarationFileName;
|
|
174
183
|
//TS Loader now uses paths relative to output dir. so here we remove a single ../ from the path (which is in there because /builds is the output dir and /lib is the relative path of the file)
|
|
175
184
|
var fixedDeclarationPath = declarationFileName.replace(/\\/g, '/').replace('../', '').replace('.d.ts', '');
|
|
176
185
|
var moduleDeclaration = npmModuleName + '/' + fixedDeclarationPath;
|
|
177
|
-
//var moduleDeclaration = npmModuleName+'/'+declarationFileName.replace(/\\/g,"/").replace(".d.ts","");
|
|
178
186
|
//this.debug('basePath:'+basePath);
|
|
179
187
|
declarations += "declare module '" + moduleDeclaration + "' {\n\t" + lines.join('\n\t') + '\n}\n\n';
|
|
180
|
-
// this.debug('fixed:'+declarationFileName+' -> '+fixedDeclarationPath);
|
|
181
188
|
this.debug('Defining module ' + colors.yellow(moduleDeclaration) + ' from ' + colors.blue(declarationFileName));
|
|
182
189
|
}
|
|
183
190
|
for (var relativeImportPath in importMap) {
|
|
184
191
|
var absoluteImportPath_1 = importMap[relativeImportPath];
|
|
185
192
|
var npmImportModule = npmModuleName + '/' + absoluteImportPath_1.substr(basePath.length).replace('.d.ts', '').replace(/\\/g, '/');
|
|
186
|
-
//this.debug("From: "+absoluteImportPath+" to npm: "+npmImportModule);
|
|
187
193
|
this.debug('Replacing ' + colors.blue(relativeImportPath) + ' with ' + colors.yellow(npmImportModule));
|
|
188
194
|
//wrap in quotes to omit problems with replacing partials and having to fix order of replacements
|
|
189
195
|
declarations = declarations.replace(new RegExp('(\'|")' + relativeImportPath + '(\'|")', 'g'), '"' + npmImportModule + '"');
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
/// <reference path="colors.d.ts" />
|
|
4
4
|
var colors = require("colors");
|
|
5
|
-
var included = [];
|
|
6
5
|
var exportRoot = '/lib';
|
|
7
6
|
var libraryName = 'lincd';
|
|
8
7
|
var lincdModules = new Map();
|
|
8
|
+
var excluded = new Set();
|
|
9
|
+
var includedInternals = new Set();
|
|
10
|
+
var excludedExternals = new Set();
|
|
11
|
+
var includedLincdModules = new Set();
|
|
9
12
|
//This function determines which modules that are requested by the module being built are external
|
|
10
|
-
//it basically turns every import from
|
|
13
|
+
//it basically turns every import from a lincd module into a lookup for that class/object in the global lincd object
|
|
11
14
|
//See also: https://webpack.js.org/configuration/externals/
|
|
12
15
|
var externaliseModules = function (config, es5) {
|
|
13
16
|
function debug() {
|
|
@@ -28,12 +31,19 @@ var externaliseModules = function (config, es5) {
|
|
|
28
31
|
msgs.unshift('externals: ');
|
|
29
32
|
console.log.apply(null, msgs);
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
// let externalKeys: string[] = config.externals ? Object.keys(config.externals) : [];
|
|
32
35
|
//return the function that is handed to webpack in the 'externals' option.
|
|
33
36
|
//it determines for each request what is external and what is not
|
|
34
|
-
return function (
|
|
37
|
+
return function (_a, callback) {
|
|
38
|
+
// debug('checking '+request);
|
|
39
|
+
// debug('imported by '+contextInfo.issuer);
|
|
40
|
+
var context = _a.context, request = _a.request, contextInfo = _a.contextInfo;
|
|
35
41
|
if (config.externals && config.externals[request]) {
|
|
36
|
-
|
|
42
|
+
if (!excludedExternals.has(request)) {
|
|
43
|
+
excludedExternals.add(request);
|
|
44
|
+
// debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
|
|
45
|
+
debug(colors.red(request) + ' is defined as external --> excluded');
|
|
46
|
+
}
|
|
37
47
|
// return callback(config.externals[request]);
|
|
38
48
|
return callback(null, 'var ' + config.externals[request]);
|
|
39
49
|
}
|
|
@@ -84,29 +94,35 @@ var externaliseModules = function (config, es5) {
|
|
|
84
94
|
// --> match[0] = @dacore/some-mod
|
|
85
95
|
// --> match[1] = @dacore
|
|
86
96
|
// --> match[2] = some-mod
|
|
87
|
-
var
|
|
97
|
+
var _b = request.match(/(@[\w\-]+\/)?([\w\-]+)/), packageName = _b[0], scope = _b[1], cleanPackageName = _b[2];
|
|
88
98
|
//if this module is listed as internal module in the config (or if we internalize all modules with '*')
|
|
89
99
|
if (config && config.internals && (config.internals.indexOf(packageName) !== -1 || config.internals === '*')) {
|
|
90
100
|
//then don't exclude and don't continue this function
|
|
91
101
|
//only log once
|
|
92
|
-
if (
|
|
93
|
-
|
|
102
|
+
if (!includedInternals.has(packageName)) {
|
|
103
|
+
includedInternals.add(packageName);
|
|
104
|
+
debug(colors.blue(request) + ' marked internal --> included');
|
|
94
105
|
}
|
|
95
|
-
debug(colors.blue('marked internal & will be included: ' + request));
|
|
96
106
|
return callback();
|
|
97
107
|
}
|
|
98
108
|
//check if this module is a lincd module
|
|
99
109
|
var isLincd = isLincdModule(debug, packageName);
|
|
100
110
|
if (isLincd) {
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
if (!includedLincdModules.has(packageName)) {
|
|
112
|
+
includedLincdModules.add(packageName);
|
|
113
|
+
debug(colors.magenta(packageName +
|
|
114
|
+
' is a lincd module, imports will be excluded from this bundle and refer to a global variable instead'));
|
|
115
|
+
}
|
|
103
116
|
}
|
|
104
117
|
else {
|
|
105
|
-
|
|
118
|
+
//avoid duplicate messages
|
|
119
|
+
if (!excluded.has(packageName)) {
|
|
120
|
+
excluded.add(packageName);
|
|
121
|
+
debug(colors.green(packageName) + ' --> included');
|
|
122
|
+
}
|
|
106
123
|
return callback();
|
|
107
124
|
}
|
|
108
|
-
//remove export root path (for example with
|
|
109
|
-
//TODO: read this from package.json
|
|
125
|
+
//remove export root path (for example with lincd/lib/models: the module has lib/ as root, so to get to the exported path lincd.models we need to remove it)
|
|
110
126
|
var cleanRequest = request.replace(exportRoot, '');
|
|
111
127
|
var targetVariable;
|
|
112
128
|
//expects a flat export / global tree with all the modules classes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lincd-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Command line tools for the lincd.js library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,16 +25,22 @@
|
|
|
25
25
|
"lincd": "lib/cli.js"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@babel/plugin-proposal-decorators": "^7.19.3",
|
|
29
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
30
|
+
"@babel/preset-env": "^7.19.3",
|
|
31
|
+
"@babel/preset-react": "^7.18.6",
|
|
32
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
28
33
|
"@lodder/grunt-postcss": "^3.1.1",
|
|
29
34
|
"@types/node": "^17.0.14",
|
|
30
35
|
"@types/react": "^18.0.17",
|
|
31
36
|
"@types/react-dom": "^18.0.6",
|
|
37
|
+
"babel-loader": "^8.2.5",
|
|
32
38
|
"chalk": "4.1.0",
|
|
33
39
|
"child-process-promise": "^2.2.1",
|
|
34
40
|
"colors": "^1.4.0",
|
|
35
41
|
"commander": "^9.4.0",
|
|
36
|
-
"css-loader": "^
|
|
37
|
-
"extract-text-webpack-plugin": "^
|
|
42
|
+
"css-loader": "^6.7.1",
|
|
43
|
+
"extract-text-webpack-plugin": "^3.0.2",
|
|
38
44
|
"fs-extra": "^10.1.0",
|
|
39
45
|
"glob": "^7.1.6",
|
|
40
46
|
"grunt": "^1.3.0",
|
|
@@ -43,33 +49,33 @@
|
|
|
43
49
|
"grunt-contrib-copy": "^1.0.0",
|
|
44
50
|
"grunt-exec": "^3.0.0",
|
|
45
51
|
"grunt-ts": "^6.0.0-beta.22",
|
|
46
|
-
"grunt-webpack": "^
|
|
52
|
+
"grunt-webpack": "^5.0.0",
|
|
47
53
|
"license-info-webpack-plugin": "^3.0.0",
|
|
48
54
|
"lincd": "^0.3",
|
|
49
55
|
"lincd-jsonld": "^0.1.4",
|
|
50
56
|
"load-grunt-tasks": "^5.1.0",
|
|
51
|
-
"mini-css-extract-plugin": "^
|
|
57
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
52
58
|
"open": "^8.4.0",
|
|
53
|
-
"postcss": "^8.4.
|
|
54
|
-
"postcss-import": "^
|
|
55
|
-
"postcss-loader": "^
|
|
56
|
-
"postcss-modules": "^
|
|
59
|
+
"postcss": "^8.4.17",
|
|
60
|
+
"postcss-import": "^15.0.0",
|
|
61
|
+
"postcss-loader": "^7.0.1",
|
|
62
|
+
"postcss-modules": "^5.0.0",
|
|
57
63
|
"postcss-nested": "^5.0.6",
|
|
58
|
-
"postcss-scss": "^4.0.
|
|
64
|
+
"postcss-scss": "^4.0.5",
|
|
59
65
|
"require-extensions": "^0.0.4",
|
|
60
|
-
"sass": "^1.
|
|
61
|
-
"sass-loader": "^
|
|
62
|
-
"source-map-loader": "^
|
|
66
|
+
"sass": "^1.55.0",
|
|
67
|
+
"sass-loader": "^13.0.2",
|
|
68
|
+
"source-map-loader": "^4.0.0",
|
|
63
69
|
"tailwindcss": "^3.1.6",
|
|
64
|
-
"terser-webpack-plugin": "^
|
|
65
|
-
"ts-loader": "
|
|
70
|
+
"terser-webpack-plugin": "^5.3.6",
|
|
71
|
+
"ts-loader": "^9.4.1",
|
|
66
72
|
"ts-node": "10.7",
|
|
67
73
|
"tsc-hooks": "^1.1.1",
|
|
68
|
-
"tsconfig-paths-webpack-plugin": "^
|
|
74
|
+
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
69
75
|
"typescript": "4.6.4",
|
|
70
|
-
"webpack": "^
|
|
76
|
+
"webpack": "^5.74.0",
|
|
71
77
|
"webpack-bundle-analyzer": "^4.6.1",
|
|
72
|
-
"webpack-license-plugin": "^4.2.
|
|
78
|
+
"webpack-license-plugin": "^4.2.2"
|
|
73
79
|
},
|
|
74
80
|
"devDependencies": {
|
|
75
81
|
"optimize-css-assets-webpack-plugin": "^6.0.1"
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
//not sure what this does, but removing it causes errors
|
|
7
|
-
// const babelRegister = require('@babel/register');
|
|
8
|
-
// babelRegister({
|
|
9
|
-
// ignore: [/[\\\/](frontend\/build|frontend\/lib|backend\/lib|node_modules)[\\\/]/],
|
|
10
|
-
// presets: [['react-app', {runtime: 'automatic'}]],
|
|
11
|
-
// plugins: ['@babel/transform-modules-commonjs'],
|
|
12
|
-
// });
|
|
13
|
-
//make sure nodejs doesn't choke when css files are imported in js
|
|
14
|
-
const ignore_styles_1 = __importDefault(require("ignore-styles"));
|
|
15
|
-
(0, ignore_styles_1.default)(['.sass', '.scss', '.css']);
|
|
16
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
|
-
const body_parser_1 = __importDefault(require("body-parser"));
|
|
18
|
-
const fs_1 = __importDefault(require("fs"));
|
|
19
|
-
globalThis.fetch = node_fetch_1.default;
|
|
20
|
-
const express = require('express');
|
|
21
|
-
const compress = require('compression');
|
|
22
|
-
const { readFileSync } = require('fs');
|
|
23
|
-
const path = require('path');
|
|
24
|
-
const render_1 = __importDefault(require("./render"));
|
|
25
|
-
const JSONWriter_1 = require("lincd-jsonld/lib/JSONWriter");
|
|
26
|
-
const Schema_1 = require("lincd-graphql/lib/shapes/Schema");
|
|
27
|
-
const GraphQLParser_1 = require("lincd-graphql/lib/GraphQLParser");
|
|
28
|
-
const JSONLDWriter_1 = require("lincd-jsonld/lib/JSONLDWriter");
|
|
29
|
-
const PORT = process.env.PORT || 4000;
|
|
30
|
-
const app = express();
|
|
31
|
-
const REGISTRY_URL = process.env.REGISTRY_URL;
|
|
32
|
-
//does this compress things with gzip?
|
|
33
|
-
app.use(compress());
|
|
34
|
-
app.use(body_parser_1.default.json());
|
|
35
|
-
// app.use(bodyParser.urlencoded({extended: true}));
|
|
36
|
-
app.use('/static', express.static('./frontend/web'));
|
|
37
|
-
app.use('/images', express.static('./frontend/web/images'));
|
|
38
|
-
app.use('/css', express.static('./frontend/web/css'));
|
|
39
|
-
app.use('/js', express.static('./frontend/build'));
|
|
40
|
-
app.get('*', handleErrors(async function (req, res) {
|
|
41
|
-
//make sure the frontend bundle has finished building
|
|
42
|
-
await waitForWebpack();
|
|
43
|
-
(0, render_1.default)(req.url, res);
|
|
44
|
-
}));
|
|
45
|
-
//reject any requests that are not from localhost
|
|
46
|
-
function localOnly(req, res, next) {
|
|
47
|
-
var hostmachine = req.headers.host.split(':')[0];
|
|
48
|
-
if (hostmachine !== 'localhost' && hostmachine !== 'dev.lincd.org' && hostmachine !== 'www.lincd.org') {
|
|
49
|
-
return res.send(401);
|
|
50
|
-
}
|
|
51
|
-
next();
|
|
52
|
-
}
|
|
53
|
-
const sendJson = async function (res, obj) {
|
|
54
|
-
let json = await JSONWriter_1.JSONWriter.stringify(obj, true);
|
|
55
|
-
// console.log('Sending data...', json);
|
|
56
|
-
res.send(json);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Handles data requests from the frontend and sends them off to the registry.
|
|
60
|
-
* We don't expose the registry through a URL. instead we always access it on the local network from the backend.
|
|
61
|
-
*/
|
|
62
|
-
app.post('/request/*', async (req, res) => {
|
|
63
|
-
let url = REGISTRY_URL + req.url.substr('/request'.length);
|
|
64
|
-
let body = req.body;
|
|
65
|
-
// if(Object.keys(body).length === 0)
|
|
66
|
-
// {
|
|
67
|
-
// console.warn("Empty body");
|
|
68
|
-
// console.warn('Content type :'+req.headers['content-type']);
|
|
69
|
-
// res.send(false);
|
|
70
|
-
// return;
|
|
71
|
-
// }
|
|
72
|
-
return (0, node_fetch_1.default)(url, {
|
|
73
|
-
method: 'POST',
|
|
74
|
-
headers: {
|
|
75
|
-
Accept: 'application/json, text/plain, */*',
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify(body),
|
|
79
|
-
})
|
|
80
|
-
.then((res) => {
|
|
81
|
-
if (!res.ok) {
|
|
82
|
-
throw new Error(url + ' returned ' + res.status + ' - ' + res.statusText);
|
|
83
|
-
}
|
|
84
|
-
return res.json();
|
|
85
|
-
})
|
|
86
|
-
.then((jsonObject) => {
|
|
87
|
-
sendJson(res, jsonObject);
|
|
88
|
-
})
|
|
89
|
-
.catch((err) => {
|
|
90
|
-
console.warn('error during internal registry request to ' + url + ': ', err);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
app.post('/api/tools/graphql', async (req, res) => {
|
|
94
|
-
let { url, headers } = req.body;
|
|
95
|
-
// let parser = new GraphQLParser(url);
|
|
96
|
-
let parseResult = await GraphQLParser_1.GraphQLParser.parseSchema(url, headers); //parser.parseSchema();
|
|
97
|
-
if (parseResult instanceof Schema_1.Schema) {
|
|
98
|
-
let rawJSONLD = await JSONLDWriter_1.JSONLDWriter.toJSONObject([parseResult.node, parseResult.publicShapes]);
|
|
99
|
-
fs_1.default.writeFile(path.join('../tmp', url.replace(/[^a-z0-9]+/gi, '-') + '.json'), JSON.stringify(rawJSONLD, null, 2), (err) => {
|
|
100
|
-
console.log(err);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
sendJson(res, parseResult instanceof Schema_1.Schema ? parseResult.node : parseResult);
|
|
104
|
-
// if (type === owl.Ontology) {
|
|
105
|
-
// sendJson(res, instances);
|
|
106
|
-
});
|
|
107
|
-
app
|
|
108
|
-
.listen(PORT, () => {
|
|
109
|
-
console.log(`Up and running at http://localhost:${PORT}`);
|
|
110
|
-
})
|
|
111
|
-
.on('error', function (error) {
|
|
112
|
-
if (error.syscall !== 'listen') {
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
const isPipe = (portOrPipe) => Number.isNaN(portOrPipe);
|
|
116
|
-
const bind = isPipe(PORT) ? 'Pipe ' + PORT : 'Port ' + PORT;
|
|
117
|
-
switch (error.code) {
|
|
118
|
-
case 'EACCES':
|
|
119
|
-
console.error(bind + ' requires elevated privileges');
|
|
120
|
-
process.exit(1);
|
|
121
|
-
break;
|
|
122
|
-
case 'EADDRINUSE':
|
|
123
|
-
console.error(bind + ' is already in use');
|
|
124
|
-
process.exit(1);
|
|
125
|
-
break;
|
|
126
|
-
default:
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
function handleErrors(fn) {
|
|
131
|
-
return async function (req, res, next) {
|
|
132
|
-
try {
|
|
133
|
-
return await fn(req, res);
|
|
134
|
-
}
|
|
135
|
-
catch (x) {
|
|
136
|
-
next(x);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
async function waitForWebpack() {
|
|
141
|
-
while (true) {
|
|
142
|
-
try {
|
|
143
|
-
readFileSync(path.resolve(__dirname, '../../frontend/build/main.js'));
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
console.log('Could not find webpack build output. Will retry in a second...');
|
|
148
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["server.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,wDAAwD;AACxD,oDAAoD;AACpD,kBAAkB;AAClB,sFAAsF;AACtF,qDAAqD;AACrD,mDAAmD;AACnD,MAAM;AAEN,kEAAkE;AAClE,kEAAqC;AACrC,IAAA,uBAAQ,EAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAErC,4DAA+B;AAC/B,8DAAqC;AACrC,4CAAoB;AAGpB,UAAU,CAAC,KAAK,GAAG,oBAAK,CAAC;AAEzB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACn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