feat: add baseURL dev and sequelize error
This commit is contained in:
24
src/command/config.ts
Normal file
24
src/command/config.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { program as app, Command } from '@/program.ts';
|
||||
import { getConfig, writeConfig } from '@/module/index.ts';
|
||||
|
||||
const command = new Command('config')
|
||||
.description('')
|
||||
.option('-d, --dev <dev>', 'Specify dev')
|
||||
.option('-l --list', 'list config')
|
||||
.action(async (options) => {
|
||||
const { dev, list } = options || {};
|
||||
if (dev === 'true' || dev === 'false') {
|
||||
const config = getConfig();
|
||||
if (dev === 'true') {
|
||||
writeConfig({ ...config, dev: true });
|
||||
} else {
|
||||
writeConfig({ ...config, dev: false });
|
||||
}
|
||||
}
|
||||
if (list) {
|
||||
const config = getConfig();
|
||||
console.log('config', config);
|
||||
}
|
||||
});
|
||||
|
||||
app.addCommand(command);
|
||||
@@ -3,7 +3,7 @@ import { glob } from 'glob';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import FormData from 'form-data';
|
||||
import { baseURL } from '@/module/query.ts';
|
||||
import { baseURL, getBaseURL } from '@/module/query.ts';
|
||||
import { getConfig } from '@/module/index.ts';
|
||||
import inquirer from 'inquirer';
|
||||
|
||||
@@ -76,12 +76,14 @@ const uploadFiles = async (files: string[], directory: string, { key, version }:
|
||||
const filePath = path.join(directory, file);
|
||||
form.append('file', fs.createReadStream(filePath), {
|
||||
filename: file,
|
||||
filepath: file,
|
||||
});
|
||||
}
|
||||
form.append('appKey', key);
|
||||
form.append('version', version);
|
||||
return new Promise((resolve) => {
|
||||
const url = new URL(baseURL);
|
||||
const _baseURL = getBaseURL();
|
||||
const url = new URL(_baseURL);
|
||||
console.log('upload url', url.hostname, url.protocol, url.port);
|
||||
form.submit(
|
||||
{
|
||||
|
||||
@@ -5,5 +5,6 @@ import './command/ls-token.ts';
|
||||
import './command/me.ts';
|
||||
import './command/deploy.ts';
|
||||
import './command/serve.ts';
|
||||
import './command/config.ts';
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
@@ -2,7 +2,12 @@ import { Query } from '@kevisual/query';
|
||||
import { getConfig } from './get-config.ts';
|
||||
const config = getConfig();
|
||||
export const baseURL = config?.baseURL || 'https://envision.xiongxiao.me';
|
||||
|
||||
export const getBaseURL = () => {
|
||||
if (config?.dev) {
|
||||
return 'http://localhost:4002';
|
||||
}
|
||||
return baseURL;
|
||||
};
|
||||
export const query = new Query({
|
||||
url: `${baseURL}/api/router`,
|
||||
});
|
||||
|
||||
@@ -8,6 +8,9 @@ export const sequelize = new Sequelize({
|
||||
// logging: false,
|
||||
});
|
||||
|
||||
sequelize.authenticate({ logging: false }).then(() => {
|
||||
console.log('Connection sqlite has been established successfully.');
|
||||
});
|
||||
sequelize
|
||||
.authenticate({ logging: false })
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
console.error('Unable to connect to the database:', err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user