@@ -5,13 +5,13 @@ import os from "node:os";
55
66import { execa } from "execa" ;
77import { detect , getCommand } from "@antfu/ni" ;
8- import PackageJson from "@npmcli/package-json" ;
98import fse from "fs-extra" ;
109import PQueue from "p-queue" ;
10+ import PackageJson from "@npmcli/package-json" ;
1111
1212console . log ( { concurrency : os . cpus ( ) . length } ) ;
1313
14- const queue = new PQueue ( { concurrency : os . cpus ( ) . length } ) ;
14+ const queue = new PQueue ( { concurrency : os . cpus ( ) . length , autoStart : false } ) ;
1515
1616const TO_IGNORE = [ ".git" , ".github" , "__scripts" , "yarn.lock" , "package.json" ] ;
1717
@@ -40,9 +40,7 @@ if (process.env.CI) {
4040 . filter ( ( entry ) => entry . isDirectory ( ) )
4141 . filter ( ( entry ) => ! TO_IGNORE . includes ( entry . name ) )
4242 . map ( ( entry ) => entry . name )
43- . filter ( ( entry ) => {
44- return fse . existsSync ( path . join ( entry , "package.json" ) ) ;
45- } ) ;
43+ . filter ( ( entry ) => fse . existsSync ( path . join ( entry , "package.json" ) ) ) ;
4644}
4745
4846const list = new Intl . ListFormat ( "en" , { style : "long" , type : "conjunction" } ) ;
@@ -53,43 +51,47 @@ for (const example of examples) {
5351 queue . add ( async ( ) => {
5452 const pkgJson = await PackageJson . load ( example ) ;
5553
56- const remixDeps = Object . keys ( pkgJson . content . dependencies ) . filter ( ( d ) => {
57- return d . startsWith ( "@remix-run/" ) ;
58- } ) ;
59-
60- const remixDevDeps = Object . keys ( pkgJson . content . devDependencies ) . filter (
61- ( d ) => {
62- return d . startsWith ( "@remix-run/" ) ;
63- }
64- ) ;
65-
54+ // TODO: figure out why this is blowing up
6655 pkgJson . update ( {
6756 dependencies : {
6857 ...pkgJson . content . dependencies ,
69- ...Object . fromEntries ( remixDeps . map ( ( d ) => [ d , `latest` ] ) ) ,
70- } ,
71- devDependencies : {
72- ...pkgJson . content . devDependencies ,
73- ...Object . fromEntries ( remixDevDeps . map ( ( d ) => [ d , `latest` ] ) ) ,
58+ "@vanilla-extract/css" : "1.9.2" ,
7459 } ,
7560 } ) ;
7661
7762 await pkgJson . save ( ) ;
7863
7964 /** @type {import('execa').Options } */
80- const options = { cwd : example } ;
65+ const options = { cwd : example , reject : false } ;
8166
67+ // detect package manager
8268 const detected = await detect ( { cwd : example } ) ;
8369
84- const install = await getCommand ( detected , "install" , [ "--silent" ] ) ;
70+ const hasSetup = ! ! pkgJson . content . scripts ?. __setup ;
71+
72+ if ( hasSetup ) {
73+ const setup = await getCommand ( detected , "run" , [ "__setup" ] ) ;
74+ const setupArgs = setup . split ( " " ) . slice ( 1 ) ;
75+ console . log ( "🔧 Running setup script for" , example ) ;
76+ const setupResult = await execa ( detected , setupArgs , options ) ;
77+ if ( setupResult . exitCode ) {
78+ console . error ( setupResult . stderr ) ;
79+ throw new Error ( `Error running setup script for ${ example } ` ) ;
80+ }
81+ }
82+
83+ const install = await getCommand ( detected , "install" , [
84+ "--silent" ,
85+ "--legacy-peer-deps" ,
86+ ] ) ;
87+ // this is silly, but is needed in order for execa to work
8588 const installArgs = install . split ( " " ) . slice ( 1 , - 1 ) ;
86- console . log ( `📥 Installing ${ example } with ${ install } ` ) ;
89+ console . log ( `📥 Installing ${ example } with " ${ install } " ` ) ;
8790 const installResult = await execa ( detected , installArgs , options ) ;
8891
8992 if ( installResult . exitCode ) {
90- console . error ( `Error installing ${ example } ` ) ;
9193 console . error ( installResult . stderr ) ;
92- return ;
94+ throw new Error ( `Error installing ${ example } ` ) ;
9395 }
9496
9597 const hasPrisma = fse . existsSync (
@@ -105,56 +107,34 @@ for (const example of examples) {
105107 ) ;
106108
107109 if ( prismaGenerate . exitCode ) {
108- console . error ( `Error generating prisma types for ${ example } ` ) ;
109110 console . error ( prismaGenerate . stderr ) ;
110- return ;
111+ throw new Error ( `Error generating prisma types for ${ example } ` ) ;
111112 }
112113 }
113114
114115 const build = await getCommand ( detected , "run" , [ "build" ] ) ;
115116 const buildArgs = build . split ( " " ) . slice ( 1 ) ;
116- console . log ( `📦 Building ${ example } with ${ build } ` ) ;
117+ console . log ( `📦 Building ${ example } with " ${ build } " ` ) ;
117118 const buildResult = await execa ( detected , buildArgs , options ) ;
118119
119120 if ( buildResult . exitCode ) {
120- console . error ( `Error building ${ example } ` ) ;
121121 console . error ( buildResult . stderr ) ;
122- return ;
122+ throw new Error ( `Error building ${ example } ` ) ;
123123 }
124124
125125 const typecheck = await getCommand ( detected , "run" , [ "typecheck" ] ) ;
126126 const typecheckArgs = typecheck . split ( " " ) . slice ( 1 ) ;
127- console . log ( `🕵️ Typechecking ${ example } with ${ typecheck } ` ) ;
127+ console . log ( `🕵️ Typechecking ${ example } with " ${ typecheck } " ` ) ;
128128 const typecheckResult = await execa ( detected , typecheckArgs , options ) ;
129129
130130 if ( typecheckResult . exitCode ) {
131- console . error ( `Error typechecking ${ example } ` ) ;
132131 console . error ( typecheckResult . stderr ) ;
133- return ;
132+ throw new Error ( `Error typechecking ${ example } ` ) ;
134133 }
135-
136- pkgJson . update ( {
137- dependencies : {
138- ...pkgJson . content . dependencies ,
139- ...Object . fromEntries ( remixDeps . map ( ( d ) => [ d , `*` ] ) ) ,
140- } ,
141- devDependencies : {
142- ...pkgJson . content . devDependencies ,
143- ...Object . fromEntries ( remixDevDeps . map ( ( d ) => [ d , `*` ] ) ) ,
144- } ,
145- } ) ;
146-
147- await pkgJson . save ( ) ;
148134 } ) ;
149135}
150136
151- try {
152- queue . start ( ) ;
153- } catch ( error ) {
154- console . error ( error ) ;
155- process . exit ( 1 ) ;
156- }
157-
158- // const rejected = promises.filter((s) => s.status === "rejected");
159- // rejected.forEach((s) => console.error(s.reason));
160- // process.exit(rejected.length > 0 ? 1 : 0);
137+ queue . start ( ) ;
138+ queue . on ( "error" , ( error ) => {
139+ console . error ( "🚨" , error ) ;
140+ } ) ;
0 commit comments