Skip to content

Scaffold a new service's package, and treat resourcemanager as global - #7

Merged
mrcrgl merged 2 commits into
mainfrom
scaffold-new-packages
Nov 2, 2026
Merged

mrcrgl merged 2 commits into
mainfrom
scaffold-new-packages

Conversation

@mrcrgl

@mrcrgl mrcrgl commented Nov 2, 2026

Copy link
Copy Markdown
Member

Right now, a regeneration that brings a new service fails CI by design: someone has to add packages/<service> by hand first. Two changes here:

  1. That package is now scaffolded, so the regeneration comes out complete and green.
  2. The global-service list is corrected; without that, a scaffolded resource manager package would generate wrongly.

What changed

  • generator/src/scaffold.ts, which scripts/generate.sh --write runs. For each service that has no package yet, it writes:

    • packages/<service> with package.json, tsconfig.json, README.md, LICENSE and test/client.test.ts, laid out like packages/location;
    • the package added to the root package.json workspaces, the tsconfig.json and tsconfig.test.json references, and README.md's table.

    generate.sh then runs npm install to link the packages and add them to package-lock.json. It runs it twice, because npm leaves a new workspace's name out of the lock file until the next install.

    • The description comes from the API's definitions, using the first of these that exists:
      1. the first sentence of the package's comment;
      2. the first sentence of the comment of the package's only service;
      3. the resources the package serves, leaving out those inside another resource, spelled as the comments' prose spells them ("ACLs", "DNS policies", "VPCs").
    • The client test calls the first method that gets a resource by its name, using a fake fetch, and checks the URL and the answer.
    • Without --write, the check still fails on a service that has no package.
  • Global services. The generator and @origincloud/core treated iam, admin and location as global. The API design names iam, resourcemanager and location, so a resource manager client with a region would have called a regional host that doesn't exist. The list now matches the API design, and core's endpoint test covers all three.

  • npm test also runs the generator's tests (generator/dist). CONTRIBUTING.md and the regeneration PR's body describe the scaffolding.

  • A new service's regeneration still waits for review, because its package's first version is published by hand (RELEASING.md).

The published packages don't change, and neither does their version.

Tested against the four new APIs

I generated from a local copy of the API with origincloud.compute.v1beta1, origincloud.network.v1beta1, origincloud.iam.v1beta1 and origincloud.resourcemanager.v1beta1 added. scripts/generate.sh --write scaffolded four packages:

Package Description
@origincloud/compute Origin Cloud's compute service: instance types, image families, images, instances, key pairs and public images.
@origincloud/iam Origin Cloud's IAM service: audit log entries, permissions, roles, role bindings, service accounts and users.
@origincloud/network Origin Cloud's network service: ACLs, DNS policies, floating IPs, internet gateways, NAT gateways, network interfaces, route tables, security groups, subnets and VPCs.
@origincloud/resourcemanager Origin Cloud's resourcemanager service: organizations and projects.

After a fresh npm ci, every CI step passes on that tree:

  • scripts/generate.sh
  • npm run build
  • the package checks (LICENSE, README, types)
  • npm test: 59 tests, the four new client tests among them

The generated clients pass regional: false for iam, resourcemanager and location.

A regeneration that brought a new service failed CI until someone added
its package by hand. scripts/generate.sh --write now scaffolds it
(generator/src/scaffold.ts): packages/<service> with package.json,
tsconfig.json, README.md, LICENSE and a test of its client, as
packages/location has them, its place in the workspaces, the references,
README.md's table and package-lock.json. Its description says what the
API's definitions do: the first sentence of the package's comment, or
else of its one service's comment, or else the resources it serves but
those within another of them, spelled as its comments spell them.

The services without a regional host were iam, admin and location, in
the generator and in core. The API's global services are iam,
resourcemanager and location: a resourcemanager client with a region
would have called a regional host that doesn't exist.
@mrcrgl
mrcrgl merged commit ca47b4d into main Nov 2, 2026
4 checks passed
@mrcrgl
mrcrgl deleted the scaffold-new-packages branch November 2, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant