Refactor Code to typescript
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
#! /usr/bin/env node
|
||||
// @ts-check
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(process.cwd(), ".env"),
|
||||
});
|
||||
|
||||
const datasquirel = require("../index");
|
||||
const colors = require("../console-colors");
|
||||
const createDbFromSchema = require("../package-shared/shell/createDbFromSchema");
|
||||
import datasquirel from "../index";
|
||||
import colors from "../console-colors";
|
||||
import createDbFromSchema from "../package-shared/shell/createDbFromSchema";
|
||||
import { DSQL_DatabaseSchemaType } from "../package-shared/types";
|
||||
|
||||
if (!fs.existsSync(path.resolve(process.cwd(), ".env"))) {
|
||||
console.log(".env file not found");
|
||||
@@ -45,9 +45,8 @@ if (!DSQL_PASS?.match(/./)) {
|
||||
|
||||
const dbSchemaLocalFilePath = path.resolve(process.cwd(), "dsql.schema.json");
|
||||
|
||||
async function run() {
|
||||
/** @type {any} */
|
||||
let schemaData;
|
||||
export default async function run() {
|
||||
let schemaData: any;
|
||||
|
||||
if (DSQL_KEY && DSQL_REF_DB_NAME?.match(/./)) {
|
||||
const dbSchemaDataResponse = await datasquirel.getSchema({
|
||||
@@ -66,8 +65,8 @@ async function run() {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType} */ // @ts-ignore
|
||||
let fetchedDbSchemaObject = dbSchemaDataResponse.payload;
|
||||
let fetchedDbSchemaObject =
|
||||
dbSchemaDataResponse.payload as DSQL_DatabaseSchemaType;
|
||||
if (DSQL_DB_NAME) fetchedDbSchemaObject.dbFullName = DSQL_DB_NAME;
|
||||
|
||||
schemaData = [fetchedDbSchemaObject];
|
||||
@@ -129,8 +128,6 @@ async function run() {
|
||||
);
|
||||
}
|
||||
|
||||
// let timeout;
|
||||
|
||||
let interval;
|
||||
|
||||
if (fs.existsSync(dbSchemaLocalFilePath) && !DSQL_KEY?.match(/....../)) {
|
||||
@@ -1,9 +1,8 @@
|
||||
#! /usr/bin/env node
|
||||
// @ts-check
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(process.cwd(), ".env"),
|
||||
@@ -57,6 +56,6 @@ try {
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {*} */ error) {
|
||||
} catch (error: any) {
|
||||
console.log("Dump Error: ", error.message);
|
||||
}
|
||||
Reference in New Issue
Block a user