fix(nx): remove --yarn flag
This commit is contained in:
parent
f6224ffca5
commit
35498d13bf
@ -11,13 +11,12 @@ ng generate ng-new ...
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Alias | Description | Type | Default value |
|
| Name | Alias | Description | Type | Default value |
|
||||||
| ---------------- | ----- | ---------------------------------------------- | ------- | ------------- |
|
| ------------- | ----- | ---------------------------------------------- | ------- | ------------- |
|
||||||
| `name` | | The name of the workspace. | string | `undefined` |
|
| `name` | | The name of the workspace. | string | `undefined` |
|
||||||
| `style` | | The file extension to be used for style files. | string | `css` |
|
| `style` | | The file extension to be used for style files. | string | `css` |
|
||||||
| `directory` | | The directory name to create the workspace in. | string | `` |
|
| `directory` | | The directory name to create the workspace in. | string | `` |
|
||||||
| `npmScope` | | Npm scope for importing libs. | string | `undefined` |
|
| `npmScope` | | Npm scope for importing libs. | string | `undefined` |
|
||||||
| `skipInstall` | | Skip installing dependency packages. | boolean | `false` |
|
| `skipInstall` | | Skip installing dependency packages. | boolean | `false` |
|
||||||
| `skipGit` | g | Skip initializing a git repository. | 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` |
|
||||||
| `commit` | | Initial repository commit information. | boolean | `true` |
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { angularCliVersion } from '../src/lib-versions';
|
|||||||
|
|
||||||
const parsedArgs = yargsParser(process.argv, {
|
const parsedArgs = yargsParser(process.argv, {
|
||||||
string: ['directory'],
|
string: ['directory'],
|
||||||
boolean: ['yarn', 'bazel', 'help']
|
boolean: ['help']
|
||||||
});
|
});
|
||||||
|
|
||||||
if (parsedArgs.help) {
|
if (parsedArgs.help) {
|
||||||
@ -32,8 +32,6 @@ if (parsedArgs.help) {
|
|||||||
`);
|
`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
const useYarn = parsedArgs.yarn;
|
|
||||||
|
|
||||||
const schematicsTool = {
|
const schematicsTool = {
|
||||||
name: 'Schematics',
|
name: 'Schematics',
|
||||||
packageName: '@nrwl/schematics'
|
packageName: '@nrwl/schematics'
|
||||||
@ -44,6 +42,13 @@ const bazelTool = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const nxTool = parsedArgs.bazel ? bazelTool : schematicsTool;
|
const nxTool = parsedArgs.bazel ? bazelTool : schematicsTool;
|
||||||
|
let useYarn = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
execSync('yarn --version', { stdio: ['ignore', 'ignore', 'ignore'] });
|
||||||
|
} catch (e) {
|
||||||
|
useYarn = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!useYarn) {
|
if (!useYarn) {
|
||||||
try {
|
try {
|
||||||
@ -110,24 +115,20 @@ if (useYarn) {
|
|||||||
execSync('npm install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
|
execSync('npm install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const packageManagerOption = useYarn ? '--packageManager=yarn' : '';
|
|
||||||
|
|
||||||
// creating the app itself
|
// creating the app itself
|
||||||
const args = process.argv
|
const args = process.argv
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.filter(a => a !== '--yarn' && a !== '--bazel')
|
.filter(a => a !== '--yarn' && a !== '--bazel')
|
||||||
.map(a => `"${a}"`)
|
.map(a => `"${a}"`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
console.log(
|
console.log(`ng new ${args} --collection=${nxTool.packageName}`);
|
||||||
`ng new ${args} --collection=${nxTool.packageName} ${packageManagerOption}`
|
|
||||||
);
|
|
||||||
execSync(
|
execSync(
|
||||||
`${path.join(
|
`${path.join(
|
||||||
tmpDir,
|
tmpDir,
|
||||||
'node_modules',
|
'node_modules',
|
||||||
'.bin',
|
'.bin',
|
||||||
'ng'
|
'ng'
|
||||||
)} new ${args} --collection=${nxTool.packageName} ${packageManagerOption}`,
|
)} new ${args} --collection=${nxTool.packageName}`,
|
||||||
{
|
{
|
||||||
stdio: [0, 1, 2]
|
stdio: [0, 1, 2]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"types": ["jasmine", "node"]
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"]
|
"include": ["**/*.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,7 @@
|
|||||||
"typescriptMismatch": false,
|
"typescriptMismatch": false,
|
||||||
"versionMismatch": false
|
"versionMismatch": false
|
||||||
},
|
},
|
||||||
"defaultCollection": "@nrwl/schematics"<% if(packageManager) { %>,<% } %>
|
"defaultCollection": "@nrwl/schematics"
|
||||||
<% if(packageManager) { %>"packageManager": "<%= packageManager %>"<% } %>
|
|
||||||
},
|
},
|
||||||
"schematics": {<% if (style !== 'css') { %>
|
"schematics": {<% if (style !== 'css') { %>
|
||||||
"@nrwl/schematics:application": {
|
"@nrwl/schematics:application": {
|
||||||
@ -19,4 +18,4 @@
|
|||||||
"style": "<%= style %>"
|
"style": "<%= style %>"
|
||||||
}
|
}
|
||||||
<% } %>}
|
<% } %>}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,10 @@
|
|||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"types": [
|
"types": [
|
||||||
"jasmine",
|
|
||||||
"node"
|
"node"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"**/*.ts"
|
"**/*.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', () => {
|
it('should configure the project to use style argument', () => {
|
||||||
const tree = schematicRunner.runSchematic(
|
const tree = schematicRunner.runSchematic(
|
||||||
'ng-new',
|
'ng-new',
|
||||||
{ name: 'proj', packageManager: 'yarn', style: 'scss' },
|
{ name: 'proj', style: 'scss' },
|
||||||
projectTree
|
projectTree
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@ -6,7 +6,6 @@ export interface Schema {
|
|||||||
npmScope?: string;
|
npmScope?: string;
|
||||||
skipInstall?: boolean;
|
skipInstall?: boolean;
|
||||||
skipGit?: boolean;
|
skipGit?: boolean;
|
||||||
packageManager?: string;
|
|
||||||
style?: string;
|
style?: string;
|
||||||
commit?: { name: string; email: string; message?: string };
|
commit?: { name: string; email: string; message?: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,18 +52,6 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"alias": "g"
|
"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": {
|
"commit": {
|
||||||
"description": "Initial repository commit information.",
|
"description": "Initial repository commit information.",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user