-
Notifications
You must be signed in to change notification settings - Fork 1.5k
build(cli): integrate nx #16648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,134
โ332
Merged
build(cli): integrate nx #16648
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c61d4a8
build(cli): integrate nx
addisonbeck 537d6d7
refactor(project.json): rename "bit" builds to "commercial"
addisonbeck a72cd0e
refactor(webpack.base): implement DEFAULT_PARAMS
addisonbeck 17675f1
refactor(webpack.base): move DEFAULT_PARAMS out of buildConfig
addisonbeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"name": "cli", | ||
"projectType": "application", | ||
"sourceRoot": "apps/cli/src", | ||
"tags": ["scope:cli", "type:app"], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/webpack:webpack", | ||
"outputs": ["{options.outputPath}"], | ||
"defaultConfiguration": "oss-dev", | ||
"options": { | ||
"outputPath": "dist/apps/cli", | ||
"webpackConfig": "apps/cli/webpack.config.js", | ||
"tsConfig": "apps/cli/tsconfig.json", | ||
"main": "apps/cli/src/bw.ts", | ||
"target": "node", | ||
"compiler": "tsc" | ||
}, | ||
"configurations": { | ||
"oss": { | ||
"mode": "production", | ||
"outputPath": "dist/apps/cli/oss" | ||
}, | ||
"oss-dev": { | ||
"mode": "development", | ||
"outputPath": "dist/apps/cli/oss-dev" | ||
}, | ||
"commercial": { | ||
"mode": "production", | ||
"outputPath": "dist/apps/cli/commercial", | ||
"webpackConfig": "bitwarden_license/bit-cli/webpack.config.js", | ||
"main": "bitwarden_license/bit-cli/src/bw.ts", | ||
"tsConfig": "bitwarden_license/bit-cli/tsconfig.json" | ||
}, | ||
"commercial-dev": { | ||
"mode": "development", | ||
"outputPath": "dist/apps/cli/commercial-dev", | ||
"webpackConfig": "bitwarden_license/bit-cli/webpack.config.js", | ||
"main": "bitwarden_license/bit-cli/src/bw.ts", | ||
"tsConfig": "bitwarden_license/bit-cli/tsconfig.json" | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"executor": "@nx/webpack:webpack", | ||
"defaultConfiguration": "oss-dev", | ||
"options": { | ||
"outputPath": "dist/apps/cli", | ||
"webpackConfig": "apps/cli/webpack.config.js", | ||
"tsConfig": "apps/cli/tsconfig.json", | ||
"main": "apps/cli/src/bw.ts", | ||
"target": "node", | ||
"compiler": "tsc", | ||
"watch": true | ||
}, | ||
"configurations": { | ||
"oss-dev": { | ||
"mode": "development", | ||
"outputPath": "dist/apps/cli/oss-dev" | ||
}, | ||
"commercial-dev": { | ||
"mode": "development", | ||
"outputPath": "dist/apps/cli/commercial-dev", | ||
"webpackConfig": "bitwarden_license/bit-cli/webpack.config.js", | ||
"main": "bitwarden_license/bit-cli/src/bw.ts", | ||
"tsConfig": "bitwarden_license/bit-cli/tsconfig.json" | ||
} | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "apps/cli/jest.config.js" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["apps/cli/**/*.ts"] | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
const path = require("path"); | ||
const { buildConfig } = require("./webpack.base"); | ||
|
||
module.exports = buildConfig({ | ||
configName: "OSS", | ||
entry: "./src/bw.ts", | ||
tsConfig: "./tsconfig.json", | ||
}); | ||
module.exports = (webpackConfig, context) => { | ||
// Detect if called by Nx (context parameter exists) | ||
const isNxBuild = context && context.options; | ||
|
||
if (isNxBuild) { | ||
// Nx build configuration | ||
const mode = context.options.mode || "development"; | ||
if (process.env.NODE_ENV == null) { | ||
process.env.NODE_ENV = mode; | ||
} | ||
const ENV = (process.env.ENV = process.env.NODE_ENV); | ||
|
||
return buildConfig({ | ||
configName: "OSS", | ||
entry: context.options.main || "apps/cli/src/bw.ts", | ||
tsConfig: "tsconfig.base.json", | ||
outputPath: path.resolve(context.context.root, context.options.outputPath), | ||
mode: mode, | ||
env: ENV, | ||
modulesPath: [path.resolve("node_modules")], | ||
localesPath: "apps/cli/src/locales", | ||
externalsModulesDir: "node_modules", | ||
watch: context.options.watch || false, | ||
}); | ||
} else { | ||
// npm build configuration | ||
if (process.env.NODE_ENV == null) { | ||
process.env.NODE_ENV = "development"; | ||
} | ||
const ENV = (process.env.ENV = process.env.NODE_ENV); | ||
const mode = ENV; | ||
|
||
return buildConfig({ | ||
configName: "OSS", | ||
entry: "./src/bw.ts", | ||
tsConfig: "./tsconfig.json", | ||
outputPath: path.resolve(__dirname, "build"), | ||
mode: mode, | ||
env: ENV, | ||
modulesPath: [path.resolve("../../node_modules")], | ||
localesPath: "./src/locales", | ||
externalsModulesDir: "../../node_modules", | ||
}); | ||
Comment on lines
+36
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of these are the default values in webpack.base, but they won't be for long so I was verbose with these args. |
||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
const path = require("path"); | ||
const { buildConfig } = require("../../apps/cli/webpack.base"); | ||
|
||
module.exports = buildConfig({ | ||
configName: "Commercial", | ||
entry: "../../bitwarden_license/bit-cli/src/bw.ts", | ||
tsConfig: "../../bitwarden_license/bit-cli/tsconfig.json", | ||
}); | ||
module.exports = (webpackConfig, context) => { | ||
// Detect if called by Nx (context parameter exists) | ||
const isNxBuild = context && context.options; | ||
|
||
if (isNxBuild) { | ||
// Nx build configuration | ||
const mode = context.options.mode || "development"; | ||
if (process.env.NODE_ENV == null) { | ||
process.env.NODE_ENV = mode; | ||
} | ||
const ENV = (process.env.ENV = process.env.NODE_ENV); | ||
|
||
return buildConfig({ | ||
configName: "Commercial", | ||
entry: context.options.main || "bitwarden_license/bit-cli/src/bw.ts", | ||
tsConfig: "tsconfig.base.json", | ||
outputPath: path.resolve(context.context.root, context.options.outputPath), | ||
mode: mode, | ||
env: ENV, | ||
modulesPath: [path.resolve("node_modules")], | ||
localesPath: "apps/cli/src/locales", | ||
externalsModulesDir: "node_modules", | ||
watch: context.options.watch || false, | ||
}); | ||
} else { | ||
// npm build configuration | ||
if (process.env.NODE_ENV == null) { | ||
process.env.NODE_ENV = "development"; | ||
} | ||
const ENV = (process.env.ENV = process.env.NODE_ENV); | ||
const mode = ENV; | ||
|
||
return buildConfig({ | ||
configName: "Commercial", | ||
entry: "../../bitwarden_license/bit-cli/src/bw.ts", | ||
tsConfig: "../../bitwarden_license/bit-cli/tsconfig.json", | ||
outputPath: path.resolve(__dirname, "../../apps/cli/build"), | ||
mode: mode, | ||
env: ENV, | ||
modulesPath: [path.resolve("../../node_modules")], | ||
localesPath: "../../apps/cli/src/locales", | ||
externalsModulesDir: "../../node_modules", | ||
}); | ||
} | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: instead of putting the default values interspersed in the code
could we move it all to one place?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Really cleans this up a lot. Implemented as suggested on a72cd0e.