lincd-cli 0.2.10 → 0.2.11
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/package.json +1 -1
- package/lib/cli-methods.js +1391 -0
- package/lib/cli.js +25 -1446
- package/lib/utils.js +90 -18
- package/package.json +1 -1
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
|
-
|
|
90
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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);
|