structure updates
This commit is contained in:
@@ -1,54 +1,31 @@
|
||||
import {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
realpathSync,
|
||||
statSync,
|
||||
} from 'node:fs';
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const modulesPath = join(process.cwd(), 'Modules');
|
||||
const modulesDirectory = join(process.cwd(), 'Modules');
|
||||
|
||||
if (!existsSync(modulesPath)) {
|
||||
if (!existsSync(modulesDirectory)) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const installed = new Set();
|
||||
for (const moduleName of readdirSync(modulesDirectory).sort()) {
|
||||
const moduleDirectory = join(modulesDirectory, moduleName);
|
||||
|
||||
for (const moduleName of readdirSync(modulesPath)) {
|
||||
const modulePath = join(modulesPath, moduleName);
|
||||
|
||||
if (!statSync(modulePath).isDirectory()) {
|
||||
if (!statSync(moduleDirectory).isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const packageJson = join(modulePath, 'package.json');
|
||||
const packageLock = join(modulePath, 'package-lock.json');
|
||||
const lockFile = join(moduleDirectory, 'package-lock.json');
|
||||
const packageFile = join(moduleDirectory, 'package.json');
|
||||
|
||||
if (!existsSync(packageJson) || !existsSync(packageLock)) {
|
||||
if (!existsSync(lockFile) || !existsSync(packageFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const physicalModulePath = realpathSync(modulePath);
|
||||
console.log(`[modules] Installing ${moduleName} dependencies`);
|
||||
|
||||
if (installed.has(physicalModulePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
installed.add(physicalModulePath);
|
||||
|
||||
console.log(`[Modules] Installing npm dependencies for ${moduleName}...`);
|
||||
|
||||
const result = spawnSync(
|
||||
'npm',
|
||||
['ci', '--no-audit', '--no-fund'],
|
||||
{
|
||||
cwd: modulePath,
|
||||
stdio: 'inherit',
|
||||
},
|
||||
);
|
||||
|
||||
if (result.status !== 0) {
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
execFileSync('npm', ['ci', '--no-audit', '--no-fund'], {
|
||||
cwd: moduleDirectory,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user