@bleedingdev/modern-js-create 3.2.0-ultramodern.121 → 3.2.0-ultramodern.123

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/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
24
- "version": "3.2.0-ultramodern.121",
24
+ "version": "3.2.0-ultramodern.123",
25
25
  "types": "./dist/types/index.d.ts",
26
26
  "main": "./dist/esm-node/index.js",
27
27
  "bin": {
@@ -52,7 +52,7 @@
52
52
  "bin"
53
53
  ],
54
54
  "dependencies": {
55
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.121"
55
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.123"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@rslib/core": "0.22.0",
@@ -73,6 +73,6 @@
73
73
  "test": "rm -rf dist && rslib build -c rslibconfig.mts && rstest --passWithNoTests"
74
74
  },
75
75
  "ultramodern": {
76
- "frameworkVersion": "3.2.0-ultramodern.121"
76
+ "frameworkVersion": "3.2.0-ultramodern.123"
77
77
  }
78
78
  }
@@ -38,6 +38,73 @@ const assertExists = relativePath => {
38
38
  const assertNotExists = relativePath => {
39
39
  assert(!fs.existsSync(path.join(root, relativePath)), `Unexpected ${relativePath}`);
40
40
  };
41
+ const packageJsonFiles = startDir => {
42
+ const files = [];
43
+ const queue = [startDir];
44
+ while (queue.length > 0) {
45
+ const current = queue.shift();
46
+ for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
47
+ if (
48
+ ['.git', '.output', 'dist', 'node_modules', 'repos'].includes(
49
+ entry.name,
50
+ )
51
+ ) {
52
+ continue;
53
+ }
54
+ const absolute = path.join(current, entry.name);
55
+ if (entry.isDirectory()) {
56
+ queue.push(absolute);
57
+ } else if (entry.name === 'package.json') {
58
+ files.push(absolute);
59
+ }
60
+ }
61
+ }
62
+ return files.sort();
63
+ };
64
+ const modernDependencyNames = packageJson =>
65
+ [
66
+ ...new Set(
67
+ ['dependencies', 'devDependencies']
68
+ .flatMap(section => Object.keys(packageJson[section] ?? {}))
69
+ .filter(packageName => packageName.startsWith('@modern-js/')),
70
+ ),
71
+ ];
72
+ const assertModernPackageCohort = () => {
73
+ const modernPackageNames = packageSource.modernPackages?.packages;
74
+ assert(
75
+ Array.isArray(modernPackageNames) && modernPackageNames.length > 0,
76
+ 'Package source metadata must list the Modern package cohort',
77
+ );
78
+ for (const packageName of modernPackageNames) {
79
+ assert(
80
+ typeof packageName === 'string' && packageName.startsWith('@modern-js/'),
81
+ `Package source metadata contains invalid Modern package name ${packageName}`,
82
+ );
83
+ }
84
+
85
+ const modernPackageNameSet = new Set(modernPackageNames);
86
+ for (const packageJsonPath of packageJsonFiles(root)) {
87
+ const relativePath = path.relative(root, packageJsonPath).split(path.sep).join('/');
88
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
89
+ for (const packageName of modernDependencyNames(packageJson)) {
90
+ assert(
91
+ modernPackageNameSet.has(packageName),
92
+ `${relativePath} declares ${packageName} outside package source metadata`,
93
+ );
94
+ }
95
+ for (const section of ['dependencies', 'devDependencies']) {
96
+ for (const packageName of modernPackageNames) {
97
+ const actual = packageJson[section]?.[packageName];
98
+ if (actual !== undefined) {
99
+ assert(
100
+ actual === expectedModernPackageSpecifier(packageName),
101
+ `${relativePath} ${section}.${packageName} must match package source metadata`,
102
+ );
103
+ }
104
+ }
105
+ }
106
+ }
107
+ };
41
108
  const assertPublicSurfaceAssets = (appPath, publicRoutes) => {
42
109
  for (const relativePath of publicSurfaceManagedSourceAssetPaths) {
43
110
  assertNotExists(`${appPath}/${relativePath}`);
@@ -269,19 +336,15 @@ assert(rootPackage.modernjs?.packageSource?.config === './.modernjs/ultramodern-
269
336
  assert(rootPackage.modernjs?.packageSource?.strategy === packageSource.strategy, 'Root package source strategy must match metadata');
270
337
  assert(packageSource.strategy === 'workspace' || packageSource.strategy === 'install', 'Package source strategy must be workspace or install');
271
338
  assert(packageSource.strategy === 'install' || packageSource.modernPackages?.specifier === 'workspace:*', 'Workspace package source must be explicitly backed by workspace:*');
272
- const expectedModernDependency = packageName => {
273
- const alias = packageSource.modernPackages?.aliases?.[packageName];
274
- const specifier = packageSource.modernPackages?.specifier;
275
- return typeof alias === 'string' ? `npm:${alias}@${specifier}` : specifier;
276
- };
339
+ assertModernPackageCohort();
277
340
  assert(
278
341
  rootPackage.devDependencies?.['@modern-js/create'] ===
279
- expectedModernDependency('@modern-js/create'),
342
+ expectedModernPackageSpecifier('@modern-js/create'),
280
343
  'Root must depend on @modern-js/create through package source metadata',
281
344
  );
282
345
  assert(
283
346
  rootPackage.devDependencies?.['@modern-js/code-tools'] ===
284
- expectedModernDependency('@modern-js/code-tools'),
347
+ expectedModernPackageSpecifier('@modern-js/code-tools'),
285
348
  'Root must depend on @modern-js/code-tools through package source metadata',
286
349
  );
287
350
  if (packageSource.strategy === 'install') {