1
1
import { cloneLibraryRepo , readFile } from "../utils" ;
2
2
import fs from "fs/promises" ;
3
- import { exec } from "child_process" ;
3
+ import { exec , execSync } from "child_process" ;
4
4
import path from "path" ;
5
5
import { fileURLToPath } from "url" ;
6
6
import type { ParsedLibraryReference } from "../../../types/parsers.interface" ;
@@ -18,13 +18,16 @@ const yuidocOutputPath = path.join(__dirname, "out")
18
18
export const parseLibraryReference =
19
19
async ( ) : Promise < ParsedLibraryReference | null > => {
20
20
// Clone p5.js
21
- await cloneLibraryRepo ( localPath ) ;
21
+ await cloneLibraryRepo ( localPath , 'https://github.com/Garima3110/p5.js.git' , 'shaders' , { shouldFixAbsolutePathInPreprocessor : false } ) ;
22
22
// TODO(dave): let this happen via `npm run docs` in the p5 repo once we
23
23
// merge the 2.0 branch
24
- await saveYuidocOutput ( 'p5.js' , 'data-p5' , {
24
+ await createP5Docs ( 'p5.js' , 'data-p5' )
25
+ // If dev
26
+ await createP5Build ( 'p5.js' )
27
+ /*await saveYuidocOutput('p5.js', 'data-p5', {
25
28
flags: `--config ${path.join(__dirname, '../../../yuidoc.json')}`,
26
29
inputPath: './src',
27
- } ) ;
30
+ });*/
28
31
const p5Data = await getYuidocOutput ( 'data-p5' ) ;
29
32
if ( ! p5Data ) throw new Error ( 'Error generating p5 reference data!' ) ;
30
33
@@ -128,6 +131,31 @@ export const saveYuidocOutput = async (
128
131
}
129
132
} ;
130
133
134
+ export const createP5Docs = async ( inDirName : string , outDirName : string ) => {
135
+ execSync ( 'npm install' , {
136
+ cwd : path . join ( __dirname , 'in' , inDirName ) ,
137
+ } )
138
+ execSync ( 'npm run docs' , {
139
+ cwd : path . join ( __dirname , 'in' , inDirName ) ,
140
+ } )
141
+ const outputFilePath = path . join ( yuidocOutputPath , outDirName ) ;
142
+ await fs . mkdir ( outputFilePath , { recursive : true } )
143
+ await fs . cp (
144
+ path . join ( __dirname , 'in' , inDirName , 'docs' , 'reference' , 'data.json' ) ,
145
+ path . join ( outputFilePath , 'data.json' ) ,
146
+ )
147
+ }
148
+
149
+ export const createP5Build = async ( inDirName : string ) => {
150
+ execSync ( 'npm run build' , {
151
+ cwd : path . join ( __dirname , 'in' , inDirName )
152
+ } )
153
+ await fs . cp (
154
+ path . join ( __dirname , 'in' , inDirName , 'lib' , 'p5.min.js' ) ,
155
+ path . join ( __dirname , '../../../public' , 'p5.min.js' ) ,
156
+ )
157
+ }
158
+
131
159
export async function combineYuidocData (
132
160
inputData : ParsedLibraryReference [ ] ,
133
161
outDirName : string
0 commit comments