This commit is contained in:
2021-06-12 17:48:26 +03:00
commit 3e68914c92
56 changed files with 26153 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{
"_api": "src/core/api",
"_blocks": "src/core/blocks",
"_consts": "src/core/consts",
"_hooks": "src/core/hooks",
"_hoks": "src/core/hoks",
"_services": "src/core/services",
"_types": "src/core/types",
"_utils": "src/core/utils",
"_infrastructure": "src/core/infrastructure",
"_enums": "src/core/enums",
"_referers": "src/core/referers",
"_pages": "src/pages"
}

View File

@ -0,0 +1,50 @@
const fs = require('fs');
const path = require('path');
const aliases = require('./config.json');
const tsconfig = require('../../tsconfig.json');
const CURRENT_FOLDER = process.cwd();
function createTsConfigDev() {
const tsConfigDev = {
...tsconfig,
compilerOptions: {
...tsconfig.compilerOptions,
paths: Object.entries(aliases).reduce((acc, [key, value]) => ({
...acc,
[`${key}/*`]: [`./${value}/*`],
}), {}),
}
};
fs.writeFileSync(path.resolve('tsconfig.dev.json'), JSON.stringify(tsConfigDev, null, 4));
}
function createSymlinks() {
if (!fs.existsSync('./node_modules')) {
fs.mkdirSync('node_modules');
}
try {
for (const alias in aliases) {
const folder = aliases[alias];
const pathInPackage = path.resolve(CURRENT_FOLDER, folder);
if (!fs.existsSync(folder)) {
continue;
}
const symlinkPath = path.resolve(`./node_modules/${alias}`);
if (fs.existsSync(symlinkPath)) {
continue;
}
fs.symlinkSync(pathInPackage, symlinkPath);
console.info(`${symlinkPath} --> ${pathInPackage}`);
}
} catch (e) {
console.info(`${e}`);
}
}
createSymlinks();
createTsConfigDev();

View File

@ -0,0 +1,5 @@
module.exports = {
ignore: [
'src/core',
],
};

View File

@ -0,0 +1,15 @@
const runner = require("ts-prune/lib/runner");
const {ignore} = require('./ignore-files');
const error = [];
runner.run({ project: 'tsconfig.dev.json' }, (text) => {
if (ignore.every(ign => !text.includes(ign))) {
error.push(text);
}
});
setTimeout(() => {
if (error.length) {
throw new Error(`Присутствует не используемый код: \n${error.join('\n')}`);
}
}, 0);