1
1
#!/usr/bin/env node
2
2
3
- import path from "node:path" ;
4
3
import os from "node:os" ;
4
+ import path from "node:path" ;
5
5
6
- import { execa } from "execa" ;
7
6
import { detect , getCommand } from "@antfu/ni" ;
7
+ import PackageJson from "@npmcli/package-json" ;
8
+ import { execa } from "execa" ;
8
9
import fse from "fs-extra" ;
9
10
import PQueue from "p-queue" ;
10
- import PackageJson from "@npmcli/package-json" ;
11
11
12
- console . log ( { concurrency : os . cpus ( ) . length } ) ;
12
+ const concurrency = os . cpus ( ) . length ;
13
+
14
+ console . log ( { concurrency } ) ;
13
15
14
- const queue = new PQueue ( { concurrency : os . cpus ( ) . length , autoStart : false } ) ;
16
+ const queue = new PQueue ( { concurrency, autoStart : false } ) ;
15
17
16
18
const TO_IGNORE = [ ".git" , ".github" , "__scripts" , "yarn.lock" , "package.json" ] ;
17
19
@@ -51,16 +53,6 @@ for (const example of examples) {
51
53
queue . add ( async ( ) => {
52
54
const pkgJson = await PackageJson . load ( example ) ;
53
55
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
-
64
56
/** @type {import('execa').Options } */
65
57
const options = { cwd : example , reject : false } ;
66
58
@@ -72,21 +64,21 @@ for (const example of examples) {
72
64
if ( hasSetup ) {
73
65
const setup = await getCommand ( detected , "run" , [ "__setup" ] ) ;
74
66
const setupArgs = setup . split ( " " ) . slice ( 1 ) ;
75
- console . log ( "🔧 Running setup script for" , example ) ;
67
+ console . log ( "🔧\u00A0Running setup script for" , example ) ;
76
68
const setupResult = await execa ( detected , setupArgs , options ) ;
77
69
if ( setupResult . exitCode ) {
78
70
console . error ( setupResult . stderr ) ;
79
71
throw new Error ( `Error running setup script for ${ example } ` ) ;
80
72
}
81
73
}
82
74
83
- const install = await getCommand ( detected , "install" , [
75
+ const installCommand = await getCommand ( detected , "install" , [
84
76
"--silent" ,
85
77
"--legacy-peer-deps" ,
86
78
] ) ;
87
79
// 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 } "` ) ;
90
82
const installResult = await execa ( detected , installArgs , options ) ;
91
83
92
84
if ( installResult . exitCode ) {
@@ -100,31 +92,33 @@ for (const example of examples) {
100
92
101
93
if ( hasPrisma ) {
102
94
console . log ( "Generating prisma types for" , example ) ;
103
- const prismaGenerate = await execa (
95
+ const prismaGenerateCommand = await execa (
104
96
"npx" ,
105
97
[ "prisma" , "generate" ] ,
106
98
options
107
99
) ;
108
100
109
- if ( prismaGenerate . exitCode ) {
110
- console . error ( prismaGenerate . stderr ) ;
101
+ if ( prismaGenerateCommand . exitCode ) {
102
+ console . error ( prismaGenerateCommand . stderr ) ;
111
103
throw new Error ( `Error generating prisma types for ${ example } ` ) ;
112
104
}
113
105
}
114
106
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 } "` ) ;
118
110
const buildResult = await execa ( detected , buildArgs , options ) ;
119
111
120
112
if ( buildResult . exitCode ) {
121
113
console . error ( buildResult . stderr ) ;
122
114
throw new Error ( `Error building ${ example } ` ) ;
123
115
}
124
116
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
+ ) ;
128
122
const typecheckResult = await execa ( detected , typecheckArgs , options ) ;
129
123
130
124
if ( typecheckResult . exitCode ) {
0 commit comments