Skip to content

Commit

Permalink
fix(generators): Remove app directory from Next app
Browse files Browse the repository at this point in the history
  • Loading branch information
krzotki committed Nov 18, 2024
1 parent 888ea01 commit ebd38bb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const domains = [
'srv-supersonic-images.z-dn.net',
];

module.exports = () => {
const getConfig = () => {
return plugins.reduce(
(acc, next) => {
if (typeof next !== 'function') {
Expand Down Expand Up @@ -96,3 +96,5 @@ module.exports = () => {
}
);
};

module.exports = getConfig();
19 changes: 15 additions & 4 deletions packages/gene-tools/src/generators/bff-app-generator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getNpmScope, updateJestConfig } from '../utilities';

export default async function (tree: Tree, schema: BrainlyNextJSAppGenerator) {
const { name, directory, e2e } = schema;

const currentPackageJson = readJson(tree, 'package.json');

await applicationGenerator(tree, {
Expand All @@ -43,7 +43,13 @@ export default async function (tree: Tree, schema: BrainlyNextJSAppGenerator) {
? `${normalizedDirectory}-${name}`
: name;
const projectPath = `${directory}/${name}`;
await updateWorkspaceTarget({ tree, projectPath, projectName, e2e, directory: normalizedDirectory });
await updateWorkspaceTarget({
tree,
projectPath,
projectName,
e2e,
directory: normalizedDirectory,
});

const { appsDir } = getWorkspaceLayout(tree);
const appDir = `${appsDir}/${projectPath}`;
Expand Down Expand Up @@ -84,7 +90,7 @@ export default async function (tree: Tree, schema: BrainlyNextJSAppGenerator) {
}

updateEslint(tree, appDir);

await storybookConfigurationGenerator(tree, {
name: projectName,
});
Expand Down Expand Up @@ -122,7 +128,12 @@ export default async function (tree: Tree, schema: BrainlyNextJSAppGenerator) {

await formatFiles(tree);

cleanupFiles(tree, ['pages/_app.tsx', 'pages/index.tsx', 'pages/styles.css']);
cleanupFiles(tree, [
'src/app',
'pages/_app.tsx',
'pages/index.tsx',
'pages/styles.css',
]);

// revert possible changes to package.json
writeJson(tree, 'package.json', currentPackageJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const plugins = [withNodeModulesCSS, withBundleAnalyzer, withNx].concat(
const domains = [
];

module.exports = () => {
const getConfig = () => {
return plugins.reduce(
(acc, next) => {
if (typeof next !== 'function') {
Expand Down Expand Up @@ -74,3 +74,6 @@ module.exports = () => {
}
);
};


module.exports = getConfig();
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export default async function (tree: Tree, schema: BrainlyNextJSAppGenerator) {

maybeExcludeRewrites(tree, schema);

//Remove src/app directory
tree.delete(`${appDir}/src/app`);

if (e2e !== false) {
excludeTestsBoilerplate(tree);
}
Expand Down

0 comments on commit ebd38bb

Please sign in to comment.