forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturbowatch.ts
49 lines (44 loc) · 1.48 KB
/
turbowatch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import chalk from 'chalk'; // Import the chalk library
import { config } from 'dotenv';
import { watch } from 'turbowatch';
config({ path: 'packages/backend/.env' });
const packages = process.env.AP_DEV_PIECES?.split(',') || [];
packages.forEach((packageName) => {
console.log(chalk.blue(`Starting Turbowatch for package: ${packageName}`));
// Define the inline configuration
const piecePackageName = `pieces-${packageName}`;
void watch({
project: `${__dirname}/packages/pieces/${packageName}`,
triggers: [
{
expression: ['match', '**/*.ts', 'basename'],
name: `build-pieces-${packageName}`,
initialRun: true,
interruptible: false,
persistent: false,
onChange: async ({ spawn, first, files }) => {
console.log(
chalk.yellow.bold(
'👀 Detected changes in pieces. Building... 👀 ' +
piecePackageName
)
);
if (first) {
await spawn`nx run-many -t build --projects=${piecePackageName} --skip-nx-cache`;
return;
}
await spawn`nx run-many -t build --projects=${piecePackageName} --skip-nx-cache`;
// Print a fancy message to the console using chalk
console.log(
chalk.green.bold(
'✨ Changes are ready! Please refresh the frontend to see the new updates. ✨'
)
);
},
},
],
debounce: {
wait: 1000,
},
});
});