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/lib/utils.js CHANGED
@@ -51,10 +51,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  return (mod && mod.__esModule) ? mod : { "default": mod };
52
52
  };
53
53
  exports.__esModule = true;
54
- exports.flatten = exports.warn = exports.debug = exports.log = exports.generateScopedName = exports.getGruntConfig = exports.getPackageJSON = void 0;
54
+ exports.flatten = exports.warn = exports.debug = exports.log = exports.generateScopedName = exports.execPromise = exports.execp = exports.getGruntConfig = exports.getPackageJSON = void 0;
55
55
  var fs = __importStar(require("fs"));
56
56
  var path = __importStar(require("path"));
57
57
  var chalk_1 = __importDefault(require("chalk"));
58
+ var child_process_1 = require("child_process");
58
59
  var _a = require('find-nearest-package-json'), findNearestPackageJson = _a.findNearestPackageJson, findNearestPackageJsonSync = _a.findNearestPackageJsonSync;
59
60
  var getPackageJSON = function (root, error) {
60
61
  if (root === void 0) { root = process.cwd(); }
@@ -86,24 +87,95 @@ var getGruntConfig = function (root, error) {
86
87
  }
87
88
  };
88
89
  exports.getGruntConfig = getGruntConfig;
89
- /*export function getShapesJSONLD(packageExports): Promise<string> {
90
- // return JSONLDWriter.stringify(getShapes(packageExports));
90
+ function execp(cmd, log, allowError, options) {
91
+ if (log === void 0) { log = false; }
92
+ if (allowError === void 0) { allowError = false; }
93
+ if (options === void 0) { options = {}; }
94
+ // opts || (opts = {});
95
+ if (log)
96
+ console.log(chalk_1["default"].cyan(cmd));
97
+ return new Promise(function (resolve, reject) {
98
+ var child = (0, child_process_1.exec)(cmd, options);
99
+ child.stdout.pipe(process.stdout);
100
+ child.stderr.pipe(process.stderr);
101
+ // process.stdin.pipe(child.stdin);
102
+ child.on('close', function (code) {
103
+ if (code === 0) {
104
+ resolve(null);
105
+ }
106
+ else {
107
+ reject();
108
+ }
109
+ // console.log('killing child');
110
+ // child.kill('SIGHUP');
111
+ // resolve(code);
112
+ });
113
+ // child.on('data', function (result) {
114
+ // // if (log)
115
+ // // {
116
+ // // console.log(result);
117
+ // // }
118
+ // resolve(result);
119
+ // console.log('resolve data');
120
+ //
121
+ // });
122
+ child.on('error', function (err) {
123
+ if (!allowError) {
124
+ // console.log('reject err');
125
+ reject(err);
126
+ return;
127
+ }
128
+ else if (log) {
129
+ console.warn(err);
130
+ }
131
+ // console.log('resolve err');
132
+ resolve(null);
133
+ });
134
+ child.on('exit', function (code, signal) {
135
+ if (code !== 0) {
136
+ reject('Child process exited with error code ' + code);
137
+ return;
138
+ }
139
+ // console.log('resolve exit');
140
+ resolve(null);
141
+ });
142
+ });
91
143
  }
92
-
93
- export function getShapes(packageExports): CoreSet<SHACL_Shape> {
94
- let shapes = new CoreSet<SHACL_Shape>();
95
- for (var key in packageExports) {
96
- let moduleExport = packageExports[key];
97
- // console.log(key, Object.keys(packageExports[key]));
98
- if (moduleExport.shape) {
99
- // console.log(Object.keys(moduleExport.shape));
100
- if (moduleExport.shape && moduleExport.shape instanceof SHACL_Shape) {
101
- shapes.add(moduleExport.shape);
102
- }
103
- }
104
- }
105
- return shapes;
106
- }*/
144
+ exports.execp = execp;
145
+ function execPromise(command, log, allowError, options, pipeOutput) {
146
+ if (log === void 0) { log = false; }
147
+ if (allowError === void 0) { allowError = false; }
148
+ if (pipeOutput === void 0) { pipeOutput = false; }
149
+ return new Promise(function (resolve, reject) {
150
+ if (log)
151
+ console.log(chalk_1["default"].cyan(command));
152
+ var child = (0, child_process_1.exec)(command, options, function (error, stdout, stderr) {
153
+ if (error) {
154
+ if (!allowError) {
155
+ reject({ error: error, stdout: stdout, stderr: stderr });
156
+ return;
157
+ }
158
+ else if (log) {
159
+ console.warn(error);
160
+ }
161
+ }
162
+ //TODO: getting a typescript error for 'trim()', this worked before, is it still used? do we log anywhere?
163
+ var result = stdout['trim']();
164
+ if (log) {
165
+ // console.log(chalk"RESOLVING "+command);
166
+ console.log(result);
167
+ // console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));
168
+ // console.log('stderr:'+stderr);
169
+ }
170
+ resolve(result);
171
+ });
172
+ if (pipeOutput) {
173
+ child.stdout.pipe(process.stdout);
174
+ child.stderr.pipe(process.stderr);
175
+ }
176
+ });
177
+ }
178
+ exports.execPromise = execPromise;
107
179
  // export function generateScopedName(moduleName,name, filename, css) {
