Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
node_modules
.env
.env
.local-optic-core
17 changes: 17 additions & 0 deletions debugsourceme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# usage: $ source ./debugsourceme.sh
export OPTIC_SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

debug_to_capture() {
(
set -o errexit
node "$OPTIC_SRC_DIR/workspaces/cli-shared/build/captures/avro/file-system/dump-capture-saver.js" $1 .
)
}

clear_events() {
(
set -o errexit
node "$OPTIC_SRC_DIR/support/remove-all-events.js" $1 .
)
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"publish-github": "OPTIC_PUBLISH_SCOPE=github node ./workspaces/scripts/publish.js",
"publish": "OPTIC_PUBLISH_SCOPE=public node ./workspaces/scripts/publish.js",
"bump": "node ./workspaces/scripts/bump.js",
"bump-core": "node ./workspaces/scripts/bump-core.js"
"bump-core": "node ./workspaces/scripts/bump-core.js",
"bump-core-snapshot": "node ./workspaces/scripts/bump-core-local.js"
},
"workspaces": [
"workspaces/saas-types",
Expand Down
16 changes: 15 additions & 1 deletion sourceme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@ optic_build_with_linked_core() {
set -o errexit
cd "$OPTIC_SRC_DIR"
optic_workspace_clean
yarn workspaces run ws:linkDomain
yarn run bump-core-snapshot
yarn install
optic_workspace_build
)
}
bump_domain() {
if [[ -z "$1" ]]; then
echo "No version provided"
exit 1
fi
(
set -o errexit
cd "$OPTIC_SRC_DIR"
optic_workspace_clean
yarn run bump-core $1
yarn install
optic_workspace_build
)
Expand Down
13 changes: 13 additions & 0 deletions support/remove-all-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');

const myArgs = process.argv.slice(2);
const debugCaptureFilePath = myArgs[0];

const json = JSON.parse(fs.readFileSync(debugCaptureFilePath, 'utf8'));
console.log(json);
console.log(
`removing ${json.events.length} events from ${debugCaptureFilePath}`
);
json.events = [];
fs.writeFileSync(debugCaptureFilePath, JSON.stringify(json, null, 2));
console.log('saved!');
4 changes: 2 additions & 2 deletions workspaces/cli-scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export function runManagedScript(modulePath: string, ...args: string[]) {

const isDebuggingEnabled =
process.env.OPTIC_DAEMON_ENABLE_DEBUGGING === 'yes';
const execArgv = isDebuggingEnabled ? ['--inspect=63694'] : [];
const child = cp.fork(modulePath, args, { execArgv });
// const execArgv = isDebuggingEnabled ? ['--inspect=63694'] : []; // not in spawn
const child = cp.spawn(modulePath, args, { windowsHide: true });
return child;
}

Expand Down
6 changes: 3 additions & 3 deletions workspaces/cli-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"@useoptic/cli-client": "8.2.6",
"@useoptic/cli-config": "8.2.6",
"@useoptic/client-utilities": "8.2.6",
"@useoptic/domain": "8.3.1",
"@useoptic/domain-types": "8.3.1",
"@useoptic/domain-utilities": "8.3.1",
"@useoptic/domain": "10.0.2",
"@useoptic/domain-types": "10.0.2",
"@useoptic/domain-utilities": "10.0.2",
"avsc": "^5.4.21",
"bottleneck": "^2.19.5",
"colors": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/local-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@useoptic/cli-scripts": "8.2.6",
"@useoptic/cli-server": "8.2.6",
"@useoptic/cli-shared": "8.2.6",
"@useoptic/domain": "8.3.1",
"@useoptic/domain": "10.0.2",
"analytics-node": "^3.4.0-beta.1",
"cli-ux": "^5.4.1",
"colors": "^1.4.0",
Expand Down
72 changes: 72 additions & 0 deletions workspaces/scripts/bump-core-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// this script is meant to be run via `yarn bump <whatever version>`
const path = require('path');
const fs = require('fs-extra');

async function main(localRoot) {
const localOpticCore = fs
.readFileSync(path.join(__dirname, '../../.local-optic-core'))
.toString()
.trim();

if (!localOpticCore) {
throw new Error(
'Add a .local-optic-core file to your root so Optic knows where optic-core lives locally'
);
}

const opticCoreWorkspaceHome = path.resolve(
path.join(localOpticCore, 'workspace', 'packages')
);

const packageJson = await fs.readJson('./package.json');
const { workspaces } = packageJson;
console.log(`setting workspace versions to file:/...`);
console.log(workspaces.map((x) => ` - ${x}\n`).join(''));
const tasks = workspaces.map((workspace) => {
const task = new Promise(async (resolve, reject) => {
try {
const targetPackage = await fs.readJson(`./${workspace}/package.json`);
resolve({
workspace,
package: targetPackage,
});
} catch (e) {
reject(e);
}
});
return task;
});
const results = await Promise.all(tasks);
const packageNames = [
'@useoptic/domain',
'@useoptic/domain-types',
'@useoptic/domain-utilities',
];
console.log(packageNames.map((x) => ` - ${x}\n`).join(''));
const updateVersionTasks = results.map((result) => {
const task = new Promise(async (resolve, reject) => {
try {
packageNames.map((packageName) => {
if (result.package.dependencies[packageName]) {
result.package.dependencies[
packageName
] = `file:${opticCoreWorkspaceHome}/${packageName.split('/')[1]}`;
}
});
await fs.writeJson(
`./${result.workspace}/package.json`,
result.package,
{ spaces: 2 }
);
} catch (e) {
reject(e);
}
});
return task;
});
await Promise.all(updateVersionTasks);
console.log(`Done!`);
}

const [, , targetVersion] = process.argv;
main(targetVersion);
6 changes: 3 additions & 3 deletions workspaces/snapshot-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"directory": "workspaces/snapshot-tests"
},
"dependencies": {
"@useoptic/domain-types": "8.3.1",
"@useoptic/domain": "8.3.1",
"@useoptic/domain-utilities": "8.3.1",
"@useoptic/domain-types": "10.0.2",
"@useoptic/domain": "10.0.2",
"@useoptic/domain-utilities": "10.0.2",
"dataloader": "^2.0.0",
"fs-extra": "^9.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions workspaces/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.46",
"@useoptic/cli-client": "8.2.6",
"@useoptic/domain": "8.3.1",
"@useoptic/domain-utilities": "8.3.1",
"@useoptic/domain": "10.0.2",
"@useoptic/domain-utilities": "10.0.2",
"bottleneck": "^2.19.5",
"camelcase": "^5.2.0",
"classnames": "^2.2.6",
Expand Down
35 changes: 21 additions & 14 deletions workspaces/ui/src/__tests__/examples.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import {Facade, RfcCommandContext} from '@useoptic/domain';
import fs from 'fs'
import { Facade, RfcCommandContext } from '@useoptic/domain-utilities';
import fs from 'fs';

xdescribe('Example loading', function () {
const examples = [
'./public/example-commands/mattermost-commands.json'
]
const examples = ['./public/example-commands/mattermost-commands.json'];

examples.forEach(function (exampleFileName) {
it('should parse the commands', function () {
const rfcId = 'rrr'
const eventStore = Facade.makeEventStore()
const initialCommandsString = fs.readFileSync(exampleFileName)
const commandContext = new RfcCommandContext('userId', 'sessionId', 'batchId')
const service = Facade.fromJsonCommands(eventStore, rfcId, commandContext, initialCommandsString)
});
})
examples.forEach(function (exampleFileName) {
it('should parse the commands', function () {
const rfcId = 'rrr';
const eventStore = Facade.makeEventStore();
const initialCommandsString = fs.readFileSync(exampleFileName);
const commandContext = new RfcCommandContext(
'userId',
'sessionId',
'batchId'
);
const service = Facade.fromJsonCommands(
eventStore,
rfcId,
commandContext,
initialCommandsString
);
});
});
});
23 changes: 16 additions & 7 deletions workspaces/ui/src/components/diff/SimulatedCommandContext.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import React from 'react';
import {InitialRfcCommandsStore} from '../../contexts/InitialRfcCommandsContext';
import {LocalDiffRfcStore} from '../../contexts/RfcContext';
import {commandsToJson} from '@useoptic/domain';
import {withSpecServiceContext} from '../../contexts/SpecServiceContext';
import { InitialRfcCommandsStore } from '../../contexts/InitialRfcCommandsContext';
import { LocalDiffRfcStore } from '../../contexts/RfcContext';
import { commandsToJson } from '@useoptic/domain';
import { withSpecServiceContext } from '../../contexts/SpecServiceContext';
import compose from 'lodash.compose';
import sha1 from 'node-sha1';

class SimulatedCommandContext extends React.Component {
render() {
const {rfcId, eventStore, commands, shouldSimulate, specService} = this.props;
const {
rfcId,
eventStore,
commands,
shouldSimulate,
specService,
} = this.props;
const initialEventStore = eventStore.getCopy(rfcId);
const initialEventsString = eventStore.serializeEvents(rfcId);
const initialCommandsString = shouldSimulate ? JSON.stringify(commandsToJson(commands)) : null;
const initialCommandsString = shouldSimulate
? JSON.stringify(commandsToJson(commands))
: null;
const hash = sha1(`${initialEventsString}+${initialCommandsString}`);
return (
<InitialRfcCommandsStore
instance="the one in simulated command context"
rfcId={rfcId}
initialEventsString={initialEventsString}
initialCommandsString={initialCommandsString}>
initialCommandsString={initialCommandsString}
>
<LocalDiffRfcStore
specService={specService}
initialEventStore={initialEventStore}
Expand Down
Loading