Skip to content

Commit e12635d

Browse files
authored
Monorepo (#560)
* 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
1 parent aa4c098 commit e12635d

File tree

240 files changed

+11710
-43963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+11710
-43963
lines changed

Diff for: .build/bump_version.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const { exec } = require("child_process");
2+
const { readFile, writeFile } = require("fs");
3+
const { join } = require("path");
4+
5+
const args = process.argv.slice(2);
6+
const version = args[0];
7+
8+
if (version == null || version === "") {
9+
throw new Error("Version is required");
10+
}
11+
12+
exec("pnpm m ls --json --depth=-1", (_, stdout) => {
13+
const modules = JSON.parse(stdout).filter(
14+
(module) => module.private !== true,
15+
);
16+
17+
for (const module of modules) {
18+
const filePath = join(module.path, "package.json");
19+
20+
readFile(filePath, "utf8", (err, data) => {
21+
if (err) {
22+
throw new Error(err);
23+
}
24+
// Parse JSON
25+
const obj = JSON.parse(data);
26+
27+
// Change a property
28+
obj.version = version;
29+
30+
// Convert object back to JSON
31+
const json = JSON.stringify(obj, null, 2);
32+
33+
// Write JSON file
34+
writeFile(filePath, json, "utf8", (err) => {
35+
if (err) {
36+
throw new Error(err);
37+
} else {
38+
console.log("File successfully updated.");
39+
}
40+
});
41+
});
42+
}
43+
});

Diff for: .build/pre-release.sh

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ patchVersion=$(npm --no-git-tag version patch)
55
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
66
echo "${nextVersion:1}"
77

8-
npm version --no-git-tag -f "${nextVersion:1}"
8+
node ./bump_version.js "${nextVersion:1}"

Diff for: .github/workflows/ci.yaml

+26-27
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,50 @@ jobs:
1313
sonar:
1414
runs-on: ubuntu-latest
1515
if: "!contains(github.event.head_commit.message, 'skip ci')"
16+
env:
17+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1618
steps:
1719
- name: Set up Git repository
1820
uses: actions/checkout@v3
1921
- name: Set up node
2022
uses: actions/setup-node@v3
2123
with:
2224
node-version: 18
25+
registry-url: https://registry.npmjs.org/
26+
token: ${{ secrets.NPM_TOKEN }}
27+
- name: Setup pnpm
28+
uses: pnpm/[email protected]
2329
- name: Install
24-
run: npm ci
30+
run: |
31+
pnpm whoami
32+
pnpm i
2533
- name: Compile
26-
run: npm run compile
27-
- name: Init window e2e test subpackage
28-
run: npm --prefix e2e/window-test ci
34+
run: pnpm -r run compile
2935
- name: Clean coverage report
30-
run: npm run coverage:clean
36+
run: pnpm run coverage:clean
3137
- name: Generate coverage report
3238
uses: GabrielBB/xvfb-action@v1
3339
env:
3440
NODE_OPTIONS: "--max-old-space-size=8192"
3541
with:
36-
run: npm run coverage -- --coverageDirectory=coverage/unit
37-
- name: Run Electron e2e test subpackage
38-
uses: GabrielBB/xvfb-action@v1
39-
with:
40-
run: npm --prefix e2e/electron-test cit
41-
- name: Merge coverage reports
42-
run: |
43-
npm run coverage:merge
44-
npm run coverage:merge-report
42+
run: pnpm run coverage
4543
- name: Send results to SonarCloud
46-
uses: SonarSource/[email protected]
44+
uses: SonarSource/[email protected]
45+
with:
46+
projectBaseDir: core/nut.js
4747
env:
4848
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4949
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5050

5151
test:
5252
needs:
5353
- sonar
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5456
strategy:
5557
matrix:
56-
os: [windows-latest, macos-latest]
57-
node: [18]
58+
os: [ windows-latest, macos-latest ]
59+
node: [ 18 ]
5860
runs-on: ${{matrix.os}}
5961
steps:
6062
- name: Set up Git repository
@@ -63,19 +65,16 @@ jobs:
6365
uses: actions/setup-node@v3
6466
with:
6567
node-version: ${{matrix.node}}
68+
registry-url: https://registry.npmjs.org/
69+
token: ${{ secrets.NPM_TOKEN }}
70+
- name: Setup pnpm
71+
uses: pnpm/[email protected]
6672
- name: Install
67-
run: npm ci
73+
run: pnpm i
6874
- name: Compile
69-
run: npm run compile
70-
- name: Init window e2e test subpackage
71-
run: npm --prefix e2e/window-test ci
75+
run: pnpm run compile
7276
- name: Generate coverage report
7377
uses: GabrielBB/xvfb-action@v1
7478
with:
7579
run: |
76-
npx playwright install --with-deps
77-
npm test
78-
- name: Run Electron e2e test subpackage
79-
uses: GabrielBB/xvfb-action@v1
80-
with:
81-
run: npm --prefix e2e/electron-test cit
80+
pnpm run coverage

Diff for: .github/workflows/snapshot_release.yaml

+17-16
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,21 @@ jobs:
2424
uses: actions/setup-node@v3
2525
with:
2626
node-version: ${{matrix.node}}
27+
registry-url: https://registry.npmjs.org/
28+
token: ${{ secrets.NPM_TOKEN }}
29+
- name: Setup pnpm
30+
uses: pnpm/[email protected]
2731
- name: Install
28-
run: npm ci
32+
run: pnpm i
2933
- name: Install @nut-tree/libnut@next
30-
run: npm i @nut-tree/libnut@next
34+
run: |
35+
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
3136
- name: Compile
32-
run: npm run compile
33-
- name: Init window e2e test subpackage
34-
run: npm --prefix e2e/window-test ci
37+
run: pnpm run compile
3538
- name: Run tests
3639
uses: GabrielBB/xvfb-action@v1
3740
with:
38-
run: |
39-
npx playwright install --with-deps
40-
npm test
41-
- name: Run Electron e2e test subpackage
42-
uses: GabrielBB/xvfb-action@v1
43-
with:
44-
run: npm --prefix e2e/electron-test cit
41+
run: pnpm run coverage
4542

4643
deploy:
4744
needs:
@@ -54,15 +51,19 @@ jobs:
5451
uses: actions/setup-node@v3
5552
with:
5653
node-version: 18
57-
registry-url: "https://registry.npmjs.org"
54+
registry-url: https://registry.npmjs.org/
55+
token: ${{ secrets.NPM_TOKEN }}
56+
- name: Setup pnpm
57+
uses: pnpm/[email protected]
5858
- name: Install
59-
run: npm ci
59+
run: pnpm i
6060
- name: Install @nut-tree/libnut@next
61-
run: npm i @nut-tree/libnut@next
61+
run: |
62+
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
6263
- name: Create snapshot release
6364
run: bash ./.build/pre-release.sh
6465
- name: Publish snapshot release to npm
65-
run: npm run publish-next
66+
run: pnpm run publish:next
6667
env:
6768
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6869
- uses: actions/setup-node@v3

Diff for: .github/workflows/tagged_release.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
uses: actions/setup-node@v3
1919
with:
2020
node-version: ${{matrix.node}}
21+
registry-url: https://registry.npmjs.org/
22+
token: ${{ secrets.NPM_TOKEN }}
23+
- name: Setup pnpm
24+
uses: pnpm/[email protected]
2125
- name: Install
2226
run: npm ci
2327
- name: Compile
@@ -46,7 +50,10 @@ jobs:
4650
uses: actions/setup-node@v3
4751
with:
4852
node-version: 18
49-
registry-url: "https://registry.npmjs.org"
53+
registry-url: https://registry.npmjs.org/
54+
token: ${{ secrets.NPM_TOKEN }}
55+
- name: Setup pnpm
56+
uses: pnpm/[email protected]
5057
- name: Install
5158
run: npm ci
5259
- name: Run typedoc

Diff for: .husky/pre-commit

-4
This file was deleted.

Diff for: .nvmrc

-1
This file was deleted.

Diff for: README.md

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ Check out this demo video to get a first impression of what nut.js is capable of
5050

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

53-
# Examples
54-
55-
[nut-tree/trailmix](https://github.com/nut-tree/trailmix) contains a set of ready to use examples which demo the usage of nut.js.
56-
5753
# API Docs
5854

5955
nut.js provides [public API documentation](https://nut-tree.github.io/apidoc/) auto-generated by [TypeDoc](https://typedoc.org).

Diff for: core/configs/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@nut-tree/configs",
3+
"private": true,
4+
"version": "4.0.0",
5+
"description": "Shared configs for nut.js",
6+
"author": {
7+
"name": "dry Software UG (haftungsbeschränkt)",
8+
"email": "[email protected]",
9+
"url": "https://dry.software"
10+
}
11+
}

Diff for: tsconfig.json renamed to core/configs/tsconfig/base.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
"compilerOptions": {
33
"target": "ES2018",
44
"module": "commonjs",
5-
"lib": ["es6"],
6-
"outDir": "./dist",
5+
"lib": [
6+
"es6"
7+
],
78
"declaration": true,
8-
"declarationMap": true,
9+
"declarationMap": false,
910
"sourceMap": true,
1011
"strict": true,
1112
"noImplicitAny": true,
1213
"noUnusedLocals": true,
1314
"noUnusedParameters": true,
1415
"noImplicitReturns": true,
15-
1616
"esModuleInterop": true
17-
},
18-
"include": ["lib/**/*.ts", "index.ts"],
19-
"exclude": ["node_modules"]
17+
}
2018
}

Diff for: core/nut.js/.gfx/nut.png

81.1 KB
Loading

Diff for: core/nut.js/.gfx/permissions.png

64.7 KB
Loading

Diff for: core/nut.js/.gfx/permissions_popup.png

201 KB
Loading

Diff for: core/nut.js/.gfx/sponsors/mighty.svg

+1
Loading

0 commit comments

Comments
 (0)