Skip to content

Commit

Permalink
fix(backend): Fix install packages when vitnode-backend packages has …
Browse files Browse the repository at this point in the history
…scripts
  • Loading branch information
aXenDeveloper committed Jun 20, 2024
1 parent 4347a43 commit 9e3f1b9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/aXenDeveloper/vitnode/"
},
"bin": {
"vitnode-backend": "./dist/scripts/init.js"
"vitnode-backend": "./scripts/init.mjs"
},
"scripts": {
"build": "tsc",
Expand Down
23 changes: 15 additions & 8 deletions packages/backend/src/scripts/init.ts → packages/backend/scripts/init.mjs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/usr/bin/env node
// @ts-check
/* eslint-disable no-console */

import { join } from "path";
import * as path from "path";
import * as fs from "fs";
import { fileURLToPath } from "url";

/* eslint-disable no-console */
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const copyDatabaseSchema = ({ corePluginPath }: { corePluginPath: string }) => {
const currentPathToSchema = join(
/**
*
* @param {string} corePluginPath
*/
const copyDatabaseSchema = corePluginPath => {
const currentPathToSchema = path.join(
__dirname,
"..",
"..",
"templates",
"core",
"admin",
Expand All @@ -21,20 +28,20 @@ const copyDatabaseSchema = ({ corePluginPath }: { corePluginPath: string }) => {
);
}

const userPathToSchema = join(corePluginPath, "admin", "database");
const userPathToSchema = path.join(corePluginPath, "admin", "database");
fs.cpSync(currentPathToSchema, userPathToSchema, { recursive: true });
};

export const init = () => {
const corePluginPath = join(process.cwd(), "src", "plugins", "core");
const corePluginPath = path.join(process.cwd(), "src", "plugins", "core");

if (!fs.existsSync(corePluginPath)) {
console.error("Plugin 'core' not found in 'src/plugins' directory.");
process.exit(1);
}

// Copy the schema from the template to the core plugin
copyDatabaseSchema({ corePluginPath });
copyDatabaseSchema(corePluginPath);

console.log("Hello, world!", process.cwd());
};
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ export * from "./decorators";
export * from "./main";
export * from "./app.module";
export * from "./database";
export * from "./scripts";
1 change: 0 additions & 1 deletion packages/backend/src/scripts/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"@/*": ["./src/*"]
}
},
"include": ["src/**/*"]
"include": ["src/**/*", "scripts"]
}

0 comments on commit 9e3f1b9

Please sign in to comment.