Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ linkStyle default opacity:0.5
social_controllers --> messenger;
social_controllers --> profile_sync_controller;
solana_test_validator_up --> local_node_utils;
stellar_quickstart_up --> local_node_utils;
storage_service --> messenger;
subscription_controller --> base_controller;
subscription_controller --> controller_utils;
Expand Down
4 changes: 4 additions & 0 deletions packages/stellar-quickstart-up/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add the `@metamask/stellar-quickstart-up` package ([#9282](https://github.com/MetaMask/core/pull/9282)).

[Unreleased]: https://github.com/MetaMask/core/
129 changes: 122 additions & 7 deletions packages/stellar-quickstart-up/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,130 @@
# `@metamask/stellar-quickstart-up`

Stellar Quickstart runtime installer for MetaMask E2E tests
`stellar-quickstart-up` installs a pinned [Stellar Quickstart](https://github.com/stellar/quickstart)
Docker image for local development and CI. It follows the same runtime-only shape as
`@metamask/foundryup`: this package pulls the image into the local Docker daemon,
stores image metadata in the MetaMask cache, and exposes a `stellar-quickstart`
wrapper in `node_modules/.bin`; the consuming test harness owns container
lifecycle, readiness checks, and seeding.

## Installation
This package requires Docker to be installed and available on `PATH`. It does not
start or seed a Stellar node itself.

`yarn add @metamask/stellar-quickstart-up`
## Usage

or
Install the package in the consuming repo:

`npm install @metamask/stellar-quickstart-up`
```bash
yarn add @metamask/stellar-quickstart-up
npm install @metamask/stellar-quickstart-up
```

## Contributing
For Yarn v4 projects, it is usually simplest to add package scripts in the
consuming repo:

This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
```json
{
"scripts": {
"stellar-quickstart-up": "node_modules/.bin/stellar-quickstart-up",
"stellar-quickstart": "node_modules/.bin/stellar-quickstart"
}
}
```

Pull the pinned Stellar Quickstart image and install the wrapper:

```bash
yarn stellar-quickstart-up install
```

Run the installed Stellar Quickstart wrapper:

```bash
node_modules/.bin/stellar-quickstart --local
```

For MetaMask Extension E2E tests, the Stellar seeder should spawn
`node_modules/.bin/stellar-quickstart`, pass the desired network mode such as
`--local`, poll Horizon or RPC readiness, and perform wallet/funding seeding
itself.

## Installed Artifacts

`stellar-quickstart-up` installs:

- a digest-pinned `stellar/quickstart` Docker image in the local Docker daemon
- cached image metadata under the MetaMask cache
- a `node_modules/.bin/stellar-quickstart` wrapper that runs:

```bash
docker run --rm -i -p 8000:8000 stellar/quickstart:latest "$@"
```

## CLI

```bash
stellar-quickstart-up [install] [options]
stellar-quickstart-up cache clean [options]
```

Options:

- `--bin-directory <path>`: directory for generated wrappers. Defaults to
`node_modules/.bin`.
- `--cache-directory <path>`: artifact cache directory. Defaults to
`.metamask/cache`.
- `--docker-binary <path>`: Docker CLI binary. Defaults to `docker` on `PATH`.
- `--image-reference <reference>` and `--image-digest <digest>`: override the
pinned Stellar Quickstart image.
- `--help`: show help text.

## Default Image

The package currently pins `stellar/quickstart:latest` with digest
`sha256:8ddf3ed87a5c07eab5202b0fd95f06fb5db3f48cacd7e69fdc0e22925f181168`.

The installer verifies the digest against the image `RepoDigests` reported by
`docker image inspect` after `docker pull`.

The installed wrapper defaults to `docker run --rm -i -p 8000:8000` and forwards
extra arguments to the container entrypoint, for example `--local`, `--testnet`,
or `--pubnet`.

With the default port mapping, the Quickstart services are available at:

- Horizon: `http://localhost:8000/`
- RPC: `http://localhost:8000/rpc`
- Friendbot: `http://localhost:8000/friendbot`

## Cache

The cache defaults to `.metamask/cache` in the current repo. `enableGlobalCache`
is read by parsing `.yarnrc.yml` as YAML; when it is `true`, the cache moves to
`~/.cache/metamask`, matching the `@metamask/foundryup` behavior.

Clean only this package's cache namespace:

```bash
yarn stellar-quickstart-up cache clean
```

## Package Config

The consuming repo can override the pinned image reference, digest, and wrapper
`docker run` arguments in its root `package.json`:

```json
{
"stellarQuickstartUp": {
"image": {
"version": "latest",
"reference": "stellar/quickstart:latest",
"digest": "sha256:8ddf3ed87a5c07eab5202b0fd95f06fb5db3f48cacd7e69fdc0e22925f181168"
},
"runArgs": ["run", "--rm", "-i", "-p", "8000:8000"]
}
}
```

Supported package config keys are `stellarQuickstartUp`, `stellarquickstartup`,
and `stellar-quickstart-up`.
14 changes: 10 additions & 4 deletions packages/stellar-quickstart-up/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// The CLI entrypoint is exercised through package builds and installed-bin smoke tests.
coveragePathIgnorePatterns: [
...baseConfig.coveragePathIgnorePatterns,
'./src/bin/stellar-quickstart-up.ts',
],

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
branches: 35,
functions: 60,
lines: 65,
statements: 65,
},
},
});
4 changes: 4 additions & 0 deletions packages/stellar-quickstart-up/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"type": "git",
"url": "https://github.com/MetaMask/core.git"
},
"bin": "./dist/bin/stellar-quickstart-up.mjs",
"files": [
"dist/"
],
Expand Down Expand Up @@ -52,6 +53,9 @@
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/local-node-utils": "^0.0.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^6.1.0",
"@ts-bridge/cli": "^0.6.4",
Expand Down
64 changes: 64 additions & 0 deletions packages/stellar-quickstart-up/src/bin/stellar-quickstart-up.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env node
/* eslint-disable no-restricted-globals */
import {
cleanStellarQuickstartCache,
installStellarQuickstart,
parseStellarQuickstartInstallCliOptions,
readStellarQuickstartInstallOptionsFromPackageJson,
} from '../install';

async function main(): Promise<void> {
const [command, ...args] = process.argv.slice(2);

if (command === '--help' || command === 'help') {
printHelp();
return;
}

if (command === 'cache' && args[0] === 'clean') {
await cleanStellarQuickstartCache({
...readStellarQuickstartInstallOptionsFromPackageJson(),
...parseStellarQuickstartInstallCliOptions(args.slice(1)),
});
console.log('[stellar-quickstart-up] cache cleaned');
return;
}

const installArgs = command === 'install' ? args : process.argv.slice(2);
const result = await installStellarQuickstart({
...readStellarQuickstartInstallOptionsFromPackageJson(),
...parseStellarQuickstartInstallCliOptions(installArgs),
});
Comment thread
cursor[bot] marked this conversation as resolved.

console.log(
`[stellar-quickstart-up] Stellar Quickstart image ${
result.cacheHit ? 'found in cache' : 'installed'
}`,
);
console.log(
`[stellar-quickstart-up] stellar-quickstart installed at ${result.binaryPath}`,
);
}

main().catch((error) => {
console.error(error);
process.exit(1);
});

function printHelp(): void {
console.log(`Usage: stellar-quickstart-up [install] [options]
stellar-quickstart-up cache clean [options]

Commands:
install Pull the Stellar Quickstart image and install wrappers. Default command.
cache clean Remove cached stellar-quickstart-up artifacts.

Options:
--bin-directory <path> Directory for executable wrappers.
Defaults to node_modules/.bin.
--cache-directory <path> Cache directory. Defaults to .metamask/cache.
--docker-binary <path> Docker CLI binary. Defaults to docker.
--image-reference <reference> Docker image reference override.
--image-digest <digest> Expected Docker image digest.
--help Show this help text.`);
}
9 changes: 0 additions & 9 deletions packages/stellar-quickstart-up/src/index.test.ts

This file was deleted.

24 changes: 15 additions & 9 deletions packages/stellar-quickstart-up/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/**
* Example function that returns a greeting for the given name.
*
* @param name - The name to greet.
* @returns The greeting.
*/
export default function greeter(name: string): string {
return `Hello, ${name}!`;
}
export {
STELLAR_QUICKSTART_DEFAULT_IMAGE,
STELLAR_QUICKSTART_DEFAULT_RUN_ARGS,
cleanStellarQuickstartCache,
getStellarQuickstartCacheDirectory,
installStellarQuickstart,
parseStellarQuickstartInstallCliOptions,
readStellarQuickstartInstallOptionsFromPackageJson,
} from './install';
export type {
StellarQuickstartImageConfig,
StellarQuickstartInstallDependencies,
StellarQuickstartInstallOptions,
StellarQuickstartInstallResult,
} from './install';
Loading
Loading