fix(nx): remove --yarn flag

This commit is contained in:
Victor Savkin 2019-02-18 17:34:40 -05:00
parent f6224ffca5
commit 35498d13bf
8 changed files with 24 additions and 62 deletions

View File

@ -12,12 +12,11 @@ ng generate ng-new ...
### Options
| Name | Alias | Description | Type | Default value |
| ---------------- | ----- | ---------------------------------------------- | ------- | ------------- |
| ------------- | ----- | ---------------------------------------------- | ------- | ------------- |
| `name` | | The name of the workspace. | string | `undefined` |
| `style` | | The file extension to be used for style files. | string | `css` |
| `directory` | | The directory name to create the workspace in. | string | `` |
| `npmScope` | | Npm scope for importing libs. | string | `undefined` |
| `skipInstall` | | Skip installing dependency packages. | boolean | `false` |
| `skipGit` | g | Skip initializing a git repository. | boolean | `false` |
| `packageManager` | | Package manager used in the project. | string | `undefined` |
| `commit` | | Initial repository commit information. | boolean | `true` |

View File

@ -12,7 +12,7 @@ import { angularCliVersion } from '../src/lib-versions';
const parsedArgs = yargsParser(process.argv, {
string: ['directory'],
boolean: ['yarn', 'bazel', 'help']
boolean: ['help']
});
if (parsedArgs.help) {
@ -32,8 +32,6 @@ if (parsedArgs.help) {
`);
process.exit(0);
}
const useYarn = parsedArgs.yarn;
const schematicsTool = {
name: 'Schematics',
packageName: '@nrwl/schematics'
@ -44,6 +42,13 @@ const bazelTool = {
};
const nxTool = parsedArgs.bazel ? bazelTool : schematicsTool;
let useYarn = true;
try {
execSync('yarn --version', { stdio: ['ignore', 'ignore', 'ignore'] });
} catch (e) {
useYarn = false;
}
if (!useYarn) {
try {
@ -110,24 +115,20 @@ if (useYarn) {
execSync('npm install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
}
const packageManagerOption = useYarn ? '--packageManager=yarn' : '';
// creating the app itself
const args = process.argv
.slice(2)
.filter(a => a !== '--yarn' && a !== '--bazel')
.map(a => `"${a}"`)
.join(' ');
console.log(
`ng new ${args} --collection=${nxTool.packageName} ${packageManagerOption}`
);
console.log(`ng new ${args} --collection=${nxTool.packageName}`);
execSync(
`${path.join(
tmpDir,
'node_modules',
'.bin',
'ng'
)} new ${args} --collection=${nxTool.packageName} ${packageManagerOption}`,
)} new ${args} --collection=${nxTool.packageName}`,
{
stdio: [0, 1, 2]
}

View File

@ -5,7 +5,7 @@
"rootDir": ".",
"module": "commonjs",
"target": "es5",
"types": ["jasmine", "node"]
"types": ["node"]
},
"include": ["**/*.ts"]
}

View File

@ -8,8 +8,7 @@
"typescriptMismatch": false,
"versionMismatch": false
},
"defaultCollection": "@nrwl/schematics"<% if(packageManager) { %>,<% } %>
<% if(packageManager) { %>"packageManager": "<%= packageManager %>"<% } %>
"defaultCollection": "@nrwl/schematics"
},
"schematics": {<% if (style !== 'css') { %>
"@nrwl/schematics:application": {

View File

@ -6,7 +6,6 @@
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"node"
]
},

View File

@ -75,33 +75,10 @@ describe('app', () => {
]);
});
it('should not set package manager by default', () => {
const treeNoPackages = schematicRunner.runSchematic(
'ng-new',
{ name: 'proj' },
projectTree
);
expect(
JSON.parse(treeNoPackages.readContent('/proj/angular.json')).cli
.packageManager
).toBeUndefined();
});
it('should set package manager when provided', () => {
const tree = schematicRunner.runSchematic(
'ng-new',
{ name: 'proj', packageManager: 'yarn' },
projectTree
);
expect(
JSON.parse(tree.readContent('/proj/angular.json')).cli.packageManager
).toEqual('yarn');
});
it('should configure the project to use style argument', () => {
const tree = schematicRunner.runSchematic(
'ng-new',
{ name: 'proj', packageManager: 'yarn', style: 'scss' },
{ name: 'proj', style: 'scss' },
projectTree
);
expect(

View File

@ -6,7 +6,6 @@ export interface Schema {
npmScope?: string;
skipInstall?: boolean;
skipGit?: boolean;
packageManager?: string;
style?: string;
commit?: { name: string; email: string; message?: string };
}

View File

@ -52,18 +52,6 @@
"default": false,
"alias": "g"
},
"packageManager": {
"type": "string",
"description": "Package manager used in the project.",
"x-prompt": {
"message": "Which Package Manager would you like to use for your workspace?",
"type": "list",
"items": [
{ "value": "npm", "label": "" },
{ "value": "yarn", "label": "Yarn (https://yarnpkg.com/)" }
]
}
},
"commit": {
"description": "Initial repository commit information.",
"oneOf": [