Skip to content

Commit

Permalink
feat(bazel): Add correct dependencies to package.json (#405)
Browse files Browse the repository at this point in the history
* feat(bazel): Add correct dependencies to package.json

Only allow valid Bazel workspace names to avoid confusion
  • Loading branch information
mrmeku authored Apr 6, 2018
1 parent 871129e commit eca5259
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"license": "MIT",
"schematics": "./src/collection.json",
"dependencies": {
"@ngrx/schematics": "5.2.0",
"@schematics/angular": "0.4.6",
"app-root-path": "^2.0.1",
"npm-run-all": "4.1.2",
"semver": "5.4.1",
"tmp": "0.0.33",
"yargs-parser": "9.0.2"
Expand Down
7 changes: 7 additions & 0 deletions packages/bazel/src/collection/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import {
import { libVersions } from '../../lib-versions';

export default function(options: Schema): Rule {
if (!/^\w+$/.test(options.name)) {
throw new Error(
`${options.name} is invalid for a bazel workspace.\n` +
'Your workspace name must contain only alphanumeric characters and underscores.'
);
}

return (host: Tree, context: SchematicContext) => {
addTasks(options, context);
const npmScope = options.npmScope ? options.npmScope : options.name;
Expand Down
10 changes: 10 additions & 0 deletions packages/schematics/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ if (!useYarn) {

const projectName = parsedArgs._[2];

if (parsedArgs.bazel) {
if (!/^\w+$/.test(projectName)) {
console.error(
`${projectName} is invalid for a bazel workspace.\n` +
'Your workspace name must contain only alphanumeric characters and underscores.'
);
process.exit(1);
}
}

// check that the workspace name is passed in
if (!projectName) {
console.error(
Expand Down

0 comments on commit eca5259

Please sign in to comment.