chore: 更新.gitignore并清理脚本文件
删除不再使用的脚本文件test_db_count.ts和replace_punctuation.js 更新config.local.ts中的数据库配置和wpSite配置
This commit is contained in:
parent
998e1e31c7
commit
4bbfa0cc2d
|
|
@ -16,3 +16,7 @@ yarn.lock
|
||||||
**/config.local.ts
|
**/config.local.ts
|
||||||
container
|
container
|
||||||
ai/products-20251202 (1).csv
|
ai/products-20251202 (1).csv
|
||||||
|
scripts/replace_punctuation.js
|
||||||
|
scripts/test_db_count.d.ts
|
||||||
|
scripts/test_db_count.js
|
||||||
|
scripts/test_db_count.ts
|
||||||
|
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const map = {
|
|
||||||
',': ',',
|
|
||||||
'.': '.',
|
|
||||||
':': ':',
|
|
||||||
'?': '?',
|
|
||||||
'!': '!',
|
|
||||||
'"': '"',
|
|
||||||
'"': '"',
|
|
||||||
''': "'",
|
|
||||||
''': "'",
|
|
||||||
'(': '(',
|
|
||||||
')': ')',
|
|
||||||
'[': '[',
|
|
||||||
']': ']',
|
|
||||||
',': ',',
|
|
||||||
';': ';'
|
|
||||||
};
|
|
||||||
|
|
||||||
function getAllFiles(dirPath, arrayOfFiles) {
|
|
||||||
const files = fs.readdirSync(dirPath);
|
|
||||||
|
|
||||||
arrayOfFiles = arrayOfFiles || [];
|
|
||||||
|
|
||||||
files.forEach(function(file) {
|
|
||||||
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
|
|
||||||
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
|
|
||||||
} else {
|
|
||||||
if (extensions.some(ext => file.endsWith(ext))) {
|
|
||||||
arrayOfFiles.push(path.join(dirPath, "/", file));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return arrayOfFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
const srcDirAPI = path.join(__dirname);
|
|
||||||
const srcDirWEB = path.join(__dirname, '../WEB');
|
|
||||||
|
|
||||||
const targetDirs = [srcDirAPI, srcDirWEB];
|
|
||||||
|
|
||||||
const extensions = ['.ts', '.js', '.tsx', '.jsx', '.vue', '.html', '.css', '.scss', '.less', '.json', '.md'];
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
targetDirs.forEach(dir => {
|
|
||||||
if (fs.existsSync(dir)) {
|
|
||||||
const files = getAllFiles(dir);
|
|
||||||
files.forEach(file => {
|
|
||||||
// Skip node_modules, .git, dist, build, .idea, .vscode
|
|
||||||
if (file.includes('/node_modules/') ||
|
|
||||||
file.includes('/.git/') ||
|
|
||||||
file.includes('/dist/') ||
|
|
||||||
file.includes('/build/') ||
|
|
||||||
file.includes('/.idea/') ||
|
|
||||||
file.includes('/.vscode/') ||
|
|
||||||
file.includes('/coverage/')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let content = fs.readFileSync(file, 'utf8');
|
|
||||||
let originalContent = content;
|
|
||||||
|
|
||||||
for (const [cn, en] of Object.entries(map)) {
|
|
||||||
const regex = new RegExp(cn, 'g');
|
|
||||||
content = content.replace(regex, en);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content !== originalContent) {
|
|
||||||
fs.writeFileSync(file, content, 'utf8');
|
|
||||||
console.log(`Updated: ${file}`);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.warn(`Directory not found: ${dir}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(`Total files updated: ${count}`);
|
|
||||||
|
|
@ -16,8 +16,10 @@ export default {
|
||||||
dataSource: {
|
dataSource: {
|
||||||
default: {
|
default: {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
|
port: "23306",
|
||||||
username: 'root',
|
username: 'root',
|
||||||
password: '12345678',
|
password: '12345678',
|
||||||
|
database: 'inventory',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -25,7 +27,7 @@ export default {
|
||||||
origin: '*', // 允许所有来源跨域请求
|
origin: '*', // 允许所有来源跨域请求
|
||||||
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], // 允许的 HTTP 方法
|
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], // 允许的 HTTP 方法
|
||||||
allowHeaders: ['Content-Type', 'Authorization'], // 允许的自定义请求头
|
allowHeaders: ['Content-Type', 'Authorization'], // 允许的自定义请求头
|
||||||
credentials: true, // 允许携带凭据(cookies等)
|
credentials: true, // 允许携带凭据(cookies等)
|
||||||
},
|
},
|
||||||
jwt: {
|
jwt: {
|
||||||
secret: 'YOONE2024!@abc',
|
secret: 'YOONE2024!@abc',
|
||||||
|
|
@ -33,30 +35,34 @@ export default {
|
||||||
},
|
},
|
||||||
wpSite: [
|
wpSite: [
|
||||||
{
|
{
|
||||||
id: '-1',
|
id: '200',
|
||||||
siteName: 'Admin',
|
wpApiUrl: "http://simple.local",
|
||||||
email: '2469687281@qq.com',
|
consumerKey: 'ck_11b446d0dfd221853830b782049cf9a17553f886',
|
||||||
},
|
consumerSecret: 'cs_2b06729269f659dcef675b8cdff542bf3c1da7e8',
|
||||||
{
|
siteName: 'LocalSimple',
|
||||||
id: '2',
|
|
||||||
wpApiUrl: 'http://t2-shop.local/',
|
|
||||||
consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742',
|
|
||||||
consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c',
|
|
||||||
siteName: 'Local',
|
|
||||||
email: '2469687281@qq.com',
|
|
||||||
emailPswd: 'lulin91.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
wpApiUrl: 'http://t1-shop.local/',
|
|
||||||
consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742',
|
|
||||||
consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c',
|
|
||||||
siteName: 'Local-test-2',
|
|
||||||
email: '2469687281@qq.com',
|
email: '2469687281@qq.com',
|
||||||
emailPswd: 'lulin91.',
|
emailPswd: 'lulin91.',
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// id: '2',
|
// id: '2',
|
||||||
|
// wpApiUrl: 'http://t2-shop.local/',
|
||||||
|
// consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742',
|
||||||
|
// consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c',
|
||||||
|
// siteName: 'Local',
|
||||||
|
// email: '2469687281@qq.com',
|
||||||
|
// emailPswd: 'lulin91.',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: '3',
|
||||||
|
// wpApiUrl: 'http://t1-shop.local/',
|
||||||
|
// consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742',
|
||||||
|
// consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c',
|
||||||
|
// siteName: 'Local-test-2',
|
||||||
|
// email: '2469687281@qq.com',
|
||||||
|
// emailPswd: 'lulin91.',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: '2',
|
||||||
// wpApiUrl: 'http://localhost:10004',
|
// wpApiUrl: 'http://localhost:10004',
|
||||||
// consumerKey: 'ck_dc9e151e9048c8ed3e27f35ac79d2bf7d6840652',
|
// consumerKey: 'ck_dc9e151e9048c8ed3e27f35ac79d2bf7d6840652',
|
||||||
// consumerSecret: 'cs_d05d625d7b0ac05c6d765671d8417f41d9477e38',
|
// consumerSecret: 'cs_d05d625d7b0ac05c6d765671d8417f41d9477e38',
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
import { App, IMidwayApplication, Inject } from '@midwayjs/core';
|
|
||||||
import { Framework } from '@midwayjs/koa';
|
|
||||||
import { Bootstrap } from '@midwayjs/bootstrap';
|
|
||||||
import { Product } from './src/entity/product.entity';
|
|
||||||
import { WpProduct } from './src/entity/wp_product.entity';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
||||||
|
|
||||||
@App()
|
|
||||||
class TestApp {
|
|
||||||
@InjectEntityModel(Product)
|
|
||||||
productModel: Repository<Product>;
|
|
||||||
|
|
||||||
@InjectEntityModel(WpProduct)
|
|
||||||
wpProductModel: Repository<WpProduct>;
|
|
||||||
|
|
||||||
async run() {
|
|
||||||
if (!this.productModel || !this.wpProductModel) {
|
|
||||||
console.log('Models not injected');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const productCount = await this.productModel.count();
|
|
||||||
const wpProductCount = await this.wpProductModel.count();
|
|
||||||
console.log(`Product Count: ${productCount}`);
|
|
||||||
console.log(`WpProduct Count: ${wpProductCount}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bootstrap.run().then(async () => {
|
|
||||||
const app = await Bootstrap.getApplication() as IMidwayApplication<any>;
|
|
||||||
const testApp = await app.getApplicationContext().getAsync(TestApp);
|
|
||||||
await testApp.run();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue