lincd-cli 0.2.77 → 0.2.79
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/babel.config.js +11 -0
- package/defaults/app-static/src/index-static.tsx +2 -2
- package/defaults/app-with-backend/src/index.tsx +7 -7
- package/lib/cli-methods.js +63 -3
- package/lib/cli.js +12 -0
- package/lib/config-grunt.js +2 -2
- package/lib/config-webpack.js +3 -3
- package/lib/utils.js +1 -1
- package/package.json +9 -7
package/babel.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: [
|
|
3
|
+
'@babel/preset-env',
|
|
4
|
+
['@babel/preset-react', {runtime: 'automatic'}],
|
|
5
|
+
'@babel/preset-typescript',
|
|
6
|
+
],
|
|
7
|
+
plugins: [
|
|
8
|
+
'@babel/plugin-transform-runtime',
|
|
9
|
+
['@babel/plugin-proposal-decorators', {legacy: true}],
|
|
10
|
+
],
|
|
11
|
+
};
|
|
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';
|
|
|
3
3
|
import {BrowserRouter} from 'react-router-dom';
|
|
4
4
|
import App from './App';
|
|
5
5
|
import {BackendAPIStore} from 'lincd-server/lib/shapes/BackendAPIStore';
|
|
6
|
-
import {
|
|
6
|
+
import {LinkedStorage} from 'lincd/lib/utils/LinkedStorage';
|
|
7
7
|
import {AppContextProvider} from 'lincd-server-utils/lib/components/AppContext';
|
|
8
8
|
|
|
9
9
|
const root = ReactDOM.createRoot(
|
|
@@ -14,7 +14,7 @@ const root = ReactDOM.createRoot(
|
|
|
14
14
|
//store all quads in a file on the backend named 'main'
|
|
15
15
|
// export const store = new BackendFileStore('main');
|
|
16
16
|
export const store = new BackendAPIStore();
|
|
17
|
-
|
|
17
|
+
LinkedStorage.setDefaultStore(store);
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
root.render(
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {initFrontend} from 'lincd-server-utils/lib/utils/Frontend';
|
|
2
|
-
import {hydrateRoot} from 'react-dom/client';
|
|
3
|
-
import {BrowserRouter} from 'react-router-dom';
|
|
1
|
+
import { initFrontend } from 'lincd-server-utils/lib/utils/Frontend';
|
|
2
|
+
import { hydrateRoot } from 'react-dom/client';
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
4
4
|
import App from './App';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import {
|
|
7
|
-
import {BackendAPIStore} from 'lincd-server/lib/shapes/BackendAPIStore';
|
|
8
|
-
import {AppContextProvider} from 'lincd-server-utils/lib/components/AppContext';
|
|
6
|
+
import { LinkedStorage } from 'lincd/lib/utils/LinkedStorage';
|
|
7
|
+
import { BackendAPIStore } from 'lincd-server/lib/shapes/BackendAPIStore';
|
|
8
|
+
import { AppContextProvider } from 'lincd-server-utils/lib/components/AppContext';
|
|
9
9
|
|
|
10
10
|
window['$RefreshReg$'] = () => {};
|
|
11
11
|
window['$RefreshSig$'] = () => () => {};
|
|
12
12
|
|
|
13
13
|
//forward all storage requests to the backend
|
|
14
14
|
export const store = new BackendAPIStore();
|
|
15
|
-
|
|
15
|
+
LinkedStorage.setDefaultStore(store);
|
|
16
16
|
|
|
17
17
|
initFrontend().then(() => {
|
|
18
18
|
hydrateRoot(
|
package/lib/cli-methods.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.buildPackage = exports.register = exports.createPackage = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = exports.warn = exports.createApp = void 0;
|
|
15
|
+
exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.buildPackage = exports.register = exports.createPackage = exports.startServer = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = exports.warn = exports.createApp = void 0;
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
const child_process_1 = require("child_process");
|
|
18
18
|
const depcheck_1 = __importDefault(require("depcheck"));
|
|
@@ -819,12 +819,14 @@ const depCheck = (path = process.cwd()) => __awaiter(void 0, void 0, void 0, fun
|
|
|
819
819
|
});
|
|
820
820
|
//currently just missing LINCD packages cause a hard failure exit code
|
|
821
821
|
if (missingLincdPackages.length > 0) {
|
|
822
|
-
console.warn(chalk_1.default.red(
|
|
822
|
+
console.warn(chalk_1.default.red(path +
|
|
823
|
+
'\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
|
|
823
824
|
missingLincdPackages.join(',\n- ')));
|
|
824
825
|
process.exit(1);
|
|
825
826
|
}
|
|
826
827
|
else if (missing.length > 0) {
|
|
827
|
-
console.warn(chalk_1.default.magenta(
|
|
828
|
+
console.warn(chalk_1.default.magenta(path +
|
|
829
|
+
'\nMissing dependencies (for now a warning, soon an error):\n\t' +
|
|
828
830
|
missing.join(',\n\t')));
|
|
829
831
|
}
|
|
830
832
|
}
|
|
@@ -840,6 +842,64 @@ const depCheck = (path = process.cwd()) => __awaiter(void 0, void 0, void 0, fun
|
|
|
840
842
|
});
|
|
841
843
|
});
|
|
842
844
|
exports.depCheck = depCheck;
|
|
845
|
+
const ensureEnvironmentLoaded = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
846
|
+
if (!process.env.NODE_ENV) {
|
|
847
|
+
//load env-cmd for development environment
|
|
848
|
+
let { GetEnvVars } = require('env-cmd');
|
|
849
|
+
let envCmdrcPath = path_1.default.join(process.cwd(), '.env-cmdrc.json');
|
|
850
|
+
if (!fs_extra_1.default.existsSync(envCmdrcPath)) {
|
|
851
|
+
console.warn('No .env-cmdrc.json found in this folder. Are you running this command from the root of a LINCD app?');
|
|
852
|
+
process.exit();
|
|
853
|
+
}
|
|
854
|
+
let vars = yield GetEnvVars({
|
|
855
|
+
envFile: {
|
|
856
|
+
filePath: envCmdrcPath,
|
|
857
|
+
},
|
|
858
|
+
});
|
|
859
|
+
let environments = Object.keys(vars);
|
|
860
|
+
//if _main is present, load it first
|
|
861
|
+
if (environments.includes('_main')) {
|
|
862
|
+
process.env = Object.assign(Object.assign({}, process.env), vars._main);
|
|
863
|
+
}
|
|
864
|
+
//if --env is passed, load that environment
|
|
865
|
+
let args = process.argv.splice(2);
|
|
866
|
+
if (args.includes('--env')) {
|
|
867
|
+
let envIndex = args.indexOf('--env');
|
|
868
|
+
let env = args[envIndex + 1];
|
|
869
|
+
if (environments.includes(env)) {
|
|
870
|
+
console.log('Environment: ' + env);
|
|
871
|
+
process.env = Object.assign(Object.assign({}, process.env), vars[env]);
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
console.warn('Environment ' +
|
|
875
|
+
env +
|
|
876
|
+
' not found in .env-cmdrc.json. Available environments: ' +
|
|
877
|
+
environments.join(', '));
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
//chose development by default
|
|
882
|
+
process.env = Object.assign(Object.assign({}, process.env), vars.development);
|
|
883
|
+
console.log('No environment specified, using development');
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
const startServer = (initOnly = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
888
|
+
yield ensureEnvironmentLoaded();
|
|
889
|
+
const LincdServer = require('lincd-server/lib/shapes/LincdServer');
|
|
890
|
+
let lincdConfig = require(path_1.default.join(process.cwd(), 'lincd.config'));
|
|
891
|
+
require(path_1.default.join(process.cwd(), 'scripts', 'storage-config'));
|
|
892
|
+
let server = new LincdServer.LincdServer(Object.assign({ loadAppComponent: () => require(path_1.default.join(process.cwd(), 'src', 'App')).default }, lincdConfig));
|
|
893
|
+
let args = process.argv.splice(2);
|
|
894
|
+
//if --initOnly is passed, only initialize the server and don't start it
|
|
895
|
+
if (args.includes('--initOnly') || initOnly) {
|
|
896
|
+
return server.initOnly();
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
return server.start();
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
exports.startServer = startServer;
|
|
843
903
|
const createPackage = (name, uriBase, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
|
|
844
904
|
//if ran with npx, basePath will be the root directory of the repository, even if we're executing from a sub folder (the root directory is where node_modules lives and package.json with workspaces)
|
|
845
905
|
//so we manually find a packages folder, if it exists we go into that.
|
package/lib/cli.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const register_1 = __importDefault(require("@babel/register"));
|
|
8
|
+
(0, register_1.default)({ extensions: ['.ts', '.tsx'] });
|
|
4
9
|
const cli_methods_1 = require("./cli-methods");
|
|
5
10
|
const metadata_1 = require("./metadata");
|
|
6
11
|
require('require-extensions');
|
|
@@ -14,6 +19,13 @@ program
|
|
|
14
19
|
})
|
|
15
20
|
.description('Creates a new folder with all the required files for a LINCD app')
|
|
16
21
|
.argument('<name>', 'the name of your LINCD app. To use spaces, wrap the name in double quotes.');
|
|
22
|
+
program
|
|
23
|
+
.command('start')
|
|
24
|
+
.action(() => {
|
|
25
|
+
return (0, cli_methods_1.startServer)();
|
|
26
|
+
})
|
|
27
|
+
.option('--env', 'The node environment to use. Default is "development"')
|
|
28
|
+
.description('Start the LINCD node.js server. Use --initOnly to start the backend without http server');
|
|
17
29
|
program
|
|
18
30
|
.command('create-package')
|
|
19
31
|
.action((name, uriBase) => {
|
package/lib/config-grunt.js
CHANGED
|
@@ -158,9 +158,9 @@ function setupGrunt(grunt, moduleName, config) {
|
|
|
158
158
|
},
|
|
159
159
|
postcss: {
|
|
160
160
|
options: {
|
|
161
|
-
map: true,
|
|
161
|
+
map: true, // inline sourcemaps
|
|
162
162
|
// parser: require('postcss-scss'), //require('postcss-comment'),
|
|
163
|
-
syntax: require('postcss-scss'),
|
|
163
|
+
syntax: require('postcss-scss'), //for accepting comments
|
|
164
164
|
processors: [
|
|
165
165
|
require('postcss-preset-env'),
|
|
166
166
|
require('postcss-strip-inline-comments'),
|
package/lib/config-webpack.js
CHANGED
|
@@ -357,8 +357,8 @@ function generateWebpackConfig(buildName, moduleName, config = {}) {
|
|
|
357
357
|
},
|
|
358
358
|
resolveLoader: {
|
|
359
359
|
modules: [
|
|
360
|
-
path.join(__dirname, 'plugins'),
|
|
361
|
-
path.join(__dirname, '..', 'node_modules'),
|
|
360
|
+
path.join(__dirname, 'plugins'), //load webpack our own custom-made loaders from the plugin folder
|
|
361
|
+
path.join(__dirname, '..', 'node_modules'), //load webpack loaders from this lincd-cli library instead of the library that's using it to build its project
|
|
362
362
|
'node_modules',
|
|
363
363
|
],
|
|
364
364
|
},
|
|
@@ -388,7 +388,7 @@ function generateWebpackConfig(buildName, moduleName, config = {}) {
|
|
|
388
388
|
externals: (0, externalise_modules_1.default)(config, es5),
|
|
389
389
|
plugins: plugins,
|
|
390
390
|
stats: {
|
|
391
|
-
errorDetails: true,
|
|
391
|
+
errorDetails: true, //config.debug,
|
|
392
392
|
chunks: false,
|
|
393
393
|
children: true,
|
|
394
394
|
version: true,
|
package/lib/utils.js
CHANGED
|
@@ -51,7 +51,7 @@ const tsHost = typescript_1.default.createCompilerHost({
|
|
|
51
51
|
noEmit: true,
|
|
52
52
|
isolatedModules: true,
|
|
53
53
|
resolveJsonModule: false,
|
|
54
|
-
moduleResolution: typescript_1.default.ModuleResolutionKind.Classic,
|
|
54
|
+
moduleResolution: typescript_1.default.ModuleResolutionKind.Classic, // we don't want node_modules
|
|
55
55
|
incremental: true,
|
|
56
56
|
noLib: true,
|
|
57
57
|
noResolve: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lincd-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.79",
|
|
4
4
|
"description": "Command line tools for the lincd.js library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,12 +41,14 @@
|
|
|
41
41
|
"lincd-cli": "lib/cli.js"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@babel/
|
|
45
|
-
"@babel/
|
|
46
|
-
"@babel/plugin-
|
|
47
|
-
"@babel/
|
|
48
|
-
"@babel/preset-
|
|
49
|
-
"@babel/preset-
|
|
44
|
+
"@babel/cli": "^7.22.9",
|
|
45
|
+
"@babel/core": "^7.22.9",
|
|
46
|
+
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
47
|
+
"@babel/plugin-transform-runtime": "^7.22.9",
|
|
48
|
+
"@babel/preset-env": "^7.22.9",
|
|
49
|
+
"@babel/preset-react": "^7.22.5",
|
|
50
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
51
|
+
"@babel/register": "^7.22.5",
|
|
50
52
|
"@lodder/grunt-postcss": "^3.1.1",
|
|
51
53
|
"@types/node": "^18.11.10",
|
|
52
54
|
"@types/react": "^18.0.17",
|