-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Chore: Upgrade Node.js, improve publishing scripts, and fix Angular tests #1177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2550458
080ca44
aa7725c
f93d49e
44fd313
4ca1173
337eb1c
c5e6319
7dd6321
9441595
8fe9fa6
9628421
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,8 +16,8 @@ | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { readFileSync, writeFileSync, copyFileSync, existsSync, mkdirSync } from 'node:fs'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { join, resolve } from 'node:path'; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { fileURLToPath } from 'node:url'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { getPackageGraph } from './lib/workspace.mjs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // This script prepares a package for publishing. | ||||||||||||||||||||||||||||||||||||||||||||
| // Arguments: | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,19 +46,22 @@ if (!existsSync(resolvedDistDir)) { | |||||||||||||||||||||||||||||||||||||||||||
| mkdirSync(resolvedDistDir, { recursive: true }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 1. Get current @a2ui/web_core version | ||||||||||||||||||||||||||||||||||||||||||||
| const corePkgPath = join(rootDir, 'renderers/web_core/package.json'); | ||||||||||||||||||||||||||||||||||||||||||||
| const coreVersion = JSON.parse(readFileSync(corePkgPath, 'utf8')).version; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const graph = getPackageGraph(); | ||||||||||||||||||||||||||||||||||||||||||||
| const pkg = JSON.parse(readFileSync(resolvedSourcePkg, 'utf8')); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 2. Update @a2ui/web_core dependency | ||||||||||||||||||||||||||||||||||||||||||||
| if (pkg.dependencies && pkg.dependencies['@a2ui/web_core']) { | ||||||||||||||||||||||||||||||||||||||||||||
| pkg.dependencies['@a2ui/web_core'] = '^' + coreVersion; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| if (pkg.peerDependencies && pkg.peerDependencies['@a2ui/web_core']) { | ||||||||||||||||||||||||||||||||||||||||||||
| pkg.peerDependencies['@a2ui/web_core'] = '^' + coreVersion; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| // 2. Update internal @a2ui dependencies | ||||||||||||||||||||||||||||||||||||||||||||
| const updateInternalDeps = (deps) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (!deps) return; | ||||||||||||||||||||||||||||||||||||||||||||
| for (const name in deps) { | ||||||||||||||||||||||||||||||||||||||||||||
| const version = deps[name]; | ||||||||||||||||||||||||||||||||||||||||||||
| if (version.startsWith('file:') && graph[name]) { | ||||||||||||||||||||||||||||||||||||||||||||
| deps[name] = '^' + graph[name].version; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactoring
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| updateInternalDeps(pkg.dependencies); | ||||||||||||||||||||||||||||||||||||||||||||
| updateInternalDeps(pkg.peerDependencies); | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script should also update internal dependencies in
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 3. Adjust paths | ||||||||||||||||||||||||||||||||||||||||||||
| if (!skipPathAdjustment) { | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ export async function runPublish(args, customRunCommand, customExecSync, customR | |
| let autoYes = false; | ||
| let dryRun = false; | ||
| let skipTests = false; | ||
| let testOnly = false; | ||
|
|
||
| for (const arg of args) { | ||
| if (arg.startsWith('--packages=')) { | ||
|
|
@@ -43,11 +44,13 @@ export async function runPublish(args, customRunCommand, customExecSync, customR | |
| dryRun = true; | ||
| } else if (arg === '--skip-tests') { | ||
| skipTests = true; | ||
| } else if (arg === '--test-only') { | ||
| testOnly = true; | ||
| } | ||
| } | ||
|
|
||
| if (packagesToPublish.length === 0) { | ||
| throw new Error('Usage: publish_npm --packages=pkg1,pkg2 [--force] [--yes] [--dry-run] [--skip-tests]'); | ||
| throw new Error('Usage: publish_npm --packages=pkg1,pkg2 [--force] [--yes] [--dry-run] [--skip-tests] [--test-only]'); | ||
| } | ||
|
|
||
| const graph = getPackageGraph(); | ||
|
|
@@ -62,16 +65,23 @@ export async function runPublish(args, customRunCommand, customExecSync, customR | |
| return pkg.name; | ||
| }); | ||
|
|
||
| // Validation: web_core check | ||
| // Validation: core dependencies check | ||
| const webCoreName = '@a2ui/web_core'; | ||
| const markdownItName = '@a2ui/markdown-it'; | ||
| const renderers = ['@a2ui/lit', '@a2ui/angular', '@a2ui/react']; | ||
| const requestedRenderers = resolvedPackages.filter(p => renderers.includes(p)); | ||
|
Comment on lines
71
to
72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of hardcoding the list of renderers, you can dynamically identify packages that depend on core libraries (like const corePackages = [webCoreName, markdownItName];
const requestedRenderers = resolvedPackages.filter(name => {
const pkg = graph[name];
return pkg && pkg.internalDependencies.some(dep => corePackages.includes(dep));
}); |
||
|
|
||
| if (requestedRenderers.length > 0 && !resolvedPackages.includes(webCoreName) && !force) { | ||
| console.warn('WARNING: You are publishing renderers but NOT @a2ui/web_core.'); | ||
| console.warn('This can lead to broken versions if web_core has changed.'); | ||
| console.warn('Use --force to override this check.'); | ||
| throw new Error('Safety check failed: web_core missing from publish list.'); | ||
| if (requestedRenderers.length > 0 && !force) { | ||
| const missingCores = []; | ||
| if (!resolvedPackages.includes(webCoreName)) missingCores.push(webCoreName); | ||
| if (!resolvedPackages.includes(markdownItName)) missingCores.push(markdownItName); | ||
|
|
||
| if (missingCores.length > 0) { | ||
| console.warn(`WARNING: You are publishing renderers but NOT ${missingCores.join(' and ')}.`); | ||
| console.warn('This can lead to broken versions if shared dependencies have changed.'); | ||
| console.warn('Use --force to override this check.'); | ||
| throw new Error(`Safety check failed: ${missingCores.join(' and ')} missing from publish list.`); | ||
| } | ||
| } | ||
|
|
||
| // Topological Sort | ||
|
|
@@ -229,6 +239,11 @@ export async function runPublish(args, customRunCommand, customExecSync, customR | |
| } | ||
| } | ||
|
|
||
| if (testOnly) { | ||
| console.log('\n[TEST ONLY] Build and tests completed successfully. Skipping publish phase.'); | ||
| return; | ||
| } | ||
|
|
||
| console.log('\n--- Proceeding to publish ---'); | ||
|
|
||
| for (const pkgName of sortedPackages) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are relying on trusted people to execute this, and allowing to publish potentially skipping a PR review. Until we have CD set up I think this is fine.
A nice to have to prevent human error: to early exit this script if there are any uncommitted changes in the current workspace.