create-ssam
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -32,3 +32,3 @@ import fs from 'fs'; | ||
color: yellow, | ||
customCommand: `npm install ssam@latest --prefix TARGET_DIR` | ||
customCommands: [`npm install ssam@latest --prefix TARGET_DIR`] | ||
} | ||
@@ -52,2 +52,13 @@ ] | ||
{ | ||
name: "ogl-shader-lygia-ts", | ||
display: "Fullscreen Shader TS (Lygia + git)", | ||
color: blue, | ||
customCommands: [ | ||
`git init`, | ||
`git submodule add https://github.com/patriciogonzalezvivo/lygia.git`, | ||
`npm install ssam@latest ogl@latest --prefix TARGET_DIR`, | ||
`npm install -D @types/node @types/ogl@npm:ogl-types vite-plugin-glsl@latest --prefix TARGET_DIR` | ||
] | ||
}, | ||
{ | ||
name: "ogl-cube-ts", | ||
@@ -78,6 +89,31 @@ display: "Basic Cube Scene TS", | ||
{ | ||
name: "three-shader-lygia-ts", | ||
display: "Fullscreen Shader TS (Lygia + git)", | ||
color: blue, | ||
customCommands: [ | ||
`git init`, | ||
`git submodule add https://github.com/patriciogonzalezvivo/lygia.git`, | ||
`npm install ssam@latest three@latest --prefix TARGET_DIR`, | ||
`npm install -D @types/node @types/three vite-plugin-glsl@latest --prefix TARGET_DIR` | ||
] | ||
}, | ||
{ | ||
name: "three-shader-js", | ||
display: "Fullscreen Shader JS", | ||
color: yellow, | ||
customCommand: `npm install ssam@latest three@latest vite-plugin-glsl@latest --prefix TARGET_DIR` | ||
customCommands: [ | ||
`npm install ssam@latest three@latest --prefix TARGET_DIR`, | ||
`npm install -D vite-plugin-glsl@latest --prefix TARGET_DIR` | ||
] | ||
}, | ||
{ | ||
name: "three-shader-lygia-js", | ||
display: "Fullscreen Shader JS (Lygia + git)", | ||
color: yellow, | ||
customCommands: [ | ||
`git init`, | ||
`git submodule add https://github.com/patriciogonzalezvivo/lygia.git`, | ||
`npm install ssam@latest three@latest --prefix TARGET_DIR`, | ||
`npm install -D vite-plugin-glsl@latest --prefix TARGET_DIR` | ||
] | ||
} | ||
@@ -212,6 +248,6 @@ ] | ||
write("package.json", JSON.stringify(pkg, null, 2)); | ||
const { customCommand, customCommands } = templates.flatMap((t) => t.options).find((o) => o.name === option) ?? {}; | ||
const { customCommands } = templates.flatMap((t) => t.options).find((o) => o.name === option) ?? {}; | ||
if (customCommands) { | ||
customCommands.forEach((customCommand2) => { | ||
const fullCustomCommand = customCommand2.replace("TARGET_DIR", targetDir).replace(/^npm create/, `${pkgManager} create`).replace(/^npm install/, `${pkgManager} install`).replace("@latest", () => isYarn1 ? "" : "@latest").replace(/^npm exec/, () => { | ||
customCommands.forEach((customCommand) => { | ||
const fullCustomCommand = customCommand.replace("TARGET_DIR", targetDir).replace(/^npm create/, `${pkgManager} create`).replace(/^npm install/, `${pkgManager} install`).replace("@latest", () => isYarn1 ? "" : "@latest").replace(/^npm exec/, () => { | ||
if (pkgManager === "pnpm") { | ||
@@ -227,22 +263,7 @@ return "pnpm dlx"; | ||
spawn.sync(command, args, { | ||
stdio: "inherit" | ||
stdio: "inherit", | ||
cwd: command.startsWith(`git`) ? targetDir : `.` | ||
}); | ||
}); | ||
} | ||
if (customCommand) { | ||
const fullCustomCommand = customCommand.replace("TARGET_DIR", targetDir).replace(/^npm create/, `${pkgManager} create`).replace(/^npm install/, `${pkgManager} install`).replace("@latest", () => isYarn1 ? "" : "@latest").replace(/^npm exec/, () => { | ||
if (pkgManager === "pnpm") { | ||
return "pnpm dlx"; | ||
} | ||
if (pkgManager === "yarn" && !isYarn1) { | ||
return "yarn dlx"; | ||
} | ||
return "npm exec"; | ||
}); | ||
const [command, ...args] = fullCustomCommand.split(" "); | ||
const { status } = spawn.sync(command, args, { | ||
stdio: "inherit" | ||
}); | ||
console.log(status); | ||
} | ||
console.log(` | ||
@@ -249,0 +270,0 @@ Done. Now run: |
{ | ||
"name": "create-ssam", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Quickstart a creative coding sketch with ssam", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -50,2 +50,7 @@ import { ssam } from "ssam"; | ||
}; | ||
wrap.unload = () => { | ||
renderer.dispose(); | ||
renderer.forceContextLoss(); | ||
}; | ||
}; | ||
@@ -52,0 +57,0 @@ |
@@ -50,2 +50,7 @@ import { Sketch, SketchSettings, ssam, WebGLProps } from "ssam"; | ||
}; | ||
wrap.unload = () => { | ||
renderer.dispose(); | ||
renderer.forceContextLoss(); | ||
}; | ||
}; | ||
@@ -52,0 +57,0 @@ |
96083
92
1578
3