mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
chore(schematics): add path to schematics
This commit is contained in:
parent
38c502fccf
commit
91f9845661
4 changed files with 1365 additions and 9 deletions
|
|
@ -16,6 +16,7 @@
|
|||
"dependencies": {
|
||||
"@angular-devkit/core": "^7.3.9",
|
||||
"@angular-devkit/schematics": "^7.3.9",
|
||||
"@schematics/angular": "^7.3.9",
|
||||
"@types/jasmine": "^3.0.0",
|
||||
"@types/node": "^8.0.31",
|
||||
"jasmine": "^3.0.0",
|
||||
|
|
|
|||
|
|
@ -1,21 +1,41 @@
|
|||
import {apply, mergeWith, Rule, SchematicContext, template, Tree, url} from '@angular-devkit/schematics';
|
||||
import {
|
||||
apply,
|
||||
mergeWith,
|
||||
move,
|
||||
Rule,
|
||||
SchematicContext,
|
||||
SchematicsException,
|
||||
template,
|
||||
Tree,
|
||||
url
|
||||
} from '@angular-devkit/schematics';
|
||||
import {strings} from '@angular-devkit/core';
|
||||
import {strings} from 'underscore.string';
|
||||
import {buildDefaultPath} from '@schematics/angular/utility/project';
|
||||
import {parseName} from '@schematics/angular/utility/parse-name';
|
||||
|
||||
// const TPL = './tpl/';
|
||||
|
||||
// You don't have to export the function as default. You can also have more than one rule factory
|
||||
// per file.
|
||||
export function jo(_options: any, _context: SchematicContext): Rule {
|
||||
export default function jo(_options: any): Rule {
|
||||
return (tree: Tree, _context: SchematicContext) => {
|
||||
console.log(tree, _context);
|
||||
const workspaceConfigBuffer = tree.read('angular.json');
|
||||
if (!workspaceConfigBuffer) {
|
||||
throw new SchematicsException('Not an angular cli workspace');
|
||||
}
|
||||
const workspaceConfig = JSON.parse(workspaceConfigBuffer.toString());
|
||||
const projectName = _options.project || workspaceConfig.defaultProject;
|
||||
const project = workspaceConfig.projects[projectName];
|
||||
|
||||
const defaultProjectPath = buildDefaultPath(project);
|
||||
const parsedPath = parseName(defaultProjectPath, _options.name);
|
||||
const {name, path} = parsedPath;
|
||||
|
||||
const sourceTemplates = url('./files');
|
||||
const sourceParameterizedTemplates = apply(sourceTemplates, [
|
||||
template({
|
||||
..._options,
|
||||
...strings
|
||||
})
|
||||
...strings,
|
||||
name
|
||||
}),
|
||||
move(path + '/' + strings.dasherize(name))
|
||||
]);
|
||||
return mergeWith(sourceParameterizedTemplates);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,17 @@
|
|||
"index": 0
|
||||
},
|
||||
"x-prompt": "Enter name prompt x"
|
||||
},
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project.",
|
||||
"aliases": ["p"]
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"format": "path",
|
||||
"description": "The path to create the component.",
|
||||
"visible": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
|||
1324
tools/schematics/yarn.lock
Normal file
1324
tools/schematics/yarn.lock
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue