forked from accordproject/concerto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): compare two concerto models (contributes to accordproject#442)
Signed-off-by: Simon Stone <[email protected]>
- Loading branch information
Simon Stone
authored and
Simon Stone
committed
Aug 5, 2022
1 parent
1669924
commit 39a9a65
Showing
51 changed files
with
22,316 additions
and
14,716 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
coverage | ||
node_modules | ||
out | ||
lib/parser.js | ||
test/data | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
env: | ||
es6: true | ||
node: true | ||
mocha: true | ||
extends: | ||
- 'eslint:recommended' | ||
- 'plugin:@typescript-eslint/eslint-recommended' | ||
- 'plugin:@typescript-eslint/recommended' | ||
parser: '@typescript-eslint/parser' | ||
plugins: | ||
- '@typescript-eslint' | ||
parserOptions: | ||
ecmaVersion: 13 | ||
sourceType: script | ||
rules: | ||
indent: | ||
- error | ||
- 4 | ||
linebreak-style: | ||
- warn | ||
- unix | ||
quotes: | ||
- error | ||
- single | ||
semi: | ||
- error | ||
- always | ||
no-console: warn | ||
curly: error | ||
eqeqeq: error | ||
no-throw-literal: error | ||
strict: 0 | ||
no-var: error | ||
dot-notation: error | ||
no-tabs: error | ||
no-trailing-spaces: error | ||
# no-use-before-define: error | ||
no-useless-call: error | ||
no-with: error | ||
operator-linebreak: error | ||
require-jsdoc: 0 | ||
valid-jsdoc: | ||
- error | ||
- requireReturn: false | ||
yoda: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/generated/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# hidden config files | ||
.editorconfig | ||
.eslint.yml | ||
.eslintignore | ||
.eslintrc.yml | ||
.tern-project | ||
|
||
# test directory | ||
test | ||
|
||
# scripts directory | ||
scripts | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# JSDoc | ||
out | ||
|
||
# Mac files. | ||
**/.DS_Store | ||
|
||
*.swp | ||
|
||
# Build generated files should be ignored by git, but not by npm. | ||
# lib/acl/parser.js | ||
# lib/introspect/parser.js | ||
# lib/query/parser.js | ||
# index.d.ts | ||
|
||
.babelrc | ||
api.txt | ||
changelog.txt | ||
jsdoc.json | ||
HEADER | ||
HEADER.md | ||
rollup.config.js | ||
lib/introspect/parser.pegjs | ||
|
||
# Locally built npm packages | ||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## License <a name="license"></a> | ||
Accord Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Accord Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Concerto Analysis | ||
Analysis of [Concerto](https://github.com/accordproject/concerto/) model files. | ||
|
||
## Install | ||
|
||
``` | ||
npm install @accordproject/concerto-types --save | ||
``` | ||
|
||
## License <a name="license"></a> | ||
Accord Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Accord Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"name": "@accordproject/concerto-analysis", | ||
"version": "3.0.0-alpha.1", | ||
"description": "Analysis of Concerto model files", | ||
"homepage": "https://github.com/accordproject/concerto", | ||
"engines": { | ||
"node": ">=14", | ||
"npm": ">=6" | ||
}, | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"prebuild": "npm-run-all clean", | ||
"build": "tsc -p tsconfig.build.json", | ||
"pretest": "npm-run-all licchk lint", | ||
"lint": "eslint .", | ||
"licchk": "license-check-and-add", | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/accordproject/concerto.git", | ||
"directory": "packages/concerto-analysis" | ||
}, | ||
"keywords": [ | ||
"concerto", | ||
"tools", | ||
"modeling" | ||
], | ||
"author": "accordproject.org", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@accordproject/concerto-core": "3.0.0-alpha.1" | ||
}, | ||
"devDependencies": { | ||
"@accordproject/concerto-cto": "3.0.0-alpha.1", | ||
"@types/jest": "28.1.1", | ||
"@typescript-eslint/parser": "5.27.1", | ||
"@typescript-eslint/eslint-plugin": "5.27.1", | ||
"eslint": "8.2.0", | ||
"jest": "28.1.1", | ||
"license-check-and-add": "2.3.6", | ||
"npm-run-all": "4.1.5", | ||
"rimraf": "3.0.2", | ||
"ts-jest": "28.0.4", | ||
"typescript": "4.6.3" | ||
}, | ||
"license-check-and-add-config": { | ||
"folder": "./src", | ||
"license": "HEADER", | ||
"exact_paths_method": "EXCLUDE", | ||
"exact_paths": [ | ||
"api.txt", | ||
"composer-logs", | ||
"coverage", | ||
"index.d.ts", | ||
"./system", | ||
"./introspect/parser.js", | ||
"LICENSE", | ||
"node_modules", | ||
".nyc-output", | ||
"out", | ||
".tern-project", | ||
"./generated/concerto.ts", | ||
"./generated/concerto.metamodel.ts" | ||
], | ||
"file_type_method": "EXCLUDE", | ||
"file_types": [ | ||
".yml", | ||
".yaml", | ||
".zip", | ||
".tgz" | ||
], | ||
"insert_license": false, | ||
"license_formats": { | ||
"js|ts|njk|pegjs|cto|acl|qry": { | ||
"prepend": "/*", | ||
"append": " */", | ||
"eachLine": { | ||
"prepend": " * " | ||
} | ||
}, | ||
"npmrc|editorconfig|txt": { | ||
"eachLine": { | ||
"prepend": "# " | ||
} | ||
}, | ||
"md": { | ||
"file": "./HEADER.md" | ||
} | ||
} | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"testPathIgnorePatterns": ["<rootDir>/dist/", "/node_modules/"], | ||
"collectCoverage": true, | ||
"collectCoverageFrom": ["src/**/*.ts"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { ComparerFactory } from './comparer'; | ||
import { comparerFactories } from './comparers'; | ||
|
||
export enum CompareResult { | ||
NONE, | ||
PATCH, | ||
MINOR, | ||
MAJOR, | ||
ERROR, | ||
} | ||
|
||
export function compareResultToString(result: CompareResult) { | ||
switch (result) { | ||
case CompareResult.NONE: | ||
return 'none'; | ||
case CompareResult.PATCH: | ||
return 'patch'; | ||
case CompareResult.MINOR: | ||
return 'minor'; | ||
case CompareResult.MAJOR: | ||
return 'major'; | ||
case CompareResult.ERROR: | ||
return 'error'; | ||
} | ||
} | ||
|
||
export type CompareConfig = { | ||
comparerFactories: ComparerFactory[]; | ||
rules: Record<string, CompareResult>; | ||
} | ||
|
||
export const defaultCompareConfig: CompareConfig = { | ||
comparerFactories, | ||
rules: { | ||
'asset-added': CompareResult.MINOR, | ||
'asset-removed': CompareResult.MAJOR, | ||
'concept-added': CompareResult.MINOR, | ||
'concept-removed': CompareResult.MAJOR, | ||
'enum-added': CompareResult.MINOR, | ||
'enum-removed': CompareResult.MAJOR, | ||
'event-added': CompareResult.MINOR, | ||
'event-removed': CompareResult.MAJOR, | ||
'participant-added': CompareResult.MINOR, | ||
'participant-removed': CompareResult.MAJOR, | ||
'transaction-added': CompareResult.MINOR, | ||
'transaction-removed': CompareResult.MAJOR, | ||
'required-field-added': CompareResult.MAJOR, | ||
'optional-field-added': CompareResult.PATCH, | ||
'field-removed': CompareResult.MAJOR, | ||
'namespace-changed': CompareResult.ERROR | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { CompareFinding } from './compare-message'; | ||
|
||
export type CompareContext = { | ||
report: (finding: CompareFinding) => void; | ||
} |
Oops, something went wrong.