mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
build: Add reset script (#10627)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com>
This commit is contained in:
17
scripts/ensure-zx.mjs
Normal file
17
scripts/ensure-zx.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
import { accessSync, constants } from 'node:fs';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const ZX_PATH = 'node_modules/.bin/zx';
|
||||
|
||||
if (!zxExists()) {
|
||||
execSync('pnpm --frozen-lockfile --filter n8n-monorepo install', { stdio: 'inherit' });
|
||||
}
|
||||
|
||||
function zxExists() {
|
||||
try {
|
||||
accessSync(ZX_PATH, constants.F_OK);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
30
scripts/reset.mjs
Normal file
30
scripts/reset.mjs
Normal file
@@ -0,0 +1,30 @@
|
||||
// Resets the repository by deleting all untracked files except for few exceptions.
|
||||
import { $, echo, fs } from 'zx';
|
||||
|
||||
$.verbose = true;
|
||||
process.env.FORCE_COLOR = '1';
|
||||
|
||||
const excludePatterns = ['/.vscode/', '/.idea/', '.env'];
|
||||
const excludeFlags = excludePatterns.map((exclude) => ['-e', exclude]).flat();
|
||||
|
||||
echo(
|
||||
`This will delete all untracked files except for those matching the following patterns: ${excludePatterns.map((x) => `"${x}"`).join(', ')}.`,
|
||||
);
|
||||
|
||||
const answer = await question('❓ Do you want to continue? (y/n) ');
|
||||
|
||||
if (!['y', 'Y', ''].includes(answer)) {
|
||||
echo('Aborting...');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
echo('🧹 Cleaning untracked files...');
|
||||
await $({ verbose: false })`git clean -fxd ${excludeFlags}`;
|
||||
// In case node_modules is not removed by git clean
|
||||
fs.removeSync('node_modules');
|
||||
|
||||
echo('⏬ Running pnpm install...');
|
||||
await $`pnpm install`;
|
||||
|
||||
echo('🏗️ Running pnpm build...');
|
||||
await $`pnpm build`;
|
||||
Reference in New Issue
Block a user