mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
restructure
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
"dev": "node scripts/start_dev.js",
|
"dev": "node scripts/start_dev.js",
|
||||||
"compile": "tsc",
|
"compile": "tsc",
|
||||||
"build_project": "node ../scripts/build.js",
|
"build_project": "node ../scripts/build.js",
|
||||||
"build": "npm run compile && npm run build",
|
"build": "npm run compile && npm run build_project",
|
||||||
"docker-build": "docker build -t litlyx-producer -f Dockerfile ../",
|
"docker-build": "docker build -t litlyx-producer -f Dockerfile ../",
|
||||||
"docker-inspect": "docker run -it litlyx-producer sh"
|
"docker-inspect": "docker run -it litlyx-producer sh"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const { globSync } = require('glob');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const tsConfigPath = path.join(process.cwd(), 'tsconfig.json');
|
const tsConfigPath = path.join(process.cwd(), '../tsconfig.json');
|
||||||
const tsconfigContent = fs.readFileSync(tsConfigPath, 'utf8');
|
const tsconfigContent = fs.readFileSync(tsConfigPath, 'utf8');
|
||||||
|
|
||||||
const tsconfigObject = JSON.parse(tsconfigContent);
|
const tsconfigObject = JSON.parse(tsconfigContent);
|
||||||
@@ -12,17 +12,25 @@ const paths = tsconfigObject.compilerOptions.paths;
|
|||||||
|
|
||||||
const filesList = globSync('dist/**/*.js');
|
const filesList = globSync('dist/**/*.js');
|
||||||
|
|
||||||
|
console.log(`[BUILD] Building ${filesList.length} files`);
|
||||||
|
|
||||||
filesList.forEach(file => {
|
filesList.forEach(file => {
|
||||||
|
|
||||||
let raw = fs.readFileSync(file, 'utf8');
|
let raw = fs.readFileSync(file, 'utf8');
|
||||||
for (const path in paths) {
|
for (const path in paths) {
|
||||||
const deep = (file.match(/\\|\//g) || []).length;
|
const deep = (file.match(/\\|\//g) || []).length;
|
||||||
const pathText = path.replace('*', '');
|
const pathText = path.replace('*', '');
|
||||||
const toReplaceText = new RegExp(`"${pathText}(.*?)"`, 'g');
|
const toReplaceText = new RegExp(`"${pathText}(.*?)"`, 'g');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
raw = raw.replace(toReplaceText, `"${new Array(deep - 2).fill('../').join('')}${paths[path][0].replace('*', '')}${'$1'}"`);
|
raw = raw.replace(toReplaceText, `"${new Array(deep - 2).fill('../').join('')}.${paths[path][0].replace('*', '')}${'$1'}"`);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.log({ deep, pathText, toReplaceText, path })
|
console.log({ deep, pathText, toReplaceText, path })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(file, raw);
|
fs.writeFileSync(file, raw);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`[BUILD] Done`);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
|
|||||||
Reference in New Issue
Block a user