108
180
  function generateScopedName(moduleName, name, filename, css) {
109
181
  // console.log(moduleName,name,filename,css);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -58,9 +58,11 @@
58
58
  "grunt-webpack": "^5.0.0",
59
59
  "license-info-webpack-plugin": "^3.0.0",
60
60
  "lincd": "^0.5",
61
+ "lincd-app": "^0.1",
61
62
  "lincd-jsonld": "^0.1.13",
63
+ "lincd-modules": "^0.1",
62
64
  "load-grunt-tasks": "^5.1.0",
63
- "mini-css-extract-plugin": "^2.6.1",
65
+ "mini-css-extract-plugin": "^2.7.5",
64
66
  "open": "^8.4.0",
65
67
  "postcss": "^8.4.17",
66
68
  "postcss-import": "^15.0.0",
@@ -72,14 +74,14 @@
72
74
  "sass": "^1.55.0",
73
75
  "sass-loader": "^13.0.2",
74
76
  "source-map-loader": "^4.0.0",
75
- "tailwindcss": "^3.1.6",
77
+ "tailwindcss": "^3.2.7",
76
78
  "terser-webpack-plugin": "^5.3.6",
77
79
  "ts-loader": "^9.4.1",
78
80
  "ts-node": "10.7",
79
81
  "tsc-hooks": "^1.1.1",
80
82
  "tsconfig-paths-webpack-plugin": "^4.0.0",
81
83
  "typescript": "4.8.4",
82
- "webpack": "^5.74.0",
84
+ "webpack": "^5.76.3",
83
85
  "webpack-bundle-analyzer": "^4.6.1",
84
86
  "webpack-license-plugin": "^4.2.2"
85
87
  },
package/utils.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.getShapes = exports.getShapesJSONLD = exports.getPackageJSON = void 0;
4
- var fs = require("fs");
5
- var path = require("path");
6
- var SHACL_Shape_1 = require("lincd/lib/shapes/SHACL_Shape");
7
- var CoreSet_1 = require("lincd/lib/collections/CoreSet");
8
- var JSONLDWriter_1 = require("lincd-jsonld/lib/JSONLDWriter");
9
- var getPackageJSON = function (root) {
10
- if (root === void 0) { root = process.cwd(); }
11
- var packagePath = path.join(root, 'package.json');
12
- if (fs.existsSync(packagePath)) {
13
- return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
14
- }
15
- else if (root === process.cwd()) {
16
- console.warn('Could not find package.json. Make sure you run this command from the root of a lincd module or a lincd yarn workspace');
17
- process.exit();
18
- }
19
- };
20
- exports.getPackageJSON = getPackageJSON;
21
- function getShapesJSONLD(moduleExports) {
22
- return JSONLDWriter_1.JSONLDWriter.stringify(getShapes(moduleExports));
23
- }
24
- exports.getShapesJSONLD = getShapesJSONLD;
25
- function getShapes(moduleExports) {
26
- var shapes = new CoreSet_1.CoreSet();
27
- for (var key in moduleExports) {
28
- var moduleExport = moduleExports[key];
29
- // console.log(key, Object.keys(moduleExports[key]));
30
- if (moduleExport.shape) {
31
- // console.log(Object.keys(moduleExport.shape));
32
- if (moduleExport.shape && moduleExport.shape instanceof SHACL_Shape_1.SHACL_Shape) {
33
- shapes.add(moduleExport.shape);
34
- }
35
- }
36
- }
37
- return shapes;
38
- }
39
- exports.getShapes = getShapes;