Skip to content

Commit

Permalink
add workspace definitions, update readme/devcontainer (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Venables <rob@rvenables.com>
  • Loading branch information
mryckman and rvenables committed Mar 8, 2024
1 parent e973f7f commit 22fc2a6
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npx lerna bootstrap --hoist",
"postCreateCommand": "sh ./setup.sh",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "node"
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/lerna.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
bootstrap-params: [--no-ci, --hoist --no-ci]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -26,5 +24,5 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npx lerna@^6.0.3 bootstrap ${{ matrix.bootstrap-params }}
- run: npx lerna@^6.0.3 run test
- run: sh ./setup.sh
- run: npx lerna run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
.idea/*
# !.vscode/settings.json # Optional example we could enable if we want to share settings
.DS_Store

.nx/*
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ Join the discussion at http://chat.opr.dev/ for support.

### Install deps and build

First, run lerna bootstrap to install all package dependencies and compile local libraries in the correct order.
We recommend Node versions >=18.x, due to compatability issues with Lerna.

First, run the setup script to install packages and compile the workspaces.
Note that there are a few known issues with the install process that the
setup script is designed to overcome. We highly recommend you use this
for your package installation and setup.

```console
npx lerna bootstrap --hoist
sh ./setup.sh
```

The --hoist flag is optional for local builds, but the --hoist flag is _required_ for library development. Hoisting creates a very different package-lock structure from non-hoisted repositories. We standardize on the hoisted versions in the repository to avoid churn.

### Run the unit tests

Run
Expand All @@ -58,6 +61,7 @@ npx lerna run test
from the root directory to run all the unit tests. If you want to run the Postgres tests in opr-sql-database, you need to have a working installation of Postgres and the `initdb`, `postgres` and `psql` commands must be in your `PATH` environment variable. If those commands aren't available, the Postgres tests will be skipped.

### Devcontainer

If you use [VScode](https://code.visualstudio.com/), install the [devcontainer extention](https://code.visualstudio.com/docs/devcontainers/containers) as well as [docker desktop](https://www.docker.com/). VS code will helpfully ask if you'd like to re-open the project in a devcontainer, which should, after downloading and setting up a whole bunch of stuff, drop you right into a prompt that is ready to run `npx lerna run test`

### Read the standards
Expand Down
4 changes: 2 additions & 2 deletions examples/local-starter/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node
WORKDIR /usr
COPY ./ ./
RUN npx lerna@^6.0.3 bootstrap
RUN sh ./setup.sh
RUN mkdir ./deploy
RUN cp -Lr ./examples/local-starter/package.json ./deploy
RUN cp -Lr ./examples/local-starter/build ./deploy
RUN cp -Lr ./examples/local-starter/node_modules ./deploy
RUN cp -Lr ./node_modules ./deploy

## this is stage two , where the app actually runs
FROM node
Expand Down
15 changes: 10 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"packages": [
".",
"components/*",
"integrations/*",
"examples/*"
"components/models",
"components/devtools",
"components/core",
"components/core-testutil",
"integrations/google-cloud",
"integrations/sql-database",
"examples/gcp-cloudrun-postgres",
"examples/local-starter"
],
"version": "0.7.1"
"version": "0.7.1",
"workspaces": true
}
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
{
"private": true,
"name": "@opr/monorepo",
"private": false,
"scripts": {
"lintchanged": "eslint $(git diff --diff-filter=ACMRTUXB --name-only HEAD | grep '.*\\.ts$' | xargs)"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"lerna": "^6.0.3"
"lerna": "^8.1.2",
"prettier": "^3.2.5"
},
"repository": {
"type": "git",
"url": "https://github.com/google/open-product-recovery.git"
},
"engines": {
"node": ">=12.0.0"
}
},
"workspaces": [
"components/models",
"components/devtools",
"components/core",
"components/core-testutil",
"integrations/google-cloud",
"integrations/sql-database",
"examples/gcp-cloudrun-postgres",
"examples/local-starter"
]
}
12 changes: 12 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sh ./clean.sh
# Install will currently fail because the post-install "prepare" scripts just run
# when that package's install script finishes. This forces the install command
# to not run the post-install scripts. So we then separately run the compile.
# This is discussed here: https://github.com/npm/cli/issues/3034
npm install --workspaces --ignore-scripts --include-workspace-root
npm run compile --workspaces
# TypeORM is currently unable to locate the sqlite driver when using workspaces
# using a normal install. Calling rebuild here corrects this issue.
npm rebuild


0 comments on commit 22fc2a6

Please sign in to comment.