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