fix: generate SDK packages against sdk facade

This commit is contained in:
Ubuntu 2026-06-08 00:45:46 +00:00
parent 25d8a62140
commit 116b30454a
3 changed files with 15 additions and 12 deletions

View File

@ -21,7 +21,7 @@ test('init, add actor, and configure write package-local SDK state', async () =>
const manifest = JSON.parse(await readFile(join(root, 'matrix.json'), 'utf8')); const manifest = JSON.parse(await readFile(join(root, 'matrix.json'), 'utf8'));
const packageJson = JSON.parse(await readFile(join(root, 'package.json'), 'utf8')); const packageJson = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
assert.equal(packageJson.private, undefined); assert.equal(packageJson.private, undefined);
assert.equal(packageJson.dependencies['@open-matrix/core'], '^0.1.0'); assert.equal(packageJson.dependencies['@open-matrix/sdk'], '^0.1.0');
assert.equal(manifest.name, 'demo-package'); assert.equal(manifest.name, 'demo-package');
assert.equal(manifest.runtime.entry, './dist/index.js'); assert.equal(manifest.runtime.entry, './dist/index.js');
assert.deepEqual(manifest.runtime.factory, { assert.deepEqual(manifest.runtime.factory, {
@ -44,7 +44,7 @@ test('init, add actor, and configure write package-local SDK state', async () =>
}]); }]);
const actorSource = await readFile(join(root, 'src', 'GreeterActor.ts'), 'utf8'); const actorSource = await readFile(join(root, 'src', 'GreeterActor.ts'), 'utf8');
assert.match(actorSource, /from '@open-matrix\/core'/); assert.match(actorSource, /from '@open-matrix\/sdk'/);
const factorySource = await readFile(join(root, 'src', 'create-standalone-GreeterActor.ts'), 'utf8'); const factorySource = await readFile(join(root, 'src', 'create-standalone-GreeterActor.ts'), 'utf8');
assert.match(factorySource, /createStandaloneGreeterActor/); assert.match(factorySource, /createStandaloneGreeterActor/);
assert.match(factorySource, /runtime\.createSupervised\(GreeterActor, mount\)/); assert.match(factorySource, /runtime\.createSupervised\(GreeterActor, mount\)/);

View File

