Skip to content

Commit

Permalink
chore(cicd): build cjs, remove volta, add e2e tests (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra authored Dec 24, 2022
1 parent 31a55bd commit 3362547
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
node-version: "18"

- run: npm ci
- run: npm run cjs
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v1
with:
node-version: ${{ matrix.node-version }}
npm-version: '8.5.0'
- run: npm ci
- run: npm run format
- run: npm run lint
- run: npm run test
- run: npm run test:unit
- run: npm run cjs
- run: npm run test:e2e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ coverage
# project files
build
cache
dist
*.zip
nwbuild.log
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.

> Please note that the latest stable version is [v3.8.6](https://github.com/nwutils/nw-builder/tree/v3.8.6).
## Contributing

1. Pick and install a Node version manager
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"main": "./src/nwbuild.js",
"exports": {
"import": "./src/nwbuild.js",
"require": "./nwbuild.cjs"
"require": "./dist/nwbuild.cjs"
},
"type": "module",
"homepage": "https://github.com/nwutils/nw-builder",
Expand All @@ -26,14 +26,16 @@
"url": "https://github.com/nwutils/nw-builder.git"
},
"scripts": {
"format": "prettier --write \"./**/*.{js,md}\"",
"format": "prettier --write \"./**/*.{js,cjs,md}\"",
"lint": "eslint ./src",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"docs": "jsdoc ./src/nwbuild.js -d docs",
"demo:cli": "cd ./test/demo && nwbuild ./nwapp --mode=build --version=0.70.1 --flavour=normal --platform=win --arch=x64 --outDir=./build",
"demo:bld": "cd ./test/demo && node bld.cjs",
"demo:run": "cd ./test/demo && node run.cjs",
"cjs": "esbuild ./src/nwbuild.js --bundle --minify --legal-comments=inline --platform=node --outfile=./nwbuild.cjs",
"test:cli": "cd ./test/e2e && nwbuild ./nwapp --mode=build --version=0.70.1 --flavour=normal --platform=win --arch=x64 --outDir=./build",
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:e2e": "npm run cjs && cd ./test/e2e && node bld.cjs",
"demo:nix": "npm run cjs && cd ./test/e2e && node nix.cjs",
"demo:osx": "npm run cjs && cd ./test/e2e && node osx.cjs",
"demo:win": "npm run cjs && cd ./test/e2e && node win.cjs",
"cjs": "esbuild ./src/nwbuild.js --bundle --minify --legal-comments=inline --platform=node --outfile=./dist/nwbuild.cjs",
"checklist": "npm run cjs && npm run format && npm run lint && npm run test"
},
"devDependencies": {
Expand Down
24 changes: 12 additions & 12 deletions src/bld/winCfg.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rename } from "node:fs/promises";

import rcedit from "rcedit";
// import rcedit from "rcedit";

/**
* Windows specific configuration steps
Expand All @@ -12,17 +12,17 @@ const setWinConfig = async (pkg, outDir) => {
await rename(`${outDir}/nw.exe`, `${outDir}/${pkg.name}.exe`);

// https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource?redirectedfrom=MSDN#string-name
await rcedit(`${outDir}/${pkg.name}.exe`, {
"file-version": pkg.version,
"product-version": pkg.version,
"icon": pkg.icon,
"version-string": {
FileDescription: pkg.description,
LegalCopyright: pkg.copyright,
ProductName: pkg.name,
OriginalFilename: pkg.name,
},
});
// await rcedit(`${outDir}/${pkg.name}.exe`, {
// "file-version": pkg.version,
// "product-version": pkg.version,
// "icon": pkg.icon,
// "version-string": {
// FileDescription: pkg.description,
// LegalCopyright: pkg.copyright,
// ProductName: pkg.name,
// OriginalFilename: pkg.name,
// },
// });
};

export { setWinConfig };
19 changes: 12 additions & 7 deletions test/demo/bld.cjs → test/e2e/bld.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { platform } = require("node:process");
const { nwbuild } = require("nw-builder");

const bld = async () => {
await nwbuild({
if (platform === "linux") {
nwbuild({
srcDir: "./nwapp",
mode: "build",
version: "0.70.1",
Expand All @@ -10,7 +11,10 @@ const bld = async () => {
arch: "x64",
outDir: "./build/nix",
});
await nwbuild({
}

if (platform === "darwin") {
nwbuild({
srcDir: "./nwapp",
mode: "build",
version: "0.70.1",
Expand All @@ -19,7 +23,10 @@ const bld = async () => {
arch: "x64",
outDir: "./build/osx",
});
await nwbuild({
}

if (platform === "win32") {
nwbuild({
srcDir: "./nwapp",
mode: "build",
version: "0.70.1",
Expand All @@ -28,6 +35,4 @@ const bld = async () => {
arch: "x64",
outDir: "./build/win",
});
};

bld();
}
11 changes: 11 additions & 0 deletions test/e2e/nix.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { nwbuild } = require("nw-builder");

nwbuild({
srcDir: "./nwapp",
mode: "build",
version: "0.70.1",
flavour: "normal",
platform: "linux",
arch: "x64",
outDir: "./build/nix",
});
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions test/e2e/osx.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { nwbuild } = require("nw-builder");

nwbuild({
srcDir: "./nwapp",
mode: "build",
version: "0.70.1",
flavour: "normal",
platform: "linux",
arch: "x64",
outDir: "./build/osx",
});
7 changes: 5 additions & 2 deletions test/demo/run.cjs → test/e2e/win.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const { nwbuild } = require("nw-builder");

nwbuild({
srcDir: "./nwapp",
mode: "run",
mode: "build",
version: "0.70.1",
flavour: "sdk",
flavour: "normal",
platform: "win",
arch: "x64",
outDir: "./build/win",
});

0 comments on commit 3362547

Please sign in to comment.