1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-30 16:23:53 +00:00

jest/npm/nx updates

This commit is contained in:
Derek Nance
2025-12-19 14:42:33 -06:00
parent c600d41c66
commit 5973c8805c
4 changed files with 127 additions and 34 deletions

View File

@@ -20,24 +20,42 @@
"start": "cross-env ELECTRON_IS_DEV=0 ELECTRON_NO_UPDATER=1 electron ./build",
"build-native-macos": "cd desktop_native && ./macos_provider/build.sh && node build.js cross-platform",
"build-native": "cd desktop_native && node build.js",
"build": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\" \"npm run build:preload\"",
"build:dev": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:main:dev\" \"npm run build:renderer:dev\" \"npm run build:preload:dev\"",
"build:preload": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name preload",
"build:preload:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name preload",
"build:preload:watch": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name preload --watch",
"build": "npm run build:oss",
"build:dev": "npm run build:oss:dev",
"build:preload": "npm run build:oss:preload",
"build:preload:dev": "npm run build:oss:preload:dev",
"build:preload:watch": "npm run build:oss:preload:watch",
"build:macos-extension:mac": "./desktop_native/macos_provider/build.sh && node scripts/build-macos-extension.js mac",
"build:macos-extension:mas": "./desktop_native/macos_provider/build.sh && node scripts/build-macos-extension.js mas",
"build:macos-extension:masdev": "./desktop_native/macos_provider/build.sh && node scripts/build-macos-extension.js mas-dev",
"build:main": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name main",
"build:main:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name main",
"build:main:watch": "npm run build-native && cross-env NODE_ENV=development webpack --config webpack.config.js --config-name main --watch",
"build:renderer": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name renderer",
"build:renderer:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer",
"build:renderer:watch": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer --watch",
"build:main": "npm run build:oss:main",
"build:main:dev": "npm run build:oss:main:dev",
"build:main:watch": "npm run build:oss:main:watch",
"build:renderer": "npm run build:oss:renderer",
"build:renderer:dev": "npm run build:oss:renderer:dev",
"build:renderer:watch": "npm run build:oss:renderer:watch",
"build:oss": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:oss:main\" \"npm run build:oss:renderer\" \"npm run build:oss:preload\"",
"build:oss:dev": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:oss:main:dev\" \"npm run build:oss:renderer:dev\" \"npm run build:oss:preload:dev\"",
"build:oss:main": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name main",
"build:oss:main:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name main",
"build:oss:main:watch": "npm run build-native && cross-env NODE_ENV=development webpack --config webpack.config.js --config-name main --watch",
"build:oss:renderer": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name renderer",
"build:oss:renderer:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer",
"build:oss:renderer:watch": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer --watch",
"build:oss:preload": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name preload",
"build:oss:preload:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name preload",
"build:oss:preload:watch": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name preload --watch",
"build:bit": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:bit:main\" \"npm run build:bit:renderer\" \"npm run build:bit:preload\"",
"build:bit:dev": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:bit:main:dev\" \"npm run build:bit:renderer:dev\" \"npm run build:bit:preload:dev\"",
"build:bit:main": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main",
"build:bit:main:dev": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main",
"build:bit:main:watch": "npm run build-native && cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main --watch",
"build:bit:renderer": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name renderer",
"build:bit:renderer:dev": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name renderer",
"build:bit:renderer:watch": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name renderer --watch",
"build:bit:preload": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name preload",
"build:bit:preload:dev": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name preload",
"build:bit:preload:watch": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name preload --watch",
"electron": "node ./scripts/start.js",
"electron:ignore": "node ./scripts/start.js --ignore-certificate-errors",
"flatpak:dev": "npm run clean:dist && electron-builder --dir -p never && flatpak-builder --force-clean --install --user ../../.flatpak/ ./resources/com.bitwarden.desktop.devel.yaml && flatpak run com.bitwarden.desktop",
@@ -69,8 +87,14 @@
"publish:win": "npm run build && npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p always",
"publish:win:dev": "npm run build:dev && npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p always",
"upload:mas": "xcrun altool --upload-app --type osx --file \"$(find ./dist/mas-universal/Bitwarden*.pkg)\" --apiKey $APP_STORE_CONNECT_AUTH_KEY --apiIssuer $APP_STORE_CONNECT_TEAM_ISSUER",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
"test": "npm run test:oss",
"test:watch": "npm run test:oss:watch",
"test:watch:all": "npm run test:oss:watch:all",
"test:oss": "jest",
"test:oss:watch": "jest --watch",
"test:oss:watch:all": "jest --watchAll",
"test:bit": "jest --config ../../bitwarden_license/bit-desktop/jest.config.js",
"test:bit:watch": "jest --config ../../bitwarden_license/bit-desktop/jest.config.js --watch",
"test:bit:watch:all": "jest --config ../../bitwarden_license/bit-desktop/jest.config.js --watchAll"
}
}

View File

@@ -20,11 +20,17 @@
"cwd": "apps/desktop"
},
"configurations": {
"development": {
"oss": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name main"
},
"oss-dev": {
"command": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name main"
},
"production": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name main"
"commercial": {
"command": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main"
},
"commercial-dev": {
"command": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main"
}
}
},
@@ -36,11 +42,17 @@
"cwd": "apps/desktop"
},
"configurations": {
"development": {
"oss": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name preload"
},
"oss-dev": {
"command": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name preload"
},
"production": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name preload"
"commercial": {
"command": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name preload"
},
"commercial-dev": {
"command": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name preload"
}
}
},
@@ -52,11 +64,17 @@
"cwd": "apps/desktop"
},
"configurations": {
"development": {
"oss": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name renderer"
},
"oss-dev": {
"command": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer"
},
"production": {
"command": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name renderer"
"commercial": {
"command": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name renderer"
},
"commercial-dev": {
"command": "cross-env NODE_ENV=development webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name renderer"
}
}
},
@@ -73,18 +91,32 @@
]
},
"configurations": {
"development": {
"oss": {
"commands": [
"nx run desktop:build-main --configuration=development",
"nx run desktop:build-preload --configuration=development",
"nx run desktop:build-renderer --configuration=development"
"nx run desktop:build-main --configuration=oss",
"nx run desktop:build-preload --configuration=oss",
"nx run desktop:build-renderer --configuration=oss"
]
},
"production": {
"oss-dev": {
"commands": [
"nx run desktop:build-main --configuration=production",
"nx run desktop:build-preload --configuration=production",
"nx run desktop:build-renderer --configuration=production"
"nx run desktop:build-main --configuration=oss-dev",
"nx run desktop:build-preload --configuration=oss-dev",
"nx run desktop:build-renderer --configuration=oss-dev"
]
},
"commercial": {
"commands": [
"nx run desktop:build-main --configuration=commercial",
"nx run desktop:build-preload --configuration=commercial",
"nx run desktop:build-renderer --configuration=commercial"
]
},
"commercial-dev": {
"commands": [
"nx run desktop:build-main --configuration=commercial-dev",
"nx run desktop:build-preload --configuration=commercial-dev",
"nx run desktop:build-renderer --configuration=commercial-dev"
]
}
}
@@ -102,6 +134,14 @@
"outputs": ["{workspaceRoot}/coverage/apps/desktop"],
"options": {
"jestConfig": "apps/desktop/jest.config.js"
},
"configurations": {
"oss": {
"jestConfig": "apps/desktop/jest.config.js"
},
"commercial": {
"jestConfig": "bitwarden_license/bit-desktop/jest.config.js"
}
}
},
"lint": {

View File

@@ -0,0 +1,22 @@
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("../../tsconfig.base");
const sharedConfig = require("../../libs/shared/jest.config.angular");
/** @type {import('jest').Config} */
module.exports = {
...sharedConfig,
displayName: "bit-desktop",
preset: "jest-preset-angular",
setupFilesAfterEnv: ["<rootDir>/../../apps/desktop/test.setup.ts"],
moduleNameMapper: pathsToModuleNameMapper(
{ "@bitwarden/common/spec": ["libs/common/spec"], ...(compilerOptions?.paths ?? {}) },
{
prefix: "<rootDir>/../../",
},
),
testMatch: ["**/+(*.)+(spec).+(ts)"],
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.spec.ts", "!src/**/index.ts"],
coverageDirectory: "<rootDir>/../../coverage/bitwarden_license/bit-desktop",
};

View File

@@ -9,14 +9,21 @@ module.exports = (webpackConfig, context) => {
return buildConfig({
configName: "Commercial",
renderer: {
entry: "",
entryModule: "",
tsConfig: "",
entry: path.resolve(__dirname, "src/app/main.ts"),
entryModule: "src/app/app.module#AppModule",
tsConfig: path.resolve(
context.context.root,
"bitwarden_license/bit-desktop/tsconfig.renderer.json",
),
},
main: {
entry: path.resolve(__dirname, "src/entry.ts"),
tsConfig: path.resolve(context.context.root, "bitwarden_license/bit-desktop/tsconfig.json"),
},
preload: {
entry: path.resolve(__dirname, "src/preload.ts"),
tsConfig: path.resolve(context.context.root, "bitwarden_license/bit-desktop/tsconfig.json"),
},
outputPath: path.resolve(context.context.root, context.options.outputPath),
});
} else {