@cosmicjs/blocks
Advanced tools
Comparing version 0.0.826 to 0.0.827
28
index.js
@@ -107,3 +107,4 @@ #!/usr/bin/env node | ||
await blockGenerator(blockData, sourceFolderPath) | ||
const response = await blockGenerator(blockData, sourceFolderPath) | ||
return response | ||
} | ||
@@ -116,2 +117,3 @@ | ||
.action(async (components) => { | ||
let response | ||
const startTime = performance.now() | ||
@@ -122,7 +124,9 @@ for (const component of components) { | ||
chalk.red( | ||
`"${component}" is an invalid Block name. Please find a valid list of Blocks on cosmicjs.com/blocks` | ||
`"${component}" is an invalid Block name. Please find a valid list of Blocks on ${chalk.bold( | ||
"https://cosmicjs.com/blocks." | ||
)}` | ||
) | ||
) | ||
} else { | ||
await addComponent(component) | ||
response = await addComponent(component) | ||
} | ||
@@ -133,12 +137,14 @@ } | ||
if (speed < 10) | ||
if (response === "success") { | ||
if (speed < 5) | ||
console.log( | ||
chalk.greenBright(`ϟ Executed superfast in ${speed} seconds!`) | ||
) | ||
console.log( | ||
chalk.greenBright(`ϟ Executed superfast in ${speed} seconds!`) | ||
chalk.yellow( | ||
`➤ View more Blocks at ${chalk.bold("https://cosmicjs.com/blocks.")}` | ||
) | ||
) | ||
console.log( | ||
chalk.yellow( | ||
`➤ View more Blocks at ${chalk.bold("cosmicjs.com/blocks.")}` | ||
) | ||
) | ||
} | ||
}) | ||
@@ -145,0 +151,0 @@ |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.826", | ||
"version": "0.0.827", | ||
"description": "Cosmic blocks setup", | ||
@@ -10,0 +10,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ const { fontFamily } = require("tailwindcss/defaultTheme") | ||
"components/**/*.{ts,tsx}", | ||
"cosmic/**/*.{ts,tsx,js,jsx}", | ||
"./cosmic/**/*.{ts,tsx,js,jsx}", | ||
], | ||
@@ -12,0 +12,0 @@ theme: { |
@@ -15,2 +15,4 @@ import fs from "fs" | ||
let hasRanOnce = false | ||
async function blockGenerator(blockObject, sourceFolderPath) { | ||
@@ -20,2 +22,3 @@ const { installationSteps, executionSteps, name, elements } = blockObject | ||
// Step 0. Check to make sure the block isn't already installed | ||
const cosmicFolderPath = createCosmicFolder() | ||
@@ -30,2 +33,3 @@ const blocksPath = createBlocksFolder(cosmicFolderPath) | ||
// Overwrite prompt | ||
if (fs.existsSync(destinationFolderPath)) { | ||
@@ -159,2 +163,4 @@ const response = await prompts({ | ||
console.log(" ") | ||
hasRanOnce = true | ||
return "success" | ||
} catch (error) { | ||
@@ -174,3 +180,4 @@ if (error.code === "EEXIST") | ||
) | ||
return "" | ||
hasRanOnce = true | ||
return "failure" | ||
} | ||
@@ -180,4 +187,6 @@ } | ||
function updateTailwindFile() { | ||
const cosmicTailwindPath = "cosmic/**/*.{ts,tsx,js,jsx}" | ||
if (hasRanOnce) return | ||
const cosmicTailwindPath = "./cosmic/**/*.{ts,tsx,js,jsx}" | ||
const tailwindConfigPath = path.join(process.cwd(), "tailwind.config.js") | ||
@@ -202,5 +211,7 @@ const tailwindConfigTSPath = path.join(process.cwd(), "tailwind.config.ts") | ||
arrayString = arrayString.replace(/'/g, '"') | ||
arrayString = arrayString.replace(/'/g, '"').replace(/,(?=[^,]*$)/, "") | ||
arrayString = arrayString.replace(/,(?=[^,]*$)/, "") | ||
let parsedArray = JSON.parse(arrayString) | ||
const hasCosmicPath = parsedArray.includes(cosmicPath) | ||
const hasCosmicPath = Boolean( | ||
parsedArray.filter((arr) => arr.includes("/cosmic/")).length > 0 | ||
) | ||
if (!hasCosmicPath) { | ||
@@ -216,7 +227,3 @@ console.log("➤ Adding cosmic folder to tailwind config file...") | ||
console.log( | ||
chalk.yellowBright( | ||
"➤ Tailwind config updated. Please restart your server." | ||
) | ||
) | ||
console.log(chalk.green("✔ Tailwind config updated successfully!")) | ||
} | ||
@@ -223,0 +230,0 @@ } else { |
Sorry, the diff of this file is not supported yet
127101
2140