lincd-cli 0.2.57 → 0.2.59

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.
@@ -753,10 +753,25 @@ exports.checkImports = checkImports;
753
753
  const depCheck = () => __awaiter(void 0, void 0, void 0, function* () {
754
754
  (0, depcheck_1.default)(process.cwd(), {}, (results) => {
755
755
  if (results.missing) {
756
+ let lincdPackages = getLocalLincdModules();
756
757
  let missing = Object.keys(results.missing);
758
+ //filter out missing types, if it builds we're not too concerned about that at the moment?
759
+ //especially things like @types/react, @types/react-dom, @types/node (they are added elsewhere?)
760
+ // missing = missing.filter(m => m.indexOf('@types/') === 0);
757
761
  //currently react is not an explicit dependency, but we should add it as a peer dependency
758
- missing.splice(missing.indexOf('react'));
759
- if (missing.length > 0) {
762
+ missing.splice(missing.indexOf('react'), 1);
763
+ let missingLincdPackages = missing.filter((missingDep) => {
764
+ return lincdPackages.some((lincdPackage) => {
765
+ return lincdPackage.packageName === missingDep;
766
+ });
767
+ });
768
+ //currently just missing LINCD packages cause a hard failure exit code
769
+ if (missingLincdPackages.length > 0) {
770
+ console.warn(chalk_1.default.red('\nThese LINCD packages are imported but they are not listed in package.json:\n- ' +
771
+ missingLincdPackages.join(',\n- ')));
772
+ process.exit(1);
773
+ }
774
+ else if (missing.length > 0) {
760
775
  console.warn(chalk_1.default.red('Missing dependencies:\n\t' + missing.join(',\n\t')));
761
776
  }
762
777
  }
@@ -971,6 +986,14 @@ const buildPackage = (target, target2, packagePath = process.cwd(), logResults =
971
986
  (target2 ? '-' + target2 : '') +
972
987
  ' --color');
973
988
  let method = logResults ? utils_1.execp : utils_1.execPromise;
989
+ //NOTE: we moved SCSS:JSON out of webpack and grunt, into this file
990
+ //this is the beginning of a transition away from grunt
991
+ //but for the time being it's perhaps a bit strange that we
992
+ // let x = postcss([
993
+ // postcssModules({
994
+ // generateScopedName,
995
+ // }),
996
+ // ]);
974
997
  //execute the command to build the method, and provide the current work directory as option
975
998
  return method(nodeEnv +
976
999
  'grunt build' +
@@ -88,7 +88,7 @@ function setupGrunt(grunt, moduleName, config) {
88
88
  // buildFrontend ? 'webpack:build-es6' : null,
89
89
  buildServer
90
90
  ? [
91
- 'clean:lib',
91
+ // 'clean:lib',
92
92
  'exec:build-lib',
93
93
  'copy:lib',
94
94
  'exec:depcheck',
@@ -143,8 +143,20 @@ function setupGrunt(grunt, moduleName, config) {
143
143
  postcss: {
144
144
  options: {
145
145
  map: true,
146
- processors: [require('postcss-modules')({ generateScopedName: utils_1.generateScopedName })],
146
+ // parser: require('postcss-scss'), //require('postcss-comment'),
147
147
  syntax: require('postcss-scss'),
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
+ ],
148
160
  writeDest: false,
149
161
  },
150
162
  cssjson: {
@@ -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, moduleName),
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(moduleName, name, filename, css) {
279
- // console.log(moduleName,name,filename,css);
280
- var file = path.basename(filename, '.scss');
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
- : 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];
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.57",
3
+ "version": "0.2.59",
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": "yarn version patch && npm exec tsc && pinst --disable",
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.3.0",
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.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.17",
82
- "postcss-import": "^15.0.0",
83
- "postcss-loader": "^7.0.1",
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": "^5.0.6",
86
- "postcss-scss": "^4.0.5",
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",