Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
📦 isolate jsonSchemaCommand in a package
Browse files Browse the repository at this point in the history
  • Loading branch information
julietteff committed Jul 29, 2022
1 parent 78e1e9d commit 8a6840e
Show file tree
Hide file tree
Showing 23 changed files with 521 additions and 143 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/realease-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ jobs:
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: ./packages/test-tools/package.json
# - uses: JS-DevTools/npm-publish@v1
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: ./packages/json-schema-command/package.json
8 changes: 6 additions & 2 deletions castore.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@
},
{
"path": "packages/json-schema-event",
"name": "📬 Json Schema"
"name": "📬 Json Schema Event"
},
{
"path": "packages/zod-event",
"name": "📬 Zod"
"name": "📬 Zod Event"
},
{
"path": "packages/json-schema-command",
"name": "👮‍♀️ Json Schema Command"
},
{
"path": "packages/test-tools",
Expand Down
4 changes: 2 additions & 2 deletions demo/blueprint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
},
"dependencies": {
"@babel/runtime": "^7.18.3",
"@castore/core": "^1.0.3",
"@castore/json-schema-command": "^1.0.3",
"@castore/json-schema-event": "^1.0.3",
"uuid": "^8.3.2"
},
Expand All @@ -39,7 +41,6 @@
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@castore/core": "^1.0.3",
"@types/node": "^17.0.29",
"@zerollup/ts-transform-paths": "^1.7.18",
"babel-plugin-module-resolver": "^4.1.0",
Expand Down Expand Up @@ -70,7 +71,6 @@
}
},
"peerDependencies": {
"@castore/core": "^0.7.0",
"json-schema-to-ts": "^2.0.0",
"uuid": "^8.3.2"
}
Expand Down
3 changes: 2 additions & 1 deletion demo/blueprint/src/commands/createUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { v4 as uuid } from 'uuid';

import { JSONSchemaCommand, tuple } from '@castore/core';
import { tuple } from '@castore/core';
import { JSONSchemaCommand } from '@castore/json-schema-command';

import { userEventStore, UserStatus } from '~/users';

Expand Down
3 changes: 2 additions & 1 deletion demo/blueprint/src/commands/deleteUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { JSONSchemaCommand, tuple } from '@castore/core';
import { tuple } from '@castore/core';
import { JSONSchemaCommand } from '@castore/json-schema-command';

import { userEventStore, UserStatus } from '~/users';

Expand Down
120 changes: 0 additions & 120 deletions packages/core/src/command/implementations/jsonSchema.util.test.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export type {
EventStoreAggregate,
} from './eventStore';
export { Command, tuple } from './command/command';
export { JSONSchemaCommand } from './command/implementations/jsonSchema';
export type { OnEventAlreadyExistsCallback } from './command/implementations/jsonSchema';
1 change: 1 addition & 0 deletions packages/json-schema-command/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 2 additions & 0 deletions packages/json-schema-command/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const baseConfig = require('../../.lintstagedrc');
module.exports = baseConfig;
3 changes: 3 additions & 0 deletions packages/json-schema-command/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const commonBabelConfig = require('../../commonConfiguration/babel.config');

module.exports = commonBabelConfig();
3 changes: 3 additions & 0 deletions packages/json-schema-command/dependency-cruiser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/** @type {import('dependency-cruiser').IConfiguration} */
const baseConfig = require('../../dependency-cruiser');
module.exports = baseConfig;
8 changes: 8 additions & 0 deletions packages/json-schema-command/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const commonConfig = require('../../commonConfiguration/jest.config');

const config = {
...commonConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};

