create-ssam
Advanced tools
Comparing version 0.13.1 to 0.13.2
@@ -13,8 +13,4 @@ import fs from 'fs'; | ||
var package_default = { | ||
version: "0.13.1"}; | ||
// src/index.ts | ||
var log = console.log; | ||
version: "0.13.2"}; | ||
var { red, green, yellow, blue, magenta, white, bold } = kleur; | ||
var cwd = process.cwd(); | ||
var packs = { | ||
@@ -40,3 +36,3 @@ // ssam | ||
"thing-color-palettes": "@thi.ng/color-palettes@1.4.33", | ||
// | ||
// daeinc packs | ||
"daeinc-draw": "@daeinc/draw@0.6.1", | ||
@@ -48,6 +44,6 @@ "daeinc-geom": "@daeinc/geom@0.12.0", | ||
"daeinc-timeline": "@daeinc/timeline@0.5.2", | ||
// | ||
// random | ||
"thing-arrays": "@thi.ng/arrays@2.10.15", | ||
"thing-random": "@thi.ng/random@4.1.11", | ||
// | ||
// animation | ||
eases: "eases@1.0.8", | ||
@@ -60,41 +56,2 @@ "types-eases": "@types/eases@1.0.4" | ||
var viteGlslPkg = `${packs["glsl"]}`; | ||
var extraPacks = [ | ||
{ | ||
title: `Color`, | ||
description: "Install @thi.ng/color and @thi.ng/color-palettes", | ||
value: { | ||
dep: `${packs["thing-color"]} ${packs["thing-color-palettes"]}` | ||
} | ||
}, | ||
{ | ||
title: `Daeinc Pack`, | ||
description: "Install @daeinc/math, @daeinc/geom and @daeinc/draw", | ||
value: { | ||
dep: `${packs["daeinc-math"]} ${packs["daeinc-geom"]} ${packs["daeinc-draw"]}` | ||
} | ||
}, | ||
// NOTE: Lygia extra install is disabled because | ||
// Lygia is installed via supported templates AND here (twice). | ||
// maybe, check if template uses lygia, and decide to include or not? | ||
// { | ||
// title: `Lygia (GLSL)`, | ||
// description: "Git clone Lygia shader library", | ||
// value: { | ||
// git: `git clone --no-tags --depth 1 --single-branch --branch=main https://github.com/patriciogonzalezvivo/lygia.git`, | ||
// }, | ||
// }, | ||
{ | ||
title: `Random`, | ||
description: "Install @thi.ng/random and @thi.ng/arrays", | ||
value: { dep: `${packs["thing-random"]} ${packs["thing-arrays"]}` } | ||
}, | ||
{ | ||
title: `Animation`, | ||
description: "Install @daeinc/pd-timeline, @daeinc/timeline, @daeinc/keyframes and eases", | ||
value: { | ||
dep: `${packs["eases"]} ${packs["daeinc-pd-timeline"]} ${packs["daeinc-timeline"]} ${packs["daeinc-keyframes"]}`, | ||
devDep: `${packs["types-eases"]}` | ||
} | ||
} | ||
]; | ||
var templates = [ | ||
@@ -228,2 +185,36 @@ { | ||
]; | ||
var extraPacks = [ | ||
{ | ||
title: `Color`, | ||
description: "Install @thi.ng/color and @thi.ng/color-palettes", | ||
value: { | ||
dep: `${packs["thing-color"]} ${packs["thing-color-palettes"]}` | ||
} | ||
}, | ||
{ | ||
title: `Daeinc Pack`, | ||
description: "Install @daeinc/math, @daeinc/geom and @daeinc/draw", | ||
value: { | ||
dep: `${packs["daeinc-math"]} ${packs["daeinc-geom"]} ${packs["daeinc-draw"]}` | ||
} | ||
}, | ||
{ | ||
title: `Random`, | ||
description: "Install @thi.ng/random and @thi.ng/arrays", | ||
value: { dep: `${packs["thing-random"]} ${packs["thing-arrays"]}` } | ||
}, | ||
{ | ||
title: `Animation`, | ||
description: "Install @daeinc/pd-timeline, @daeinc/timeline, @daeinc/keyframes and eases", | ||
value: { | ||
dep: `${packs["eases"]} ${packs["daeinc-pd-timeline"]} ${packs["daeinc-timeline"]} ${packs["daeinc-keyframes"]}`, | ||
devDep: `${packs["types-eases"]}` | ||
} | ||
} | ||
]; | ||
// src/index.ts | ||
var log = console.log; | ||
var { red: red2, green: green2, bold: bold2 } = kleur; | ||
var cwd = process.cwd(); | ||
var renameFiles = { | ||
@@ -236,3 +227,3 @@ _gitignore: ".gitignore", | ||
log( | ||
`${green( | ||
`${green2( | ||
figlet.textSync("create ssam", { | ||
@@ -244,4 +235,4 @@ font: "Ogre", | ||
); | ||
log(green(`v${package_default.version}`)); | ||
log(bold().white(`Let's create a new sketch with ssam/\uC308. | ||
log(green2(`v${package_default.version}`)); | ||
log(bold2().white(`Let's create a new sketch with ssam/\uC308. | ||
`)); | ||
@@ -261,3 +252,3 @@ async function init() { | ||
onState: (state) => { | ||
targetDir = formatTargetDir(state.value) || defaultTargetDir; | ||
targetDir = formatTargetDir(toValidPackageName(state.value)) || defaultTargetDir; | ||
} | ||
@@ -272,3 +263,3 @@ }, | ||
throw new Error( | ||
red("\u2716") + ` Target directory "${targetDir}" is not empty. Try again with another name or empty the directory first.` | ||
red2("\u2716") + ` Target directory "${targetDir}" is not empty. Try again with another name or empty the directory first.` | ||
); | ||
@@ -283,3 +274,3 @@ } | ||
if (overwrite2 === false) { | ||
throw new Error(red("\u2716") + " Operation cancelled"); | ||
throw new Error(red2("\u2716") + " Operation cancelled"); | ||
} | ||
@@ -338,3 +329,3 @@ return null; | ||
onCancel: () => { | ||
throw new Error(red("\u2716") + " cancelled"); | ||
throw new Error(red2("\u2716") + " cancelled"); | ||
} | ||
@@ -363,3 +354,3 @@ } | ||
); | ||
const write = (file, content) => { | ||
const write = (fromDir, file, content) => { | ||
const targetPath = path.join(root, renameFiles[file] ?? file); | ||
@@ -369,9 +360,26 @@ if (content) { | ||
} else { | ||
copy(path.join(templateDir, file), targetPath); | ||
copy(path.join(fromDir, file), targetPath); | ||
} | ||
}; | ||
const files = fs.readdirSync(templateDir); | ||
for (const file of files.filter((f) => f !== "package.json")) { | ||
write(file); | ||
const templateFiles = fs.readdirSync(templateDir); | ||
for (const file of templateFiles.filter((f) => f !== "package.json")) { | ||
write(templateDir, file); | ||
} | ||
const commonFilesDir = path.resolve( | ||
fileURLToPath(import.meta.url), | ||
// `import.meta.url` returns `<project>/dist/index.js` | ||
"../..", | ||
`templates/_commons` | ||
); | ||
const commonFiles = fs.readdirSync(commonFilesDir); | ||
for (const file of commonFiles) { | ||
if (file === `README.md`) { | ||
const title = getProjectName(); | ||
write(commonFilesDir, file, `# ${title} | ||
`); | ||
console.log(title); | ||
} else { | ||
write(commonFilesDir, file); | ||
} | ||
} | ||
const pkg = JSON.parse( | ||
@@ -381,3 +389,3 @@ fs.readFileSync(path.join(templateDir, `package.json`), "utf-8") | ||
pkg.name = packageName || getProjectName(); | ||
write("package.json", JSON.stringify(pkg, null, 2)); | ||
write(templateDir, "package.json", JSON.stringify(pkg, null, 2)); | ||
const { installCommands } = templates.flatMap((t) => t.options).find((o) => o.name === option) ?? {}; | ||
@@ -427,3 +435,3 @@ const toInstall = ["npm install"]; | ||
if (root !== cwd) { | ||
console.log(` ${bold(`cd`)} ${path.relative(cwd, root)}`); | ||
console.log(` ${bold2(`cd`)} ${path.relative(cwd, root)}`); | ||
} | ||
@@ -430,0 +438,0 @@ switch (pkgManager) { |
{ | ||
"name": "create-ssam", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "Quickstart a creative coding sketch with ssam", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -28,2 +28,3 @@ # create-ssam | ||
- Fullscreen Shader TS with Lygia | ||
- WebGPU TS | ||
- Fullscreen Shader JS with Lygia | ||
@@ -42,3 +43,3 @@ - StableDiffusion | ||
- `npm version <patch/minor/major` and then, `npm run build` so the correct packageJson version will be included in the dist. | ||
- `npm version <patch/minor/major>` and then, `npm run build` so the correct packageJson version will be included in the dist. | ||
@@ -45,0 +46,0 @@ ## License |
1483
49
91472
76