diff --git a/package.json b/package.json index d1203c8d..6c07271e 100644 --- a/package.json +++ b/package.json @@ -11,22 +11,24 @@ "yarn": ">= 1.22.0" }, "scripts": { + "init": "yarn install", "prepare": "husky install", "ng": "ng", - "build": "ng build --configuration production && yarn build:schematics && yarn copy:schematics && yarn copy:docs", - "build:schematics": "tsc -p projects/spectator/schematics/tsconfig.json", + "build": "ng build --configuration production && yarn build:schematics && yarn copy:docs", + "build:schematics": "node projects/spectator/build-schematics.js", + "pack": "cd dist/spectator && npm pack && bash -c 'mv openng-spectator-*.tgz ../../'", "test": "ng test", "test:jest": "ng run spectator:test-jest", "test:vitest": "ng run spectator:test-vitest", "test:types": "tsc -p type-tests/jasmine && tsc -p type-tests/jest && tsc -p type-tests/vitest", - "test:ci": "cross-env NODE_ENV=build yarn test && yarn test:jest --silent && yarn test:vitest", + "test:schematics": "jest --config projects/spectator/schematics/jest.config.js", + "test:ci": "cross-env NODE_ENV=build yarn test && yarn test:jest --silent && yarn test:vitest && yarn test:schematics", "lint": "ng lint", "format": "prettier --write \"{projects,src}/**/*.ts\"", "commit": "git-cz", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate", "copy:docs": "cp *.md dist/spectator", - "copy:schematics": "cp -r projects/spectator/schematics/src/ dist/spectator/schematics", "postbump": "yarn build", "release": "cd projects/spectator && standard-version --infile ../../CHANGELOG.md", "release:dry": "cd projects/spectator && standard-version --infile ../../CHANGELOG.md --dry-run" @@ -52,10 +54,10 @@ "@angular/platform-browser-dynamic": "^22.0.5", "@angular/router": "22.0.5", "@commitlint/cli": "17.3.0", - "@emnapi/core": "^1.7.1", - "@emnapi/runtime": "^1.7.1", "@commitlint/config-angular": "17.3.0", "@commitlint/config-conventional": "17.3.0", + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1", "@types/jasmine": "5.1.4", "@types/jest": "30.0.0", "@types/node": "^26.1.0", @@ -66,6 +68,8 @@ "core-js": "^3.9.1", "cross-env": "^5.1.4", "cz-conventional-changelog": "^3.3.0", + "esbuild": "^0.28.1", + "esbuild-plugin-tsc": "^0.6.0", "eslint": "^9.28.0", "git-cz": "^4.7.6", "helpful-decorators": "^2.1.0", diff --git a/projects/spectator/build-schematics.js b/projects/spectator/build-schematics.js new file mode 100644 index 00000000..e2596038 --- /dev/null +++ b/projects/spectator/build-schematics.js @@ -0,0 +1,61 @@ +import { build } from 'esbuild'; +import esbuildPluginTsc from 'esbuild-plugin-tsc'; +import { glob } from 'fs/promises'; +import { rmSync } from 'fs'; +import { dirname, resolve } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const distPath = '../../dist/spectator/schematics'; + +const schematics = build({ + absWorkingDir: __dirname, + bundle: false, + entryPoints: ['schematics/src/**'], + format: 'esm', + loader: { + '.json': 'copy', + '.template': 'copy', + '.md': 'empty', + }, + minify: false, + outdir: resolve(__dirname, distPath), + packages: 'external', + platform: 'node', + plugins: [ + esbuildPluginTsc({ + force: true, + tsconfigPath: resolve(__dirname, './schematics/tsconfig.json'), + }), + ], + target: 'node22', + treeShaking: false, +}); + +/** + * Remove files/directories from dist/schematics using glob patterns. + * + * @param patterns - Glob pattern(s) relative to dist/schematics + */ +async function removeFromDistSchematics(patterns) { + const targetDir = resolve(__dirname, distPath); + const list = Array.isArray(patterns) ? patterns : [patterns]; + + for (const pattern of list) { + const globResults = await Array.fromAsync(glob(pattern, { cwd: targetDir })); + for (const match of globResults) { + const fullPath = resolve(targetDir, match); + rmSync(fullPath, { recursive: true, force: true }); + } + } +} + +schematics + .then(async () => { + // Remove unwanted artifact form the build + await removeFromDistSchematics(['*.config.js', '**/*.spec.js', '__mocks__', "**/*.md"]); + }) + .catch((e) => { + console.error(e); + process.exit(1); + }); diff --git a/projects/spectator/schematics/__mocks__/ora.js b/projects/spectator/schematics/__mocks__/ora.js new file mode 100644 index 00000000..c5d07df7 --- /dev/null +++ b/projects/spectator/schematics/__mocks__/ora.js @@ -0,0 +1,18 @@ +// Mock for ora (ESM-only) package +// ora returns an object with start/stop/succeed/fail methods +const createMockSpinner = () => ({ + start: (text) => createMockSpinner(), + stop: () => createMockSpinner(), + succeed: (text) => createMockSpinner(), + fail: (text) => createMockSpinner(), + warn: (text) => createMockSpinner(), + info: (text) => createMockSpinner(), + clear: () => createMockSpinner(), + render: () => createMockSpinner(), + color: 'cyan', + prefixText: '', + text: '', +}); + +module.exports = createMockSpinner; +module.exports.default = createMockSpinner; diff --git a/projects/spectator/schematics/jest.config.js b/projects/spectator/schematics/jest.config.js new file mode 100644 index 00000000..2d11f0da --- /dev/null +++ b/projects/spectator/schematics/jest.config.js @@ -0,0 +1,19 @@ +module.exports = { + testEnvironment: 'node', + roots: ['/src'], + testMatch: ['**/*.spec.ts'], + testPathIgnorePatterns: ['/files/'], + transform: { + '^.+\\.ts$': [ + 'ts-jest', + { + tsconfig: '/tsconfig.spec.json', + }, + ], + }, + moduleNameMapper: { + '^ora$': '/__mocks__/ora.js', + }, + moduleFileExtensions: ['ts', 'js'], + collectCoverageFrom: ['src/**/*.ts', '!src/**/*.spec.ts', '!src/**/files/**/*'], +}; diff --git a/projects/spectator/schematics/src/collection.json b/projects/spectator/schematics/src/collection.json index 92ba704d..f6a92f08 100644 --- a/projects/spectator/schematics/src/collection.json +++ b/projects/spectator/schematics/src/collection.json @@ -1,5 +1,5 @@ { - "$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json", + "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json", "extends": ["@schematics/angular"], "schematics": { "spectator-component": { @@ -25,6 +25,12 @@ "factory": "./spectator/index#spectatorPipeSchematic", "schema": "./spectator/pipe-schema.json", "aliases": ["ps"] + }, + "ngneat-to-openng": { + "description": "Convert @ngneat/spectator to @openng/spectator", + "factory": "./ngneat-to-openng/index#migrate", + "schema": "./ngneat-to-openng/schema.json", + "aliases": ["nto"] } } } diff --git a/projects/spectator/schematics/src/ngneat-to-openng/README.md b/projects/spectator/schematics/src/ngneat-to-openng/README.md new file mode 100644 index 00000000..1a680ee8 --- /dev/null +++ b/projects/spectator/schematics/src/ngneat-to-openng/README.md @@ -0,0 +1,25 @@ +# ngneat to openng migration + +Converts all imports of `@ngneat/spectator` to `@openng/spectator` across your project. + +This migration scans every TypeScript file in your project (excluding `node_modules` and `dist` directories) and updates any import or export declarations that reference `@ngneat/spectator` to instead reference `@openng/spectator`. Named imports remain intact — only the module specifier path changes. + +## What does this migration do? + +- Finds all TypeScript files (`.ts`) in your project +- Skips files inside `node_modules` and `dist` directories +- Replaces `from '@ngneat/spectator/'` with `from '@openng/spectator/'` in import and export declarations +- Preserves all named imports (e.g., `createComponentFactory`, `Spectator`, etc.) +- Remove `@ngneat/spectator` for the `package.json` + +## How to run this migration? + +```bash +ng generate @openng/spectator:ngneat-to-openng +``` + +Or using the alias: + +```bash +ng g @openng/spectator:nto +``` diff --git a/projects/spectator/schematics/src/ngneat-to-openng/index.spec.ts b/projects/spectator/schematics/src/ngneat-to-openng/index.spec.ts new file mode 100644 index 00000000..c868c5d3 --- /dev/null +++ b/projects/spectator/schematics/src/ngneat-to-openng/index.spec.ts @@ -0,0 +1,316 @@ +import { Tree } from '@angular-devkit/schematics'; +import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; +import path from 'path'; + +/** + * Supported test-runner sub-packages for @ngneat/@openng/spectator. + */ +const TEST_RUNNERS = ['jasmine', 'jest', 'vitest'] as const; + +/** + * Resolves the full module path for a given test runner under the `@ngneat/spectator` package. + * Jasmine maps to the base package; other runners map to a sub-path. + */ +function resolveNgNeatModule(testRunner: (typeof TEST_RUNNERS)[number]): string { + const base = '@ngneat/spectator'; + return testRunner === 'jasmine' ? base : `${base}/${testRunner}`; +} + +/** + * Resolves the full module path for a given test runner under the `@openng/spectator` package. + * Jasmine maps to the base package; other runners map to a sub-path. + */ +function resolveOpenNgModule(testRunner: (typeof TEST_RUNNERS)[number]): string { + const base = '@openng/spectator'; + return testRunner === 'jasmine' ? base : `${base}/${testRunner}`; +} + +/** + * Configuration used to generate a synthetic test fixture file. + */ +interface TestFixtureConfig { + /** + * Spectator type name (e.g., `Spectator`, `SpectatorDirective`). + */ + spectatorType: string; + /** + * Factory creator function name (e.g., `createComponentFactory`). + */ + factoryName: string; + /** + * Angular element kind being tested. + */ + type: 'component' | 'directive' | 'pipe' | 'service'; + /** + * Body of the test describe block. + */ + testBody: string; + /** + * Test-runner sub-package to target (defaults to `jasmine`). + */ + testRunner?: (typeof TEST_RUNNERS)[number]; +} + +/** + * Generates the source content for a synthetic test file that imports from `@ngneat/spectator`. + * The generated file can be fed into the schematic to verify import rewriting. + */ +function createTestFixtureContent(config: TestFixtureConfig): string { + const { spectatorType, factoryName, type, testBody, testRunner = 'jasmine' } = config; + const ngNeatModule = resolveNgNeatModule(testRunner); + const className = `My${type.replace(/^./, (c) => c.toUpperCase())}`; + const importPath = `./my.${type.toLowerCase()}`; + + return `import { ${factoryName}, ${spectatorType} } from '${ngNeatModule}'; +import { ${className} } from '${importPath}'; + +describe('${className}', () => { + let spectator: ${spectatorType}<${className}>; + const create${className.replace(/^./, (c) => c.toLowerCase())} = ${factoryName}(${className}); + +${testBody} +});`; +} + +describe('ngneat-to-openng', () => { + const runner = new SchematicTestRunner('schematics', path.join(__dirname, '../collection.json')); + + let tree: Tree; + + beforeEach(() => { + tree = Tree.empty(); + tree.create( + 'package.json', + JSON.stringify({ + name: 'app', + version: '0.0.0', + dependencies: { + '@ngneat/spectator': '^22.1.0', + }, + devDependencies: { + '@ngneat/spectator': '^22.1.0', + }, + }), + ); + }); + + describe('ngneat/directive', () => { + const pathStr = '/src/ngneat.directive.ts'; + + /** + * Builds a test tree seeded with a directive fixture for the given runner. + */ + function createTreeWithRunner(testRunner: (typeof TEST_RUNNERS)[number]) { + tree.create( + pathStr, + createTestFixtureContent({ + spectatorType: 'SpectatorDirective', + factoryName: 'createDirectiveFactory', + type: 'directive', + testRunner, + testBody: ` it('should change the background color', () => { + spectator = createDirective(\`
Testing MyDirective
\`); + + spectator.dispatchMouseEvent(spectator.element, 'mouseover'); + + expect(spectator.element).toHaveStyle({ + backgroundColor: 'rgba(0,0,0, 0.1)' + }); + + spectator.dispatchMouseEvent(spectator.element, 'mouseout'); + expect(spectator.element).toHaveStyle({ + backgroundColor: '#fff' + }); + });`, + }), + ); + } + + it.each(TEST_RUNNERS)(`should rename to @openng - $testRunner`, async (testRunner) => { + createTreeWithRunner(testRunner); + const result = await runner.runSchematic('ngneat-to-openng', {}, tree); + const content = result.readContent(pathStr); + + expect(content).toContain(`from '${resolveOpenNgModule(testRunner)}'`); + expect(content).not.toContain(`from '${resolveNgNeatModule(testRunner)}'`); + expect(content).toContain(`import { createDirectiveFactory, SpectatorDirective }`); + }); + }); + + describe('ngneat/pipe', () => { + const pathStr = '/src/ngneat.pipe.ts'; + + /** + * Builds a test tree seeded with a pipe fixture for the given runner. + */ + function createTreeWithRunner(testRunner: (typeof TEST_RUNNERS)[number]) { + tree.create( + pathStr, + createTestFixtureContent({ + spectatorType: 'SpectatorPipe', + factoryName: 'createPipeFactory', + type: 'pipe', + testRunner, + testBody: ` it('should change the background color', () => { + spectator = createPipe(\`
{{ 'Testing' | my }}
\`); + + expect(spectator.element).toHaveText('Testing'); + });`, + }), + ); + } + + it.each(TEST_RUNNERS)(`should rename to @openng - $testRunner`, async (testRunner) => { + createTreeWithRunner(testRunner); + const result = await runner.runSchematic('nto', {}, tree); + const content = result.readContent(pathStr); + + expect(content).toContain(`from '${resolveOpenNgModule(testRunner)}'`); + expect(content).not.toContain(`from '${resolveNgNeatModule(testRunner)}'`); + expect(content).toContain(`import { createPipeFactory, SpectatorPipe }`); + }); + }); + + describe('ngneat/service', () => { + const pathStr = '/src/ngneat.service.ts'; + + /** + * Builds a test tree seeded with a service fixture for the given runner. + */ + function createTreeWithRunner(testRunner: (typeof TEST_RUNNERS)[number]) { + tree.create( + pathStr, + createTestFixtureContent({ + spectatorType: 'SpectatorService', + factoryName: 'createServiceFactory', + type: 'service', + testRunner, + testBody: ` beforeEach(() => spectator = createService()); + + it('should...', () => { + expect(spectator.service).toBeTruthy(); + });`, + }), + ); + } + + it.each(TEST_RUNNERS)(`should rename to @openng - $testRunner`, async (testRunner) => { + createTreeWithRunner(testRunner); + const result = await runner.runSchematic('nto', {}, tree); + const content = result.readContent(pathStr); + + expect(content).toContain(`from '${resolveOpenNgModule(testRunner)}'`); + expect(content).not.toContain(`from '${resolveNgNeatModule(testRunner)}'`); + expect(content).toContain(`import { createServiceFactory, SpectatorService }`); + }); + }); + + describe('ngneat/component', () => { + const pathStr = '/src/ngneat.component.ts'; + + /** + * Builds a test tree seeded with a component fixture for the given runner. + */ + function createTreeWithRunner(testRunner: (typeof TEST_RUNNERS)[number]) { + tree.create( + pathStr, + createTestFixtureContent({ + spectatorType: 'Spectator', + factoryName: 'createComponentFactory', + type: 'component', + testRunner, + testBody: ` it('should create', () => { + spectator = createComponent(); + + expect(spectator.component).toBeTruthy(); + });`, + }), + ); + } + + it.each(TEST_RUNNERS)(`should rename to @openng - $testRunner`, async (testRunner) => { + createTreeWithRunner(testRunner); + const result = await runner.runSchematic('nto', {}, tree); + const content = result.readContent(pathStr); + + expect(content).toContain(`from '${resolveOpenNgModule(testRunner)}'`); + expect(content).not.toContain(`from '${resolveNgNeatModule(testRunner)}'`); + expect(content).toContain(`import { createComponentFactory, Spectator }`); + }); + }); + + describe('package.json', () => { + it('should remove ngneat dependencies', async () => { + const result = await runner.runSchematic('nto', {}, tree); + const content = result.readContent('package.json'); + + expect(content).not.toContain('@ngneat/spectator'); + }); + }); + + describe('edge cases', () => { + it('leaves unrelated files alone', async () => { + const content = `import { Component } from '@angular/core'; + +@Component({}) +export class Unrelated {}`; + + tree.create('/src/unrelated.ts', content); + const result = await runner.runSchematic('nto', {}, tree); + + expect(result.readContent('/src/unrelated.ts')).toBe(content); + }); + + it('ignores partial prefix matches like @ngneat/spectator-testing', async () => { + const content = `import { Something } from '@ngneat/spectator-testing'; +import { Other } from '@ngneat/spectator-fork/vitest'; + +console.log(Something, Other);`; + + tree.create('/src/lookalike.ts', content); + const result = await runner.runSchematic('nto', {}, tree); + + expect(result.readContent('/src/lookalike.ts')).toBe(content); + }); + + it('handles multiple imports from @ngneat/spectator in the same file', async () => { + const content = `import { Spectator, createComponentFactory } from '@ngneat/spectator'; +import { MockProvider } from '@ngneat/spectator'; +import { Component } from '@angular/core'; + +describe('multi-import', () => {});`; + + tree.create('/src/multi.ts', content); + const result = await runner.runSchematic('nto', {}, tree); + const updated = result.readContent('/src/multi.ts'); + + expect(updated).toContain(`from '@openng/spectator'`); + expect(updated).not.toContain(`from '@ngneat/spectator'`); + // Both import lines should be rewritten — count occurrences + expect(updated.match(/@ngneat\/spectator/g)).toBeNull(); + expect(updated.match(/@openng\/spectator/g)?.length).toBe(2); + }); + + it('rewrites export declarations from @ngneat/spectator', async () => { + const content = `export { Spectator, createComponentFactory } from '@ngneat/spectator'; +export { MockProvider } from '@ngneat/spectator/jest';`; + + tree.create('/src/barrel.ts', content); + const result = await runner.runSchematic('nto', {}, tree); + const updated = result.readContent('/src/barrel.ts'); + + expect(updated).toContain(`from '@openng/spectator'`); + expect(updated).toContain(`from '@openng/spectator/jest'`); + expect(updated).not.toContain(`from '@ngneat/spectator'`); + }); + + it('skips non-TypeScript files', async () => { + const content = "import { Spectator } from '@ngneat/spectator';"; + + tree.create('/src/notes.md', content); + const result = await runner.runSchematic('nto', {}, tree); + + expect(result.readContent('/src/notes.md')).toBe(content); + }); + }); +}); diff --git a/projects/spectator/schematics/src/ngneat-to-openng/index.ts b/projects/spectator/schematics/src/ngneat-to-openng/index.ts new file mode 100644 index 00000000..7dfb56d7 --- /dev/null +++ b/projects/spectator/schematics/src/ngneat-to-openng/index.ts @@ -0,0 +1,80 @@ +import { SchematicContext, Tree, type UpdateRecorder } from '@angular-devkit/schematics'; +import { removePackageJsonDependency } from '@schematics/angular/utility/dependencies'; +import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks/index.js'; +import type { SourceFile } from 'typescript'; +import * as ts from 'typescript'; + +const OLD_PKG = '@ngneat/spectator'; +const NEW_PKG = '@openng/spectator'; + +/** + * Creates a visitor function that replaces occurrences of an old module prefix with a new one + * within import or export declarations in a TypeScript source file. + * Supports both exact matches (`@ngneat/spectator`) and sub-paths (`@ngneat/spectator/jest`). + * + * @param sourceFile - The TypeScript source/AST node being visited. + * @param oldModule - The original package name. + * @param newModule - The replacement package name. + * @param recorder - The update recorder used to apply changes to the tree. + * @param state - An object containing a `hasChanged` flag to track if any replacements were made. + * + * @returns A visitor function that traverses the AST and applies replacements. + */ +function visiteFactory( + sourceFile: SourceFile, + oldModule: string, + newModule: string, + recorder: UpdateRecorder, + state: { hasChanged: boolean }, +) { + const visit = (node: ts.Node) => { + const isImportOrExport = ts.isImportDeclaration(node) || ts.isExportDeclaration(node); + + if (isImportOrExport && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { + const text = node.moduleSpecifier.text; + if (text === oldModule || text.startsWith(oldModule + '/')) { + const specifier = node.moduleSpecifier; + const start = specifier.getStart(sourceFile) + 1; // +1 to skip the opening quote + + recorder.remove(start, text.length); + recorder.insertRight(start, newModule + text.slice(oldModule.length)); + state.hasChanged = true; + } + } + + ts.forEachChild(node, visit); + }; + return visit; +} + +export function migrate() { + return (tree: Tree, context: SchematicContext) => { + // Update the import + tree.visit((filePath, entry) => { + // Early return if the file is in node_modules or dist directories + if (filePath.includes('node_modules') || filePath.includes('dist')) { + return; + } + // Early return if the file is not a TypeScript file or if the entry is null + if (!entry || !filePath.endsWith('.ts')) { + return; + } + + const sourceText = entry.content.toString('utf-8'); + const sourceFile = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true); + const recorder = tree.beginUpdate(filePath); + const state = { hasChanged: false }; + + const visit = visiteFactory(sourceFile, OLD_PKG, NEW_PKG, recorder, state); + visit(sourceFile); + + if (state.hasChanged) { + tree.commitUpdate(recorder); + } + }); + + // Update the package.json to remove @ngneat/spectator dependencies + removePackageJsonDependency(tree, '@ngneat/spectator'); + context.addTask(new NodePackageInstallTask()); + }; +} diff --git a/projects/spectator/schematics/src/ngneat-to-openng/schema.json b/projects/spectator/schematics/src/ngneat-to-openng/schema.json new file mode 100644 index 00000000..170f3860 --- /dev/null +++ b/projects/spectator/schematics/src/ngneat-to-openng/schema.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "ngneatToOpenng", + "title": "Migration from @ngneat/spectator to @openng/spectator Options Schema", + "description": "Automatic migration of import of @ngneat/spectator to @openng/spectator" +} \ No newline at end of file diff --git a/projects/spectator/schematics/src/spectator/component-schema.json b/projects/spectator/schematics/src/spectator/component-schema.json index ac221395..a8cc9f2d 100644 --- a/projects/spectator/schematics/src/spectator/component-schema.json +++ b/projects/spectator/schematics/src/spectator/component-schema.json @@ -52,9 +52,9 @@ }, "changeDetection": { "description": "The change detection strategy to use in the new component.", - "enum": ["Default", "OnPush"], + "enum": ["Eager", "OnPush"], "type": "string", - "default": "Default", + "default": "OnPush", "alias": "c" }, "prefix": { diff --git a/projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts b/projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts.template similarity index 99% rename from projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts rename to projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts.template index 5501dc7b..8cc8f2ab 100644 --- a/projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts +++ b/projects/spectator/schematics/src/spectator/files/component-custom-host/__name@dasherize__.__type@dasherize__.spec.ts.template @@ -1,6 +1,5 @@ import { Component, ChangeDetectionStrategy } from '@angular/core'; import { createHostFactory, SpectatorHost } from '@openng/spectator<% if (secondaryEntryPoint) { %>/<%= secondaryEntryPoint%><% } %>'; - import { <%= classify(name)%>Component } from './<%= dasherize(name)%>.component'; @Component({ diff --git a/projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts b/projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts.template similarity index 99% rename from projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts rename to projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts.template index 6287c051..ac2a5a0b 100644 --- a/projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts +++ b/projects/spectator/schematics/src/spectator/files/component-host/__name@dasherize__.__type@dasherize__.spec.ts.template @@ -1,5 +1,4 @@ import { createHostFactory, SpectatorHost } from '@openng/spectator<% if (secondaryEntryPoint) { %>/<%= secondaryEntryPoint%><% } %>'; - import { <%= classify(name)%>Component } from './<%= dasherize(name)%>.component'; describe('<%= classify(name)%>Component', () => { diff --git a/projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts b/projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts.template similarity index 99% rename from projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts rename to projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts.template index 3e4cb38f..a81d1f69 100644 --- a/projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts +++ b/projects/spectator/schematics/src/spectator/files/component/__name@dasherize__.__type@dasherize__.spec.ts.template @@ -1,5 +1,4 @@ import { Spectator, createComponentFactory } from '@openng/spectator<% if (secondaryEntryPoint) { %>/<%= secondaryEntryPoint%><% } %>'; - import { <%= classify(name)%>Component } from './<%= dasherize(name)%>.component'; describe('<%= classify(name)%>Component', () => { diff --git a/projects/spectator/schematics/src/spectator/files/data-service/__name@dasherize__.service.spec.ts b/projects/spectator/schematics/src/spectator/files/data-service/__name@dasherize__.service.spec.ts.template similarity index 100% rename from projects/spectator/schematics/src/spectator/files/data-service/__name@dasherize__.service.spec.ts rename to projects/spectator/schematics/src/spectator/files/data-service/__name@dasherize__.service.spec.ts.template diff --git a/projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts b/projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts.template similarity index 99% rename from projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts rename to projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts.template index ee2bc648..bbfb57e9 100644 --- a/projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts +++ b/projects/spectator/schematics/src/spectator/files/directive/__name@dasherize__.directive.spec.ts.template @@ -1,5 +1,4 @@ import { createDirectiveFactory, SpectatorDirective } from '@openng/spectator<% if (secondaryEntryPoint) { %>/<%= secondaryEntryPoint%><% } %>'; - import { <%= classify(name)%>Directive } from './<%= dasherize(name)%>.directive'; describe('<%= classify(name)%>Directive', () => { diff --git a/projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts b/projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts.template similarity index 99% rename from projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts rename to projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts.template index f4f51a7e..f73a3e0c 100644 --- a/projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts +++ b/projects/spectator/schematics/src/spectator/files/pipe/__name@dasherize__.pipe.spec.ts.template @@ -1,5 +1,4 @@ import { createPipeFactory, SpectatorPipe } from '@openng/spectator<% if (secondaryEntryPoint) { %>/<%= secondaryEntryPoint%><% } %>'; - import { <%= classify(name)%>Pipe } from './<%= dasherize(name)%>.pipe'; describe('<%= classify(name)%>Pipe ', () => { diff --git a/projects/spectator/schematics/src/spectator/files/service/__name@dasherize__.service.spec.ts b/projects/spectator/schematics/src/spectator/files/service/__name@dasherize__.service.spec.ts.template similarity index 100% rename from projects/spectator/schematics/src/spectator/files/service/__name@dasherize__.service.spec.ts rename to projects/spectator/schematics/src/spectator/files/service/__name@dasherize__.service.spec.ts.template diff --git a/projects/spectator/schematics/src/spectator/index.js b/projects/spectator/schematics/src/spectator/index.js deleted file mode 100644 index 5907edbb..00000000 --- a/projects/spectator/schematics/src/spectator/index.js +++ /dev/null @@ -1,140 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.spectatorComponentSchematic = spectatorComponentSchematic; -exports.spectatorServiceSchematic = spectatorServiceSchematic; -exports.spectatorDirectiveSchematic = spectatorDirectiveSchematic; -exports.spectatorPipeSchematic = spectatorPipeSchematic; -const core_1 = require("@angular-devkit/core"); -const schematics_1 = require("@angular-devkit/schematics"); -const workspace_1 = require("@schematics/angular/utility/workspace"); -const parse_name_1 = require("@schematics/angular/utility/parse-name"); -function spectatorComponentSchematic(options) { - return (0, schematics_1.chain)([ - (0, schematics_1.externalSchematic)('@schematics/angular', 'component', { - ...omit(options, ['jest', 'withHost', 'withCustomHost', 'unitTestRunner']), - skipTests: true, - }), - async (tree, _context) => { - if (options.skipTests) { - return schematics_1.noop; - } - await _ensurePath(tree, options); - const movePath = options.flat ? options.path : (0, core_1.normalize)(options.path + '/' + core_1.strings.dasherize(options.name) || ''); - const specTemplateRule = (0, schematics_1.apply)((0, schematics_1.url)(`./files/${options.withHost ? 'component-host' : options.withCustomHost ? 'component-custom-host' : 'component'}`), [ - (0, schematics_1.template)({ - ...core_1.strings, - ...options, - secondaryEntryPoint: getSecondaryEntryPoint(options), - }), - (0, schematics_1.move)(movePath), - ]); - return (0, schematics_1.mergeWith)(specTemplateRule, schematics_1.MergeStrategy.Default); - }, - ]); -} -function spectatorServiceSchematic(options) { - return (0, schematics_1.chain)([ - (0, schematics_1.externalSchematic)('@schematics/angular', 'service', { - ...omit(options, ['jest', 'isDataService', 'unitTestRunner']), - skipTests: true, - }), - async (tree, _context) => { - if (options.skipTests) { - return schematics_1.noop; - } - await _ensurePath(tree, options); - const movePath = (0, core_1.normalize)(options.path || ''); - const specTemplateRule = (0, schematics_1.apply)((0, schematics_1.url)(`./files/${options.isDataService ? 'data-service' : `service`}`), [ - (0, schematics_1.template)({ - ...core_1.strings, - ...options, - secondaryEntryPoint: getSecondaryEntryPoint(options), - }), - (0, schematics_1.move)(movePath), - ]); - return (0, schematics_1.mergeWith)(specTemplateRule, schematics_1.MergeStrategy.Default); - }, - ]); -} -function spectatorDirectiveSchematic(options) { - return (0, schematics_1.chain)([ - (0, schematics_1.externalSchematic)('@schematics/angular', 'directive', { - ...omit(options, ['jest', 'unitTestRunner']), - skipTests: true, - }), - async (tree, _context) => { - if (options.skipTests) { - return schematics_1.noop; - } - await _ensurePath(tree, options); - const movePath = (0, core_1.normalize)(options.path || ''); - const specTemplateRule = (0, schematics_1.apply)((0, schematics_1.url)(`./files/directive`), [ - (0, schematics_1.template)({ - ...core_1.strings, - ...options, - secondaryEntryPoint: getSecondaryEntryPoint(options), - }), - (0, schematics_1.move)(movePath), - ]); - return (0, schematics_1.mergeWith)(specTemplateRule, schematics_1.MergeStrategy.Default); - }, - ]); -} -function spectatorPipeSchematic(options) { - return (0, schematics_1.chain)([ - (0, schematics_1.externalSchematic)('@schematics/angular', 'pipe', { - ...omit(options, ['jest', 'unitTestRunner']), - skipTests: true, - }), - async (tree, _context) => { - if (options.skipTests) { - return schematics_1.noop; - } - await _ensurePath(tree, options); - const movePath = (0, core_1.normalize)(options.path || ''); - const specTemplateRule = (0, schematics_1.apply)((0, schematics_1.url)(`./files/pipe`), [ - (0, schematics_1.template)({ - ...core_1.strings, - ...options, - secondaryEntryPoint: getSecondaryEntryPoint(options), - }), - (0, schematics_1.move)(movePath), - ]); - return (0, schematics_1.mergeWith)(specTemplateRule, schematics_1.MergeStrategy.Default); - }, - ]); -} -async function _ensurePath(tree, options) { - const workspace = await (0, workspace_1.getWorkspace)(tree); - if (!options.project) { - options.project = workspace.projects.keys().next().value; - } - const project = workspace.projects.get(options.project); - if (options.path === undefined && project) { - options.path = (0, workspace_1.buildDefaultPath)(project); - } - const parsedPath = (0, parse_name_1.parseName)(options.path, options.name); - options.name = parsedPath.name; - options.path = parsedPath.path; -} -function omit(original, keys) { - return Object.keys(original) - .filter((key) => !keys.includes(key)) - .reduce((obj, key) => { - obj[key] = original[key]; - return obj; - }, {}); -} -function getSecondaryEntryPoint(options) { - const secondaryEntryPoints = { - jest: 'jest', - vitest: 'vitest', - jasmine: null, - }; - if (options.jest) { - console.warn('The `jest` option is deprecated and will be removed in the future. Use `unitTestRunner` instead.'); - return secondaryEntryPoints.jest; - } - return secondaryEntryPoints[options.unitTestRunner]; -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/projects/spectator/schematics/src/spectator/index.js.map b/projects/spectator/schematics/src/spectator/index.js.map deleted file mode 100644 index 89f2815a..00000000 --- a/projects/spectator/schematics/src/spectator/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAoBA,kEA6BC;AAED,8DAyBC;AAED,kEAyBC;AAED,wDAyBC;AAlID,+CAA0D;AAC1D,2DAaoC;AACpC,qEAAuF;AACvF,uEAAmE;AAInE,SAAgB,2BAA2B,CAAC,OAAyB;IACnE,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,8BAAiB,EAAC,qBAAqB,EAAE,WAAW,EAAE;YACpD,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;YAC1E,SAAS,EAAE,IAAI;SAChB,CAAC;QACF,KAAK,EAAE,IAAU,EAAE,QAA0B,EAAiB,EAAE;YAC9D,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACtB,OAAO,iBAAI,CAAC;YACd,CAAC;YAED,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACjC,MAAM,QAAQ,GA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} \ No newline at end of file diff --git a/projects/spectator/schematics/src/spectator/index.ts b/projects/spectator/schematics/src/spectator/index.ts index 60ae36bf..0c18f8d0 100644 --- a/projects/spectator/schematics/src/spectator/index.ts +++ b/projects/spectator/schematics/src/spectator/index.ts @@ -1,21 +1,20 @@ import { normalize, strings } from '@angular-devkit/core'; import { apply, + applyTemplates, chain, externalSchematic, + MergeStrategy, mergeWith, move, - template, - url, - MergeStrategy, + noop, Rule, SchematicContext, Tree, - noop, + url, } from '@angular-devkit/schematics'; -import { buildDefaultPath, getWorkspace } from '@schematics/angular/utility/workspace'; import { parseName } from '@schematics/angular/utility/parse-name'; - +import { buildDefaultPath, getWorkspace } from '@schematics/angular/utility/workspace'; import { ComponentOptions, DirectiveOptions, PipeOptions, ServiceOptions, UnitTestRunner } from './schema'; export function spectatorComponentSchematic(options: ComponentOptions): Rule { @@ -35,9 +34,10 @@ export function spectatorComponentSchematic(options: ComponentOptions): Rule { const specTemplateRule = apply( url(`./files/${options.withHost ? 'component-host' : options.withCustomHost ? 'component-custom-host' : 'component'}`), [ - template({ + applyTemplates({ ...strings, ...options, + type: 'component', secondaryEntryPoint: getSecondaryEntryPoint(options), }), move(movePath), @@ -63,9 +63,10 @@ export function spectatorServiceSchematic(options: ServiceOptions): Rule { await _ensurePath(tree, options); const movePath = normalize(options.path || ''); const specTemplateRule = apply(url(`./files/${options.isDataService ? 'data-service' : `service`}`), [ - template({ + applyTemplates({ ...strings, ...options, + type: 'service', secondaryEntryPoint: getSecondaryEntryPoint(options), }), move(movePath), @@ -90,9 +91,10 @@ export function spectatorDirectiveSchematic(options: DirectiveOptions): Rule { await _ensurePath(tree, options); const movePath = normalize(options.path || ''); const specTemplateRule = apply(url(`./files/directive`), [ - template({ + applyTemplates({ ...strings, ...options, + type: 'directive', secondaryEntryPoint: getSecondaryEntryPoint(options), }), move(movePath), @@ -117,9 +119,10 @@ export function spectatorPipeSchematic(options: PipeOptions): Rule { await _ensurePath(tree, options); const movePath = normalize(options.path || ''); const specTemplateRule = apply(url(`./files/pipe`), [ - template({ + applyTemplates({ ...strings, ...options, + type: 'pipe', secondaryEntryPoint: getSecondaryEntryPoint(options), }), move(movePath), diff --git a/projects/spectator/schematics/src/spectator/schema.js b/projects/spectator/schematics/src/spectator/schema.js deleted file mode 100644 index 69b842cb..00000000 --- a/projects/spectator/schematics/src/spectator/schema.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PipeOptions = exports.DirectiveOptions = exports.ServiceOptions = exports.ComponentOptions = void 0; -class ComponentOptions { -} -exports.ComponentOptions = ComponentOptions; -class ServiceOptions { -} -exports.ServiceOptions = ServiceOptions; -class DirectiveOptions { -} -exports.DirectiveOptions = DirectiveOptions; -class PipeOptions { -} -exports.PipeOptions = PipeOptions; -//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/projects/spectator/schematics/src/spectator/schema.js.map b/projects/spectator/schematics/src/spectator/schema.js.map deleted file mode 100644 index 40535d23..00000000 --- a/projects/spectator/schematics/src/spectator/schema.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";;;AAIA,MAAa,gBAAgB;CA8D5B;AA9DD,4CA8DC;AACD,MAAa,cAAc;CAqB1B;AArBD,wCAqBC;AACD,MAAa,gBAAgB;CAwC5B;AAxCD,4CAwCC;AACD,MAAa,WAAW;CAoCvB;AApCD,kCAoCC"} \ No newline at end of file diff --git a/projects/spectator/schematics/tsconfig.json b/projects/spectator/schematics/tsconfig.json index 59a9f4bb..32e188a9 100644 --- a/projects/spectator/schematics/tsconfig.json +++ b/projects/spectator/schematics/tsconfig.json @@ -1,23 +1,17 @@ { "compilerOptions": { - "lib": ["es2017", "dom"], - "module": "nodenext", - "moduleResolution": "nodenext", - "strictPropertyInitialization": false, - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitThis": true, - "noUnusedParameters": true, + "target": "es2022", + "module": "commonjs", + "lib": ["ES2022"], + "declaration": true, + "strict": true, "noUnusedLocals": true, - "rootDir": "src/", - "skipDefaultLibCheck": true, + "noImplicitAny": true, + "outDir": "../../../dist/schematics", + "rootDir": ".", "skipLibCheck": true, - "sourceMap": true, - "strictNullChecks": true, - "target": "ES2020", - "types": ["jasmine", "node"] + "esModuleInterop": true }, - "include": ["src/**/*"], - "exclude": ["src/*/files/**/*"] -} + "include": ["src/**/*.ts"], + "exclude": ["**/*.spec.ts", "**/*.js"] +} \ No newline at end of file diff --git a/projects/spectator/schematics/tsconfig.spec.json b/projects/spectator/schematics/tsconfig.spec.json new file mode 100644 index 00000000..05e450db --- /dev/null +++ b/projects/spectator/schematics/tsconfig.spec.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": ["jest", "node"] + }, + "include": ["src/**/*.spec.ts", "**/*.d.ts"], + "exclude": null +} diff --git a/yarn.lock b/yarn.lock index 2d451619..73313b33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7658,12 +7658,19 @@ es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: dependencies: es-errors "^1.3.0" +esbuild-plugin-tsc@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/esbuild-plugin-tsc/-/esbuild-plugin-tsc-0.6.0.tgz#0df768cc5b7e83e249c359393ff4e7c33d569d4f" + integrity sha512-j26KTBbDSXOzG+8Wh/YgGg6SGCPH1i8JZT1sATT+ED0mHfGpqb1iOHOUvfZry5rRu3Ue0LE9rX1ImkHLawwlgA== + dependencies: + strip-comments "^2.0.1" + esbuild-wasm@0.28.1, esbuild-wasm@>=0.28.0: version "0.28.1" resolved "https://registry.yarnpkg.com/esbuild-wasm/-/esbuild-wasm-0.28.1.tgz#b173826abdc645419c3c7ac77e2d9128286a7a79" integrity sha512-p/GD4E8oYRjg3kjdKrnMb0s4PzXgJF42e0MF4H0+ACyK/kIlFRp3e0fzOleIG+wBBm6MM3XQrbpe7soEA+vJIA== -esbuild@0.28.1, esbuild@>=0.28.0, esbuild@^0.28.0: +esbuild@0.28.1, esbuild@>=0.28.0, esbuild@^0.28.0, esbuild@^0.28.1: version "0.28.1" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.28.1.tgz#ef45b4634c9c9d97a296aea4114a5f9840f95578" integrity sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw== @@ -13412,6 +13419,11 @@ strip-bom@^3.0.0: resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz" integrity "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==" +strip-comments@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-2.0.1.tgz#4ad11c3fbcac177a67a40ac224ca339ca1c1ba9b" + integrity sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw== + strip-final-newline@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz"