@spartacus/user
Version:
User feature library for Spartacus
84 lines • 3.48 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addUserFeatures = void 0;
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@spartacus/schematics");
const package_json_1 = require("../../package.json");
const constants_1 = require("../constants");
function addUserFeatures(options) {
return (tree, _context) => {
const packageJson = schematics_2.readPackageJson(tree);
schematics_2.validateSpartacusInstallation(packageJson);
return schematics_1.chain([
schematics_2.addPackageJsonDependenciesForLibrary(package_json_1.peerDependencies, options),
schematics_2.shouldAddFeature(schematics_2.CLI_USER_ACCOUNT_FEATURE, options.features)
? addAccountFeature(options)
: schematics_1.noop(),
schematics_2.shouldAddFeature(schematics_2.CLI_USER_PROFILE_FEATURE, options.features)
? addProfileFeature(options)
: schematics_1.noop(),
]);
};
}
exports.addUserFeatures = addUserFeatures;
function addAccountFeature(options) {
return schematics_2.addLibraryFeature(options, {
folderName: constants_1.USER_FOLDER_NAME,
moduleName: constants_1.USER_MODULE_NAME,
featureModule: {
name: constants_1.USER_ACCOUNT_MODULE,
importPath: constants_1.SPARTACUS_USER_ACCOUNT,
},
rootModule: {
name: constants_1.USER_ACCOUNT_ROOT_MODULE,
importPath: constants_1.SPARTACUS_USER_ACCOUNT_ROOT,
},
lazyLoadingChunk: {
moduleSpecifier: constants_1.SPARTACUS_USER_ACCOUNT_ROOT,
namedImports: [constants_1.USER_ACCOUNT_FEATURE_NAME_CONSTANT],
},
i18n: {
resources: constants_1.USER_ACCOUNT_TRANSLATIONS,
chunks: constants_1.USER_ACCOUNT_TRANSLATION_CHUNKS_CONFIG,
importPath: constants_1.SPARTACUS_USER_ACCOUNT_ASSETS,
},
styles: {
scssFileName: constants_1.SCSS_FILE_NAME,
importStyle: schematics_2.SPARTACUS_USER,
},
});
}
function addProfileFeature(options) {
return schematics_2.addLibraryFeature(options, {
folderName: constants_1.USER_FOLDER_NAME,
moduleName: constants_1.USER_MODULE_NAME,
featureModule: {
name: constants_1.USER_PROFILE_MODULE,
importPath: constants_1.SPARTACUS_USER_PROFILE,
},
rootModule: {
name: constants_1.USER_PROFILE_ROOT_MODULE,
importPath: constants_1.SPARTACUS_USER_PROFILE_ROOT,
},
lazyLoadingChunk: {
moduleSpecifier: constants_1.SPARTACUS_USER_PROFILE_ROOT,
namedImports: [constants_1.USER_PROFILE_FEATURE_NAME_CONSTANT],
},
i18n: {
resources: constants_1.USER_PROFILE_TRANSLATIONS,
chunks: constants_1.USER_PROFILE_TRANSLATION_CHUNKS_CONFIG,
importPath: constants_1.SPARTACUS_USER_PROFILE_ASSETS,
},
styles: {
scssFileName: constants_1.SCSS_FILE_NAME,
importStyle: schematics_2.SPARTACUS_USER,
},
dependencyManagement: {
featureName: schematics_2.CLI_USER_PROFILE_FEATURE,
featureDependencies: {
[schematics_2.SPARTACUS_USER]: [schematics_2.CLI_USER_ACCOUNT_FEATURE],
},
},
});
}
//# sourceMappingURL=index.js.map