Skip to content

Commit

Permalink
trying node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonhochkins committed Jul 5, 2024
1 parent feb5d03 commit 764265b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hakit/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Hakit",
"version": "1.0.32",
"version": "1.0.33",
"slug": "hakit",
"init": false,
"ingress": true,
Expand Down
5 changes: 2 additions & 3 deletions hakit/server/routes/remove-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import { translateError } from '../helpers/index.js';

export async function removeBuildDirectory() {
// remove the directory .next
const buildDir = join(APP_DIRECTORY, 'app', '.next');
const buildDir = join(APP_DIRECTORY, 'app', 'node_modules');
await rm(buildDir, { recursive: true, force: true });
console.log('.next directory removed successfully');
console.log('node_modules directory removed successfully');
}


export async function removeBuild(_req: Request, res: Response) {
try {
await removeBuildDirectory();
console.log('.next directory removed successfully');
return res.status(200).send('Directory removed successfully');
} catch (error) {
console.error('Error removing build directory:', translateError(error));
Expand Down
16 changes: 8 additions & 8 deletions hakit/server/routes/run-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function runApplication(app: Express) {
}
}

const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', '.next'));
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', 'node_modules'));

if (nextJsBuilt) {
// Start the Next.js server if the application is available
Expand All @@ -57,7 +57,7 @@ export async function runApplication(app: Express) {
res.send(pageContent);
});
app.use((_req, res, next) => {
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', '.next'));
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', 'node_modules'));
console.log('_req.path', _req.path);
// first check if the current path is the root level
if (!nextJsBuilt && (_req.path === '/' || _req.path === '')) {
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function runApplication(app: Express) {
console.error('Error reading package.json:', error);
}

const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', '.next'));
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', 'node_modules'));

const status: {
version: string | null;
Expand All @@ -101,17 +101,17 @@ export async function runApplication(app: Express) {
});

return async (_req: Request, res: Response) => {
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', '.next'));
const nextJsBuilt = existsSync(join(APP_DIRECTORY, 'app', 'node_modules'));
try {
if (!nextJsBuilt) {
const installDependencies = `cd ${join(APP_DIRECTORY, 'app')} && npm i`;
const buildNextApp = `cd ${join(APP_DIRECTORY, 'app')} && SKIP_TYPE_CHECKING=true npm run build`;
const installDependencies = `cd ${join(APP_DIRECTORY, 'app')} && npm ci`;
// const buildNextApp = `cd ${join(APP_DIRECTORY, 'app')} && SKIP_LINTING=true SKIP_TYPE_CHECKING=true npm run build`;

try {
console.log('Installing dependencies');
execSync(installDependencies, { stdio: 'inherit' });
console.log('Building Next.js application');
execSync(buildNextApp, { stdio: 'inherit' });
// console.log('Building Next.js application');
// execSync(buildNextApp, { stdio: 'inherit' });
console.log('Next.js application built successfully');
} catch (error) {
console.error('Error building Next.js application:', translateError(error));
Expand Down

0 comments on commit 764265b

Please sign in to comment.