MCPcopy Create free account
hub / github.com/CedarCopilot/cedar-OS / addSaplingCommand

Function addSaplingCommand

packages/cli/src/commands/add-sapling.ts:46–138  ·  view source on GitHub ↗
(options: AddSaplingOptions)

Source from the content-addressed store, hash-verified

44// an existing project. It's designed to be called both directly via the
45// add-sapling command and indirectly from the plant-seed command.
46export async function addSaplingCommand(options: AddSaplingOptions) {
47 intro(pc.bgCyan(pc.black(' cedar add-sapling ')));
48 console.log(pc.green("Welcome to Cedar-OS, let's get you set up!"));
49
50 try {
51 // STEP 1: INSTALLATION MODE (LOCAL ONLY)
52 // ==========================================================================
53 // The CLI previously allowed installing cedar-os-components from npm directly.
54 // We now enforce local source downloads only, so we skip the old prompt/branch.
55
56 // Otherwise continue with local installation
57 console.log(
58 pc.cyan(
59 '🌱 Adding saplings to your Cedar forest (downloading components)...'
60 )
61 );
62
63 // Check if directory already exists for confirmation prompt
64 const targetDir = options.dir || 'src/cedar/components';
65 const dirExists = await checkDirectoryExists(targetDir);
66 if (dirExists && !options.yes) {
67 const shouldContinue = await p.confirm({
68 message: `Directory ${pc.cyan(targetDir)} already exists. Continue?`,
69 initialValue: false,
70 });
71
72 if (p.isCancel(shouldContinue) || !shouldContinue) {
73 p.cancel('Operation cancelled.');
74 process.exit(0);
75 }
76 }
77
78 // ==========================================================================
79 // STEP 2: ENSURE TAILWIND CSS IS SET UP
80 // ==========================================================================
81 await ensureTailwindSetup(targetDir);
82
83 // ==========================================================================
84 // STEP 3: USE DOWNLOAD COMPONENTS FLOW
85 // ==========================================================================
86 // Always include these core dependencies for Cedar components
87 const coreDeps = ['lucide-react', 'motion', 'motion-plus-react'];
88
89 const result = await downloadComponentsFlow(
90 options as ComponentDownloadOptions,
91 {
92 promptMessage: 'Which components would you like to install?',
93 filterDependencies: (deps) => {
94 return [...new Set([...coreDeps, ...deps])].filter(
95 (dep) => dep !== 'react'
96 );
97 },
98 }
99 );
100
101 // ==========================================================================
102 // STEP 4: INSTALL CEDAR-OS PACKAGE
103 // ==========================================================================

Callers 1

runCedarAddFunction · 0.90

Calls 6

checkDirectoryExistsFunction · 0.90
ensureTailwindSetupFunction · 0.90
downloadComponentsFlowFunction · 0.90
detectPackageManagerFunction · 0.90
runCommandFunction · 0.90
showLocalImportStepsFunction · 0.90

Tested by

no test coverage detected