lincd-cli 0.2.9 → 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/backend/server.js +2 -1
- package/defaults/app-with-backend/frontend/src/App.scss +0 -3
- package/defaults/app-with-backend/frontend/src/App.tsx +12 -8
- package/defaults/app-with-backend/frontend/src/package.ts +3 -0
- package/defaults/app-with-backend/lincd.config.js +4 -0
- package/defaults/app-with-backend/package.json +2 -1
- package/lib/cli-methods.js +1391 -0
- package/lib/cli.js +25 -1446
- package/lib/config-webpack.js +121 -34
- package/lib/utils.js +90 -18
- package/package.json +1 -1
- package/yarn-error.log +0 -12933
package/lib/config-webpack.js
CHANGED
|
@@ -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/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);
|