@@ -5,13 +5,13 @@ import os from "node:os";
5
5
6
6
import { execa } from "execa" ;
7
7
import { detect , getCommand } from "@antfu/ni" ;
8
- import PackageJson from "@npmcli/package-json" ;
9
8
import fse from "fs-extra" ;
10
9
import PQueue from "p-queue" ;
10
+ import PackageJson from "@npmcli/package-json" ;
11
11
12
12
console . log ( { concurrency : os . cpus ( ) . length } ) ;
13
13
14
- const queue = new PQueue ( { concurrency : os . cpus ( ) . length } ) ;
14
+ const queue = new PQueue ( { concurrency : os . cpus ( ) . length , autoStart : false } ) ;
15
15
16
16
const TO_IGNORE = [ ".git" , ".github" , "__scripts" , "yarn.lock" , "package.json" ] ;
17
17
@@ -40,9 +40,7 @@ if (process.env.CI) {
40
40
. filter ( ( entry ) => entry . isDirectory ( ) )
41
41
. filter ( ( entry ) => ! TO_IGNORE . includes ( entry . name ) )
42
42
. 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" ) ) ) ;
46
44
}
47
45
48
46
const list = new Intl . ListFormat ( "en" , { style : "long" , type : "conjunction" } ) ;
@@ -53,43 +51,47 @@ for (const example of examples) {
53
51
queue . add ( async ( ) => {
54
52
const pkgJson = await PackageJson . load ( example ) ;
55
53
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
66
55
pkgJson . update ( {
67
56
dependencies : {
68
57
...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" ,
74
59
} ,
75
60
} ) ;
76
61
77
62
await pkgJson . save ( ) ;
78
63
79
64
/** @type {import('execa').Options } */
80
- const options = { cwd : example } ;
65
+ const options = { cwd : example , reject : false } ;
81
66
67
+ // detect package manager
82
68
const detected = await detect ( { cwd : example } ) ;
83
69
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
85
88
const installArgs = install . split ( " " ) . slice ( 1 , - 1 ) ;
86
- console . log ( `📥 Installing ${ example } with ${ install } ` ) ;
89
+ console . log ( `📥 Installing ${ example } with " ${ install } " ` ) ;
87
90
const installResult = await execa ( detected , installArgs , options ) ;
88
91
89
92
if ( installResult . exitCode ) {
90
- console . error ( `Error installing ${ example } ` ) ;
91
93
console . error ( installResult . stderr ) ;
92
- return ;
94
+ throw new Error ( `Error installing ${ example } ` ) ;
93
95
}
94
96
95
97
const hasPrisma = fse . existsSync (
@@ -105,56 +107,34 @@ for (const example of examples) {
105
107
) ;
106
108
107
109
if ( prismaGenerate . exitCode ) {
108
- console . error ( `Error generating prisma types for ${ example } ` ) ;
109
110
console . error ( prismaGenerate . stderr ) ;
110
- return ;
111
+ throw new Error ( `Error generating prisma types for ${ example } ` ) ;
111
112
}
112
113
}
113
114
114
115
const build = await getCommand ( detected , "run" , [ "build" ] ) ;
115
116
const buildArgs = build . split ( " " ) . slice ( 1 ) ;
116
- console . log ( `📦 Building ${ example } with ${ build } ` ) ;
117
+ console . log ( `📦 Building ${ example } with " ${ build } " ` ) ;
117
118
const buildResult = await execa ( detected , buildArgs , options ) ;
118
119
119
120
if ( buildResult . exitCode ) {
120
- console . error ( `Error building ${ example } ` ) ;
121
121
console . error ( buildResult . stderr ) ;
122
- return ;
122
+ throw new Error ( `Error building ${ example } ` ) ;
123
123
}
124
124
125
125
const typecheck = await getCommand ( detected , "run" , [ "typecheck" ] ) ;
126
126
const typecheckArgs = typecheck . split ( " " ) . slice ( 1 ) ;
127
- console . log ( `🕵️ Typechecking ${ example } with ${ typecheck } ` ) ;
127
+ console . log ( `🕵️ Typechecking ${ example } with " ${ typecheck } " ` ) ;
128
128
const typecheckResult = await execa ( detected , typecheckArgs , options ) ;
129
129
130
130
if ( typecheckResult . exitCode ) {
131
- console . error ( `Error typechecking ${ example } ` ) ;
132
131
console . error ( typecheckResult . stderr ) ;
133
- return ;
132
+ throw new Error ( `Error typechecking ${ example } ` ) ;
134
133
}
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 ( ) ;
148
134
} ) ;
149
135
}
150
136
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