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
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 initial `stellar-quickstart-up` runtime installer that pulls a pinned `stellar/quickstart` Docker image, caches image metadata, and installs a `stellar-quickstart` wrapper in `node_modules/.bin` ([#9282](https://github.com/MetaMask/core/pull/9282))

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

Stellar Quickstart runtime installer for MetaMask E2E tests
`stellar-quickstart-up` installs a pinned `stellar/quickstart` Docker image for local
development and CI. It follows the same runtime-only shape as
`@metamask/foundryup`: this package pulls the external runtime image into the
MetaMask cache and exposes a `stellar-quickstart` binary 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/RPC readiness, and perform wallet/funding seeding itself.

## Installed Artifacts

`stellar-quickstart-up` installs:

- a pinned `stellar/quickstart` Docker image reference in the MetaMask cache
- a `node_modules/.bin/stellar-quickstart` wrapper that forwards to `docker run`

## 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`.
- `--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 installed wrapper defaults to `docker run --rm -i -p 8000:8000`.

## 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 and digest 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,
},
},
});
6 changes: 5 additions & 1 deletion packages/stellar-quickstart-up/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/stellar-quickstart-up",
"version": "0.0.0",
"version": "0.1.0",
"description": "Stellar Quickstart runtime installer for MetaMask E2E tests",
"keywords": [
"Ethereum",
Expand All @@ -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),
});

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