Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ngrx/schematics

Package Overview
Dependencies
Maintainers
4
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngrx/schematics - npm Package Compare versions

Comparing version 12.4.0 to 12.5.0

2

package.json
{
"name": "@ngrx/schematics",
"version": "12.4.0",
"version": "12.5.0",
"description": "NgRx Schematics for Angular",

@@ -5,0 +5,0 @@ "repository": {

@@ -10,3 +10,3 @@ "use strict";

exports.__esModule = true;
exports.visitTemplates = exports.visitNgModules = exports.visitDecorator = exports.visitComponents = exports.visitNgModuleExports = exports.visitNgModuleImports = exports.visitTSSourceFiles = exports.platformVersion = exports.addPackageToPackageJson = exports.parseName = exports.updatePackage = exports.stringUtils = exports.isLib = exports.getProject = exports.getProjectPath = exports.omit = exports.addReducerToActionReducerMap = exports.addReducerImportToNgModule = exports.addReducerToStateInterface = exports.addReducerToState = exports.findPropertyInAstObject = exports.buildRelativePath = exports.findModuleFromOptions = exports.findModule = exports.findComponentFromOptions = exports.getWorkspacePath = exports.getWorkspace = exports.commitChanges = exports.createChangeRecorder = exports.createReplaceChange = exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = exports.containsProperty = exports.replaceImport = exports.addProviderToModule = exports.addProviderToComponent = exports.addImportToModule = exports.addExportToModule = exports.addDeclarationToModule = exports.addBootstrapToModule = exports.insertImport = exports.insertAfterLastOccurrence = exports.getContentOfKeyLiteral = exports.getDecoratorMetadata = exports.getSourceNodes = exports.findNodes = exports.isIvyEnabled = void 0;
exports.visitTemplates = exports.visitNgModules = exports.visitDecorator = exports.visitComponents = exports.visitNgModuleExports = exports.visitNgModuleImports = exports.visitTSSourceFiles = exports.platformVersion = exports.addPackageToPackageJson = exports.parseName = exports.updatePackage = exports.stringUtils = exports.isLib = exports.getProject = exports.getProjectPath = exports.getPrefix = exports.omit = exports.addReducerToActionReducerMap = exports.addReducerImportToNgModule = exports.addReducerToStateInterface = exports.addReducerToState = exports.findPropertyInAstObject = exports.buildRelativePath = exports.findModuleFromOptions = exports.findModule = exports.findComponentFromOptions = exports.getWorkspacePath = exports.getWorkspace = exports.commitChanges = exports.createChangeRecorder = exports.createReplaceChange = exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = exports.containsProperty = exports.replaceImport = exports.addProviderToModule = exports.addProviderToComponent = exports.addImportToModule = exports.addExportToModule = exports.addDeclarationToModule = exports.addBootstrapToModule = exports.insertImport = exports.insertAfterLastOccurrence = exports.getContentOfKeyLiteral = exports.getDecoratorMetadata = exports.getSourceNodes = exports.findNodes = exports.isIvyEnabled = void 0;
var strings_1 = require("./utility/strings");

@@ -55,2 +55,3 @@ var angular_utils_1 = require("./utility/angular-utils");

__createBinding(exports, ngrx_utils_1, "omit");
__createBinding(exports, ngrx_utils_1, "getPrefix");
var project_1 = require("./utility/project");

@@ -57,0 +58,0 @@ __createBinding(exports, project_1, "getProjectPath");

"use strict";
exports.__esModule = true;
require("jest-preset-angular");
require("jest-preset-angular/setup-jest");
//# sourceMappingURL=test-setup.js.map
"use strict";
exports.__esModule = true;
exports.platformVersion = void 0;
exports.platformVersion = '^12.4.0';
exports.platformVersion = '^12.5.0';
//# sourceMappingURL=libs-version.js.map

@@ -35,3 +35,3 @@ "use strict";

exports.__esModule = true;
exports.omit = exports.addReducerImportToNgModule = exports.addReducerToActionReducerMap = exports.addReducerToStateInterface = exports.addReducerToState = void 0;
exports.getPrefix = exports.omit = exports.addReducerImportToNgModule = exports.addReducerToActionReducerMap = exports.addReducerToStateInterface = exports.addReducerToState = void 0;
var ts = require("typescript");

@@ -241,2 +241,8 @@ var stringUtils = require("./strings");

exports.omit = omit;
function getPrefix(options) {
return options.creators
? stringUtils.camelize(options.prefix || 'load')
: stringUtils.capitalize(options.prefix || 'load');
}
exports.getPrefix = getPrefix;
//# sourceMappingURL=ngrx-utils.js.map

@@ -16,9 +16,6 @@ "use strict";

var schematics_core_1 = require("../../schematics-core");
var strings_1 = require("../../schematics-core/utility/strings");
function default_1(options) {
return function (host, context) {
options.path = schematics_core_1.getProjectPath(host, options);
options.prefix = options.creators
? strings_1.camelize(options.prefix || 'load')
: strings_1.capitalize(options.prefix || 'load');
options.prefix = schematics_core_1.getPrefix(options);
var parsedPath = schematics_core_1.parseName(options.path, options.name);

@@ -25,0 +22,0 @@ options.name = parsedPath.name;

@@ -98,8 +98,10 @@ "use strict";

}
function getEffectStart(name, creators) {
function getEffectStart(name, effectPrefix, creators) {
var effectName = schematics_core_1.stringUtils.classify(name);
var effectMethodPrefix = schematics_core_1.stringUtils.camelize(effectPrefix);
return creators
? "load" + effectName + "s$ = createEffect(() => {" +
? "" + effectMethodPrefix + effectName + "s$ = createEffect(() => {" +
'\n return this.actions$.pipe( \n'
: '@Effect()\n' + (" load" + effectName + "s$ = this.actions$.pipe(");
: '@Effect()\n' +
(" " + effectMethodPrefix + effectName + "s$ = this.actions$.pipe(");
}

@@ -112,2 +114,3 @@ function getEffectEnd(creators) {

options.path = schematics_core_1.getProjectPath(host, options);
options.prefix = schematics_core_1.getPrefix(options);
if (options.module) {

@@ -126,3 +129,3 @@ options.module = schematics_core_1.findModuleFromOptions(host, options);

return schematics_core_1.stringUtils.group(options.flat ? '' : s, options.group ? 'effects' : '');
}, effectMethod: getEffectMethod(options.creators), effectStart: getEffectStart(options.name, options.creators), effectEnd: getEffectEnd(options.creators) }), options)),
}, effectMethod: getEffectMethod(options.creators), effectStart: getEffectStart(options.name, options.prefix, options.creators), effectEnd: getEffectEnd(options.creators) }), options)),
schematics_1.move(parsedPath.path),

@@ -129,0 +132,0 @@ ]);

@@ -30,2 +30,3 @@ import {

creators: false,
prefix: 'load',
};

@@ -467,2 +468,64 @@

});
it('should add prefix to the effect', async () => {
const options = {
...defaultOptions,
prefix: 'custom',
feature: true,
api: true,
};
const tree = await schematicRunner
.runSchematicAsync('effect', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.effects.ts`
);
expect(content).toMatch(
/import { CustomFoosFailure, CustomFoosSuccess, FooActionTypes, FooActions } from '\.\/foo.actions';/
);
expect(content).toMatch(/customFoos\$ = this\.actions\$.pipe\(/);
expect(content).toMatch(/ofType\(FooActionTypes\.CustomFoos\),/);
expect(content).toMatch(
/map\(data => new CustomFoosSuccess\({ data }\)\),/
);
expect(content).toMatch(
/catchError\(error => of\(new CustomFoosFailure\({ error }\)\)\)\)/
);
});
it('should add prefix to the effect using creator function', async () => {
const options = {
...defaultOptions,
creators: true,
api: true,
feature: true,
prefix: 'custom',
};
const tree = await schematicRunner
.runSchematicAsync('effect', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.effects.ts`
);
expect(content).toMatch(
/customFoos\$ = createEffect\(\(\) => {\s* return this.actions\$.pipe\(/
);
expect(content).toMatch(/ofType\(FooActions.customFoos\),/);
expect(content).toMatch(
/map\(data => FooActions.customFoosSuccess\({ data }\)\),/
);
expect(content).toMatch(
/catchError\(error => of\(FooActions.customFoosFailure\({ error }\)\)\)\)/
);
});
});

