Skip to content

Commit 7f6a0ce

Browse files
Clean Up Publish Process (#21)
## TLDR; Cleans up the publish process and removes the `dart_jsx` package from the list of packages to be published. ## What Does This Do? This change ensures that the `dart_jsx` package is no longer included in the publishing process. This prevents it from being built or published. ## Brief Details? The `dart_jsx` package has been removed from the `packageDeps` and `publishOrder` lists within the `prepare_publish.dart` file. This exclusion effectively removes the package from the automated publishing workflow. ## How Do The Tests Prove The Change Works? There are no specific tests included in this change, but the removal of `dart_jsx` prevents it from being included in any tests related to the publishing process.
1 parent 4048b6d commit 7f6a0ce

8 files changed

Lines changed: 385 additions & 324 deletions

File tree

cspell-dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,4 @@ LTWH
238238
blockquotes
239239
Blockquotes
240240
strikethrough
241+
unconfigured

packages/dart_jsx/CHANGELOG.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

tools/build/build.dart

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@ String? _searchEntryPoints(String exampleDir, List<String> remaining) {
187187
);
188188
}
189189

190-
// Transpile JSX files before compilation
191-
final jsxResult = _transpileJsxFiles(exampleDir);
192-
return !jsxResult.isSuccess
193-
? jsxResult
194-
: _compileToJs(exampleDir, entryPoint, target, buildDir);
190+
return _compileToJs(exampleDir, entryPoint, target, buildDir);
195191
}
196192

197193
({bool isSuccess, String message}) _compileToJs(
@@ -252,45 +248,3 @@ String? _searchEntryPoints(String exampleDir, List<String> remaining) {
252248
print(' Build complete: $finalOutput');
253249
return (isSuccess: true, message: 'Build successful');
254250
}
255-
256-
({bool isSuccess, String message}) _transpileJsxFiles(String exampleDir) {
257-
final dir = Directory(exampleDir);
258-
final jsxFiles = dir
259-
.listSync(recursive: true)
260-
.whereType<File>()
261-
.where((f) => f.path.endsWith('.jsx'))
262-
.toList();
263-
264-
final hasJsxFiles = jsxFiles.isNotEmpty;
265-
if (!hasJsxFiles) {
266-
return (isSuccess: true, message: 'No JSX files to transpile');
267-
}
268-
269-
print(' Transpiling ${jsxFiles.length} JSX file(s)...');
270-
271-
for (final file in jsxFiles) {
272-
final result = _transpileJsxFile(file.path);
273-
if (!result.isSuccess) return result;
274-
}
275-
276-
return (isSuccess: true, message: 'JSX transpilation complete');
277-
}
278-
279-
({bool isSuccess, String message}) _transpileJsxFile(String inputPath) {
280-
final outputPath = inputPath.replaceAll('.jsx', '.g.dart');
281-
final projectRoot = Directory.current.path;
282-
283-
final result = Process.runSync('dart', [
284-
'run',
285-
'$projectRoot/packages/dart_jsx/bin/jsx.dart',
286-
inputPath,
287-
outputPath,
288-
]);
289-
290-
return result.exitCode != 0
291-
? (
292-
isSuccess: false,
293-
message: 'JSX transpilation failed for $inputPath:\n${result.stderr}',
294-
)
295-
: (isSuccess: true, message: 'Transpiled $inputPath');
296-
}

tools/lib/packages.dart

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// ignore_for_file: avoid_print
2+
import 'dart:io';
3+
4+
/// Package metadata - single source of truth for all tooling
5+
/// Dependencies are read from pubspec.yaml files
6+
/// Test platforms and tiers are defined here
7+
class PackageConfig {
8+
final String name;
9+
final int tier;
10+
final TestPlatform testPlatform;
11+
final bool publish;
12+
13+
const PackageConfig({
14+
required this.name,
15+
required this.tier,
16+
required this.testPlatform,
17+
this.publish = true,
18+
});
19+
}
20+
21+
enum TestPlatform { node, vm, browser }
22+
23+
/// Package configurations - defines tier, test platform, and publish status
24+
/// Add new packages here when created
25+
const _packageConfigs = <String, PackageConfig>{
26+
// Tier 1 - no internal dependencies
27+
'dart_logging': PackageConfig(
28+
name: 'dart_logging',
29+
tier: 1,
30+
testPlatform: TestPlatform.vm,
31+
),
32+
'dart_node_core': PackageConfig(
33+
name: 'dart_node_core',
34+
tier: 1,
35+
testPlatform: TestPlatform.node,
36+
),
37+
// Tier 2 - depends on tier 1
38+
'reflux': PackageConfig(
39+
name: 'reflux',
40+
tier: 2,
41+
testPlatform: TestPlatform.vm,
42+
),
43+
'dart_node_express': PackageConfig(
44+
name: 'dart_node_express',
45+
tier: 2,
46+
testPlatform: TestPlatform.node,
47+
),
48+
'dart_node_ws': PackageConfig(
49+
name: 'dart_node_ws',
50+
tier: 2,
51+
testPlatform: TestPlatform.node,
52+
),
53+
'dart_node_better_sqlite3': PackageConfig(
54+
name: 'dart_node_better_sqlite3',
55+
tier: 2,
56+
testPlatform: TestPlatform.node,
57+
),
58+
'dart_node_mcp': PackageConfig(
59+
name: 'dart_node_mcp',
60+
tier: 2,
61+
testPlatform: TestPlatform.node,
62+
),
63+
// Tier 3 - depends on tier 2
64+
'dart_node_react': PackageConfig(
65+
name: 'dart_node_react',
66+
tier: 3,
67+
testPlatform: TestPlatform.browser,
68+
),
69+
'dart_node_react_native': PackageConfig(
70+
name: 'dart_node_react_native',
71+
tier: 3,
72+
testPlatform: TestPlatform.node,
73+
),
74+
// Non-published packages
75+
'dart_node_coverage': PackageConfig(
76+
name: 'dart_node_coverage',
77+
tier: 0,
78+
testPlatform: TestPlatform.vm,
79+
publish: false,
80+
),
81+
};
82+
83+
/// Discovers packages from the filesystem that have pubspec.yaml
84+
List<String> discoverPackages(String repoRoot) {
85+
final packagesDir = Directory('$repoRoot/packages');
86+
if (!packagesDir.existsSync()) return [];
87+
88+
return packagesDir
89+
.listSync()
90+
.whereType<Directory>()
91+
.where((d) => File('${d.path}/pubspec.yaml').existsSync())
92+
.map((d) => d.path.split('/').last)
93+
.toList()
94+
..sort();
95+
}
96+
97+
/// Gets config for a package, returns null if not configured
98+
PackageConfig? getPackageConfig(String name) => _packageConfigs[name];
99+
100+
/// Gets all publishable packages in tier order
101+
List<PackageConfig> getPublishablePackages() {
102+
final packages = _packageConfigs.values.where((p) => p.publish).toList()
103+
..sort((a, b) {
104+
final tierCmp = a.tier.compareTo(b.tier);
105+
return tierCmp != 0 ? tierCmp : a.name.compareTo(b.name);
106+
});
107+
return packages;
108+
}
109+
110+
/// Gets packages by tier
111+
List<PackageConfig> getPackagesByTier(int tier) =>
112+
_packageConfigs.values.where((p) => p.tier == tier && p.publish).toList();
113+
114+
/// Gets packages by test platform
115+
List<PackageConfig> getPackagesByTestPlatform(TestPlatform platform) =>
116+
_packageConfigs.values.where((p) => p.testPlatform == platform).toList();
117+
118+
/// Reads internal dependencies from a package's pubspec.yaml
119+
/// Returns list of dependency names that are publishable internal packages
120+
List<String> getInternalDependencies(String repoRoot, String packageName) {
121+
final pubspecFile = File('$repoRoot/packages/$packageName/pubspec.yaml');
122+
if (!pubspecFile.existsSync()) return [];
123+
124+
final content = pubspecFile.readAsStringSync();
125+
final publishablePackages = getPublishablePackages()
126+
.map((p) => p.name)
127+
.toList();
128+
129+
return publishablePackages
130+
.where((pkg) => pkg != packageName && content.contains('$pkg:'))
131+
.toList();
132+
}
133+
134+
/// Validates that all discovered packages have configs
135+
/// Returns list of packages without configs
136+
List<String> validatePackageConfigs(String repoRoot) {
137+
final discovered = discoverPackages(repoRoot);
138+
return discovered.where((p) => !_packageConfigs.containsKey(p)).toList();
139+
}

tools/prepare_publish.dart

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
11
// ignore_for_file: avoid_print
22
import 'dart:io';
33

4-
/// Package dependency graph - order matters for publishing
5-
/// Packages with no dependencies must be published first
6-
const packageDeps = <String, List<String>>{
7-
// Tier 1 - no internal dependencies
8-
'dart_logging': [],
9-
'dart_node_core': [],
10-
'dart_jsx': [],
11-
// Tier 2 - depends on tier 1
12-
'reflux': ['dart_logging'],
13-
'dart_node_express': ['dart_node_core'],
14-
'dart_node_ws': ['dart_node_core'],
15-
'dart_node_better_sqlite3': ['dart_node_core'],
16-
'dart_node_mcp': ['dart_node_core'],
17-
// Tier 3 - depends on tier 2
18-
'dart_node_react': ['dart_node_core'],
19-
'dart_node_react_native': ['dart_node_core', 'dart_node_react'],
20-
};
21-
22-
/// Publishing order based on dependency graph (topological sort)
23-
const publishOrder = [
24-
// Tier 1
25-
'dart_logging',
26-
'dart_node_core',
27-
'dart_jsx',
28-
// Tier 2
29-
'reflux',
30-
'dart_node_express',
31-
'dart_node_ws',
32-
'dart_node_better_sqlite3',
33-
'dart_node_mcp',
34-
// Tier 3
35-
'dart_node_react',
36-
'dart_node_react_native',
37-
];
4+
import 'lib/packages.dart';
385

396
void main(List<String> args) {
407
if (args.isEmpty) {
@@ -56,20 +23,32 @@ void main(List<String> args) {
5623
}
5724

5825
final scriptDir = File(Platform.script.toFilePath()).parent;
59-
final repoRoot = scriptDir.parent;
60-
final packagesDir = Directory('${repoRoot.path}/packages');
26+
final repoRoot = scriptDir.parent.path;
27+
final packagesDir = Directory('$repoRoot/packages');
28+
29+
// Validate all packages have configs
30+
final unconfigured = validatePackageConfigs(repoRoot);
31+
if (unconfigured.isNotEmpty) {
32+
print('Warning: Packages without config (will be skipped):');
33+
for (final pkg in unconfigured) {
34+
print(' - $pkg');
35+
}
36+
print('Add them to tools/lib/packages.dart if they should be published.\n');
37+
}
6138

6239
print('Preparing packages for publishing version $version\n');
6340

64-
for (final packageName in publishOrder) {
65-
_preparePackage(packagesDir, packageName, version);
41+
final packages = getPublishablePackages();
42+
for (final pkg in packages) {
43+
_preparePackage(repoRoot, packagesDir, pkg.name, version);
6644
}
6745

6846
print('\nAll packages prepared for publishing!');
69-
print('Publishing order: ${publishOrder.join(' -> ')}');
47+
print('Publishing order: ${packages.map((p) => p.name).join(' -> ')}');
7048
}
7149

7250
void _preparePackage(
51+
String repoRoot,
7352
Directory packagesDir,
7453
String packageName,
7554
String version,
@@ -98,7 +77,7 @@ void _preparePackage(
9877
}
9978

10079
// 3. Update interdependencies to pub.dev versions
101-
final deps = packageDeps[packageName] ?? [];
80+
final deps = getInternalDependencies(repoRoot, packageName);
10281
for (final dep in deps) {
10382
content = _switchToPubDevDependency(content, dep, version);
10483
changes.add('$dep -> $version');

0 commit comments

Comments
 (0)