@modern-js/repo-generator 0.0.0-canary-20221010130822 → 0.0.0-canary-20221011062930

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.
Files changed (2) hide show
  1. package/dist/index.js +63 -39
  2. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -130418,23 +130418,17 @@ var require_compatRequire2 = __commonJSMin((exports) => {
130418
130418
  Object.defineProperty(exports, "__esModule", { value: true });
130419
130419
  exports.cleanRequireCache = exports.requireExistModule = exports.compatRequire = void 0;
130420
130420
  var findExists_1 = require_findExists2();
130421
- var compatRequire = (filePath, interop = true) => {
130421
+ var compatRequire = (filePath) => {
130422
130422
  const mod = __require(filePath);
130423
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
130424
- return rtnESMDefault ? mod.default : mod;
130423
+ return (mod === null || mod === void 0 ? void 0 : mod.__esModule) ? mod.default : mod;
130425
130424
  };
130426
130425
  exports.compatRequire = compatRequire;
130427
- var requireExistModule = (filename, opt) => {
130428
- const final = {
130429
- extensions: [".ts", ".js"],
130430
- interop: true,
130431
- ...opt
130432
- };
130433
- const exist = (0, findExists_1.findExists)(final.extensions.map((ext) => `${filename}${ext}`));
130426
+ var requireExistModule = (filename, extensions = [".ts", ".js"]) => {
130427
+ const exist = (0, findExists_1.findExists)(extensions.map((ext) => `${filename}${ext}`));
130434
130428
  if (!exist) {
130435
130429
  return null;
130436
130430
  }
130437
- return (0, exports.compatRequire)(exist, final.interop);
130431
+ return (0, exports.compatRequire)(exist);
130438
130432
  };
130439
130433
  exports.requireExistModule = requireExistModule;
130440
130434
  var cleanRequireCache = (filelist) => {
@@ -130467,7 +130461,6 @@ var require_constants6 = __commonJSMin((exports) => {
130467
130461
  "@modern-js/app-tools": { cli: "@modern-js/app-tools/cli" },
130468
130462
  "@modern-js/monorepo-tools": { cli: "@modern-js/monorepo-tools/cli" },
130469
130463
  "@modern-js/module-tools": { cli: "@modern-js/module-tools/cli" },
130470
- "@modern-js/module-tools-v2": { cli: "@modern-js/module-tools-v2" },
130471
130464
  "@modern-js/runtime": { cli: "@modern-js/runtime/cli" },
130472
130465
  "@modern-js/plugin-less": { cli: "@modern-js/plugin-less/cli" },
130473
130466
  "@modern-js/plugin-sass": { cli: "@modern-js/plugin-sass/cli" },
@@ -130772,10 +130765,13 @@ var require_getPort2 = __commonJSMin((exports) => {
130772
130765
  var net_1 = __importDefault(__require("net"));
130773
130766
  var compiled_1 = require_compiled2();
130774
130767
  var logger_1 = require_logger4();
130775
- var getPort = async (port, tryLimits = 20) => {
130768
+ var getPort = async (port, { tryLimits = 20, strictPort = false } = {}) => {
130776
130769
  if (typeof port === "string") {
130777
130770
  port = parseInt(port, 10);
130778
130771
  }
130772
+ if (strictPort) {
130773
+ tryLimits = 1;
130774
+ }
130779
130775
  const original = port;
130780
130776
  let found = false;
130781
130777
  let attempts = 0;
@@ -130802,7 +130798,11 @@ var require_getPort2 = __commonJSMin((exports) => {
130802
130798
  }
130803
130799
  }
130804
130800
  if (port !== original) {
130805
- logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
130801
+ if (strictPort) {
130802
+ throw new Error(`Port "${original}" is occupied, please choose another one.`);
130803
+ } else {
130804
+ logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
130805
+ }
130806
130806
  }
130807
130807
  return port;
130808
130808
  };
@@ -134519,6 +134519,7 @@ var PluginInputContext = /* @__PURE__ */ function() {
134519
134519
  function PluginInputContext2(inputs) {
134520
134520
  _classCallCheck(this, PluginInputContext2);
134521
134521
  _defineProperty(this, "inputValue", {});
134522
+ _defineProperty(this, "defaultConfig", {});
134522
134523
  _defineProperty(this, "inputs", []);
134523
134524
  _defineProperty(this, "extendInputMap", {});
134524
134525
  _defineProperty(this, "extendOptionMap", {});
@@ -134533,7 +134534,8 @@ var PluginInputContext = /* @__PURE__ */ function() {
134533
134534
  setInput: this.setInput.bind(this),
134534
134535
  addOptionBefore: this.addOptionBefore.bind(this),
134535
134536
  addOptionAfter: this.addOptionAfter.bind(this),
134536
- setInputValue: this.setInputValue.bind(this)
134537
+ setInputValue: this.setInputValue.bind(this),
134538
+ setDefaultConfig: this.setDefualtConfig.bind(this)
134537
134539
  };
134538
134540
  }
134539
134541
  }, {
@@ -134843,6 +134845,11 @@ var PluginInputContext = /* @__PURE__ */ function() {
134843
134845
  value: function setInputValue(value) {
134844
134846
  this.inputValue = value;
134845
134847
  }
134848
+ }, {
134849
+ key: "setDefualtConfig",
134850
+ value: function setDefualtConfig(value) {
134851
+ this.defaultConfig = value;
134852
+ }
134846
134853
  }]);
134847
134854
  return PluginInputContext2;
134848
134855
  }();
@@ -135431,11 +135438,28 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135431
135438
  }
135432
135439
  return result;
135433
135440
  }
135441
+ }, {
135442
+ key: "getDefaultConfig",
135443
+ value: function getDefaultConfig() {
135444
+ var result = {};
135445
+ var _iterator3 = _createForOfIteratorHelper(this.plugins), _step3;
135446
+ try {
135447
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
135448
+ var info = _step3.value;
135449
+ result = (0, import_lodash7.merge)(result, info.context.inputContext.defaultConfig);
135450
+ }
135451
+ } catch (err) {
135452
+ _iterator3.e(err);
135453
+ } finally {
135454
+ _iterator3.f();
135455
+ }
135456
+ return result;
135457
+ }
135434
135458
  }, {
135435
135459
  key: "installPlugins",
135436
135460
  value: function() {
135437
135461
  var _installPlugins2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(solution, inputData) {
135438
- var plugins, plugin, _iterator3, _step3, info;
135462
+ var plugins, plugin, _iterator4, _step4, info;
135439
135463
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
135440
135464
  while (1) {
135441
135465
  switch (_context3.prev = _context3.next) {
@@ -135457,17 +135481,17 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135457
135481
  return installPlugins(plugins, inputData.registry);
135458
135482
  case 6:
135459
135483
  this.plugins = _context3.sent;
135460
- _iterator3 = _createForOfIteratorHelper(this.plugins);
135484
+ _iterator4 = _createForOfIteratorHelper(this.plugins);
135461
135485
  try {
135462
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
135463
- info = _step3.value;
135486
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
135487
+ info = _step4.value;
135464
135488
  info.context = new PluginContext(SolutionSchemas[solution], inputData.locale);
135465
135489
  info.module(info.context.context);
135466
135490
  }
135467
135491
  } catch (err) {
135468
- _iterator3.e(err);
135492
+ _iterator4.e(err);
135469
135493
  } finally {
135470
- _iterator3.f();
135494
+ _iterator4.f();
135471
135495
  }
135472
135496
  case 9:
135473
135497
  case "end":
@@ -135485,20 +135509,20 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135485
135509
  key: "getGitMessage",
135486
135510
  value: function getGitMessage() {
135487
135511
  var result = "";
135488
- var _iterator4 = _createForOfIteratorHelper(this.plugins), _step4;
135512
+ var _iterator5 = _createForOfIteratorHelper(this.plugins), _step5;
135489
135513
  try {
135490
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
135514
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done; ) {
135491
135515
  var _info$context;
135492
- var info = _step4.value;
135516
+ var info = _step5.value;
135493
135517
  if ((_info$context = info.context) !== null && _info$context !== void 0 && _info$context.gitAPI.gitMessage) {
135494
135518
  var _info$context2;
135495
135519
  result = ((_info$context2 = info.context) === null || _info$context2 === void 0 ? void 0 : _info$context2.gitAPI.gitMessage) || "";
135496
135520
  }
135497
135521
  }
135498
135522
  } catch (err) {
135499
- _iterator4.e(err);
135523
+ _iterator5.e(err);
135500
135524
  } finally {
135501
- _iterator4.f();
135525
+ _iterator5.f();
135502
135526
  }
135503
135527
  return result;
135504
135528
  }
@@ -135506,7 +135530,7 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135506
135530
  key: "handleForged",
135507
135531
  value: function() {
135508
135532
  var _handleForged = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee4(solution, basePath, inputData, projectPath, generatorCore) {
135509
- var generatorPlugin, restData, _iterator5, _step5, _info$context3, _info$context4, info, onForgedFunc, _iterator6, _step6, _info$context5, _info, afterForged;
135533
+ var generatorPlugin, restData, _iterator6, _step6, _info$context3, _info$context4, info, onForgedFunc, _iterator7, _step7, _info$context5, _info, afterForged;
135510
135534
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
135511
135535
  while (1) {
135512
135536
  switch (_context4.prev = _context4.next) {
@@ -135522,15 +135546,15 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135522
135546
  }
135523
135547
  return _context4.abrupt("return");
135524
135548
  case 5:
135525
- _iterator5 = _createForOfIteratorHelper(this.plugins);
135549
+ _iterator6 = _createForOfIteratorHelper(this.plugins);
135526
135550
  _context4.prev = 6;
135527
- _iterator5.s();
135551
+ _iterator6.s();
135528
135552
  case 8:
135529
- if ((_step5 = _iterator5.n()).done) {
135553
+ if ((_step6 = _iterator6.n()).done) {
135530
135554
  _context4.next = 17;
135531
135555
  break;
135532
135556
  }
135533
- info = _step5.value;
135557
+ info = _step6.value;
135534
135558
  (_info$context3 = info.context) === null || _info$context3 === void 0 ? void 0 : _info$context3.handlePrepareContext(generatorCore, solution, import_path2.default.join(basePath, projectPath), import_path2.default.join(info.templatePath, "templates"), restData);
135535
135559
  onForgedFunc = (_info$context4 = info.context) === null || _info$context4 === void 0 ? void 0 : _info$context4.lifeCycleFuncMap[LifeCycle.OnForged];
135536
135560
  if (!(onForgedFunc && (0, import_lodash7.isFunction)(onForgedFunc))) {
@@ -135548,21 +135572,21 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135548
135572
  case 19:
135549
135573
  _context4.prev = 19;
135550
135574
  _context4.t0 = _context4["catch"](6);
135551
- _iterator5.e(_context4.t0);
135575
+ _iterator6.e(_context4.t0);
135552
135576
  case 22:
135553
135577
  _context4.prev = 22;
135554
- _iterator5.f();
135578
+ _iterator6.f();
135555
135579
  return _context4.finish(22);
135556
135580
  case 25:
135557
- _iterator6 = _createForOfIteratorHelper(this.plugins);
135581
+ _iterator7 = _createForOfIteratorHelper(this.plugins);
135558
135582
  _context4.prev = 26;
135559
- _iterator6.s();
135583
+ _iterator7.s();
135560
135584
  case 28:
135561
- if ((_step6 = _iterator6.n()).done) {
135585
+ if ((_step7 = _iterator7.n()).done) {
135562
135586
  _context4.next = 36;
135563
135587
  break;
135564
135588
  }
135565
- _info = _step6.value;
135589
+ _info = _step7.value;
135566
135590
  afterForged = (_info$context5 = _info.context) === null || _info$context5 === void 0 ? void 0 : _info$context5.lifeCycleFuncMap[LifeCycle.AfterForged];
135567
135591
  if (!(afterForged && (0, import_lodash7.isFunction)(afterForged))) {
135568
135592
  _context4.next = 34;
@@ -135579,10 +135603,10 @@ var GeneratorPlugin = /* @__PURE__ */ function() {
135579
135603
  case 38:
135580
135604
  _context4.prev = 38;
135581
135605
  _context4.t1 = _context4["catch"](26);
135582
- _iterator6.e(_context4.t1);
135606
+ _iterator7.e(_context4.t1);
135583
135607
  case 41:
135584
135608
  _context4.prev = 41;
135585
- _iterator6.f();
135609
+ _iterator7.f();
135586
135610
  return _context4.finish(41);
135587
135611
  case 44:
135588
135612
  if (this.event) {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-canary-20221010130822",
14
+ "version": "0.0.0-canary-20221011062930",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "main": "./dist/index.js",
17
17
  "files": [
@@ -23,18 +23,18 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/runtime": "^7.18.0",
26
- "@modern-js/base-generator": "0.0.0-canary-20221010130822",
26
+ "@modern-js/base-generator": "0.0.0-canary-20221011062930",
27
27
  "@modern-js/codesmith": "^1.5.0",
28
28
  "@modern-js/codesmith-api-app": "^1.5.0",
29
- "@modern-js/generator-common": "0.0.0-canary-20221010130822",
30
- "@modern-js/generator-plugin": "0.0.0-canary-20221010130822",
31
- "@modern-js/generator-utils": "0.0.0-canary-20221010130822",
32
- "@modern-js/module-generator": "0.0.0-canary-20221010130822",
33
- "@modern-js/monorepo-generator": "0.0.0-canary-20221010130822",
34
- "@modern-js/mwa-generator": "0.0.0-canary-20221010130822",
35
- "@modern-js/utils": "0.0.0-canary-20221010130822",
36
- "@scripts/build": "0.0.0-canary-20221010130822",
37
- "@scripts/jest-config": "0.0.0-canary-20221010130822",
29
+ "@modern-js/generator-common": "0.0.0-canary-20221011062930",
30
+ "@modern-js/generator-plugin": "0.0.0-canary-20221011062930",
31
+ "@modern-js/generator-utils": "0.0.0-canary-20221011062930",
32
+ "@modern-js/module-generator": "0.0.0-canary-20221011062930",
33
+ "@modern-js/monorepo-generator": "0.0.0-canary-20221011062930",
34
+ "@modern-js/mwa-generator": "0.0.0-canary-20221011062930",
35
+ "@modern-js/utils": "0.0.0-canary-20221011062930",
36
+ "@scripts/build": "0.0.0-canary-20221011062930",
37
+ "@scripts/jest-config": "0.0.0-canary-20221011062930",
38
38
  "@types/jest": "^27",
39
39
  "@types/node": "^14",
40
40
  "jest": "^27",