From 4448ff56e30507fc69b9e1f755b6e6e7fe021692 Mon Sep 17 00:00:00 2001 From: Isaac Mann Date: Fri, 19 Jul 2019 14:17:46 -0400 Subject: [PATCH] chore: Move some schematics into @nrwl/angular --- packages/angular/collection.json | 21 +++++ .../component-cypress-spec.ts | 26 +++---- .../__componentFileName__.spec.ts__tmpl__ | 0 .../component-cypress-spec/schema.json | 0 .../component-story/component-story.ts | 19 +++-- .../__componentFileName__.stories.ts__tmpl__ | 0 .../schematics/component-story/schema.json | 0 .../src/schematics/stories}/schema.json | 0 .../src/schematics/stories/stories.spec.ts} | 37 +++++---- .../src/schematics/stories/stories.ts} | 32 ++------ packages/angular/src/utils/ast-utils.ts | 18 ++++- packages/angular/src/utils/testing.ts | 76 ++++++++++++++++++- packages/storybook/collection.json | 30 ++------ .../configuration.spec.ts} | 25 ++---- .../configuration.ts} | 12 +-- .../files/.storybook/addons.js | 0 .../files/.storybook/config.js | 0 .../files/.storybook/tsconfig.json | 0 .../schema.d.ts | 0 .../schema.json | 0 .../cypress-project.spec.ts} | 9 +-- .../cypress-project.ts} | 14 ++-- .../schema.json | 0 23 files changed, 184 insertions(+), 135 deletions(-) rename packages/{storybook => angular}/src/schematics/component-cypress-spec/component-cypress-spec.ts (93%) rename packages/{storybook => angular}/src/schematics/component-cypress-spec/files/__componentFileName__.spec.ts__tmpl__ (100%) rename packages/{storybook => angular}/src/schematics/component-cypress-spec/schema.json (100%) rename packages/{storybook => angular}/src/schematics/component-story/component-story.ts (96%) rename packages/{storybook => angular}/src/schematics/component-story/files/__componentFileName__.stories.ts__tmpl__ (100%) rename packages/{storybook => angular}/src/schematics/component-story/schema.json (100%) rename packages/{storybook/src/schematics/storybook-stories => angular/src/schematics/stories}/schema.json (100%) rename packages/{storybook/src/schematics/storybook-stories/storybook-stories.spec.ts => angular/src/schematics/stories/stories.spec.ts} (77%) rename packages/{storybook/src/schematics/storybook-stories/storybook-stories.ts => angular/src/schematics/stories/stories.ts} (90%) rename packages/storybook/src/schematics/{storybook-configure/storybook-configure.spec.ts => configuration/configuration.spec.ts} (84%) rename packages/storybook/src/schematics/{storybook-configure/storybook-configure.ts => configuration/configuration.ts} (88%) rename packages/storybook/src/schematics/{storybook-configure => configuration}/files/.storybook/addons.js (100%) rename packages/storybook/src/schematics/{storybook-configure => configuration}/files/.storybook/config.js (100%) rename packages/storybook/src/schematics/{storybook-configure => configuration}/files/.storybook/tsconfig.json (100%) rename packages/storybook/src/schematics/{storybook-configure => configuration}/schema.d.ts (100%) rename packages/storybook/src/schematics/{storybook-configure => configuration}/schema.json (100%) rename packages/storybook/src/schematics/{cypress-configure/cypress-configure.spec.ts => cypress-project/cypress-project.spec.ts} (85%) rename packages/storybook/src/schematics/{cypress-configure/cypress-configure.ts => cypress-project/cypress-project.ts} (90%) rename packages/storybook/src/schematics/{cypress-configure => cypress-project}/schema.json (100%) diff --git a/packages/angular/collection.json b/packages/angular/collection.json index f295c47e7b732..2dd5fb7af0ba4 100644 --- a/packages/angular/collection.json +++ b/packages/angular/collection.json @@ -52,6 +52,27 @@ "factory": "./src/schematics/upgrade-module/upgrade-module", "schema": "./src/schematics/upgrade-module/schema.json", "description": "Add an upgrade module" + }, + + "stories": { + "factory": "./src/schematics/stories/stories", + "schema": "./src/schematics/stories/schema.json", + "description": "Create stories/specs for all components declared in a library", + "hidden": false + }, + + "component-cypress-spec": { + "factory": "./src/schematics/component-cypress-spec/component-cypress-spec", + "schema": "./src/schematics/component-cypress-spec/schema.json", + "description": "Create a cypress spec for a ui component that has a story", + "hidden": true + }, + + "component-story": { + "factory": "./src/schematics/component-story/component-story", + "schema": "./src/schematics/component-story/schema.json", + "description": "Create a stories.ts file for a component", + "hidden": true } } } diff --git a/packages/storybook/src/schematics/component-cypress-spec/component-cypress-spec.ts b/packages/angular/src/schematics/component-cypress-spec/component-cypress-spec.ts similarity index 93% rename from packages/storybook/src/schematics/component-cypress-spec/component-cypress-spec.ts rename to packages/angular/src/schematics/component-cypress-spec/component-cypress-spec.ts index cd56cd7938722..6359a229219e9 100644 --- a/packages/storybook/src/schematics/component-cypress-spec/component-cypress-spec.ts +++ b/packages/angular/src/schematics/component-cypress-spec/component-cypress-spec.ts @@ -1,34 +1,30 @@ import { + apply, chain, - externalSchematic, + mergeWith, + move, Rule, - Tree, SchematicContext, - mergeWith, - apply, - url, + SchematicsException, template, - move, - SchematicsException + Tree, + url } from '@angular-devkit/schematics'; import { - getSourceNodes, findNodes, - getDecoratorMetadata, - findNode + getDecoratorMetadata } from '@schematics/angular/utility/ast-utils'; +import { getProject } from '@schematics/angular/utility/project'; import { - SyntaxKind, + PropertyAssignment, PropertyDeclaration, - PropertyAssignment + SyntaxKind } from 'typescript'; +import { getTsSourceFile } from '../../utils/ast-utils'; import { - CreateComponentStoriesFileSchema, getInputPropertyDeclarations, getKnobType } from '../component-story/component-story'; -import { getTsSourceFile } from '../../utils/utils'; -import { getProject } from '@schematics/angular/utility/project'; export default function(schema: CreateComponentSpecFileSchema): Rule { return chain([createComponentSpecFile(schema)]); diff --git a/packages/storybook/src/schematics/component-cypress-spec/files/__componentFileName__.spec.ts__tmpl__ b/packages/angular/src/schematics/component-cypress-spec/files/__componentFileName__.spec.ts__tmpl__ similarity index 100% rename from packages/storybook/src/schematics/component-cypress-spec/files/__componentFileName__.spec.ts__tmpl__ rename to packages/angular/src/schematics/component-cypress-spec/files/__componentFileName__.spec.ts__tmpl__ diff --git a/packages/storybook/src/schematics/component-cypress-spec/schema.json b/packages/angular/src/schematics/component-cypress-spec/schema.json similarity index 100% rename from packages/storybook/src/schematics/component-cypress-spec/schema.json rename to packages/angular/src/schematics/component-cypress-spec/schema.json diff --git a/packages/storybook/src/schematics/component-story/component-story.ts b/packages/angular/src/schematics/component-story/component-story.ts similarity index 96% rename from packages/storybook/src/schematics/component-story/component-story.ts rename to packages/angular/src/schematics/component-story/component-story.ts index 4b14dbad63b1b..5c349cc440622 100644 --- a/packages/storybook/src/schematics/component-story/component-story.ts +++ b/packages/angular/src/schematics/component-story/component-story.ts @@ -1,21 +1,20 @@ import { + apply, chain, - externalSchematic, + mergeWith, + move, Rule, - Tree, SchematicContext, - mergeWith, - apply, - url, template, - move + Tree, + url } from '@angular-devkit/schematics'; -import { PropertyDeclaration, SyntaxKind } from 'typescript'; import { - getSourceNodes, - findNodes + findNodes, + getSourceNodes } from '@schematics/angular/utility/ast-utils'; -import { getTsSourceFile } from '../../utils/utils'; +import { PropertyDeclaration, SyntaxKind } from 'typescript'; +import { getTsSourceFile } from '../../utils/ast-utils'; export interface CreateComponentStoriesFileSchema { libPath: string; diff --git a/packages/storybook/src/schematics/component-story/files/__componentFileName__.stories.ts__tmpl__ b/packages/angular/src/schematics/component-story/files/__componentFileName__.stories.ts__tmpl__ similarity index 100% rename from packages/storybook/src/schematics/component-story/files/__componentFileName__.stories.ts__tmpl__ rename to packages/angular/src/schematics/component-story/files/__componentFileName__.stories.ts__tmpl__ diff --git a/packages/storybook/src/schematics/component-story/schema.json b/packages/angular/src/schematics/component-story/schema.json similarity index 100% rename from packages/storybook/src/schematics/component-story/schema.json rename to packages/angular/src/schematics/component-story/schema.json diff --git a/packages/storybook/src/schematics/storybook-stories/schema.json b/packages/angular/src/schematics/stories/schema.json similarity index 100% rename from packages/storybook/src/schematics/storybook-stories/schema.json rename to packages/angular/src/schematics/stories/schema.json diff --git a/packages/storybook/src/schematics/storybook-stories/storybook-stories.spec.ts b/packages/angular/src/schematics/stories/stories.spec.ts similarity index 77% rename from packages/storybook/src/schematics/storybook-stories/storybook-stories.spec.ts rename to packages/angular/src/schematics/stories/stories.spec.ts index 85eb3cafe256f..a4071260b7b08 100644 --- a/packages/storybook/src/schematics/storybook-stories/storybook-stories.spec.ts +++ b/packages/angular/src/schematics/stories/stories.spec.ts @@ -1,18 +1,13 @@ import { Tree } from '@angular-devkit/schematics'; -import { createEmptyWorkspace } from '@nrwl/workspace/testing'; -import { runSchematic, createTestUILib } from '../../utils/testing'; -import { readJsonInTree } from '@nrwl/workspace'; -import { join, normalize } from '@angular-devkit/core'; +import { CypressConfigureSchema } from '../../../../storybook/src/schematics/cypress-project/cypress-project'; +import { StorybookStoriesSchema } from './stories'; import { - babelCoreVersion, - storybookAddonKnobsVersion, - storybookAngularVersion, - babelLoaderVersion -} from '../../utils/versions'; -import { StorybookStoriesSchema } from './storybook-stories'; -import { CypressConfigureSchema } from '../cypress-configure/cypress-configure'; + createTestUILib, + runSchematic, + runExternalSchematic +} from '../../utils/testing'; -describe('schematic:storybook-stories', () => { +describe('schematic:stories', () => { let appTree: Tree; beforeEach(async () => { @@ -22,7 +17,7 @@ describe('schematic:storybook-stories', () => { describe('Storybook stories', () => { it('should generate stories.ts files', async () => { const tree = await runSchematic( - 'storybook-stories', + 'stories', { name: 'test-ui-lib', generateCypressSpecs: false }, appTree ); @@ -52,13 +47,14 @@ describe('schematic:storybook-stories', () => { }); it('should generate cypress spec files', async () => { - let tree = await runSchematic( - 'cypress-configure', + let tree = await runExternalSchematic( + '@nrwl/storybook', + 'cypress-project', { name: 'test-ui-lib' }, appTree ); tree = await runSchematic( - 'storybook-stories', + 'stories', { name: 'test-ui-lib', generateCypressSpecs: true }, tree ); @@ -99,18 +95,19 @@ describe('schematic:storybook-stories', () => { }); it('should run twice without errors', async () => { - let tree = await runSchematic( - 'cypress-configure', + let tree = await runExternalSchematic( + '@nrwl/storybook', + 'cypress-project', { name: 'test-ui-lib' }, appTree ); tree = await runSchematic( - 'storybook-stories', + 'stories', { name: 'test-ui-lib', generateCypressSpecs: false }, tree ); tree = await runSchematic( - 'storybook-stories', + 'stories', { name: 'test-ui-lib', generateCypressSpecs: true }, tree ); diff --git a/packages/storybook/src/schematics/storybook-stories/storybook-stories.ts b/packages/angular/src/schematics/stories/stories.ts similarity index 90% rename from packages/storybook/src/schematics/storybook-stories/storybook-stories.ts rename to packages/angular/src/schematics/stories/stories.ts index 408062bfae7ac..e14d65460608d 100644 --- a/packages/storybook/src/schematics/storybook-stories/storybook-stories.ts +++ b/packages/angular/src/schematics/stories/stories.ts @@ -1,40 +1,20 @@ import { chain, - externalSchematic, Rule, - Tree, + schematic, SchematicContext, SchematicsException, - mergeWith, - apply, - url, - template, - move, - schematic + Tree } from '@angular-devkit/schematics'; import { - getFirstNgModuleName, getDecoratorMetadata, - getSourceNodes, - findNodes + getFirstNgModuleName } from '@schematics/angular/utility/ast-utils'; import { getProject } from '@schematics/angular/utility/project'; -import { - SourceFile, - createSourceFile, - ScriptTarget, - SyntaxKind, - Identifier, - PropertyDeclaration, - TypeReference -} from 'typescript'; -import { NgModule } from '@angular/core'; -import { - createComponentStoriesFile, - CreateComponentStoriesFileSchema -} from '../component-story/component-story'; -import { getTsSourceFile } from '../../utils/utils'; +import { SyntaxKind } from 'typescript'; +import { getTsSourceFile } from '../../utils/ast-utils'; import { CreateComponentSpecFileSchema } from '../component-cypress-spec/component-cypress-spec'; +import { CreateComponentStoriesFileSchema } from '../component-story/component-story'; export interface StorybookStoriesSchema { name: string; diff --git a/packages/angular/src/utils/ast-utils.ts b/packages/angular/src/utils/ast-utils.ts index 991a60b8e2f8f..66c5904ebff30 100644 --- a/packages/angular/src/utils/ast-utils.ts +++ b/packages/angular/src/utils/ast-utils.ts @@ -8,7 +8,7 @@ import { InsertChange, RemoveChange } from '@nrwl/workspace/src/utils/ast-utils'; -import { Tree } from '@angular-devkit/schematics'; +import { Tree, SchematicsException } from '@angular-devkit/schematics'; import * as path from 'path'; import { toFileName } from '@nrwl/workspace/src/utils/name-utils'; @@ -598,3 +598,19 @@ function getMatchingObjectLiteralElement( })[0] ); } + +export function getTsSourceFile(host: Tree, path: string): ts.SourceFile { + const buffer = host.read(path); + if (!buffer) { + throw new SchematicsException(`Could not read TS file (${path}).`); + } + const content = buffer.toString(); + const source = ts.createSourceFile( + path, + content, + ts.ScriptTarget.Latest, + true + ); + + return source; +} diff --git a/packages/angular/src/utils/testing.ts b/packages/angular/src/utils/testing.ts index efbf18f424582..ee46568042908 100644 --- a/packages/angular/src/utils/testing.ts +++ b/packages/angular/src/utils/testing.ts @@ -1,17 +1,33 @@ import { join } from 'path'; import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; -import { Tree, Rule } from '@angular-devkit/schematics'; +import { Tree, Rule, externalSchematic } from '@angular-devkit/schematics'; import { names, toFileName } from '@nrwl/workspace/src/utils/name-utils'; +import { createEmptyWorkspace } from '@nrwl/workspace/testing'; const testRunner = new SchematicTestRunner( '@nrwl/angular', join(__dirname, '../../collection.json') ); -export function runSchematic(schematicName: string, options: any, tree: Tree) { +export function runSchematic( + schematicName: string, + options: SchemaOptions, + tree: Tree +) { return testRunner.runSchematicAsync(schematicName, options, tree).toPromise(); } +export function runExternalSchematic( + collectionName: string, + schematicName: string, + options: SchemaOptions, + tree: Tree +) { + return testRunner + .runExternalSchematicAsync(collectionName, schematicName, options, tree) + .toPromise(); +} + export function callRule(rule: Rule, tree: Tree) { return testRunner.callRule(rule, tree).toPromise(); } @@ -150,3 +166,59 @@ export function createLib(tree: Tree, libName: string): Tree { ); return tree; } + +export async function createTestUILib(): Promise { + let appTree = Tree.empty(); + appTree = createEmptyWorkspace(appTree); + appTree = await callRule( + externalSchematic('@nrwl/angular', 'library', { + name: 'test-ui-lib' + }), + appTree + ); + appTree = await callRule( + externalSchematic('@schematics/angular', 'component', { + name: 'test-button', + project: 'test-ui-lib' + }), + appTree + ); + appTree.overwrite( + 'libs/test-ui-lib/src/lib/test-button/test-button.component.ts', + ` +import { Component, OnInit, Input } from '@angular/core'; + +export type ButtonStyle = 'default' | 'primary' | 'accent'; + +@Component({ + selector: 'proj-test-button', + templateUrl: './test-button.component.html', + styleUrls: ['./test-button.component.css'] +}) +export class TestButtonComponent implements OnInit { + @Input('buttonType') type = 'button'; + @Input() style: ButtonStyle = 'default'; + @Input() age: number; + @Input() isOn = false; + + constructor() { } + + ngOnInit() { + } + +} +` + ); + appTree.overwrite( + 'libs/test-ui-lib/src/lib/test-button/test-button.component.html', + `` + ); + appTree = await callRule( + externalSchematic('@schematics/angular', 'component', { + name: 'test-other', + project: 'test-ui-lib' + }), + appTree + ); + return appTree; +} diff --git a/packages/storybook/collection.json b/packages/storybook/collection.json index 1f3fd57919b91..d60c8fb51af49 100644 --- a/packages/storybook/collection.json +++ b/packages/storybook/collection.json @@ -8,35 +8,17 @@ "description": "Add storybook configuration to the workspace", "hidden": true }, - "storybook-configure": { - "factory": "./src/schematics/storybook-configure/storybook-configure", - "schema": "./src/schematics/storybook-configure/schema.json", + "configuration": { + "factory": "./src/schematics/configuration/configuration", + "schema": "./src/schematics/configuration/schema.json", "description": "Add storybook configuration to a ui library", "hidden": false }, - "storybook-stories": { - "factory": "./src/schematics/storybook-stories/storybook-stories", - "schema": "./src/schematics/storybook-stories/schema.json", - "description": "Create stories/specs for all components declared in a library", - "hidden": false - }, - "cypress-configure": { - "factory": "./src/schematics/cypress-configure/cypress-configure", - "schema": "./src/schematics/cypress-configure/schema.json", + "cypress-project": { + "factory": "./src/schematics/cypress-project/cypress-project", + "schema": "./src/schematics/cypress-project/schema.json", "description": "Add cypress e2e app to test a ui library that is set up for storybook", "hidden": false - }, - "component-cypress-spec": { - "factory": "./src/schematics/component-cypress-spec/component-cypress-spec", - "schema": "./src/schematics/component-cypress-spec/schema.json", - "description": "Create a cypress spec for a ui component that has a story", - "hidden": true - }, - "component-story": { - "factory": "./src/schematics/component-story/component-story", - "schema": "./src/schematics/component-story/schema.json", - "description": "Create a stories.ts file for a component", - "hidden": true } } } diff --git a/packages/storybook/src/schematics/storybook-configure/storybook-configure.spec.ts b/packages/storybook/src/schematics/configuration/configuration.spec.ts similarity index 84% rename from packages/storybook/src/schematics/storybook-configure/storybook-configure.spec.ts rename to packages/storybook/src/schematics/configuration/configuration.spec.ts index 0cc0de86c2b64..85a91d1a632ad 100644 --- a/packages/storybook/src/schematics/storybook-configure/storybook-configure.spec.ts +++ b/packages/storybook/src/schematics/configuration/configuration.spec.ts @@ -1,20 +1,9 @@ import { Tree } from '@angular-devkit/schematics'; -import { createEmptyWorkspace } from '@nrwl/workspace/testing'; -import { runSchematic, createTestUILib } from '../../utils/testing'; import { readJsonInTree } from '@nrwl/workspace'; -import { join, normalize, schema } from '@angular-devkit/core'; -import { - babelCoreVersion, - storybookAddonKnobsVersion, - storybookAngularVersion, - babelLoaderVersion -} from '../../utils/versions'; -import { Architect, targetFromTargetString } from '@angular-devkit/architect'; -import { TestingArchitectHost } from '@angular-devkit/architect/testing'; -import * as path from 'path'; +import { createTestUILib, runSchematic } from '../../utils/testing'; import { StorybookConfigureSchema } from './schema'; -describe('schematic:storybook-configure', () => { +describe('schematic:configuration', () => { let appTree: Tree; beforeEach(async () => { @@ -23,7 +12,7 @@ describe('schematic:storybook-configure', () => { it('should generate files', async () => { const tree = await runSchematic( - 'storybook-configure', + 'configuration', { name: 'test-ui-lib' }, appTree ); @@ -37,7 +26,7 @@ describe('schematic:storybook-configure', () => { it('should update `angular.json` file', async () => { const tree = await runSchematic( - 'storybook-configure', + 'configuration', { name: 'test-ui-lib' }, appTree ); @@ -70,7 +59,7 @@ describe('schematic:storybook-configure', () => { it('should update `tsconfig.lib.json` file', async () => { const tree = await runSchematic( - 'storybook-configure', + 'configuration', { name: 'test-ui-lib' }, appTree ); @@ -83,7 +72,7 @@ describe('schematic:storybook-configure', () => { it('should configure everything at once', async () => { const tree = await runSchematic( - 'storybook-configure', + 'configuration', { name: 'test-ui-lib', configureCypress: true, @@ -122,7 +111,7 @@ describe('schematic:storybook-configure', () => { // it('should launch cypress and storybook successfully', async done => { // const tree = await runSchematic( - // 'storybook-configure', + // 'configuration', // { // name: 'test-ui-lib', // configureCypress: true, diff --git a/packages/storybook/src/schematics/storybook-configure/storybook-configure.ts b/packages/storybook/src/schematics/configuration/configuration.ts similarity index 88% rename from packages/storybook/src/schematics/storybook-configure/storybook-configure.ts rename to packages/storybook/src/schematics/configuration/configuration.ts index a499dde896044..5a3e2074ce56c 100644 --- a/packages/storybook/src/schematics/storybook-configure/storybook-configure.ts +++ b/packages/storybook/src/schematics/configuration/configuration.ts @@ -7,15 +7,15 @@ import { schematic, SchematicContext, Tree, - url + url, + externalSchematic } from '@angular-devkit/schematics'; import { getWorkspace } from '@schematics/angular/utility/config'; -import {} from '@schematics/angular/utility/json-utils'; import { getProject } from '@schematics/angular/utility/project'; import { updateWorkspace } from '@schematics/angular/utility/workspace'; +import { StorybookStoriesSchema } from '../../../../angular/src/schematics/stories/stories'; import { parseJsonAtPath } from '../../utils/utils'; -import { CypressConfigureSchema } from '../cypress-configure/cypress-configure'; -import { StorybookStoriesSchema } from '../storybook-stories/storybook-stories'; +import { CypressConfigureSchema } from '../cypress-project/cypress-project'; import { StorybookConfigureSchema } from './schema'; export default function(schema: StorybookConfigureSchema): Rule { @@ -24,12 +24,12 @@ export default function(schema: StorybookConfigureSchema): Rule { configureTsConfig(schema.name), addStorybookTask(schema.name), schema.configureCypress - ? schematic('cypress-configure', { + ? schematic('cypress-project', { name: schema.name }) : () => {}, schema.generateStories - ? schematic('storybook-stories', { + ? externalSchematic('@nrwl/angular', 'stories', { name: schema.name, generateCypressSpecs: schema.configureCypress && schema.generateCypressSpecs diff --git a/packages/storybook/src/schematics/storybook-configure/files/.storybook/addons.js b/packages/storybook/src/schematics/configuration/files/.storybook/addons.js similarity index 100% rename from packages/storybook/src/schematics/storybook-configure/files/.storybook/addons.js rename to packages/storybook/src/schematics/configuration/files/.storybook/addons.js diff --git a/packages/storybook/src/schematics/storybook-configure/files/.storybook/config.js b/packages/storybook/src/schematics/configuration/files/.storybook/config.js similarity index 100% rename from packages/storybook/src/schematics/storybook-configure/files/.storybook/config.js rename to packages/storybook/src/schematics/configuration/files/.storybook/config.js diff --git a/packages/storybook/src/schematics/storybook-configure/files/.storybook/tsconfig.json b/packages/storybook/src/schematics/configuration/files/.storybook/tsconfig.json similarity index 100% rename from packages/storybook/src/schematics/storybook-configure/files/.storybook/tsconfig.json rename to packages/storybook/src/schematics/configuration/files/.storybook/tsconfig.json diff --git a/packages/storybook/src/schematics/storybook-configure/schema.d.ts b/packages/storybook/src/schematics/configuration/schema.d.ts similarity index 100% rename from packages/storybook/src/schematics/storybook-configure/schema.d.ts rename to packages/storybook/src/schematics/configuration/schema.d.ts diff --git a/packages/storybook/src/schematics/storybook-configure/schema.json b/packages/storybook/src/schematics/configuration/schema.json similarity index 100% rename from packages/storybook/src/schematics/storybook-configure/schema.json rename to packages/storybook/src/schematics/configuration/schema.json diff --git a/packages/storybook/src/schematics/cypress-configure/cypress-configure.spec.ts b/packages/storybook/src/schematics/cypress-project/cypress-project.spec.ts similarity index 85% rename from packages/storybook/src/schematics/cypress-configure/cypress-configure.spec.ts rename to packages/storybook/src/schematics/cypress-project/cypress-project.spec.ts index 81be1bd1fe1a3..5d507927cb7bc 100644 --- a/packages/storybook/src/schematics/cypress-configure/cypress-configure.spec.ts +++ b/packages/storybook/src/schematics/cypress-project/cypress-project.spec.ts @@ -1,9 +1,8 @@ import { Tree } from '@angular-devkit/schematics'; -import { createEmptyWorkspace } from '@nrwl/workspace/testing'; -import { runSchematic, createTestUILib } from '../../utils/testing'; import { readJsonInTree } from '@nrwl/workspace'; +import { createTestUILib, runSchematic } from '../../utils/testing'; -describe('schematic:cypress-configure', () => { +describe('schematic:cypress-project', () => { let appTree: Tree; beforeEach(async () => { @@ -12,7 +11,7 @@ describe('schematic:cypress-configure', () => { it('should generate files', async () => { const tree = await runSchematic( - 'cypress-configure', + 'cypress-project', { name: 'test-ui-lib' }, appTree ); @@ -27,7 +26,7 @@ describe('schematic:cypress-configure', () => { it('should update `angular.json` file', async () => { const tree = await runSchematic( - 'cypress-configure', + 'cypress-project', { name: 'test-ui-lib' }, appTree ); diff --git a/packages/storybook/src/schematics/cypress-configure/cypress-configure.ts b/packages/storybook/src/schematics/cypress-project/cypress-project.ts similarity index 90% rename from packages/storybook/src/schematics/cypress-configure/cypress-configure.ts rename to packages/storybook/src/schematics/cypress-project/cypress-project.ts index b26336d1035a1..310df29064a9f 100644 --- a/packages/storybook/src/schematics/cypress-configure/cypress-configure.ts +++ b/packages/storybook/src/schematics/cypress-project/cypress-project.ts @@ -2,17 +2,15 @@ import { chain, externalSchematic, Rule, - Tree, - SchematicContext + SchematicContext, + Tree } from '@angular-devkit/schematics'; -import { safeFileDelete, parseJsonAtPath } from '../../utils/utils'; -import { Observable, of } from 'rxjs'; -import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; -import { getProject } from '@schematics/angular/utility/project'; import { - updateWorkspace, - getWorkspace + getWorkspace, + updateWorkspace } from '@schematics/angular/utility/config'; +import { getProject } from '@schematics/angular/utility/project'; +import { parseJsonAtPath, safeFileDelete } from '../../utils/utils'; export interface CypressConfigureSchema { name: string; diff --git a/packages/storybook/src/schematics/cypress-configure/schema.json b/packages/storybook/src/schematics/cypress-project/schema.json similarity index 100% rename from packages/storybook/src/schematics/cypress-configure/schema.json rename to packages/storybook/src/schematics/cypress-project/schema.json