@gobvoz/cli-fsd
Version:
Utility to create slices in Feature-Sliced Design methodology. Expect, that you have already installed `react`, `typescript`, `@reduxjs/toolkit`, `@reduxjs/toolkit-query`, `i18n` and use `module.scss` structure.
19 lines (13 loc) • 563 B
JavaScript
import fs from 'fs/promises';
import path from 'path';
import log from '../utils/log.js';
import lazyPublicApiTemplate from '../templates/lazy-public-api-template.js';
const createLazyPublicApi = async (layer, sliceName) => {
const resolvePath = (...segments) => path.resolve('src', layer, sliceName.kebabCase, ...segments);
try {
await fs.writeFile(resolvePath('index.ts'), lazyPublicApiTemplate(sliceName));
} catch (error) {
log.error(`Could not create 'public API' for "${sliceName.kebabCase}"`);
}
};
export default createLazyPublicApi;