Skip to content

Commit

Permalink
fix(build): Proper webpack/babel configuration + fixes to linter
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
Jerome Simeon authored and jeromesimeon committed Mar 1, 2022
1 parent 8cc8ecb commit aaf5c90
Show file tree
Hide file tree
Showing 23 changed files with 3,050 additions and 356 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ jobs:
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
npm version --no-git-tag-version --yes --exact ${{ steps.timestamp.outputs.stamp }}
npx lerna version --no-git-tag-version --yes --exact ${{ steps.timestamp.outputs.stamp }}
npx lerna exec -- npm publish --access public --ignore-scripts --tag=unstable 2>&1
npx lerna exec -- npm publish --access public --tag=unstable 2>&1
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ logs
*.log
npm-debug.log*

# Test output
output

# Runtime data
pids
*.pid
Expand Down Expand Up @@ -65,9 +68,9 @@ jspm_packages
package-lock.jsonyarn
out

# minimised build folder
dist

# windowsjunk

thumbs.db

# umd build folder
umd
2,954 changes: 2,882 additions & 72 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/concerto-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"npm": ">=6"
},
"main": "index.js",
"browser": "umd/concerto.js",
"typings": "types/index.d.ts",
"scripts": {
"prepublishOnly": "webpack --config webpack.config.js --mode production",
"pretest": "npm run lint",
"lint": "eslint .",
"postlint": "npm run licchk",
Expand All @@ -35,6 +37,8 @@
"author": "accordproject.org",
"license": "Apache-2.0",
"devDependencies": {
"@babel/preset-env": "7.16.11",
"babel-loader": "8.2.3",
"acorn": "8.5.0",
"acorn-walk": "8.2.0",
"chai": "4.3.4",
Expand All @@ -55,6 +59,8 @@
"sinon": "10.0.0",
"sinon-chai": "3.6.0",
"tmp-promise": "3.0.2",
"webpack": "5.64.2",
"webpack-cli": "4.9.1",
"yargs": "17.1.0"
},
"dependencies": {
Expand Down
51 changes: 0 additions & 51 deletions packages/concerto-core/umd/concerto.js

This file was deleted.

77 changes: 77 additions & 0 deletions packages/concerto-core/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.
*/

'use strict';

let path = require('path');
const webpack = require('webpack');
const packageJson = require('./package.json');

module.exports = {
entry: {
client: [
'./index.js'
]
},
output: {
path: path.join(__dirname, 'umd'),
filename: 'concerto.js',
library: {
name: 'concerto',
type: 'umd',
},
umdNamedDefine: true,
},
plugins: [
new webpack.BannerPlugin(`Concerto v${packageJson.version}
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.`),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
],
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, 'lib')],
use: ['babel-loader']
},
{
test: /\.ne$/,
use:['raw-loader']
}
]
},
resolve: {
fallback: {
'fs': false,
'tls': false,
'net': false,
'path': false,
'os': false,
'util': false,
'url': false,
}
}
};
3 changes: 3 additions & 0 deletions packages/concerto-tools/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
5 changes: 2 additions & 3 deletions packages/concerto-tools/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ env:
mocha: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 9
sourceType: 'script'
ecmaVersion: 13
sourceType: script
rules:
indent:
- error
- 4
- SwitchCase: 1
linebreak-style:
- warn
- unix
Expand Down
72 changes: 0 additions & 72 deletions packages/concerto-tools/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,27 @@ function inferType(definition, context) {

if (definition.type) {
switch (definition.type) {
case 'string':
if (definition.format) {
if (definition.format === 'date-time' || definition.format === 'date') {
return 'DateTime';
} else {
throw new Error(`Format '${definition.format}' in '${name}' is not supported`);
}
case 'string':
if (definition.format) {
if (definition.format === 'date-time' || definition.format === 'date') {
return 'DateTime';
} else {
throw new Error(`Format '${definition.format}' in '${name}' is not supported`);
}
return 'String';
case 'boolean':
return 'Boolean';
case 'number':
return 'Double';
case 'integer':
return 'Integer'; // Could also be Long?
case 'array':
return inferType(definition.items, context) + '[]';
case 'object':
return inferTypeName(definition, context);
default:
throw new Error(`Type keyword '${definition.type}' in '${name}' is not supported`);
}
return 'String';
case 'boolean':
return 'Boolean';
case 'number':
return 'Double';
case 'integer':
return 'Integer'; // Could also be Long?
case 'array':
return inferType(definition.items, context) + '[]';
case 'object':
return inferTypeName(definition, context);
default:
throw new Error(`Type keyword '${definition.type}' in '${name}' is not supported`);
}
}
throw new Error(`Unsupported definition: ${JSON.stringify(definition)}`);
Expand Down
35 changes: 14 additions & 21 deletions packages/concerto-tools/lib/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@

'use strict';

const ModelManager = require('@accordproject/concerto-core').ModelManager;
const ModelUtil = require('@accordproject/concerto-core').ModelUtil;
const ModelFile = require('@accordproject/concerto-core').ModelFile;
const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration;
const Field = require('@accordproject/concerto-core').Field;
const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration;
const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration;
const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration;
const util = require('util');

/**
Expand Down Expand Up @@ -234,20 +227,20 @@ class CSharpVisitor {
*/
toCSharpType(type) {
switch (type) {
case 'DateTime':
return 'DateTime';
case 'Boolean':
return 'bool';
case 'String':
return 'string';
case 'Double':
return 'float';
case 'Long':
return 'long';
case 'Integer':
return 'int';
default:
return type;
case 'DateTime':
return 'DateTime';
case 'Boolean':
return 'bool';
case 'String':
return 'string';
case 'Double':
return 'float';
case 'Long':
return 'long';
case 'Integer':
return 'int';
default:
return type;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@

'use strict';

const AssetDeclaration = require('@accordproject/concerto-core').AssetDeclaration;
const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration;
const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration;
const ConceptDeclaration = require('@accordproject/concerto-core').ConceptDeclaration;
const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration;
const Field = require('@accordproject/concerto-core').Field;
const ModelFile = require('@accordproject/concerto-core').ModelFile;
const ModelManager = require('@accordproject/concerto-core').ModelManager;
const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration;
const TransactionDeclaration = require('@accordproject/concerto-core').TransactionDeclaration;
const util = require('util');
const ModelUtil = require('@accordproject/concerto-core').ModelUtil;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
/*
* 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.
*/
* 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.
*/

'use strict';

const util = require('util');

const ModelFile = require('@accordproject/concerto-core').ModelFile;
const ModelManager = require('@accordproject/concerto-core').ModelManager;
const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration;

const Field = require('@accordproject/concerto-core').Field;
const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration;
const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration;

/**
* Convert the contents of a ModelManager to GraphQL types, based on
* the https://spec.graphql.org/June2018/ specification.
Expand Down
Loading

0 comments on commit aaf5c90

Please sign in to comment.