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 2 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
  •  
  •  
  •  
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/
11 changes: 11 additions & 0 deletions CODING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ See the [node website](https://nodejs.org) to install node and npm.
* You can then require `src/Main.js` in your code
* Test and lint changes: see test, lint and test-examples npm script

## Monorepo structure

The project is organized into the following sub-packages. This structuring is in progress.
The roadmap is to divide the `Main` sub-module into independent functionalities.
The final structure is exposed in this (page)[https://github.com/iTowns/itowns/issues/2414].

* `Geographic` (public): The geographic package provides utilities for handling coordinates, ellipsoids, extents and rotations across different coordinate systems;
* `Main` (public): all featues that haven't yet been moved to sub-module;
* `Debug` (private, for the moment): iTowns debugging utilities;
* `Widget` (private, for the moment): Graphic user interface for iTowns;

## Debugging
* `babel-inline-import-loader` prevents the source map debug in browser. If you
want launch server and debug with the original source map, run : `npm run
Expand Down
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
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,48 @@ github release page.

In your project:

To use all iTowns features, install `itowns` package :

```bash
npm install --save itowns
```

```js
import { Coordinates } from 'itowns';

const coordinates = new Coordinates('EPSG:4326', 88., 50.3, 120.3);

// change projection system to pseudo mercator
coordinates.as('EPSG:3857');
```

To import Widget features

```js
import { Navigation } from 'itowns/widgets';

const viewerDiv = document.getElementById('viewerDiv');

// Create a GlobeView
const view = new itowns.GlobeView(viewerDiv);

// Add navigation widget
const navigation = new Navigation(view, {
position: 'bottom-right',
translate: { y: -40 },
});
```

To use only geographic features, install `@itowns/geographic` package :

```bash
npm install --save @itowns/geographic
```

```js
import { Coordinates, Extent, CRS } from '@itowns/geographic';
```

This package contains the ES5-compatible sources of iTowns, up to date with the latest release.

If you're using a module bundler (like wepback), you can directly write
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';
Desplandis marked this conversation as resolved.
Show resolved Hide resolved
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