feat: add baseURL dev and sequelize error
This commit is contained in:
parent
5c3f454d8c
commit
644539b624
1
.npmrc
1
.npmrc
@ -1 +1,2 @@
|
||||
@abearxiong:registry=https://npm.pkg.github.com
|
||||
//registry.npmjs.org/:_authToken=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
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import '../dist/app.js';
|
||||
import '../dist/index.js';
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/envision-cli",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"description": "envision command tools",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
@ -50,6 +50,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@kevisual/router": "^0.0.2",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"sequelize": "^6.37.4",
|
||||
"sqlite3": "^5.1.7"
|
||||
}
|
||||
|
21
pnpm-lock.yaml
generated
21
pnpm-lock.yaml
generated
@ -14,9 +14,12 @@ importers:
|
||||
'@kevisual/router':
|
||||
specifier: ^0.0.2
|
||||
version: 0.0.2
|
||||
pg-hstore:
|
||||
specifier: ^2.3.4
|
||||
version: 2.3.4
|
||||
sequelize:
|
||||
specifier: ^6.37.4
|
||||
version: 6.37.4(sqlite3@5.1.7)
|
||||
version: 6.37.4(pg-hstore@2.3.4)(sqlite3@5.1.7)
|
||||
sqlite3:
|
||||
specifier: ^5.1.7
|
||||
version: 5.1.7
|
||||
@ -811,6 +814,10 @@ packages:
|
||||
pg-connection-string@2.7.0:
|
||||
resolution: {integrity: sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==}
|
||||
|
||||
pg-hstore@2.3.4:
|
||||
resolution: {integrity: sha512-N3SGs/Rf+xA1M2/n0JBiXFDVMzdekwLZLAO0g7mpDY9ouX+fDI7jS6kTq3JujmYbtNSJ53TJ0q4G98KVZSM4EA==}
|
||||
engines: {node: '>= 0.8.x'}
|
||||
|
||||
picomatch@4.0.2:
|
||||
resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
|
||||
engines: {node: '>=12'}
|
||||
@ -1030,6 +1037,9 @@ packages:
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
underscore@1.13.7:
|
||||
resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==}
|
||||
|
||||
undici-types@6.19.8:
|
||||
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
|
||||
|
||||
@ -1906,6 +1916,10 @@ snapshots:
|
||||
|
||||
pg-connection-string@2.7.0: {}
|
||||
|
||||
pg-hstore@2.3.4:
|
||||
dependencies:
|
||||
underscore: 1.13.7
|
||||
|
||||
picomatch@4.0.2: {}
|
||||
|
||||
prebuild-install@7.1.2:
|
||||
@ -2007,7 +2021,7 @@ snapshots:
|
||||
|
||||
sequelize-pool@7.1.0: {}
|
||||
|
||||
sequelize@6.37.4(sqlite3@5.1.7):
|
||||
sequelize@6.37.4(pg-hstore@2.3.4)(sqlite3@5.1.7):
|
||||
dependencies:
|
||||
'@types/debug': 4.1.12
|
||||
'@types/validator': 13.12.2
|
||||
@ -2026,6 +2040,7 @@ snapshots:
|
||||
validator: 13.12.0
|
||||
wkx: 0.5.0
|
||||
optionalDependencies:
|
||||
pg-hstore: 2.3.4
|
||||
sqlite3: 5.1.7
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@ -2158,6 +2173,8 @@ snapshots:
|
||||
|
||||
typescript@5.6.3: {}
|
||||
|
||||
underscore@1.13.7: {}
|
||||
|
||||
undici-types@6.19.8: {}
|
||||
|
||||
unique-filename@1.1.1:
|
||||
|
@ -10,12 +10,15 @@ import json from '@rollup/plugin-json';
|
||||
export default {
|
||||
input: 'src/index.ts', // TypeScript 入口文件
|
||||
output: {
|
||||
file: 'dist/app.js', // 输出文件
|
||||
// file: 'dist/app.js', // 输出文件
|
||||
dir: 'dist',
|
||||
format: 'es', // 输出格式设置为 ES 模块
|
||||
},
|
||||
plugins: [
|
||||
resolve(), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块
|
||||
commonjs(),
|
||||
commonjs({
|
||||
// dynamicRequireTargets: ['node_modules/sqlite3/lib/*.js'],
|
||||
}),
|
||||
json(),
|
||||
typescript({
|
||||
allowImportingTsExtensions: true,
|
||||
@ -24,4 +27,5 @@ export default {
|
||||
declaration: false,
|
||||
}), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件
|
||||
],
|
||||
external: ['sqlite3', 'sequelize'], // 将 sqlite3 作为外部依赖
|
||||
};
|
||||
|
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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user