Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(signals): initial setup #4002

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const packages: PackageDescription[] = fs
return false;
}

if (path.includes('eslint-plugin')) {
// TODO: Remove signals when released as a stable package
if (path.includes('eslint-plugin') || path.includes('signals')) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion build/copy-schematics-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const copySchematics = createBuilder([

copySchematics({
scope: '@ngrx',
packages,
// TODO: Remove signals when released as a stable package
packages: [...packages, { name: 'signals' }],
}).catch((err) => {
console.error(err);
process.exit(1);
Expand Down
26 changes: 26 additions & 0 deletions modules/signals/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "schematics-core"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"parserOptions": {
"project": ["modules/signals/tsconfig.*?.json"]
},
"rules": {
"@angular-eslint/directive-selector": "off",
"@angular-eslint/component-selector": "off"
},
"plugins": ["@typescript-eslint"]
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
3 changes: 3 additions & 0 deletions modules/signals/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Change Log

See [CHANGELOG.md](https://github.com/ngrx/platform/blob/main/CHANGELOG.md)
3 changes: 3 additions & 0 deletions modules/signals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @ngrx/signals

The sources for this package are in the main [NgRx](https://github.com/ngrx/platform) repo. Please file issues and pull requests against that repo.
7 changes: 7 additions & 0 deletions modules/signals/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* DO NOT EDIT
*
* This file is automatically generated at build
*/

export * from './public_api';
22 changes: 22 additions & 0 deletions modules/signals/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'Signals',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/signals',
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
4 changes: 4 additions & 0 deletions modules/signals/migrations/migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {}
}
8 changes: 8 additions & 0 deletions modules/signals/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/modules/signals",
"assets": ["migrations/**/*.json", "schematics/**/*.json", "**/files/**/*"],
"lib": {
"entryFile": "index.ts"
}
}
35 changes: 35 additions & 0 deletions modules/signals/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@ngrx/signals",
"version": "0.0.0",
"description": "Reactive State Management with Angular Signals",
"repository": {
"type": "git",
"url": "https://github.com/ngrx/platform.git"
},
"keywords": [
"Angular",
"NgRx",
"Signals",
"Signal Store",
"Signal State",
"State Management"
],
"author": "NgRx",
"license": "MIT",
"bugs": {
"url": "https://github.com/ngrx/platform/issues"
},
"homepage": "https://github.com/ngrx/platform#readme",
"peerDependencies": {
"@angular/core": "^16.1.0"
},
"schematics": "./schematics/collection.json",
"sideEffects": false,
"ng-update": {
"packageGroup": ["@ngrx/signals"],
"migrations": "./migrations/migration.json"
},
"dependencies": {
"tslib": "^2.3.0"
}
}
54 changes: 54 additions & 0 deletions modules/signals/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "signals",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "modules/signals/src",
"prefix": "ngrx",
"targets": {
"build-package": {
"executor": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "modules/signals/tsconfig.build.json",
"project": "modules/signals/ng-package.json"
}
},
"build": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"commands": [
{
"command": "nx build-package signals"
},
{
"command": "yarn tsc -p modules/signals/tsconfig.schematics.json"
},
{
"command": "cpy LICENSE dist/modules/signals"
}
]
},
"outputs": ["{workspaceRoot}/dist/modules/signals"]
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"modules/signals/*/**/*.ts",
"modules/signals/*/**/*.html"
]
},
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "modules/signals/jest.config.ts",
"runInBand": true
},
"outputs": ["{workspaceRoot}/coverage/modules/signals"]
}
},
"generators": {},
"tags": []
}
1 change: 1 addition & 0 deletions modules/signals/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/index';
94 changes: 94 additions & 0 deletions modules/signals/schematics-core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {
dasherize,
decamelize,
camelize,
classify,
underscore,
group,
capitalize,
featurePath,
pluralize,
} from './utility/strings';

export {
findNodes,
getSourceNodes,
getDecoratorMetadata,
getContentOfKeyLiteral,
insertAfterLastOccurrence,
insertImport,
addBootstrapToModule,
addDeclarationToModule,
addExportToModule,
addImportToModule,
addProviderToComponent,
addProviderToModule,
replaceImport,
containsProperty,
} from './utility/ast-utils';

export {
Host,
Change,
NoopChange,
InsertChange,
RemoveChange,
ReplaceChange,
createReplaceChange,
createChangeRecorder,
commitChanges,
} from './utility/change';

export { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';

export { findComponentFromOptions } from './utility/find-component';

export {
findModule,
findModuleFromOptions,
buildRelativePath,
ModuleOptions,
} from './utility/find-module';

export { findPropertyInAstObject } from './utility/json-utilts';

export {
addReducerToState,
addReducerToStateInterface,
addReducerImportToNgModule,
addReducerToActionReducerMap,
omit,
getPrefix,
} from './utility/ngrx-utils';

export { getProjectPath, getProject, isLib } from './utility/project';

export const stringUtils = {
dasherize,
decamelize,
camelize,
classify,
underscore,
group,
capitalize,
featurePath,
pluralize,
};

export { updatePackage } from './utility/update';

export { parseName } from './utility/parse-name';

export { addPackageToPackageJson } from './utility/package';

export { platformVersion } from './utility/libs-version';

export {
visitTSSourceFiles,
visitNgModuleImports,
visitNgModuleExports,
visitComponents,
visitDecorator,
visitNgModules,
visitTemplates,
} from './utility/visitors';
18 changes: 18 additions & 0 deletions modules/signals/schematics-core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
displayName: 'Schematics Core',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: {
before: [
'jest-preset-angular/build/InlineFilesTransformer',
'jest-preset-angular/build/StripStylesTransformer',
],
},
},
},
coverageDirectory: '../../coverage/modules/schematics-core',
};
22 changes: 22 additions & 0 deletions modules/signals/schematics-core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'Schematics Core',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/schematics-core',
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
1 change: 1 addition & 0 deletions modules/signals/schematics-core/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';
13 changes: 13 additions & 0 deletions modules/signals/schematics-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
22 changes: 22 additions & 0 deletions modules/signals/schematics-core/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"baseUrl": ".",
"stripInternal": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"downlevelIteration": true,
"outDir": "../../dist/modules/schematics-score",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"skipLibCheck": true,
"strict": true
},
"include": ["**/*.ts"],
"exclude": ["**/*.spec.ts", "test-setup.ts"],
"angularCompilerOptions": {
"skipMetadataEmit": true,
"enableSummariesForJit": false,
"enableIvy": false
}
}
11 changes: 11 additions & 0 deletions modules/signals/schematics-core/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"],
"target": "es2016"
},
"files": ["test-setup.ts"],
"include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}
Loading