feat(schematics): add skipInstall and skipGit options
This commit is contained in:
parent
579750be73
commit
cb79dec084
@ -14,7 +14,6 @@ export function newProject(): void {
|
|||||||
cleanup();
|
cleanup();
|
||||||
if (!directoryExists('./tmp/proj_backup')) {
|
if (!directoryExists('./tmp/proj_backup')) {
|
||||||
runNgNew('--collection=@nrwl/schematics --npmScope=proj');
|
runNgNew('--collection=@nrwl/schematics --npmScope=proj');
|
||||||
execSync('npm i', {cwd: `./tmp/${projectName}`});
|
|
||||||
copyMissingPackages();
|
copyMissingPackages();
|
||||||
execSync('mv ./tmp/proj ./tmp/proj_backup');
|
execSync('mv ./tmp/proj ./tmp/proj_backup');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import {apply, branchAndMerge, chain, mergeWith, Rule, template, url} from '@angular-devkit/schematics';
|
import {apply, branchAndMerge, chain, mergeWith, Rule, template, url, SchematicContext} from '@angular-devkit/schematics';
|
||||||
import {Schema} from './schema';
|
import {Schema} from './schema';
|
||||||
import {strings} from '@angular-devkit/core';
|
import {strings} from '@angular-devkit/core';
|
||||||
|
import {RepositoryInitializerTask, NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
|
||||||
import {libVersions} from '../utility/lib-versions';
|
import {libVersions} from '../utility/lib-versions';
|
||||||
import {wrapIntoFormat} from '../utility/tasks';
|
import {wrapIntoFormat} from '../utility/tasks';
|
||||||
|
|
||||||
export default function(options: Schema): Rule {
|
export default function(options: Schema): Rule {
|
||||||
return wrapIntoFormat(() => {
|
return wrapIntoFormat((context: SchematicContext) => {
|
||||||
|
addSkipInstallAndSkipGit(options, context);
|
||||||
|
|
||||||
const npmScope = options.npmScope ? options.npmScope : options.name;
|
const npmScope = options.npmScope ? options.npmScope : options.name;
|
||||||
const templateSource = apply(url('./files'), [
|
const templateSource = apply(url('./files'), [
|
||||||
template({
|
template({
|
||||||
@ -19,3 +22,13 @@ export default function(options: Schema): Rule {
|
|||||||
return chain([branchAndMerge(chain([mergeWith(templateSource)]))]);
|
return chain([branchAndMerge(chain([mergeWith(templateSource)]))]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSkipInstallAndSkipGit(options: Schema, context: SchematicContext) {
|
||||||
|
let packageTask;
|
||||||
|
if (!options.skipInstall) {
|
||||||
|
packageTask = context.addTask(new NodePackageInstallTask(options.directory));
|
||||||
|
}
|
||||||
|
if (!options.skipGit) {
|
||||||
|
context.addTask(new RepositoryInitializerTask(options.directory, options.commit), packageTask ? [packageTask] : []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -6,4 +6,7 @@ export interface Schema {
|
|||||||
prefix?: string;
|
prefix?: string;
|
||||||
style?: string;
|
style?: string;
|
||||||
minimal?: boolean;
|
minimal?: boolean;
|
||||||
|
skipInstall?: boolean;
|
||||||
|
commit?: { name: string, email: string, message?: string };
|
||||||
|
skipGit?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,43 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Npm scope for importing libs."
|
"description": "Npm scope for importing libs."
|
||||||
},
|
},
|
||||||
|
"skipInstall": {
|
||||||
|
"description": "Skip installing dependency packages.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"skipGit": {
|
||||||
|
"description": "Skip initializing a git repository.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"alias": "sg"
|
||||||
|
},
|
||||||
|
"commit": {
|
||||||
|
"description": "Initial repository commit information.",
|
||||||
|
"default": null,
|
||||||
|
"oneOf": [
|
||||||
|
{ "type": "null" },
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "email"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"email"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -15,6 +15,6 @@ export class FormatFiles implements TaskConfigurationGenerator<any> {
|
|||||||
export function wrapIntoFormat(fn: Function): any {
|
export function wrapIntoFormat(fn: Function): any {
|
||||||
return (host: Tree, context: SchematicContext) => {
|
return (host: Tree, context: SchematicContext) => {
|
||||||
context.addTask(new FormatFiles());
|
context.addTask(new FormatFiles());
|
||||||
return fn()(host, context);
|
return fn(context)(host, context);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
rm -rf build
|
rm -rf build
|
||||||
ngc
|
./node_modules/.bin/ngc
|
||||||
rsync -a --exclude=*.ts packages/ build/packages
|
rsync -a --exclude=*.ts packages/ build/packages
|
||||||
chmod +x build/packages/schematics/bin/create-nx-workspace.js
|
chmod +x build/packages/schematics/bin/create-nx-workspace.js
|
||||||
chmod +x build/packages/schematics/src/command-line/nx.js
|
chmod +x build/packages/schematics/src/command-line/nx.js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user