lincd-cli 0.2.49 → 0.2.51

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.
@@ -4,12 +4,7 @@
4
4
  "es2021": true,
5
5
  "jest": true
6
6
  },
7
- "extends": [
8
- "plugin:react/recommended",
9
- "plugin:@typescript-eslint/recommended",
10
- "plugin:import/recommended",
11
- "prettier"
12
- ],
7
+ "extends": ["plugin:react/recommended", "plugin:@typescript-eslint/recommended", "plugin:import/recommended", "prettier"],
13
8
  "overrides": [],
14
9
  "parser": "@typescript-eslint/parser",
15
10
  "parserOptions": {
@@ -19,20 +14,22 @@
19
14
  "ecmaVersion": 12,
20
15
  "sourceType": "module"
21
16
  },
22
- "plugins": [ "react", "@typescript-eslint", "react-hooks" ],
17
+ "plugins": ["react", "@typescript-eslint", "react-hooks"],
23
18
  "rules": {
19
+ "no-var": "off",
24
20
  "no-use-before-define": "off",
25
21
  "react/react-in-jsx-scope": "off",
26
- "@typescript-eslint/explicit-function-return-type" : "off",
27
- "@typescript-eslint/no-use-before-define": [ "error" ],
28
- "react/jsx-filename-extension": [ "warn", { "extensions": [ ".tsx" ] } ],
29
- "import/extensions": [ "error", "ignorePackages", { "ts": "never", "tsx": "never" } ],
22
+ "@typescript-eslint/explicit-function-return-type": "off",
23
+ "@typescript-eslint/no-use-before-define": ["error"],
24
+ "@typescript-eslint/no-shadow": "off",
25
+ "react/jsx-filename-extension": ["warn", {"extensions": [".tsx"]}],
26
+ "import/extensions": ["error", "ignorePackages", {"ts": "never", "tsx": "never"}],
30
27
  "no-shadow": "off",
31
- "@typescript-eslint/no-shadow": [ "error" ],
32
- "max-len": [ "warn", { "code": 100, "ignoreComments": true, "ignoreUrls": true } ],
28
+ "max-len": ["warn", {"code": 100, "ignoreComments": true, "ignoreUrls": true}],
33
29
  "react-hooks/rules-of-hooks": "error",
34
30
  "react-hooks/exhaustive-deps": "warn",
35
31
  "import/prefer-default-export": "off",
32
+ "prefer-const": "off",
36
33
  "react/prop-types": "off"
37
34
  },
38
35
  "settings": {
@@ -40,4 +37,4 @@
40
37
  "typescript": {}
41
38
  }
42
39
  }
43
- }
40
+ }
@@ -1,5 +1,4 @@
1
1
  node_modules
2
2
  *.scss.json
3
- # Ignore artifacts:
4
3
  build
5
4
  package.json
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "printWidth": 80,
3
3
  "tabWidth": 2,
4
- "bracketSpacing": false,
5
4
  "useTabs": false,
6
5
  "semi": true,
7
6
  "singleQuote": true,
7
+ "quoteProps": "as-needed",
8
+ "jsxSingleQuote": false,
8
9
  "trailingComma": "all",
10
+ "bracketSpacing": true,
9
11
  "endOfLine": "auto",
10
12
  "overrides": [
11
13
  {
@@ -21,4 +23,4 @@
21
23
  }
22
24
  }
23
25
  ]
24
- }
26
+ }
@@ -0,0 +1,6 @@
1
+ const { NodeFileStore } = require('lincd-server/lib/shapes/NodeFileStore');
2
+ const { Storage } = require('lincd/lib/utils/Storage');
3
+
4
+ //on the backend, we use a file store which stores all data as JSON-LD
5
+ let fileStore = new NodeFileStore(process.env.NODE_ENV + '-main');
6
+ Storage.setDefaultStore(fileStore);
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
- require('@babel/register')({extensions: ['.ts', '.tsx']});
2
+ require('@babel/register')({ extensions: ['.ts', '.tsx'] });
3
3
  const LincdServer = require('lincd-server/lib/shapes/LincdServer');
4
- let lincdConfig = require("../lincd.config");
5
- const {NodeFileStore} = require('lincd-server/lib/shapes/NodeFileStore');
6
- const {Storage} = require('lincd/lib/utils/Storage');
4
+ let lincdConfig = require('../lincd.config');
5
+ require('./setup_storage');
7
6
 
8
- //on the backend, we use a file store which stores all data as JSON-LD
9
- let fileStore = new NodeFileStore(process.env.NODE_ENV+'-main');
10
- Storage.setDefaultStore(fileStore);
11
-
12
- let server = new LincdServer.LincdServer({loadAppComponent: () => require('../src/App').default,...lincdConfig});
13
- server.start();
7
+ let server = new LincdServer.LincdServer({
8
+ loadAppComponent: () => require('../src/App').default,
9
+ ...lincdConfig,
10
+ });
11
+ server.start();
@@ -1,27 +1,4 @@
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
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,17 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.buildPackage = exports.buildMetadata = exports.register = exports.createPackage = exports.depCheck = exports.createComponent = exports.createSetComponent = exports.createShape = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = 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.depCheck = exports.createComponent = exports.createSetComponent = exports.createShape = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = exports.warn = exports.createApp = void 0;
39
16
  const path_1 = __importDefault(require("path"));
40
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
41
18
  const utils_1 = require("./utils");
42
19
  const chalk_1 = __importDefault(require("chalk"));
43
20
  const child_process_1 = require("child_process");
44
- const models_1 = require("lincd/lib/models");
45
- const env_cmd_1 = require("env-cmd");
46
- const JSONLDWriter_1 = require("lincd-jsonld/lib/utils/JSONLDWriter");
47
- const NameSpace_1 = require("lincd/lib/utils/NameSpace");
48
- const Prefix_1 = require("lincd/lib/utils/Prefix");
49
21
  const get_env_vars_1 = require("env-cmd/dist/get-env-vars");
50
22
  const depcheck_1 = __importDefault(require("depcheck"));
51
23
  var glob = require('glob');
@@ -119,6 +91,7 @@ function warn(...messages) {
119
91
  // console.log(chalk.red(message));
120
92
  });
121
93
  }
94
+ exports.warn = warn;
122
95
  function developPackage(target, mode) {
123
96
  if (!target)
124
97
  target = 'es6';
@@ -959,116 +932,6 @@ const register = function (registryURL) {
959
932
  }
960
933
  };
961
934
  exports.register = register;
962
- const buildMetadata = () => __awaiter(void 0, void 0, void 0, function* () {
963
- // require('@babel/register')({extensions: ['js', '.ts', '.tsx']});
964
- //NOTE: we can not rely on the LincdWebApp shape from lincd-server here, because that would make the initial build of all modules a lot trickier
965
- //see, CLI needs to be built as one of the first things in order to build other things. So it cannot rely on lincd-server, which relies on 10 other packages
966
- let app;
967
- //set the URL of the app as the URI of its node
968
- let envVars = yield (0, env_cmd_1.GetEnvVars)({
969
- envFile: {
970
- filePath: '.env-cmdrc.json',
971
- },
972
- });
973
- if (envVars[process.env.NODE_ENV] &&
974
- envVars[process.env.NODE_ENV].SITE_ROOT) {
975
- //get the site root of the current environment
976
- app = models_1.NamedNode.getOrCreate(envVars[process.env.NODE_ENV].SITE_ROOT);
977
- }
978
- else {
979
- warn('Cannot find environment variable SITE_ROOT. Make sure SITE_ROOT is set (likely in .env-cmdrc.json) for the current environment: ' +
980
- process.env.NODE_ENV);
981
- app = models_1.NamedNode.create();
982
- }
983
- let updatedPaths = [];
984
- var localPackagePaths = getLocalPackagePaths();
985
- //prepare output path
986
- let metadataFolder = path_1.default.join(process.cwd(), 'data', 'metadata');
987
- yield fs_extra_1.default.ensureDir(metadataFolder); //{recursive:true} but not needed with fs-extra
988
- for (const [packageCodeName, packagePath, lincdPackagePath, isAppPackage,] of localPackagePaths) {
989
- let errors = false;
990
- //TODO: check if this resolves, if not, skip it (for initial setup)
991
- Promise.resolve().then(() => __importStar(require('lincd-modules/lib/scripts/package-metadata.js'))).then((script) => __awaiter(void 0, void 0, void 0, function* () {
992
- yield script
993
- .getPackageMetadata(packagePath, lincdPackagePath)
994
- .then((response) => __awaiter(void 0, void 0, void 0, function* () {
995
- if (response.errors.length > 0) {
996
- // console.log(JSON.stringify(response));
997
- warn('Error processing ' +
998
- packagePath +
999
- ':\n' +
1000
- response.errors.join('\n'));
1001
- // throw response
1002
- errors = true;
1003
- }
1004
- else {
1005
- if (!response.packageUri) {
1006
- console.warn('No package URI from meta data. Not building meta data for this package');
1007
- return;
1008
- }
1009
- let pkgNode = models_1.NamedNode.getOrCreate(response.packageUri);
1010
- //connect the packages to the app
1011
- let lincdApp = (0, NameSpace_1.createNameSpace)('http://lincd.org/ont/lincd-app/');
1012
- Prefix_1.Prefix.add('lincdApp', 'http://lincd.org/ont/lincd-app/');
1013
- if (isAppPackage) {
1014
- //Note: this needs to match with LincdWebApp.ownPackage accessor;
1015
- app.overwrite(lincdApp('ownPackage'), pkgNode);
1016
- }
1017
- else {
1018
- //Note: this needs to match with LincdWebApp.packages accessor;
1019
- app.set(lincdApp('maintainsPackage'), pkgNode);
1020
- }
1021
- //write this graph to a jsonld file
1022
- let packageMetaData = JSON.stringify(response.result, null, 2);
1023
- let metadataFile = path_1.default.join(metadataFolder, packageCodeName + '.json');
1024
- yield fs_extra_1.default.writeFile(metadataFile, packageMetaData).then(() => {
1025
- updatedPaths.push(metadataFile);
1026
- });
1027
- }
1028
- }));
1029
- }));
1030
- //enable this when testing if you don't want to continue with building other metadata when an errors occur
1031
- // if (errors) break;
1032
- }
1033
- let packageMetaData = yield JSONLDWriter_1.JSONLDWriter.stringify(app, process.env.NODE_ENV === 'development');
1034
- let metadataFile = path_1.default.join(metadataFolder, '_app.json');
1035
- yield fs_extra_1.default.writeFile(metadataFile, packageMetaData).then(() => {
1036
- updatedPaths.push(metadataFile);
1037
- });
1038
- return updatedPaths;
1039
- });
1040
- exports.buildMetadata = buildMetadata;
1041
- function getLocalPackagePaths() {
1042
- let packagePaths = [];
1043
- //add the APP package itself
1044
- let appPackagePath = process.cwd();
1045
- let appLincdPackagePath = path_1.default.join(appPackagePath, 'frontend', 'src', 'package.ts');
1046
- if (fs_extra_1.default.existsSync(appPackagePath)) {
1047
- let packageJSON = (0, utils_1.getPackageJSON)(appPackagePath);
1048
- packagePaths.push([
1049
- packageJSON.name,
1050
- appPackagePath,
1051
- appLincdPackagePath,
1052
- true,
1053
- ]);
1054
- }
1055
- else {
1056
- console.log('Not a LINCD app');
1057
- }
1058
- //NOTE: we could also switch to checking 'workspaces'?
1059
- let packagesFolder = path_1.default.join(process.cwd(), 'packages');
1060
- if (fs_extra_1.default.existsSync(packagesFolder)) {
1061
- let localPackages = fs_extra_1.default.readdirSync(packagesFolder);
1062
- localPackages.forEach((packageFolderName) => {
1063
- packagePaths.push([
1064
- packageFolderName,
1065
- path_1.default.join(packagesFolder, packageFolderName),
1066
- path_1.default.join(packagesFolder, packageFolderName, 'lib', 'package.js'),
1067
- ]);
1068
- });
1069
- }
1070
- return packagePaths;
1071
- }
1072
935
  const buildPackage = (target, target2, packagePath = process.cwd(), logResults = true) => {
1073
936
  if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
1074
937
  if (!fs_extra_1.default.existsSync(path_1.default.join(packagePath, 'Gruntfile.js'))) {
package/lib/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const cli_methods_1 = require("./cli-methods");
5
+ const metadata_1 = require("./metadata");
5
6
  require('require-extensions');
6
7
  var program = require('commander');
7
8
  var fs = require('fs-extra');
@@ -79,7 +80,7 @@ program
79
80
  (0, cli_methods_1.buildPackage)(target, target2);
80
81
  });
81
82
  program.command('build-metadata').action(() => {
82
- (0, cli_methods_1.buildMetadata)();
83
+ (0, metadata_1.buildMetadata)();
83
84
  });
84
85
  program.command('publish-updated').action(() => {
85
86
  return (0, cli_methods_1.publishUpdated)();
@@ -291,6 +291,15 @@ function generateWebpackConfig(buildName, moduleName, config = {}) {
291
291
  },
292
292
  ],
293
293
  },
294
+ {
295
+ test: /[\w]+/,
296
+ use: [
297
+ {
298
+ loader: path.resolve(__dirname, 'plugins', 'check-imports.js'),
299
+ options: {},
300
+ },
301
+ ],
302
+ },
294
303
  // {
295
304
  // enforce: 'pre',
296
305
  // test: /\.js$/,
@@ -349,7 +358,7 @@ function generateWebpackConfig(buildName, moduleName, config = {}) {
349
358
  resolveLoader: {
350
359
  modules: [
351
360
  path.join(__dirname, 'plugins'),
352
- path.join(__dirname, 'node_modules'),
361
+ path.join(__dirname, '..', 'node_modules'),
353
362
  'node_modules',
354
363
  ],
355
364
  },
package/lib/index.js CHANGED
@@ -17,13 +17,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.generateWebpackConfig = exports.generateGruntConfig = exports.externaliseModules = exports.DeclarationPlugin = void 0;
20
+ exports.generateWebpackConfig = exports.buildMetadata = exports.generateGruntConfig = exports.checkImports = exports.externaliseModules = exports.DeclarationPlugin = void 0;
21
21
  var declaration_plugin_1 = require("./plugins/declaration-plugin");
22
22
  Object.defineProperty(exports, "DeclarationPlugin", { enumerable: true, get: function () { return __importDefault(declaration_plugin_1).default; } });
23
23
  var externalise_modules_1 = require("./plugins/externalise-modules");
24
24
  Object.defineProperty(exports, "externaliseModules", { enumerable: true, get: function () { return __importDefault(externalise_modules_1).default; } });
25
+ var check_imports_1 = require("./plugins/check-imports");
26
+ Object.defineProperty(exports, "checkImports", { enumerable: true, get: function () { return __importDefault(check_imports_1).default; } });
25
27
  var config_grunt_1 = require("./config-grunt");
26
28
  Object.defineProperty(exports, "generateGruntConfig", { enumerable: true, get: function () { return __importDefault(config_grunt_1).default; } });
29
+ var metadata_1 = require("./metadata");
30
+ Object.defineProperty(exports, "buildMetadata", { enumerable: true, get: function () { return metadata_1.buildMetadata; } });
27
31
  const config_webpack_1 = require("./config-webpack");
28
32
  Object.defineProperty(exports, "generateWebpackConfig", { enumerable: true, get: function () { return config_webpack_1.generateWebpackConfig; } });
29
33
  __exportStar(require("./utils"), exports);
@@ -0,0 +1,157 @@
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
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.buildMetadata = void 0;
39
+ const models_1 = require("lincd/lib/models");
40
+ const env_cmd_1 = require("env-cmd");
41
+ const path_1 = __importDefault(require("path"));
42
+ const fs_extra_1 = __importDefault(require("fs-extra"));
43
+ const NameSpace_1 = require("lincd/lib/utils/NameSpace");
44
+ const Prefix_1 = require("lincd/lib/utils/Prefix");
45
+ const JSONLDWriter_1 = require("lincd-jsonld/lib/utils/JSONLDWriter");
46
+ const utils_1 = require("./utils");
47
+ const cli_methods_1 = require("./cli-methods");
48
+ function getLocalPackagePaths() {
49
+ let packagePaths = [];
50
+ //add the APP package itself
51
+ let appPackagePath = process.cwd();
52
+ let appLincdPackagePath = path_1.default.join(appPackagePath, 'frontend', 'src', 'package.ts');
53
+ if (fs_extra_1.default.existsSync(appPackagePath)) {
54
+ let packageJSON = (0, utils_1.getPackageJSON)(appPackagePath);
55
+ packagePaths.push([
56
+ packageJSON.name,
57
+ appPackagePath,
58
+ appLincdPackagePath,
59
+ true,
60
+ ]);
61
+ }
62
+ else {
63
+ console.log('Not a LINCD app');
64
+ }
65
+ //NOTE: we could also switch to checking 'workspaces'?
66
+ let packagesFolder = path_1.default.join(process.cwd(), 'packages');
67
+ if (fs_extra_1.default.existsSync(packagesFolder)) {
68
+ let localPackages = fs_extra_1.default.readdirSync(packagesFolder);
69
+ localPackages.forEach((packageFolderName) => {
70
+ packagePaths.push([
71
+ packageFolderName,
72
+ path_1.default.join(packagesFolder, packageFolderName),
73
+ path_1.default.join(packagesFolder, packageFolderName, 'lib', 'package.js'),
74
+ ]);
75
+ });
76
+ }
77
+ return packagePaths;
78
+ }
79
+ const buildMetadata = () => __awaiter(void 0, void 0, void 0, function* () {
80
+ // require('@babel/register')({extensions: ['js', '.ts', '.tsx']});
81
+ //NOTE: we can not rely on the LincdWebApp shape from lincd-server here, because that would make the initial build of all modules a lot trickier
82
+ //see, CLI needs to be built as one of the first things in order to build other things. So it cannot rely on lincd-server, which relies on 10 other packages
83
+ let app;
84
+ //set the URL of the app as the URI of its node
85
+ let envVars = yield (0, env_cmd_1.GetEnvVars)({
86
+ envFile: {
87
+ filePath: '.env-cmdrc.json',
88
+ },
89
+ });
90
+ if (envVars[process.env.NODE_ENV] &&
91
+ envVars[process.env.NODE_ENV].SITE_ROOT) {
92
+ //get the site root of the current environment
93
+ app = models_1.NamedNode.getOrCreate(envVars[process.env.NODE_ENV].SITE_ROOT);
94
+ }
95
+ else {
96
+ (0, cli_methods_1.warn)('Cannot find environment variable SITE_ROOT. Make sure SITE_ROOT is set (likely in .env-cmdrc.json) for the current environment: ' +
97
+ process.env.NODE_ENV);
98
+ app = models_1.NamedNode.create();
99
+ }
100
+ let updatedPaths = [];
101
+ var localPackagePaths = getLocalPackagePaths();
102
+ //prepare output path
103
+ let metadataFolder = path_1.default.join(process.cwd(), 'data', 'metadata');
104
+ yield fs_extra_1.default.ensureDir(metadataFolder); //{recursive:true} but not needed with fs-extra
105
+ for (const [packageCodeName, packagePath, lincdPackagePath, isAppPackage,] of localPackagePaths) {
106
+ let errors = false;
107
+ //TODO: check if this resolves, if not, skip it (for initial setup)
108
+ Promise.resolve().then(() => __importStar(require('lincd-modules/lib/scripts/package-metadata.js'))).then((script) => __awaiter(void 0, void 0, void 0, function* () {
109
+ yield script
110
+ .getPackageMetadata(packagePath, lincdPackagePath)
111
+ .then((response) => __awaiter(void 0, void 0, void 0, function* () {
112
+ if (response.errors.length > 0) {
113
+ // console.log(JSON.stringify(response));
114
+ (0, cli_methods_1.warn)('Error processing ' +
115
+ packagePath +
116
+ ':\n' +
117
+ response.errors.join('\n'));
118
+ // throw response
119
+ errors = true;
120
+ }
121
+ else {
122
+ if (!response.packageUri) {
123
+ console.warn('No package URI from meta data. Not building meta data for this package');
124
+ return;
125
+ }
126
+ let pkgNode = models_1.NamedNode.getOrCreate(response.packageUri);
127
+ //connect the packages to the app
128
+ let lincdApp = (0, NameSpace_1.createNameSpace)('http://lincd.org/ont/lincd-app/');
129
+ Prefix_1.Prefix.add('lincdApp', 'http://lincd.org/ont/lincd-app/');
130
+ if (isAppPackage) {
131
+ //Note: this needs to match with LincdWebApp.ownPackage accessor;
132
+ app.overwrite(lincdApp('ownPackage'), pkgNode);
133
+ }
134
+ else {
135
+ //Note: this needs to match with LincdWebApp.packages accessor;
136
+ app.set(lincdApp('maintainsPackage'), pkgNode);
137
+ }
138
+ //write this graph to a jsonld file
139
+ let packageMetaData = JSON.stringify(response.result, null, 2);
140
+ let metadataFile = path_1.default.join(metadataFolder, packageCodeName + '.json');
141
+ yield fs_extra_1.default.writeFile(metadataFile, packageMetaData).then(() => {
142
+ updatedPaths.push(metadataFile);
143
+ });
144
+ }
145
+ }));
146
+ }));
147
+ //enable this when testing if you don't want to continue with building other metadata when an errors occur
148
+ // if (errors) break;
149
+ }
150
+ let packageMetaData = yield JSONLDWriter_1.JSONLDWriter.stringify(app, process.env.NODE_ENV === 'development');
151
+ let metadataFile = path_1.default.join(metadataFolder, '_app.json');
152
+ yield fs_extra_1.default.writeFile(metadataFile, packageMetaData).then(() => {
153
+ updatedPaths.push(metadataFile);
154
+ });
155
+ return updatedPaths;
156
+ });
157
+ exports.buildMetadata = buildMetadata;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // file: my-webpack-loader.js
4
+ const { getOptions } = require('loader-utils');
5
+ // const validateOptions = require('schema-utils');
6
+ const path = require('path');
7
+ // const schema = {
8
+ // type: 'object',
9
+ // properties: {
10
+ // test: {
11
+ // type: 'string',
12
+ // },
13
+ // },
14
+ // };
15
+ let tsconfig, baseUrl, outDir;
16
+ try {
17
+ tsconfig = require(path.resolve(process.cwd(), './tsconfig.json'));
18
+ baseUrl = path.resolve(process.cwd(), tsconfig.compilerOptions.baseUrl);
19
+ outDir = tsconfig.compilerOptions.outDir;
20
+ }
21
+ catch (err) {
22
+ console.warn('Could not find tsconfig for checking imports');
23
+ }
24
+ function handler(source) {
25
+ const options = getOptions(this);
26
+ //e.g. lincd.org/modules/schema
27
+ let rootContext = this.rootContext;
28
+ //the folder, e.g. lincd.org/modules/schema/src/shapes
29
+ let context = this._module.context;
30
+ //the short raw request, e.g. ./shapes/Action
31
+ let request = this._module.rawRequest;
32
+ //full resolved path, e.g. /Users/you/web/lincd.org/modules/schema/src/shapes/Action.ts
33
+ let userRequest = this._module.userRequest;
34
+ //save as userRequest?
35
+ let resource = this._module.resource;
36
+ let relativePath = this._module.resourceResolveData.relativePath;
37
+ // console.log('-----');
38
+ // for (let key in this) {
39
+ // console.log(key, this[key]);
40
+ // }
41
+ let isRelativeReq = request.indexOf('./') === 0 || request.indexOf('../') === 0;
42
+ // if (isRelativeReq) {
43
+ // console.log('rootContext', rootContext);
44
+ // console.log('context', context);
45
+ // console.log('request', request);
46
+ // // console.log('userRequest', userRequest);
47
+ // // console.log('resource', resource);
48
+ // console.log('relativePath', relativePath);
49
+ // console.log(this.resourcePath);
50
+ // // console.log(path.resolve(process.cwd(), baseUrl));
51
+ // // }
52
+ // console.log(isRelativeReq, this.resourcePath.indexOf(baseUrl) !== 0);
53
+ //if its a relative import,and its not in the baseUrl, throw an error
54
+ if (isRelativeReq &&
55
+ this.resourcePath.indexOf(baseUrl) !== 0 &&
56
+ this.resourcePath.indexOf('node_modules') === -1) {
57
+ this.emitError(Error(`LINCD Error: You are importing a file from outside the baseUrl ${tsconfig.compilerOptions.baseUrl}.
58
+ ${relativePath} is not in ${tsconfig.compilerOptions.baseUrl}.`));
59
+ }
60
+ // if (this.resourcePath.indexOf(path.resolve('./src')) !== 0) {
61
+ // throw Error(`Reseource loading restricted for ${this.resourcePath}`);
62
+ // }
63
+ // validateOptions(schema, options, 'My Webpack Loader');
64
+ return source;
65
+ }
66
+ exports.default = handler;
67
+ module.exports = handler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -73,7 +73,7 @@
73
73
  "grunt-webpack": "^5.0.0",
74
74
  "license-info-webpack-plugin": "^3.0.0",
75
75
  "lincd": "^0.5",
76
- "lincd-jsonld": "^0.1.22",
76
+ "lincd-jsonld": "^0.1.21",
77
77
  "lincd-modules": "^0.1",
78
78
  "load-grunt-tasks": "^5.1.0",
79
79
  "mini-css-extract-plugin": "^2.7.5",