Skip to content

Commit

Permalink
Monorepo (nut-tree#560)
Browse files Browse the repository at this point in the history
* Monorepo build

* Added global gitignore

* Excluded .idea folder

* Added step to set up pnpm

* Added packageManager info to root level package.json

* Replaced npx with pnpx

* Fixed trailing comma

* NPM_TOKEN

* NPM_TOKEN

* NPM_TOKEN

* Added missing root level coverage:clean target

* Streamlined naming of samples

* Run coverage instead of test

* Updated lock file

* Updated sonar settings

* Updated sonar settings

* Aligned package versions, added script to bump versions on snapshot releases
  • Loading branch information
s1hofmann authored Feb 15, 2024
1 parent aa4c098 commit e12635d
Show file tree
Hide file tree
Showing 240 changed files with 11,710 additions and 43,963 deletions.
43 changes: 43 additions & 0 deletions .build/bump_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { exec } = require("child_process");
const { readFile, writeFile } = require("fs");
const { join } = require("path");

const args = process.argv.slice(2);
const version = args[0];

if (version == null || version === "") {
throw new Error("Version is required");
}

exec("pnpm m ls --json --depth=-1", (_, stdout) => {
const modules = JSON.parse(stdout).filter(
(module) => module.private !== true,
);

for (const module of modules) {
const filePath = join(module.path, "package.json");

readFile(filePath, "utf8", (err, data) => {
if (err) {
throw new Error(err);
}
// Parse JSON
const obj = JSON.parse(data);

// Change a property
obj.version = version;

// Convert object back to JSON
const json = JSON.stringify(obj, null, 2);

// Write JSON file
writeFile(filePath, json, "utf8", (err) => {
if (err) {
throw new Error(err);
} else {
console.log("File successfully updated.");
}
});
});
}
});
2 changes: 1 addition & 1 deletion .build/pre-release.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ patchVersion=$(npm --no-git-tag version patch)
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
echo "${nextVersion:1}"

npm version --no-git-tag -f "${nextVersion:1}"
node ./bump_version.js "${nextVersion:1}"
53 changes: 26 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,50 @@ jobs:
sonar:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Set up Git repository
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: |
pnpm whoami
pnpm i
- name: Compile
run: npm run compile
- name: Init window e2e test subpackage
run: npm --prefix e2e/window-test ci
run: pnpm -r run compile
- name: Clean coverage report
run: npm run coverage:clean
run: pnpm run coverage:clean
- name: Generate coverage report
uses: GabrielBB/xvfb-action@v1
env:
NODE_OPTIONS: "--max-old-space-size=8192"
with:
run: npm run coverage -- --coverageDirectory=coverage/unit
- name: Run Electron e2e test subpackage
uses: GabrielBB/xvfb-action@v1
with:
run: npm --prefix e2e/electron-test cit
- name: Merge coverage reports
run: |
npm run coverage:merge
npm run coverage:merge-report
run: pnpm run coverage
- name: Send results to SonarCloud
uses: SonarSource/[email protected]
uses: SonarSource/[email protected]
with:
projectBaseDir: core/nut.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

test:
needs:
- sonar
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
strategy:
matrix:
os: [windows-latest, macos-latest]
node: [18]
os: [ windows-latest, macos-latest ]
node: [ 18 ]
runs-on: ${{matrix.os}}
steps:
- name: Set up Git repository
Expand All @@ -63,19 +65,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{matrix.node}}
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: pnpm i
- name: Compile
run: npm run compile
- name: Init window e2e test subpackage
run: npm --prefix e2e/window-test ci
run: pnpm run compile
- name: Generate coverage report
uses: GabrielBB/xvfb-action@v1
with:
run: |
npx playwright install --with-deps
npm test
- name: Run Electron e2e test subpackage
uses: GabrielBB/xvfb-action@v1
with:
run: npm --prefix e2e/electron-test cit
pnpm run coverage
33 changes: 17 additions & 16 deletions .github/workflows/snapshot_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,21 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{matrix.node}}
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: pnpm i
- name: Install @nut-tree/libnut@next
run: npm i @nut-tree/libnut@next
run: |
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
- name: Compile
run: npm run compile
- name: Init window e2e test subpackage
run: npm --prefix e2e/window-test ci
run: pnpm run compile
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: |
npx playwright install --with-deps
npm test
- name: Run Electron e2e test subpackage
uses: GabrielBB/xvfb-action@v1
with:
run: npm --prefix e2e/electron-test cit
run: pnpm run coverage

deploy:
needs:
Expand All @@ -54,15 +51,19 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: pnpm i
- name: Install @nut-tree/libnut@next
run: npm i @nut-tree/libnut@next
run: |
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
- name: Create snapshot release
run: bash ./.build/pre-release.sh
- name: Publish snapshot release to npm
run: npm run publish-next
run: pnpm run publish:next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v3
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tagged_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{matrix.node}}
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
- name: Compile
Expand Down Expand Up @@ -46,7 +50,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
registry-url: https://registry.npmjs.org/
token: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
- name: Run typedoc
Expand Down
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ Check out this demo video to get a first impression of what nut.js is capable of

Please consult the project website at [nutjs.dev](https://nutjs.dev/docs/tutorial-first_steps/prerequisites) for in-depth tutorials

# Examples

[nut-tree/trailmix](https://github.com/nut-tree/trailmix) contains a set of ready to use examples which demo the usage of nut.js.

# API Docs

nut.js provides [public API documentation](https://nut-tree.github.io/apidoc/) auto-generated by [TypeDoc](https://typedoc.org).
Expand Down
11 changes: 11 additions & 0 deletions core/configs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@nut-tree/configs",
"private": true,
"version": "4.0.0",
"description": "Shared configs for nut.js",
"author": {
"name": "dry Software UG (haftungsbeschränkt)",
"email": "[email protected]",
"url": "https://dry.software"
}
}
12 changes: 5 additions & 7 deletions tsconfig.json → core/configs/tsconfig/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
"compilerOptions": {
"target": "ES2018",
"module": "commonjs",
"lib": ["es6"],
"outDir": "./dist",
"lib": [
"es6"
],
"declaration": true,
"declarationMap": true,
"declarationMap": false,
"sourceMap": true,
"strict": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,

"esModuleInterop": true
},
"include": ["lib/**/*.ts", "index.ts"],
"exclude": ["node_modules"]
}
}
Binary file added core/nut.js/.gfx/nut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/nut.js/.gfx/permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/nut.js/.gfx/permissions_popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/nut.js/.gfx/sponsors/mighty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e12635d

Please sign in to comment.