lincd-cli 0.2.8 → 0.2.10

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.
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  require('@babel/register')({extensions: ['.ts', '.tsx']});
3
3
  const LincdServer = require('lincd-server/lib/shapes/LincdServer');
4
- let server = new LincdServer.LincdServer({loadAppComponent: () => require('../frontend/src/App').default});
4
+ let lincdConfig = require("../lincd.config");
5
+ let server = new LincdServer.LincdServer({loadAppComponent: () => require('../frontend/src/App').default,...lincdConfig});
5
6
  server.start();
@@ -10,9 +10,6 @@
10
10
 
11
11
  .content {
12
12
  display: block;
13
- background-color: #f3f3f3;
14
- box-shadow: 2px 2px 2px rgba(68, 68, 68, 0.3);
15
- padding: 1rem;
16
13
  margin: 1rem 0;
17
14
 
18
15
  code {
@@ -94,14 +94,18 @@ function Header() {
94
94
  function Html({assets, children, title}) {
95
95
  return (
96
96
  <html lang="en">
97
- <head>
98
- <meta charSet="utf-8" />
99
- <meta name="viewport" content="width=device-width, initial-scale=1" />
100
- <link rel="shortcut icon" href="/static/favicon.ico" />
101
- <link rel="stylesheet" href={assets['main.css']} />
102
- {assets['tailwind-cdn'] && <script src={assets['tailwind-cdn']}></script>}
103
- <title>{title}</title>
104
- </head>
97
+ {globalThis.document?.head ? (
98
+ <head dangerouslySetInnerHTML={{__html: document.head.innerHTML}} />
99
+ ) : (
100
+ <head>
101
+ <meta charSet="utf-8" />
102
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
103
+ <link rel="shortcut icon" href="/static/favicon.ico" />
104
+ <link rel="stylesheet" href={assets['main.css']} />
105
+ {assets['tailwind-cdn'] && <script src={assets['tailwind-cdn']}></script>}
106
+ <title>{title}</title>
107
+ </head>
108
+ )}
105
109
  <body>
106
110
  <noscript
107
111
  dangerouslySetInnerHTML={{
@@ -0,0 +1,3 @@
1
+ import {linkedPackage} from 'lincd/lib/utils/Module';
2
+ export const {linkedComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, packageExports, packageName} =
3
+ linkedPackage('${hyphen_name}');
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ cssMode: 'scss-modules',
3
+ cacheWebpack:true,
4
+ };
@@ -4,6 +4,7 @@
4
4
  "description": "",
5
5
  "version": "0.1.0",
6
6
  "private": true,
7
+ "lincdApp": true,
7
8
  "author": {
8
9
  "name": "",
9
10
  "url": "",
@@ -49,6 +50,7 @@
49
50
  "react-router-dom": "^6.3.0"
50
51
  },
51
52
  "devDependencies": {
53
+ "@types/node": "^18.11.10",
52
54
  "@types/react": "^18.0.17",
53
55
  "@types/react-dom": "^18.0.6",
54
56
  "env-cmd": "^10.1.0",
package/lib/cli.js CHANGED
@@ -116,7 +116,7 @@ program
116
116
  })
117
117
  .description('Creates a new ontology file for your package. Execute this from your package folder.')
118
118
  .argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
119
- .argument('[uribase]', 'Optional argument to set the URI base for the URI\'s of all entities in your ontology. Leave blank to use the URI\'s provided by lincd.org once you register this package');
119
+ .argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package");
120
120
  program.command('register-local', { hidden: true }).action(function () {
121
121
  register('http://localhost:4101');
122
122
  });
@@ -136,7 +136,7 @@ program
136
136
  console.log(ownPackage.version);
137
137
  console.log('Running from: ' + __dirname);
138
138
  })
139
- .description('Log the version of this tool and the path that it\'s running from');
139
+ .description("Log the version of this tool and the path that it's running from");
140
140
  program.command('build [target] [target2]', { isDefault: true }).action(function (target, target2) {
141
141
  buildPackage(target, target2);
142
142
  });
@@ -699,12 +699,12 @@ var createOntology = function (prefix, uriBase, basePath) {
699
699
  }
700
700
  targetFolder = ensureFolderExists(basePath, 'src', 'ontologies');
701
701
  if (!uriBase) {
702
- uriBase = 'http://lincd.org/ont/' + prefix;
702
+ uriBase = 'http://lincd.org/ont/' + prefix + '/';
703
703
  }
704
704
  setVariable('uri_base', uriBase);
705
705
  _a = setNameVariables(prefix), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
706
706
  //copy ontology accessor file
707
- log('Creating files for ontology \'' + prefix + '\'');
707
+ log("Creating files for ontology '" + prefix + "'");
708
708
  targetFile = path.join(targetFolder, hyphenName + '.ts');
709
709
  fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
710
710
  targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
@@ -828,7 +828,7 @@ var createShape = function (name, basePath) {
828
828
  targetFolder = ensureFolderExists(basePath, 'src', 'shapes');
829
829
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
830
830
  //copy default shape file
831
- log('Creating files for shape \'' + name + '\'');
831
+ log("Creating files for shape '" + name + "'");
832
832
  targetFile = path.join(targetFolder, hyphenName + '.ts');
833
833
  fs.copySync(path.join(__dirname, '..', 'defaults', 'shape.ts'), targetFile);
834
834
  //replace variables in some of the copied files
@@ -853,7 +853,7 @@ var createSetComponent = function (name, basePath) {
853
853
  targetFolder = ensureFolderExists(basePath, 'src', 'components');
854
854
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
855
855
  //copy default shape file
856
- log('Creating files for set component \'' + name + '\'');
856
+ log("Creating files for set component '" + name + "'");
857
857
  targetFile = path.join(targetFolder, hyphenName + '.tsx');
858
858
  fs.copySync(path.join(__dirname, '..', 'defaults', 'set-component.tsx'), targetFile);
859
859
  targetFile2 = path.join(targetFolder, hyphenName + '.scss');
@@ -880,7 +880,7 @@ var createComponent = function (name, basePath) {
880
880
  targetFolder = ensureFolderExists(basePath, 'src', 'components');
881
881
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
882
882
  //copy default shape file
883
- log('Creating files for component \'' + name + '\'');
883
+ log("Creating files for component '" + name + "'");
884
884
  targetFile = path.join(targetFolder, hyphenName + '.tsx');
885
885
  fs.copySync(path.join(__dirname, '..', 'defaults', 'component.tsx'), targetFile);
886
886
  targetFile2 = path.join(targetFolder, hyphenName + '.scss');
@@ -918,7 +918,7 @@ var createPackage = function (name, uriBase, basePath) {
918
918
  if (!uriBase) {
919
919
  uriBase = 'http://lincd.org/ont/' + name;
920
920
  }
921
- setVariable('uri_base', uriBase);
921
+ setVariable('uri_base', uriBase + '/');
922
922
  //find @scope and the next part between 2 slashes after
923
923
  //so @dacore/some-mod/lib/file.js
924
924
  // --> match[0] = @dacore/some-mod
@@ -929,7 +929,7 @@ var createPackage = function (name, uriBase, basePath) {
929
929
  //extra variable for clarity (will be same as 'name')
930
930
  setVariable('output_file_name', name);
931
931
  _b = setNameVariables(cleanPackageName), hyphenName = _b.hyphenName, camelCaseName = _b.camelCaseName, underscoreName = _b.underscoreName;
932
- log('Creating new LINCD package \'' + name + '\'');
932
+ log("Creating new LINCD package '" + name + "'");
933
933
  fs.copySync(path.join(__dirname, '..', 'defaults', 'package'), targetFolder);
934
934
  //replace variables in some of the copied files
935
935
  return [4 /*yield*/, Promise.all([
@@ -997,9 +997,9 @@ var createApp = function (name, basePath) {
997
997
  fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
998
998
  fs.renameSync(path.join(targetFolder, '.yarnrc.yml.template'), path.join(targetFolder, '.yarnrc.yml'));
999
999
  // fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
1000
- log('Creating new LINCD application \'' + name + '\'');
1000
+ log("Creating new LINCD application '" + name + "'");
1001
1001
  //replace variables in some copied files
1002
- replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
1002
+ replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/package.ts', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
1003
1003
  return [4 /*yield*/, hasYarnInstalled()];
1004
1004
  case 1:
1005
1005
  hasYarn = _b.sent();
@@ -1126,7 +1126,7 @@ var buildPackage = function (target, target2, packagePath, logResults) {
1126
1126
  nodeEnv = 'SET NODE_ENV=production&& ';
1127
1127
  }
1128
1128
  else {
1129
- nodeEnv = 'NODE_ENV=\'production\' ';
1129
+ nodeEnv = "NODE_ENV='production' ";
1130
1130
  }
1131
1131
  }
1132
1132
  if (!target) {
@@ -1204,7 +1204,8 @@ var publishUpdated = function (test) {
1204
1204
  log('Checking which packages need to be published by comparing last published date with last git commit');
1205
1205
  // p = Promise.all(packages.map((pckg) => {
1206
1206
  packages.forEach(function (pckg) {
1207
- p = p.then(function (previousResult) {
1207
+ p = p
1208
+ .then(function (previousResult) {
1208
1209
  // progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
1209
1210
  // log('# Checking package ' + pckg.packageName);
1210
1211
  // log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
@@ -1274,6 +1275,8 @@ var publishUpdated = function (test) {
1274
1275
  case 2: return [3 /*break*/, 4];
1275
1276
  case 3:
1276
1277
  err_1 = _a.sent();
1278
+ // var stats = fs.statSync(path.join(packageDirectory));
1279
+ // var files = fs.readdirSync(path.join(packageDirectory,'src'));
1277
1280
  console.log(chalk.red(pckg.packageName + ' failed: ' + err_1.message + '\n'));
1278
1281
  console.warn('Returned JSON from npm: ' + output);
1279
1282
  // return previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
@@ -1313,7 +1316,8 @@ var publishUpdated = function (test) {
1313
1316
  console.warn(chalk.red(pckg.packageName + ' failed'));
1314
1317
  return chalk.red(pckg.packageName + ' failed');
1315
1318
  });
1316
- }).then(function (res) {
1319
+ })
1320
+ .then(function (res) {
1317
1321
  log(res);
1318
1322
  results.push(res);
1319
1323
  })["catch"](function (err) {
@@ -1348,7 +1352,7 @@ var publishPackage = function (pkg, test, info, publishVersion) {
1348
1352
  .then(function (res) {
1349
1353
  if (res.indexOf('Aborted due to warnings') !== -1 ||
1350
1354
  res.indexOf('Could not publish') !== -1 ||
1351
- res.indexOf('Couldn\'t publish') !== -1) {
1355
+ res.indexOf("Couldn't publish") !== -1) {
1352
1356
  console.log(res);
1353
1357
  return chalk.red(pkg.packageName + ' failed\n');
1354
1358
  }
@@ -1496,9 +1500,9 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
1496
1500
  return seen_1;
1497
1501
  });
1498
1502
  }
1499
- log('Executing \'' +
1503
+ log("Executing '" +
1500
1504
  chalk.blueBright(command) +
1501
- '\' on packages ' +
1505
+ "' on packages " +
1502
1506
  chalk.magenta(packages.map(function (m) { return m.packageName; }).join(', ')));
1503
1507
  var p = Promise.resolve(true);
1504
1508
  packages.forEach(function (pkg) {
@@ -1539,11 +1543,11 @@ var executeCommandForPackage = function (packageName, command) {
1539
1543
  return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
1540
1544
  });
1541
1545
  if (packageDetails) {
1542
- log('Executing \'cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + '\'');
1546
+ log("Executing 'cd " + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
1543
1547
  return execp('cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
1544
1548
  }
1545
1549
  else {
1546
- warn('Could not find a pkg who\'s name (partially) matched ' + chalk.cyan(packageName));
1550
+ warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(packageName));
1547
1551
  }
1548
1552
  };
1549
1553
  program.parse(process.argv);
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __values = (this && this.__values) || function(o) {
14
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
+ if (m) return m.call(o);
16
+ if (o && typeof o.length === "number") return {
17
+ next: function () {
18
+ if (o && i >= o.length) o = void 0;
19
+ return { value: o && o[i++], done: !o };
20
+ }
21
+ };
22
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
+ };
24
+ var __read = (this && this.__read) || function (o, n) {
25
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26
+ if (!m) return o;
27
+ var i = m.call(o), r, ar = [], e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ }
31
+ catch (error) { e = { error: error }; }
32
+ finally {
33
+ try {
34
+ if (r && !r.done && (m = i["return"])) m.call(i);
35
+ }
36
+ finally { if (e) throw e.error; }
37
+ }
38
+ return ar;
39
+ };
40
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
+ if (ar || !(i in from)) {
43
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
+ ar[i] = from[i];
45
+ }
46
+ }
47
+ return to.concat(ar || Array.prototype.slice.call(from));
48
+ };
13
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
51
  };
@@ -37,6 +73,37 @@ var NODE_ENV = process.env.NODE_ENV;
37
73
  var nodeProduction = NODE_ENV == 'production';
38
74
  // const libraryName = 'lincd';
39
75
  process.traceDeprecation = true;
76
+ function getLincdPackagePaths(packages) {
77
+ var e_1, _a;
78
+ if (!packages) {
79
+ var pkgJson = (0, utils_1.getPackageJSON)();
80
+ packages = __assign(__assign({}, pkgJson.dependencies), pkgJson.devDependencies);
81
+ }
82
+ var lincdPackagePaths = [];
83
+ try {
84
+ for (var _b = __values(Object.keys(packages)), _c = _b.next(); !_c.done; _c = _b.next()) {
85
+ var dependency = _c.value;
86
+ try {
87
+ var pkgJson = require(dependency + '/package.json');
88
+ if (pkgJson.lincd) {
89
+ var pkgPath = require.resolve(dependency + '/package.json');
90
+ lincdPackagePaths.push(pkgPath.substring(0, pkgPath.length - 13));
91
+ }
92
+ }
93
+ catch (err) {
94
+ // console.log("could not find "+dependency);
95
+ }
96
+ }
97
+ }
98
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
99
+ finally {
100
+ try {
101
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
102
+ }
103
+ finally { if (e_1) throw e_1.error; }
104
+ }
105
+ return lincdPackagePaths;
106
+ }
40
107
  function generateWebpackConfig(buildName, moduleName, config) {
41
108
  if (config === void 0) { config = {}; }
42
109
  if (!config.externals)
@@ -143,6 +210,52 @@ function generateWebpackConfig(buildName, moduleName, config) {
143
210
  // }),
144
211
  // ];
145
212
  var aliases = config.alias || {};
213
+ var postcssPlugins = [];
214
+ if (!config.cssMode) {
215
+ config.cssMode = 'mixed';
216
+ }
217
+ if (config.cssMode === 'scss-modules' || config.cssMode === 'scss' || config.cssMode === 'mixed') {
218
+ postcssPlugins = postcssPlugins.concat(['postcss-preset-env', productionMode && 'cssnano']);
219
+ //we once had:
220
+ // 'postcss-import': {},
221
+ // // 'postcss-cssnext': {},
222
+ // 'postcss-nested': {},
223
+ // // "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
224
+ if (config.cssMode === 'scss-modules' || config.cssMode === 'mixed') {
225
+ postcssPlugins.push([
226
+ 'postcss-modules',
227
+ {
228
+ generateScopedName: utils_1.generateScopedName.bind(null, moduleName),
229
+ globalModulePaths: [/tailwind/, /tailwindcss/, config.cssGlobalModulePaths].filter(Boolean)
230
+ },
231
+ ]);
232
+ }
233
+ }
234
+ if (config.cssMode === 'tailwind' || config.cssMode === 'mixed') {
235
+ var lincdPackagePaths = void 0;
236
+ //IF this package is including sources from another lincd package in its bundle (usually not the case)
237
+ if (config.internals) {
238
+ //THEN make sure that we also look for tailwind classes in those packages
239
+ //pass the list of internal packages, or if all, pass null because it will look up all the package.json:dependencies
240
+ lincdPackagePaths = getLincdPackagePaths(config.internals !== '*' ? config.internals : null).map(function (path) {
241
+ return path + '/lib/**/*.{js,mjs}';
242
+ });
243
+ }
244
+ // console.log(chalk.blueBright('tailwind content: ')+chalk.magenta(['./frontend/src/**/*.{tsx,ts}',...lincdPackagePaths]));
245
+ postcssPlugins.push([
246
+ 'tailwindcss',
247
+ {
248
+ safelist: productionMode
249
+ ? {}
250
+ : {
251
+ //in development mode we allow all classes here, so that you can easily develop
252
+ pattern: /./,
253
+ variants: ['sm', 'md', 'lg', 'xl', '2xl']
254
+ },
255
+ content: __spreadArray(['./src/**/*.{tsx,ts}'], __read(lincdPackagePaths), false)
256
+ },
257
+ ]);
258
+ }
146
259
  var rules = [
147
260
  {
148
261
  test: /\.(scss|css)$/,
@@ -158,39 +271,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
158
271
  loader: 'postcss-loader',
159
272
  options: {
160
273
  postcssOptions: {
161
- plugins: {
162
- 'postcss-import': {},
163
- // 'postcss-cssnext': {},
164
- 'postcss-nested': {},
165
- // "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
166
- 'postcss-modules': {
167
- // //by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
168
- // generateScopedName:generateScopedName.bind(null,moduleName),
169
- generateScopedName: utils_1.generateScopedName.bind(null, moduleName),
170
- globalModulePaths: [/tailwind/]
171
- },
172
- tailwindcss: {
173
- safelist: productionMode
174
- ? {}
175
- : {
176
- //in development mode we allow all classes here, so that you can easily develop
177
- pattern: /./,
178
- variants: ['sm', 'md', 'lg', 'xl', '2xl']
179
- },
180
- // purge: {
181
- // enabled: productionMode,
182
- content: [
183
- './src/**/*.tsx',
184
- './src/**/*.ts',
185
- //also include @dacore modules which are internalized with the "internal" config option
186
- //imports like ... from '@dacore/module/lib/views/SomeView' will
187
- //these modules should live in the node_modules folder of the root of the site
188
- //TODO: remake this with multiple lincd modules
189
- // '../../node_modules/@dacore/*/lib/**/*.js',
190
- // './node_modules/@dacore/*/lib/**/*.js',
191
- ]
192
- }
193
- }
274
+ plugins: postcssPlugins
194
275
  }
195
276
  }
196
277
  },
@@ -285,7 +366,9 @@ function generateWebpackConfig(buildName, moduleName, config) {
285
366
  // },
286
367
  resolve: {
287
368
  extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
288
- alias: aliases
369
+ alias: aliases,
370
+ // plugins: resolvePlugins,
371
+ fallback: { crypto: false }
289
372
  },
290
373
  resolveLoader: {
291
374
  modules: [
@@ -308,6 +391,10 @@ function generateWebpackConfig(buildName, moduleName, config) {
308
391
  ]
309
392
  },
310
393
  watch: watch,
394
+ watchOptions: {
395
+ ignored: ['**/*.d.ts', '**/*.js.map', '**/*.scss.json'],
396
+ aggregateTimeout: 500
397
+ },
311
398
  module: {
312
399
  rules: rules
313
400
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -65,7 +65,7 @@
65
65
  "postcss": "^8.4.17",
66
66
  "postcss-import": "^15.0.0",
67
67
  "postcss-loader": "^7.0.1",
68
- "postcss-modules": "^5.0.0",
68
+ "postcss-modules": "^6.0.0",
69
69
  "postcss-nested": "^5.0.6",
70
70
  "postcss-scss": "^4.0.5",
71
71
  "require-extensions": "^0.0.4",