@@ -79,2 +79,8 @@ {

"description": "Setup root effects module without registering initial effects."
},
"prefix": {
"description": "The prefix of the effect.",
"type": "string",
"default": "load",
"x-prompt": "What should be the prefix of the effect?"
}

@@ -81,0 +87,0 @@ },

@@ -15,3 +15,4 @@ "use strict";

api: options.api,
creators: options.creators
creators: options.creators,
prefix: options.prefix
}),

@@ -29,3 +30,4 @@ schematics_1.schematic('reducer', {

api: options.api,
creators: options.creators
creators: options.creators,
prefix: options.prefix
}),

@@ -42,3 +44,4 @@ schematics_1.schematic('effect', {

api: options.api,
creators: options.creators
creators: options.creators,
prefix: options.prefix
}),

@@ -45,0 +48,0 @@ schematics_1.schematic('selector', {

@@ -274,2 +274,50 @@ import {

});
it('should have all api effect with prefix if api flag enabled', async () => {
const options = {
...defaultOptions,
api: true,
prefix: 'custom',
};
const tree = await schematicRunner
.runSchematicAsync('feature', options, appTree)
.toPromise();
const fileContent = tree.readContent(
`${projectPath}/src/app/foo.effects.ts`
);
expect(fileContent).toMatch(/customFoos\$ = createEffect\(\(\) => {/);
expect(fileContent).toMatch(/ofType\(FooActions.customFoos\),/);
expect(fileContent).toMatch(
/map\(data => FooActions.customFoosSuccess\({ data }\)\),/
);
expect(fileContent).toMatch(
/catchError\(error => of\(FooActions.customFoosFailure\({ error }\)\)\)\)/
);
});
it('should have all api actions with prefix in reducer if api flag enabled', async () => {
const options = {
...defaultOptions,
api: true,
prefix: 'custom',
};
const tree = await schematicRunner
.runSchematicAsync('feature', options, appTree)
.toPromise();
const fileContent = tree.readContent(
`${projectPath}/src/app/foo.reducer.ts`
);
expect(fileContent).toMatch(/on\(FooActions.customFoos, state => state\),/);
expect(fileContent).toMatch(
/on\(FooActions.customFoosSuccess, \(state, action\) => state\),/
);
expect(fileContent).toMatch(
/on\(FooActions.customFoosFailure, \(state, action\) => state\),/
);
});
});

@@ -66,2 +66,8 @@ {

"x-prompt": "Do you want to use the create functions?"
},
"prefix": {
"description": "The prefix of the action, effect and reducer.",
"type": "string",
"default": "load",
"x-prompt": "What should be the prefix of the action, effect and reducer?"
}

@@ -68,0 +74,0 @@ },

@@ -20,2 +20,3 @@ "use strict";

options.path = schematics_core_1.getProjectPath(host, options);
options.prefix = schematics_core_1.getPrefix(options);
if (options.module) {

@@ -22,0 +23,0 @@ options.module = schematics_core_1.findModuleFromOptions(host, options);

@@ -342,2 +342,23 @@ import {

});
it('should create a reducer with prefix in an api feature', async () => {
const tree = await schematicRunner
.runSchematicAsync(
'reducer',
{ ...defaultOptions, feature: true, api: true, prefix: 'custom' },
appTree
)
.toPromise();
const fileContent = tree.readContent(
`${projectPath}/src/app/foo.reducer.ts`
);
expect(fileContent).toMatch(/on\(FooActions.customFoos, state => state\)/);
expect(fileContent).toMatch(
/on\(FooActions.customFoosSuccess, \(state, action\) => state\)/
);
expect(fileContent).toMatch(
/on\(FooActions.customFoosFailure, \(state, action\) => state\)/
);
});
});

@@ -73,3 +73,9 @@ {

},
"prefix": {
"description": "The prefix of the reducer.",
"type": "string",
"default": "load",
"x-prompt": "What should be the prefix of the reducer?"
},
"required": []
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc