11#!/usr/bin/env node
22
3- import path from "node:path" ;
43import os from "node:os" ;
4+ import path from "node:path" ;
55
6- import { execa } from "execa" ;
76import { detect , getCommand } from "@antfu/ni" ;
7+ import PackageJson from "@npmcli/package-json" ;
8+ import { execa } from "execa" ;
89import fse from "fs-extra" ;
910import PQueue from "p-queue" ;
10- import PackageJson from "@npmcli/package-json" ;
1111
12- console . log ( { concurrency : os . cpus ( ) . length } ) ;
12+ const concurrency = os . cpus ( ) . length ;
13+
14+ console . log ( { concurrency } ) ;
1315
14- const queue = new PQueue ( { concurrency : os . cpus ( ) . length , autoStart : false } ) ;
16+ const queue = new PQueue ( { concurrency, autoStart : false } ) ;
1517
1618const TO_IGNORE = [ ".git" , ".github" , "__scripts" , "yarn.lock" , "package.json" ] ;
1719
@@ -51,16 +53,6 @@ for (const example of examples) {
5153 queue . add ( async ( ) => {
5254 const pkgJson = await PackageJson . load ( example ) ;
5355
54- // TODO: figure out why this is blowing up
55- pkgJson . update ( {
56- dependencies : {
57- ...pkgJson . content . dependencies ,
58- "@vanilla-extract/css" : "1.9.2" ,
59- } ,
60- } ) ;
61-
62- await pkgJson . save ( ) ;
63-
6456 /** @type {import('execa').Options } */
6557 const options = { cwd : example , reject : false } ;
6658
@@ -72,21 +64,21 @@ for (const example of examples) {
7264 if ( hasSetup ) {
7365 const setup = await getCommand ( detected , "run" , [ "__setup" ] ) ;
7466 const setupArgs = setup . split ( " " ) . slice ( 1 ) ;
75- console . log ( "🔧 Running setup script for" , example ) ;
67+ console . log ( "🔧\u00A0Running setup script for" , example ) ;
7668 const setupResult = await execa ( detected , setupArgs , options ) ;
7769 if ( setupResult . exitCode ) {
7870 console . error ( setupResult . stderr ) ;
7971 throw new Error ( `Error running setup script for ${ example } ` ) ;
8072 }
8173 }
8274
83- const install = await getCommand ( detected , "install" , [
75+ const installCommand = await getCommand ( detected , "install" , [
8476 "--silent" ,
8577 "--legacy-peer-deps" ,
8678 ] ) ;
8779 // this is silly, but is needed in order for execa to work
88- const installArgs = install . split ( " " ) . slice ( 1 , - 1 ) ;
89- console . log ( `📥 Installing ${ example } with "${ install } "` ) ;
80+ const installArgs = installCommand . split ( " " ) . slice ( 1 , - 1 ) ;
81+ console . log ( `📥\u00A0Installing ${ example } with "${ installCommand } "` ) ;
9082 const installResult = await execa ( detected , installArgs , options ) ;
9183
9284 if ( installResult . exitCode ) {
@@ -100,31 +92,33 @@ for (const example of examples) {
10092
10193 if ( hasPrisma ) {
10294 console . log ( "Generating prisma types for" , example ) ;
103- const prismaGenerate = await execa (
95+ const prismaGenerateCommand = await execa (
10496 "npx" ,
10597 [ "prisma" , "generate" ] ,
10698 options
10799 ) ;
108100
109- if ( prismaGenerate . exitCode ) {
110- console . error ( prismaGenerate . stderr ) ;
101+ if ( prismaGenerateCommand . exitCode ) {
102+ console . error ( prismaGenerateCommand . stderr ) ;
111103 throw new Error ( `Error generating prisma types for ${ example } ` ) ;
112104 }
113105 }
114106
115- const build = await getCommand ( detected , "run" , [ "build" ] ) ;
116- const buildArgs = build . split ( " " ) . slice ( 1 ) ;
117- console . log ( `📦 Building ${ example } with "${ build } "` ) ;
107+ const buildCommand = await getCommand ( detected , "run" , [ "build" ] ) ;
108+ const buildArgs = buildCommand . split ( " " ) . slice ( 1 ) ;
109+ console . log ( `📦\u00A0Building ${ example } with "${ buildCommand } "` ) ;
118110 const buildResult = await execa ( detected , buildArgs , options ) ;
119111
120112 if ( buildResult . exitCode ) {
121113 console . error ( buildResult . stderr ) ;
122114 throw new Error ( `Error building ${ example } ` ) ;
123115 }
124116
125- const typecheck = await getCommand ( detected , "run" , [ "typecheck" ] ) ;
126- const typecheckArgs = typecheck . split ( " " ) . slice ( 1 ) ;
127- console . log ( `🕵️ Typechecking ${ example } with "${ typecheck } "` ) ;
117+ const typecheckCommand = await getCommand ( detected , "run" , [ "typecheck" ] ) ;
118+ const typecheckArgs = typecheckCommand . split ( " " ) . slice ( 1 ) ;
119+ console . log (
120+ `🕵️\u00A0\u00A0Typechecking ${ example } with "${ typecheckCommand } "`
121+ ) ;
128122 const typecheckResult = await execa ( detected , typecheckArgs , options ) ;
129123
130124 if ( typecheckResult . exitCode ) {
0 commit comments