Skip to content

Commit

Permalink
Revert "feat: add local package.json to schematics collection (#298)"
Browse files Browse the repository at this point in the history
This reverts commit 33b85fa.
  • Loading branch information
vsavkin committed Nov 9, 2018
1 parent a5049b4 commit 070e22a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 99 deletions.
71 changes: 0 additions & 71 deletions apps/angular-console-e2e/src/integration/local-collection.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,7 @@ export class SchematicComponent implements OnInit {
}

getPrefix(schematic: Schematic) {
return [
`${schematic.collection.startsWith('.') ? '.' : schematic.collection}:${
schematic.name
}`
];
return [`${schematic.collection}:${schematic.name}`];
}

path() {
Expand Down
14 changes: 4 additions & 10 deletions server/src/api/read-schematic-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ interface Schematic {
export function readAllSchematicCollections(basedir: string) {
const nodeModulesDir = path.join(basedir, 'node_modules');
const packages = listOfUnnestedNpmPackages(nodeModulesDir);
const relativeRootPath = './..';
const schematicCollections = [relativeRootPath, ...packages].filter(p => {
const schematicCollections = packages.filter(p => {
try {
return !!readJsonFile(path.join(p, 'package.json'), nodeModulesDir).json
.schematics;
Expand All @@ -48,13 +47,12 @@ export function readAllSchematicCollections(basedir: string) {
}
});
return schematicCollections
.map(c => readSchematicCollections(nodeModulesDir, relativeRootPath, c))
.map(c => readSchematicCollections(nodeModulesDir, c))
.filter(collection => !!collection && collection.schematics.length > 0);
}

function readSchematicCollections(
basedir: string,
rootCollection: string,
collectionName: string
): SchematicCollection {
try {
Expand All @@ -66,12 +64,8 @@ function readSchematicCollections(
packageJson.json.schematics,
path.dirname(packageJson.path)
);
const name =
collectionName === rootCollection
? `.${packageJson.json.name}`
: collectionName;
const schematicCollection = {
name,
name: collectionName,
schematics: [] as Schematic[]
};
Object.entries(collection.json.schematics).forEach(([k, v]: [any, any]) => {
Expand All @@ -83,7 +77,7 @@ function readSchematicCollections(

schematicCollection.schematics.push({
name: k,
collection: name,
collection: collectionName,
schema: normalizeSchema(schematicSchema.json),
description: v.description
});
Expand Down
13 changes: 0 additions & 13 deletions tools/scripts/set-up-e2e-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ shell.rm('-rf', path.join(tmp, 'proj-extensions'));
shell.mkdir(path.join(tmp, 'proj-extensions'));
shell.rm('-rf', path.join(tmp, 'proj-no-node-modules'));
shell.mkdir(path.join(tmp, 'proj-no-node-modules'));
shell.rm('-rf', path.join(tmp, 'proj-local-collection'));
shell.mkdir(path.join(tmp, 'proj-local-collection'));

shell.rm('-rf', path.join(tmp, 'ng'));
shell.mkdir(path.join(tmp, 'ng'));
cp.execSync('yarn add @angular/[email protected]', {cwd: path.join(tmp, 'ng')});
cp.execSync('yarn add @angular-devkit/schematics-cli @schematics/schematics', {cwd: path.join(tmp, 'ng')});
cp.execSync('yarn add json', {cwd: path.join(tmp, 'ng')});

cp.execSync('ng config -g cli.packageManager yarn');
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj --collection=@schematics/angular --directory=proj --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] });
Expand All @@ -32,12 +28,3 @@ shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions');

cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj-no-node-modules --collection=@schematics/angular --directory=proj-no-node-modules --skip-install --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] });
shell.mv(path.join(tmp, 'proj-no-node-modules'), './tmp/proj-no-node-modules');

cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/ng new proj-local-collection --collection=@schematics/angular --directory=proj-local-collection --skip-git --no-interactive`, { cwd: tmp, stdio: [0, 1, 2] });
shell.mv(path.join(tmp, 'proj-local-collection'), './tmp/proj-local-collection');
shell.cd('./tmp/proj-local-collection');
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/schematics schematic --name=schematics .`);
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/json -I -f package.json -e 'this.schematics="./schematics/src/collection.json"'`);
cp.execSync('ng config cli.defaultCollection schematics')
shell.cd('schematics');
cp.execSync(`${path.join(tmp, 'ng')}/node_modules/.bin/tsc`);

0 comments on commit 070e22a

Please sign in to comment.