lincd-cli 0.2.32 → 0.2.36

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.
@@ -1,112 +1,53 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
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
- };
49
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
4
  };
52
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
53
6
  exports.generateWebpackConfig = void 0;
54
- var declaration_plugin_1 = __importDefault(require("./plugins/declaration-plugin"));
55
- var externalise_modules_1 = __importDefault(require("./plugins/externalise-modules"));
56
- var watch_run_1 = __importDefault(require("./plugins/watch-run"));
57
- var utils_1 = require("./utils");
58
- var colors = require("colors");
7
+ const declaration_plugin_1 = __importDefault(require("./plugins/declaration-plugin"));
8
+ const externalise_modules_1 = __importDefault(require("./plugins/externalise-modules"));
9
+ const watch_run_1 = __importDefault(require("./plugins/watch-run"));
10
+ const utils_1 = require("./utils");
11
+ const colors = require("colors");
59
12
  // console.log('Webpack '+require('webpack/package.json').version);
60
13
  // console.log('ts-loader '+require('ts-loader/package.json').version);
61
- var fs = require('fs');
62
- var MiniCssExtractPlugin = require('mini-css-extract-plugin');
63
- var chalk = require('chalk');
64
- var webpack = require('webpack');
65
- var path = require('path');
14
+ const fs = require('fs');
15
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
16
+ const chalk = require('chalk');
17
+ const webpack = require('webpack');
18
+ const path = require('path');
66
19
  // const WebpackLicencePlugin = require('webpack-license-plugin');
67
20
  // const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
68
- var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
69
- var TerserPlugin = require('terser-webpack-plugin');
70
- var exec = require('child_process').exec;
71
- var CopyPlugin = require('copy-webpack-plugin');
72
- var tailwindPlugin = require('tailwindcss/plugin');
73
- var NODE_ENV = process.env.NODE_ENV;
74
- var nodeProduction = NODE_ENV == 'production';
21
+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
22
+ const TerserPlugin = require('terser-webpack-plugin');
23
+ const exec = require('child_process').exec;
24
+ const CopyPlugin = require('copy-webpack-plugin');
25
+ const tailwindPlugin = require('tailwindcss/plugin');
26
+ const NODE_ENV = process.env.NODE_ENV;
27
+ const nodeProduction = NODE_ENV == 'production';
75
28
  // const libraryName = 'lincd';
76
29
  process.traceDeprecation = true;
77
30
  function getLincdPackagePaths(packages) {
78
- var e_1, _a;
79
31
  if (!packages) {
80
- var pkgJson = (0, utils_1.getPackageJSON)();
81
- packages = __assign(__assign({}, pkgJson.dependencies), pkgJson.devDependencies);
32
+ let pkgJson = (0, utils_1.getPackageJSON)();
33
+ packages = Object.assign(Object.assign({}, pkgJson.dependencies), pkgJson.devDependencies);
82
34
  }
83
- var lincdPackagePaths = [];
84
- try {
85
- for (var _b = __values(Object.keys(packages)), _c = _b.next(); !_c.done; _c = _b.next()) {
86
- var dependency = _c.value;
87
- try {
88
- var pkgJson = require(dependency + '/package.json');
89
- if (pkgJson.lincd) {
90
- var pkgPath = require.resolve(dependency + '/package.json');
91
- lincdPackagePaths.push(pkgPath.substring(0, pkgPath.length - 13));
92
- }
93
- }
94
- catch (err) {
95
- // console.log("could not find "+dependency);
35
+ let lincdPackagePaths = [];
36
+ for (var dependency of Object.keys(packages)) {
37
+ try {
38
+ let pkgJson = require(dependency + '/package.json');
39
+ if (pkgJson.lincd) {
40
+ let pkgPath = require.resolve(dependency + '/package.json');
41
+ lincdPackagePaths.push(pkgPath.substring(0, pkgPath.length - 13));
96
42
  }
97
43
  }
98
- }
99
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
100
- finally {
101
- try {
102
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
44
+ catch (err) {
45
+ // console.log("could not find "+dependency);
103
46
  }
104
- finally { if (e_1) throw e_1.error; }
105
47
  }
106
48
  return lincdPackagePaths;
107
49
  }
108
- function generateWebpackConfig(buildName, moduleName, config) {
109
- if (config === void 0) { config = {}; }
50
+ function generateWebpackConfig(buildName, moduleName, config = {}) {
110
51
  if (!config.externals)
111
52
  config.externals = {};
112
53
  if (!config.internals)
@@ -128,7 +69,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
128
69
  (0, utils_1.warn)('Cannot find ' + configFile);
129
70
  process.exit();
130
71
  }
131
- var tsConfig = JSON.parse(fs.readFileSync(configFile));
72
+ let tsConfig = JSON.parse(fs.readFileSync(configFile));
132
73
  var plugins = [
133
74
  // new webpack.DefinePlugin({
134
75
  // 'process.env.BROWSER': JSON.stringify(true),
@@ -138,7 +79,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
138
79
  // new ExtractTextPlugin(config.cssFileName ? config.cssFileName : cleanModuleName + '.css'),
139
80
  new MiniCssExtractPlugin({
140
81
  // linkType: false,
141
- filename: config.cssFileName ? config.cssFileName : cleanModuleName + '.css'
82
+ filename: config.cssFileName ? config.cssFileName : cleanModuleName + '.css',
142
83
  }),
143
84
  //currently not compatible with webpack 5
144
85
  // new WebpackLicencePlugin({
@@ -152,38 +93,37 @@ function generateWebpackConfig(buildName, moduleName, config) {
152
93
  patterns: [
153
94
  {
154
95
  from: 'src/**/*.scss',
155
- to: function (_a) {
156
- var context = _a.context, absoluteFilename = _a.absoluteFilename;
96
+ to({ context, absoluteFilename }) {
157
97
  // console.log(chalk.magenta(context),chalk.magenta(absoluteFilename),process.cwd());
158
98
  //turn absolute path into the right lib path (lib is NOT in webpack output path, so need to use '../')
159
- var outputPath = absoluteFilename.replace(process.cwd(), '').replace('/src/', '../lib/');
99
+ let outputPath = absoluteFilename.replace(process.cwd(), '').replace('/src/', '../lib/');
160
100
  // console.log(chalk.blueBright(outputPath));
161
101
  return Promise.resolve(outputPath);
162
102
  },
163
- noErrorOnMissing: true
103
+ noErrorOnMissing: true,
164
104
  },
165
- ]
105
+ ],
166
106
  }),
167
107
  ];
168
108
  if (config.debug) {
169
- plugins.push(new watch_run_1["default"]());
109
+ plugins.push(new watch_run_1.default());
170
110
  }
171
111
  if (config.afterBuildCommand || config.afterFirstBuildCommand) {
172
- var executedFirstCommand_1 = false;
112
+ let executedFirstCommand = false;
173
113
  plugins.push({
174
- apply: function (compiler) {
175
- compiler.hooks.afterEmit.tap('AfterEmitPlugin', function (compilation) {
114
+ apply: (compiler) => {
115
+ compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
176
116
  if (config.afterBuildCommand) {
177
- exec(config.afterBuildCommand, function (err, stdout, stderr) {
117
+ exec(config.afterBuildCommand, (err, stdout, stderr) => {
178
118
  if (stdout)
179
119
  process.stdout.write(stdout);
180
120
  if (stderr)
181
121
  process.stderr.write(stderr);
182
122
  });
183
123
  }
184
- if (config.afterFirstBuildCommand && !executedFirstCommand_1) {
185
- executedFirstCommand_1 = true;
186
- exec(config.afterFirstBuildCommand, function (err, stdout, stderr) {
124
+ if (config.afterFirstBuildCommand && !executedFirstCommand) {
125
+ executedFirstCommand = true;
126
+ exec(config.afterFirstBuildCommand, (err, stdout, stderr) => {
187
127
  if (stdout)
188
128
  process.stdout.write(stdout);
189
129
  if (stderr)
@@ -191,17 +131,17 @@ function generateWebpackConfig(buildName, moduleName, config) {
191
131
  });
192
132
  }
193
133
  });
194
- }
134
+ },
195
135
  });
196
136
  }
197
137
  if (config.analyse) {
198
138
  plugins.push(new BundleAnalyzerPlugin());
199
139
  }
200
140
  if ((es6 || config.declarations === true) && !config.declarations === false) {
201
- plugins.push(new declaration_plugin_1["default"]({
141
+ plugins.push(new declaration_plugin_1.default({
202
142
  out: (config.filename ? config.filename : cleanModuleName) + '.d.ts',
203
143
  root: config.outputPath ? config.outputPath : './lib/',
204
- debug: 'debug' in config ? config.debug : false
144
+ debug: 'debug' in config ? config.debug : false,
205
145
  }));
206
146
  }
207
147
  // var resolvePlugins = [
@@ -211,7 +151,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
211
151
  // }),
212
152
  // ];
213
153
  var aliases = config.alias || {};
214
- var postcssPlugins = [];
154
+ let postcssPlugins = [];
215
155
  if (!config.cssMode) {
216
156
  config.cssMode = 'mixed';
217
157
  }
@@ -227,18 +167,18 @@ function generateWebpackConfig(buildName, moduleName, config) {
227
167
  'postcss-modules',
228
168
  {
229
169
  generateScopedName: utils_1.generateScopedName.bind(null, moduleName),
230
- globalModulePaths: [/tailwind/, /tailwindcss/, config.cssGlobalModulePaths].filter(Boolean)
170
+ globalModulePaths: [/tailwind/, /tailwindcss/, config.cssGlobalModulePaths].filter(Boolean),
231
171
  },
232
172
  ]);
233
173
  }
234
174
  }
235
175
  if (config.cssMode === 'tailwind' || config.cssMode === 'mixed') {
236
- var lincdPackagePaths = void 0;
176
+ let lincdPackagePaths;
237
177
  //IF this package is including sources from another lincd package in its bundle (usually not the case)
238
178
  if (config.internals) {
239
179
  //THEN make sure that we also look for tailwind classes in those packages
240
180
  //pass the list of internal packages, or if all, pass null because it will look up all the package.json:dependencies
241
- lincdPackagePaths = getLincdPackagePaths(config.internals !== '*' ? config.internals : null).map(function (path) {
181
+ lincdPackagePaths = getLincdPackagePaths(config.internals !== '*' ? config.internals : null).map((path) => {
242
182
  return path + '/lib/**/*.{js,mjs}';
243
183
  });
244
184
  }
@@ -246,22 +186,21 @@ function generateWebpackConfig(buildName, moduleName, config) {
246
186
  postcssPlugins.push([
247
187
  'tailwindcss',
248
188
  {
249
- content: __spreadArray(['./src/**/*.{tsx,ts}'], __read(lincdPackagePaths), false),
189
+ content: ['./src/**/*.{tsx,ts}', ...lincdPackagePaths],
250
190
  safelist: productionMode
251
191
  ? {}
252
192
  : {
253
193
  //in development mode we allow all classes here, so that you can easily develop
254
194
  pattern: /./,
255
- variants: ['sm', 'md', 'lg', 'xl', '2xl']
195
+ variants: ['sm', 'md', 'lg', 'xl', '2xl'],
256
196
  },
257
197
  theme: {
258
198
  extend: {
259
- colors: (0, utils_1.getLinkedTailwindColors)()
260
- }
199
+ colors: (0, utils_1.getLinkedTailwindColors)(),
200
+ },
261
201
  },
262
202
  plugins: [
263
- tailwindPlugin(function (_a) {
264
- var addBase = _a.addBase, config = _a.config;
203
+ tailwindPlugin(function ({ addBase, config }) {
265
204
  //we can use LINCD CSS variables for default font color, size etc.
266
205
  // addBase({
267
206
  // 'h1': { fontSize: config('theme.fontSize.2xl') },
@@ -269,11 +208,11 @@ function generateWebpackConfig(buildName, moduleName, config) {
269
208
  // 'h3': { fontSize: config('theme.fontSize.lg') },
270
209
  // })
271
210
  }),
272
- ]
211
+ ],
273
212
  },
274
213
  ]);
275
214
  }
276
- var rules = [
215
+ let rules = [
277
216
  {
278
217
  test: /\.(scss|css)$/,
279
218
  use: [
@@ -281,22 +220,22 @@ function generateWebpackConfig(buildName, moduleName, config) {
281
220
  {
282
221
  loader: 'css-loader',
283
222
  options: {
284
- url: false
285
- }
223
+ url: false,
224
+ },
286
225
  },
287
226
  {
288
227
  loader: 'postcss-loader',
289
228
  options: {
290
229
  postcssOptions: {
291
- plugins: postcssPlugins
292
- }
293
- }
230
+ plugins: postcssPlugins,
231
+ },
232
+ },
294
233
  },
295
234
  {
296
235
  loader: 'sass-loader',
297
- options: { sourceMap: true }
236
+ options: { sourceMap: true },
298
237
  },
299
- ]
238
+ ],
300
239
  },
301
240
  // {
302
241
  // test: /\.(ts|tsx)$/,
@@ -327,17 +266,17 @@ function generateWebpackConfig(buildName, moduleName, config) {
327
266
  use: [
328
267
  {
329
268
  loader: 'ts-loader?' +
330
- JSON.stringify(__assign({ configFile: configFile, compilerOptions: {
269
+ JSON.stringify(Object.assign({ configFile: configFile, compilerOptions: {
331
270
  declaration: !es5,
332
271
  /*
333
272
  for webpack we overwrite the module settings of the modules' tsconfig file
334
273
  because we NEED esnext for code splitting. But the VM we currently use for the registry does not support esnext modules
335
274
  */
336
275
  module: 'esnext',
337
- moduleResolution: 'node'
338
- } }, config.tsConfigOverwrites))
276
+ moduleResolution: 'node',
277
+ } }, config.tsConfigOverwrites)),
339
278
  },
340
- ]
279
+ ],
341
280
  },
342
281
  // {
343
282
  // enforce: 'pre',
@@ -356,8 +295,8 @@ function generateWebpackConfig(buildName, moduleName, config) {
356
295
  //so we fix that here by just referring directly to the typescript source instead of the transpiled js for internalised modules
357
296
  //however this means that for internalised modules THE SOURCE CODE NEEDS TO BE AVAILABLE. This is currently NOT the case with how we publish modules to yarn
358
297
  //so that means internalised modules need to be LOCALLY AVAILABLE with yarn workspaces
359
- plugins.push(new webpack.NormalModuleReplacementPlugin(/lincd\/lib\//, function (resource, match) {
360
- var moduleName = resource.request.match(/lincd\/lib\//)[1];
298
+ plugins.push(new webpack.NormalModuleReplacementPlugin(/lincd\/lib\//, (resource, match) => {
299
+ let moduleName = resource.request.match(/lincd\/lib\//)[1];
361
300
  if (config.internalsources.indexOf(moduleName) !== -1) {
362
301
  console.log(colors.magenta('internal sources + ES5: Replacing /lib/ with /src/ for source-internalised module ' + moduleName));
363
302
  resource.request = resource.request.replace('/lib/', '/src/');
@@ -371,7 +310,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
371
310
  output: {
372
311
  filename: (config.filename ? config.filename : cleanModuleName) + (es5 ? '.es5' : '') + '.js',
373
312
  path: path.resolve(process.cwd(), config.bundlePath || 'dist'),
374
- devtoolModuleFilenameTemplate: moduleName + '/[resource-path]'
313
+ devtoolModuleFilenameTemplate: moduleName + '/[resource-path]',
375
314
  },
376
315
  devtool: productionMode ? 'source-map' : 'cheap-module-source-map',
377
316
  // devtool: productionMode ? 'cheap-source-map' : 'cheap-source-map',
@@ -385,14 +324,14 @@ function generateWebpackConfig(buildName, moduleName, config) {
385
324
  extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
386
325
  alias: aliases,
387
326
  // plugins: resolvePlugins,
388
- fallback: { crypto: false }
327
+ fallback: { crypto: false },
389
328
  },
390
329
  resolveLoader: {
391
330
  modules: [
392
331
  path.join(__dirname, 'plugins'),
393
332
  path.join(__dirname, 'node_modules'),
394
333
  'node_modules',
395
- ]
334
+ ],
396
335
  },
397
336
  optimization: {
398
337
  minimize: productionMode,
@@ -400,24 +339,24 @@ function generateWebpackConfig(buildName, moduleName, config) {
400
339
  new TerserPlugin({
401
340
  extractComments: {
402
341
  condition: /^\**!|@preserve|@license|@cc_on/i,
403
- banner: function (licenseFile) {
404
- return "License information can be found in ".concat(licenseFile, " and oss-licences.json");
405
- }
406
- }
342
+ banner: (licenseFile) => {
343
+ return `License information can be found in ${licenseFile} and oss-licences.json`;
344
+ },
345
+ },
407
346
  }),
408
- ]
347
+ ],
409
348
  },
410
349
  watch: watch,
411
350
  watchOptions: {
412
351
  ignored: ['**/*.d.ts', '**/*.js.map', '**/*.scss.json'],
413
- aggregateTimeout: 500
352
+ aggregateTimeout: 500,
414
353
  },
415
354
  module: {
416
- rules: rules
355
+ rules,
417
356
  },
418
357
  //See plugins/externalise-modules.ts We're passing in a function here that determines what to exclude from the bundle and what not
419
358
  //See also https://webpack.js.org/configuration/externals/
420
- externals: (0, externalise_modules_1["default"])(config, es5),
359
+ externals: (0, externalise_modules_1.default)(config, es5),
421
360
  plugins: plugins,
422
361
  stats: {
423
362
  errorDetails: true,
@@ -426,14 +365,16 @@ function generateWebpackConfig(buildName, moduleName, config) {
426
365
  version: true,
427
366
  hash: false,
428
367
  entrypoints: false,
429
- modules: false
368
+ modules: false,
430
369
  },
431
370
  //hide some info from output when in watch mode to keep it succinct
432
371
  //stats:{chunks:!watch,version:!watch}//hide some info from output when in watch mode to keep it succinct
433
372
  cache: {
434
373
  // https://webpack.js.org/configuration/other-options/#cache
435
- type: 'filesystem'
436
- }
374
+ type: 'filesystem',
375
+ // cacheDirectory: path.resolve(process.cwd(),"node_modules",".cache","webpack"),
376
+ // name: "lincd-webpack-cache",
377
+ },
437
378
  };
438
379
  }
439
380
  exports.generateWebpackConfig = generateWebpackConfig;
package/lib/index.js CHANGED
@@ -13,14 +13,17 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- exports.__esModule = true;
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
17
20
  exports.generateWebpackConfig = exports.generateGruntConfig = exports.externaliseModules = exports.DeclarationPlugin = void 0;
18
21
  var declaration_plugin_1 = require("./plugins/declaration-plugin");
19
- __createBinding(exports, declaration_plugin_1, "default", "DeclarationPlugin");
22
+ Object.defineProperty(exports, "DeclarationPlugin", { enumerable: true, get: function () { return __importDefault(declaration_plugin_1).default; } });
20
23
  var externalise_modules_1 = require("./plugins/externalise-modules");
21
- __createBinding(exports, externalise_modules_1, "default", "externaliseModules");
24
+ Object.defineProperty(exports, "externaliseModules", { enumerable: true, get: function () { return __importDefault(externalise_modules_1).default; } });
22
25
  var config_grunt_1 = require("./config-grunt");
23
- __createBinding(exports, config_grunt_1, "default", "generateGruntConfig");
24
- var config_webpack_1 = require("./config-webpack");
25
- exports.generateWebpackConfig = config_webpack_1.generateWebpackConfig;
26
+ Object.defineProperty(exports, "generateGruntConfig", { enumerable: true, get: function () { return __importDefault(config_grunt_1).default; } });
27
+ const config_webpack_1 = require("./config-webpack");
28
+ Object.defineProperty(exports, "generateWebpackConfig", { enumerable: true, get: function () { return config_webpack_1.generateWebpackConfig; } });
26
29
  __exportStar(require("./utils"), exports);
package/lib/interfaces.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });