From 794d35fd026518868e32ff78c7d006cbe3061c4c Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Mon, 1 Feb 2021 12:25:15 +0100 Subject: [PATCH] =?UTF-8?q?Enl=C3=A8ve=20mecanismDoc=20des=20exports=20de?= =?UTF-8?q?=20publicodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Déplace l'import du fichier dans publicodes-react, le seul endroit où il est utilisé --- publicodes/core/esm/index.js | 1 - publicodes/core/source/index.ts | 2 -- publicodes/ui-react/.gitignore | 1 + publicodes/ui-react/package.json | 6 ++--- .../ui-react/source/mecanisms/common.tsx | 24 ++++++++----------- yarn.lock | 12 ++++++++++ 6 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 publicodes/ui-react/.gitignore diff --git a/publicodes/core/esm/index.js b/publicodes/core/esm/index.js index 480ad7634..6496b33f6 100644 --- a/publicodes/core/esm/index.js +++ b/publicodes/core/esm/index.js @@ -9,5 +9,4 @@ export const transformAST = publicodes.transformAST export const formatValue = publicodes.formatValue export const utils = publicodes.utils export const UNSAFE_isNotApplicable = publicodes.UNSAFE_isNotApplicable -export const mecanismsDoc = publicodes.mecanismsDoc export const evaluateRule = publicodes.evaluateRule diff --git a/publicodes/core/source/index.ts b/publicodes/core/source/index.ts index b90a4bc3f..13d540abc 100644 --- a/publicodes/core/source/index.ts +++ b/publicodes/core/source/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/ban-types */ import { reduceAST } from './AST' import { ASTNode, EvaluatedNode, NodeKind } from './AST/types' import { evaluationFunctions } from './evaluationFunctions' @@ -38,7 +37,6 @@ export type EvaluationOptions = Partial<{ unit: string }> -export { default as mecanismsDoc } from '../../docs/mecanisms.yaml' export { reduceAST, transformAST } from './AST/index' export { Evaluation, Unit } from './AST/types' export { capitalise0, formatValue } from './format' diff --git a/publicodes/ui-react/.gitignore b/publicodes/ui-react/.gitignore new file mode 100644 index 000000000..6320cd248 --- /dev/null +++ b/publicodes/ui-react/.gitignore @@ -0,0 +1 @@ +data \ No newline at end of file diff --git a/publicodes/ui-react/package.json b/publicodes/ui-react/package.json index bfff39b98..dbfe8cbe6 100644 --- a/publicodes/ui-react/package.json +++ b/publicodes/ui-react/package.json @@ -7,10 +7,9 @@ "license": "MIT", "readme": "../README.md", "scripts": { - "clean": "rimraf dist node_modules", + "clean": "rimraf dist node_modules data", "build": "tsc", - "clean": "rimraf dist node_modules", - "prepare": "yarn run build", + "prepare": "mkdir -p ./source/data && yarn run --silent js-yaml ../docs/mecanisms.yaml >| ./source/data/mecanisms.json && yarn run build", "test": "echo \"Error: no test specified\"" }, "dependencies": { @@ -31,6 +30,7 @@ "react-router-hash-link": "^1.2.2" }, "devDependencies": { + "js-yaml": "^4.0.0", "typescript": "^4.1.3" } } diff --git a/publicodes/ui-react/source/mecanisms/common.tsx b/publicodes/ui-react/source/mecanisms/common.tsx index de1df3b0c..1d0e48033 100644 --- a/publicodes/ui-react/source/mecanisms/common.tsx +++ b/publicodes/ui-react/source/mecanisms/common.tsx @@ -1,25 +1,21 @@ -import React, { createContext, useContext, useState } from 'react' -import { Trans } from 'react-i18next' -import styled from 'styled-components' +import { capitalise0, formatValue, simplifyNodeUnit } from 'publicodes' import { - mecanismsDoc, - formatValue, - capitalise0, - simplifyNodeUnit, -} from 'publicodes' -import { - Evaluation, EvaluatedNode, + Evaluation, Types, Unit, } from 'publicodes/source/AST/types' +import { ReferenceNode } from 'publicodes/source/reference' +import React, { createContext, useContext, useState } from 'react' +import { Trans } from 'react-i18next' +import styled from 'styled-components' +import { EngineContext } from '../contexts' +import mecanismsDoc from '../data/mecanisms.json' +import Explanation from '../Explanation' +import { Markdown } from '../Markdown' import Overlay from '../Overlay' import { RuleLinkWithContext } from '../RuleLink' import mecanismColors from './colors' -import Explanation from '../Explanation' -import { ReferenceNode } from 'publicodes/source/reference' -import { EngineContext } from '../contexts' -import { Markdown } from '../Markdown' export function ConstantNode({ nodeValue, type, fullPrecision, unit }) { if (nodeValue === null) { diff --git a/yarn.lock b/yarn.lock index e1ab7946d..045541e56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3153,6 +3153,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -8407,6 +8412,13 @@ js-yaml@^3.13.1, js-yaml@^3.5.2, js-yaml@^3.7.0: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== + dependencies: + argparse "^2.0.1" + js-yaml@~3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"