修复了在linux下的路径问题(by : qcqcqc
This commit is contained in:
parent
1635dbdf39
commit
80fe14eb2f
|
|
@ -16,7 +16,6 @@
|
||||||
"${workspaceFolder}/dist/**/*.js"
|
"${workspaceFolder}/dist/**/*.js"
|
||||||
],
|
],
|
||||||
"preLaunchTask": "${defaultBuildTask}",
|
"preLaunchTask": "${defaultBuildTask}",
|
||||||
"cwd": "${fileDirname}"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4932
pnpm-lock.yaml
4932
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -509,6 +509,11 @@ export const updateCheckerByPath = (path: string) => {
|
||||||
updateCount++;
|
updateCount++;
|
||||||
|
|
||||||
const norPath = normalizePath(path);
|
const norPath = normalizePath(path);
|
||||||
|
|
||||||
|
if(!norPath.startsWith(pathConfig.checkerHome)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!checkerProgram) {
|
if (!checkerProgram) {
|
||||||
console.error('checker program not initialized');
|
console.error('checker program not initialized');
|
||||||
return;
|
return;
|
||||||
|
|
@ -570,7 +575,7 @@ export const updateCheckerByPath = (path: string) => {
|
||||||
// 获取更新后的 SourceFile
|
// 获取更新后的 SourceFile
|
||||||
const updatedSourceFile = checkerProgram.getSourceFile(norPath);
|
const updatedSourceFile = checkerProgram.getSourceFile(norPath);
|
||||||
if (!updatedSourceFile) {
|
if (!updatedSourceFile) {
|
||||||
console.error('Updated source file not found');
|
console.error('Updated checker source file not found:', norPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ export const scanComponents = (scanPath: string[]): EntityComponentDef[] => {
|
||||||
fs.readFileSync(configPath, 'utf-8')
|
fs.readFileSync(configPath, 'utf-8')
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('读取配置文件失败', e);
|
console.log('读取配置文件失败:', configPath, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let formDataAttrs: DocumentValue[] = [];
|
let formDataAttrs: DocumentValue[] = [];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
import { debounce, random } from 'lodash';
|
import { debounce, random } from 'lodash';
|
||||||
|
import os from "os";
|
||||||
|
|
||||||
|
// 如果系统是windows,首先采用\\ 否则默认使用/
|
||||||
|
|
||||||
|
const delimiter: string = os.platform() === 'win32' ? '\\' : '/';
|
||||||
|
|
||||||
export const pluginPaths: {
|
export const pluginPaths: {
|
||||||
root: string;
|
root: string;
|
||||||
|
|
@ -6,21 +11,21 @@ export const pluginPaths: {
|
||||||
} = {
|
} = {
|
||||||
root: __dirname,
|
root: __dirname,
|
||||||
get templates() {
|
get templates() {
|
||||||
return `${this.root}\\templates`;
|
return `${this.root}${delimiter}templates`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('plugin inited:', pluginPaths);
|
console.log('plugin inited:', pluginPaths);
|
||||||
|
|
||||||
export const internalPath = {
|
export const internalPath = {
|
||||||
entities: 'src\\entities',
|
entities: `src${delimiter}entities`,
|
||||||
triggers: 'src\\triggers',
|
triggers: `src${delimiter}triggers`,
|
||||||
checkers: 'src\\checkers',
|
checkers: `src${delimiter}checkers`,
|
||||||
pages: 'src\\pages',
|
pages: `src${delimiter}pages`,
|
||||||
namespaces: 'web\\src\\app\\namespaces',
|
namespaces: `web${delimiter}src${delimiter}app${delimiter}namespaces`,
|
||||||
oakAppDomain: 'src\\oak-app-domain',
|
oakAppDomain: `src${delimiter}oak-app-domain`,
|
||||||
components: 'src\\components',
|
components: `src${delimiter}components`,
|
||||||
locales: 'src\\locales',
|
locales: `src${delimiter}locales`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pathConfig: {
|
export const pathConfig: {
|
||||||
|
|
@ -36,28 +41,28 @@ export const pathConfig: {
|
||||||
} = {
|
} = {
|
||||||
projectHome: '',
|
projectHome: '',
|
||||||
get entityHome() {
|
get entityHome() {
|
||||||
return `${this.projectHome}\\${internalPath.entities}`;
|
return `${this.projectHome}${delimiter}${internalPath.entities}`;
|
||||||
},
|
},
|
||||||
get triggerHome() {
|
get triggerHome() {
|
||||||
return `${this.projectHome}\\${internalPath.triggers}`;
|
return `${this.projectHome}${delimiter}${internalPath.triggers}`;
|
||||||
},
|
},
|
||||||
get checkerHome() {
|
get checkerHome() {
|
||||||
return `${this.projectHome}\\${internalPath.checkers}`;
|
return `${this.projectHome}${delimiter}${internalPath.checkers}`;
|
||||||
},
|
},
|
||||||
get pagesHome() {
|
get pagesHome() {
|
||||||
return `${this.projectHome}\\${internalPath.pages}`;
|
return `${this.projectHome}${delimiter}${internalPath.pages}`;
|
||||||
},
|
},
|
||||||
get namespacesHome() {
|
get namespacesHome() {
|
||||||
return `${this.projectHome}\\${internalPath.namespaces}`;
|
return `${this.projectHome}${delimiter}${internalPath.namespaces}`;
|
||||||
},
|
},
|
||||||
get oakAppDomainHome() {
|
get oakAppDomainHome() {
|
||||||
return `${this.projectHome}\\${internalPath.oakAppDomain}`;
|
return `${this.projectHome}${delimiter}${internalPath.oakAppDomain}`;
|
||||||
},
|
},
|
||||||
get componentsHome() {
|
get componentsHome() {
|
||||||
return `${this.projectHome}\\${internalPath.components}`;
|
return `${this.projectHome}${delimiter}${internalPath.components}`;
|
||||||
},
|
},
|
||||||
get localesHome() {
|
get localesHome() {
|
||||||
return `${this.projectHome}\\${internalPath.locales}`;
|
return `${this.projectHome}${delimiter}${internalPath.locales}`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -65,7 +70,13 @@ export const pathConfig: {
|
||||||
const subscribers: Map<number, () => void> = new Map();
|
const subscribers: Map<number, () => void> = new Map();
|
||||||
|
|
||||||
const updateDeounced = debounce(() => {
|
const updateDeounced = debounce(() => {
|
||||||
subscribers.forEach((callback) => callback());
|
subscribers.forEach((callback) => {
|
||||||
|
try {
|
||||||
|
callback();
|
||||||
|
} catch(e) {
|
||||||
|
console.log("error", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
export const subscribe = (callback: () => void) => {
|
export const subscribe = (callback: () => void) => {
|
||||||
|
|
@ -96,7 +107,7 @@ export const isConfigReady = (): boolean => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setProjectHome = (projectHome: string) => {
|
export const setProjectHome = (projectHome: string) => {
|
||||||
const newHome = projectHome.endsWith('\\')
|
const newHome = (projectHome.endsWith('\\') || projectHome.endsWith('/'))
|
||||||
? projectHome.slice(0, -1)
|
? projectHome.slice(0, -1)
|
||||||
: projectHome;
|
: projectHome;
|
||||||
if (newHome !== pathConfig.projectHome) {
|
if (newHome !== pathConfig.projectHome) {
|
||||||
|
|
@ -147,8 +158,8 @@ export function normalizePath(path: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拼接规范化后的路径
|
// 拼接规范化后的路径
|
||||||
const outPath = normalizedParts.join('\\');
|
const outPath = normalizedParts.join(delimiter);
|
||||||
return outPath.endsWith('\\') ? outPath.slice(0, -1) : outPath;
|
return outPath.endsWith(delimiter) ? outPath.slice(0, -1) : outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断一个路径是不是相对路径
|
// 判断一个路径是不是相对路径
|
||||||
|
|
|
||||||
|
|
@ -516,6 +516,11 @@ export const updateTriggerByPath = (path: string) => {
|
||||||
updateCount++;
|
updateCount++;
|
||||||
|
|
||||||
const norPath = normalizePath(path);
|
const norPath = normalizePath(path);
|
||||||
|
|
||||||
|
if(!norPath.startsWith(pathConfig.triggerHome)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!triggerProgram) {
|
if (!triggerProgram) {
|
||||||
console.error('trigger program not initialized');
|
console.error('trigger program not initialized');
|
||||||
return;
|
return;
|
||||||
|
|
@ -577,7 +582,7 @@ export const updateTriggerByPath = (path: string) => {
|
||||||
// 获取更新后的 SourceFile
|
// 获取更新后的 SourceFile
|
||||||
const updatedSourceFile = triggerProgram.getSourceFile(norPath);
|
const updatedSourceFile = triggerProgram.getSourceFile(norPath);
|
||||||
if (!updatedSourceFile) {
|
if (!updatedSourceFile) {
|
||||||
console.error('Updated source file not found');
|
console.error('Updated trigger source file not found:', norPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue