chore: removed emojis from CLI
912879e3
1 file(s) · +23 −30
| 32 | 32 | const configContent = await readFile(CONFIG_FILE, "utf8"); |
|
| 33 | 33 | return JSON.parse(configContent); |
|
| 34 | 34 | } catch (error) { |
|
| 35 | - | console.error(`❌ Failed to load ${CONFIG_FILE}:`, error); |
|
| 35 | + | console.error(`✗ Failed to load ${CONFIG_FILE}:`, error); |
|
| 36 | 36 | return null; |
|
| 37 | 37 | } |
|
| 38 | 38 | } |
|
| 41 | 41 | try { |
|
| 42 | 42 | await writeFile(CONFIG_FILE, JSON.stringify(config, null, 2), "utf8"); |
|
| 43 | 43 | } catch (error) { |
|
| 44 | - | console.error(`❌ Failed to save ${CONFIG_FILE}:`, error); |
|
| 44 | + | console.error(`✗ Failed to save ${CONFIG_FILE}:`, error); |
|
| 45 | 45 | throw error; |
|
| 46 | 46 | } |
|
| 47 | 47 | } |
|
| 68 | 68 | } |
|
| 69 | 69 | ||
| 70 | 70 | async function init() { |
|
| 71 | - | console.log("🧙 Initializing norns project..."); |
|
| 71 | + | console.log("⚡ Initializing norns project..."); |
|
| 72 | 72 | ||
| 73 | 73 | // Check if components.json already exists |
|
| 74 | 74 | if (existsSync(CONFIG_FILE)) { |
|
| 75 | - | console.log(`📁 ${CONFIG_FILE} already exists`); |
|
| 75 | + | console.log(`▸ ${CONFIG_FILE} already exists`); |
|
| 76 | 76 | const overwrite = await promptUser( |
|
| 77 | 77 | "Would you like to overwrite it? (y/N)", |
|
| 78 | 78 | "n", |
|
| 79 | 79 | ); |
|
| 80 | 80 | if (overwrite.toLowerCase() !== "y" && overwrite.toLowerCase() !== "yes") { |
|
| 81 | - | console.log("⏹️ Initialization cancelled"); |
|
| 81 | + | console.log("✗ Initialization cancelled"); |
|
| 82 | 82 | return; |
|
| 83 | 83 | } |
|
| 84 | 84 | } |
|
| 85 | 85 | ||
| 86 | - | console.log("\n📋 Setting up your components configuration...\n"); |
|
| 86 | + | console.log("\n▸ Setting up your components configuration...\n"); |
|
| 87 | 87 | ||
| 88 | 88 | // Get component directory path |
|
| 89 | 89 | const componentsPath = await promptUser( |
|
| 99 | 99 | // Create components directory if it doesn't exist |
|
| 100 | 100 | if (!existsSync(componentsPath)) { |
|
| 101 | 101 | await mkdir(componentsPath, { recursive: true }); |
|
| 102 | - | console.log(`✅ Created ${componentsPath} directory`); |
|
| 102 | + | console.log(`✓ Created ${componentsPath} directory`); |
|
| 103 | 103 | } |
|
| 104 | 104 | ||
| 105 | 105 | // Save the configuration |
|
| 106 | 106 | await saveConfig(config); |
|
| 107 | - | console.log(`✅ Created ${CONFIG_FILE}`); |
|
| 107 | + | console.log(`✓ Created ${CONFIG_FILE}`); |
|
| 108 | 108 | ||
| 109 | 109 | console.log( |
|
| 110 | - | "\n🎉 norns project initialized! You can now add components with:", |
|
| 110 | + | "\n✓ norns project initialized! You can now add components with:", |
|
| 111 | 111 | ); |
|
| 112 | 112 | console.log(" npx norns@latest add <component-name>"); |
|
| 113 | - | console.log(`\n📁 Components will be installed to: ${componentsPath}`); |
|
| 113 | + | console.log(`\n▸ Components will be installed to: ${componentsPath}`); |
|
| 114 | 114 | } |
|
| 115 | 115 | ||
| 116 | 116 | async function addComponent(componentName: string | undefined) { |
|
| 117 | 117 | if (!componentName) { |
|
| 118 | - | console.error("❌ Please specify a component name"); |
|
| 118 | + | console.error("✗ Please specify a component name"); |
|
| 119 | 119 | console.log("Usage: npx norns@latest add <component-name>"); |
|
| 120 | 120 | process.exit(1); |
|
| 121 | 121 | } |
|
| 122 | 122 | ||
| 123 | - | console.log(`🔄 Adding component: ${componentName}`); |
|
| 123 | + | console.log(`▸ Adding component: ${componentName}`); |
|
| 124 | 124 | ||
| 125 | 125 | // Load configuration |
|
| 126 | 126 | let config = await loadConfig(); |
|
| 127 | 127 | ||
| 128 | 128 | // If no config exists, ask user to run init first or use defaults |
|
| 129 | 129 | if (!config) { |
|
| 130 | - | console.log("📋 No norns.json found."); |
|
| 130 | + | console.log("▸ No norns.json found."); |
|
| 131 | 131 | const shouldInit = await promptUser( |
|
| 132 | 132 | "Would you like to run 'norns init' first? (Y/n)", |
|
| 133 | 133 | "y", |
|
| 141 | 141 | await init(); |
|
| 142 | 142 | config = await loadConfig(); |
|
| 143 | 143 | } else { |
|
| 144 | - | console.log("📁 Using default configuration..."); |
|
| 144 | + | console.log("▸ Using default configuration..."); |
|
| 145 | 145 | config = DEFAULT_CONFIG; |
|
| 146 | 146 | } |
|
| 147 | 147 | } |
|
| 148 | 148 | ||
| 149 | 149 | if (!config) { |
|
| 150 | - | console.error("❌ Failed to initialize configuration"); |
|
| 150 | + | console.error("✗ Failed to initialize configuration"); |
|
| 151 | 151 | process.exit(1); |
|
| 152 | 152 | } |
|
| 153 | 153 | ||
| 156 | 156 | // Create components directory if it doesn't exist |
|
| 157 | 157 | if (!existsSync(componentsDir)) { |
|
| 158 | 158 | console.log( |
|
| 159 | - | `📁 Components directory doesn't exist. Creating ${componentsDir}...`, |
|
| 159 | + | `▸ Components directory doesn't exist. Creating ${componentsDir}...`, |
|
| 160 | 160 | ); |
|
| 161 | 161 | await mkdir(componentsDir, { recursive: true }); |
|
| 162 | 162 | } |
|
| 165 | 165 | const sourceComponentPath = join(COMPONENTS_DIR, `${componentName}.js`); |
|
| 166 | 166 | ||
| 167 | 167 | if (!existsSync(sourceComponentPath)) { |
|
| 168 | - | console.error(`❌ Component '${componentName}' not found`); |
|
| 168 | + | console.error(`✗ Component '${componentName}' not found`); |
|
| 169 | 169 | console.log("Available components:"); |
|
| 170 | 170 | console.log(" - connect-wallet"); |
|
| 171 | 171 | console.log(" - contract-call"); |
|
| 177 | 177 | ||
| 178 | 178 | await writeFile(componentPath, componentCode, "utf8"); |
|
| 179 | 179 | ||
| 180 | - | console.log(`✅ Added ${componentName} to ${componentPath}`); |
|
| 181 | - | console.log(`📝 You can now use it in your HTML:`); |
|
| 182 | - | ||
| 183 | - | // Calculate relative path from project root |
|
| 184 | - | const relativePath = componentsDir.startsWith("./") |
|
| 185 | - | ? componentsDir |
|
| 186 | - | : `./${componentsDir}`; |
|
| 187 | - | console.log( |
|
| 188 | - | ` <script src="${relativePath}/${componentName}.js"></script>`, |
|
| 189 | - | ); |
|
| 180 | + | console.log(`✓ Added ${componentName} to ${componentPath}`); |
|
| 181 | + | console.log(`▸ You can now use it in your HTML:`); |
|
| 182 | + | console.log(` <script src="components/${componentName}.js"></script>`); |
|
| 190 | 183 | console.log(` <${componentName}></${componentName}>`); |
|
| 191 | 184 | } catch (error) { |
|
| 192 | - | console.error(`❌ Failed to add component: ${error}`); |
|
| 185 | + | console.error(`✗ Failed to add component: ${error}`); |
|
| 193 | 186 | process.exit(1); |
|
| 194 | 187 | } |
|
| 195 | 188 | } |
|
| 196 | 189 | ||
| 197 | 190 | function showHelp() { |
|
| 198 | 191 | console.log(` |
|
| 199 | - | 🧙 norns - Web Component Library CLI |
|
| 192 | + | ⚡ norns - Web Component Library CLI |
|
| 200 | 193 | ||
| 201 | 194 | Usage: |
|
| 202 | 195 | npx norns@latest init Initialize a new norns project with norns.json |
|
| 254 | 247 | if (!command) { |
|
| 255 | 248 | showHelp(); |
|
| 256 | 249 | } else { |
|
| 257 | - | console.error(`❌ Unknown command: ${command}`); |
|
| 250 | + | console.error(`✗ Unknown command: ${command}`); |
|
| 258 | 251 | showHelp(); |
|
| 259 | 252 | process.exit(1); |
|
| 260 | 253 | } |
|