diff --git a/.npmignore b/.npmignore index 2b2cee7..1846a62 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,15 @@ # Ignores TypeScript files, but keeps definitions. !*.d.ts + +*.ts(!**/files/**/*.{ts,json}) + +.idea + +!package.json +jest.config.js +coverage/ +tsconfig.json +tslint.json +.travis.yml +.prettierrc +.prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..77a04b0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +src/subentry/files/**/* diff --git a/src/collection.json b/src/collection.json index 5b65a10..c705e32 100644 --- a/src/collection.json +++ b/src/collection.json @@ -1,14 +1,14 @@ { "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json", "schematics": { - "ng-samurai": { - "description": "A blank schematic.", - "factory": "./ng-samurai/index#ngSamurai" + "split-lib": { + "description": "Automatically split your library into multiple chungks", + "factory": "./library-split/index#splitLib" }, - "submodule": { - "description": "A schematic to generate tree-shakeable sub-module in Angular library (ng-packagr secondary entry point).", - "factory": "./submodule/index#submodule", - "schema": "./submodule/schema.json" + "generate-subentry": { + "description": "A schematic to generate tree-shakeable sub-entry in Angular library (ng-packagr secondary entry point).", + "factory": "./subentry/index#generateSubentry", + "schema": "./subentry/schema.json" } } } diff --git a/src/ng-samurai/index.spec.ts b/src/library-split/index.spec.ts similarity index 86% rename from src/ng-samurai/index.spec.ts rename to src/library-split/index.spec.ts index 7907c1c..5d557fa 100644 --- a/src/ng-samurai/index.spec.ts +++ b/src/library-split/index.spec.ts @@ -20,7 +20,7 @@ const collectionPath = path.join(__dirname, '../collection.json'); const runner = new SchematicTestRunner('schematics', collectionPath); let appTree: UnitTestTree; -describe('ng-samurai', () => { +describe('split', () => { beforeEach(async () => { console.log = () => {}; @@ -101,7 +101,7 @@ describe('ng-samurai', () => { } it('should export foo and bar from the public-api', async () => { - const updatedTree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const updatedTree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const topLevelPublicAPIContent = updatedTree.readContent( '/projects/some-lib/src/public-api.ts' ); @@ -124,22 +124,22 @@ describe('ng-samurai', () => { } it('should add a public_api to foo module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/foo/public-api.ts')).toBe(true); }); it('should add a public_api to bar module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/public-api.ts')).toBe(true); }); it('should not add a public_api to baz module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/baz/public-api.ts')).not.toBe(true); }); it('should export foo.component.ts and foo.module.ts from foos public-api', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const publicAPI = tree.read('/projects/some-lib/src/lib/foo/public-api.ts').toString(); const expectedFilesIncludedInPublicAPI = ['foo.module', 'foo.component', 'foo.service']; const expectedFileContent = expectedSubentryPublicAPIContent( @@ -150,7 +150,7 @@ describe('ng-samurai', () => { }); it('should export bar.component.ts, bar.module.ts, bar.model and baz.component.ts from bars public-api', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const publicAPI = tree.read('/projects/some-lib/src/lib/bar/public-api.ts').toString(); const expectedFilesIncludedInPublicAPI = [ 'bar.module', @@ -169,43 +169,43 @@ describe('ng-samurai', () => { describe('index.ts', () => { it('should add an index.ts to foo module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/foo/index.ts')).toBe(true); }); it('should add export everything from public-api inside the index.ts of foo', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.read('/projects/some-lib/src/lib/foo/index.ts').toString()).toEqual( "export * from './public-api';\n" ); }); it('should add an index.ts bar module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/index.ts')).toBe(true); }); it('should add export everything from public-api inside the index.ts of bar', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.read('/projects/some-lib/src/lib/bar/index.ts').toString()).toEqual( "export * from './public-api';\n" ); }); it('should not add an index.ts to baz module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/baz/index.ts')).not.toBe(true); }); }); describe('package.json', () => { it('should add an index.ts to foo module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/foo/package.json')).toBe(true); }); it('should add the correct config to the package.json of foo subentry', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const expectedSubentryConfig = { ngPackage: { lib: { @@ -220,12 +220,12 @@ describe('ng-samurai', () => { }); it('should add an packag.json to bar module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/package.json')).toBe(true); }); it('should add the correct config to the package.json of bar subentry', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const expectedSubentryConfig = { ngPackage: { lib: { @@ -240,7 +240,7 @@ describe('ng-samurai', () => { }); it('should not add a package.json to baz module', async () => { - const tree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const tree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); expect(tree.exists('/projects/some-lib/src/lib/bar/baz/package.json')).not.toBe(true); }); }); @@ -283,7 +283,7 @@ describe('ng-samurai', () => { const expectedModuleContent = getExpectedBarModuleContent(); updateBarModuleContent(); - const updatedTree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const updatedTree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const moduleContentAfterSchematics = updatedTree.readContent( '/projects/some-lib/src/lib/bar/bar.module.ts' ); @@ -296,7 +296,7 @@ describe('ng-samurai', () => { const expectedComponentContent = getExpectedBazComponentContent(); updateBazComponentContent(); - const updatedTree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const updatedTree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const componentContentAfterSchematics = updatedTree.readContent( '/projects/some-lib/src/lib/bar/baz/baz.component.ts' ); @@ -313,7 +313,7 @@ describe('ng-samurai', () => { } it('should update the paths in the tsconfig.json', async () => { - const updatedTree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const updatedTree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const tsconfigContent = JSON.parse(updatedTree.readContent('tsconfig.json')); const expectedPaths = { 'some-lib': ['dist/some-lib/some-lib', 'dist/some-lib'], @@ -326,7 +326,7 @@ describe('ng-samurai', () => { it('should add paths to the tsconfig.json even if no path exist', async () => { deletePathsFromTsconfig(); - const updatedTree = await runner.runSchematicAsync('ng-samurai', {}, appTree).toPromise(); + const updatedTree = await runner.runSchematicAsync('split-lib', {}, appTree).toPromise(); const tsconfigContent = JSON.parse(updatedTree.readContent('tsconfig.json')); const expectedPaths = { 'some-lib/*': ['projects/some-lib/*', 'projects/some-lib'] diff --git a/src/ng-samurai/index.ts b/src/library-split/index.ts similarity index 78% rename from src/ng-samurai/index.ts rename to src/library-split/index.ts index 32d5fc0..d1cded9 100644 --- a/src/ng-samurai/index.ts +++ b/src/library-split/index.ts @@ -1,14 +1,14 @@ import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; -import { submodule } from '../submodule/index'; -import { getLibRootPath, getModuleName } from '../shared/pathHelper'; +import { generateSubentry } from '../subentry/index'; +import { getFolderPath, getLibRootPath, getModuleName, resolvePath } from '../shared/path-helper'; import { addTsconfigPaths } from '../rules/add-tsconfig-paths.rule'; import { updateImportPaths } from '../rules/update-import-paths.rule'; import { updateSubentryPublicAPI } from '../rules/update-public-api/update-subentry-public-api.rule'; import { updateTopLevelPublicAPI } from '../rules/update-public-api/update-top-level-public-api.rule'; import { logWelcomeMessage } from '../shared/log-helper'; -export function ngSamurai(_options: any): Rule { +export function splitLib(_options: any): Rule { logWelcomeMessage(); return (tree: Tree, _context: SchematicContext) => { @@ -25,10 +25,10 @@ export function ngSamurai(_options: any): Rule { modulePaths.push(filePath); rules.push( - submodule({ + generateSubentry({ name: getModuleName(filePath), - filesPath: '../submodule/files', - path: libRootPath, + filesPath: '../subentry/files', + path: resolvePath(getFolderPath(filePath), '..'), generateComponent: false, generateModule: false }) diff --git a/src/rules/update-import-paths.rule.ts b/src/rules/update-import-paths.rule.ts index e0dc38a..07f24fa 100644 --- a/src/rules/update-import-paths.rule.ts +++ b/src/rules/update-import-paths.rule.ts @@ -6,7 +6,7 @@ import { convertModulePathToPublicAPIImport, convertToAbsolutPath, getFolderPath -} from '../shared/pathHelper'; +} from '../shared/path-helper'; import { logError } from '../shared/log-helper'; interface Modification { diff --git a/src/rules/update-public-api/update-public-api.rule.ts b/src/rules/update-public-api/update-public-api.rule.ts index bc09b24..13c5666 100644 --- a/src/rules/update-public-api/update-public-api.rule.ts +++ b/src/rules/update-public-api/update-public-api.rule.ts @@ -7,6 +7,7 @@ export function updatePublicAPI(path: string, paths: string[]): Rule { const publicAPIFile = path + '/public-api.ts'; tree.overwrite(publicAPIFile, generatePublicAPIcontent(paths)); } catch (e) { + console.error(e); logError(`Something went wrong: Do you have multiple modules in ${path}`); } }; diff --git a/src/rules/update-public-api/update-subentry-public-api.rule.ts b/src/rules/update-public-api/update-subentry-public-api.rule.ts index 2ab03c0..2eded2c 100644 --- a/src/rules/update-public-api/update-subentry-public-api.rule.ts +++ b/src/rules/update-public-api/update-subentry-public-api.rule.ts @@ -1,7 +1,7 @@ import { Rule, Tree } from '@angular-devkit/schematics'; import { buildRelativePath } from '@schematics/angular/utility/find-module'; -import { getFileDirectoryPath } from '../../shared/pathHelper'; +import { getFileDirectoryPath } from '../../shared/path-helper'; import { updatePublicAPI } from './update-public-api.rule'; diff --git a/src/rules/update-public-api/update-top-level-public-api.rule.ts b/src/rules/update-public-api/update-top-level-public-api.rule.ts index a7b29a4..1f4fe79 100644 --- a/src/rules/update-public-api/update-top-level-public-api.rule.ts +++ b/src/rules/update-public-api/update-top-level-public-api.rule.ts @@ -1,6 +1,6 @@ import { Rule, Tree } from '@angular-devkit/schematics'; -import { convertModulePathToPublicAPIImport, getSourceRootPath } from '../../shared/pathHelper'; +import { convertModulePathToPublicAPIImport, getSourceRootPath } from '../../shared/path-helper'; import { updatePublicAPI } from './update-public-api.rule'; diff --git a/src/shared/log-helper.ts b/src/shared/log-helper.ts index 5cf512b..8459b29 100644 --- a/src/shared/log-helper.ts +++ b/src/shared/log-helper.ts @@ -25,8 +25,5 @@ export function logWelcomeMessage() { } export function logError(error: string) { - console.log(boxen(`${chalk.blue('Ng-samurai: ')} ${chalk.red(error)}`), { - padding: 2, - borderColor: 'red' - }); + console.log(`${chalk.blue('Ng-samurai: ')} ${chalk.red(error)}`); } diff --git a/src/shared/path-helper.spec.ts b/src/shared/path-helper.spec.ts new file mode 100644 index 0000000..2fce387 --- /dev/null +++ b/src/shared/path-helper.spec.ts @@ -0,0 +1,165 @@ +import { + convertModulePathToPublicAPIImport, + convertToAbsolutPath, + getFileDirectoryPath, + getFolderPath, + getLibRootPath, + getModuleName, + getSourceRootPath +} from './path-helper'; + +describe('path-helper', () => { + it('should get the directory of a filepath', () => { + const filepath = './foo/bar/baz.component.ts'; + const expectedDirectoryPath = './foo/bar'; + + expect(getFileDirectoryPath(filepath)).toEqual(expectedDirectoryPath); + }); + + it('should get the name of a module from a modules file path', () => { + const moduleFilePath = './foo/bar/bar.module.ts'; + const expectedModuleName = 'bar'; + + expect(getModuleName(moduleFilePath)).toEqual(expectedModuleName); + }); + + it('should convert the modulePaths to a public API import path', () => { + const moduleFilePath = '/projects/got-wiki/src/lib/arya-stark/arya-stark.module.ts'; + const expectedPath = 'got-wiki/src/lib/arya-stark'; + + expect(convertModulePathToPublicAPIImport(moduleFilePath)).toEqual(expectedPath); + }); + + it('should get the root path of the default project', () => { + const workspace = { + projects: { + foo: { + projectType: 'library', + sourceRoot: 'projects/foo/src' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(getLibRootPath(tree)).toEqual('projects/foo/src/lib'); + }); + + it('should return the library path of the desired project', () => { + const workspace = { + projects: { + foo: { + projectType: 'library', + sourceRoot: 'projects/foo/src' + }, + bar: { + projectType: 'library', + sourceRoot: 'projects/bar/src' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(getLibRootPath(tree, 'bar')).toEqual('projects/bar/src/lib'); + }); + + it('should get the foldre path of a file', () => { + const filePath = './projects/foo/foo.component.ts'; + const folderPath = './projects/foo'; + + expect(getFolderPath(filePath)).toEqual(folderPath); + }); + + describe('getSourceRootPath', () => { + it('should throw an exception if there is no angular.json', () => { + const tree = { + read: (): any => null + } as any; + expect(() => getSourceRootPath(tree)).toThrowError('Not and Angular CLI workspace'); + }); + + it('should throw if the projectType is not a library', () => { + const workspace = { + projects: { + foo: { + projectType: 'application' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(() => getSourceRootPath(tree)).toThrowError( + 'Ng-samurai works only for the "library" projects, please specify correct project using --project flag' + ); + }); + + it('should throw if the desired projectType is not a library', () => { + const workspace = { + projects: { + foo: { + projectType: 'library' + }, + bar: { + projectType: 'application' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(() => getSourceRootPath(tree, 'bar')).toThrowError( + 'Ng-samurai works only for the "library" projects, please specify correct project using --project flag' + ); + }); + + it('should return the source root of the default project', () => { + const workspace = { + projects: { + foo: { + projectType: 'library', + sourceRoot: 'projects/foo/src' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(getSourceRootPath(tree)).toEqual('projects/foo/src'); + }); + + it('should return the source root of the desired project', () => { + const workspace = { + projects: { + foo: { + projectType: 'library', + sourceRoot: 'projects/foo/src' + }, + bar: { + projectType: 'library', + sourceRoot: 'projects/bar/src' + } + }, + defaultProject: 'foo' + }; + const tree = { + read: (): any => Buffer.from(JSON.stringify(workspace)) + } as any; + expect(getSourceRootPath(tree, 'bar')).toEqual('projects/bar/src'); + }); + }); + + it('should convert a import string litereal to an absolute path', () => { + const filePath = './projects/foo/bar/baz/baz.component.ts'; + const importStringLiteral = '../../foo.component.ts'; + const expectedPath = './projects/foo/foo.component.ts'; + + expect(convertToAbsolutPath(filePath, importStringLiteral)).toEqual(expectedPath); + }); +}); diff --git a/src/shared/pathHelper.ts b/src/shared/path-helper.ts similarity index 89% rename from src/shared/pathHelper.ts rename to src/shared/path-helper.ts index c06d90c..695b23a 100644 --- a/src/shared/pathHelper.ts +++ b/src/shared/path-helper.ts @@ -50,6 +50,12 @@ export function convertToAbsolutPath(filePath: string, importStringLiteral: stri return `${folderPathAfterLevelsMove}${pathAfterRelativeSegment}`; } +export function resolvePath(filePath: string, pathChange: string): string { + const levelsUp = getLevels(pathChange); + const filePathSegments = filePath.split('/'); + return filePathSegments.slice(0, filePathSegments.length - levelsUp).join('/'); +} + function getLevels(importStringLiteral: string): number { const numberOfDots = importStringLiteral.match(/[^a-zA-Z0-9]*/)[0].match(/\./g)?.length; return Math.floor(numberOfDots / 2); diff --git a/src/submodule/files/__name@dasherize__/index.ts b/src/subentry/files/__name@dasherize__/index.ts similarity index 100% rename from src/submodule/files/__name@dasherize__/index.ts rename to src/subentry/files/__name@dasherize__/index.ts diff --git a/src/submodule/files/__name@dasherize__/package.json b/src/subentry/files/__name@dasherize__/package.json similarity index 100% rename from src/submodule/files/__name@dasherize__/package.json rename to src/subentry/files/__name@dasherize__/package.json diff --git a/src/submodule/files/__name@dasherize__/public-api.ts b/src/subentry/files/__name@dasherize__/public-api.ts similarity index 100% rename from src/submodule/files/__name@dasherize__/public-api.ts rename to src/subentry/files/__name@dasherize__/public-api.ts diff --git a/src/submodule/index.spec.ts b/src/subentry/index.spec.ts similarity index 83% rename from src/submodule/index.spec.ts rename to src/subentry/index.spec.ts index 90653f7..be7fd44 100755 --- a/src/submodule/index.spec.ts +++ b/src/subentry/index.spec.ts @@ -33,7 +33,7 @@ const runner = new SchematicTestRunner('schematics', collectionPath); let appTree: UnitTestTree; -describe('submodule', () => { +describe('generate-subentry', () => { beforeEach(async () => { appTree = await runner .runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions) @@ -49,7 +49,7 @@ describe('submodule', () => { it('should generate a CustomerComponent', async () => { const options = { ...defaultOptions }; - const tree = await runner.runSchematicAsync('submodule', options, appTree).toPromise(); + const tree = await runner.runSchematicAsync('generate-subentry', options, appTree).toPromise(); expect( tree.files.includes('/projects/some-lib/src/lib/path/to/customer/customer.component.ts') @@ -59,7 +59,7 @@ describe('submodule', () => { it('should generate a CustomerModule and add a CustomerComponent', async () => { const options = { ...defaultOptions }; - const tree = await runner.runSchematicAsync('submodule', options, appTree).toPromise(); + const tree = await runner.runSchematicAsync('generate-subentry', options, appTree).toPromise(); expect( tree.files.includes('/projects/some-lib/src/lib/path/to/customer/customer.module.ts') @@ -75,7 +75,7 @@ describe('submodule', () => { const options = { ...defaultOptions }; const expectedContent = "export * from './public-api';\n"; - const tree = await runner.runSchematicAsync('submodule', options, appTree).toPromise(); + const tree = await runner.runSchematicAsync('generate-subentry', options, appTree).toPromise(); expect(tree.readContent('/projects/some-lib/src/lib/path/to/customer/index.ts')).toEqual( expectedContent ); @@ -86,13 +86,13 @@ describe('submodule', () => { const expectedContent = "export * from './customer.module';\nexport * from './customer.component';\n"; - const tree = await runner.runSchematicAsync('submodule', options, appTree).toPromise(); + const tree = await runner.runSchematicAsync('generate-subentry', options, appTree).toPromise(); expect(tree.readContent('/projects/some-lib/src/lib/path/to/customer/public-api.ts')).toEqual( expectedContent ); }); - it('should add a package.json with the subentry config', async () => { + it('should add a package.json with the generate-subentry config', async () => { const options = { ...defaultOptions }; const expectedContent = { ngPackage: { @@ -102,7 +102,7 @@ describe('submodule', () => { } }; - const tree = await runner.runSchematicAsync('submodule', options, appTree).toPromise(); + const tree = await runner.runSchematicAsync('generate-subentry', options, appTree).toPromise(); expect( JSON.parse(tree.readContent('/projects/some-lib/src/lib/path/to/customer/package.json')) ).toEqual(expectedContent); diff --git a/src/submodule/index.ts b/src/subentry/index.ts similarity index 87% rename from src/submodule/index.ts rename to src/subentry/index.ts index 11610e0..3057dc0 100755 --- a/src/submodule/index.ts +++ b/src/subentry/index.ts @@ -14,9 +14,9 @@ import { import { strings } from '@angular-devkit/core'; import { parseName } from '@schematics/angular/utility/parse-name'; -import { Schema as SubmoduleOptions } from './schema.model'; +import { Schema as SubentryOptions } from './schema.model'; -export function submodule(_options: SubmoduleOptions): Rule { +export function generateSubentry(_options: SubentryOptions): Rule { return (tree: Tree, _context: SchematicContext) => { const moduleSchematicsOptions = { ..._options }; const componentSchematicsOptions = { ..._options }; @@ -33,7 +33,7 @@ export function submodule(_options: SubmoduleOptions): Rule { if (project.projectType === 'application') { throw new SchematicsException( - 'The "submodule" schematics works only for the "library" projects, please specify correct project using --project flag' + 'The "generateSubentry" schematics works only for the "library" projects, please specify correct project using --project flag' ); } diff --git a/src/submodule/schema.json b/src/subentry/schema.json similarity index 97% rename from src/submodule/schema.json rename to src/subentry/schema.json index 155bff6..4801e5b 100755 --- a/src/submodule/schema.json +++ b/src/subentry/schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/schema", - "id": "SchematicsAngularExtensionsSubModule", + "id": "NgSamuraiSubentry", "title": "Angular SubModule Options Schema", "type": "object", "description": "Creates a new sub-module for Angular library in the given or default project.", diff --git a/src/submodule/schema.model.ts b/src/subentry/schema.model.ts similarity index 100% rename from src/submodule/schema.model.ts rename to src/subentry/schema.model.ts