@modern-js/repo-generator 0.0.0-canary-20220824070800 → 0.0.0-canary-20220830054020

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 +162 -26
  2. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -140400,18 +140400,14 @@ var require_runtimeExports2 = __commonJSMin((exports) => {
140400
140400
  return res;
140401
140401
  };
140402
140402
  };
140403
- exports.createRuntimeExportsUtils = memo((pwd = "", namespace, ts = false) => {
140404
- const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : "index.js"}`);
140405
- const entryExportTsFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : "index.d.ts"}`);
140403
+ exports.createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
140404
+ const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace}.js`);
140406
140405
  const addExport = (statement) => {
140407
140406
  statement = (0, path_2.normalizeOutputPath)(statement);
140408
140407
  try {
140409
140408
  compiled_1.fs.ensureFileSync(entryExportFile);
140410
- compiled_1.fs.ensureFileSync(entryExportTsFile);
140411
140409
  if (!compiled_1.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
140412
140410
  compiled_1.fs.appendFileSync(entryExportFile, `${statement}
140413
- `);
140414
- ts && compiled_1.fs.appendFileSync(entryExportTsFile, `${statement.replace(".js", ".d")}
140415
140411
  `);
140416
140412
  }
140417
140413
  } catch {
@@ -140900,8 +140896,8 @@ var require_analyzeProject2 = __commonJSMin((exports) => {
140900
140896
  exports.isApiOnly = void 0;
140901
140897
  var path6 = __importStar(__require("path"));
140902
140898
  var compiled_1 = require_compiled2();
140903
- var isApiOnly = async (appDirectory) => {
140904
- const srcDir = path6.join(appDirectory, "src");
140899
+ var isApiOnly = async (appDirectory, entryDir) => {
140900
+ const srcDir = path6.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
140905
140901
  const existSrc = await compiled_1.fs.pathExists(srcDir);
140906
140902
  const options3 = (0, compiled_1.minimist)(process.argv.slice(2));
140907
140903
  return !existSrc || Boolean(options3["api-only"]);
@@ -140925,8 +140921,9 @@ var require_chainId2 = __commonJSMin((exports) => {
140925
140921
  LESS: "less",
140926
140922
  SASS: "sass",
140927
140923
  SVG: "svg",
140928
- SVG_INLINE: "svg-inline",
140929
- SVG_URL: "svg-url"
140924
+ PUG: "pug",
140925
+ TOML: "toml",
140926
+ YAML: "yaml"
140930
140927
  },
140931
140928
  ONE_OF: {
140932
140929
  JS: "js",
@@ -140944,6 +140941,7 @@ var require_chainId2 = __commonJSMin((exports) => {
140944
140941
  SASS_MODULES: "sass-modules",
140945
140942
  SVG: "svg",
140946
140943
  SVG_URL: "svg-url",
140944
+ SVG_ASSET: "svg-asset",
140947
140945
  SVG_INLINE: "svg-inline",
140948
140946
  ASSETS: "assets",
140949
140947
  ASSETS_URL: "assets-url",
@@ -140955,6 +140953,7 @@ var require_chainId2 = __commonJSMin((exports) => {
140955
140953
  SASS: "sass",
140956
140954
  LESS: "less",
140957
140955
  URL: "url",
140956
+ PUG: "pug",
140958
140957
  FILE: "file",
140959
140958
  SVGR: "svgr",
140960
140959
  YAML: "yaml",
@@ -140985,7 +140984,8 @@ var require_chainId2 = __commonJSMin((exports) => {
140985
140984
  HTML_CROSS_ORIGIN: "html-cross-origin",
140986
140985
  MINI_CSS_EXTRACT: "mini-css-extract",
140987
140986
  REACT_FAST_REFRESH: "react-fast-refresh",
140988
- NODE_POLYFILL_PROVIDE: "node-polyfill-provide"
140987
+ NODE_POLYFILL_PROVIDE: "node-polyfill-provide",
140988
+ MODULE_DEPENDENCY_ERROR: "module-dependency-error"
140989
140989
  },
140990
140990
  MINIMIZER: {
140991
140991
  JS: "js",
@@ -141153,6 +141153,78 @@ var require_locale2 = __commonJSMin((exports) => {
141153
141153
  });
141154
141154
  exports.localeKeys = localeKeys3;
141155
141155
  });
141156
+ var require_package = __commonJSMin((exports) => {
141157
+ "use strict";
141158
+ Object.defineProperty(exports, "__esModule", {
141159
+ value: true
141160
+ });
141161
+ exports.getAvailableVersion = getAvailableVersion;
141162
+ exports.isPackageDeprecated = isPackageDeprecated;
141163
+ exports.isPackageExist = isPackageExist;
141164
+ exports.semverDecrease = semverDecrease;
141165
+ var _utils = require_dist2();
141166
+ async function isPackageExist(packageName, registry) {
141167
+ if (await (0, _utils.canUseNpm)()) {
141168
+ const args = ["view", packageName, "version"];
141169
+ if (registry) {
141170
+ args.push(`--registry=${registry}`);
141171
+ }
141172
+ const result = await (0, _utils.execa)("npm", args);
141173
+ return (0, _utils.stripAnsi)(result.stdout);
141174
+ }
141175
+ throw new Error("not found npm, please install npm before");
141176
+ }
141177
+ async function isPackageDeprecated(packageName, registry) {
141178
+ if (await (0, _utils.canUseNpm)()) {
141179
+ const args = ["view", packageName, "deprecated"];
141180
+ if (registry) {
141181
+ args.push(`--registry=${registry}`);
141182
+ }
141183
+ const result = await (0, _utils.execa)("npm", args);
141184
+ return (0, _utils.stripAnsi)(result.stdout);
141185
+ }
141186
+ throw new Error("not found npm, please install npm before");
141187
+ }
141188
+ function semverDecrease(version4) {
141189
+ const versionObj = _utils.semver.parse(version4, {
141190
+ loose: true
141191
+ });
141192
+ if (!versionObj) {
141193
+ throw new Error(`Version ${version4} is not valid semver`);
141194
+ }
141195
+ versionObj.build = [];
141196
+ versionObj.prerelease = [];
141197
+ versionObj.patch--;
141198
+ const result = versionObj.format();
141199
+ if (!_utils.semver.valid(result)) {
141200
+ _utils.logger.debug(`Version ${result} is not valid semver`);
141201
+ return version4;
141202
+ }
141203
+ return result;
141204
+ }
141205
+ async function getAvailableVersion(packageName, currentVersion, registry) {
141206
+ let times = 5;
141207
+ let version4 = currentVersion;
141208
+ while (times) {
141209
+ if (!await isPackageExist(`${packageName}@${version4}`, registry) || await isPackageDeprecated(`${packageName}@${version4}`, registry)) {
141210
+ version4 = _utils.semver.inc(version4, "patch");
141211
+ times--;
141212
+ continue;
141213
+ }
141214
+ return version4;
141215
+ }
141216
+ times = 5;
141217
+ while (times) {
141218
+ version4 = semverDecrease(version4);
141219
+ if (!await isPackageExist(`${packageName}@${version4}`, registry) || await isPackageDeprecated(`${packageName}@${version4}`, registry)) {
141220
+ times--;
141221
+ continue;
141222
+ }
141223
+ return version4;
141224
+ }
141225
+ return currentVersion;
141226
+ }
141227
+ });
141156
141228
  var require_utils10 = __commonJSMin((exports) => {
141157
141229
  "use strict";
141158
141230
  Object.defineProperty(exports, "__esModule", {
@@ -141171,6 +141243,19 @@ var require_utils10 = __commonJSMin((exports) => {
141171
141243
  }
141172
141244
  });
141173
141245
  });
141246
+ var _package = require_package();
141247
+ Object.keys(_package).forEach(function(key) {
141248
+ if (key === "default" || key === "__esModule")
141249
+ return;
141250
+ if (key in exports && exports[key] === _package[key])
141251
+ return;
141252
+ Object.defineProperty(exports, key, {
141253
+ enumerable: true,
141254
+ get: function() {
141255
+ return _package[key];
141256
+ }
141257
+ });
141258
+ });
141174
141259
  });
141175
141260
  var require_node8 = __commonJSMin((exports) => {
141176
141261
  "use strict";
@@ -141180,6 +141265,7 @@ var require_node8 = __commonJSMin((exports) => {
141180
141265
  var _exportNames = {
141181
141266
  getPackageVersion: true,
141182
141267
  getModernVersion: true,
141268
+ getModernPluginVersion: true,
141183
141269
  getPackageManagerText: true,
141184
141270
  isTsProject: true,
141185
141271
  getPackageObj: true,
@@ -141189,6 +141275,7 @@ var require_node8 = __commonJSMin((exports) => {
141189
141275
  getModuleProjectPath: true,
141190
141276
  getMWAProjectPath: true,
141191
141277
  fs: true,
141278
+ semver: true,
141192
141279
  execa: true,
141193
141280
  readTsConfigByFile: true,
141194
141281
  getPackageManager: true,
@@ -141230,6 +141317,7 @@ var require_node8 = __commonJSMin((exports) => {
141230
141317
  });
141231
141318
  exports.getAllPackages = getAllPackages;
141232
141319
  exports.getMWAProjectPath = getMWAProjectPath;
141320
+ exports.getModernPluginVersion = getModernPluginVersion;
141233
141321
  exports.getModernVersion = getModernVersion;
141234
141322
  exports.getModuleProjectPath = getModuleProjectPath;
141235
141323
  Object.defineProperty(exports, "getPackageManager", {
@@ -141260,12 +141348,19 @@ var require_node8 = __commonJSMin((exports) => {
141260
141348
  return _utils.readTsConfigByFile;
141261
141349
  }
141262
141350
  });
141351
+ Object.defineProperty(exports, "semver", {
141352
+ enumerable: true,
141353
+ get: function() {
141354
+ return _utils.semver;
141355
+ }
141356
+ });
141263
141357
  exports.validatePackageName = validatePackageName;
141264
141358
  exports.validatePackagePath = validatePackagePath;
141265
141359
  var _path = _interopRequireDefault(__require("path"));
141266
141360
  var _utils = require_dist2();
141267
141361
  var _stripAnsi = require_strip_ansi4();
141268
141362
  var _locale = require_locale2();
141363
+ var _package = require_package();
141269
141364
  var _utils2 = require_utils10();
141270
141365
  Object.keys(_utils2).forEach(function(key) {
141271
141366
  if (key === "default" || key === "__esModule")
@@ -141322,11 +141417,39 @@ var require_node8 = __commonJSMin((exports) => {
141322
141417
  module: "@modern-js/module-tools",
141323
141418
  monorepo: "@modern-js/monorepo-tools"
141324
141419
  };
141325
- async function getModernVersion(solution) {
141420
+ async function getModernVersion(solution, registry) {
141326
141421
  const dep = SolutionDep[solution];
141327
- const modernVersion = await getPackageVersion(dep);
141422
+ const modernVersion = await getPackageVersion(dep, registry);
141328
141423
  return modernVersion;
141329
141424
  }
141425
+ async function getModernPluginVersion(solution, packageName, options3 = {}) {
141426
+ const {
141427
+ cwd = process.cwd(),
141428
+ registry
141429
+ } = options3;
141430
+ const getLatetPluginVersion = async () => {
141431
+ const version4 = await getPackageVersion(packageName, registry);
141432
+ return version4;
141433
+ };
141434
+ if (!packageName.startsWith("@modern-js")) {
141435
+ return getLatetPluginVersion();
141436
+ }
141437
+ const pkgPath = _path.default.join(__require.resolve(SolutionDep[solution], {
141438
+ paths: [cwd]
141439
+ }), "../../../../", "package.json");
141440
+ if (_utils.fs.existsSync(pkgPath)) {
141441
+ const pkgInfo = _utils.fs.readJSONSync(pkgPath);
141442
+ const modernVersion = pkgInfo.version;
141443
+ if (typeof modernVersion !== "string") {
141444
+ return getLatetPluginVersion();
141445
+ }
141446
+ if (_utils.semver.lt(modernVersion, "1.15.0")) {
141447
+ return getLatetPluginVersion();
141448
+ }
141449
+ return (0, _package.getAvailableVersion)(packageName, modernVersion, registry);
141450
+ }
141451
+ return getLatetPluginVersion();
141452
+ }
141330
141453
  function getPackageManagerText(packageManager) {
141331
141454
  return packageManager === "yarn" ? "yarn" : `${packageManager} run`;
141332
141455
  }
@@ -142347,6 +142470,7 @@ var require_utils12 = __commonJSMin((exports) => {
142347
142470
  value: true
142348
142471
  });
142349
142472
  exports.alreadyRepo = alreadyRepo;
142473
+ exports.getGeneratorPath = getGeneratorPath2;
142350
142474
  exports.hasEnabledFunction = hasEnabledFunction;
142351
142475
  exports.readJson = void 0;
142352
142476
  var _path = _interopRequireDefault(__require("path"));
@@ -142396,6 +142520,14 @@ var require_utils12 = __commonJSMin((exports) => {
142396
142520
  }
142397
142521
  return false;
142398
142522
  }
142523
+ function getGeneratorPath2(generator, distTag) {
142524
+ if (process.env.CODESMITH_ENV === "development") {
142525
+ return _path.default.dirname(__require.resolve(generator));
142526
+ } else if (distTag) {
142527
+ return `${generator}@${distTag}`;
142528
+ }
142529
+ return generator;
142530
+ }
142399
142531
  });
142400
142532
  var require_mwa = __commonJSMin((exports) => {
142401
142533
  "use strict";
@@ -142457,13 +142589,15 @@ var require_mwa = __commonJSMin((exports) => {
142457
142589
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
142458
142590
  const actionType = ans.actionType;
142459
142591
  const action2 = ans[actionType];
142460
- let generator = _generatorCommon.MWANewActionGenerators[actionType][action2];
142592
+ const generator = (0, _utils.getGeneratorPath)(_generatorCommon.MWANewActionGenerators[actionType][action2], distTag);
142461
142593
  if (!generator) {
142462
142594
  throw new Error(`no valid option`);
142463
142595
  }
142464
- if (distTag) {
142465
- generator = `${generator}@${distTag}`;
142466
- }
142596
+ const getMwaPluginVersion = (packageName) => {
142597
+ return (0, _generatorUtils.getModernPluginVersion)(_generatorCommon.Solution.MWA, packageName, {
142598
+ registry
142599
+ });
142600
+ };
142467
142601
  const devDependency = _generatorCommon.MWAActionFunctionsDevDependencies[action2];
142468
142602
  const dependency = _generatorCommon.MWAActionFunctionsDependencies[action2];
142469
142603
  const finalConfig = (0, _lodash.merge)(UserConfig, ans, {
@@ -142471,10 +142605,10 @@ var require_mwa = __commonJSMin((exports) => {
142471
142605
  packageManager: UserConfig.packageManager || await (0, _generatorUtils.getPackageManager)(cwd)
142472
142606
  }, {
142473
142607
  devDependencies: devDependency ? {
142474
- [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
142608
+ [devDependency]: `${await getMwaPluginVersion(devDependency)}`
142475
142609
  } : {},
142476
142610
  dependencies: dependency ? {
142477
- [dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
142611
+ [dependency]: `${await getMwaPluginVersion(dependency)}`
142478
142612
  } : {},
142479
142613
  appendTypeContent: _generatorCommon.MWAActionFunctionsAppendTypeContent[action2]
142480
142614
  });
@@ -142560,28 +142694,30 @@ var require_module = __commonJSMin((exports) => {
142560
142694
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
142561
142695
  const actionType = ans.actionType;
142562
142696
  const action2 = ans[actionType];
142563
- let generator = _generatorCommon.ModuleNewActionGenerators[actionType] && _generatorCommon.ModuleNewActionGenerators[actionType][action2];
142697
+ const generator = (0, _utils.getGeneratorPath)(_generatorCommon.ModuleNewActionGenerators[actionType][action2], distTag);
142564
142698
  if (!generator) {
142565
142699
  throw new Error(`no valid option`);
142566
142700
  }
142567
- if (distTag) {
142568
- generator = `${generator}@${distTag}`;
142569
- }
142570
142701
  const devDependency = _generatorCommon.ModuleActionFunctionsDevDependencies[action2];
142571
142702
  const dependency = _generatorCommon.ModuleActionFunctionsDependencies[action2];
142572
142703
  const peerDependency = _generatorCommon.ModuleActionFunctionsPeerDependencies[action2];
142704
+ const getModulePluginVersion = (packageName) => {
142705
+ return (0, _generatorUtils.getModernPluginVersion)(_generatorCommon.Solution.Module, packageName, {
142706
+ registry
142707
+ });
142708
+ };
142573
142709
  const finalConfig = (0, _lodash.merge)(UserConfig, ans, {
142574
142710
  locale: UserConfig.locale || locale,
142575
142711
  packageManager: UserConfig.packageManager || await (0, _generatorUtils.getPackageManager)(cwd)
142576
142712
  }, {
142577
142713
  devDependencies: devDependency ? {
142578
- [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
142714
+ [devDependency]: `${await getModulePluginVersion(devDependency)}`
142579
142715
  } : {},
142580
142716
  dependencies: dependency ? {
142581
- [dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
142717
+ [dependency]: `${await getModulePluginVersion(dependency)}`
142582
142718
  } : {},
142583
142719
  peerDependencies: peerDependency ? {
142584
- [peerDependency]: `^${await (0, _generatorUtils.getPackageVersion)(peerDependency)}`
142720
+ [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
142585
142721
  } : {}
142586
142722
  });
142587
142723
  const task = [{
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-canary-20220824070800",
14
+ "version": "0.0.0-canary-20220830054020",
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-20220824070800",
26
+ "@modern-js/base-generator": "0.0.0-canary-20220830054020",
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-20220824070800",
30
- "@modern-js/generator-plugin": "0.0.0-canary-20220824070800",
31
- "@modern-js/generator-utils": "0.0.0-canary-20220824070800",
32
- "@modern-js/module-generator": "0.0.0-canary-20220824070800",
33
- "@modern-js/monorepo-generator": "0.0.0-canary-20220824070800",
34
- "@modern-js/mwa-generator": "0.0.0-canary-20220824070800",
35
- "@modern-js/utils": "0.0.0-canary-20220824070800",
36
- "@scripts/build": "1.15.0",
37
- "@scripts/jest-config": "1.15.0",
29
+ "@modern-js/generator-common": "0.0.0-canary-20220830054020",
30
+ "@modern-js/generator-plugin": "0.0.0-canary-20220830054020",
31
+ "@modern-js/generator-utils": "0.0.0-canary-20220830054020",
32
+ "@modern-js/module-generator": "0.0.0-canary-20220830054020",
33
+ "@modern-js/monorepo-generator": "0.0.0-canary-20220830054020",
34
+ "@modern-js/mwa-generator": "0.0.0-canary-20220830054020",
35
+ "@modern-js/utils": "0.0.0-canary-20220830054020",
36
+ "@scripts/build": "0.0.0-canary-20220830054020",
37
+ "@scripts/jest-config": "0.0.0-canary-20220830054020",
38
38
  "@types/jest": "^27",
39
39
  "@types/node": "^14",
40
40
  "jest": "^27",