lincd-cli 0.2.22 → 0.2.25

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.
@@ -18,12 +18,13 @@ const Page1 = lazy(() => import('./pages/Page1' /* webpackPrefetch: true */));
18
18
  declare var window;
19
19
  export default function App({
20
20
  assets = typeof window !== 'undefined' ? window['assetManifest'] : {},
21
- //on the frontend data will not be set yet, but it will be present in the initial HTML as a script tag with JSON-LD inside, with the ID: lincd_data
21
+ //on the frontend data will not be set yet, but it will be present in the initial HTML as a script tag with JSON-LD inside, with the ID: request-ld
22
22
  //so here we read that back to the data variable, so that the rendering (of that same <script> tag) will be identical as the backend
23
- data = typeof document !== 'undefined' ? document.getElementById('lincd_data')?.innerText : null,
23
+ requestLD = typeof document !== 'undefined' ? document.getElementById('request-ld')?.innerText : null,
24
+ requestObject = typeof document !== 'undefined' ? document.getElementById('request-json')?.innerText : null,
24
25
  }) {
25
26
  return (
26
- <Html assets={assets} data={data} title="${name} - LINCD App">
27
+ <Html assets={assets} requestObject={requestObject} requestLD={requestLD} title="${name} - LINCD App">
27
28
  <Suspense fallback={<Spinner />}>
28
29
  <ErrorBoundary FallbackComponent={Error}>
29
30
  <Content />
@@ -90,20 +91,25 @@ function Header() {
90
91
  );
91
92
  }
92
93
 
93
- function Html({assets, data, children, title}) {
94
+ function Html({assets,requestObject,requestLD,children,title}) {
94
95
  return (
95
96
  <html lang="en">
96
97
  {globalThis.document?.head ? (
97
98
  <head dangerouslySetInnerHTML={{__html: document.head.innerHTML}} />
98
99
  ) : (
99
100
  <head>
101
+ <title>{title}</title>
102
+
100
103
  <meta charSet="utf-8" />
101
104
  <meta name="viewport" content="width=device-width, initial-scale=1" />
105
+
102
106
  <link rel="shortcut icon" href="/static/favicon.ico" />
103
107
  <link rel="stylesheet" href={assets['main.css']} />
108
+
104
109
  {assets['tailwind-cdn'] && <script src={assets['tailwind-cdn']}></script>}
105
- <title>{title}</title>
106
- <script id='lincd_data' type='application/ld+json' dangerouslySetInnerHTML={{__html: data}} />
110
+ <script id='request-ld' type='application/ld+json' dangerouslySetInnerHTML={{__html: requestLD}} />
111
+ <script id='request-json' type='application/json' dangerouslySetInnerHTML={{__html: requestObject}} />
112
+
107
113
  </head>
108
114
  )}
109
115
  <body>
@@ -1,3 +1,5 @@
1
+ import {initFrontend} from 'lincd-server-utils/lib/utils/Frontend';
2
+
1
3
  window['$RefreshReg$'] = () => {};
2
4
  window['$RefreshSig$'] = () => () => {};
3
5
 
@@ -12,11 +14,14 @@ import {BackendFileStore} from 'lincd-server/lib/shapes/BackendFileStore';
12
14
  export const store = new BackendFileStore('main');
13
15
  Storage.setDefaultStore(store);
14
16
 
15
- hydrateRoot(
16
- document,
17
- <React.StrictMode>
18
- <BrowserRouter>
19
- <App assets={window['assetManifest']} />
20
- </BrowserRouter>
21
- </React.StrictMode>,
22
- );
17
+
18
+ initFrontend().then(() => {
19
+ hydrateRoot(
20
+ document,
21
+ <React.StrictMode>
22
+ <BrowserRouter>
23
+ <App assets={window['assetManifest']} />
24
+ </BrowserRouter>
25
+ </React.StrictMode>,
26
+ );
27
+ });
@@ -45,6 +45,7 @@
45
45
  "lincd": "^0.5",
46
46
  "lincd-jsonld": "^0.1.5",
47
47
  "lincd-server": "^0.1.19",
48
+ "lincd-server-utils": "^0.1",
48
49
  "react": "^18.2",
49
50
  "react-dom": "^18.2",
50
51
  "react-error-boundary": "^3.1.3",
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -81,9 +104,7 @@ var fs_extra_1 = __importDefault(require("fs-extra"));
81
104
  var utils_1 = require("./utils");
82
105
  var chalk_1 = __importDefault(require("chalk"));
83
106
  var child_process_1 = require("child_process");
84
- var package_metadata_js_1 = require("lincd-modules/lib/scripts/package-metadata.js");
85
107
  var models_1 = require("lincd/lib/models");
86
- var Module_1 = require("lincd-modules/lib/shapes/Module");
87
108
  var env_cmd_1 = require("env-cmd");
88
109
  var JSONLDWriter_1 = require("lincd-jsonld/lib/utils/JSONLDWriter");
89
110
  var NameSpace_1 = require("lincd/lib/utils/NameSpace");
@@ -302,12 +323,44 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
302
323
  })) {
303
324
  stack.push(pkg);
304
325
  }
305
- // else if(!done.has(package))
306
- // {
307
- // console.log(chalk.red(package+' not yet'))
308
- // console.log('UNMET DEPS: '+deps.filter(dependency => !done.has(dependency)).join(" "))
309
- // }
310
326
  });
327
+ if (stack.length <= 0 && done.size < lincdPackages.size) {
328
+ console.log(chalk_1["default"].red('Only ' + done.size + ' out of ' + lincdPackages.size + ' packages have been built'));
329
+ console.log('ALL remaining packages have dependencies that have not been met. This may point to ' + chalk_1["default"].red('circular dependencies.'));
330
+ console.log('Already built: ' + Array.from(done).map(function (p) { return chalk_1["default"].green(p.packageName); }).join(', '));
331
+ console.log(chalk_1["default"].blue('\nTo solve this issue') + ': find the circular dependencies below and fix the dependencies:\n\n');
332
+ //TODO: actually find and name the packages that have circular dependencies
333
+ // let circular = [];
334
+ // lincdPackages.forEach((pkg) => {
335
+ // if (!done.has(pkg))
336
+ // {
337
+ // let deps = dependencies.get(pkg);
338
+ // if (deps.some(dependency => {
339
+ // //return true if this dependency (indirectly) depends on the package whos' dependency it is
340
+ // return hasDependency(dependency,pkg,dependencies)
341
+ // }))
342
+ // {
343
+ // circular.push(pkg);
344
+ // }
345
+ // process.exit();
346
+ // }
347
+ // });
348
+ lincdPackages.forEach(function (pkg) {
349
+ var deps = dependencies.get(pkg);
350
+ if (!done.has(pkg)) {
351
+ console.log(chalk_1["default"].red(pkg.packageName) + ' has not been built yet. Unbuilt dependencies:\n' + deps.filter(function (dependency) {
352
+ return !Array.from(done).some(function (p) {
353
+ // console.log(p.packageName,dependency.packageName,p===dependency)
354
+ return p === dependency;
355
+ });
356
+ }).map(function (p) { return chalk_1["default"].red('\t- ' + p.packageName + '\n'); }).join(" "));
357
+ // console.log(chalk.red(pkg.packageName)+' has not been built yet. Built dependencies:\n' + deps.filter(dependency => {
358
+ // return Array.from(done).some(p => p.packageName === pkg.packageName)
359
+ // }).map(p => chalk.green('\t- '+p.packageName+'\n')).join(" "))
360
+ // console.log(chalk.red(pkg.packageName)+' has not been built yet. Built dependencies:\n' + deps.filter(dependency => done.has(pkg)).map(p => chalk.green('\t- '+p.packageName+'\n')).join(" "))
361
+ }
362
+ });
363
+ }
311
364
  //if more to be built, iterate
312
365
  if (stack.length > 0) {
313
366
  return [2 /*return*/, runStack(stack)];
@@ -322,6 +375,23 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
322
375
  //starts the process
323
376
  runStack(startStack);
324
377
  }
378
+ function hasDependency(pkg, childPkg, dependencies, depth) {
379
+ if (depth === void 0) { depth = 1; }
380
+ console.log("Does " + pkg.packageName + " have dep " + childPkg.packageName + " ?");
381
+ var deps = dependencies.get(pkg);
382
+ if (deps.some(function (dependency) {
383
+ console.log(dependency.packageName, childPkg.packageName, dependency === childPkg);
384
+ if (depth === 2)
385
+ return false;
386
+ // return dependency === childPkg;
387
+ return dependency === childPkg || hasDependency(dependency, childPkg, dependencies, depth++);
388
+ })) {
389
+ console.log("##YES");
390
+ return true;
391
+ }
392
+ console.log("going up");
393
+ return false;
394
+ }
325
395
  function buildAll(target, target2, target3) {
326
396
  var _this = this;
327
397
  console.log('Building all LINCD packages of this repository in order of dependencies');
@@ -362,8 +432,9 @@ function buildAll(target, target2, target3) {
362
432
  }
363
433
  debugInfo('Now building: ' + chalk_1["default"].blue(packageGroup.map(function (i) { return i.packageName; })));
364
434
  return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
365
- var command;
435
+ var command, skipping;
366
436
  return __generator(this, function (_a) {
437
+ skipping = false;
367
438
  //if we're skipping builds until a certain package
368
439
  if (!building) {
369
440
  //if the package name matches the package we're supposed to start from then start building packages
@@ -374,6 +445,7 @@ function buildAll(target, target2, target3) {
374
445
  else {
375
446
  log(chalk_1["default"].blue('skipping ' + pkg.packageName));
376
447
  command = Promise.resolve(true);
448
+ skipping = true;
377
449
  }
378
450
  }
379
451
  //unless told otherwise, build the package
@@ -403,7 +475,9 @@ function buildAll(target, target2, target3) {
403
475
  }
404
476
  })
405
477
  .then(function (res) {
406
- log(chalk_1["default"].green('Built ' + pkg.packageName));
478
+ if (!skipping) {
479
+ log(chalk_1["default"].green('Built ' + pkg.packageName));
480
+ }
407
481
  done.add(pkg);
408
482
  packagesLeft--;
409
483
  // log(chalk.magenta(packagesLeft + ' packages left'));
@@ -959,7 +1033,7 @@ var register = function (registryURL) {
959
1033
  };
960
1034
  exports.register = register;
961
1035
  var buildMetadata = function () { return __awaiter(void 0, void 0, void 0, function () {
962
- var app, envVars, updatedPaths, localPackagePaths, metadataFolder, _loop_1, localPackagePaths_1, localPackagePaths_1_1, _a, packageCodeName, packagePath, lincdPackagePath, isAppPackage, e_1_1, packageMetaData, metadataFile;
1036
+ var app, envVars, updatedPaths, localPackagePaths, metadataFolder, _loop_1, localPackagePaths_1, localPackagePaths_1_1, _a, packageCodeName, packagePath, lincdPackagePath, isAppPackage, packageMetaData, metadataFile;
963
1037
  var e_1, _b;
964
1038
  return __generator(this, function (_c) {
965
1039
  switch (_c.label) {
@@ -986,13 +1060,12 @@ var buildMetadata = function () { return __awaiter(void 0, void 0, void 0, funct
986
1060
  case 2:
987
1061
  _c.sent(); //{recursive:true} but not needed with fs-extra
988
1062
  _loop_1 = function (packageCodeName, packagePath, lincdPackagePath, isAppPackage) {
989
- var errors;
990
- return __generator(this, function (_d) {
991
- switch (_d.label) {
992
- case 0:
993
- errors = false;
994
- return [4 /*yield*/, (0, package_metadata_js_1.getPackageMetadata)(packagePath, lincdPackagePath).then(function (response) { return __awaiter(void 0, void 0, void 0, function () {
995
- var pkg, lincdApp, packageMetaData_1, metadataFile_1;
1063
+ var errors = false;
1064
+ Promise.resolve().then(function () { return __importStar(require('lincd-modules/lib/scripts/package-metadata.js')); }).then(function (script) { return __awaiter(void 0, void 0, void 0, function () {
1065
+ return __generator(this, function (_a) {
1066
+ switch (_a.label) {
1067
+ case 0: return [4 /*yield*/, script.getPackageMetadata(packagePath, lincdPackagePath).then(function (response) { return __awaiter(void 0, void 0, void 0, function () {
1068
+ var pkgNode, lincdApp, packageMetaData_1, metadataFile_1;
996
1069
  return __generator(this, function (_a) {
997
1070
  switch (_a.label) {
998
1071
  case 0:
@@ -1003,16 +1076,16 @@ var buildMetadata = function () { return __awaiter(void 0, void 0, void 0, funct
1003
1076
  errors = true;
1004
1077
  return [3 /*break*/, 3];
1005
1078
  case 1:
1006
- pkg = Module_1.Module.getFromURI(response.packageUri);
1079
+ pkgNode = models_1.NamedNode.getOrCreate(response.packageUri);
1007
1080
  lincdApp = (0, NameSpace_1.createNameSpace)('http://lincd.org/ont/lincd-app/');
1008
1081
  Prefix_1.Prefix.add('lincdApp', 'http://lincd.org/ont/lincd-app/');
1009
1082
  if (isAppPackage) {
1010
1083
  //Note: this needs to match with LincdWebApp.ownPackage accessor;
1011
- app.overwrite(lincdApp('ownPackage'), pkg.namedNode);
1084
+ app.overwrite(lincdApp('ownPackage'), pkgNode);
1012
1085
  }
1013
1086
  else {
1014
1087
  //Note: this needs to match with LincdWebApp.packages accessor;
1015
- app.set(lincdApp('maintainsPackage'), pkg.namedNode);
1088
+ app.set(lincdApp('maintainsPackage'), pkgNode);
1016
1089
  }
1017
1090
  packageMetaData_1 = JSON.stringify(response.result, null, 2);
1018
1091
  metadataFile_1 = path_1["default"].join(metadataFolder, packageCodeName + '.json');
@@ -1026,46 +1099,34 @@ var buildMetadata = function () { return __awaiter(void 0, void 0, void 0, funct
1026
1099
  }
1027
1100
  });
1028
1101
  }); })];
1029
- case 1:
1030
- _d.sent();
1031
- return [2 /*return*/];
1032
- }
1033
- });
1102
+ case 1:
1103
+ _a.sent();
1104
+ return [2 /*return*/];
1105
+ }
1106
+ });
1107
+ }); });
1034
1108
  };
1035
- _c.label = 3;
1036
- case 3:
1037
- _c.trys.push([3, 8, 9, 10]);
1038
- localPackagePaths_1 = __values(localPackagePaths), localPackagePaths_1_1 = localPackagePaths_1.next();
1039
- _c.label = 4;
1040
- case 4:
1041
- if (!!localPackagePaths_1_1.done) return [3 /*break*/, 7];
1042
- _a = __read(localPackagePaths_1_1.value, 4), packageCodeName = _a[0], packagePath = _a[1], lincdPackagePath = _a[2], isAppPackage = _a[3];
1043
- return [5 /*yield**/, _loop_1(packageCodeName, packagePath, lincdPackagePath, isAppPackage)];
1044
- case 5:
1045
- _c.sent();
1046
- _c.label = 6;
1047
- case 6:
1048
- localPackagePaths_1_1 = localPackagePaths_1.next();
1049
- return [3 /*break*/, 4];
1050
- case 7: return [3 /*break*/, 10];
1051
- case 8:
1052
- e_1_1 = _c.sent();
1053
- e_1 = { error: e_1_1 };
1054
- return [3 /*break*/, 10];
1055
- case 9:
1056
1109
  try {
1057
- if (localPackagePaths_1_1 && !localPackagePaths_1_1.done && (_b = localPackagePaths_1["return"])) _b.call(localPackagePaths_1);
1110
+ for (localPackagePaths_1 = __values(localPackagePaths), localPackagePaths_1_1 = localPackagePaths_1.next(); !localPackagePaths_1_1.done; localPackagePaths_1_1 = localPackagePaths_1.next()) {
1111
+ _a = __read(localPackagePaths_1_1.value, 4), packageCodeName = _a[0], packagePath = _a[1], lincdPackagePath = _a[2], isAppPackage = _a[3];
1112
+ _loop_1(packageCodeName, packagePath, lincdPackagePath, isAppPackage);
1113
+ }
1114
+ }
1115
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1116
+ finally {
1117
+ try {
1118
+ if (localPackagePaths_1_1 && !localPackagePaths_1_1.done && (_b = localPackagePaths_1["return"])) _b.call(localPackagePaths_1);
1119
+ }
1120
+ finally { if (e_1) throw e_1.error; }
1058
1121
  }
1059
- finally { if (e_1) throw e_1.error; }
1060
- return [7 /*endfinally*/];
1061
- case 10: return [4 /*yield*/, JSONLDWriter_1.JSONLDWriter.stringify(app, process.env.NODE_ENV === 'development')];
1062
- case 11:
1122
+ return [4 /*yield*/, JSONLDWriter_1.JSONLDWriter.stringify(app, process.env.NODE_ENV === 'development')];
1123
+ case 3:
1063
1124
  packageMetaData = _c.sent();
1064
1125
  metadataFile = path_1["default"].join(metadataFolder, '_app.json');
1065
1126
  return [4 /*yield*/, fs_extra_1["default"].writeFile(metadataFile, packageMetaData).then(function () {
1066
1127
  updatedPaths.push(metadataFile);
1067
1128
  })];
1068
- case 12:
1129
+ case 4:
1069
1130
  _c.sent();
1070
1131
  return [2 /*return*/, updatedPaths];
1071
1132
  }
@@ -1425,8 +1486,8 @@ var buildUpdated = function (back, target, target2, test) {
1425
1486
  rebuildAllModules = false;
1426
1487
  packagesLeft = packages.size;
1427
1488
  runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
1428
- // console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
1429
- // console.log((packagesLeft) + " packages left.");
1489
+ debugInfo('Now checking: ' + chalk_1["default"].blue(packageGroup.map(function (i) { return i.packageName; })));
1490
+ debugInfo((packagesLeft) + " packages left.");
1430
1491
  packagesLeft = packagesLeft - packageGroup.length;
1431
1492
  return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
1432
1493
  var needRebuild;
@@ -1483,12 +1544,12 @@ var buildUpdated = function (back, target, target2, test) {
1483
1544
  });
1484
1545
  };
1485
1546
  exports.buildUpdated = buildUpdated;
1486
- var needsRebuilding = function (pkg, logDetailsIfTrue) {
1487
- if (logDetailsIfTrue === void 0) { logDetailsIfTrue = false; }
1547
+ var needsRebuilding = function (pkg, log) {
1548
+ if (log === void 0) { log = false; }
1488
1549
  var lastModifiedSource = getLastModifiedSourceTime(pkg.path);
1489
1550
  var lastModifiedBundle = getLastBuildTime(pkg.path);
1490
1551
  var result = lastModifiedSource.lastModifiedTime > lastModifiedBundle.lastModifiedTime;
1491
- if (logDetailsIfTrue) {
1552
+ if (log) {
1492
1553
  debugInfo(chalk_1["default"].cyan('Last modified source: ' +
1493
1554
  lastModifiedSource.lastModifiedName +
1494
1555
  ' on ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.22",
3
+ "version": "0.2.25",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -60,7 +60,7 @@
60
60
  "license-info-webpack-plugin": "^3.0.0",
61
61
  "lincd": "^0.5",
62
62
  "lincd-app": "^0.1",
63
- "lincd-jsonld": "^0.1",
63
+ "lincd-jsonld": "^0.1.13",
64
64
  "lincd-modules": "^0.1",
65
65
  "load-grunt-tasks": "^5.1.0",
66
66
  "mini-css-extract-plugin": "^2.7.5",