Skip to content

Commit

Permalink
chore(architecture): monorepo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Nov 28, 2024
1 parent 683e55d commit 7da9652
Show file tree
Hide file tree
Showing 348 changed files with 1,752 additions and 339 deletions.
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 = {

// Global ESLint settings
Expand All @@ -15,7 +17,15 @@ module.exports = {
},
settings: {
'import/resolver': {
'babel-module': {},
'babel-module': {
alias: {
'@itowns/geographic': path.resolve(__dirname, 'packages/Geographic/src/Main.js'),
itowns: path.resolve(__dirname, '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/geographic"
path: "Geographic"
- 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/Main/package.json',
'packages/Geographic/package.json',
'packages/Widget/package.json',
'packages/Debug/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/Main/package.json',
'packages/Geographic/package.json',
'packages/Widget/package.json',
'packages/Debug/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/Geographic",
"./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 @@ -193,8 +193,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

0 comments on commit 7da9652

Please sign in to comment.