module.exports = config;
81 changes: 81 additions & 0 deletions packages/json-schema-command/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "@castore/json-schema-command",
"version": "1.0.3",
"license": "MIT",
"homepage": "https://github.com/theodo/castore#readme",
"bugs": "https://github.com/theodo/castore/issues",
"repository": "theodo/castore.git",
"keywords": [
"event",
"source",
"store",
"typescript"
],
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"files": [
"dist"
],
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"scripts": {
"lint-fix": "yarn linter-base-config --fix",
"lint-fix-all": "yarn lint-fix .",
"linter-base-config": "eslint --ext=js,ts .",
"package": "rm -rf dist && yarn package-cjs && yarn package-esm && yarn package-types",
"package-cjs": "NODE_ENV=cjs yarn transpile --out-dir dist/cjs --source-maps",
"package-esm": "NODE_ENV=esm yarn transpile --out-dir dist/esm --source-maps",
"package-types": "ttsc -p tsconfig.build.json",
"test": "yarn test-linter && yarn test-type && yarn test-circular && yarn test-unit",
"test-circular": "yarn depcruise --validate dependency-cruiser.js .",
"test-linter": "yarn linter-base-config .",
"test-type": "tsc --noEmit --emitDeclarationOnly false",
"test-unit": "yarn jest",
"transpile": "babel src --extensions .ts --quiet",
"watch": "rm -rf dist && concurrently 'yarn:package-* --watch'"
},
"dependencies": {
"ts-toolbelt": "^9.6.0"
},
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.9",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@castore/core": "^1.0.3",
"@types/node": "^17.0.29",
"@zerollup/ts-transform-paths": "^1.7.18",
"babel-plugin-module-resolver": "^4.1.0",
"concurrently": "^7.1.0",
"dependency-cruiser": "^11.7.0",
"eslint": "^8.14.0",
"jest": "^27.5.1",
"json-schema-to-ts": "^2.5.4",
"prettier": "^2.6.2",
"ts-node": "^10.7.0",
"ttypescript": "^1.5.13",
"typescript": "^4.6.3"
},
"maintainers": [
"Thomas Aribart",
"Charles Géry",
"Juliette Fournier",
"Valentin Beggi"
],
"nx": {
"targets": {
"package": {
"outputs": [
"packages/json-schema-command/dist"
]
}
}
},
"peerDependencies": {
"@castore/core": "1.0.3"
}
}
6 changes: 6 additions & 0 deletions packages/json-schema-command/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "packages/json-schema-command",
"projectType": "library",
"tags": [],
"implicitDependencies": ["core"]
}
2 changes: 2 additions & 0 deletions packages/json-schema-command/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { JSONSchemaCommand } from './jsonSchema';
export type { OnEventAlreadyExistsCallback } from './jsonSchema';
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts';

import { EventAlreadyExistsError } from '~/errors/eventAlreadyExists';
import { EventStore } from '~/eventStore';

import { Command } from '../command';
import { Command, EventAlreadyExistsError, EventStore } from '@castore/core';

export type OnEventAlreadyExistsCallback = (
error: EventAlreadyExistsError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Command } from '@castore/core';
import { FromSchema } from 'json-schema-to-ts';
import { A } from 'ts-toolbelt';

import { counterEventStore, userEventStore } from '~/eventStore.util.test';

import { Command } from '../command';
import { JSONSchemaCommand } from './jsonSchema';
import {
counterEventStore,
incrementCounter,
incrementCounterA,
incrementCounterANoOutput,
incrementCounterNoOutput,
inputSchema,
outputSchema,
userEventStore,
} from './jsonSchema.util.test';

type Input = FromSchema<typeof inputSchema>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { EventAlreadyExistsError } from '~/errors/eventAlreadyExists';
import { EventDetail } from '~/event/eventDetail';
import { EventDetail, EventAlreadyExistsError } from '@castore/core';

import {
counterEventsMocks,
counterEventStore,
getEventsMock,
pushEventMock,
userEventStore,
} from '~/eventStore.util.test';

import {
incrementCounter,
incrementCounterA,
incrementCounterANoOutput,
incrementCounterNoOutput,
inputSchema,
onEventAlreadyExistsMock,
outputSchema,
pushEventMock,
requiredEventStores,
userEventStore,
} from './jsonSchema.util.test';

getEventsMock.mockResolvedValue({ events: counterEventsMocks });
Expand Down
Loading

0 comments on commit 8a6840e

Please sign in to comment.