mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
workspace: auto export from src
This commit is contained in:
1 parent
6fb05fd5a0
commit
77a54b7663
2 files changed
+13
-3
No files matched your search
@@ -23,7 +23,6 @@ tsconfig.json
|
|||||||
packages/**/*.js
|
packages/**/*.js
|
||||||
!/build/build.js
|
!/build/build.js
|
||||||
!**/bin/*.js
|
!**/bin/*.js
|
||||||
!packages/hydrojudge/service.js
|
|
||||||
|
|
||||||
# Data files
|
# Data files
|
||||||
*.mmdb
|
*.mmdb
|
||||||
|
|||||||
+13
-2
@@ -48,13 +48,24 @@ const configFlat = {
|
|||||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||||
console.log(packages);
|
console.log(packages);
|
||||||
for (const package of packages) {
|
for (const package of packages) {
|
||||||
const files = fs.readdirSync(path.resolve(process.cwd(), 'packages', package));
|
const basedir = path.resolve(process.cwd(), 'packages', package);
|
||||||
|
const files = fs.readdirSync(basedir);
|
||||||
if (!files.includes('src') && !files.map(n => n.split('.')[1]).includes('ts')) continue;
|
if (!files.includes('src') && !files.map(n => n.split('.')[1]).includes('ts')) continue;
|
||||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.resolve(process.cwd(), 'packages', package, 'tsconfig.json'),
|
path.resolve(basedir, 'tsconfig.json'),
|
||||||
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
||||||
);
|
);
|
||||||
|
if (files.includes('src')) {
|
||||||
|
const inner = fs.readdirSync(path.resolve(basedir, 'src'));
|
||||||
|
for (const file of inner) {
|
||||||
|
if (!fs.statSync(path.resolve(basedir, 'src', file)).isFile()) continue;
|
||||||
|
const name = file.split('.')[0];
|
||||||
|
if (['handler', 'service', 'lib', 'model', 'script'].includes(name)) {
|
||||||
|
fs.writeFileSync(path.resolve(basedir, name + '.js'), `module.exports = require('./dist/${name}');\n`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user