lincd-cli 0.2.10 → 0.2.12
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/app-with-backend/.env-cmdrc.json +2 -2
- package/defaults/app-with-backend/.vscode/launch.json +12 -0
- package/defaults/app-with-backend/frontend/scripts/build.js +8 -3
- package/defaults/app-with-backend/frontend/src/App.tsx +11 -11
- package/defaults/app-with-backend/frontend/src/index.tsx +6 -0
- package/defaults/app-with-backend/frontend/src/package.ts +1 -1
- package/defaults/app-with-backend/package.json +4 -4
- package/defaults/package/src/backend.ts +1 -0
- package/defaults/package/src/package.ts +1 -1
- package/lib/cli-methods.js +1548 -0
- package/lib/cli.js +28 -1446
- package/lib/utils.js +90 -18
- package/package.json +6 -4
- package/utils.js +0 -39
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"development": {
|
|
3
3
|
"NODE_ENV": "development",
|
|
4
4
|
"SITE_ROOT": "http://localhost:4000",
|
|
5
5
|
"DATA_ROOT": "http://localhost:4000/data"
|
|
6
6
|
},
|
|
7
|
-
"
|
|
7
|
+
"production": {
|
|
8
8
|
"NODE_ENV": "production",
|
|
9
9
|
"SITE_ROOT": "[define me in .env-cmdrc.json]",
|
|
10
10
|
"DATA_ROOT": "http://localhost:4000/data"
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
const webpack = require('webpack');
|
|
3
3
|
const config = require('lincd-server/site.webpack.config');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const {buildMetadata} = require('lincd-cli/lib/cli-methods');
|
|
6
|
+
|
|
7
|
+
webpack(config, async (err, stats) => {
|
|
7
8
|
if (err) {
|
|
8
9
|
console.error(err.stack || err);
|
|
9
10
|
if (err.details) {
|
|
@@ -17,7 +18,7 @@ webpack(config, (err, stats) => {
|
|
|
17
18
|
console.log('Finished running webpack with errors.');
|
|
18
19
|
info.errors.forEach((e) => console.error(e));
|
|
19
20
|
} else {
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
console.log(
|
|
22
23
|
stats.toString({
|
|
23
24
|
chunks: false,
|
|
@@ -32,6 +33,10 @@ webpack(config, (err, stats) => {
|
|
|
32
33
|
// console.log(
|
|
33
34
|
// chalk.green('\t'+Object.keys(stats.compilation.assets).join('\n\t')),
|
|
34
35
|
// );
|
|
36
|
+
|
|
37
|
+
//build metadata (JSON-LD files containing metadata about the lincd components, shapes & ontologies in this app or its packages)
|
|
38
|
+
let updatedPaths = await buildMetadata();
|
|
39
|
+
console.log(chalk.green("Updated metadata:\n")+" - "+updatedPaths.map(p => chalk.magenta(p.replace(process.cwd(),''))).join("\n - "));
|
|
35
40
|
}
|
|
36
41
|
process.exit();
|
|
37
42
|
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {Link} from 'react-router-dom';
|
|
2
|
-
import {lazy, Suspense} from 'react';
|
|
2
|
+
import React,{lazy, Suspense} from 'react';
|
|
3
3
|
import {ErrorBoundary} from 'react-error-boundary';
|
|
4
4
|
import Spinner from './components/Spinner';
|
|
5
5
|
import {Route, Routes} from 'react-router-dom';
|
|
6
|
-
import {Storage} from 'lincd/lib/utils/Storage';
|
|
7
|
-
import {FrontendFileStore} from 'lincd-server/lib/shapes/FrontendFileStore';
|
|
8
6
|
|
|
9
7
|
//Note that by default LINCD apps are set up with support for SCSS (sass) and CSS Modules
|
|
10
8
|
//So any .scss file needs to be imported by itself
|
|
@@ -17,14 +15,15 @@ import style from './App.scss.json';
|
|
|
17
15
|
const Home = lazy(() => import('./pages/Home' /* webpackPrefetch: true */));
|
|
18
16
|
const Page1 = lazy(() => import('./pages/Page1' /* webpackPrefetch: true */));
|
|
19
17
|
|
|
20
|
-
//store all quads in a file on the backend named 'main'
|
|
21
|
-
export const store = new FrontendFileStore('main');
|
|
22
|
-
Storage.setDefaultStore(store);
|
|
23
|
-
|
|
24
18
|
declare var window;
|
|
25
|
-
export default function App({
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
export default function App({
|
|
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
|
|
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,
|
|
24
|
+
}) {
|
|
25
|
+
return (
|
|
26
|
+
<Html assets={assets} data={data} title="${name} - LINCD App">
|
|
28
27
|
<Suspense fallback={<Spinner />}>
|
|
29
28
|
<ErrorBoundary FallbackComponent={Error}>
|
|
30
29
|
<Content />
|
|
@@ -91,7 +90,7 @@ function Header() {
|
|
|
91
90
|
);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
function Html({assets, children, title}) {
|
|
93
|
+
function Html({assets, data, children, title}) {
|
|
95
94
|
return (
|
|
96
95
|
<html lang="en">
|
|
97
96
|
{globalThis.document?.head ? (
|
|
@@ -104,6 +103,7 @@ function Html({assets, children, title}) {
|
|
|
104
103
|
<link rel="stylesheet" href={assets['main.css']} />
|
|
105
104
|
{assets['tailwind-cdn'] && <script src={assets['tailwind-cdn']}></script>}
|
|
106
105
|
<title>{title}</title>
|
|
106
|
+
<script id='lincd_data' type='application/ld+json' dangerouslySetInnerHTML={{__html: data}} />
|
|
107
107
|
</head>
|
|
108
108
|
)}
|
|
109
109
|
<body>
|
|
@@ -5,6 +5,12 @@ import {hydrateRoot} from 'react-dom/client';
|
|
|
5
5
|
import {BrowserRouter} from 'react-router-dom';
|
|
6
6
|
import App from './App';
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import {Storage} from 'lincd/lib/utils/Storage';
|
|
9
|
+
import {FrontendFileStore} from 'lincd-server/lib/shapes/FrontendFileStore';
|
|
10
|
+
|
|
11
|
+
//store all quads in a file on the backend named 'main'
|
|
12
|
+
export const store = new FrontendFileStore('main');
|
|
13
|
+
Storage.setDefaultStore(store);
|
|
8
14
|
|
|
9
15
|
hydrateRoot(
|
|
10
16
|
document,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import {linkedPackage} from 'lincd/lib/utils/Module';
|
|
2
|
-
export const {linkedComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, packageExports, packageName} =
|
|
2
|
+
export const {linkedComponent, linkedSetComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, packageExports, packageName} =
|
|
3
3
|
linkedPackage('${hyphen_name}');
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "npm run server:dev",
|
|
20
|
-
"build": "env-cmd -e
|
|
21
|
-
"server:dev": "env-cmd -e
|
|
22
|
-
"server:prod": "env-cmd -e
|
|
20
|
+
"build": "env-cmd -e production node frontend/scripts/build.js",
|
|
21
|
+
"server:dev": "env-cmd -e development nodemon --watch ../../modules/lincd-server/lib --watch ../../modules/lincd-server/site.webpack.config.js ./backend/server.js",
|
|
22
|
+
"server:prod": "env-cmd -e production nodemon -e js,json s ./backend/server.js"
|
|
23
23
|
},
|
|
24
24
|
"workspaces" : [
|
|
25
|
-
"
|
|
25
|
+
"packages/*"
|
|
26
26
|
],
|
|
27
27
|
"keywords": [
|
|
28
28
|
"lincd",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//import your providers here (providers only run in the backend)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import {linkedPackage} from 'lincd/lib/utils/Module';
|
|
2
2
|
|
|
3
|
-
export const {linkedComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology, registerPackageModule, registerPackageExport, packageExports} =
|
|
3
|
+
export const {linkedComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology, registerPackageModule, registerPackageExport, packageExports, packageName} =
|
|
4
4
|
linkedPackage('${package_name}');
|