Skip to content

Commit

Permalink
Minimize available commands to work on the seed.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Oct 8, 2024
1 parent c6c765b commit bdc8214
Show file tree
Hide file tree
Showing 16 changed files with 428 additions and 617 deletions.
5 changes: 3 additions & 2 deletions src/scripts/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ function getLintDiffCommands(options: Options): Record<string, any> {
'*': 'prettier --ignore-unknown' + (options.fix ? ' --write' : ' --check'),
'*.{ts,js,tsx,jsx}':
'eslint --config src/.eslintrc.js' + (options.fix ? ' --fix' : ''),
'studies/**/*.json':
'npm run seed_tools -- check_study' + (options.fix ? ' --fix' : ''),
'studies/*': () =>
'npm run seed_tools -- create_seed --validate_only' +
(options.fix ? ' --fix' : ''),
};
}

Expand Down
75 changes: 5 additions & 70 deletions src/seed_tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,23 @@

## Tools

### `check_study`

Validates study files for both logic and format errors. Called automatically
during `lint` for `studies/**/*.json` files.

##### Syntax

```bash
npm run seed_tools -- check_study <study_files...> [--fix]
```

##### Arguments

- `<study_files...>`: One or more study files that you want to check.

##### Options

- `--fix`: Fix format errors in-place.

### `create_seed`

Generates a `seed.bin` file from study files.

##### Syntax

```bash
npm run seed_tools -- create_seed <studies_dir> <output_file> [--mock_serial_number <value>] [--serial_number_path <path>]
```

##### Arguments

- `<studies_dir>`: The directory containing the study files.
- `<output_file>`: The output file for the generated seed.

##### Options

- `--mock_serial_number <value>`: Mock a serial number. If not provided, a
random number is used.
- `--serial_number_path <path>`: The file path to write the serial number to.

### `compare_seeds`

Compares two seed binary files and displays a human-readable diff. Used for safe
migration from the python seed generator to the typescript seed generator.

##### Syntax

```bash
npm run seed_tools -- compare_seeds <seed1_file> <seed2_file>
```

##### Arguments
### `create_seed`

- `<seed1_file>`: The first seed binary file to compare.
- `<seed2_file>`: The second seed binary file to compare.
Generates a `seed.bin` file from study files.

### `split_seed_json`

Splits a legacy `seed.json` file into individual study files.

##### Syntax
## Tools help

```bash
npm run seed_tools -- split_seed_json <seed_json_path> <output_dir>
```

##### Arguments

- `<seed_json_path>`: The path to the `seed.json` file to be split.
- `<output_dir>`: The directory where the individual study files will be
outputted.

### `validate_seed`

Validates a seed protobuf.

##### Syntax
Run to get available arguments and options:

```bash
npm run seed_tools -- validate_seed <seed_file>
npm run seed_tools -- <tool> --help
```

##### Arguments

- `<seed_file>`: The path to the binary-serialized `seed` protobuf.
132 changes: 0 additions & 132 deletions src/seed_tools/commands/check_study.test.ts

This file was deleted.

89 changes: 0 additions & 89 deletions src/seed_tools/commands/check_study.ts

This file was deleted.

Loading

0 comments on commit bdc8214

Please sign in to comment.