lincd-cli 0.2.57 → 0.2.58
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/cli-methods.js +8 -0
- package/lib/config-grunt.js +14 -2
- package/lib/config-webpack.js +1 -1
- package/lib/utils.js +19 -32
- package/package.json +11 -9
package/lib/cli-methods.js
CHANGED
|
@@ -971,6 +971,14 @@ const buildPackage = (target, target2, packagePath = process.cwd(), logResults =
|
|
|
971
971
|
(target2 ? '-' + target2 : '') +
|
|
972
972
|
' --color');
|
|
973
973
|
let method = logResults ? utils_1.execp : utils_1.execPromise;
|
|
974
|
+
//NOTE: we moved SCSS:JSON out of webpack and grunt, into this file
|
|
975
|
+
//this is the beginning of a transition away from grunt
|
|
976
|
+
//but for the time being it's perhaps a bit strange that we
|
|
977
|
+
// let x = postcss([
|
|
978
|
+
// postcssModules({
|
|
979
|
+
// generateScopedName,
|
|
980
|
+
// }),
|
|
981
|
+
// ]);
|
|
974
982
|
//execute the command to build the method, and provide the current work directory as option
|
|
975
983
|
return method(nodeEnv +
|
|
976
984
|
'grunt build' +
|
package/lib/config-grunt.js
CHANGED
|
@@ -143,9 +143,21 @@ function setupGrunt(grunt, moduleName, config) {
|
|
|
143
143
|
postcss: {
|
|
144
144
|
options: {
|
|
145
145
|
map: true,
|
|
146
|
-
|
|
146
|
+
// parser: require('postcss-scss'), //require('postcss-comment'),
|
|
147
147
|
syntax: require('postcss-scss'),
|
|
148
|
-
|
|
148
|
+
processors: [
|
|
149
|
+
require('postcss-preset-env'),
|
|
150
|
+
require('postcss-strip-inline-comments'),
|
|
151
|
+
require('postcss-modules')({
|
|
152
|
+
generateScopedName: utils_1.generateScopedName.bind(this, config.prod, false),
|
|
153
|
+
globalModulePaths: [
|
|
154
|
+
/tailwind/,
|
|
155
|
+
/tailwindcss/,
|
|
156
|
+
config.cssGlobalModulePaths,
|
|
157
|
+
].filter(Boolean),
|
|
158
|
+
}),
|
|
159
|
+
],
|
|
160
|
+
// writeDest: false,
|
|
149
161
|
},
|
|
150
162
|
cssjson: {
|
|
151
163
|
src: 'src/**/*.scss',
|
package/lib/config-webpack.js
CHANGED
|
@@ -175,7 +175,7 @@ function generateWebpackConfig(buildName, moduleName, config = {}) {
|
|
|
175
175
|
postcssPlugins.push([
|
|
176
176
|
'postcss-modules',
|
|
177
177
|
{
|
|
178
|
-
generateScopedName: utils_1.generateScopedName.bind(null,
|
|
178
|
+
generateScopedName: utils_1.generateScopedName.bind(null, config.prod, true),
|
|
179
179
|
globalModulePaths: [
|
|
180
180
|
/tailwind/,
|
|
181
181
|
/tailwindcss/,
|
package/lib/utils.js
CHANGED
|
@@ -275,41 +275,28 @@ function execPromise(command, log = false, allowError = false, options, pipeOutp
|
|
|
275
275
|
}
|
|
276
276
|
exports.execPromise = execPromise;
|
|
277
277
|
// export function generateScopedName(moduleName,name, filename, css) {
|
|
278
|
-
function generateScopedName(
|
|
279
|
-
//
|
|
280
|
-
|
|
278
|
+
function generateScopedName(isProduction, isWebpack, cssClassName, filepath, css) {
|
|
279
|
+
//for app development we can use short unique hashes
|
|
280
|
+
//but for webpack bundles of lincd modules, we need to ensure unique class names across bundles of many packages
|
|
281
|
+
if (isProduction && !isWebpack) {
|
|
282
|
+
//generate a short unique hash based on cssClassName and filepath
|
|
283
|
+
let hash = require('crypto')
|
|
284
|
+
.createHash('md5')
|
|
285
|
+
.update(cssClassName + filepath)
|
|
286
|
+
.digest('hex')
|
|
287
|
+
.substring(0, 6);
|
|
288
|
+
return hash;
|
|
289
|
+
}
|
|
290
|
+
var filename = path.basename(filepath, '.scss');
|
|
281
291
|
let nearestPackageJson = findNearestPackageJsonSync(filename);
|
|
282
292
|
let packageName = nearestPackageJson
|
|
283
293
|
? nearestPackageJson.data.name
|
|
284
|
-
:
|
|
285
|
-
return packageName.replace(/[^a-zA-Z0-9_]+/g, '_') +
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
var moduleName;
|
|
291
|
-
if (module) {
|
|
292
|
-
moduleName = module[1];
|
|
293
|
-
}
|
|
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;
|
|
294
|
+
: 'unknown';
|
|
295
|
+
return (packageName.replace(/[^a-zA-Z0-9_]+/g, '_') +
|
|
296
|
+
'_' +
|
|
297
|
+
filename +
|
|
298
|
+
'_' +
|
|
299
|
+
cssClassName);
|
|
313
300
|
}
|
|
314
301
|
exports.generateScopedName = generateScopedName;
|
|
315
302
|
function log(...messages) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lincd-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.58",
|
|
4
4
|
"description": "Command line tools for the lincd.js library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepublishOnly": "npm exec tsc",
|
|
8
8
|
"build": "npm exec tsc",
|
|
9
9
|
"_postinstall": "husky install",
|
|
10
|
-
"prepack": "
|
|
10
|
+
"prepack": "npm exec tsc && pinst --disable && yarn version patch",
|
|
11
11
|
"postpack": "pinst --enable",
|
|
12
12
|
"dev": "npm exec tsc -w",
|
|
13
13
|
"prettier": "prettier \"src/**/*.{js,jsx,ts,tsx,css,scss}\" --check",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"find-nearest-package-json": "^2.0.1",
|
|
64
64
|
"fs-extra": "^11.1.1",
|
|
65
65
|
"glob": "^7.1.6",
|
|
66
|
-
"grunt": "^1.
|
|
66
|
+
"grunt": "^1.6.1",
|
|
67
67
|
"grunt-cli": "^1.4.3",
|
|
68
68
|
"grunt-concurrent": "^3.0.0",
|
|
69
|
-
"grunt-contrib-clean": "^2.0.
|
|
69
|
+
"grunt-contrib-clean": "^2.0.1",
|
|
70
70
|
"grunt-contrib-copy": "^1.0.0",
|
|
71
71
|
"grunt-exec": "^3.0.0",
|
|
72
72
|
"grunt-ts": "^6.0.0-beta.22",
|
|
@@ -78,12 +78,14 @@
|
|
|
78
78
|
"load-grunt-tasks": "^5.1.0",
|
|
79
79
|
"mini-css-extract-plugin": "^2.7.5",
|
|
80
80
|
"open": "^8.4.0",
|
|
81
|
-
"postcss": "^8.4.
|
|
82
|
-
"postcss-
|
|
83
|
-
"postcss-
|
|
81
|
+
"postcss": "^8.4.31",
|
|
82
|
+
"postcss-comment": "^2.0.0",
|
|
83
|
+
"postcss-import": "^15.1.0",
|
|
84
|
+
"postcss-loader": "^7.3.3",
|
|
84
85
|
"postcss-modules": "^6.0.0",
|
|
85
|
-
"postcss-nested": "^
|
|
86
|
-
"postcss-scss": "^4.0.
|
|
86
|
+
"postcss-nested": "^6.0.1",
|
|
87
|
+
"postcss-scss": "^4.0.9",
|
|
88
|
+
"postcss-strip-inline-comments": "^0.1.5",
|
|
87
89
|
"require-extensions": "^0.0.4",
|
|
88
90
|
"sass": "^1.55.0",
|
|
89
91
|
"sass-loader": "^13.0.2",
|