diff --git a/docs/api-schematics/ng-new.md b/docs/api-schematics/ng-new.md index 39e978b3fb..c2dd6559b9 100644 --- a/docs/api-schematics/ng-new.md +++ b/docs/api-schematics/ng-new.md @@ -11,13 +11,12 @@ 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` | +| 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` | +| `commit` | | Initial repository commit information. | boolean | `true` | diff --git a/packages/schematics/bin/create-nx-workspace.ts b/packages/schematics/bin/create-nx-workspace.ts index 21269665fd..aa961d1c47 100644 --- a/packages/schematics/bin/create-nx-workspace.ts +++ b/packages/schematics/bin/create-nx-workspace.ts @@ -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] } diff --git a/packages/schematics/src/collection/ng-add/files/tools/tsconfig.tools.json b/packages/schematics/src/collection/ng-add/files/tools/tsconfig.tools.json index ff5779958f..82bd1f098d 100644 --- a/packages/schematics/src/collection/ng-add/files/tools/tsconfig.tools.json +++ b/packages/schematics/src/collection/ng-add/files/tools/tsconfig.tools.json @@ -5,7 +5,7 @@ "rootDir": ".", "module": "commonjs", "target": "es5", - "types": ["jasmine", "node"] + "types": ["node"] }, "include": ["**/*.ts"] } diff --git a/packages/schematics/src/collection/ng-new/files/__directory__/angular.json b/packages/schematics/src/collection/ng-new/files/__directory__/angular.json index 1aeda5c9b0..90e767aac4 100644 --- a/packages/schematics/src/collection/ng-new/files/__directory__/angular.json +++ b/packages/schematics/src/collection/ng-new/files/__directory__/angular.json @@ -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": { @@ -19,4 +18,4 @@ "style": "<%= style %>" } <% } %>} -} \ No newline at end of file +} diff --git a/packages/schematics/src/collection/ng-new/files/__directory__/tools/tsconfig.tools.json b/packages/schematics/src/collection/ng-new/files/__directory__/tools/tsconfig.tools.json index a70e2f01e6..c74be19b06 100644 --- a/packages/schematics/src/collection/ng-new/files/__directory__/tools/tsconfig.tools.json +++ b/packages/schematics/src/collection/ng-new/files/__directory__/tools/tsconfig.tools.json @@ -6,11 +6,10 @@ "module": "commonjs", "target": "es5", "types": [ - "jasmine", "node" ] }, "include": [ "**/*.ts" ] -} \ No newline at end of file +} diff --git a/packages/schematics/src/collection/ng-new/ng-new.spec.ts b/packages/schematics/src/collection/ng-new/ng-new.spec.ts index 9cc186f476..d14141184d 100644 --- a/packages/schematics/src/collection/ng-new/ng-new.spec.ts +++ b/packages/schematics/src/collection/ng-new/ng-new.spec.ts @@ -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( diff --git a/packages/schematics/src/collection/ng-new/schema.d.ts b/packages/schematics/src/collection/ng-new/schema.d.ts index d262f0a619..89f184af90 100644 --- a/packages/schematics/src/collection/ng-new/schema.d.ts +++ b/packages/schematics/src/collection/ng-new/schema.d.ts @@ -6,7 +6,6 @@ export interface Schema { npmScope?: string; skipInstall?: boolean; skipGit?: boolean; - packageManager?: string; style?: string; commit?: { name: string; email: string; message?: string }; } diff --git a/packages/schematics/src/collection/ng-new/schema.json b/packages/schematics/src/collection/ng-new/schema.json index 67102a2b4e..cd07589d85 100644 --- a/packages/schematics/src/collection/ng-new/schema.json +++ b/packages/schematics/src/collection/ng-new/schema.json @@ -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": [