@ -153,7 +153,7 @@ async function initCommand(options: CommandOptions, positional: string[]): Promi
build: 'tsc -p tsconfig.json', build: 'tsc -p tsconfig.json',
}, },
dependencies: { dependencies: {
'@open-matrix/core': '^0.1.0', '@open-matrix/sdk': '^0.1.0',
}, },
devDependencies: { devDependencies: {
typescript: '^5.7.0', typescript: '^5.7.0',
@ -223,7 +223,7 @@ function runtimeIdToken(value: string): string {
function actorFactoryTemplate(className: string, mount: string): string { function actorFactoryTemplate(className: string, mount: string): string {
const factoryName = `createStandalone${className}`; const factoryName = `createStandalone${className}`;
return `import { InMemoryBroker, InMemoryTransport, MatrixRuntime } from '@open-matrix/core'; return `import { InMemoryBroker, InMemoryTransport, MatrixRuntime } from '@open-matrix/sdk';
import { ${className} } from './${className}.js'; import { ${className} } from './${className}.js';
@ -286,7 +286,7 @@ async function addActorCommand(options: CommandOptions, name: string): Promise<v
readMatrixManifest(root); readMatrixManifest(root);
ensureDir(join(root, 'src')); ensureDir(join(root, 'src'));
writeIfMissing(sourcePath, `import { MatrixActor } from '@open-matrix/core'; writeIfMissing(sourcePath, `import { MatrixActor } from '@open-matrix/sdk';
export class ${className} extends MatrixActor { export class ${className} extends MatrixActor {
static accepts = { static accepts = {

View File

@ -267,6 +267,9 @@ async function main() {
'@open-matrix/federation', '@open-matrix/federation',
'@open-matrix/omega-core', '@open-matrix/omega-core',
'@open-matrix/core', '@open-matrix/core',
'@open-matrix/browser-host',
'@open-matrix/browser-kit',
'@open-matrix/sdk',
].map((packageName) => [packageName, tarballDependencies[packageName]]) ].map((packageName) => [packageName, tarballDependencies[packageName]])
); );
@ -288,7 +291,7 @@ async function main() {
const authorPackagePath = path.join(authorDir, 'package.json'); const authorPackagePath = path.join(authorDir, 'package.json');
const authorPackage = JSON.parse(await readFile(authorPackagePath, 'utf8')); const authorPackage = JSON.parse(await readFile(authorPackagePath, 'utf8'));
authorPackage.dependencies['@open-matrix/core'] = tarballDependencies['@open-matrix/core']; authorPackage.dependencies['@open-matrix/sdk'] = tarballDependencies['@open-matrix/sdk'];
authorPackage.pnpm = { overrides: authorOverrides }; authorPackage.pnpm = { overrides: authorOverrides };
await writeFile(authorPackagePath, `${JSON.stringify(authorPackage, null, 2)}\n`); await writeFile(authorPackagePath, `${JSON.stringify(authorPackage, null, 2)}\n`);
@ -361,8 +364,8 @@ async function main() {
]; ];
const foundForbidden = forbidden.find((needle) => combinedAuthorFiles.includes(needle)); const foundForbidden = forbidden.find((needle) => combinedAuthorFiles.includes(needle));
if (foundForbidden) throw new Error(`Fresh author package contains forbidden dependency/path: ${foundForbidden}`); if (foundForbidden) throw new Error(`Fresh author package contains forbidden dependency/path: ${foundForbidden}`);
if (!actorSource.includes("from '@open-matrix/core'")) { if (!actorSource.includes("from '@open-matrix/sdk'")) {
throw new Error('Fresh actor source does not import @open-matrix/core'); throw new Error('Fresh actor source does not import @open-matrix/sdk');
} }
if (!existsSync(path.join(authorDir, '.matrix', 'run.json'))) { if (!existsSync(path.join(authorDir, '.matrix', 'run.json'))) {
throw new Error('matrix run did not write package-local .matrix/run.json'); throw new Error('matrix run did not write package-local .matrix/run.json');
@ -443,8 +446,8 @@ async function main() {
throw new Error('Generated author package is still private after package-manager install'); throw new Error('Generated author package is still private after package-manager install');
} }
const installedActorSource = await readFile(path.join(installedPackageDir, 'src', 'GreeterActor.ts'), 'utf8'); const installedActorSource = await readFile(path.join(installedPackageDir, 'src', 'GreeterActor.ts'), 'utf8');
if (!installedActorSource.includes("from '@open-matrix/core'")) { if (!installedActorSource.includes("from '@open-matrix/sdk'")) {
throw new Error('Package-manager installed source does not keep @open-matrix/core import'); throw new Error('Package-manager installed source does not keep @open-matrix/sdk import');
} }
packageRunner = spawn('pnpm', [ packageRunner = spawn('pnpm', [
'exec', 'matrix', 'run', 'exec', 'matrix', 'run',
@ -482,8 +485,8 @@ async function main() {
authorDir, authorDir,
cliInstalledSeparately: true, cliInstalledSeparately: true,
authorPackageDependsOnCli: false, authorPackageDependsOnCli: false,
legacyMonorepoPathReferences: false, monorepoPathReferences: false,
actorImport: '@open-matrix/core', actorImport: '@open-matrix/sdk',
configuredKeyStored: existsSync(path.join(authorDir, '.matrix', 'credentials', 'matrix-api-key.json')), configuredKeyStored: existsSync(path.join(authorDir, '.matrix', 'credentials', 'matrix-api-key.json')),
validKeyConfigSupplied: Boolean(liveKeyConfig), validKeyConfigSupplied: Boolean(liveKeyConfig),
liveKeyValidation, liveKeyValidation,