lincd-cli 0.2.46 → 0.2.48
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 +4 -2
- package/defaults/app-with-backend/readme.md +6 -0
- package/lib/cli-methods.js +1332 -1472
- package/lib/cli.js +102 -103
- package/lib/config-grunt.js +246 -298
- package/lib/config-webpack.js +364 -358
- package/lib/index.js +29 -67
- package/lib/interfaces.js +2 -2
- package/lib/plugins/declaration-plugin.js +233 -209
- package/lib/plugins/externalise-modules.js +166 -167
- package/lib/plugins/watch-run.js +14 -16
- package/lib/utils.js +284 -326
- package/package.json +1 -1
package/lib/utils.js
CHANGED
|
@@ -1,80 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __setModuleDefault =
|
|
23
|
-
(this && this.__setModuleDefault) ||
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', {enumerable: true, value: v});
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
function (mod) {
|
|
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) {
|
|
34
19
|
if (mod && mod.__esModule) return mod;
|
|
35
20
|
var result = {};
|
|
36
|
-
if (mod != null)
|
|
37
|
-
for (var k in mod)
|
|
38
|
-
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
39
22
|
__setModuleDefault(result, mod);
|
|
40
23
|
return result;
|
|
41
|
-
|
|
42
|
-
var __importDefault =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
exports.log =
|
|
53
|
-
exports.generateScopedName =
|
|
54
|
-
exports.execPromise =
|
|
55
|
-
exports.execp =
|
|
56
|
-
exports.getGruntConfig =
|
|
57
|
-
exports.getModulePackageJSON =
|
|
58
|
-
exports.getLINCDDependencies =
|
|
59
|
-
exports.getPackageJSON =
|
|
60
|
-
void 0;
|
|
61
|
-
const fs = __importStar(require('fs'));
|
|
62
|
-
const path = __importStar(require('path'));
|
|
63
|
-
const chalk_1 = __importDefault(require('chalk'));
|
|
64
|
-
const child_process_1 = require('child_process');
|
|
65
|
-
const {findNearestPackageJson, findNearestPackageJsonSync} = require('find-nearest-package-json');
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getLinkedTailwindColors = exports.flatten = exports.warn = exports.debug = exports.log = exports.generateScopedName = exports.execPromise = exports.execp = exports.getGruntConfig = exports.getModulePackageJSON = exports.getLINCDDependencies = exports.getPackageJSON = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
33
|
+
const child_process_1 = require("child_process");
|
|
34
|
+
const { findNearestPackageJson, findNearestPackageJsonSync, } = require('find-nearest-package-json');
|
|
66
35
|
var getPackageJSON = function (root = process.cwd(), error = true) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
let packagePath = path.join(root, 'package.json');
|
|
37
|
+
if (fs.existsSync(packagePath)) {
|
|
38
|
+
return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
39
|
+
}
|
|
40
|
+
else if (root === process.cwd()) {
|
|
41
|
+
if (error) {
|
|
42
|
+
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');
|
|
43
|
+
process.exit();
|
|
44
|
+
}
|
|
76
45
|
}
|
|
77
|
-
}
|
|
78
46
|
};
|
|
79
47
|
exports.getPackageJSON = getPackageJSON;
|
|
80
48
|
/**
|
|
@@ -85,303 +53,293 @@ exports.getPackageJSON = getPackageJSON;
|
|
|
85
53
|
* @param packageJson
|
|
86
54
|
*/
|
|
87
55
|
var getLINCDDependencies = function (packageJson, checkedPackages = new Set()) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
56
|
+
if (!packageJson) {
|
|
57
|
+
packageJson = (0, exports.getPackageJSON)();
|
|
58
|
+
}
|
|
59
|
+
let dependencies = Object.assign(Object.assign({}, packageJson.dependencies), packageJson.devDependencies);
|
|
60
|
+
let lincdPackagePaths = [];
|
|
61
|
+
let firstTime = checkedPackages.size === 0;
|
|
62
|
+
for (var dependency of Object.keys(dependencies)) {
|
|
63
|
+
try {
|
|
64
|
+
if (!checkedPackages.has(dependency)) {
|
|
65
|
+
let [modulePackageJson, modulePath] = (0, exports.getModulePackageJSON)(dependency);
|
|
66
|
+
checkedPackages.add(dependency);
|
|
67
|
+
if (modulePackageJson === null || modulePackageJson === void 0 ? void 0 : modulePackageJson.lincd) {
|
|
68
|
+
lincdPackagePaths.push([
|
|
69
|
+
modulePackageJson.name,
|
|
70
|
+
modulePath,
|
|
71
|
+
[
|
|
72
|
+
...Object.keys(Object.assign(Object.assign({}, modulePackageJson.dependencies), modulePackageJson.devDependencies)),
|
|
73
|
+
],
|
|
74
|
+
]);
|
|
75
|
+
//also check if this package has any dependencies that are lincd packages
|
|
76
|
+
lincdPackagePaths = lincdPackagePaths.concat((0, exports.getLINCDDependencies)(modulePackageJson, checkedPackages));
|
|
77
|
+
}
|
|
78
|
+
if (!modulePackageJson) {
|
|
79
|
+
//this seems to only happen with yarn workspaces for some grunt related dependencies of lincd-cli
|
|
80
|
+
// console.log(`could not find package.json of ${dependency}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
113
83
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// console.log(`could not find package.json of ${dependency}`);
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.log(`could not check if ${dependency} is a lincd package: ${err}`);
|
|
117
86
|
}
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
console.log(`could not check if ${dependency} is a lincd package: ${err}`);
|
|
121
87
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
88
|
+
if (firstTime) {
|
|
89
|
+
// let dependencyMap:Map<string,Set<string>> = new Map();
|
|
90
|
+
let lincdPackageNames = new Set(lincdPackagePaths.map(([packageName, modulePath, pkgDependencies]) => packageName));
|
|
91
|
+
//remove lincd-cli from the list of lincd packages
|
|
92
|
+
lincdPackageNames.delete('lincd-cli');
|
|
93
|
+
lincdPackagePaths.forEach(([packageName, modulePath, pkgDependencies], key) => {
|
|
94
|
+
let lincdDependencies = pkgDependencies.filter((dependency) => lincdPackageNames.has(dependency));
|
|
95
|
+
if (packageName === 'lincd-cli') {
|
|
96
|
+
//remove lincd-modules from the dependencies of lincd-cli (it's not a hard dependency, and it messes things up)
|
|
97
|
+
lincdDependencies.splice(lincdDependencies.indexOf('lincd-modules'), 1);
|
|
98
|
+
}
|
|
99
|
+
// dependencyMap.set(packageName, new Set(lincdDependencies));
|
|
100
|
+
//update dependencies to be the actual lincd package objects
|
|
101
|
+
lincdPackagePaths[key][2] = lincdDependencies;
|
|
102
|
+
});
|
|
103
|
+
// //add the nested dependencies for each lincd package
|
|
104
|
+
// for (let [packageName,pkgDependencies] of dependencyMap) {
|
|
105
|
+
// pkgDependencies.forEach((dependency) => {
|
|
106
|
+
// if (dependencyMap.has(dependency)) {
|
|
107
|
+
// dependencyMap.get(dependency).forEach((nestedDependency) => {
|
|
108
|
+
// pkgDependencies.add(nestedDependency);
|
|
109
|
+
// });
|
|
110
|
+
// }
|
|
111
|
+
// });
|
|
112
|
+
// }
|
|
113
|
+
//
|
|
114
|
+
// dependencyMap.forEach((dependencies,packageName) => {
|
|
115
|
+
// //check for circular dependencies
|
|
116
|
+
// if([...dependencies].some(dependency => {
|
|
117
|
+
// return dependencyMap.get(dependency).has(packageName);
|
|
118
|
+
// }))
|
|
119
|
+
// {
|
|
120
|
+
// console.warn(`Circular dependency detected between ${packageName} and ${dependency}`);
|
|
121
|
+
// }
|
|
122
|
+
//
|
|
123
|
+
// });
|
|
124
|
+
// a simple sort with dependencyMap doesn't seem to work,so we start with LINCD (least dependencies) and from there add packages that have all their dependencies already added
|
|
125
|
+
let sortedPackagePaths = [];
|
|
126
|
+
let addedPackages = new Set(['lincd']);
|
|
127
|
+
sortedPackagePaths.push(lincdPackagePaths.find(([packageName]) => {
|
|
128
|
+
return packageName === 'lincd';
|
|
129
|
+
}));
|
|
130
|
+
while (addedPackages.size !== lincdPackagePaths.length) {
|
|
131
|
+
let startSize = addedPackages.size;
|
|
132
|
+
lincdPackagePaths.forEach(([packageName, modulePath, pkgDependencies]) => {
|
|
133
|
+
if (!addedPackages.has(packageName) &&
|
|
134
|
+
pkgDependencies.every((dependency) => addedPackages.has(dependency))) {
|
|
135
|
+
sortedPackagePaths.push([packageName, modulePath, pkgDependencies]);
|
|
136
|
+
addedPackages.add(packageName);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (startSize === addedPackages.size) {
|
|
140
|
+
console.warn('Could not sort lincd packages, circular dependencies?');
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
173
143
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
144
|
+
//sort the lincd packages by least dependent first
|
|
145
|
+
// lincdPackagePaths = lincdPackagePaths.sort(([packageNameA],[packageNameB]) => {
|
|
146
|
+
// //if package A depends on package B, then package B should come first
|
|
147
|
+
// if (dependencyMap.get(packageNameA).has(packageNameB)) {
|
|
148
|
+
// console.log(packageNameA+' depends on '+packageNameB+ ' (below)')
|
|
149
|
+
// return 1;
|
|
150
|
+
// }
|
|
151
|
+
// console.log(packageNameA+' above '+packageNameB)
|
|
152
|
+
// return -1;
|
|
153
|
+
// });
|
|
154
|
+
return sortedPackagePaths;
|
|
179
155
|
}
|
|
180
|
-
|
|
181
|
-
// lincdPackagePaths = lincdPackagePaths.sort(([packageNameA],[packageNameB]) => {
|
|
182
|
-
// //if package A depends on package B, then package B should come first
|
|
183
|
-
// if (dependencyMap.get(packageNameA).has(packageNameB)) {
|
|
184
|
-
// console.log(packageNameA+' depends on '+packageNameB+ ' (below)')
|
|
185
|
-
// return 1;
|
|
186
|
-
// }
|
|
187
|
-
// console.log(packageNameA+' above '+packageNameB)
|
|
188
|
-
// return -1;
|
|
189
|
-
// });
|
|
190
|
-
return sortedPackagePaths;
|
|
191
|
-
}
|
|
192
|
-
return lincdPackagePaths;
|
|
156
|
+
return lincdPackagePaths;
|
|
193
157
|
};
|
|
194
158
|
exports.getLINCDDependencies = getLINCDDependencies;
|
|
195
159
|
//from https://github.com/haalcala/node-packagejson/blob/master/index.js
|
|
196
160
|
var getModulePackageJSON = function (module_name, work_dir) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
161
|
+
if (!work_dir) {
|
|
162
|
+
work_dir = process.cwd();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
work_dir = path.resolve(work_dir);
|
|
166
|
+
}
|
|
167
|
+
var package_json;
|
|
168
|
+
if (fs.existsSync(path.resolve(work_dir, './node_modules'))) {
|
|
169
|
+
var module_dir = path.resolve(work_dir, './node_modules/' + module_name);
|
|
170
|
+
if (fs.existsSync(module_dir) &&
|
|
171
|
+
fs.existsSync(module_dir + '/package.json')) {
|
|
172
|
+
package_json = JSON.parse(fs.readFileSync(module_dir + '/package.json', 'utf-8'));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!package_json && work_dir != '/') {
|
|
176
|
+
return (0, exports.getModulePackageJSON)(module_name, path.resolve(work_dir, '..'));
|
|
207
177
|
}
|
|
208
|
-
|
|
209
|
-
if (!package_json && work_dir != '/') {
|
|
210
|
-
return (0, exports.getModulePackageJSON)(module_name, path.resolve(work_dir, '..'));
|
|
211
|
-
}
|
|
212
|
-
return [package_json, module_dir];
|
|
178
|
+
return [package_json, module_dir];
|
|
213
179
|
};
|
|
214
180
|
exports.getModulePackageJSON = getModulePackageJSON;
|
|
215
181
|
var getGruntConfig = function (root = process.cwd(), error = true) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
182
|
+
let gruntFile = path.join(root, 'Gruntfile.js');
|
|
183
|
+
if (fs.existsSync(gruntFile)) {
|
|
184
|
+
return require(gruntFile)();
|
|
185
|
+
}
|
|
186
|
+
else if (root === process.cwd()) {
|
|
187
|
+
if (error) {
|
|
188
|
+
console.warn('Could not find Gruntfile.js. Make sure you run this command from the root of a lincd module or a lincd yarn workspace');
|
|
189
|
+
process.exit();
|
|
190
|
+
}
|
|
225
191
|
}
|
|
226
|
-
}
|
|
227
192
|
};
|
|
228
193
|
exports.getGruntConfig = getGruntConfig;
|
|
229
|
-
|
|
230
194
|
function execp(cmd, log = false, allowError = false, options = {}) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
195
|
+
// opts || (opts = {});
|
|
196
|
+
if (log)
|
|
197
|
+
console.log(chalk_1.default.cyan(cmd));
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
var child = (0, child_process_1.exec)(cmd, options);
|
|
200
|
+
child.stdout.pipe(process.stdout);
|
|
201
|
+
child.stderr.pipe(process.stderr);
|
|
202
|
+
// process.stdin.pipe(child.stdin);
|
|
203
|
+
child.on('close', function (code) {
|
|
204
|
+
if (code === 0) {
|
|
205
|
+
resolve(null);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
reject();
|
|
209
|
+
}
|
|
210
|
+
// console.log('killing child');
|
|
211
|
+
// child.kill('SIGHUP');
|
|
212
|
+
// resolve(code);
|
|
213
|
+
});
|
|
214
|
+
// child.on('data', function (result) {
|
|
215
|
+
// // if (log)
|
|
216
|
+
// // {
|
|
217
|
+
// // console.log(result);
|
|
218
|
+
// // }
|
|
219
|
+
// resolve(result);
|
|
220
|
+
// console.log('resolve data');
|
|
221
|
+
//
|
|
222
|
+
// });
|
|
223
|
+
child.on('error', function (err) {
|
|
224
|
+
if (!allowError) {
|
|
225
|
+
// console.log('reject err');
|
|
226
|
+
reject(err);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
else if (log) {
|
|
230
|
+
console.warn(err);
|
|
231
|
+
}
|
|
232
|
+
// console.log('resolve err');
|
|
233
|
+
resolve(null);
|
|
234
|
+
});
|
|
235
|
+
child.on('exit', function (code, signal) {
|
|
236
|
+
if (code !== 0) {
|
|
237
|
+
reject('Child process exited with error code ' + code);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
// console.log('resolve exit');
|
|
241
|
+
resolve(null);
|
|
242
|
+
});
|
|
267
243
|
});
|
|
268
|
-
child.on('exit', function (code, signal) {
|
|
269
|
-
if (code !== 0) {
|
|
270
|
-
reject('Child process exited with error code ' + code);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
// console.log('resolve exit');
|
|
274
|
-
resolve(null);
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
244
|
}
|
|
278
|
-
|
|
279
245
|
exports.execp = execp;
|
|
280
|
-
|
|
281
246
|
function execPromise(command, log = false, allowError = false, options, pipeOutput = false) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
247
|
+
return new Promise(function (resolve, reject) {
|
|
248
|
+
if (log)
|
|
249
|
+
console.log(chalk_1.default.cyan(command));
|
|
250
|
+
let child = (0, child_process_1.exec)(command, options, (error, stdout, stderr) => {
|
|
251
|
+
if (error) {
|
|
252
|
+
if (!allowError) {
|
|
253
|
+
reject({ error, stdout, stderr });
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
else if (log) {
|
|
257
|
+
console.warn(error);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//TODO: getting a typescript error for 'trim()', this worked before, is it still used? do we log anywhere?
|
|
261
|
+
let result = stdout['trim']();
|
|
262
|
+
if (log) {
|
|
263
|
+
// console.log(chalk"RESOLVING "+command);
|
|
264
|
+
console.log(result);
|
|
265
|
+
// console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));
|
|
266
|
+
// console.log('stderr:'+stderr);
|
|
267
|
+
}
|
|
268
|
+
resolve(result);
|
|
269
|
+
});
|
|
270
|
+
if (pipeOutput) {
|
|
271
|
+
child.stdout.pipe(process.stdout);
|
|
272
|
+
child.stderr.pipe(process.stderr);
|
|
291
273
|
}
|
|
292
|
-
}
|
|
293
|
-
//TODO: getting a typescript error for 'trim()', this worked before, is it still used? do we log anywhere?
|
|
294
|
-
let result = stdout['trim']();
|
|
295
|
-
if (log) {
|
|
296
|
-
// console.log(chalk"RESOLVING "+command);
|
|
297
|
-
console.log(result);
|
|
298
|
-
// console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));
|
|
299
|
-
// console.log('stderr:'+stderr);
|
|
300
|
-
}
|
|
301
|
-
resolve(result);
|
|
302
274
|
});
|
|
303
|
-
if (pipeOutput) {
|
|
304
|
-
child.stdout.pipe(process.stdout);
|
|
305
|
-
child.stderr.pipe(process.stderr);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
275
|
}
|
|
309
|
-
|
|
310
276
|
exports.execPromise = execPromise;
|
|
311
|
-
|
|
312
277
|
// export function generateScopedName(moduleName,name, filename, css) {
|
|
313
278
|
function generateScopedName(moduleName, name, filename, css) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
moduleName
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
//https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
|
|
329
|
-
var hash = 0;
|
|
330
|
-
if (filename.length == 0) {
|
|
331
|
-
moduleName = '_unknown';
|
|
332
|
-
} else {
|
|
333
|
-
for (var i = 0; i < filename.length; i++) {
|
|
334
|
-
var char = filename.charCodeAt(i);
|
|
335
|
-
hash = (hash << 5) - hash + char;
|
|
336
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
337
|
-
}
|
|
338
|
-
moduleName = hash;
|
|
279
|
+
// console.log(moduleName,name,filename,css);
|
|
280
|
+
var file = path.basename(filename, '.scss');
|
|
281
|
+
let nearestPackageJson = findNearestPackageJsonSync(filename);
|
|
282
|
+
let packageName = nearestPackageJson
|
|
283
|
+
? nearestPackageJson.data.name
|
|
284
|
+
: moduleName;
|
|
285
|
+
return packageName.replace(/[^a-zA-Z0-9_]+/g, '_') + '_' + file + '_' + name;
|
|
286
|
+
// process.exit();
|
|
287
|
+
// var path = require('path');
|
|
288
|
+
var file = path.basename(filename, '.scss');
|
|
289
|
+
var module = filename.match(/[\\\/]modules[\\\/]([\w\-_]+)/);
|
|
290
|
+
var moduleName;
|
|
291
|
+
if (module) {
|
|
292
|
+
moduleName = module[1];
|
|
339
293
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
294
|
+
else {
|
|
295
|
+
//if we cant find module name from path, we'll use a hash
|
|
296
|
+
//https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
|
|
297
|
+
var hash = 0;
|
|
298
|
+
if (filename.length == 0) {
|
|
299
|
+
moduleName = '_unknown';
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
for (var i = 0; i < filename.length; i++) {
|
|
303
|
+
var char = filename.charCodeAt(i);
|
|
304
|
+
hash = (hash << 5) - hash + char;
|
|
305
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
306
|
+
}
|
|
307
|
+
moduleName = hash;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// console.log("Module name: "+moduleName);
|
|
311
|
+
// console.log("Returning: " + moduleName + "_" + file + "_" + name);
|
|
312
|
+
return moduleName + '_' + file + '_' + name;
|
|
344
313
|
}
|
|
345
|
-
|
|
346
314
|
exports.generateScopedName = generateScopedName;
|
|
347
|
-
|
|
348
315
|
function log(...messages) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
316
|
+
messages.forEach((message) => {
|
|
317
|
+
console.log(chalk_1.default.cyan(message));
|
|
318
|
+
});
|
|
352
319
|
}
|
|
353
|
-
|
|
354
320
|
exports.log = log;
|
|
355
|
-
|
|
356
321
|
function debug(config, ...messages) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
322
|
+
if (config.debug) {
|
|
323
|
+
log(...messages);
|
|
324
|
+
}
|
|
360
325
|
}
|
|
361
|
-
|
|
362
326
|
exports.debug = debug;
|
|
363
|
-
|
|
364
327
|
function warn(...messages) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
328
|
+
messages.forEach((message) => {
|
|
329
|
+
console.log(chalk_1.default.red(message));
|
|
330
|
+
});
|
|
368
331
|
}
|
|
369
|
-
|
|
370
332
|
exports.warn = warn;
|
|
371
|
-
|
|
372
333
|
function flatten(arr) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
334
|
+
return arr.reduce(function (a, b) {
|
|
335
|
+
return b ? a.concat(b) : a;
|
|
336
|
+
}, []);
|
|
376
337
|
}
|
|
377
|
-
|
|
378
338
|
exports.flatten = flatten;
|
|
379
|
-
|
|
380
339
|
function getLinkedTailwindColors() {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
340
|
+
return {
|
|
341
|
+
'primary-color': 'var(--primary-color)',
|
|
342
|
+
'font-color': 'var(--font-color)',
|
|
343
|
+
};
|
|
385
344
|
}
|
|
386
|
-
|
|
387
345
|
exports.getLinkedTailwindColors = getLinkedTailwindColors;
|