@pageai/ralph-loop 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -353,12 +353,12 @@ async function main() {
353
353
 
354
354
  // Playwright setup
355
355
  if (installPlaywright) {
356
- setupPlaywright(clack, TARGET_DIR, appDir);
356
+ await setupPlaywright(clack, TARGET_DIR, appDir);
357
357
  }
358
358
 
359
359
  // Vitest setup
360
360
  if (installVitest) {
361
- setupVitest(clack, TARGET_DIR, appDir);
361
+ await setupVitest(clack, TARGET_DIR, appDir);
362
362
  }
363
363
 
364
364
  // Final setup steps (git init, shadcn install)
@@ -372,7 +372,7 @@ async function main() {
372
372
 
373
373
  if (needsGit) {
374
374
  try {
375
- initGitRepo(TARGET_DIR);
375
+ await initGitRepo(TARGET_DIR);
376
376
  } catch {
377
377
  // Non-critical — continue setup even if git init fails
378
378
  }
@@ -380,7 +380,7 @@ async function main() {
380
380
 
381
381
  if (needsShadcn) {
382
382
  try {
383
- installAllComponents(appDirPath);
383
+ await installAllComponents(appDirPath);
384
384
  } catch {
385
385
  // Non-critical — continue setup even if shadcn install fails
386
386
  }
package/bin/lib/git.js CHANGED
@@ -4,9 +4,12 @@
4
4
  */
5
5
 
6
6
  const path = require('path');
7
- const { execSync } = require('child_process');
7
+ const { exec } = require('child_process');
8
+ const { promisify } = require('util');
8
9
  const { exists } = require('./copy');
9
10
 
11
+ const execAsync = promisify(exec);
12
+
10
13
  /**
11
14
  * Checks if a directory is inside a git repository
12
15
  * @param {string} dir - Directory path to check
@@ -19,9 +22,10 @@ function isGitRepo(dir) {
19
22
  /**
20
23
  * Initializes a new git repository in the given directory
21
24
  * @param {string} dir - Directory path to initialize
25
+ * @returns {Promise<void>}
22
26
  */
23
- function initGitRepo(dir) {
24
- execSync('git init', { cwd: dir, stdio: 'pipe' });
27
+ async function initGitRepo(dir) {
28
+ await execAsync('git init', { cwd: dir });
25
29
  }
26
30
 
27
31
  module.exports = {
@@ -4,17 +4,20 @@
4
4
  */
5
5
 
6
6
  const path = require('path');
7
- const { execSync } = require('child_process');
7
+ const { exec } = require('child_process');
8
+ const { promisify } = require('util');
8
9
  const { copyFile, exists } = require('./copy');
9
10
  const display = require('./display');
10
11
 
12
+ const execAsync = promisify(exec);
13
+
11
14
  /**
12
15
  * Copies playwright.config.ts into the app directory and installs Chromium.
13
16
  * @param {object} clack - @clack/prompts module (passed in because it's ESM)
14
17
  * @param {string} targetDir - Project root (TARGET_DIR)
15
18
  * @param {string} appDir - Relative app source directory
16
19
  */
17
- function setupPlaywright(clack, targetDir, appDir) {
20
+ async function setupPlaywright(clack, targetDir, appDir) {
18
21
  console.log();
19
22
  display.printStep('🎭', 'Playwright setup');
20
23
 
@@ -31,9 +34,8 @@ function setupPlaywright(clack, targetDir, appDir) {
31
34
  const s = clack.spinner();
32
35
  s.start('Installing Playwright browsers (chromium)...');
33
36
  try {
34
- execSync('npx playwright install --with-deps chromium', {
37
+ await execAsync('npx playwright install --with-deps chromium', {
35
38
  cwd: path.join(targetDir, appDir),
36
- stdio: 'pipe',
37
39
  });
38
40
  s.stop('Playwright browsers installed');
39
41
  } catch (err) {
package/bin/lib/shadcn.js CHANGED
@@ -5,9 +5,12 @@
5
5
 
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
- const { execSync } = require('child_process');
8
+ const { exec } = require('child_process');
9
+ const { promisify } = require('util');
9
10
  const { exists } = require('./copy');
10
11
 
12
+ const execAsync = promisify(exec);
13
+
11
14
  const SHADCN_SCHEMA = 'https://ui.shadcn.com/schema.json';
12
15
 
13
16
  /**
@@ -57,14 +60,38 @@ function isShadcnProject(dir) {
57
60
  }
58
61
 
59
62
  /**
60
- * Initializes shadcn in the given directory with default settings.
63
+ * Initializes shadcn in the given directory with default settings,
64
+ * then strips the "#/" alias prefix from components.json.
61
65
  * @param {string} dir - Directory path to run the init in
62
66
  */
63
- function initShadcn(dir) {
64
- execSync('npx shadcn@latest init -y -d 2>&1', {
67
+ async function initShadcn(dir) {
68
+ await execAsync('npx shadcn@latest init -y -d 2>&1', {
65
69
  cwd: dir,
66
- stdio: 'pipe',
67
70
  });
71
+
72
+ stripAliasPrefix(dir);
73
+ }
74
+
75
+ /**
76
+ * Removes the "#/" prefix from all alias values in components.json.
77
+ * @param {string} dir - Directory containing components.json
78
+ */
79
+ function stripAliasPrefix(dir) {
80
+ const configPath = path.join(dir, 'components.json');
81
+ if (!exists(configPath)) return;
82
+
83
+ try {
84
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
85
+ if (!config.aliases) return;
86
+
87
+ for (const key of Object.keys(config.aliases)) {
88
+ config.aliases[key] = config.aliases[key].replace(/^#\//, '');
89
+ }
90
+
91
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
92
+ } catch {
93
+ // Non-critical — continue even if patching fails
94
+ }
68
95
  }
69
96
 
70
97
  /**
@@ -72,14 +99,13 @@ function initShadcn(dir) {
72
99
  * Runs init first if no components.json exists.
73
100
  * @param {string} dir - Directory path to run the install in
74
101
  */
75
- function installAllComponents(dir) {
102
+ async function installAllComponents(dir) {
76
103
  if (!hasShadcnConfig(dir)) {
77
- initShadcn(dir);
104
+ await initShadcn(dir);
78
105
  }
79
106
 
80
- execSync('npx shadcn@latest add --all --yes --overwrite 2>&1', {
107
+ await execAsync('npx shadcn@latest add --all --yes --overwrite 2>&1', {
81
108
  cwd: dir,
82
- stdio: 'pipe',
83
109
  });
84
110
  }
85
111
 
package/bin/lib/vitest.js CHANGED
@@ -5,11 +5,14 @@
5
5
 
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
- const { execSync } = require('child_process');
8
+ const { exec } = require('child_process');
9
+ const { promisify } = require('util');
9
10
  const { copyFile, exists } = require('./copy');
10
11
  const display = require('./display');
11
12
  const { DEFAULT_APP_DIR } = require('./consts');
12
13
 
14
+ const execAsync = promisify(exec);
15
+
13
16
  /**
14
17
  * Copies vitest.config.ts into the app directory, patches the include
15
18
  * paths to match appDir, and installs vitest + react plugin.
@@ -17,7 +20,7 @@ const { DEFAULT_APP_DIR } = require('./consts');
17
20
  * @param {string} targetDir - Project root (TARGET_DIR)
18
21
  * @param {string} appDir - Relative app source directory
19
22
  */
20
- function setupVitest(clack, targetDir, appDir) {
23
+ async function setupVitest(clack, targetDir, appDir) {
21
24
  console.log();
22
25
  display.printStep('⚡', 'Vitest setup');
23
26
 
@@ -42,9 +45,8 @@ function setupVitest(clack, targetDir, appDir) {
42
45
  const s = clack.spinner();
43
46
  s.start('Installing Vitest dependencies...');
44
47
  try {
45
- execSync('npm install --save-dev vitest @vitejs/plugin-react', {
48
+ await execAsync('npm install --save-dev vitest @vitejs/plugin-react', {
46
49
  cwd: path.join(targetDir, appDir),
47
- stdio: 'pipe',
48
50
  });
49
51
  s.stop('Vitest dependencies installed');
50
52
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageai/ralph-loop",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },