Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo structure #2300

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
}]
],
"plugins": [
["module-resolver", { "root": ["./src"] } ],
["module-resolver", {
"cwd": "packagejson",
"root": ["./packages/Main/src"]
}],
["babel-plugin-inline-import", {
"extensions": [
".json",
Expand All @@ -32,4 +35,4 @@
}],
["minify-dead-code-elimination"]
]
}
}
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
examples/libs/
examples/layers/
src/ThreeExtended/
packages/Main/src/ThreeExtended/
test/hooks.js
dist/
node_modules/
Expand Down
12 changes: 11 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');

module.exports = {
root: true,
extends: [
Expand All @@ -13,7 +15,15 @@ module.exports = {
},
settings: {
'import/resolver': {
'babel-module': {},
'babel-module': {
alias: {
'@itowns/geodesy': 'packages/Geodesy/src/Main.js',
itowns: 'packages/Main/src/Main.js',
},
plugins: [
['module-extension-resolver'],
],
},
},
},
env: {
Expand Down
52 changes: 37 additions & 15 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- master
workflow_dispatch: {}


jobs:

# Build bundle, doc and check linter
Expand Down Expand Up @@ -55,7 +54,7 @@ jobs:
with:
name: dist-itowns
path: |
dist/**/*.js
packages/Main/dist/**/*.js
examples
buildDocs

Expand All @@ -79,8 +78,15 @@ jobs:
# Unit and coverage tests
unit-and-coverage-tests:
name: Unit and coverage tests
needs: build
needs: [build, check-commit-message]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- package: "@itowns/geodesy"
path: "Geodesy"
- package: "itowns"
path: "Main"
steps:

# Use specific Node.js version
Expand All @@ -95,17 +101,33 @@ jobs:
- name: Install packages
run: npm ci

- name: Run unit tests
run: npm run test-with-coverage_lcov
# Transpile
- name: transpile packages
run: npm run transpile

# Code coverage
- name: Coveralls
if: ${{ success() }}
uses: coverallsapp/github-action@master
- name: Test ${{ matrix.package }}
run: npm run test-with-coverage_lcov --workspace ${{ matrix.package}}
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
format: lcov
base-path: ./packages/${{ matrix.path }}
path-to-lcov: ./packages/${{ matrix.path }}/coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.package }}
parallel: true


# Final Code coverage
finish-coverage:
name: finish parallel test unit
needs: unit-and-coverage-tests
runs-on: ubuntu-latest
steps:
- name: Close parallel build
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
github-token: ${{ secrets.GITHUB_TOKEN }}
# Functional tests
functional-tests:
name: Functional tests
Expand Down Expand Up @@ -139,7 +161,7 @@ jobs:
publish:
name: Publish NPM package
if: ${{ github.ref == 'refs/heads/master' }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
needs: [finish-coverage, functional-tests]
runs-on: ubuntu-latest
permissions:
# id-token: write permission is required for npm provenance:
Expand Down Expand Up @@ -196,7 +218,7 @@ jobs:
deploy:
name: Deploy to itowns.github.io
if: ${{ github.ref == 'refs/heads/master' }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
needs: [finish-coverage, functional-tests]
runs-on: ubuntu-latest
steps:

Expand All @@ -212,7 +234,7 @@ jobs:
mkdir -p itowns/dist
mkdir -p itowns/potree/build
mkdir -p itowns/potree/libs
cp -R dist/*.js itowns/dist/
cp -R packages/Main/dist/*.js itowns/dist
cp -R examples itowns/
cp -R buildDocs itowns/docs

Expand Down Expand Up @@ -257,7 +279,7 @@ jobs:
release:
name: Release GitHub
if: ${{ github.ref == 'refs/heads/master' && startsWith( github.event.head_commit.message, 'release v' ) }}
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
needs: [finish-coverage, functional-tests]
runs-on: ubuntu-latest
steps:

Expand Down Expand Up @@ -308,7 +330,7 @@ jobs:
# Zip assets into bundle
- name: Zip assets
run: |
zip --junk-paths bundles ./dist/*.js ./dist/*.map
zip --junk-paths bundles ./packages/Main/dist/*.js ./packages/Main/dist/*.map

# Upload release asset
- name: upload release asset
Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# See https://help.github.com/articles/ignoring-files/ for how to configure your environment.
# See https://github.com/github/gitignore/tree/master/Global for a list of global ignore rules.

/node_modules/
/dist/
**/node_modules/
**/dist/
/potree/
potree
/lib/
**/lib/
/docs/out/
coverage
**/coverage
.nyc_output/
/src/ThreeExtended/
**/src/ThreeExtended/
14 changes: 12 additions & 2 deletions Gruntfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ module.exports = (grunt) => {
pkg: grunt.file.readJSON('package.json'),
bump: {
options: {
files: ['package.json', 'package-lock.json', 'src/Main.js'],
files: ['package.json', 'package-lock.json', 'packages/Main/src/Main.js',
// 'packages/**/package.json'
'packages/Main/package.json',
'packages/Geodesy/package.json',
'packages/Widget/package.json',
],
updateConfigs: [],
commit: true,
commitMessage: 'release v%VERSION%',
commitFiles: ['package.json', 'package-lock.json', 'src/Main.js'],
commitFiles: ['package.json', 'package-lock.json',
// 'packages/**/package.json'
'packages/Main/package.json',
'packages/Geodesy/package.json',
'packages/Widget/package.json',
],
createTag: false,
tagName: 'v%VERSION%',
tagMessage: 'Release %VERSION%.',
Expand Down
6 changes: 5 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"babelrcRoots": [
"."
".",
"./packages/Geodesy",
"./packages/Main",
"./packages/Debug",
"./packages/Widget"
]
}
12 changes: 12 additions & 0 deletions config/concurrently.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import concurrently from 'concurrently';

import fs from 'fs';

const pck = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const script = process.argv[2];

concurrently(pck.workspaces.map(workspace => ({
command: `npm run ${script} -w ${workspace} --if-present`,
name: `${workspace}`,
})));

12 changes: 0 additions & 12 deletions config/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import chalk from 'chalk';
import copyfiles from 'copyfiles';
// const chalk = require('chalk');
import { execSync } from 'child_process';
import threeExamples from './threeExamples.mjs';



Expand Down Expand Up @@ -33,12 +30,3 @@ const npmVersion = execSync('npm --version', {
if (npmVersion) {
console.log(chalk.green('Npm version :', npmVersion), '\n');
}



// Copy and patch THREE Examples Files
const paths = threeExamples.filesExamples.map(f => f.replace('./', './node_modules/three/examples/jsm/'));

paths.push(threeExamples.patchedPath);

copyfiles(paths, { up: 4 }, () => {});
5 changes: 3 additions & 2 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@
}
},
"source": {
"include": [ "src", "examples/js/plugins" ],
"exclude": [ "src/ThreeExtended" ]
"include": [ "examples/js/plugins", "packages" ],
"exclude": [ "packages/Main/src/ThreeExtended" ],
"excludePattern": "(^|\\/|\\\\)lib"
},
"plugins": ["plugins/markdown"]
}
Loading
Loading